Ask Your Question
1

Zero solution does not result in zero

asked 2013-05-22 02:48:05 -0600

MvG gravatar image

updated 2013-06-03 03:47:22 -0600

tmonteil gravatar image

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[0]/z[1]
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[1]))
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 flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
1

answered 2013-05-22 06:34:13 -0600

tmonteil gravatar image

updated 2013-05-22 07:35:19 -0600

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]

This both gives you the correct answer and confirms that your hand-made calculation is reliable :)

edit flag offensive delete link more

Comments

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…

MvG gravatar imageMvG ( 2013-05-22 09:07:08 -0600 )edit

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) :(

tmonteil gravatar imagetmonteil ( 2013-05-22 09:24:35 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2013-05-22 02:48:05 -0600

Seen: 97 times

Last updated: May 22 '13