Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I can't seem to use FindMinValue to find the min. value of a curve represented by an interpolating function.

For instance the below code generates an interpolating function polynomial as the solution of the heat equation.

tsol = u /. 
  NDSolve[{D[u[t, x], t] == D[u[t, x], x, x], u[0, x] == 0, 
     u[t, 0] == Sin[t], u[t, 5] == 0}, u, {t, 0, 10}, {x, 0, 5}][[1]]

This plots it:

Plot3D[Evaluate[u[t, x] /. %], {t, 0, 10}, {x, 0, 5}, 
 PlotRange -> All]

enter image description here

I'd like to find the minimum point in the curve represented by this function at say, t=10.0, , so I try doing this:

FindMinValue[tsol, {{x, 0, 5}, {t, 0, 10}}]

Which is obviously wrong. I'd like to find the minimum value AT t=10.

This didn't work either:

FindMinValue[tsol[10, x], {x, 0, 5}]

I actually have an interpolating func. which is in x y and t and I am quite flabbergasted.

Why is the Dimensions of tsol 5? I thought it'd be 2 since it is only in x and t.

Plot of tsol[10,x]:

enter image description here

share|improve this question
Have you seen a plot of tsol[10, x]? – J. M. Oct 16 '12 at 0:09
@J.M. I just did... I editted my question to include that... However, the images aren't showing at all! – drN Oct 16 '12 at 0:20
up vote 5 down vote accepted

It is always a good thing to ensure that InterpolatingFunctions are called with parameters inside the region:

tsol = u /. 
  NDSolve[{D[u[t, x], t] == D[u[t, x], x, x], u[0, x] == 0, 
     u[t, 0] == Sin[t], u[t, 5] == 0}, u, {t, 0, 10}, {x, 0, 5}][[1]];
Plot3D[tsol[t, x], {t, 0, 10}, {x, 0, 5}, PlotRange -> All]

FindMinimum[{tsol[t, x], 0 <= t <= 10 && 0 <= x <= 5}, {{x, 1}, {t, 9}}]

(* {-1.00007, {x -> 1.43395*10^-7, t -> 4.71148}} *)

This should only give you an idea, although it does not find the minimum you like.


And to find the minimum value as pointed out in the last part of your question, you can do

Plot[tsol[10, x], {x, 0, 5}, PlotRange -> All]
FindMinValue[{tsol[10, x], 0 <= x <= 5}, x]

(*  -0.544147  *)

The option-value is All to plot everything.

Mathematica graphics

share|improve this answer
@haliurtan What I wanted to find was the point on the curve at say t=10 which is the minimum. This doesn't find the minimum because the result is actually a sine curve? -ish? – drN Oct 16 '12 at 0:23
@drN See my update. – halirutan Oct 16 '12 at 0:25
@haliurtan I tested this for a data set and I find that this method is incorrect. I'll try to post my data set online for you to take a look at if you'd so choose to. – drN Oct 16 '12 at 17:34
@haliurtan You will find here two data files in .mat format and one .nb which imports the data and tries to find the minimum value of the plot. You'd want to use L=92.389, fac=0.99, thres1 and thresh2 can be set to any value as I am not using them in this code. – drN Oct 16 '12 at 17:39

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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