1
$\begingroup$

I need to find the minimum of a function $f(t) = \int_0^1\!g(t,x)\,dx$. What I did in mathematica is as follows:

f[t_] = NIntegrate[g[t,x],{x,-1,1}] FindMinimum[f[t],{t,t0}] 

However mathematica halts at the first try, because NIntegrate does not work with the symbolic t. Although Plot[f[t],{t,0,1}] works perferctly, FindMinimum stops at the initial point.

Any way to get around it? Thanks!

  • 0
    What's g[t,x]? If you have an explicit expression, we might manage to be more helpful.2010-08-13
  • 3
    Also, it should be f[t_]:=... ; you need delayed evaluation instead of immediate evaluation of the RHS. Also changing the LHS of the definition to f[t_?NumericQ] might help. This is because FindMinimum[], unlike Plot[], does not have the HoldAll attribute.2010-08-13
  • 1
    http://stackoverflow.com/questions/3474961/find-minimum-of-a-function-defined-by-integration-in-mathematica2010-08-13
  • 0
    Bah, I don't really hang around in StackOverflow... XD too bad my comment was late!2010-08-13
  • 0
    thank you guys!. next time i will ask on SO instead.2010-08-13

1 Answers 1