Let $f(x) = \ln\left(\frac{x^2}{2}+1\right)+\cos x -1$. Find the largest $n\in\Bbb{N}$ such that there is $C\in\Bbb{R}$ such that:
$$g(x) = \begin{cases} \frac{f(x)}{x^n} &\mbox{if } x\ne 0 \\ C & \mbox{if } x=0 \end{cases} $$
Is differentiable at $x=0$. What is the value of $C$?
My Work so far
We know that
$$ln(t+1) = t - \frac{t^2}{2} + \frac{t^3}{3} - ...$$
Hence, $$\ln\left(\frac{x^2}{2} + 1\right) = \frac{x^2}{2} - \frac{x^4}{8} + \frac{x^6}{24} + o(x^6)$$
$$\cos x = 1 - \frac{x^2}{2} + \frac{x^4}{24} - \frac{x^6}{720} + o(x^6)$$
Therefore, $$f(x) = -\frac{x^4}{8} + \frac{x^4}{24} +o(x^5) = -\frac{1}{12}x^4 + o(x^5)$$
The answer is $n=4$ but I'm not sure why.