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.Fri, 15 Jan 2021 17:58:56 +0100Simple trigonometric equation solvinghttps://ask.sagemath.org/question/55268/simple-trigonometric-equation-solving/I was a MapleV user in the past (~25 years ago) an I'm very pleased to find such an elegant solution the sage is.
I try to see how it works trying to solve an easy trigonometry calculation:
var('r,l,m')
ex = l/sin(m/2/r)-r
solve(ex,r)
[r == l/sin(1/2*m/r)]
Do not want, ok. To simplify I put some real values m and l and tried again:
exval = ex.subs(l=7.2,m=10)
solve(exval,r)
[r == 36/5/sin(5/r)]
still not solving, r=3.68357 is what I'm searching for. What would be a right way to proceed?
Thank you in advance, v42
Thu, 14 Jan 2021 14:46:18 +0100https://ask.sagemath.org/question/55268/simple-trigonometric-equation-solving/Comment by Emmanuel Charpentier for <p>I was a MapleV user in the past (~25 years ago) an I'm very pleased to find such an elegant solution the sage is.
I try to see how it works trying to solve an easy trigonometry calculation: </p>
<pre><code>var('r,l,m')
ex = l/sin(m/2/r)-r
solve(ex,r)
[r == l/sin(1/2*m/r)]
</code></pre>
<p>Do not want, ok. To simplify I put some real values m and l and tried again:</p>
<pre><code>exval = ex.subs(l=7.2,m=10)
solve(exval,r)
[r == 36/5/sin(5/r)]
</code></pre>
<p>still not solving, r=3.68357 is what I'm searching for. What would be a right way to proceed?
Thank you in advance, v42</p>
https://ask.sagemath.org/question/55268/simple-trigonometric-equation-solving/?comment=55270#post-id-55270Due to mis-reading the question, I inadvertently left here a pile of manure...
My apologies to whomever I may have misled.Thu, 14 Jan 2021 17:02:24 +0100https://ask.sagemath.org/question/55268/simple-trigonometric-equation-solving/?comment=55270#post-id-55270Answer by Emmanuel Charpentier for <p>I was a MapleV user in the past (~25 years ago) an I'm very pleased to find such an elegant solution the sage is.
I try to see how it works trying to solve an easy trigonometry calculation: </p>
<pre><code>var('r,l,m')
ex = l/sin(m/2/r)-r
solve(ex,r)
[r == l/sin(1/2*m/r)]
</code></pre>
<p>Do not want, ok. To simplify I put some real values m and l and tried again:</p>
<pre><code>exval = ex.subs(l=7.2,m=10)
solve(exval,r)
[r == 36/5/sin(5/r)]
</code></pre>
<p>still not solving, r=3.68357 is what I'm searching for. What would be a right way to proceed?
Thank you in advance, v42</p>
https://ask.sagemath.org/question/55268/simple-trigonometric-equation-solving/?answer=55276#post-id-55276This plot :
var('r,l,m')
ex = l/sin(m/2/r)-r
plot(ex.subs(l=36/6, m=10), (r, -5, 5), ymin=-5, ymax=5, detect_poles=True, plot_points=1000)
suggests that `ex` has no (real) roots around 0. *Proving* it may require a non-trivial *analytical* exploration, possibly requiring the non-trivial use of non-trivial tools...
However, trying the suggested numerical solution :
print("Value of ex at suggested root r=%f is %f"%(3.68357, ex.subs([l==36/5,m==10]).subs(r==3.68357)))
Value of ex at suggested root r=3.683570 is 3.683570
suggests a typo in the question : at this value, `ex` approximately equals `r`. Which suggests that this value is (ano approximation of) a root of `ex-r`, which can be found more elegantly by :
print("Root of ex-r : %f"%find_root(ex.subs(l=36/5, m=10)-r, 2, 5))
Root of ex-r : 3.683570
See plot and computations in [Sagecell](https://sagecell.sagemath.org/?z=eJxdjtGKwjAQRd_9ikEoJjC1XUvrsjA_IbIvi0i1qQSSViap6N87sfqyT8NcDufeW8tqxejQr_TC3IHAFcEOyhebgnXOiyvbIarlb-smA2MPwrQRwnS5mBBNBzyOEZiyHmyArF9mqlo331W9RUHXYToF9eeIqqao0RN9lQc9pyzhTGqtPzW7ZHu15Aw_L19vh-6YWtTH52YbeLHJRIQNQp0c7j_UvCEEJVheJw7h4e1A6Xn49k5yOxPNOR6vozOB9jwZhOSSQEYFEZSlfgISkFfD&lang=sage&interacts=eJyLjgUAARUAuQ==)Fri, 15 Jan 2021 00:39:51 +0100https://ask.sagemath.org/question/55268/simple-trigonometric-equation-solving/?answer=55276#post-id-55276Comment by vladimir42000 for <p>This plot :</p>
<pre><code>var('r,l,m')
ex = l/sin(m/2/r)-r
plot(ex.subs(l=36/6, m=10), (r, -5, 5), ymin=-5, ymax=5, detect_poles=True, plot_points=1000)
</code></pre>
<p>suggests that <code>ex</code> has no (real) roots around 0. <em>Proving</em> it may require a non-trivial <em>analytical</em> exploration, possibly requiring the non-trivial use of non-trivial tools...</p>
<p>However, trying the suggested numerical solution :</p>
<pre><code>print("Value of ex at suggested root r=%f is %f"%(3.68357, ex.subs([l==36/5,m==10]).subs(r==3.68357)))
Value of ex at suggested root r=3.683570 is 3.683570
</code></pre>
<p>suggests a typo in the question : at this value, <code>ex</code> approximately equals <code>r</code>. Which suggests that this value is (ano approximation of) a root of <code>ex-r</code>, which can be found more elegantly by : </p>
<pre><code>print("Root of ex-r : %f"%find_root(ex.subs(l=36/5, m=10)-r, 2, 5))
Root of ex-r : 3.683570
</code></pre>
<p>See plot and computations in <a href="https://sagecell.sagemath.org/?z=eJxdjtGKwjAQRd_9ikEoJjC1XUvrsjA_IbIvi0i1qQSSViap6N87sfqyT8NcDufeW8tqxejQr_TC3IHAFcEOyhebgnXOiyvbIarlb-smA2MPwrQRwnS5mBBNBzyOEZiyHmyArF9mqlo331W9RUHXYToF9eeIqqao0RN9lQc9pyzhTGqtPzW7ZHu15Aw_L19vh-6YWtTH52YbeLHJRIQNQp0c7j_UvCEEJVheJw7h4e1A6Xn49k5yOxPNOR6vozOB9jwZhOSSQEYFEZSlfgISkFfD&lang=sage&interacts=eJyLjgUAARUAuQ==">Sagecell</a></p>
https://ask.sagemath.org/question/55268/simple-trigonometric-equation-solving/?comment=55287#post-id-55287Dear Emmanuel, Thank you a lot for your reply and explanation, this is what I tried to achieve. You're right with ex - r. Thanks again, I pursue my exploration of this superb piece of software :).Fri, 15 Jan 2021 17:58:56 +0100https://ask.sagemath.org/question/55268/simple-trigonometric-equation-solving/?comment=55287#post-id-55287