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.Thu, 11 Jan 2018 14:10:48 +0100Another problem simplifying symbolic trigonometric expressionshttps://ask.sagemath.org/question/40561/another-problem-simplifying-symbolic-trigonometric-expressions/ I am testing Sage with the notebook interface, and I want to simplify this trigonometric symbolic expression:
var('x1','x2')
exp1=sin(x1)*cos(x2)+sin(x2)*cos(x1)
print(exp1.trig_simplify())
Sage does not simplify this expression and the result is:
cos(x2)*sin(x1) + cos(x1)*sin(x2)
As you can see the result show be:
sin(x1+x2)
Is there any to simplify trigonometric functions applied to the addition or the subtraction of two values?
ThanksThu, 11 Jan 2018 10:40:29 +0100https://ask.sagemath.org/question/40561/another-problem-simplifying-symbolic-trigonometric-expressions/Answer by eric_g for <p>I am testing Sage with the notebook interface, and I want to simplify this trigonometric symbolic expression:</p>
<pre><code>var('x1','x2')
exp1=sin(x1)*cos(x2)+sin(x2)*cos(x1)
print(exp1.trig_simplify())
</code></pre>
<p>Sage does not simplify this expression and the result is:</p>
<pre><code>cos(x2)*sin(x1) + cos(x1)*sin(x2)
</code></pre>
<p>As you can see the result show be:</p>
<pre><code>sin(x1+x2)
</code></pre>
<p>Is there any to simplify trigonometric functions applied to the addition or the subtraction of two values?
Thanks</p>
https://ask.sagemath.org/question/40561/another-problem-simplifying-symbolic-trigonometric-expressions/?answer=40566#post-id-40566You must use `trig_reduce()`:
sage: exp1.trig_reduce()
sin(x1 + x2)
The reverse operation is `trig_expand()`:
sage: exp2 = sin(x1 + x2)
sage: exp2.trig_expand()
cos(x2)*sin(x1) + cos(x1)*sin(x2)Thu, 11 Jan 2018 14:10:48 +0100https://ask.sagemath.org/question/40561/another-problem-simplifying-symbolic-trigonometric-expressions/?answer=40566#post-id-40566