I am trying to apply differentiation, D, operator in Mathematica to a vector. Importantly, I want to carry out the operation with respect to another vector. Basically, I am computing a Jacobian matrix.

Here is what I do:

Q = {\[Rho], \[Rho]u, \[Rho]v, \[Rho]T + \[Theta]\[Rho]T}
Ax1 = D[fx4, {Q}] // Expand
Ay1 = D[fy4, {Q}] // Expand

Where Q is the vector with respect which I want to differentiate vectors fx4 and fy4. However, instead of carrying out the operation Ax1 = D[fx4, {Q}] // Expand Mathematica returns the following error

General::ivar: \[Theta]\[Rho]T+\[Rho]T is not a valid variable.

Do you know how I could bypass tis issue?



1 Answer 1


First a variable can not be a sum: ρT + θρT. Replace this with a new variable, call it e.g.: T. Second, you must specify the arguments of a function. With this changes:

Q = {ρ, ρu, ρv, T}
D[fx4[ρ, ρu, ρv, T], {Q}]

enter image description here


Not the answer you're looking for? Browse other questions tagged or ask your own question.