<< diffcode_CDcost diffcode diffcode_hessian >>

diffcode >> diffcode > diffcode_der

diffcode_der

Create a new code differentiation object.

Calling Sequence

VDV=diffcode_der(v,dv)

Parameters

v :

matrix of doubles, or hypermatrix of doubles, or diffcode object

dv :

matrix of doubles, or hypermatrix of doubles, or diffcode object. dv must have the same size as v

VDV :

a data structure with type "TDFFCD".

Description

This function creates a data structure containing the value and the directional derivative.

On output, the data structure VDV has two fields:

This module is based on overloading.

The principle of the module is the following. Assume that a function f is defined by

	  v=f(x)
	  

where x is the input and v is the output. Then the directional derivative is

	  dv = f'(x) dx
	  

where dx is the directional derivative of x and dv is the directional derivative of v.

Examples

In the following example, we compute the function value and derivative of z=x^3+y^3+2*x*y.

// The function
function z=f(x, y)
  z=x^3+y^3+2*x*y
endfunction

// The evaluation point
x=2;
y=3;
// The direction
dv=-1;
dy=4;

xy=diffcode_der([x,y],[dv,dy]);

// Compute the value and directional derivative
z=f(xy(1),xy(2))

// Let's check this.
// The value at the point (x,y):
x^3+y^3+2*x*y 
// The exact derivative:
dzdx=3*x^2+2*y;
dzdy=2*x+3*y^2;
// The directional derivative at the 
// point (x,y) along (dv,dy):
[dzdx dzdy]*[dv;dy]

Authors


Report an issue
<< diffcode_CDcost diffcode diffcode_hessian >>