0
$\begingroup$

I have to find the first few zeros of function for which I have not the analitycal expression. The function is named f in the following code and it is the result of a combination of solution of differential equation. (I have attach its plot ). I tried with FindRoots and I tried to follow this post but I've not solved my problem...

ti = 0;
u = 8;
yi = 0;
zi = -.75;
zf = -.5;

sol = FullSimplify[DSolve[{y'[t] == 1/(2 zf) y[t] - u z[t], 
 z'[t] == -1 + 1/zf z[t] + u y[t], y[ti] == yi, 
 z[ti] == zi}, {y[t], z[t]}, t]];

{{ysol[t_], zsol[t_]}} = Simplify[{y[t], z[t]} /. sol, 
 Assumptions -> Element[u, Reals] && Element[zi, Reals] && t > 0];

{{Gy[t_], Gz[t_]}} = {-z[t], y[t]} /. sol;

soladj = DSolve[{vy'[t] == 1/(2 zf) vy[t] - u vz[t], 
 vz'[t] == -1 + 1/zf vz[t] + u vy[t], vy[T] == Gy[T], 
 vz[T] == Gz[T]}, {vy[t], vz[t]}, t];

{{VY[t_], VZ[t_]}} = {vy[t], vz[t]} /. soladj;

f[T0_?NumericQ] := ArcTan @@ First@RotationMatrix[{{VY[0], VZ[0]},
 {Gy[0],Gz[0]}} /. T -> T0]

plotf = Plot[f[T0], {T0, 0, 4}, PlotRange -> Full, MaxRecursion ->15,
 LabelStyle -> {FontSize -> 15}]

plotf

$\endgroup$
  • $\begingroup$ There is not definition for Theta function ([Theta][T0]) in your code. Not Plot results. $\endgroup$ – Algohi May 30 '14 at 14:53
  • 1
    $\begingroup$ By numerically looking for zero crossings of the ArcTan, you will get spurious results that don't correspond to zeros of the function, whenever the ArcTan goes to infinity and flips sign. I think you should look for zeros of the sine, which means replacing your definition f[T0_?NumericQ] := ArcTan @@ by Chop@Last@First@. $\endgroup$ – Jens May 30 '14 at 17:20
2
$\begingroup$

By using JM's answer on the post you linked:

l = FindAllCrossings[Re@f[x], {x, 0, 4}, WorkingPrecision -> 20];
Plot[f[T0], {T0, 0, 4}, PlotRange -> Full, 
     Epilog -> {Red, PointSize[Large], Point[{#, 0} & /@ l]}]

Mathematica graphics

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.