Can Mathematica solve

$\min_{f(x) s.t. f(0)=f_0} \int_{0}^{\infty} (a f'(x)^2+b f(x)^2+c |f(x)|$)dx ?

I tried

DSolve[EulerEquations[a f'[x]^2 + b f[x]^2 + c Abs[f[x]],f[x],x],f[x],x]

but I don't know what to do with the result


PS: Sorry for the bad math formatting, I can't use math blocks. This is an old problem: "Your post appears to contain code that is not properly formatted as code" with math blocks

  • $\begingroup$ Please post the output of your code by direct copy-paste, don't try to LaTeXify it. $\endgroup$ – corey979 Oct 7 at 17:51
  • $\begingroup$ @corey979 The output is a visual formula. Should I take a screenshot? $\endgroup$ – Bananach Oct 7 at 17:58
  • $\begingroup$ closed form solution? $\endgroup$ – Xminer Oct 7 at 18:38
  • $\begingroup$ @Xminer Yes, if possible $\endgroup$ – Bananach Oct 7 at 19:29
  • $\begingroup$ do you have any additional condition for variable,$a$,$b$,$c$ and function $f(x)$ itself? $\endgroup$ – Xminer Oct 7 at 19:35

DSolve solution for positive/negative halfplane

eulereqs = EulerEquations[a f'[x]^2 + b f[x]^2 + c Abs[f[x]], f[x], x]

(* Out[] *)
2 b f[x] + c Abs'[f[x]] - 2 a f''[x] == 0

DSolve can't solve this right away because of the Abs'[x] term, but if we assume f[x] > 0 (or f[x] < 0 to the same effect) we can get solution families for the positive and negative half-plane.

eqpos = FullSimplify[eulereqs, f[x] > 0]
eqneg = FullSimplify[eulereqs, f[x] < 0]
DSolve[eqpos, f[x], x]
DSolve[eqneg, f[x], x]

(* Out[]*)
c + 2 b f[x] == 2 a f''[x]
c + 2 a f''[x] == 2 b f[x]
{{f[x] -> -(c/(2 b)) + E^((Sqrt[b] x)/Sqrt[a]) C[1] + E^(-((Sqrt[b] x)/Sqrt[a])) C[2]}}
{{f[x] ->   c/(2 b)  + E^((Sqrt[b] x)/Sqrt[a]) C[1] + E^(-((Sqrt[b] x)/Sqrt[a])) C[2]}}

Phase space plot

If we don't want to confine our solution to the positive/negative special case but still get a good idea how our solutions look like, we can instead visualize the solutions with a phase space plot, where we plot the trajectories {f[x], f'[x]}. To do that we first do a simplification, where we replace Abs'[x] by Sign[x]

eq = eulereqs /. Derivative[1][Abs] -> Sign

(* Out[] *)
2 b f[x] + c Sign[f[x]] - 2 a f''[x] == 0

Through the introduction of helper variable g[x]==f'[x] we can see, that our second order system in f is equivalent to a system of two first order ODEs:

 g'[x]==(b/a)f[x] + (c/(2 a)) Sign[f[x]]}

Now to get the correct slope or vector direction of the trajectory in a vector plot we want the rise dg and the run df which we can get as


and feed that to a VectorPlot or StreamPlot. Let's also use Manipulate to make it interactive and easy to explore the effect of different {a, b, c} parameter values.

    {g, b/a f + c/(2 a) Sign[f]}
    , {f, -3, 3}, {g, -3, 3}
    , FrameLabel -> {"f(x)", "f'(x)"}
  , {{a, 1}, 0, 5}
  , {{b, 2}, -5, 5}
  , {{c, 3}, -5, 5}

Interactive phase space plot

To generate a trajectory as function for further computations we can use NDSolveValue like this:

With[{a = 1, b = 2, c = 3},
    sol = NDSolveValue[{f''[x] == b/a f[x] + (c/(2a)) Sign[f[x]],
                        f[0] == 1, f'[0] == 0}, f, {x, -10, 10}];
        Plot[sol[x], {x, -3, 3}, PlotRange -> All],
        ParametricPlot[{sol[x], sol'[x]}, {x, -3, 3}]
  • $\begingroup$ Thanks. Just for completeness, do you also know how to solve the concrete optimization problem with fixed initial position and optimizable initial derivative? (I'm mostly interested in the min, not the argmin) For $a=c=1,b=0$, I got $4/3 p_0^{3/2}$ through manual computations; do you get the same? $\endgroup$ – Bananach Oct 8 at 15:51

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.