TITLE: Solving linear differential equation with variable coefficients.
QUESTION [5 upvotes]: I have faced this task, when preparing to my university's "mathematical methods" exam, and I do not really understand how to solve it. The task content is as follows:
Given: $$(1-x^2)\cdot y''_{xx} -x\cdot y'_x +y = \frac{\sqrt{1-x^2}}{x}$$ Solve the equation by substituion of the independent variable: $x(t) = \cos(t), x\in(0,1).$
My attempt:
I have performed the suggested substitution:

$(1-\cos^{2}(t))\cdot \large\frac{\partial^2y}{\partial x(t)^2}\normalsize-\cos(t)\cdot\large\frac{\partial y}{\partial x(t)} \normalsize+ y = \large\frac{\sqrt{1-\cos^2(t)}}{cos(t)}.$
$\sin^2(t)\cdot \large\frac{\partial^2y}{\partial x(t)^2}\normalsize-\cos(t)\cdot\large\frac{\partial y / \partial t}{\partial x / \partial t} \normalsize+ y = \tan(t).$
$\sin^2(t)\cdot\frac{\large\partial\left(\frac{\dot{y}}{-\sin(t)}\right) / \partial t}{\large\partial x / \partial t} + \large\frac{\cos(t)}{\sin(t)}\normalsize\dot{y} + y = \tan(t).$
$-\ddot{y} + 2\dot{y}\cot(t) +y = \tan(t).$

That is now I have to solve: $-\ddot{y} + 2\dot{y}\cot(t) +y = \tan(t).$ And that is the point, where I am stuck, I have no idea how to proceed from here, and I did not manage to find the way to solve such a linear D.E. in my course book.
I would appreciate any help, hints or book references, thank you in advance!
Post Scriptum:
As correctly mentioned by @Aryadeva, I have made a mistake, when calculating $\large\frac{\partial^2 y}{\partial x^2}$, I simply lost "minus".
That is, after recalculating I had to solve: $$\ddot{y} + y = \tan(t), \text{ s.t. } x\in(0,1) \text{ and } x = \cos(t) \Leftrightarrow \forall x\in \mathbb{D}_x: \text{ }t = \arccos{x}.\tag{1}$$
My solution has involved appying vatiation of parameters method:
$\underline{\text{Step I}}$: find characteristic polynomial over $y(t)$ to get a general solution $(\large y_{\small G})$ for $(1)$:
$\lambda^2 + 1 = 0. \Rightarrow \lambda = \pm i.$
$\begin{bmatrix}
\lambda_1\\
\lambda_2\\
\end{bmatrix} = \begin{bmatrix}
i\\
-i\\
\end{bmatrix} \Rightarrow \large y_{\small G} \normalsize = C_1 e^{it}+C_2 e^{-it} = \dot{\tilde {C}}_1\cos(t) + \dot{\tilde{C}}_2 \sin(t).$
$\underline{\text{Step II}}$: Finding particular solution $(\large y_{\small P})$ for $(1)$, using Wronskian matrices:
I would omit my calculations here, would just note that for the given D.E.:
$\mathbb{W} = \begin{pmatrix}\cos(t) & \sin(t) \\ -\sin(t) & \cos(t) \end{pmatrix}, \mathbb{W}_{\small \Delta} = \begin{vmatrix}\cos(t) & \sin(t) \\ -\sin(t) & \cos(t) \end{vmatrix} = 1.$
$\mathbb{W}_{\small \Delta,\normalsize 1} = \begin{vmatrix}0 & \sin(t) \\ 1 & \cos(t) \end{vmatrix} = -\sin(t), \mathbb{W}_{\small \Delta,\normalsize 2} = \begin{vmatrix}\cos(t) & 0 \\ -\sin(t) & 1 \end{vmatrix} = \cos(t).$
Thus:
$$\dot{\tilde{C}}_1(t) = \int\frac{\tan(t)\cdot \mathbb{W}_{\small \Delta,\normalsize 1}}{\mathbb{W}_{\small \Delta}} \partial t = \sin(t) +\frac{1}{2}\ln\left(\frac{\sin(t)-1}{\sin(t)+1}\right) +\bar{C}_1,$$
$$\dot{\tilde{C}}_2(t) = \int\frac{\tan(t)\cdot \mathbb{W}_{\small \Delta,\normalsize 2}}{\mathbb{W}_{\small \Delta}} \partial t = -\cos(t) + \bar{C}_2.$$
Thereof:
$$\large y_{\small P} \normalsize = \left(\sin(t)+\frac{1}{2}\ln\left(\frac{\sin(t)-1}{\sin(t)+1}\right) +\bar{C}_1\right)\cos(t) +\left(-\cos(t) +\bar{C}_2\right)\sin(t).$$
$\underline{\text{Step III}}$: Now it just suffices to write down the whole solution and transfer from $t$ to $x$:

$\large y \normalsize (t) = \large y_{\small G} + y_{\small P} \normalsize = \left(\sin(t)+\frac{1}{2}\ln\left(\frac{\sin(t)-1}{\sin(t)+1}\right) +\tilde{C}_1\right)\cos(t) +\left(-\cos(t) +\tilde{C}_2\right)\sin(t).$

Now, as $x \in (0, 1): \cos(\arccos{x}) = x, \text{ }\sin(\arccos{x}) = \sqrt{1-x^2}:$
$$\text{Answer: } \begin{array}{|c|}
\hline
y(x) = \left(\sqrt{1-x^2} + \frac{1}{2}\ln\left(\frac{\sqrt{1-x^2} - 1}{\sqrt{1-x^2} +1}\right)+\tilde{C}_1 \right)x +\left(-x+\tilde{C}_2\right)\sqrt{1-x^2}.\\
\hline
\end{array}$$

REPLY [2 votes]: We are given this ODE:
$$(1 - x^2) \frac{\mathrm{d}^2y}{\mathrm{d}x^2} - x \frac{\mathrm{d}y}{\mathrm{d}x} + y = \frac{\sqrt{1 - x^2}}{x}$$
To solve this, we simply make the substitution $x = \cos t$ and then write $\frac{\mathrm{d}y}{\mathrm{d}x}$ in term of $\frac{\mathrm{d}y}{\mathrm{d}t}$ and $\frac{\mathrm{d}^2y}{\mathrm{d}x^2}$ in term of $\frac{\mathrm{d}^2y}{\mathrm{d}t^2}$. After that, things will magically cancel out :)
Substitute $x = \cos t$ into the ODE gives
$$(1 - x^2) \frac{\mathrm{d}^2y}{\mathrm{d}x^2} - x \frac{\mathrm{d}y}{\mathrm{d}x} + y = \frac{\sqrt{1 - x^2}}{x}$$
$$(1 - \cos^2) \frac{\mathrm{d}^2y}{\mathrm{d}x^2} - \cos t \frac{\mathrm{d}y}{\mathrm{d}x} + y = \frac{\sqrt{1 - \cos^2}}{\cos t}$$
$$\sin^2 t \frac{\mathrm{d}^2y}{\mathrm{d}x^2} - \cos t \frac{\mathrm{d}y}{\mathrm{d}x} + y = \frac{\sin t}{\cos t} = \tan t$$
Differentiate $x = \cos t$ on both side w.r.t. $x$  gives
$$1 = - \sin t \cdot \frac{\mathrm{d}t}{\mathrm{d}x}$$
$$\frac{\mathrm{d}t}{\mathrm{d}x} = -\csc t$$
Now $$\frac{\mathrm{d}y}{\mathrm{d}x} = \frac{\mathrm{d}y}{\mathrm{d}t} \cdot \frac{\mathrm{d}t}{\mathrm{d}x} = -\csc t \cdot \frac{\mathrm{d}y}{\mathrm{d}t}$$
and hence $$\begin{align}
\frac{\mathrm{d}^2y}{\mathrm{d}x^2}
&= \frac{\mathrm{d}}{\mathrm{d}x}\left(\frac{\mathrm{d}y}{\mathrm{d}x}\right) \\
&= \frac{\mathrm{d}}{\mathrm{d}t}\left(\frac{\mathrm{d}y}{\mathrm{d}x} \right) \cdot \frac{\mathrm{d}t}{\mathrm{d}x} \\
&= \frac{\mathrm{d}}{\mathrm{d}t} \left(-\csc t \frac{\mathrm{d}y}{\mathrm{d}t}\right) \cdot (-\csc t) \\
&= \left(\csc t \cot t \frac{\mathrm{d}y}{\mathrm{d}t} - \csc t \frac{\mathrm{d}^2y}{\mathrm{d}t^2}\right) \cdot (-\csc t) \\
&= \csc^2 t \left(\frac{\mathrm{d}^2y}{\mathrm{d}t^2} - \cot t \frac{\mathrm{d}y}{\mathrm{d}t}\right) 
\end{align}$$
Next, write $\frac{\mathrm{d}y}{\mathrm{d}x}$ in term of $\frac{\mathrm{d}y}{\mathrm{d}t}$ and $\frac{\mathrm{d}^2y}{\mathrm{d}x^2}$ in term of $\frac{\mathrm{d}^2y}{\mathrm{d}t^2}$
$$\sin^2 t \cdot \csc^2 t \left(\frac{\mathrm{d}^2y}{\mathrm{d}t^2} - \cot t \frac{\mathrm{d}y}{\mathrm{d}t}\right) - \cos t \cdot (-\csc t) \cdot \frac{\mathrm{d}y}{\mathrm{d}t} + y = \tan t$$
$$\frac{\mathrm{d}^2y}{\mathrm{d}t^2} - \cot t \frac{\mathrm{d}y}{\mathrm{d}t} + \cot t \cdot \frac{\mathrm{d}y}{\mathrm{d}t} + y = \tan t$$
$$\frac{\mathrm{d}^2y}{\mathrm{d}t^2} + y = \tan t$$