I'm looking for the proof of deriving the order-2 polynomial which best approximates a twice differentiable function in a given point. I have written down a simple proof for this, but something doesn't seem right. It goes as follows:
Let $f$ be a twice differentiable function around point $a$, and we look for the order-2 polynomial $p(x)$ such that $|f(x) - p(x)|$ is minimal when $x\rightarrow a$. Since then $f(a) = p(a)$, $p(x)$ takes the form
$$p(x) = c_2(x-a)^2 + c_1(x-a) + f(a).$$
Therefore
$$|f(x) - p(x)| = \left|\frac{f(x)-f(a)}{x-a}-c_1-c_2(x-a)\right|\cdot|x-a| $$
When $x\rightarrow a$, then $\frac{f(x)-f(a)}{x-a}\rightarrow f^\prime(a)$, $c_2(x-a)\rightarrow 0$, so $c_1 = f^\prime(a)$ and
$$p(x) = c_2(x-a)^2 + f^\prime(a)(x-a) + f(a).$$
For the next step we recall the theorem which states that if the derivative of a function has a limit in a point, then it is also continuous in that point:
$$\lim_{x\rightarrow a} f^\prime(x)=f^\prime(a).$$
With this we have
$$\lim_{x\rightarrow a}\frac{f^\prime(x)+f^\prime(a)}{2} = f^\prime(a)$$
and so
\begin{align} \lim_{x\rightarrow a} \frac{f(x)-f(a)}{x-a} - f^\prime(a) & = \lim_{x\rightarrow a}\frac{f^\prime(x)+f^\prime(a)}{2} - f^\prime(a)\\ & = \lim_{x\rightarrow a} \frac{f^\prime(x)-f^\prime(a)}{2} \end{align}
(This is where I think the problem is).
With this we can now write
$$|f(x) - p(x)| = \left|\frac{f^\prime(x)-f^\prime(a)}{2(x-a)} - c_2\right|\cdot|x-a|^2$$
Similarly as before, this implies that the first term must tend to $0$, which happens when $c_2 = \frac{f^{\prime\prime}(a)}{2}$, giving
$$p(x) = \frac{f^{\prime\prime}(a)}{2}(x-a)^2 + f^\prime(a)(x-a) + f(a).$$
This is of course correct, but I think something is amiss. In the equation which I marked as the potential source of the problem, both sides tend to $0$ when $x$ tends to $a$, but that would remain true if I replaced the denominator of $\frac{f^\prime(x)-f^\prime(a)}{2}$ to any positive number, say $100$. So with the same reasoning we could say that
$$\lim_{x\rightarrow a} \frac{f(x)-f(a)}{x-a} - f^\prime(a) = \lim_{x\rightarrow a} \frac{f^\prime(x)-f^\prime(a)}{100}$$
is also true, which would lead us to the wrong estimate
$$p(x) = \frac{f^{\prime\prime}(a)}{100}(x-a)^2 + f^\prime(a)(x-a) + f(a).$$
Can anyone explain what is wrong and how to resolve this?
The problem is that
is not a precise problem. For example, if the above means minimizing
$$ \lim_{x\to a} |f(x) -p(x)|,$$ then any polynomial (indeed, any continuous $p$) with $p(x) = f(a)$ would suffices.
A more precise problem is whether one can find an order 2 polynomial $p$ so that
$$\tag{1} \frac{f(x) - p(x)}{(x-a)^2} \to 0$$
as $x\to a$. There will be at most one such polynomial $p$ which satisfies (1): if both $p_1, p_2$ satisfies (1), then
$$ \lim_{x\to a}\frac{p_1(x) - p_2(x)}{(x-a)^2} =0,$$ and this implies that $p_1(x) = p_2(x)$.
On the other hand, the Taylor series $$T(x) = f(a) + f'(a) (x-a) + \frac{f''(a)}{2} (x-a)^2$$ would be the one since by L'Hospital, \begin{align} \lim_{x\to a} \frac{f(x) - T(x)}{(x-a)^2} &= \lim_{x\to a} \frac{f'(x) -T'(x)}{2(x-a)}\\ &= \frac 12 \lim_{x\to a} \left( \frac{f'(x) - f'(a)}{x-a} - f''(a)\right) = 0. \end{align}
Related post here.