y[t] and m[t] are functions I made from different differential equations, and they should be periodic function. But I am not sure how to get the period.
Also, I want to know how to compute x intercepts of my graphs, as in that way I can calculate the period as well.
Thank you so much.
edit: this is my code.
g = 9.81
L = 0.5
y =.
m =.
y = First[
y /. NDSolve[{y''[t] == -(g/L)*Sin[y[t]], y[0] == Pi/2, y'[0] == 0},
y, {t, 0, 10}]]
m = First[
m /. NDSolve[{m''[t] == -(g/L)*m[t], m[0] == Pi/2, m'[0] == 0},
m, {t, 0, 10}]]
Plot[{m[t], y[t]}, {t, 0, 10}, PlotLegends -> "Expressions",]
FunctionPeriod[{m[t], y[t]}, {t, 0, 10}]
Oh wow, you are my savior, thank you so much.
And it works for m(t) too! And I am getting expected answers!
But I’d like to ask why the peak difference is not consistent and slightly varies every time. m(t) should be clearly trigonometric function, and its period should be consistent. And I am sure y(t) should also have consistent period. could you explain me the reason why there’s small difference between each peak y values?
Thank you!
I really appreciate your help.
For m there is an analytic solution so we can get an exact answer using DSolve.
g = Rationalize@9.81; L = Rationalize@0.5; y =.; m =.;
solm = DSolve[{m''[t] == -(g/L)*m[t], m[0] == Pi/2, m'[0] == 0}, m, {t, 0, 10}]
fm = solm[[1, 1, 2]]
(* Function[{t}, 1/2 π Cos[3/5 Sqrt[109/2] t]] *)
FunctionPeriod[fm[t], t]
(* 10/3 Sqrt[2/109] π *)
N@%
(* 1.4185 *)
The numerical solutions will always have some variability due to the precision of the computations.You can control those in WL to arrive at a more precise computation of the period. For NDSolve you can try increasing AccuracyGoal and PrecisionGoal. For Plot you can try increasing PlotPoints.