ASKSAGE: Sage Q&A Forum - Individual question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 26 Nov 2012 16:25:21 -0600how to calculate distance between origin and furthest point on graph?https://ask.sagemath.org/question/9567/how-to-calculate-distance-between-origin-and-furthest-point-on-graph/Hello!
I am new on this forum so forgive me if I don't respect all "rules" or if someone answered already this question.
![image description](http://oi45.tinypic.com/ve3i2e.jpg)
If you take a look at the image, I just want to know how to calculate the distance between origin and the furthest dot on the graph.
code:
var('t')
ff = (exp(cos(t)) - 2*cos(4*t) + sin(t/12)^5)
parametric_plot((ff*cos(t),ff*sin(t)), (t,0,2*pi) , fill=True, fillcolor='orange', figsize=[3,3])
Mon, 26 Nov 2012 08:55:31 -0600https://ask.sagemath.org/question/9567/how-to-calculate-distance-between-origin-and-furthest-point-on-graph/Answer by calc314 for <p>Hello!
I am new on this forum so forgive me if I don't respect all "rules" or if someone answered already this question.
<img alt="image description" src="http://oi45.tinypic.com/ve3i2e.jpg"/></p>
<p>If you take a look at the image, I just want to know how to calculate the distance between origin and the furthest dot on the graph.</p>
<p>code:</p>
<pre><code>var('t')
ff = (exp(cos(t)) - 2*cos(4*t) + sin(t/12)^5)
parametric_plot((ff*cos(t),ff*sin(t)), (t,0,2*pi) , fill=True, fillcolor='orange', figsize=[3,3])
</code></pre>
https://ask.sagemath.org/question/9567/how-to-calculate-distance-between-origin-and-furthest-point-on-graph/?answer=14303#post-id-14303The maximum you need occurs for $t$ in $[0,\pi/4]$. So, we can look for the maximum of the distance from the origin to the point over that interval as follows.
var('t')
ff = (exp(cos(t)) - 2*cos(4*t) + sin(t/12)^5)
v=vector((ff*cos(t),ff*sin(t)))
w=v[0]^2+v[1]^2
ans=w.find_maximum_on_interval(0,pi/4)
ans
which gives
(16.48247427444069, 0.74104978802589871)
So, the length is $\sqrt{16.4825}=4.060$.
The point at which this max occurs is given by:
v.subs(t=ans[1])
(2.99520450583, 2.74066127836)
Mon, 26 Nov 2012 12:52:56 -0600https://ask.sagemath.org/question/9567/how-to-calculate-distance-between-origin-and-furthest-point-on-graph/?answer=14303#post-id-14303Comment by kcrisman for <p>The maximum you need occurs for $t$ in $[0,\pi/4]$. So, we can look for the maximum of the distance from the origin to the point over that interval as follows.</p>
<pre><code>var('t')
ff = (exp(cos(t)) - 2*cos(4*t) + sin(t/12)^5)
v=vector((ff*cos(t),ff*sin(t)))
w=v[0]^2+v[1]^2
ans=w.find_maximum_on_interval(0,pi/4)
ans
</code></pre>
<p>which gives</p>
<pre><code>(16.48247427444069, 0.74104978802589871)
</code></pre>
<p>So, the length is $\sqrt{16.4825}=4.060$.</p>
<p>The point at which this max occurs is given by:</p>
<pre><code>v.subs(t=ans[1])
</code></pre>
<p>(2.99520450583, 2.74066127836)</p>
https://ask.sagemath.org/question/9567/how-to-calculate-distance-between-origin-and-furthest-point-on-graph/?comment=18647#post-id-18647Good catch - I was about to point out the missing sqrt :)Mon, 26 Nov 2012 16:25:21 -0600https://ask.sagemath.org/question/9567/how-to-calculate-distance-between-origin-and-furthest-point-on-graph/?comment=18647#post-id-18647Answer by kcrisman for <p>Hello!
I am new on this forum so forgive me if I don't respect all "rules" or if someone answered already this question.
<img alt="image description" src="http://oi45.tinypic.com/ve3i2e.jpg"/></p>
<p>If you take a look at the image, I just want to know how to calculate the distance between origin and the furthest dot on the graph.</p>
<p>code:</p>
<pre><code>var('t')
ff = (exp(cos(t)) - 2*cos(4*t) + sin(t/12)^5)
parametric_plot((ff*cos(t),ff*sin(t)), (t,0,2*pi) , fill=True, fillcolor='orange', figsize=[3,3])
</code></pre>
https://ask.sagemath.org/question/9567/how-to-calculate-distance-between-origin-and-furthest-point-on-graph/?answer=14304#post-id-14304The above is a more or less analytic answer. It's possible (perhaps not advisable) to give one from the data itself, though this is probably not robust.
sage: P = parametric_plot((ff*cos(t),ff*sin(t)), (t,0,2*pi) , fill=True, fillcolor='orange', figsize=[3,3])
sage: p = P[0]sage: Z = zip(p.xdata,p.ydata)
sage: W = [(vector(z).norm(),z) for z in Z]
sage: W.sort()
sage: W[-5:]
[(4.07480714946, (3.0424694670479733, -2.7106148467446545)), (4.0760691956, (2.9829635305007063, -2.7778172479461185)), (4.07657737686, (3.028814532960587, -2.7285097827236444)), (4.07721170912, (2.99905277507801, -2.762125589698095)), (4.07738007646, (3.01433945952578, -2.7456849620178922))]
The last two points correspond to the outer parts of the biggest leaves in your picture. Note that this involves a lot of rounding error, relatively speaking. Using
sage: P = parametric_plot((ff*cos(t),ff*sin(t)), (t,0,2*pi) , fill=True, fillcolor='orange', plot_points=400)
gives things slightly closer together.Mon, 26 Nov 2012 16:25:04 -0600https://ask.sagemath.org/question/9567/how-to-calculate-distance-between-origin-and-furthest-point-on-graph/?answer=14304#post-id-14304