Ask Your Question
2

Solving complex equation

asked 2011-04-13 23:35:51 -0500

Juanlu001 gravatar image

I was trying to solve the following equation over the complex numbers: sin(z) + cos(z) = 2

In Sage:

sage: z = var('z')
sage: solve(sin(z) + cos(z) == 2, z)
[sin(z) == -cos(z) + 2]

Obviously, that's not what I want. Wolfram|Alpha yields the two solutions in multiple forms: http://www.wolframalpha.com/input/?i=cos%28z%29+%2B+sin%28z%29+%3D%3D+2

Can this be done in Sage?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
6

answered 2011-04-14 03:49:57 -0500

kcrisman gravatar image
sage: solve(sin(x)+cos(x)==2,x,to_poly_solve=True)
[x == 1/4*pi + 2*pi*z6 - I*log(-1/2*(sqrt(2) - 2)*sqrt(2)), x == 1/4*pi + 2*pi*z8 - I*log(sqrt(2) + 1)]

Note that one gets a family of solutions because these are multi-valued inverses.

The to_poly_solve option still is not documented in the global solve?, but will show up if you do x.solve?. Apologies for not having done this.

edit flag offensive delete link more

Comments

@kcrisman, In addition to documenting the `to_poly_solve` option for the built-in `solve`, would it also make sense to have `solve` print a message to the user with the suggestion to try the option when an implicit solution is returned? I guess this depends on if it's easy to detect an implicit solution vs. an explicit one.

benjaminfjones gravatar imagebenjaminfjones ( 2011-04-14 06:54:50 -0500 )edit

That wouldn't be too hard to do. We basically do this already with `to_poly_solve`, in order to make sure we don't use it and then miss "real" solutions that would get caught. You just check if the variable is on both sides :) Can you open a ticket for this and cc: me? We've gotten so many bug reports on this over the years it's insane.

kcrisman gravatar imagekcrisman ( 2011-04-14 08:58:27 -0500 )edit

That worked, thanks!

Juanlu001 gravatar imageJuanlu001 ( 2011-04-14 09:56:19 -0500 )edit

In this context, `z6` refers to an integer parameter in the solution. There are infinitely many solutions to the equation and they all differ by integer multiples of 2*pi.

benjaminfjones gravatar imagebenjaminfjones ( 2011-04-14 10:01:05 -0500 )edit

Sorry, I thought I made that clear - thanks for spelling it out explicitly to lurkers. Same goes for z8, of course, and they won't always look the same, depends on how much you've used Maxima that session already.

kcrisman gravatar imagekcrisman ( 2011-04-14 17:09:20 -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

Stats

Asked: 2011-04-13 23:35:51 -0500

Seen: 1,295 times

Last updated: Apr 14 '11