# ijacobian

Jacobian of a multivariate, vector-valued function using the complex-step approximation.

## Syntax

J = ijacobian(f,x0)
J = ijacobian(f,x0,h)


## Description

J = ijacobian(f,x0) numerically evaluates the Jacobian of with respect to at using the complex-step approximation with a default step size of .

J = ijacobian(f,x0,h) numerically evaluates the Jacobian 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}(\mathbf{x})$ multivariate, vector-valued function ($\inline&space;\mathbf{f}:\mathbb{R}^{n}\rightarrow\mathbb{R}^{m}$) 1×1function_handle x0 $\inline&space;\mathbf{x}_{0}$ evaluation point n×1double h $\inline&space;h$ (OPTIONAL) step size 1×1double Output J $\inline&space;\mathbf{J}(\mathbf{x}_{0})=\dfrac{\partial\mathbf{f}}{\partial\mathbf{x}}\bigg\rvert_{\mathbf{x}=\mathbf{x}_{0}}$ Jacobian of $\inline&space;\mathbf{f}$ with respect to $\inline&space;\mathbf{x}$, evaluated at $\inline&space;\mathbf{x}=\mathbf{x}_{0}$ m×ndouble

## Note

• This function requires evaluations of .

## Example

Approximate the Jacobian of

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

Approximating the Jacobian,

f = @(x) [x(1);5*x(3);4*x(2)^2-2*x(3);x(3)*sin(x(1))];
x0 = [5;6;7];
J = ijacobian(f,x0)

J =

1.0000         0         0
0         0    5.0000
0   48.0000   -2.0000
1.9856         0   -0.9589



Calculating the error,

error = J-[1,0,0;0,0,5;0,48,-02;7*cos(5),0,sin(5)]

error =

0     0     0
0     0     0
0     0     0
0     0     0



NOTE: The function and its corresponding Jacobian are from an example on Wikipedia.