[<<][meta][>>][..]

Thu Mar 21 10:36:50 EDT 2013

## Autodif pow(x,y)

I need powers and radicals for solving optimization problems.
However, I'm a bit puzzled by the autodiff rule of the pow function,
since one of the arguments is a constant,
#:pow (op ((b db) (e de)) (pow b e) (* e (pow b (- e 1))))
meaning `de' is not used.
Is this correct?
How to make this correct even in the case that de is not zero?
The thing is, we're computing the derivative towards x of x^y. So to
make it correct it should be:
d/dt f(x,y) = @/@x f dx/dt + @/@y f dy/dt
Yep, works:
;; Note that `pow' is redundant as it can be written in terms of
;; `log' and `exp', but the primitive is there to allow exact math
;; when de = 0 and b is an integer.
(define d-pow
(op-match
((b db) (e de))
(let ((b^e (pow b e))) ;; maintain sharing
(make-dual b^e
(+ (* db e (pow b (- e 1)))
(* de (log b) b^e de))))))

[Reply][About]

[<<][meta][>>][..]