Ask Your Question

Unexpected result for trigonometric function

asked 2020-05-23 20:39:24 -0600

gg gravatar image

updated 2020-05-23 20:39:53 -0600

I'm trying to solve the following trig eqn using sage.

$$sin(x)-cos(x) = 0$$

Hand calculation give me the result of: $$x=\frac{\pi}{4} + n\pi$$

However, the solve() function gives me a different result, why is that?:

sage: solve(sin(x)-cos(x) == 0, x, to_poly_solve=True)
[x == 1/4*pi + pi*z25]

Also, what's z in the answer? I haven't defined any such variable.

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted

answered 2020-05-23 21:00:24 -0600

tmonteil gravatar image

It is not z to be considered, but z25, which is a free parameter that plays the role of $n$ in your own solution. Note that free variables are generated on demand, so if you run the same solve command at the beginning of a Sage session, you will get z1.

It is indeed a symbolic variable (defined by the system), as you can see with:

sage: solve(sin(x)-cos(x) == 0, x, to_poly_solve=True)[0].variables()
(x, z25)
edit flag offensive delete link more


Thanks for the reply. BTW, I was trying to post this question since yesterday, but it was being flagged as spam. Why is that? I am not behind proxy or anything.

gg gravatar imagegg ( 2020-05-23 22:18:06 -0600 )edit

We get a lot of spam, so as a way to mitigate when you make your first contribution, it must be approved by one administrator, then you will not be moderated anymore. However, this is not your first contribution, and i do not see any suspect keyword in your post, so this should not happen, weird. Do you have any screenshot of what actually happened ?

tmonteil gravatar imagetmonteil ( 2020-05-24 08:23:46 -0600 )edit

Sorry, I didn't take a screenshot. But admins can look at the logs.

gg gravatar imagegg ( 2020-05-24 10:24:24 -0600 )edit

Also, as explained in the documentation of solve?, if the arbitrary constant r1 starts with r it is a real number in R and if the arbitrary constant z1 starts with z it is a integer in Z.

Sébastien gravatar imageSébastien ( 2020-05-25 05:29:59 -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

1 follower


Asked: 2020-05-23 20:39:24 -0600

Seen: 58 times

Last updated: May 23 '20