1
$\begingroup$

I want to solve the following ODE in steps, as opposed to using Mathematica's solver directly:

\begin{align} \frac{1}{2} \sigma \frac{\partial^2 V (x_t)}{\partial x_t^2} + \left( \frac{\delta a_0}{a_1} - a_1 x_t \right) \frac{\partial V (x_t)}{\partial x_t} - e_+ V (x_t) &= -\frac{- 2x_t + 2 \lambda e_- (a_0 + a_1 x_t)}{e_- - e_+} \end{align}

ode = 1/2*sigma*V''[x] + ((delta*a0)/a1 - a1*x)*V'[x] - ep*V[x] == -((-2*x + 2*em*(a0 + a1*x)* lambda)/(em - ep));

First, I find the general solution of the homogeneous equation:

SolGeneralHomo = DSolveValue[ode[[1]] == 0, V[x], x] // FullSimplify

\begin{align} V^g(x_t) = c^1 H_{-\frac{e_+}{a_1}}\left(\frac{a_1^2 x_t-a_0 \delta }{a_1^{3/2} \sqrt{\sigma} }\right) + c^2 \, _1F_1\left(\frac{e_+}{2 a_1};\frac{1}{2};\frac{\left(a_1^2 x_t -a_0 \delta \right)^2}{a_1^3 \sigma}\right) \end{align}

Then I find a particular solution of the inhomogeneous equation. Let's postulate that: \begin{align} V (x_t) = h_0 + h_1 x_t \end{align} Substituting the ansatz into the differential equation: \begin{align} \frac{1}{2} \sigma \frac{\partial^2}{\partial x_t^2} \left( h_0 + h_1 x_t \right) + \left( \frac{\delta a_0}{a_1} - a_1 x_t \right) \frac{\partial}{\partial x_t} \left( h_0 + h_1 x_t \right) - e_+ \left( h_0 + h_1 x_t \right) &= -\frac{- 2x_t + 2 \lambda e_+ (a_0 + a_1 x_t)}{e_- - e_+} \nonumber \\ \left( \frac{\delta a_0}{a_1} - a_1 x_t \right) h_1 - e_+ \left( h_0 + h_1 x_t \right) &= -\frac{- 2x_t + 2 \lambda e_+ (a_0 + a_1 x_t)}{e_- - e_+} \end{align}

h1 = (-2 + 2*lambda*ep*a1)/((em - ep)*(a1 + ep));
h0 = (delta*a0)/(a1*ep)*h1 + (2*lambda*a0)/(em - ep);
SolParticularNonHomo = h0 + h1*x

Can you help me understand why Mathematica says that the differential equation is not satisfied?

FinalSol = SolGeneralHomo + SolParticularNonHomo // FullSimplify;
Sol = V -> Function[{x}, Evaluate[FinalSol]];
ode /. Sol // FullSimplify

The output is:

(a0 + a1 x) [Lambda] == 0

where even substituting for a0 and a1 the equality is not satisfied.

$\endgroup$
1
  • $\begingroup$ You can't use undetermined coefficients method (which what you seem to have done with your Ansatz) to solve an ode with variable coefficients. You need to use Variation of parameters. sometimes by luck undetermined coefficients might work on such ode's, but most of the time it will fail. I used Variation of parameters on this and got the same solution as shown by Mathematica's general solution. $\endgroup$
    – Nasser
    May 16, 2023 at 9:25

1 Answer 1

1
$\begingroup$

If you substitude your Ansatz into the ode, you get

ode /. V -> (h0 + h1 # &) /. Equal -> Subtract
eqn = CoefficientList[%, x]
solh = Solve[eqn == 0, {h0, h1}][[1]]
Simplify[ode /. V -> (h0 + h1 # &) /. solh]

Particular solution

h0+h1 x /.solh
(*(2 a0 (-delta + a1^2 em lambda + a1 delta em lambda +a1 em ep lambda))/(a1 (em - ep) ep (a1 + ep)) - (2 (-1 + a1 em lambda) x)/((a1 + ep) (-em + ep))*)

solves the ode!

Complete solution V -> Function[x, SolGeneralHomo[x] + h0 + h1 x /. solh]

SolGeneralHomo = DSolveValue[ode[[1]] == 0, V , x] // FullSimplify;
ode /.  V -> Function[x, SolGeneralHomo[x] + h0 + h1 x /. solh] //Simplify;
Collect[% /. Equal -> Subtract, {C[1], C[2]}, FullSimplify]
(* 0 *)

fullfills the ode too.

Hope it helps!

$\endgroup$
2
  • $\begingroup$ Thank you for your help and neat answer. $\endgroup$
    – NC520
    May 16, 2023 at 9:17
  • $\begingroup$ You're welcome! $\endgroup$ May 16, 2023 at 9:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.