Due to Lack of LATEX compatibility, I am attaching a PDF of this blog here. I will continue to try to fix the issue in the meantime. My apologies for inconvenience.
$$\usepackage{physics}$$
$$\usepackage{amsmath}$$
$$\usepackage{amsfonts}$$
$$\usepackage{amssymb}$$
$$\usepackage{mathtools}$$
$$\usepackage{graphicx}$$
$$\usepackage{xspace}$$
$$\usepackage{color}$$
$$\newcommand{\figref}[1]{Fig.~\ref{#1}}$$
$$\renewcommand{\eqref}[1]{Eq.~\ref{#1}}$$
$$\newcommand{\hn}{\hat{H}_0}$$
$$\newcommand{\hp}{\hat{H}^\prime}$$
$$\newcommand{\phis}[2]{\ket{\phi_{#1}^{#2}}}$$
$$\newcommand{\phib}[2]{\bra{\phi_{#1}^{#2}}}$$
$$\newcommand{\psis}[2]{\ket{\psi_{#1}^{#2}}}$$
$$\newcommand{\uc}[2]{\underbrace{#1}_{\mathclap{#2}}}$$
Complete derivation of time-independent perturbation theory in Quantum Mechanics. The equation we are trying to solve.
Zeroth order
$E_n^{(0)} = E_n^0 \text{ and } \psis{n}{(0)} = \phis{n}{0}$
First Order
$E_i^{(1)} = \hp_{ii} = \ev{\hp}{\phi_i^0}$ and $\psis{n}{(1)} = \sum_{i \neq n} \frac{\mel{\phi_i^0}{\hp}{\phi_n^0}}{E_n^0 - E_i^0} \phis{n}{0}$
Here, we will derive the correction in a most basic way.
\begin{equation}
\hn \phis{n}{0} = E_n^0 \phis{n}{0}
\end{equation}
This known hamiltonian will usually be harmonic oscillator, square well or hydrogen atom.
Including the perturbation, the total hamiltonian is $\hat{H} = \hn + \lambda \hp$. Our goal is to find its engenvalues ($E_n$) and corresponding eigentstates (\psis{n}{}). In other words, solve its eigenvalue equation.
\begin{equation}
\hat{H} \psis{n}{} = \qty(\hn + \lambda \hp) \psis{n}{} = E_n \psis{n}{}
\label{Eq H ES}
\end{equation}
\begin{gather}
\psis{n}{} = \sum_m \lambda^m \psis{n}{(m)} = \psis{n}{(0)} + \lambda \psis{n}{(1)} + \lambda^2 \psis{n}{(2)} + \dots
\label{Eq psi exp}
\\
E_n = \sum_m \lambda^m E_{n}^{(m)} = E_n^{(0)} + \lambda E_n^{(1)} + \lambda^2 E_n^{(2)} + \dots
\label{Eq E exp}
\end{gather}
Let's rewrite the eigenvalue equation (\eqref{Eq H ES}) using the expansions from \eqref{Eq psi exp} and \eqref{Eq E exp}.
\begin{equation}
\qty(\hn + \lambda \hp) \underbrace{\psis{n}{}}_{\text{Expand}} = \underbrace{E_n \psis{n}{}}_{\text{Expand Both}}
\end{equation}
\begin{equation}
\underbrace{\qty(\hn + \lambda \hp) \qty(\psis{n}{(0)} + \lambda \psis{n}{(1)} + ...)}_{\text{Expand All}} =
\underbrace{\qty(E_n^{(0)} + \lambda E_n^{(1)} + \dots) \qty(\psis{n}{(0)} + \lambda \psis{n}{(1)} + ...)}_{\text{Expand All}}
\end{equation}
\begin{equation}
\underbrace{\hn \psis{n}{(0)} + \lambda \hn \psis{n}{(1)} + \lambda \hp \psis{n}{(0)} + \lambda^2 \hp \psis{n}{(1)} + \dots}_{\text{Collect Like Terms}} =
\underbrace{E_n^{(0)} \psis{n}{(0)} + \lambda E_n^{(0)} \psis{n}{(1)} + \lambda E_n^{(1)} \psis{n}{(0)} + \lambda^2 E_n^{(1)} \psis{n}{(1)} + \dots}_{\text{Collect Like Terms}}
\end{equation}
\begin{equation}
\underbrace{\hn \psis{n}{(0)}}_{0^{th} \text{ power of } \lambda} +
\lambda \underbrace{\qty(\hn \psis{n}{(1)} + \hp \psis{n}{(0)})}_{1^{st} \text{ power of } \lambda} +
\lambda^2 \underbrace{\hp \psis{n}{(1)} + \dots}_{\text{Higher Powers}} =
\underbrace{E_n^{(0)} \psis{n}{(0)}}_{0^{th} \text{ power of } \lambda} +
\lambda \underbrace{\qty(E_n^{(0)} \psis{n}{(1)} + E_n^{(1)} \psis{n}{(0)})}_{1^{st} \text{ power of } \lambda} +
\lambda^2 \underbrace{E_n^{(1)} \psis{n}{(1)} + \dots}_{\text{Higher Powers}}
\label{Eq Expansion}
\end{equation}
For this equation to hold true, the different powers of $\lambda$ have to equal to each other individually.
The $0^{th}$ order terms on both sides have to equal to each other.
\begin{equation}
\underbrace{\hn \psis{n}{(0)} = E_n^{(0)} \psis{n}{(0)}}_{\text{This is an eigenvalue equation for \hn. So, $E_n^{(0)}$ and \psis{n}{(0)} are eigenvalues and eigenstates of \hn.}}
\end{equation}
\begin{equation}
E_n^{(0)} = E_n^0 \text{ and } \psis{n}{(0)} = \phis{n}{0}
\end{equation}
The $1^{th}$ order terms on both sides have to equal to each other.
\begin{equation}
\hn \psis{n}{(1)} + \hp \underbrace{\psis{n}{(0)}}_{\mathclap{=\phis{n}{0}}} = \underbrace{E_n^{(0)}}_{=E_n^0} \psis{n}{(1)} + E_n^{(1)} \underbrace{\psis{n}{(0)}}_{\mathclap{\text{Known from $0^{th}$ order = }\phis{n}{0}}}
\end{equation}
\begin{equation}
\hn \underbrace{\psis{n}{(1)}} + \hp \phis{n}{0} = E_n^0 \underbrace{\psis{n}{(1)}} + E_n^{(1)} \phis{n}{0}
\end{equation}
We can represent this state \psis{n}{(1)} as a linear combination of the eigenstates of \hn as \psis{n}{(1)} = $\sum_m c_{n,m}^{(1)}$ \phis{m}{0}. If we can determine the value of each $c_{n,m}^{(1)}$, then we can construct the state \psis{n}{(1)}.
\begin{equation}
\underbrace{\hn \qty(\sum_m c_{n,m}^{(1)} \phis{m}{0})}_{\hn \phis{m}{0} = E_m^0 \phis{m}{0}} +
\hp \phis{n}{0}
= E_n^0 \qty(\sum_m c_{n,m}^{(1)} \phis{m}{0}) +
E_n^{(1)} \phis{n}{0}
\end{equation}
\begin{equation}
\underbrace{\sum_m c_{n,m}^{(1)} E_m^0 \phis{m}{0}} +
\hp \phis{n}{0}
= E_n^0 \underbrace{\sum_m c_{n,m}^{(1)} \phis{m}{0}} +
E_n^{(1)} \phis{n}{0}
\label{Eq Ci}
\end{equation}
In order to pick out one of the $c_{n,m}^{(1)}$, multiply above equation (\eqref{Eq Ci}) by $\phis{i}{0}$. This will pick out the $i^{th}$ component of c's (i.e. $c_{n,i}^{(1)}$). Once we know all $i$'s, we can reconstruct \psis{n}{(1)}.
\begin{equation}
\phib{i}{0} \qty\Bigg[\sum_m c_{n,m}^{(1)} E_m^0 \underbrace{\phis{m}{0}}_{\mathclap{\braket{\phi_i^0}{\phi_m^0} = \delta_{i,m} }} +
\hp \phis{n}{0}
= E_n^0 \sum_m c_{n,m}^{(1)} \underbrace{\phis{m}{0}}_{\delta_{i,m}} +
E_n^{(1)} \underbrace{\phis{n}{0}}_{\delta_{i,n}}]
\end{equation}
\begin{equation}
\underbrace{\sum_m c_{n,m}^{(1)} E_m^0 \delta_{i,m}} + \mel{\phi_i^0}{\hp}{\phi_n^0} =
E_n^0 \underbrace{\sum_m c_{n,m}^{(1)} \delta_{i,m}} + E_n^{(1)} \delta_{i,n}
\end{equation}
This sum is non-zero only when $m=i$. So, $\sum_m c_{n,m}^{(1)} E_m^0 \delta_{i,m} = c_{n,i}^{(1)} E_i^0$. Similar for the other sum term. Also, we can rewrite $\mel{\phi_i^0}{\hp}{\phi_n^0}$ as the matrix element of \hp. So, $\mel{\phi_i^0}{\hp}{\phi_n^0}=\hp_{in}$
\begin{equation}
c_{n,i}^{(1)} E_i^0 + \hp_{in} = c_{n,i}^{(1)} E_n^0 + \underbrace{E_n^{(1)} \delta_{i,n}}_{\mathclap{\text{To find $E_i^{(1)}$ set $n=i$.} }}
\label{Eq First Order}
\end{equation}
\begin{equation}
c_{i,i}^{(1)} E_i^0 + \hp_{ii} = c_{i,i}^{(1)} E_i^0 + E_i^{(1)}
\end{equation}
\begin{equation}
E_i^{(1)} = \hp_{ii} = \ev{\hp}{\phi_i^0}
\end{equation}
We need to find $c_{n,i}^{(1)}$ in order to find the $n^{th}$ eigenvector correction. Let's go back to \eqref{Eq First Order} and plug in $E_n^{(1)} =\hp_{nn} = \ev{\hp}{\phi_n^0}$.
\begin{equation}
\underbrace{c_{n,i}^{(1)}} E_i^0 + \hp_{in} = \underbrace{c_{n,i}^{(1)}}_{\mathclap{\text{Solve for } c_{n,i}^{(1)} }} E_n^0 + \hp_{nn} \delta_{i,n}
\end{equation}
\begin{equation}
c_{n,i}^{(1)} = \frac{
\overbrace{\hp_{nn} \delta_{i,n} - \hp_{in}}^{\mathclap{\text{Note $i \neq n$, because we get 0/0.}} } }
{E_i^0 - E_n^0}
\end{equation}
Using this we can reconstruct \psis{n}{(1)} because \psis{n}{(1)} = $\sum_m c_{n,m}^{(1)} \phis{n}{0}$ = $\sum_i c_{n,i}^{(1)} \phis{n}{0}$.
\begin{equation}
\psis{n}{(1)} = \sum_{i \neq n} \frac{\hp_{nn} \delta_{i,n} - \hp_{in}}{E_i^0 - E_n^0} \phis{n}{0} = \sum_{i \neq n} \frac{\mel{\phi_i^0}{\hp}{\phi_n^0}}{E_n^0 - E_i^0} \phis{n}{0}
\end{equation}
We need to find all the $\lambda^2$ terms from \eqref{Eq Expansion}. Note that I have not written all the terms in \eqref{Eq Expansion}, so I suggest you write all the terms upto $\lambda^2$. You should get the following.
\begin{equation}
\hn \psis{n}{(2)} + \hp \uc{\psis{n}{(1)}}{} = \uc{E_n^{(0)}}{\text{We know many of these terms from $0^{th}$ and $1^{st}$ order corrections.}} \psis{n}{(2)} + \uc{E_n^{(1)}}{} \uc{\psis{n}{(1)}}{} + E_n^{(2)} \uc{\psis{n}{(0)}}{}
\end{equation}
Results
Zeroth order
$E_n^{(0)} = E_n^0 \text{ and } \psis{n}{(0)} = \phis{n}{0}$
First Order
$E_i^{(1)} = \hp_{ii} = \ev{\hp}{\phi_i^0}$ and $\psis{n}{(1)} = \sum_{i \neq n} \frac{\mel{\phi_i^0}{\hp}{\phi_n^0}}{E_n^0 - E_i^0} \phis{n}{0}$
Basic Time-Independent Non-Degenerate Perturbation
Here, we will derive the correction in a most basic way.
The known system
Suppose we know everything about $\hn$, and by everything I mean its eigenvalues $E_n^0$ and corresponding eigenstates $\phis{n}{0}$.\begin{equation}
\hn \phis{n}{0} = E_n^0 \phis{n}{0}
\end{equation}
This known hamiltonian will usually be harmonic oscillator, square well or hydrogen atom.
The Perturbing Hamiltonian
Suppose we add a small perturbing hamiltonian, $\hp$, to the original known hamiltonian $\hn$, and by small I mean the expectation value being small $\qty\big(\ev*{\hn} >> \ev*{\hp})$.Including the perturbation, the total hamiltonian is $\hat{H} = \hn + \lambda \hp$. Our goal is to find its engenvalues ($E_n$) and corresponding eigentstates (\psis{n}{}). In other words, solve its eigenvalue equation.
\begin{equation}
\hat{H} \psis{n}{} = \qty(\hn + \lambda \hp) \psis{n}{} = E_n \psis{n}{}
\label{Eq H ES}
\end{equation}
Expansion of Eigenvalues and Eigenstates
Since $\lambda$ is assumed to be very small, we can expand both $E_n$ and $\psis{n}{}$ in terms of different powers of $\lambda$.\begin{gather}
\psis{n}{} = \sum_m \lambda^m \psis{n}{(m)} = \psis{n}{(0)} + \lambda \psis{n}{(1)} + \lambda^2 \psis{n}{(2)} + \dots
\label{Eq psi exp}
\\
E_n = \sum_m \lambda^m E_{n}^{(m)} = E_n^{(0)} + \lambda E_n^{(1)} + \lambda^2 E_n^{(2)} + \dots
\label{Eq E exp}
\end{gather}
Let's rewrite the eigenvalue equation (\eqref{Eq H ES}) using the expansions from \eqref{Eq psi exp} and \eqref{Eq E exp}.
\begin{equation}
\qty(\hn + \lambda \hp) \underbrace{\psis{n}{}}_{\text{Expand}} = \underbrace{E_n \psis{n}{}}_{\text{Expand Both}}
\end{equation}
\begin{equation}
\underbrace{\qty(\hn + \lambda \hp) \qty(\psis{n}{(0)} + \lambda \psis{n}{(1)} + ...)}_{\text{Expand All}} =
\underbrace{\qty(E_n^{(0)} + \lambda E_n^{(1)} + \dots) \qty(\psis{n}{(0)} + \lambda \psis{n}{(1)} + ...)}_{\text{Expand All}}
\end{equation}
\begin{equation}
\underbrace{\hn \psis{n}{(0)} + \lambda \hn \psis{n}{(1)} + \lambda \hp \psis{n}{(0)} + \lambda^2 \hp \psis{n}{(1)} + \dots}_{\text{Collect Like Terms}} =
\underbrace{E_n^{(0)} \psis{n}{(0)} + \lambda E_n^{(0)} \psis{n}{(1)} + \lambda E_n^{(1)} \psis{n}{(0)} + \lambda^2 E_n^{(1)} \psis{n}{(1)} + \dots}_{\text{Collect Like Terms}}
\end{equation}
\begin{equation}
\underbrace{\hn \psis{n}{(0)}}_{0^{th} \text{ power of } \lambda} +
\lambda \underbrace{\qty(\hn \psis{n}{(1)} + \hp \psis{n}{(0)})}_{1^{st} \text{ power of } \lambda} +
\lambda^2 \underbrace{\hp \psis{n}{(1)} + \dots}_{\text{Higher Powers}} =
\underbrace{E_n^{(0)} \psis{n}{(0)}}_{0^{th} \text{ power of } \lambda} +
\lambda \underbrace{\qty(E_n^{(0)} \psis{n}{(1)} + E_n^{(1)} \psis{n}{(0)})}_{1^{st} \text{ power of } \lambda} +
\lambda^2 \underbrace{E_n^{(1)} \psis{n}{(1)} + \dots}_{\text{Higher Powers}}
\label{Eq Expansion}
\end{equation}
For this equation to hold true, the different powers of $\lambda$ have to equal to each other individually.
$0^{th}$ order correction
The $0^{th}$ order terms on both sides have to equal to each other.
\begin{equation}
\underbrace{\hn \psis{n}{(0)} = E_n^{(0)} \psis{n}{(0)}}_{\text{This is an eigenvalue equation for \hn. So, $E_n^{(0)}$ and \psis{n}{(0)} are eigenvalues and eigenstates of \hn.}}
\end{equation}
\begin{equation}
E_n^{(0)} = E_n^0 \text{ and } \psis{n}{(0)} = \phis{n}{0}
\end{equation}
$1^{st}$ order correction
The $1^{th}$ order terms on both sides have to equal to each other.
\begin{equation}
\hn \psis{n}{(1)} + \hp \underbrace{\psis{n}{(0)}}_{\mathclap{=\phis{n}{0}}} = \underbrace{E_n^{(0)}}_{=E_n^0} \psis{n}{(1)} + E_n^{(1)} \underbrace{\psis{n}{(0)}}_{\mathclap{\text{Known from $0^{th}$ order = }\phis{n}{0}}}
\end{equation}
\begin{equation}
\hn \underbrace{\psis{n}{(1)}} + \hp \phis{n}{0} = E_n^0 \underbrace{\psis{n}{(1)}} + E_n^{(1)} \phis{n}{0}
\end{equation}
We can represent this state \psis{n}{(1)} as a linear combination of the eigenstates of \hn as \psis{n}{(1)} = $\sum_m c_{n,m}^{(1)}$ \phis{m}{0}. If we can determine the value of each $c_{n,m}^{(1)}$, then we can construct the state \psis{n}{(1)}.
\begin{equation}
\underbrace{\hn \qty(\sum_m c_{n,m}^{(1)} \phis{m}{0})}_{\hn \phis{m}{0} = E_m^0 \phis{m}{0}} +
\hp \phis{n}{0}
= E_n^0 \qty(\sum_m c_{n,m}^{(1)} \phis{m}{0}) +
E_n^{(1)} \phis{n}{0}
\end{equation}
\begin{equation}
\underbrace{\sum_m c_{n,m}^{(1)} E_m^0 \phis{m}{0}} +
\hp \phis{n}{0}
= E_n^0 \underbrace{\sum_m c_{n,m}^{(1)} \phis{m}{0}} +
E_n^{(1)} \phis{n}{0}
\label{Eq Ci}
\end{equation}
In order to pick out one of the $c_{n,m}^{(1)}$, multiply above equation (\eqref{Eq Ci}) by $\phis{i}{0}$. This will pick out the $i^{th}$ component of c's (i.e. $c_{n,i}^{(1)}$). Once we know all $i$'s, we can reconstruct \psis{n}{(1)}.
\begin{equation}
\phib{i}{0} \qty\Bigg[\sum_m c_{n,m}^{(1)} E_m^0 \underbrace{\phis{m}{0}}_{\mathclap{\braket{\phi_i^0}{\phi_m^0} = \delta_{i,m} }} +
\hp \phis{n}{0}
= E_n^0 \sum_m c_{n,m}^{(1)} \underbrace{\phis{m}{0}}_{\delta_{i,m}} +
E_n^{(1)} \underbrace{\phis{n}{0}}_{\delta_{i,n}}]
\end{equation}
\begin{equation}
\underbrace{\sum_m c_{n,m}^{(1)} E_m^0 \delta_{i,m}} + \mel{\phi_i^0}{\hp}{\phi_n^0} =
E_n^0 \underbrace{\sum_m c_{n,m}^{(1)} \delta_{i,m}} + E_n^{(1)} \delta_{i,n}
\end{equation}
This sum is non-zero only when $m=i$. So, $\sum_m c_{n,m}^{(1)} E_m^0 \delta_{i,m} = c_{n,i}^{(1)} E_i^0$. Similar for the other sum term. Also, we can rewrite $\mel{\phi_i^0}{\hp}{\phi_n^0}$ as the matrix element of \hp. So, $\mel{\phi_i^0}{\hp}{\phi_n^0}=\hp_{in}$
\begin{equation}
c_{n,i}^{(1)} E_i^0 + \hp_{in} = c_{n,i}^{(1)} E_n^0 + \underbrace{E_n^{(1)} \delta_{i,n}}_{\mathclap{\text{To find $E_i^{(1)}$ set $n=i$.} }}
\label{Eq First Order}
\end{equation}
\begin{equation}
c_{i,i}^{(1)} E_i^0 + \hp_{ii} = c_{i,i}^{(1)} E_i^0 + E_i^{(1)}
\end{equation}
\begin{equation}
E_i^{(1)} = \hp_{ii} = \ev{\hp}{\phi_i^0}
\end{equation}
We need to find $c_{n,i}^{(1)}$ in order to find the $n^{th}$ eigenvector correction. Let's go back to \eqref{Eq First Order} and plug in $E_n^{(1)} =\hp_{nn} = \ev{\hp}{\phi_n^0}$.
\begin{equation}
\underbrace{c_{n,i}^{(1)}} E_i^0 + \hp_{in} = \underbrace{c_{n,i}^{(1)}}_{\mathclap{\text{Solve for } c_{n,i}^{(1)} }} E_n^0 + \hp_{nn} \delta_{i,n}
\end{equation}
\begin{equation}
c_{n,i}^{(1)} = \frac{
\overbrace{\hp_{nn} \delta_{i,n} - \hp_{in}}^{\mathclap{\text{Note $i \neq n$, because we get 0/0.}} } }
{E_i^0 - E_n^0}
\end{equation}
Using this we can reconstruct \psis{n}{(1)} because \psis{n}{(1)} = $\sum_m c_{n,m}^{(1)} \phis{n}{0}$ = $\sum_i c_{n,i}^{(1)} \phis{n}{0}$.
\begin{equation}
\psis{n}{(1)} = \sum_{i \neq n} \frac{\hp_{nn} \delta_{i,n} - \hp_{in}}{E_i^0 - E_n^0} \phis{n}{0} = \sum_{i \neq n} \frac{\mel{\phi_i^0}{\hp}{\phi_n^0}}{E_n^0 - E_i^0} \phis{n}{0}
\end{equation}
$2^{nd}$ Order Correction
We need to find all the $\lambda^2$ terms from \eqref{Eq Expansion}. Note that I have not written all the terms in \eqref{Eq Expansion}, so I suggest you write all the terms upto $\lambda^2$. You should get the following.
\begin{equation}
\hn \psis{n}{(2)} + \hp \uc{\psis{n}{(1)}}{} = \uc{E_n^{(0)}}{\text{We know many of these terms from $0^{th}$ and $1^{st}$ order corrections.}} \psis{n}{(2)} + \uc{E_n^{(1)}}{} \uc{\psis{n}{(1)}}{} + E_n^{(2)} \uc{\psis{n}{(0)}}{}
\end{equation}