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.Sat, 05 Aug 2023 17:38:04 +0200Simple trigonometric equationhttps://ask.sagemath.org/question/71790/simple-trigonometric-equation/I am a beginner and I am reading the page *Basic Algebra and Calculus* of the Tutorial where there is the following example
theta = var('theta')
solve(cos(theta)==sin(theta), theta)
and there is no solution, but a human being and other systems, like Mathematica, are able to solve this simple equation.
So I suppose there is a way to solve it with Sage. Can you show me how?Fri, 04 Aug 2023 22:34:13 +0200https://ask.sagemath.org/question/71790/simple-trigonometric-equation/Answer by eric_g for <p>I am a beginner and I am reading the page <em>Basic Algebra and Calculus</em> of the Tutorial where there is the following example</p>
<pre><code>theta = var('theta')
solve(cos(theta)==sin(theta), theta)
</code></pre>
<p>and there is no solution, but a human being and other systems, like Mathematica, are able to solve this simple equation.
So I suppose there is a way to solve it with Sage. Can you show me how?</p>
https://ask.sagemath.org/question/71790/simple-trigonometric-equation/?answer=72018#post-id-72018Using the keyword argument `algorithm='sympy'` leads to more success:
sage: solve(cos(theta)==sin(theta), theta, algorithm='sympy')
[ImageSet(Lambda(_n, 2*_n*pi + 5*pi/4), Integers),
ImageSet(Lambda(_n, 2*_n*pi + pi/4), Integers)]
Sat, 05 Aug 2023 15:53:18 +0200https://ask.sagemath.org/question/71790/simple-trigonometric-equation/?answer=72018#post-id-72018Comment by enzotib for <p>Using the keyword argument <code>algorithm='sympy'</code> leads to more success:</p>
<pre><code>sage: solve(cos(theta)==sin(theta), theta, algorithm='sympy')
[ImageSet(Lambda(_n, 2*_n*pi + 5*pi/4), Integers),
ImageSet(Lambda(_n, 2*_n*pi + pi/4), Integers)]
</code></pre>
https://ask.sagemath.org/question/71790/simple-trigonometric-equation/?comment=72025#post-id-72025Very interesting suggestions. When I use Mathematica (which I have) it results in the following errror:
ValueError: The mathematica session in which this object was defined is no longer running.Sat, 05 Aug 2023 17:38:04 +0200https://ask.sagemath.org/question/71790/simple-trigonometric-equation/?comment=72025#post-id-72025Comment by Emmanuel Charpentier for <p>Using the keyword argument <code>algorithm='sympy'</code> leads to more success:</p>
<pre><code>sage: solve(cos(theta)==sin(theta), theta, algorithm='sympy')
[ImageSet(Lambda(_n, 2*_n*pi + 5*pi/4), Integers),
ImageSet(Lambda(_n, 2*_n*pi + pi/4), Integers)]
</code></pre>
https://ask.sagemath.org/question/71790/simple-trigonometric-equation/?comment=72021#post-id-72021Other possibilities :
sage: solve(((sin(theta)==cos(theta))/cos(theta)).trig_reduce(), theta)
[theta == 1/4*pi]
which is harder and incomplete,
sage: solve(sin(theta)==cos(theta), theta, to_poly_solve=True)
[theta == 1/4*pi + pi*z1971]
which is
- more concise, and
- already translated in Sage
but uses an undeclared and implicitly integer-valued variable.
HTH,
If you have Mathematica (or the [Wolfram engine](https://www.wolfram.com/engine/)) installed, you can also try :
sage: mathematica.Solve(sin(theta)==cos(theta), theta)
{{theta -> ConditionalExpression[(-3*Pi)/4 + 2*Pi*C[1],
Element[C[1], Integers]]},
{theta -> ConditionalExpression[Pi/4 + 2*Pi*C[1], Element[C[1], Integers]]}}
Other Sage-usable solvers do not solve this explicitly.Sat, 05 Aug 2023 16:38:55 +0200https://ask.sagemath.org/question/71790/simple-trigonometric-equation/?comment=72021#post-id-72021