**Edit**: Here is in depth derivation.

Suppose the pendulum is composed of a string of length $L$ and has a point mass of mass $m$ at the end of the string. Say we incline it at an angle $\theta_0 \in (0,\pi)$ counterclockwise from horizontal (counterclockwise counted positive and clockwise counted negative). Let the mass at the vertical position posses $0$ potential energy. Then it posses $mg(L-L\cos \theta_0)$ amount of Potential Energy at the signed angle of $\theta_0$. At any angle the mass posses a Kinetic energy of $\frac{1}{2}mv^2=\frac{1}{2}m \left(L\frac{d\theta}{dt}\right)^2$ and a potential energy of $mg(L-L\cos \theta)$. By conservation of mechanical energy,

$$\frac{1}{2}m\left(L\frac{d\theta}{dt}\right)^2+mgL(1-\cos \theta)=mgL(1-\cos \theta_0)$$

As the pendulum counterclockwise from an angle of $-\theta_0$ to $\theta_0$, $\frac{d\theta}{dt} \geq 0$ so,

$$\frac{d\theta}{dt}=\sqrt{\frac{2g}{L}(\cos \theta-\cos \theta_0)}$$

This motion is half the cycle (to show this look at the equation counterclockwise motion from $\theta_0$ to $-\theta_0$), so it takes half the period to occur. From which we find,

$$T=2\sqrt{\frac{L}{2g}} \int_{-\theta_0}^{\theta_0} \frac{1}{\sqrt{\cos \theta-\cos \theta_0}} d\theta$$

As the integrand is even we get,

$$=4\sqrt{\frac{L}{2g}}\int_{0}^{\theta_0} \frac{1}{\sqrt{\cos \theta-\cos \theta_0}} d\theta$$

Now we make the substitution $\sin x=\dfrac{\sin \frac{\theta}{2}}{\sin \frac{\theta_0}{2}}$. $x \in [0,\frac{\pi}{2}]$ and $\theta \in [0,\theta_0]$ correspond together, so let $x \in \left[0,\frac{\pi}{2}\right]$. Then note the identities,

$$1-2\sin^2 \left(\frac{\theta}{2}\right)=\cos \theta$$

$$1-2\sin^2 \left(\frac{\theta_0}{2} \right)=\cos \theta_0$$

Give,

$$\sqrt{\cos \theta-\cos \theta_0}=\sqrt{2} \sin \frac{\theta_0}{2} \cos x$$

(If we let $\theta_0 \in (0,\pi]$ As $\cos x$ is nonnegative for $x \in \left[0,\frac{\pi}{2} \right]$). Also note the identity,

$$\cos \frac {\theta}{2}=\sqrt{1-\sin^2 \frac{\theta}{2}}$$

For $0 \leq \theta \leq \theta_0 \leq \pi$. The identities we found together convert the earlier expression we found for the period into,

$$T=4 \sqrt{\frac{L}{2g}} \sqrt{2} \int_{0}^{\frac{\pi}{2}} \frac{1}{\sqrt{1-k^2 \sin^2 x}} dx$$

$$=4\sqrt{\frac{L}{g}} \int_{0}^{\frac{\pi}{2}} \frac{1}{\sqrt{1-k^2 \sin^2 x}} dx$$

Where $k=\sin (\frac{\theta_0}{2})$.

We also have the binomial series expansion,

$$(1-k^2\sin^2 x)^{-\frac{1}{2}}=\sum_{n=0}^{ \infty} {-\frac{1}{2} \choose n} (-1)^n k^{2n} \sin^{2n} x$$

A standard exercise in many books is to show for integers $n \geq 2$,

$$\int_{0}^{\frac{\pi}{2}} \sin^{n} x dx=\frac{n-1}{n} \int_{0}^{\frac{\pi}{2}} \sin^{n-2} x dx$$

Hence showing for $n \geq 1$,

$$\int_{0}^{\frac{\pi}{2}} \sin^{2n} x dx=\frac{1 \cdot 3 \cdot 5 \cdots (2n-1)}{2 \cdot 4 \cdot 6 \cdots 2n} \frac{\pi}{2}$$

Using this gives,

$$T=2\pi \sqrt{\frac{L}{g}}\left(1+ \sum_{n=1}^{\infty} \frac{1 \cdot 3 \cdot 5 \cdots (2n-1)}{2 \cdot 4 \cdot 6 \cdots 2n} {-\frac{1}{2} \choose n} (-1)^n k^{2n} \right)$$

Also a famous result for $n \geq 1$ is,

$$(-1)^n {-\frac{1}{2} \choose n}=\frac{1 \cdot 3 \cdot 5 \cdots (2n-1)}{2 \cdot 4 \cdot 6 \cdots 2n}$$

So the exact period is,

$$T=2\pi \sqrt{\frac{L}{g}}\left(1+ \sum_{n=1}^{\infty}\left( \frac{1 \cdot 3 \cdot 5 \cdots (2n-1)}{2 \cdot 4 \cdot 6 \cdots 2n} \right)^2 k^{2n} \right)$$

As claimed.

The equation that models a simple pendulum is,

$$-g\sin \theta=L \theta''$$

Where the derivative above is a time derivative. I read in my book that the period of of the pendulum starting from an angle of $\theta(0)=\theta_0$ is exactly,

$$T=2\pi\sqrt{\frac{L}{g}}\left[1+\left(\frac{1}{2}\right)^2 \sin^2 \left(\frac{\theta_0}{2}\right)+\left(\frac{1 \cdot 3}{2 \cdot 4} \right)^2 \sin^4 \left(\frac{\theta_0}{2}\right)+\cdots \right]$$

My question is how to get it?

Here's something I tried use $\sin (\theta)=\theta-\frac{\theta^3}{3}+\cdots$ to come up with a solution though I see if I include anything other than one other term I am lost. With one term I can get the first term in the period.

Here's another thing I tried to do, take Laplace transforms on both sides to get:

$$-g \int_{0}^{\infty} e^{-st} \sin (\theta(t))dt=L(s^2F(s)-s\theta(0)-\theta'(0))$$

But again it seems like there is no hope to solve that integral.