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.Wed, 19 Aug 2015 00:21:23 +0200how to get simplified result of solving equationhttps://ask.sagemath.org/question/28853/how-to-get-simplified-result-of-solving-equation/Hi there!
In a linear algebra assignment I have the following equation I need to find a solution for:
`-2*sqrt(3)*sin(t)^2+2*cos(t)*sin(t)+sqrt(3)==0`. I know the result is pi/3.
Now, when I use solve, `solve(-2*sqrt(3)*sin(t)^2+2*cos(t)*sin(t)+sqrt(3)==0, t)`. I get:
[sin(t) == -1/6*sqrt(3)*(sqrt(cos(t)^2+6)-cos(t), sin(t) == 1/6*sqrt(3)*sqrt(cos(t)^2+6)+cos(t))].
How do I use the solve function to get the more simplified result?
NB: I have also tried to use `find_root` and different simplify functions, but also without any luck. I am new to sage, so it is quite possible that I don't know a specification to the solve function which I should use.
Thank you in advance!
Sincerly SimonMon, 17 Aug 2015 19:38:14 +0200https://ask.sagemath.org/question/28853/how-to-get-simplified-result-of-solving-equation/Answer by calc314 for <p>Hi there!</p>
<p>In a linear algebra assignment I have the following equation I need to find a solution for:</p>
<p><code>-2*sqrt(3)*sin(t)^2+2*cos(t)*sin(t)+sqrt(3)==0</code>. I know the result is pi/3.</p>
<p>Now, when I use solve, <code>solve(-2*sqrt(3)*sin(t)^2+2*cos(t)*sin(t)+sqrt(3)==0, t)</code>. I get:</p>
<pre><code>[sin(t) == -1/6*sqrt(3)*(sqrt(cos(t)^2+6)-cos(t), sin(t) == 1/6*sqrt(3)*sqrt(cos(t)^2+6)+cos(t))].
</code></pre>
<p>How do I use the solve function to get the more simplified result? </p>
<p>NB: I have also tried to use <code>find_root</code> and different simplify functions, but also without any luck. I am new to sage, so it is quite possible that I don't know a specification to the solve function which I should use.</p>
<p>Thank you in advance!</p>
<p>Sincerly Simon</p>
https://ask.sagemath.org/question/28853/how-to-get-simplified-result-of-solving-equation/?answer=28854#post-id-28854First, be sure to define your variable using `var('t')`.
To find a numerical solution, you can plot the function to help identify where the roots are.
plot(-2*sqrt(3)*sin(t)^2+2*cos(t)*sin(t)+sqrt(3),(t,-10,10))
For example, to get the first positive root, you can now use `find_root` to find the root between 0 and 3.
find_root(-2*sqrt(3)*sin(t)^2+2*cos(t)*sin(t)+sqrt(3),-3,3)
which gives 2.6179938779914944.
For an analytic solution, you can do the following:
solve(-2*sqrt(3)*sin(x)^2+2*cos(x)*sin(x)+sqrt(3)==0, x,to_poly_solve ='force')
This gives: `[x == 1/3*pi + pi*z1, x == -1/6*pi + pi*z2]`
The `z1` and `z2` can be any integers.
(Interestingly, I could not get the solve to work with t as the variable. I'm not sure why.)Mon, 17 Aug 2015 22:25:06 +0200https://ask.sagemath.org/question/28853/how-to-get-simplified-result-of-solving-equation/?answer=28854#post-id-28854Comment by ismon for <p>First, be sure to define your variable using <code>var('t')</code>.</p>
<p>To find a numerical solution, you can plot the function to help identify where the roots are.</p>
<pre><code>plot(-2*sqrt(3)*sin(t)^2+2*cos(t)*sin(t)+sqrt(3),(t,-10,10))
</code></pre>
<p>For example, to get the first positive root, you can now use <code>find_root</code> to find the root between 0 and 3.</p>
<pre><code>find_root(-2*sqrt(3)*sin(t)^2+2*cos(t)*sin(t)+sqrt(3),-3,3)
</code></pre>
<p>which gives 2.6179938779914944.</p>
<p>For an analytic solution, you can do the following:</p>
<pre><code>solve(-2*sqrt(3)*sin(x)^2+2*cos(x)*sin(x)+sqrt(3)==0, x,to_poly_solve ='force')
</code></pre>
<p>This gives: <code>[x == 1/3*pi + pi*z1, x == -1/6*pi + pi*z2]</code></p>
<p>The <code>z1</code> and <code>z2</code> can be any integers.</p>
<p>(Interestingly, I could not get the solve to work with t as the variable. I'm not sure why.)</p>
https://ask.sagemath.org/question/28853/how-to-get-simplified-result-of-solving-equation/?comment=28856#post-id-28856Thank you very much for your answer!
I have marked your answer as being the correct answer. I don't know if I am to give you points, but if I am, please reply of how I do this.
Sincerly SimonTue, 18 Aug 2015 08:54:34 +0200https://ask.sagemath.org/question/28853/how-to-get-simplified-result-of-solving-equation/?comment=28856#post-id-28856Comment by calc314 for <p>First, be sure to define your variable using <code>var('t')</code>.</p>
<p>To find a numerical solution, you can plot the function to help identify where the roots are.</p>
<pre><code>plot(-2*sqrt(3)*sin(t)^2+2*cos(t)*sin(t)+sqrt(3),(t,-10,10))
</code></pre>
<p>For example, to get the first positive root, you can now use <code>find_root</code> to find the root between 0 and 3.</p>
<pre><code>find_root(-2*sqrt(3)*sin(t)^2+2*cos(t)*sin(t)+sqrt(3),-3,3)
</code></pre>
<p>which gives 2.6179938779914944.</p>
<p>For an analytic solution, you can do the following:</p>
<pre><code>solve(-2*sqrt(3)*sin(x)^2+2*cos(x)*sin(x)+sqrt(3)==0, x,to_poly_solve ='force')
</code></pre>
<p>This gives: <code>[x == 1/3*pi + pi*z1, x == -1/6*pi + pi*z2]</code></p>
<p>The <code>z1</code> and <code>z2</code> can be any integers.</p>
<p>(Interestingly, I could not get the solve to work with t as the variable. I'm not sure why.)</p>
https://ask.sagemath.org/question/28853/how-to-get-simplified-result-of-solving-equation/?comment=28861#post-id-28861Thank you. The points are managed by the website automatically.Wed, 19 Aug 2015 00:21:23 +0200https://ask.sagemath.org/question/28853/how-to-get-simplified-result-of-solving-equation/?comment=28861#post-id-28861