|
From: | Fotios Kasolis |
Subject: | Suggestion - derivatives |
Date: | Mon, 11 Oct 2010 23:43:28 +0200 |
I suggest to include in Octave a function that
calculates first derivatives/Jacobian matrix since optimization problems become
of increasingly great importance. I am working on that and I have a weakly
"optimized" finite difference routine using arbitrary stencils
n = 9;
h = 10^(-16/(n - 1)); r = 0; A = ones (n); while (rcond (A) < eps) x = x0 + [ -(n - 1)*h/2 : h : (n - 1)*h/2 ]; f = fun (x); A_ = repmat (x(:), 1, n); n_ = repmat (n - 1:-1:0, n, 1); A = A_.^n_; h = 2*h endwhile p = mldivide (A, f(:));
dfdx = polyval (polyder (p), x0); I will also include the complex variable step
derivative
imag (fun(x0 + eps*1i)) / eps
and finally for analytic functions I ll also
implement the Cauchy's integration + fft method which I posted earlier and
provides higher derivatives as well. Any other method that someone thinks is of
interest and importance (other than the adjoint)? What do you think about
this? Is this sth that should be included in Octave or?
/Fotios
|
[Prev in Thread] | Current Thread | [Next in Thread] |