I am following a walkthrough solution to the schrodinger equation and the lecturer solved this second order differential equation (the phi part of the angular equation) like so:
$d^2y/dx^2 + m^2*y = 0$
$(d/dx + im)(d/dx - im)y = 0$
(for each bracket): $dy/dx + imy = 0$
$dy/y = im dx$
$ln|y| = imx$
$y = e^{imx}$ (and $e^{-imx}$ for the other bracket)
I'm confused as to why the i on the second line appears. I can guess that $y$ is a complex function as $yfg = e^(ih)$ where $f$, $g$ and $h$ are other functions, so perhaps it is because of that? I have looked up solutions for similar second order differential equations but none of them include $i$.
A standard method for solving "linear homogeneous differential equations with constant coefficients" is to first solve its associated "characteristic equation". As you see from what you are doing, exponential functions are common solutions to such equations. Given an equation of the form $ay''+ by'+ cy= 0$, TRY $y= e^{rx}$ (Use braces, { and } around what you want in the exponent). Then $y'= re^{rx}$ and $y''= r^2e^{rx}$ so $ay''+ by'+ cy= ar^2e^{rx}+ bre^{rx}+ ce^{rx}= (ar^2+ br+ c)e^{rx}= 0$. And since $e^{rx}$ is never 0 we must have $ar^2+ br+ c= 0$. That is the "characteristic equation" for the differential equation.
Now, you know that a second order differential equation has two linearly independent solutions and it is no surprise that they correspond to the two solutions to the characteristic equation- if r and s are solutions to the characteristics equation then $e^{rx}$ and $e^{sx}$ are two independent solutions and the general solution to the differential equation is $y(x)= C_1e^{rx}+ C_2e^{sx}$.
But a quadratic equation might not have real number solutions. What if the solution to the characteristic equation are complex numbers? That a little more complicated! To answer that question, look at "MacLaurin series".
In Calculus you learned that the MacLaurin series for $e^{ax}$ is $\sum_{n=0}^\infty \frac{x^n}{n!}= 1+ x+ \frac{x^2}{2!}+ \frac{x^3}{3!}+ \cdot\cdot\cdot$. And the MacLaurin series for cos(x) and sin(x) are, respectively, $\sum_{n=0}^\infty \frac{(-1)^n x^{2n}}{(2n)!}$ and $\sum_{n= 0}^\infty \frac{(-1)^n x^{2n+ 1}}{(2n+ 1)!}$.
Do you see the similarities and differences? All three have x to a power over that number factorial. Cosine, an even function, has only even powers of x while sine, an odd function has only odd powers. Both cosine and sine have alternating powers of -1. And in fact powers of i alternate sign. $i^0= 1$. $i^2= -1$, $i^3= -i$, $i^4= 1$ and then repeats.
In fact, if we replace "x" with "ix" in the MacLaurin series for $e^x$ we get $e^{ix}= 1+ ix- \frac{x^2}{2!}- i\frac{x^3}{3!}+ \frac{x^4}{4!}+ \cdot\cdot\cdot$. Odd powers of x have an "i", even powers do not. We can separate real and imaginary parts into $e^{ix}= (1- \frac{x^2}{2!}+ \frac{x^4}{4!}+ \cdot\cdot\cdot)+ i(x- \frac{x^3}{3!}+ \frac{x^5}{5!}- \cdot\cdot\cdot)$.
That is, $e^{ix}= cos(x)+ i sin(x)!
If we have a homogeneous linear differential equation with constant, REAL, coefficients then it characteristic equation has real coefficients so if it has complex roots the come in complex conjugate pairs, a+ bi and a- bi. The corresponding solutions to the differential equation are $Ce^{(a+ bi)x}+ De^{(a- bi)x}= Ce^{ax}e^{bix}+ De^{ax}e^{-bix}= e^{ax}(Ce^{bix}+ De^{-bix})= e^{ax}(C(cos(bx)+ isin(bx))+ D(cos(-bx)+ isin(-bx))$.
Cosine is an even function, cos(-bx)= cos(bx), and sine is an odd function, sin(-bx)= -sin(bx) so that is $e^{ax}((C+D)cos(bx)+ (C-D)i sin(x))$. Let M= C+ D and N= (C- D)i and we can write the solution as $y(x)= e^{ax}(M cos(bx)+ N sin(bx))$.
Going back to your original differential equation, $\frac{d^2y}{dx^2}+ m^2y= 0$, its characteristic equation is $r^2+ m^2= 0$, $r^2= -m^2$ so the roots are r= mi and r= -mi. We COULD write the general solution to the differential equation as $y(x)= Ae^{imx}+ Be^{-imx}$ but since our original equation had only real numbers we prefer to use the equivalent form $y(x)= P cos(mx)+ Q sin(x)$.