4
$\begingroup$

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

$\endgroup$
  • $\begingroup$ Have you seen a plot of tsol[10, x]? $\endgroup$ – J. M. will be back soon Oct 16 '12 at 0:09
  • $\begingroup$ @J.M. I just did... I editted my question to include that... However, the images aren't showing at all! $\endgroup$ – dearN Oct 16 '12 at 0:20
6
$\begingroup$

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.

Mathematica graphics

$\endgroup$
  • $\begingroup$ @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? $\endgroup$ – dearN Oct 16 '12 at 0:23
  • $\begingroup$ @drN See my update. $\endgroup$ – halirutan Oct 16 '12 at 0:25
  • $\begingroup$ @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. $\endgroup$ – dearN Oct 16 '12 at 17:34
  • $\begingroup$ @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. $\endgroup$ – dearN Oct 16 '12 at 17:39

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.