Skip to content

auralius/jacobian-hessian-cpp

Repository files navigation

{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "This codes calculate numerically the Jacobian and the Hessian of a vector of function.  \n",
    "For matrix operation, Armadillo is used: http://arma.sourceforge.net/  \n",
    "To install, do the follwoing:\n",
    "\n",
    "```\n",
    "mkdir build  \n",
    "cd build  \n",
    "cmake ..  \n",
    "make  \n",
    "```\n",
    "\n",
    "There is an example provided.  \n",
    "\n",
    "To understand the concept, let's take an example of a function of vector, with 3 input parameters and 2 output parameters:   \n",
    "\n",
    "$y=\\begin{bmatrix} f_1(x_1,x_2,x_3) \\\\ f_2(x_1,x_2,x_3) \\end{bmatrix}$\n",
    "\n",
    "$Jac(y) = \\begin{bmatrix}\n",
    "\\frac{\\partial f_1}{\\partial x_1} & \\frac{\\partial f_1}{\\partial x_2} & \\frac{\\partial f_1}{\\partial x_3} \\\\ \n",
    "\\frac{\\partial f_2}{\\partial x_1} & \\frac{\\partial f_2}{\\partial x_2} & \\frac{\\partial f_2}{\\partial x_3} \n",
    "\\end{bmatrix}$ \n",
    "\n",
    "$Hess(y(1)) = \\begin{bmatrix}\n",
    "\\frac{\\partial^2 f_1}{\\partial x_1^2} & \\frac{\\partial^2 f_1}{\\partial x_1 \\partial x_2} & \\frac{\\partial^2 f_1}{\\partial x_1 \\partial x_3} \\\\\n",
    "\\frac{\\partial^2 f_1}{\\partial x_2 \\partial x_1} & \\frac{\\partial^2 f_1}{\\partial x_2^2} & \\frac{\\partial^2 f_1}{\\partial x_2 \\partial x_3}  \\\\\n",
    "\\frac{\\partial^2 f_1}{\\partial x_3 \\partial x_1} & \\frac{\\partial^2 f_1}{\\partial x_3 \\partial x_2} & \\frac{\\partial^2 f_1}{\\partial x_3^2}\n",
    "\\end{bmatrix}$\n",
    "\n",
    "$Hess(y(2)) = \\begin{bmatrix}\n",
    "\\frac{\\partial^2 f_2}{\\partial x_1^2} & \\frac{\\partial^2 f_2}{\\partial x_1 \\partial x_2} & \\frac{\\partial^2 f_2}{\\partial x_1 \\partial x_3} \\\\\n",
    "\\frac{\\partial^2 f_2}{\\partial x_2 \\partial x_1} & \\frac{\\partial^2 f_2}{\\partial x_2^2}             & \\frac{\\partial^2 f_2}{\\partial x_2 \\partial x_3} \\\\\n",
    "\\frac{\\partial^2 f_2}{\\partial x_3 \\partial x_1} & \\frac{\\partial^2 f_2}{\\partial x_3 \\partial x_2}  & \\frac{\\partial^2 f_2}{\\partial x_3^2}\n",
    "\\end{bmatrix}$"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}

About

Jacobian and Hessian of a vector function.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published