Skip to main content
1-Visitor
April 18, 2013
Question

Finding roots of a graph

  • April 18, 2013
  • 4 replies
  • 4392 views

Hello,

I have plotted the orbit of a satellite using by dericing four ODEs and solving using the rkfixed function. The resulting graph of displacement in the y direction of a cartesian coordinate system is a sine wave.

Is it possible to find the roots of this curve given that there is no initial function? I am trying to determine the period of the sine wave and thus the period of orbit.

I have attached my worksheet. The curve I am trying to find roots for is y(t) in the first graph.

Thanks very much in advance.

4 replies

25-Diamond I
April 18, 2013

what you call y(t) is in effect not a function but a simple vector. You should call it simply y. The same goes for x, Vx and Vy.

As you are searching the "root" of that "function", essentially you a searching the position of the zeros in vector y and want to know the corresponding values in vector t.

The Mathcad function for this is lookup(0,y,t). The result is a vector with all "roots" but this function would only find an exact match (y has to be exact 0).

Other posibilities would be to use some kind of interpolation or write a routine which looks for a change of sign in y.

19-Tanzanite
April 18, 2013

This is probably best tackled using odesolve - see attached.

Alan

slimjim811-VisitorAuthor
1-Visitor
April 18, 2013

Thank you very much guys. They are both very useful responses.

25-Diamond I
April 19, 2013

Here is an appraoch with a small self written routine to find the positions where the sign changes and then uses linear interpolation between the two values.

At the end of the file find a different approach using cubic spline interpolation to turn y in a "real" function (similar to the result of odesolve) on which you could use the standard numeric methods (root, given-find) to get the roots.

23-Emerald I
April 19, 2013

If you have a vector (and you do, it's the output of rkfixed) then an fft of that vector will supply the frequency (inverse of period.) What you need is the sampling frequency, the time between data points of the vector.

Look up "CFFT" in help.

Note that Rkadapt, using variable steps, would not be adaptable to this approach.

25-Diamond I
April 19, 2013

Sounds good, but could you please elaborate on how to calculate the period of y in this specific case of y,t.

23-Emerald I
April 19, 2013

Unfortunately not as precise as I'd like, but this is how to do it.