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/operator description
e A constant e=2.718281828459045
pi A constant pi=3.141592653589793
abs abs(x) the absolute value of x
sqrt sqrt(x) the square root of x
pow or ^ pow(x,y) or x^y the power of x to y
exp exp(x) the base-e exponential function of x
log log(x) the natural logarithm of x
sin sin(x) the sine of x
cos cos(x) the cosine of x
tan tan(x) the tangent of x
asin asin(x) the inverse sine of x
acos acos(x) the inverse cosine of x
atan atan(x) the inverse tangent of x
sinh sinh(x) the hyperbolic sine of x
cosh cosh(x) the hyperbolic cosine of x
tanh tanh(x) the hyperbolic tangent of x
asinh asinh(x) the inverse hyperbolic sine of x
acosh acosh(x) the inverse hyperbolic cosine of x
atanh atanh(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