Ask Your Question

wrighteap's profile - activity

2023-05-03 14:19:56 +0200 received badge  Famous Question (source)
2017-12-04 11:42:21 +0200 received badge  Notable Question (source)
2016-02-18 02:52:29 +0200 received badge  Popular Question (source)
2013-01-02 12:51:00 +0200 marked best answer Plotting eigenvalues as a function of a variable

In this approach you can check that the eigenvalues are real:

reset()
f=lambda x:matrix([[1+x, 0, x],[0, 2, 2*x],[x, 2*x, 1+x]]).eigenvalues()
#the first ***real*** eigenvalue versus x 
l0=[[x,f(x)[0]] for x in srange(0,0.5,0.01)]
p0=list_plot(l0,plotjoined=true)
#the second eigenvalue
l1=[[x,f(x)[1]] for x in srange(0,0.5,0.01)]
p1=list_plot(l1,plotjoined=true)
#the third eigenvalue
l2=[[x,f(x)[2]] for x in srange(0,0.5,0.01)]
p2=list_plot(l2,plotjoined=true)
# all
show(p0+p1+p2)
2013-01-02 12:51:00 +0200 received badge  Scholar (source)
2013-01-02 12:50:50 +0200 received badge  Supporter (source)
2013-01-02 12:50:36 +0200 commented answer Plotting eigenvalues as a function of a variable

Very elegant thanks.

2013-01-02 07:23:02 +0200 commented answer Plotting eigenvalues as a function of a variable

Thank you very much, at least now I have a working method. The real problem here is my knowledge of programming is somewhat limited so I don't understand what the eigenvalues() method is doing under the hood. One thing that struck me as odd is that both a[0] and a[1] take on complex values for different values of x when H is a hermitian matrix. Granted this could be a computational thing because the complex parts are of order 10^-15 and -19 for the values of x I tried, i.e. effectively 0.

2013-01-01 17:15:30 +0200 received badge  Student (source)
2013-01-01 15:31:59 +0200 received badge  Editor (source)
2013-01-01 15:30:29 +0200 asked a question Plotting eigenvalues as a function of a variable

I am attempting to plot the the eigenvalues for the matrix:

H=matrix([[1+x, 0, x],[0, 2, 2*x],[x, 2*x, 1+x]])

which were calculated using the following method:

a=H.eigenvalues()

in the following way:

h=fast_callable(real_part(a[2]),vars=[x],domain=CC)

plot(h,(0,0.5))

but unfortunately this does not work for a[0] and a[1],

f=fast_callable(real_part(a[0]),vars=[x],domain=CC)
g=fast_callable(real_part(a[1]),vars=[x],domain=CC)

plot(f,(0,0.5))+plot(g,(0,0.5))

Any suggestions would be greatly appreciated.