## 编写向量和矩阵目标函数

### 向量函数的雅可比矩阵

`${J}_{ij}\left(x\right)=\frac{\partial {F}_{i}\left(x\right)}{\partial {x}_{j}}.$`

`$F\left(x\right)=\left[\begin{array}{c}{x}_{1}^{2}+{x}_{2}{x}_{3}\\ \mathrm{sin}\left({x}_{1}+2{x}_{2}-3{x}_{3}\right)\end{array}\right],$`

，则 J(x) 是

`$J\left(x\right)=\left[\begin{array}{ccc}2{x}_{1}& {x}_{3}& {x}_{2}\\ \mathrm{cos}\left({x}_{1}+2{x}_{2}-3{x}_{3}\right)& 2\mathrm{cos}\left({x}_{1}+2{x}_{2}-3{x}_{3}\right)& -3\mathrm{cos}\left({x}_{1}+2{x}_{2}-3{x}_{3}\right)\end{array}\right].$`

```function [F jacF] = vectorObjective(x) F = [x(1)^2 + x(2)*x(3); sin(x(1) + 2*x(2) - 3*x(3))]; if nargout > 1 % need Jacobian jacF = [2*x(1),x(3),x(2); cos(x(1)+2*x(2)-3*x(3)),2*cos(x(1)+2*x(2)-3*x(3)), ... -3*cos(x(1)+2*x(2)-3*x(3))]; end```

`options = optimoptions('lsqnonlin','SpecifyObjectiveGradient',true);`

### 矩阵函数的雅可比矩阵

`$F=\left[\begin{array}{cc}{F}_{11}& {F}_{12}\\ {F}_{21}& {F}_{22}\\ {F}_{31}& {F}_{32}\end{array}\right]$`

`$f=\left[\begin{array}{c}{F}_{11}\\ {F}_{21}\\ {F}_{31}\\ {F}_{12}\\ {F}_{22}\\ {F}_{32}\end{array}\right].$`

F 的雅可比矩阵可定义为 f 的雅可比矩阵

`${J}_{ij}=\frac{\partial {f}_{i}}{\partial {x}_{j}}.$`

`$F\left(x\right)=\left[\begin{array}{cc}{x}_{1}{x}_{2}& {x}_{1}^{3}+3{x}_{2}^{2}\\ 5{x}_{2}-{x}_{1}^{4}& {x}_{2}/{x}_{1}\\ 4-{x}_{2}^{2}& {x}_{1}^{3}-{x}_{2}^{4}\end{array}\right],$`

`$J\left(x\right)=\left[\begin{array}{cc}{x}_{2}& {x}_{1}\\ -4{x}_{1}^{3}& 5\\ 0& -2{x}_{2}\\ 3{x}_{1}^{2}& 6{x}_{2}\\ -{x}_{2}/{x}_{1}^{2}& 1/{x}_{1}\\ 3{x}_{1}^{2}& -4{x}_{2}^{3}\end{array}\right].$`

### 具有矩阵值自变量的雅可比矩阵

`$X=\left[\begin{array}{cc}{x}_{11}& {x}_{12}\\ {x}_{21}& {x}_{22}\end{array}\right],$`

`$x=\left[\begin{array}{c}{x}_{11}\\ {x}_{21}\\ {x}_{12}\\ {x}_{22}\end{array}\right].$`

`$F=\left[\begin{array}{cc}{F}_{11}& {F}_{12}\\ {F}_{21}& {F}_{22}\\ {F}_{31}& {F}_{32}\end{array}\right],$`

`${J}_{ij}=\frac{\partial {f}_{i}}{\partial {x}_{j}}.$`