How to calculate Gradient of a vectorized equation.

163 Views Asked by At

I am solving a huge optimization problem in Matlab. I am now required to obtain gradient of objective function,and nonlinear constraint along their hessien matrix.
As my problem is completely vectorized, I am confused about calculating the gradient of them. Hereby I write a namely vectorized equation that I should take the derivative from. And I want its gradient in Vector form as well (Not 5 different equation regarding to 5x1 dimension of Eq1) $P_d=\begin{bmatrix}x_1 \\x_2 \\x_3\\x_4\end{bmatrix}$
X values are the optimization variables. Note that X3 doesn't participate in the equation at all
Some definitions: $P_{dn}=\begin{bmatrix}x_1 \\\mu_o \\x_2\\0 \\x4\end{bmatrix}$, $P_{gn}=\begin{bmatrix}x_2 \\x_1 \\\mu_1 \\x_4\\x1\end{bmatrix}$

Now what is the gradient of this equations:

$Eq1=Sin(P_{dn})+P_{dn}+P_{gn}⊙P_{gn}$ where ⊙ shows the element-wise multiplication