]> git.rustad.me Git - nummat1/commitdiff
Fix error in gradient
authorBjørn Rustad <bjorn@rustad.me>
Fri, 30 Sep 2011 13:19:55 +0000 (15:19 +0200)
committerBjørn Rustad <bjorn@rustad.me>
Fri, 30 Sep 2011 13:19:55 +0000 (15:19 +0200)
function.py
rapport.tex

index 480ceb9d03104a5e959e170c02ea10d0b7fbffd7..5c9cd9fbc3fdca3cebfe2a93affc2bdd7715004f 100644 (file)
@@ -13,7 +13,7 @@ def _C(x, c):
 
 # Calculate gradient of g in point x
 def gradient_g(x, H, b, c):
-    return -b.T + 0.5 * H.dot(x) + 0.5 * H.T.dot(x) + (1.0/3.0) * x.T.dot(_C(x,c))
+    return -b + H.dot(x) + (1.0/3.0) * _C(x,c).dot(x)
 
 # Calculate hessian of g in point x
 def hessian_g(x, H, b, c):
index 29a90b1b21a28db486890ad544c9154f52cb2284..9befc0b48fe733c9b4dd5bf0407da38abd21eb22 100644 (file)
@@ -88,18 +88,13 @@ The function analyzed in this project was
 \label{eq:func_g}\r
 g(\mathbf{x}) := -\mathbf{b}^{T}\mathbf{x}+\frac{1}{2}\mathbf{x}^{T}H\mathbf{x}+\frac{1}{12}\mathbf{x}^{T}C(\mathbf{x})\mathbf{x}\r
 \end{equation}\r
-\r
 From equation \ref{eq:func_g} we get\r
-\r
-\begin{equation}\r
+\begin{eqnarray}\r
 \label{eq:grad_g}\r
-\nabla g(\mathbf{x}) = -\mathbf{b}^{T}+H\mathbf{x}+\frac{1}{3}\mathbf{x}^{T}C(\mathbf{x}),\r
-\end{equation}\r
-\begin{equation}\r
+\nabla g(\mathbf{x}) &=& -\mathbf{b}+H\mathbf{x}+\frac{1}{3}C(\mathbf{x})\mathbf{x} \\\r
 \label{eq:hess_g}\r
-\nabla^{2}g(\mathbf{x}) = H+C(\mathbf{x}).\r
-\end{equation}\r
-\r
+\nabla^{2}g(\mathbf{x}) &=& H+C(\mathbf{x}).\r
+\end{eqnarray}\r
 The three functions, \ref{eq:func_g}, \ref{eq:grad_g} and \ref{eq:hess_g}, are implemented in the Python code below.\r
 \r
 \lstinputlisting[language=Python]{bj_function.py}\r