Message Boards Message Boards

Avoid RecursionLimit while finding roots of interpolating function?

Posted 3 years ago

I've been trying to find the roots of an interpolating function, but when using FindRoot I get $RecursionLimit and the value is returned in Hold[] which wont let me assign it to variables.

vd = Sqrt[(xd'[t])^2  + (yd'[t])^2]
forced = (0.5 1.3 0.05^2 vd^2)
eqsd = {xd''[t] == -(forced xd'[t])/(0.5 vd), 
  yd''[t] == -9.8 - (forced yd'[t])/(0.5 vd)}
inid[v_, \[Theta]_] := {xd[0] == 0, yd[0] == 0, 
  xd'[0] == v  Cos[\[Theta]], yd'[0] == v Sin[\[Theta]]}
rules[in_, ti_, tf_] := NDSolve[Join[eqsd, in], {xd, yd}, {t, ti, tf}]

rule0 = rules[inid[98.99, Pi/4], 0, 20]
xd0[t_] := xd[t] /. rule0[[1]]
yd0[t_] := yd[t] /. rule0[[1]]
FindRoot[yd0[t], {t, 5}]
POSTED BY: Juan Valdez
2 Replies
Posted 3 years ago

Hi Juan,

When I run the code I get

InterpolatingFunction::dmval: Input value {26.1579} lies outside the range of data in the interpolating function. Extrapolation will be used.

(* {t -> 9.9333} *)

Plot[yd0[t], {t, 0, 10}]

enter image description here

Are you looking for the root or the maximum?

FindMaximum[yd0[t], {t, 5}, WorkingPrecision -> 10]
(* {123.4962338, {t -> 4.394687581}} *)
POSTED BY: Rohit Namjoshi

Welcome to Wolfram Community! Please make sure you know the rules: https://wolfr.am/READ-1ST

The rules explain how to format your code properly. Images don't help other members to copy your code. Please EDIT your post and make sure code blocks start on a new paragraph and look framed and colored like this.

int = Integrate[1/(x^3 - 1), x];
Map[Framed, int, Infinity]

You can also embed notebook or attach notebook.

enter image description here

POSTED BY: Moderation Team
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract