Symbolic Math Toolbox 
This example uses Symbolic Math Toolbox to calculate Jacobian matrices of Nelson Siegel and Svensson models, which are commonly used for modeling bond data. The Jacobians can subsequently be imported into MATLAB and used to speed up optimization of model parameters.
NelsonSiegel Model

Svensson Model 
Note that t is the independent variable in these models, and represents time to maturity.
We begin by defining the NelsonSiegel model equation.
y1 := b0+b1*exp(t/t1)+b2*(t/t1)*exp(t/t1)
We extract the indeterminates (i.e. variables) that the Nelson Siegel model is comprised of, and subtract the independent variable t. These variables will be needed for the Jacobian calculation.
v1 := indets(y1) minus {t}
We convert the result from a set to a list and compute the Jacobian matrix of y1 with respect to v1.
v1 := coerce(v1, DOM_LIST);
J1 := linalg::jacobian([y1], v1)
We determine the variable type and dimension of J1 using simple commands.
type(J1)
linalg::matdim(J1)
We now perform the same calculations for the Svensson model. We start by defining the model equation.
y2 := b0+b1*exp(t/t1)+b2*(t/t1)*exp(t/t1)+b3*(t/t2)*exp(t/t2)
We extract the variables that the Svensson model is comprised of, and subtract the independent variable t.
v2 := indets(y2) minus {t}
We convert the result from a set to a list and compute the Jacobian matrix of y2 with respect to v2.
v2 := coerce(v2, DOM_LIST);
J2 := linalg::jacobian([y2], v2)
We determine the variable type and dimension of J2 using simple commands.
type(J2)
linalg::matdim(J2)
We can read the Jacobian matrices J1 and J2 into MATLAB using the getVar function in Symbolic Math Toolbox, and use them to help speed up optimization of model parameters so that they fit realworld government bond data as well as possible. To see the complete example that includes the model optimization and the speed up achieved via analytical Jacobians, view the recorded webinar “ Using MATLAB and Symbolic Math Toolbox to Develop and Analyze Financial Models (36:23) .”