On Wednesday, June 12, 2013 9:31:43 PM UTC-4, Stephen Montgomery-Smith wrote: > > On 06/11/2013 09:44 PM, robin hankin wrote: > > OK thanks for this, bug reported [at least, I think it is. I > > couldn't see it on trac]. > > > > Now what about this: > > > > > > sage: solve(sin(x) + cos(x) == cos(2*x),x,to_poly_solve=True) > > [x == 2*pi*z264, x == 2*pi*z268 + 1/6004799503160661*I - 355/452, x == > > 2*pi*z266 + 1/1125899906842624*I - 355/226, x == 2*pi*z270 + > > 1/9007199254740992*I + 1065/452] > > > > > > After the first, the solutions are not actually solutions of the > > equation. Is this reportable or have I misunderstood what solve() is > > supposed to do? > > Just in case people hadn't spotted it, it also missed some solutions: > -pi/4, 3*pi/4 and -pi/2, plus 2*pi*integer. And I think that is all of > them (even including complex solutions). >
Here is a workaround. It's not ideal, but does work. sage: sage: solve((sin(x)+cos(x)==cos(2*x)).trig_expand(),x,to_poly_solve=True) [sin(x) == cos(x) - 1, x == -1/4*pi + 2*pi*z571, x == 3/4*pi + 2*pi*z569] sage: solve(_[0],x,to_poly_solve=True) [x == 2*pi*z581, x == -1/2*pi + 2*pi*z583] Unfortunately, the Maxima list confirmed what I suspected on this - namely, that this might be the only way to do it. See also http://trac.sagemath.org/sage_trac/ticket/14738. It looks like to_poly_solve is calling algsys, which is using approximate methods and thus giving bogus results. You might try: sols: solve( [ trigexpand( sin(x)+cos(x)=cos(2*x) ), sin(x)^2+cos(x)^2=1 ], [sin(x),cos(x)] ) To get explicit results (rather than sin(x)=...), you can then use %solve: map(lambda([eq],%solve(eq,x)), sols); -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support?hl=en. For more options, visit https://groups.google.com/groups/opt_out.