# Automatic differentiation

In mathematics and computer algebra, automatic differentiation is a method to evaluate the derivative of a function, at a given point. Two classical ways of doing this are:

• symbolically differentiate the function and evaluate it in the point; or
• use finite differences.

The drawback with symbolic differentiation is low speed. Many functions grow too complex as higher derivatives are calculated. Two important drawbacks with finite differences are round-off errors in the discretization process, and cancellation. Thus both classical methods have problems with calculating higher derivatives, where the complexity and errors increase. Automatic differentiation solves all of the mentioned problems and is easily implemented on computers.

 Contents

## First-order automatic differentiation

A new arithmetic is introduced using ordered pairs as objects. The new arithmetic uses ordinary arithmetic on the first element of the pair and a first order differentiation arithmetic applying the chain rule on the second element. The basic arithmetic operations and some standard functions are defined by

[itex]\left(u,u'\right)+\left(v,v'\right)=\left(u+v, u'+v' \right)[itex]
[itex]\left(u,u'\right)-\left(v,v'\right)=\left(u-v, u'-v' \right)[itex]
[itex]\left(u,u'\right)*\left(v,v'\right)=\left( u v, u'v+uv' \right)[itex]
[itex]\left(u,u'\right)/\left(v,v'\right)=\left( \frac{u}{v}, \frac{u'v-uv'}{v^2} \right)\quad \left(v\ne 0\right)[itex]
[itex]\sin\left(u,u'\right)=\left(\sin\left(u\right),u'\cos\left(u\right)\right)[itex]
[itex]\cos\left(u,u'\right)=\left(\cos\left(u\right),-u'\sin\left(u\right)\right)[itex]
[itex]e^{\left(u,u'\right)}=\left(e^u,u'e^u\right)[itex]

The derivative of a function [itex]f\left( x \right)[itex] at the point [itex]x_0[itex] is now calculated by substituting [itex]x_0[itex] by the ordered pair [itex]\left(x_0,1\right)[itex] in the expression for [itex]f\left( x \right)[itex]. A constant c is substituted by [itex]\left(c,0\right)[itex]. Calculating [itex]f'\left( x_0 \right) [itex] using the above arithmetic gives [itex]\left( f \left( x_0 \right), f' \left( x_0 \right) \right) [itex] as the answer.

## Higher order automatic differentiation

The above arithmetic can be generalized, in the natural way, to second order and higher derivatives. However, the arithmetic rules quickly grow very complicated. Instead, truncated Taylor series arithmetic is used. This is possible because the Taylor summands in a Taylor series of a function are products of known coefficients and derivatives of the function.

## Software

There are plenty of libraries for automatic differentiation.

An "entry site to everything you want to know about automatic differentiation" (http://www.autodiff.org/)

• Art and Cultures
• Musical Instruments (http://academickids.com/encyclopedia/index.php/List_of_musical_instruments)
• Countries of the World (http://www.academickids.com/encyclopedia/index.php/Countries)
• Ancient Civilizations (http://www.academickids.com/encyclopedia/index.php/Ancient_Civilizations)
• Industrial Revolution (http://www.academickids.com/encyclopedia/index.php/Industrial_Revolution)
• Middle Ages (http://www.academickids.com/encyclopedia/index.php/Middle_Ages)
• United States (http://www.academickids.com/encyclopedia/index.php/United_States)
• World History (http://www.academickids.com/encyclopedia/index.php/History_of_the_world)
• Human Body (http://www.academickids.com/encyclopedia/index.php/Human_Body)
• Physical Science (http://www.academickids.com/encyclopedia/index.php/Physical_Science)
• Social Studies (http://www.academickids.com/encyclopedia/index.php/Social_Studies)
• Space and Astronomy
• Solar System (http://www.academickids.com/encyclopedia/index.php/Solar_System)