Re: How to calculate Hessian Matrix
- From: fj <francois.jacq@xxxxxxx>
- Date: Tue, 5 Aug 2008 00:39:59 -0700 (PDT)
On 5 août, 09:32, fj <francois.j...@xxxxxxx> wrote:
On 5 août, 04:45, John <john131...@xxxxxxxxx> wrote:
Does anyone know where there is any function/subroutine can compute
the Hessian Matrix of a multivariable function? Thanks a lot!
First of all, your are not posting in the right group.
It is very easy to compute an Hessian matrix using numerical
derivatives. The only problem is the cost especially if the multi
variable function is itself a "vector" function.
The simplest way consists in writing a routine computing the gradient.
After that, you write the function computing the Hessian in the same
way. Let us assume the the function is only scalar :
double precision function f(n,x)
integer,intent(in) :: n
double precision,intent(in) :: x(n)
double precision,intent(out) :: h(n,n)
external :: f,gradient
double precision :: xx(n),df0(n),df(n),xx0
double precision,parameter :: epsilon=1.d-5
integer :: j
Of course, you might improve this simple solution : the parameter
"epsilon" may be passed as argument and may be a vector. You might
also prefer central derivatives rather than "right" derivatives and
define routines f and gradient using interfaces rather than EXTERNAL
Oups ! The instructions in the loop are wrong and should be replaced
Sorry, I was not awake !
- Prev by Date: Re: How to calculate Hessian Matrix
- Next by Date: Re: How to calculate Hessian Matrix
- Previous by thread: Re: How to calculate Hessian Matrix
- Next by thread: Re: How to calculate Hessian Matrix