# Finding the Minimum value of an interpolating function

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]


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]:

• Have you seen a plot of tsol[10, x]? Oct 16, 2012 at 0:09
• @J.M. I just did... I editted my question to include that... However, the images aren't showing at all! Oct 16, 2012 at 0:20

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.

Update

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.

• @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? Oct 16, 2012 at 0:23
• @drN See my update. Oct 16, 2012 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. Oct 16, 2012 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. Oct 16, 2012 at 17:39