ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 25 May 2020 12:29:59 +0200Unexpected result for trigonometric functionhttps://ask.sagemath.org/question/51525/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.Sun, 24 May 2020 03:39:24 +0200https://ask.sagemath.org/question/51525/unexpected-result-for-trigonometric-function/Answer by tmonteil for <p>I'm trying to solve the following trig eqn using sage.</p>
<p>$$sin(x)-cos(x) = 0$$</p>
<p>Hand calculation give me the result of: $$x=\frac{\pi}{4} + n\pi$$</p>
<p>However, the <code>solve()</code> function gives me a different result, why is that?:</p>
<pre><code>sage:
sage: solve(sin(x)-cos(x) == 0, x, to_poly_solve=True)
[x == 1/4*pi + pi*z25]
sage:
</code></pre>
<p>Also, what's <code>z</code> in the answer? I haven't defined any such variable.</p>
https://ask.sagemath.org/question/51525/unexpected-result-for-trigonometric-function/?answer=51526#post-id-51526It 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)
Sun, 24 May 2020 04:00:24 +0200https://ask.sagemath.org/question/51525/unexpected-result-for-trigonometric-function/?answer=51526#post-id-51526Comment by gg for <p>It is not <code>z</code> to be considered, but <code>z25</code>, 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 <code>solve</code> command at the beginning of a Sage session, you will get <code>z1</code>.</p>
<p>It is indeed a symbolic variable (defined by the system), as you can see with:</p>
<pre><code>sage: solve(sin(x)-cos(x) == 0, x, to_poly_solve=True)[0].variables()
(x, z25)
</code></pre>
https://ask.sagemath.org/question/51525/unexpected-result-for-trigonometric-function/?comment=51528#post-id-51528Thanks 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.Sun, 24 May 2020 05:18:06 +0200https://ask.sagemath.org/question/51525/unexpected-result-for-trigonometric-function/?comment=51528#post-id-51528Comment by tmonteil for <p>It is not <code>z</code> to be considered, but <code>z25</code>, 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 <code>solve</code> command at the beginning of a Sage session, you will get <code>z1</code>.</p>
<p>It is indeed a symbolic variable (defined by the system), as you can see with:</p>
<pre><code>sage: solve(sin(x)-cos(x) == 0, x, to_poly_solve=True)[0].variables()
(x, z25)
</code></pre>
https://ask.sagemath.org/question/51525/unexpected-result-for-trigonometric-function/?comment=51532#post-id-51532We 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 ?Sun, 24 May 2020 15:23:46 +0200https://ask.sagemath.org/question/51525/unexpected-result-for-trigonometric-function/?comment=51532#post-id-51532Comment by gg for <p>It is not <code>z</code> to be considered, but <code>z25</code>, 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 <code>solve</code> command at the beginning of a Sage session, you will get <code>z1</code>.</p>
<p>It is indeed a symbolic variable (defined by the system), as you can see with:</p>
<pre><code>sage: solve(sin(x)-cos(x) == 0, x, to_poly_solve=True)[0].variables()
(x, z25)
</code></pre>
https://ask.sagemath.org/question/51525/unexpected-result-for-trigonometric-function/?comment=51534#post-id-51534Sorry, I didn't take a screenshot. But admins can look at the logs.Sun, 24 May 2020 17:24:24 +0200https://ask.sagemath.org/question/51525/unexpected-result-for-trigonometric-function/?comment=51534#post-id-51534Comment by Sébastien for <p>It is not <code>z</code> to be considered, but <code>z25</code>, 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 <code>solve</code> command at the beginning of a Sage session, you will get <code>z1</code>.</p>
<p>It is indeed a symbolic variable (defined by the system), as you can see with:</p>
<pre><code>sage: solve(sin(x)-cos(x) == 0, x, to_poly_solve=True)[0].variables()
(x, z25)
</code></pre>
https://ask.sagemath.org/question/51525/unexpected-result-for-trigonometric-function/?comment=51545#post-id-51545Also, 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**.Mon, 25 May 2020 12:29:59 +0200https://ask.sagemath.org/question/51525/unexpected-result-for-trigonometric-function/?comment=51545#post-id-51545