computeJacobian

Method of CPNTensor.

Core method for computing the Jacobian matrix of a CPN tensor.

Source: src/tensor/@CPNTensor/computeJacobian.m

Syntax

jacobianMatrix = computeJacobian(obj,v,mtiBase)
[jacobianMatrix,jacobianFunctionHandle] = computeJacobian(obj,v,mtiBase)

Description

The computeJacobian is the core function called by all jacobian-instances using a CPN tensor. It computes the partial derivatives with respect to all variables π―βˆˆβ„nvariables\mathbf{v}\in\mathbb{R}^{n_\mathrm{variables}} as follows:

𝐉=βˆ‚πŸ(𝐯)βˆ‚π―|𝐯=π―β€Ύβˆˆβ„nequationΓ—nvariables, \mathbf{J} = \left.\frac{\partial \mathbf{f}(\mathbf{v})}{\partial \mathbf{v}}\right|_{\mathbf{v}=\bar{\mathbf{v}}} \in \mathbb{R}^{n_\mathrm{equation}\times n_\mathrm{variables}},

where π―β€Ύβˆˆβ„nvariables\bar{\mathbf{v}}\in\mathbb{R}^{n_\mathrm{variables}} is the operating point.

The differentiated function

Each equation in the vector function behind the CPN tensor of rank RR can be written as

fl(𝐯)=βˆ‘r=1RΞ¦lrρr(𝐯),ρr(𝐯)=∏n=1nvariablesgb(Snr,vn), f_l(\mathbf{v}) = \sum_{r=1}^{R} \Phi_{lr}\,\rho_r(\mathbf{v}), \qquad \rho_r(\mathbf{v}) = \prod_{n=1}^{n_\mathrm{variables}} g_b\big(S_{nr},v_n\big),

The factors and the role of mtiBase

mtiBase selects the multilinear basis, and it reinterprets only the continuous structure entries (𝐒continuous\mathbf{S}_\mathrm{continuous}). The True and False channels are identical in both bases:

Channel Factor gb(s,vn)g_b(s,v_n) Slope βˆ‚gb/βˆ‚vn\partial g_b/\partial v_n
True (𝐒true\mathbf{S}_\mathrm{true}) vnv_n +1+1
False (𝐒false\mathbf{S}_\mathrm{false}) 1βˆ’vn1-v_n βˆ’1-1
continuous, monomial (mtiBase=0) 1βˆ’|s|+svn1-\lvert s\rvert + s\,v_n ss
continuous, literal (mtiBase=1) 1βˆ’|s|+(s+|s|βˆ’1)vn1-\lvert s\rvert + (s+\lvert s\rvert-1)\,v_n s+|s|βˆ’1s+\lvert s\rvert-1

Both bases share the same intercept 1βˆ’|s|1-\lvert s\rvert and differ only in the slope. Consequently the Jacobian of one and the same CPN tensor is base dependent.

Worked comparison

For 𝐒=(0.50.3)\mathbf{S}=\begin{pmatrix}0.5\\0.3\end{pmatrix}, 𝚽=1\mathbf{\Phi}=1 and 𝐯‾=(1,1)\bar{\mathbf{v}}=(1,1) the same tensor gives

mtiBase represented function 𝐉(𝐯‾)\mathbf{J}(\bar{\mathbf{v}})
0 (monomial) (0.5+0.5v1)(0.7+0.3v2)(0.5+0.5v_1)(0.7+0.3v_2) (0.50.3)\begin{pmatrix}0.5 & 0.3\end{pmatrix}
1 (literal) 0.5(0.7βˆ’0.4v2)0.5\,(0.7-0.4v_2) (0βˆ’0.2)\begin{pmatrix}0 & -0.2\end{pmatrix}

In the literal base S11=0.5S_{11}=0.5 is the don’t-care, so v1v_1 drops out of the function entirely.

For more information on the computation of the Jacobian matrix of a continuous-valued CPN tensor, see [1].

Input Arguments

Argument Type Description
obj CPNTensor A CPN tensor object.
v double Vector containing the operating point or a vector of variables.
mtiBase Boolean Base of MTI model (monomial: mtiBase=false, literal: mtiBase=true)

Output Arguments

Argument Type Description
jacobianMatrix double Sparse Jacobian matrix, where the rows correspond to the last mode of the CPN tensor, typically corresponding to the equation, and the columns correspond to the variables. No reordering is performed.
jacobianFunctionHandle function_handle Function handle to get the sparse Jacobian matrix for different operating points.

Examples

Computing the Jacobian matrix of a continuous-valued CPN tensor

Consider the following continuous-valued example with three variables π―βˆˆβ„3\mathbf{v}\in\mathbb{R}^3

f1=2(0.5+0.5v1)v2,f2=4(0.5+0.5v1)v2+6(0.5βˆ’0.5v1)v3,f3=8(0.5βˆ’0.5v1)v3.\begin{aligned} f_1&=2(0.5+0.5v_1)v_2,\\ f_2&=4(0.5+0.5v_1)v_2+6(0.5-0.5v_1)v_3,\\ f_3&=8(0.5-0.5v_1)v_3.\\ \end{aligned}

In this case, the multilinear basis is the monomial tensor. We want to evaluate the CPN tensor of the above set of equations at the point 𝐯‾=(βˆ’1,1,3)\bar{\mathbf{v}}=(-1,1,3).

% constructing the CPN tensor
structureMatrix=[0.5 -0.5;
                  1     0;
                  0    1];
mtiBase=0;

parameterMatrix=[2 0;
                 4 6;
                 0 8];

T= CPNTensor(structureMatrix,parameterMatrix);

% generating the operating point of the variables
v_op=[-1;1;3]; 

% compute Jacobian matrix
jacobianMatrix=computeJacobian(T,v_op, mtiBase);

The result gives Jacobian matrix

𝐉=(100βˆ’706βˆ’1208).\mathbf{J}=\begin{pmatrix}1& 0& 0\\ -7& 0& 6\\ -12 &0 &8 \end{pmatrix}.

Computing the Jacobian function handle of a continuous-valued CPN tensor

Alternatively, the Jacobian could be evaluated at different operating points, which can be achieved by creating a function handle. Consider the function: f=6(12βˆ’12v1)(23+13v2).f=6\left(\frac{1}{2}-\frac{1}{2}v_1 \right)\left(\frac{2}{3}+\frac{1}{3}v_2\right).

The multilinear base is a monomial base.

% Create the CPN tensor
structureMatrix = [-1/2;
                    1/3];
mtiBase=0;
parameterMatrix = [  6 ];

T = CPNTensor(structureMatrix,parameterMatrix); 

% development point
v0 = [1; 1];    

% function handle is the second output argument
[~,jacobinaFunctionHandle] = computeJacobian(T,v0,mtiBase);    

J=jacobinaFunctionHandle(v0);

The result is the Jacobian matrix:

𝐉=(βˆ’30).\mathbf{J}=\begin{pmatrix} -3& 0 \end{pmatrix}.

Hybrid CPN tensor

Consider the following example

f=(0.5βˆ’0.5v1)(0.7+0.3v2), f=(0.5-0.5v_1)(0.7+0.3 v_2),

which uses a literal basis.

structureMatrix = [-0.5;
                    0.3];
mtiBase=1;% literal base

parameterMatrix = [ 1 ];

T = CPNTensor(structureMatrix,parameterMatrix);   % Generate the CPN tensor

v0 = [1; 1];    % development point

J = round(computeJacobian(T,v0,mtiBase),4);    

The result is the Jacobian matrix:

𝐉=(βˆ’0.30.2).\mathbf{J}=\begin{pmatrix} -0.3& 0.2 \end{pmatrix}. ### References

[1] Christoph Kaufmann, Diego CrespΓ­ de Valldaura Garcia, Gerwald Lichtenberg, Georg Pangalos, Carlos Cateriano YÑñez, β€œEfficient Linearization of Explicit Multilinear Systems using Normalized Decomposed Tensors”, IFAC-PapersOnLine, Volume 56, Issue 2, 2023, Pages 7312-7317, ISSN 2405-8963, https://doi.org/10.1016/j.ifacol.2023.10.344

See Also

jacobian | mss/stateJacobian | mss/outputJacobian | mdss/jacobian


MyToolbox Documentation | Generated automatically by CI/CD pipeline