eigensys.py

Created by cesphoto

Created on March 13, 2024

529 Bytes

Calculates eigenvalues and eigenvectors for a 2 by 2 matrix.


from math import *
from cmath import *

def es(a, b, c, d):
  #a = float(input('a=')
  #b = float(input('b='))
  #c = float(input('c='))
  #d = float(input('d='))# Type your text here
  
  D = (a-d)**2+4*b*c
  l1 = (a+d+sqrt(D))/2
  l2 = (a+d-sqrt(D))/2

  if D>=0:
    l1 = l1.real
  if D>=0:
    l2 = l2.real


  v1 = [b/(l1-a), 1]
  v2 = [b/(l2-a), 1]

  print()
  print("A=",[[a,b],[c,d]])
  print()
  print("lambda_1=", l1)
  print("     v_1=", v1)
  print()
  print("lambda_2=", l2)
  print("     v_2=", v2)

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.