Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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

MvG gravatar image

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[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

So the solution should result in a zero of the zi expression, but apparently that is not the case. Did I make some mistake here, or is this a bug in sage?

click to hide/show revision 2
Found a correct solution and a simpler expression

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[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 solution 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.

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[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.