## Name:

autodiff Computes the first n derivatives of a function at a point or over an interval.

## Library name:

sollya_obj_t sollya_lib_autodiff(sollya_obj_t, sollya_obj_t, sollya_obj_t)

## Usage:

autodiff(f, n, x0) : (function, integer, constant) -> list autodiff(f, n, I) : (function, integer, range) -> list

## Parameters:

• f is the function to be differentiated.
• n is the order of differentiation.
• x0 is the point at which the function is differentiated.
• I is the interval over which the function is differentiated.

## Description:

• autodiff computes the first n derivatives of f at point x0. The computation is performed numerically, without symbolically differentiating the expression of f. Yet, the computation is safe since small interval enclosures are produced. More precisely, autodiff returns a list [f_0, ..., f_n] such that, for each i, f_i is a small interval enclosing the exact value of f^(i)(x0).
• Since it does not perform any symbolic differentiation, autodiff is much more efficient than diff and should be preferred when only numerical values are necessary.
• If an interval I is provided instead of a point x0, the list returned by autodiff satisfies: for each i, f^(i)(I) is included in f_i. A particular use is when one wants to know the successive derivatives of a function at a non representable point such as pi. In this case, it suffices to call autodiff with the (almost) point interval I = [pi].
• When I is almost a point interval, the returned enclosures f_i are also almost point intervals. However, when the interval I begins to be fairly large, the enclosures can be deeply overestimated due to the dependency phenomenon present with interval arithmetic.
• As a particular case, f_0 is an enclosure of the image of f over I. However, since the algorithm is not specially designed for this purpose it is not very efficient for this particular task. In particular, it is not able to return a finite enclosure for functions with removable singularities (e.g. sin(x)/x at 0). The command evaluate is much more efficient for computing an accurate enclosure of the image of a function over an interval.

## Example 1:

> L = autodiff(exp(cos(x))+sin(exp(x)), 5, 0);
> midpointmode = on!;
> for f_i in L do f_i;
0.3559752813266941742012789792982961497379810154498~2/4~e1
0.5403023058681397174009366074429766037323104206179~0/3~
-0.3019450507398802024611853185539984893647499733880~6/2~e1
-0.252441295442368951995750696489089699886768918239~6/4~e1
0.31227898756481033145214529184139729746320579069~1/3~e1
-0.16634307959006696033484053579339956883955954978~3/1~e2

## Example 2:

> f = log(cos(x)+x);
> L = autodiff(log(cos(x)+x), 5, [2,4]);
> L[0];
[0;1.27643852425465597132446653114905059102580436018893]
> evaluate(f, [2,4]);
[0.45986058925497069206106494332976097408234056912429;1.20787210589964169595901037621103012113048821362855]
> fprime = diff(f);
> L[1];
[2.53086745013099407167484456656211083053393118778677e-2;1.7568024953079282513726390945118290941359128873365]
> evaluate(fprime,[2,4]);
[2.71048755415961996452136364304380881763456815673085e-2;1.1091953066394329083739722578862353140555843127995]

## Example 3:

> L = autodiff(sin(x)/x, 0, [-1,1]);
> L[0];
[-infty;infty]
> evaluate(sin(x)/x, [-1,1]);
[0.5403023058681397174009366074429766037323104206179;1]
See also: diff, evaluate
Go back to the list of commands