Numerical differentiation and the product rule

685 Views Asked by At

It is well-known that for two functions $p$ and $q$, $$[p(x)q(x)]' = p'(x)q(x)+p(x)q'(x)$$

But if one uses numerical approximation, say the centred difference method

$$f'(x) = \frac{f(x+h)-f(x-h)}{2h}+O(h^2)$$

then the LHS and RHS will give different results. In particular, the LHS will give error $O(h^2)$ but RHS will give error $O(p+q)O(h^2)$. I'm not sure how to treat $O(p+q)O(h^2)$. As far as I understand $$O(p+q)O(h^2)\ne O(h^2)$$

Is my train of thought correct? Would appreciate a bit of an insight.

2

There are 2 best solutions below

0
On BEST ANSWER

The small parameter is $h$; $p$ and $q$ are finite. Hence, the term $p\,O(h^2) = O(h^2)$. Idem for $q$.

2
On

I think the best way to understand what is going on is to drop the "big O" notation and use Taylor's formula to actually write down the error committed when approximating the derivatives by finite differences...

$$ \dfrac{f(x+h)-f(x-h)}{2h} = \dfrac{1}{2h}\left(f(x)+f'(x)h +f''(x)\frac{h^2}{2} + \frac 16 f'''(\xi_1) h^3 - (f(x) - f'(x) h +\frac 12 h^2 f''(x) - \frac 16 h^3 f'''(\xi_2)) \right)\\= f'(x)+\frac 16 ( f'''(\xi_) + f'''(\xi_2))\frac{h^2}{2}\\ = f'(x) + \frac{h^2}{6}f'''(\xi) $$

So you see that your $O(h^2)$ is a constant times $h^2$, but this constant depends on function $f$ and on the point $x$ where we are computing the derivative.

When you approximate $(p(x)q(x))'$ you do get a $O(h^2)$, but the constant in front of $h^2$ depends on the third derivative of $pq$. When you look at the RHS, you also get a $O(h^2)$... but the constant in front of $h^2$ is different. The error will be something like $$ p'''(\xi_3)\frac{h^2}{6} \cdot q(x) + q'''(\xi_4) \frac{h^2}{6} \cdot p(x), $$

which is still $O(h^2)$.