# Using MinValue with NDSolve

A simplified example looks like this. The basic idea is to maximize fHelper by adjusting \[Alpha] for each t, and then use the resulting f in a differential equation. In the real world application, however, the functions and differential equation are much more complicated.

fHelper[t_, u_] := t + u;
f[t_] := MinValue[{fHelper[t, u], u >= 0.15, u <= 1.5}, u];
solution = NDSolve[{g'[t] == f[t], g[0.03] == 0}, g, {t, 0, 0.03}];


The last line produces a series of errors, which seems to be related to unsuccessful evaluation of f.

NMinimize::nnum:
The function value 0.211738 + t is not a number at {u} = {0.211738}.

NMinimize::nnum:
The function value 0.211738 + t is not a number at {u} = {0.211738}.

NMinimize::nnum:
The function value 0.211738 + t is not a number at {u} = {0.211738}.

General::stop: Further output of NMinimize::nnum
will be suppressed during this calculation.


I have checked f to see if there is something wrong with it, but it behaves exactly like a normal pure function, and I have no idea why Mathematica is complaining.

In[4]:= f[0.01]

Out[4]= 0.16

In[5]:= f[0.02]

Out[5]= 0.17


fHelper[t_, u_] := t + u;

fHelper[t_, u_] := t + u;