# Automatic Differentiation

Automatic Differentiation

This is a dual number expression RPN (reverse Polish notation) calculator for automatic differentiation, modeled on an old-style scientific calculator. Dual numbers are numbers of the form , where , are real and =0. ( is displayed with and in adjacent boxes. Use the calculator to calculate an arithmetic expression in and reals , , and ). Clicking a value puts the value on top of a pile. Clicking an "op" applies the "op" to the top member(s) of the pile as argument(s), and replaces them on the pile with its value. This is the RPN method of evaluation. The list of buttons clicked will be the reverse Polish notation for the expression. If the result is for a function , its value will be . Thus, is calculated "automatically". Moreover, this will be the result if is any function computable by the calculator. In fact, . It is as if were expanded in a Maclaurin series in , since =0.

a+bϵ

a

b

2

ϵ

a+bϵ

a

b

x+ϵ

a

b

c

f(x+ϵ)

f

f(x)+f'(x)ϵ

f'(x)

f

f(x+hϵ)=f(x)+hf'(x)ϵ

f(x+hϵ)

ϵ

2

ϵ

Click "x + e", "x + e", "*" to get +2xϵ.

2

x

Click "x + e", "x + e", *, "a", +, "x + e", "*" to get .

(+a)x+(3+a)ϵ

2

x

2

x

Click "x + e", "x^2", "x + e", "1/x", "sin", "*" to get sin+2xsin-cosϵ.

2

x

1

x

1

x

1

x

Click "x + h e", "cos", "x^2" to get (x)-2hsin(x)cos(x)ϵ.

2

cos

Calculating an expression in dual numbers and results in .

f(x+hϵ,y+kϵ)

x+hϵ

y+hϵ

f(x,y)+(h(x,y)+k(x,y))ϵ

f

1

f

2

For example, to compute the partial derivatives of +, click "x + h e", "y + k e", "x^2", "*", "x + h e", "x^2", "y + k e", "x^2", "+", "/". The partial derivatives are the coefficients of and in the second box.

x

2

y

2

x

2

y

h

k

Built-in generic functions and of one variable and and of two variables can be used to derive general differentiation formulas.

f

g

F

G

For example, compute the formula for the derivative of by clicking "x + e", "f", "x + e", "g", "/" and for by clicking "a", "x + e", "*", "f".

f(x)

g(x)

f(ax)

The expression pile contains symbolic expressions and the value pile contains these expressions evaluated at , , , , and . (To get decimal values, set an involved slider to a decimal value.) Click "clear" to start a new calculation. The calculator can also be used to calculate real expressions and their values in , , , , and .

x=

x

0

y=

y

0

a=

a

0

b=

b

0

c=

c

0

x

y

a

b

c