Plotting parametric matrix discriminants
Greetings, I am struggling with the problem concerting characteristic polynomial determinants. I'm intending to plot curves in the (a,b)-plane of parametric matrices, which signal the points of some eigenvalues being zero. To this end, I use the following code
var('a b')
A = matrix([[a+sqrt(-1)b,-1,0],[-1,0,-1],[0,-1,a-sqrt(-1)b]])
p=A.charpoly('t')
d=p.discriminant()
region_plot(d>=0, (a,-4,1), (b,-4,1),incol='gray',figsize=5,axes=true)
which however produces the error
File "handle_error.pyx", line 90, in sage.libs.pari.handle_error._pari_handle_exception (build/cythonized/sage/libs/pari/handle_error.c:1178) sage.libs.pari.gen.PariError: incorrect type in gtofp
Printing the discriminant explicitly and then plotting it works fine
var('a b')
A = matrix([[a+sqrt(-1)*b,-1,0],[-1,0,-1],[0,-1,a-sqrt(-1)*b]])
p=A.charpoly('t')
d=p.discriminant()
d2=-4*b^2*a^4 + (-8*b^4 - 40*b^2 + 4)*a^2 + (-4*b^6 + 24*b^4 - 48*b^2 + 32)
region_plot(d2>=0, (a,-2,2), (b,-2,2),incol='gray',figsize=5,axes=true)
although both quantities seem to be of the same type
<type 'sage.symbolic.expression.Expression'>
any ideas about what am I missing?
Missing a `*` between sqrt(-1) and b in the first example ?