I'm trying to solve an ODE where there is an optimal control problem involving a tradeoff between the flow cost c
and the drift rate g
as well as value matching and smooth pasting conditions characterizing the boundary value xbar
. Something like the following:
0 == c[a, x] + f[a, x]*V[x] + g[a, x]*V'[x] + h[x]*V''[x]
V[xbar] == psi[xbar]
V'[xbar] == psi'[xbar]
This is a class of problem that often appears in financial economics. I tried to implement this in Mathematica using FindMaximum and NDSolve, but encountered issues. Minimal Example below:
ClearAll["Global`*"]
c[a_, x_] = (1 - a^2/2)*x;
f[x_] = 1;
g[a_, x_] = a;
h[x_] = 0.5*x^2;
psi[x_] = x - 1;
astar[X_?NumericQ, dV_?NumericQ] :=
With[{xx = X, dvv = dV},
FindMaximum[{c[a, xx] + g[a, xx]*dvv, a >= 0}, {a,
1/2}][[2]]]; // Quiet
ODE = {0 == c[a, x] + f[x]*V[x] + g[a, x]*V'[x] + h[x]*V''[x],
V[xbar] == psi[xbar],
V'[xbar] == psi'[xbar]} /. {a -> astar[x, V'[x]]}
I am trying to use a shooting method to evaluate whether my guess of is too high or too low relative to the condition V(0) = 0
, and will eventually do this properly using FindRoot.
Trying with a guess of 10 (as in the example) results in errors. What is the appropriate way to implement this in Mathematica?
EDIT: To provide some more structure to the problem, x is assumed to take values $x \in \left[0, \overline{x}\right]$, and $a$ is restricted to positive values. In the MWE, I provided a convex cost function $c$ that has support over all nonnegative numbers, but it is equally interesting to consider something of the form $\left(a-\ln\left(1-a\right)\right)x$, which would only take values on the interval $\left[0, 1\right)$.
f[x_]=1
with one argument, and in the equation you use this function with two argumentsf[a,x]
. How do you solve equation? $\endgroup$