# iderivative

Derivative of a univariate, vector-valued function using the complex-step approximation.

## Syntax

df = iderivative(f,x0)
df = iderivative(f,x0,h)


## Description

df = iderivative(f,x0) numerically evaluates the derivative of with respect to at using the complex-step approximation with a default step size of .

df = iderivative(f,x0,h) numerically evaluates the derivative of with respect to at using the complex-step approximation with a user-specified step size .

## Input/Output Parameters

 Variable Symbol Description Format Input f $\inline&space;\mathbf{f}(x)$ univariate, vector-valued function ($\inline&space;\mathbf{f}:\mathbb{R}\rightarrow\mathbb{R}^{m}$) 1×1function_handle x0 $\inline&space;x_{0}$ evaluation point 1×1double h $\inline&space;h$ (OPTIONAL) step size 1×1double Output df $\inline&space;\dfrac{d\mathbf{f}}{dx}\bigg\rvert_{x=x_{0}}$ derivative of $\inline&space;\mathbf{f}$ with respect to $\inline&space;x$, evaluated at $\inline&space;x=x_{0}$ m×1double

## Note

• This function requires 1 evaluation of .
• If the function is scalar-valued, then .

## Example #1: Derivative of a scalar-valued function.

Approximate the derivative of at using the iderivative function, and compare the result to the true result of .

Approximating the derivative,

f = @(x) x^3;
df = iderivative(f,2)

df =

12



Calculating the error,

error = df-12

error =

0



## Example #2: Derivative of a vector-valued function.

Approximate the derivative of

at using the iderivative function, and compare the result to the true result of

Approximating the derivative,

f = @(t) [sin(t);cos(t)];
df = iderivative(f,1)

df =

0.5403
-0.8415



Calculating the error,

error = df-[cos(1);-sin(1)]

error =

0
0