1 | initial version |

Something odd is definitely happening here, and I am not the one to help on this situation. But, here is some code that will get the plot you want. It's a bit brute force and not as elegant as your approach, but it does work.

```
H=matrix([[1+x, 0, x],[0, 2, 2*x],[x, 2*x, 1+x]])
pts0=[]
pts1=[]
pts2=[]
xlist=srange(0,0.5,0.01)
ans=[map(lambda x: n(real_part(x)),H.subs(x=x0).eigenvalues()) for x0 in xlist]
ans=[sorted(a) for a in ans]
for i in range(0,len(xlist)):
pts0.append([xlist[i],ans[i][0]])
pts1.append([xlist[i],ans[i][1]])
pts2.append([xlist[i],ans[i][2]])
list_plot(pts0,plotjoined=true,color='red')+list_plot(pts1,plotjoined=true,color='blue')+list_plot(pts2,plotjoined=true,color='green')
```

2 | No.2 Revision |

Something odd is definitely happening here, and I am not the one to help on this situation. But, here is some code that will get the plot you want. It's a bit brute force and not as elegant as your approach, but it does work.

```
H=matrix([[1+x, 0, x],[0, 2, 2*x],[x, 2*x, 1+x]])
pts0=[]
pts1=[]
pts2=[]
xlist=srange(0,0.5,0.01)
ans=[map(lambda x: n(real_part(x)),H.subs(x=x0).eigenvalues()) for x0 in xlist]
ans=[sorted(a) for a in ans]
for i in range(0,len(xlist)):
pts0.append([xlist[i],ans[i][0]])
pts1.append([xlist[i],ans[i][1]])
pts2.append([xlist[i],ans[i][2]])
list_plot(pts0,plotjoined=true,color='red')+list_plot(pts1,plotjoined=true,color='blue')+list_plot(pts2,plotjoined=true,color='green')
```

Using the characteristic polynomial and the `implicit_plot`

command also gives a really nice plot.

var('y')
H=matrix([[1+x, 0, x],[0, 2, 2*x],[x, 2*x, 1+x]])
p(x,y)=H.charpoly('y')
implicit_plot(p(x,y),(x,-3,5),(y,0,5))

3 | No.3 Revision |

Something odd is definitely happening here, and I am not the one to help on this situation. But, here is some code that will get the plot you want. It's a bit brute force and not as elegant as your approach, but it does work.

```
H=matrix([[1+x, 0, x],[0, 2, 2*x],[x, 2*x, 1+x]])
pts0=[]
pts1=[]
pts2=[]
xlist=srange(0,0.5,0.01)
ans=[map(lambda x: n(real_part(x)),H.subs(x=x0).eigenvalues()) for x0 in xlist]
ans=[sorted(a) for a in ans]
for i in range(0,len(xlist)):
pts0.append([xlist[i],ans[i][0]])
pts1.append([xlist[i],ans[i][1]])
pts2.append([xlist[i],ans[i][2]])
list_plot(pts0,plotjoined=true,color='red')+list_plot(pts1,plotjoined=true,color='blue')+list_plot(pts2,plotjoined=true,color='green')
```

Using the characteristic polynomial and the `implicit_plot`

command also gives a really nice plot.

```
var('y')
H=matrix([[1+x, 0, x],[0, 2,
```~~2~~*x],[x, 2*x, 2*x],[x, 2*x, 1+x]])
p(x,y)=H.charpoly('y')
~~implicit_plot(p(x,y),(x,-3,5),(y,0,5))~~implicit_plot(p(x,y),(x,-3,5),(y,0,5))

4 | No.4 Revision |

```
H=matrix([[1+x, 0, x],[0, 2, 2*x],[x, 2*x, 1+x]])
pts0=[]
pts1=[]
pts2=[]
xlist=srange(0,0.5,0.01)
ans=[map(lambda x: n(real_part(x)),H.subs(x=x0).eigenvalues()) for x0 in xlist]
ans=[sorted(a) for a in ans]
for i in range(0,len(xlist)):
pts0.append([xlist[i],ans[i][0]])
pts1.append([xlist[i],ans[i][1]])
pts2.append([xlist[i],ans[i][2]])
list_plot(pts0,plotjoined=true,color='red')+list_plot(pts1,plotjoined=true,color='blue')+list_plot(pts2,plotjoined=true,color='green')
```

Using the characteristic polynomial and the `implicit_plot`

command also gives a really nice plot.

```
var('y')
H=matrix([[1+x, 0, x],[0, 2, 2*x],[x, 2*x, 1+x]])
p(x,y)=H.charpoly('y')
implicit_plot(p(x,y),(x,-3,5),(y,0,5))
```

You can also use `contour_plot`

to color the regions in the plane by sign.

```
contour_plot(p(x,y),(x,-3,5),(y,0,5),contours=0,cmap=['red','blue'])
```

Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.