Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #16835

Re: numerical gradient, Jacobian, Hessian: missing from Mathematica?

From Bob Hanlon <hanlonr357@gmail.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: numerical gradient, Jacobian, Hessian: missing from Mathematica?
Date 2014-04-22 03:00 +0000
Message-ID <lj4lvr$ct1$1@smc.vnet.net> (permalink)
References <20140421091124.8C0226A72@smc.vnet.net>
Organization Time-Warner Telecom

Show all headers | View raw


$Version

9.0 for Mac OS X x86 (64-bit) (January 24, 2013)

n=2;

vars=Table[x[m],{m,n}]

{x[1],x[2]}

funcs=Table[f[m]@@vars,{m,n}]

{f[1][x[1],x[2]],f[2][x[1],x[2]]}

http://reference.wolfram.com/mathematica/ref/Grad.html

Grad[funcs, vars]

{{Derivative[1, 0][f[1]][x[1], x[2]], Derivative[0, 1][f[1]][x[1], x[2]]},
   {Derivative[1, 0][f[2]][x[1], x[2]], Derivative[0, 1][f[2]][x[1], x[2]]}}

Grad is new in v9; for some older versions use D[funcs, {vars}]

Grad[funcs, vars]==D[funcs, {vars}]

True

http://mathworld.wolfram.com/Jacobian.html

jacobian=Outer[D,funcs,vars]

{{Derivative[1, 0][f[1]][x[1], x[2]], Derivative[0, 1][f[1]][x[1], x[2]]},
   {Derivative[1, 0][f[2]][x[1], x[2]], Derivative[0, 1][f[2]][x[1], x[2]]}}

Det[jacobian]

Derivative[0, 1][f[2]][x[1], x[2]]*Derivative[1, 0][f[1]][x[1], x[2]] -
   Derivative[0, 1][f[1]][x[1], x[2]]*Derivative[1, 0][f[2]][x[1], x[2]]

http://mathworld.wolfram.com/Hessian.html

hessians=D[#,{vars,2}]&/@funcs

{{{Derivative[2, 0][f[1]][x[1], x[2]], Derivative[1, 1][f[1]][x[1], x[2]]},
     {Derivative[1, 1][f[1]][x[1], x[2]],
   Derivative[0, 2][f[1]][x[1], x[2]]}},
   {{Derivative[2, 0][f[2]][x[1], x[2]],
   Derivative[1, 1][f[2]][x[1], x[2]]},
     {Derivative[1, 1][f[2]][x[1], x[2]],
   Derivative[0, 2][f[2]][x[1], x[2]]}}}

Det/@hessians

{-Derivative[1, 1][f[1]][x[1], x[2]]^2 + Derivative[0, 2][f[1]][x[1], x[2]]*
       Derivative[2, 0][f[1]][x[1],
    x[2]], -Derivative[1, 1][f[2]][x[1], x[2]]^2 +
     Derivative[0, 2][f[2]][x[1], x[2]]*Derivative[2, 0][f[2]][x[1], x[2]]}


Bob Hanlon



On Mon, Apr 21, 2014 at 5:11 AM, Alan <alan.isaac@gmail.com> wrote:

> Am I overlooking commands to produce numerical gradient, Jacobian, and
> Hessian?  The closest I could find was ND (in the NumericalCalculus
> package), which seems to be only for univariate functions.
>
> Thanks,
> Alan Isaac
>
>

Back to comp.soft-sys.math.mathematica | Previous | NextNext in thread | Find similar


Thread

Re: numerical gradient, Jacobian, Hessian: missing from Mathematica? Bob Hanlon <hanlonr357@gmail.com> - 2014-04-22 03:00 +0000
  Re: numerical gradient, Jacobian, Hessian: missing from Mathematica? Alan <alan.isaac@gmail.com> - 2014-04-25 04:44 +0000
  Re: numerical gradient, Jacobian, Hessian: missing from Mathematica? Alexey Popkov <lehin.p@gmail.com> - 2014-04-27 06:07 +0000

csiph-web