# 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.

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])

edit retag close merge delete

Sort by » oldest newest most voted

The 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.

more

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.

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)

more

Good catch - I was about to point out the missing sqrt :)

( 2012-11-26 16:25:21 -0500 )edit