Hi,(adsbygoogle = window.adsbygoogle || []).push({});

I've got an interpolating function which has been generated from using NDSolve and I'm trying to find all the values of x for which the y value is equal to 2.

I've constructed a (much) easier example to show what I mean.

Suppose I have a set of points which I have generated an interpolating function from:

points = {{0, 0}, {1, 1}, {2, 3}, {3, 4}, {4, 3}, {5, 0}};

ifun = Interpolation[points]

which gives me:

InterpolatingFunction[{{0, 5}}, "<>"]

How would I then go about finding the x values in this function for which y is equal to 2?

The code I have tried is as follows:

Table[x /. FindRoot[ifun[x] == 2, {x, xInit}], {xInit, 0, 10, 1}]

but this produces a lot of errors and extrapolates beyond the limits of my interpolating function. Also, while this finds all the values in this particular example, once the interpolation function gets more complicated it's skipping roots and extrapolating far beyond my limits. Does anyone have any ideas? Thanks in advance

**Physics Forums - The Fusion of Science and Community**

Dismiss Notice

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Find all roots of an interpolating function in Mathematica

Loading...

Similar Threads for Find roots interpolating | Date |
---|---|

Using Newton Raphson for Root Finding and Parameters' Estimation | Jun 25, 2014 |

Using matlab to find roots. | Aug 12, 2011 |

MATLAB Finding roots in MATLAB | May 17, 2011 |

MATLAB Finding roots with MATLAB | Apr 23, 2010 |

Finding the first roots of a function with Mathematica | Apr 16, 2010 |

**Physics Forums - The Fusion of Science and Community**