# Unexpected result for trigonometric function

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:
sage: solve(sin(x)-cos(x) == 0, x, to_poly_solve=True)
[x == 1/4*pi + pi*z25]
sage:


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

edit retag close merge delete

Sort by » oldest newest most voted

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)

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.

( 2020-05-24 05:18:06 +0200 )edit
1

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 ?

( 2020-05-24 15:23:46 +0200 )edit

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

( 2020-05-24 17:24:24 +0200 )edit
1

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.

( 2020-05-25 12:29:59 +0200 )edit