9887

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 . ( 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 .
Click "x + e", "x + e", "*" to get .
Click "x + e", "x + e", *, "a", +, "x + e", "*" to get .
Click "x + e", "x^2", "x + e", "1/x", "sin", "*" to get .
Click "x + h e", "cos", "x^2" to get .
Calculating an expression in dual numbers and results in .
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.
Built-in generic functions and of one variable and and of two variables can be used to derive general differentiation formulas.
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".
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 .

SNAPSHOTS

  • [Snapshot]
  • [Snapshot]
  • [Snapshot]
  • [Snapshot]

DETAILS

The calculator works by extending built-in functions of one or two real variables to duals by and . The chain rule implies these relations hold for every computable function.
For example, if and , then .
In Dual Number, a dual number is a number of the form , where and are real, and is a matrix such that , such as
Our calculator represents the dual number as the expression , with operations defined by
,
,
, which defines negation () and hence subtraction,
for real , which defines reciprocal () and hence division,
, for functions of one variable,
for functions of two variables,
.
These rules are implemented in Mathematica using "up values". With operations thus overloaded, the calculator is implemented as if it were defined only for reals.
References
[1] D. Piponi, "Automatic Differentiation". A Neighborhood of Infinity. (Jul 28, 2005) blog.sigfpe.com/2005/07/automatic-differentiation.html.
[2] L. B. Rall, "The Arithmetic of Differentiation," Mathematics Magazine, 59(5), 1986, pp. 275–282.
[3] R. D. Neidinger, "Automatic Differentiation and APL," The College Mathematics Journal, 20(3), 1989 pp. 238–251.
[4] R. D. Neidinger, "Introduction to Automatic Differentiation and MATLAB Obect Oriented Programming," SIAM Review, 52(3), 2010 pp. 545–563.
Also see the Wikipedia entries for Dual number and Automatic differentiation.
    • Share:

Embed Interactive Demonstration New!

Just copy and paste this snippet of JavaScript code into your website or blog to put the live Demonstration on your site. More details »

Files require Wolfram CDF Player or Mathematica.









 
RELATED RESOURCES
Mathematica »
The #1 tool for creating Demonstrations
and anything technical.
Wolfram|Alpha »
Explore anything with the first
computational knowledge engine.
MathWorld »
The web's most extensive
mathematics resource.
Course Assistant Apps »
An app for every course—
right in the palm of your hand.
Wolfram Blog »
Read our views on math,
science, and technology.
Computable Document Format »
The format that makes Demonstrations
(and any information) easy to share and
interact with.
STEM Initiative »
Programs & resources for
educators, schools & students.
Computerbasedmath.org »
Join the initiative for modernizing
math education.
Step-by-step Solutions »
Walk through homework problems one step at a time, with hints to help along the way.
Wolfram Problem Generator »
Unlimited random practice problems and answers with built-in Step-by-step solutions. Practice online or make a printable study sheet.
Wolfram Language »
Knowledge-based programming for everyone.
Powered by Wolfram Mathematica © 2014 Wolfram Demonstrations Project & Contributors  |  Terms of Use  |  Privacy Policy  |  RSS Give us your feedback
Note: To run this Demonstration you need Mathematica 7+ or the free Mathematica Player 7EX
Download or upgrade to Mathematica Player 7EX
I already have Mathematica Player or Mathematica 7+