Consider the ODE
y'(x) = -\dfrac{y(x)}{x - A} + \dfrac{x}{x -A}
with y(0) = D
and x >A
.
Determine the value \color{orange} y(C)
of the solution of the IVP.
\color{orange} y(C)
=
(0.5 * C*C - A*D)/(C-A)
We first determine the general solution of the associated homogeneous differential equation y'(x) = p(x)\cdot y(x)
.
It is given by y(x) = K \cdot e^{P(x)}
with a constant K
and a primitive
\displaystyle P(x) \in \int p(x) dx
of p
.
In the case at hand, we have \displaystyle P(x) \in \int p(x) dx =
\int -\dfrac{1}{x - A} dx=
-\ln |x -A| =- \ln (x -A)+
constant, as x >A
.
Substituting this gives
y(x) = K \cdot e^{P(x)} = K \cdot e^{- \ln (x -A)} = K \cdot \dfrac{1}{x -A}
.
The integration constant
K
is determined by the initial condition y(0) = D
and determined together with all other constnads in the end.
Using the variation of constants approach, we get the general solution of the inhomogeous ODE
\displaystyle y(x) = \left( \int e^{-P(x)} \cdot q(x) dx + C \right) e^{P(x)}
.
Compute e^{-P(x)} \cdot q(x) = e^{-(- \ln (x -A))} \cdot \dfrac{x}{x -A}
= (x -A) \dfrac{x}{x -A} = x
and \displaystyle \int e^{-P(x)} \cdot q(x) dx = \int x dx = \frac 12 x^2 +C
.
The general solution of the inhomogeous ODE is
\displaystyle y(x) = \left( \frac 12 x^2 +C \right) e^{P(x)} = \left( \frac 12 x^2 +C \right) \frac{1}{x -A}
= \frac{\frac 12 x^2 +C }{x -A}.
As
y(0) = D = \dfrac{0 +C }{0 -A}
it follows that C = -A*D
.
Eventually, the solution of the IVP is \displaystyle y(x) = \frac{\frac 12 x^2 + -A*D}{x -A}
.
Substitution gives {\color{orange} y(C)} =
fractionReduce(0.5 * C*C - A*D,C-A)
.