MathGroup Archive 2000

[Date Index] [Thread Index] [Author Index]

Search the Archive

Vector and Matrix Differentiation with Mathematica

Dear Mathgroup Members,
I have to compute derivatives of functions including vectors and 
matrices. To the best of my knowledge Mathematica doesn't 
support this fully.

For example, If b is a vector and A a conformable square matrix,
D[b . A . b, b]
should evaluate to A + Transpose[A].
Mathematica returns
0.A.b + 2 1.0.b + 2 1.A.1 + 2 b.0.1 + b.0.b + b.A.0

With some additional Rules you get a more sensible result:

D[D[b.A.b, b], b]
	//. {Dot[___, 0, ___] -> 0, Dot[x___, 1, y___] -> Dot[x, y]}

Evaluates to 2 A. This is, of course, true only if A is symmetric.
I don't claim that Mathematica makes an error here.
Rather my Rules seem to be buggy.
(However a reason for the problem might be that Mathematica 
doesn't keep track of vector dimensions, i.e. Mathematica doesn't
distinguish between row and column vectors.)
Since I assume that I will have to invest some time to supply the 
rigth rules, I ask, whether someone of you has written a package, 
which does my jobs or can provide any experience with matrix 
calculus in Mathematica.

Thank you,
	Johannes Ludsteck

Johannes Ludsteck
Centre for European Economic Research (ZEW)
Department of Labour Economics,
Human Resources and Social Policy
Phone (+49)(0)621/1235-157
Fax (+49)(0)621/1235-225

P.O.Box 103443
D-68034 Mannheim

Email: ludsteck at

  • Prev by Date: Getting graphic outputs from background jobs
  • Next by Date: Re: Weird Plot behavior...
  • Previous by thread: Re: Getting graphic outputs from background jobs
  • Next by thread: Re: Vector and Matrix Differentiation with Mathematica