This is an implementation of Taylor arithmetic in Octave. It started as a proof of concept implementation but the current goal is to develop a full package.
Much of the work have been done with spare time from the Google Summer of Code project https://gsocinterval.blogspot.se/
The package is developed to work with the interval package for Octave but should in general also work with normal floating point numbers and even complex numbers.
Short about Taylor arithmetic
Taylor arithmetic is a method for automatically computing derivatives for functions. It is suitable for computing high order derivatives. For a short introduction to Taylor arithmetic and this package see this blogpost.
For another implementation of implementation of Taylor arithmetic see for example Real and Complex Taylor Arithmetic in C-XSC.
Functions to be implemented
Taylor array functions
Creating a Taylor expansion
To create a Taylor expansion you use the class constructor
taylor (). The order of the Taylor expansion has to be decided upon
construction, for example if you only need the first derivative order
1 is sufficient. To create a variable with value
v of order
x = taylor (v, n, 'var')
To create a constant with the same value and order
c = taylor (v, n, 'const')
It is also possible to directly specify the coefficients for the expansion, for example
f = taylor (infsupdec ([5, 3, 2]))
will create a function with
f(x0) = _com,
f'(x0) = _com and
f''(x0) = _com/2! = _com.
Computing with Taylor expansions
The Taylor package overloads most numerical functions and Taylor expansions can thus be used in computations much like ordinary intervals or numbers.
For example we can calculate the third order Taylor expansion for the
f(x) = 2x + 1 at
x = 2
> f = @(x) 2.*x + 1; > x = taylor (infsupdec (2), 3) x = _com + _com X + _com X^2 + _com X^3 > y = f (x) y = _com + _com X + _com X^2 + _com X^3
so the value is 5, the first derivative 2 and all other
derivatives 0. We can also take a more complicated function like
g(x) = log(x*exp(sin(x))) and evaluate the third order Taylor expansion
x = 5
> g = @(x) log(x.*exp(sin(x))); > x = taylor (infsupdec (5), 3) x = _com + _com X + _com X^2 + _com X^3 > y = g (x) y = [0.65051, 0.65052]_com + [0.48366, 0.48367]_com X + [0.45946, 0.45947]_com X^2 + [-0.044611, -0.04461]_com X^3
So the value is enclosed in
[0.65051, 0.65052] and the derivative in
[0.48366, 0.48367]. For the higher order derivatives we have to
multiply with the appropriate factorial, the second derivative is
[0.91892, 0.91893] and the third in
Authors, License, Credits
This package is the work of Joel Dahne. It takes much inspiration, and depends on, the interval package for Octave. It is released under the terms of the GNU General Public License, version 3.