Derivative Calculator

Let $f(x)$ be a function of a real variable $x$ and given $a$ a real number, this application find at $x=a$ the value of function, $f(a)$, the first derivative of function, $f'(a)$, and the second derivative of function, $f''(a)$. To calculate the derivatives of the function, the calculator use a method of automatic differentiation (AD). In AD, the calculator exploits the fact that the math expressions of $f(x)$ consist of some elementary arithmetic operations (addition, subtraction, multiplication, division, etc.) and elementary functions which currently 17 functions, as list in the table below, are supported. By applying the chain rule repeatedly to these operations, the derivatives can be computed automatically and accurately to working precision. For example $f(x)=x^3\sin(x)$ and $a=\frac{\pi}{4}$, below are the results calculated with this calculator:

f   = 0.342574195312286
f'  = 1.651111232744576
f'' = 5.606662083171068
The derivatives have fourteen decimal place accuracy when compared to those calculated with analytic formulas.

Input Data

The calculator required from users two inputs: $f(x)$ and $a$. The first input will be in the form of math expressions with $x$ as the variable. The second input can be just a real number, for example 3, or a math expression of real numbers like 2^3+exp(pi). The valid math expressions for $f(x)$ is similar to those in calculus textbooks, for examples, in multiplication between numbers and x you can write 2x or 2*x, 2sin(x) or 2*sin(x), 3exp(-x) or 3*exp(-x), etc. So the math expressions can consist of arithmetic operators and the following elementary functions and operators.

function/operatordescription
eA constant e=2.718281828459045
piA constant pi=3.141592653589793
absabs(x) the absolute value of x
sqrtsqrt(x) the square root of x
pow or ^pow(x,y) or x^y the power of x to y
expexp(x) the base-e exponential function of x
loglog(x) the natural logarithm of x
sinsin(x) the sine of x
coscos(x) the cosine of x
tantan(x) the tangent of x
asinasin(x) the inverse sine of x
acosacos(x) the inverse cosine of x
atanatan(x) the inverse tangent of x
sinhsinh(x) the hyperbolic sine of x
coshcosh(x) the hyperbolic cosine of x
tanhtanh(x) the hyperbolic tangent of x
asinhasinh(x) the inverse hyperbolic sine of x
acoshacosh(x) the inverse hyperbolic cosine of x
atanhatanh(x) the inverse hyperbolic tangent of x
? :Ternary if-then-else operator, e.g. (x>0?1:-1)
Note that the operator ?: should be used with parenthesis, as shown in the table. You can also use parenthesis if you want the math expression parsed differently from the default, for example x^3sin(x) is parsed to $x^3\sin(x)$ but if you write x^(3sin(x)) it will be $x^{3\sin(x)}$.

Derivative Calculator