Help with Numerical
Differentiation
Prof. Richard B. Goldstein
(x2 + 2x - 1)5/3 |
is Math.pow((x*x+2*x-1),5/3) |
|
is
Math.sqrt(Math.sin(x)/(Math.pow(2,x)+3*Math.log(x))) |
calculus formula |
Javascript Function |
xo |
f(1)(xo) |
f(2) (xo) |
#1 |
x3+2x |
1*Math.pow(x,3)+2*x |
1 |
5 |
6 |
#2 |
e3xsin(2x) |
Math.exp(3*x)*Math.sin(2*x) |
0 |
2 |
12 |
The formulas and
program will work well for most functions. Note that JavaScript will
require the 1 coefficient. This is because it prefers working with
strings. That is, y=a+b where a is 2.4 and b is 3.3 will not yield 5.7.
Rather, it will get 2.43.3 a value it doesn't understand. Even worse, a =
2.5 and b = 3 will give 2.53 an incorrect number which it does understand.
Generally, higher derivatives are less accurate when calculated
numerically. The following formulas are basically derived from the Taylor
Series approximation of a function.
|
Formulas:
|