Gotta Catch ‘Em All !

Solving \frac{d^2y}{dx^2} = \frac{y}{x}\cdot\frac{dy}{dx}.

Even though ‘contrib_ode’, Maxima’s ODE solver choked on this equation (see “An Alternate Solver of ODEs“), it still can be solved as demonstrated below:

multiplied by x,

x\frac{d^2y}{dx^2} = y\frac{dy}{dx},


x\frac{d}{dx}\left(\frac{dy}{dx}\right) = y\frac{dy}{dx}.

Integrate it, we have

\int x\frac{d}{dx}\left(\frac{dy}{dx}\right)\;dx = \int y \frac{dy}{dx} \;dx \implies \int \left(\frac{dy}{dx}\right)'\cdot x\;dx = \frac{1}{2}y^2+c.\quad\quad\quad(1-1)

By \int u'\cdot v\;dx = u\cdot v - \int u\cdot v'\;dx (see “Integration by Parts Done Right“),

\int \left(\frac{dy}{dx}\right)'\cdot x\;dx = \frac{dy}{dx}\cdot x-\int\frac{dy}{dx}\cdot x'\;dx \overset{x'=1}{=}  x\frac{dy}{dx}-\int \frac{dy}{dx}\;dx = x\frac{dy}{dx}-y.

As a result, (1-1) yields a new ODE

x\frac{dy}{dx} -y = \frac{1}{2}y^2 + c\quad\quad\quad(1-2)


2x\frac{dy}{dx}=2y+y^2+c_1,\quad c_1=2c.\quad\quad\quad(1-3)

Upon submitting (1-3) to Omega CAS Explorer in non-expert mode, the CAS asks for the range of c_1.

Fig. 1

Depending on the range provided, ‘ode2’ gives three different solutions (see Fig. 2, 3 and 4).

Fig. 2 c_1>1

Fig. 3 c_1<1

Fig. 4 c_1=1

Let’s also solve (1-3) manually:

If y^2+2y+c_1=0, (1-3) has a constant solution


In fact, this solution can be observed from \frac{d^2y}{dx^2} = \frac{y}{x}\cdot\frac{dy}{dx} right away.

Otherwise (y^2+2y+c_1 \ne 0),


That is,




For c_1-1>0, let k=\sqrt{c_1-1}, we have


Divide both numerator and denominator on the left side by k^2,


Write it as


Multiply both sides by k,


Integrate it,

\int\frac{1}{k}\cdot\frac{1}{(\frac{y+1}{k})^2+1}\cdot\frac{dy}{dx}\;dx=\int k\cdot\frac{1}{2x}\;dx,

we obtain

\arctan(\frac{y+1}{k}) = \frac{k}{2}\log(|x|)+c_2.


\arctan(\frac{y+1}{\sqrt{c_1-1}}) = \frac{\sqrt{c_1-1}}{2}\log(|x|)+c_2


y = 2k_1\tan(k_1\log|x| +k_2) -1\quad\quad\quad(2-2)

where k_1=\frac{\sqrt{c_1-1}}{2}, k_2=c_2.

For c_1-1<0, let k=\sqrt{1-c_1},



\frac{1}{2k}\left(\frac{1}{y+1-k} - \frac{1}{y+1+k}\right)\cdot\frac{dy}{dx}= \frac{1}{2x}

\int \left(\frac{1}{y+1-k} - \frac{1}{y+1+k}\right)\cdot\frac{dy}{dx}\;dx= \int\frac{k}{x}\;dx

\log|y+1-k| - \log|y+1+k| = k\cdot\log|x| + c_2

\log\bigg|\frac{y+1-k}{y+1+k}\bigg| = k\cdot\log|x| + c_2

\log\bigg|\frac{y+1-\sqrt{1-c_1}}{y+1+\sqrt{1-c_1}}\bigg| = \sqrt{1-c_1}\cdot\log|x| + c_2

y= -\frac{k_2(1+k_1)|x|^{k_1}+k_1-1}{k_2|x|^{k_1}-1}, \quad k_1=\sqrt{1-c_1}, k_2=e^{c_2}.\quad\quad\quad(2-3)

For c_1-1=0 \quad(c_1=1),


\int \frac{1}{(y+1)^2}\cdot\frac{dy}{dx}\;dx=\int \frac{1}{2x}\;dx

-\frac{1}{y+1} = \frac{1}{2}\log|x| +c_2

y+1 = \frac{-1}{\frac{1}{2}\log|x|+c_2}

y = -1 - \frac{1}{\frac{1}{2}\log|x|+c_2}.\quad\quad\quad(2-4)

Notice when c_1 = 0, c=0. (1-2) becomes

\frac{dy}{dx} - \frac{1}{x}y = \frac{1}{2x}y^2.

This is a Bernoulli’s Equation \frac{dy}{dx}+f(x)y=g(x)y^{\alpha} with f(x)=\frac{1}{x}, g(x)=\frac{1}{2x} and \alpha=2. Solving it (see “Meeting Mr. Bernoulli“),

y^{1-2} = e^{(2-1)\int -\frac{1}{x}\;dx}\cdot\left((1-2)\int e^{-(2-1)\int-\frac{1}{x}\;dx} \cdot \frac{1}{2x}\;dx+c\right)

= e^{-\log|x|}\cdot\left(-\int e^{\log|x|} \frac{1}{2x}\;dx +c\right)

= \frac{1}{|x|}\cdot\left(-\int |x|\cdot\frac{1}{2x}\;dx + c\right)

= \frac{1}{|x|}\cdot\left(-\int (\pm x)\cdot\frac{1}{2x}\;dx+c\right)

= \frac{1}{|x|}\cdot\left(-(\pm)\int \frac{1}{2}\;dx + c\right)

= \frac{1}{|x|}\cdot\left(-\frac{1}{2}(\pm x) + c\right)

= \frac{1}{|x|}\cdot\left(-\frac{1}{2}|x|+c\right)

= -\frac{1}{2} + \frac{c}{|x|}

\frac{1}{y} = -\frac{1}{2} + \frac{c}{|x|}\implies y = \frac{-2|x|}{|x|-2c}.\quad\quad\quad(3-1)

Since c_1 =0 \implies c_1-1=0-1 = -1 <0, we can verify (3-1) as follows:

substitute c_1=0 into (2-3),

y = -\frac{k2(1+\sqrt{1-0})|x|^{\sqrt{1-0}}+\sqrt{1-0}-1}{k_2|x|-1}=-\frac{2k_2|x|}{k_2|x|-1}\overset{k_2=\frac{1}{2c}}{=}\frac{-2|x|}{|x|-2c}.

Unsurprisingly, this is the same as (3-1).

Exercise-1 Mathematica solves \frac{d^2y}{dx^2} = \frac{y}{x}\cdot\frac{dy}{dx}:

But it only return one solution. Show that it is equivalent to (2-2).

Exercise-2 Solving (1-2) using ‘contrib_ode’.

Exercise-3 Show that (2-2), (2-3) and (2-4) are equivalent to results shown in Fig. 2, 3 and 4 respectively.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s