Ask Your Question

Zero solution does not result in zero

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

MvG gravatar image

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

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]))
sage: zi.subs(phi=pi/2)

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

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

tmonteil gravatar image

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

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


Thank you for the confirmation. I just filed [a defect ticket]( 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]( I no longer trust `full_simplify` as much as I used to…

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

Thanks for reporting. As you can see the collection of [bugs concerning symbolic computations]( 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]( with the square of a complex number) :(

tmonteil gravatar imagetmonteil ( 2013-05-22 09:24:35 -0500 )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


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

Seen: 97 times

Last updated: May 22 '13