# Zero solution does not result in zero

The following looks like a bug to me, but I would value a second opinion:

----------------------------------------------------------------------
| Sage Version 5.8, Release Date: 2013-03-15                         |
| Type "notebook()" for the browser-based notebook interface.        |
| Type "help()" for help.                                            |
----------------------------------------------------------------------
sage: phi = var('phi', domain='real')
sage: M = Matrix([
....: [-sqrt(-I)/(exp(I*phi)-1), sqrt(-I)/(exp(I*phi)-1)],
....: [-1/(exp(I*phi)-1)+exp(-I*phi), 1/(exp(I*phi)-1)]])
sage: z = M*vector((-I, 1))
sage: z = z/z
sage: zi = z.imag_part()
sage: s1 = [s.rhs() for s in solve(zi == 0, phi)]
sage: s1
[0, pi - arccos(1/2*sqrt(5) - 1/2), arccos(1/2*sqrt(5) + 1/2)]
sage: N(zi.subs(phi=s1))
0.244669085661435
sage: zi.subs(phi=pi/2)
0


So the solutions should result in a zero of the zi expression, but apparently that is not the case. Instead, some value which is not listed among the solutions turns out to be a solution. Did I make some mistake here, or is this a bug in sage?

Edit: zi should be equal to -1/2*sqrt(2)*cos(phi)/(sin(phi) + 1). This is the expression from which I eventually derived the correct solution.

edit retag close merge delete

Sort by » oldest newest most voted

This is indeed a bug, which is unfortunately not rare when working in the Symbolic Ring :/ Could you report it on the trac server by yourself (ask for help in comment otherwise) ?

A way to get the correct solution, though not satisfactory, is to simplify the expression zi first, to help the solver:

sage: zzi = zi.full_simplify()
sage: zzi
-cos(phi)/(sqrt(2)*sin(phi) + sqrt(2))

sage: solve(zzi == 0, phi)
[phi == 1/2*pi]


more

Thank you for the confirmation. I just filed [a defect ticket](http://trac.sagemath.org/sage_trac/ticket/14628) for this issue. By the way, the other solution was not actually hand-made, but instead obtained by using the adjoint instead of the inverse matrix in some code leading up to the matrix M I had included in my post. The net effect was a multiplication of that matrix by the denominator of the bottom left entry. Also note that [since your answer here](http://ask.sagemath.org/question/2577/integrate-with-elliptic-integral-special-function?answer=3544#3544) I no longer trust full_simplify as much as I used to

Thanks for reporting. As you can see the collection of [bugs concerning symbolic computations](http://trac.sagemath.org/sage_trac/wiki/symbolics) is quite huge, and i basically do not trust SR at all, and try to avoid it as much as i can (see for example [this problem](http://ask.sagemath.org/question/2518/get-variants-of-complex-cube-root?answer=3451#3451) with the square of a complex number) :(