1
$\begingroup$

I have the following list and its interpolating finction x1:

point={{0., 0.}, {0.2, 1.}, {0.25, 1.5}, {0.3, 1.}, {0.5, 0.}};x1 = 
Interpolation[point]

I would like to obtain values of x for which y=1 and I try:

Solve[x1[x] == 1, x]

but the output is:

NSolve::ifun: Inverse functions are being used by NSolve, so some solutions 
may not be found; use Reduce for complete solution information.
{{InterpolatingFunction[{{0., 0.5}}, <>] -> 0.3}}

with a unique solution x=0.3. From the plot of x1, I expect that will be two different solutions. How can I solve this?Thanks

$\endgroup$
1
$\begingroup$

Try

FindRoot[x1[x] == 1, {x, .25, 0., 0.25}, Method -> "Secant"]
(*{x -> 0.2}*)
FindRoot[x1[x] == 1, {x, .25, 0.25, 0.5}, Method -> "Secant"]
(*{x -> 0.3}*)
$\endgroup$
1
$\begingroup$

Use numerical solver,

NSolve[x1[x] == 1, x]

{{x -> 0.3}}

$\endgroup$
  • $\begingroup$ Usually NDSolvewould be my first choice, but in this example I'm wondering why NSolve[{x1[x] == 1, 0 <= x <= 0.5}, x] doesn't evaluate the two(!) solutions. $\endgroup$ – Ulrich Neumann Feb 13 at 9:54

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.