3
$\begingroup$

I have an issue with derivatives of vectors

$Assumptions :=  v ∈ Vectors[3, Reals] (*Assuming v is a 3d vector*)

D[Norm[v]^2, v.{0, 0, 1}] (*differentiate with respect to third component*)

Output: 0

But isn't this supposed to be: $\frac{\partial (v_1^2+v_2^2+v_3^2)}{\partial v_3}=2v_3$

$\endgroup$
2
  • $\begingroup$ If my answer below answered your question, please accept it so that we can get this question off the unanswered list and so that I can get those meaningless internet points that I so crave! $\endgroup$ – march Nov 6 '15 at 4:09
  • $\begingroup$ @march Ah! Yep here are your well-deserved points :) Thanks a lot for the help! I simply forgot to click ;) $\endgroup$ – Otto Nov 7 '15 at 1:56
9
$\begingroup$

Here's how you should probably do this:

vec = Array[v, 3]
D[vec.vec, vec.{0, 0, 1}]
(* {v[1], v[2], v[3]} *)
(* 2 v[3] *)

I'll just make a couple of points about D.

  • It doesn't behave well when given functions like Abs and Norm:

    D[Norm[{a, b, c}]^2, a]
    (* 2 Abs[a] Abs'[a] *)
    

    Instead, you should typically use more explicit forms of vector norms, which is why I used

    vec.vec
    (* v[1]^2 + v[2]^2 + v[3]^2 *)
    
  • I would guess that Vectors is mainly useful for doing symbolic tensor math, as shown in the documentation. It's not for what you're trying to do with it.

  • Meditate on the result of the following evaluation; it will show you why your result was zero and how D interprets its arguments.

    Clear[v]
    D[v.{0, 0, 1}, v.{0, 0, 1}]
    
$\endgroup$
3
  • 2
    $\begingroup$ I upvoted this even though your rep counter was just at 4444, and now I messed up that nice number. Sorry for that, I guess. $\endgroup$ – Jens Oct 15 '15 at 5:27
  • $\begingroup$ @Jens I wish I could have stayed there forever. $4444 = 66^2 + 88$; $4444 = 4\times1111$ with $1+1+1+1 = 4$. $\endgroup$ – march Oct 15 '15 at 15:35
  • 2
    $\begingroup$ You are correct that Vectors is meant for symbolic tensor manipulations and simplifications. $\endgroup$ – Stefan R Oct 16 '15 at 17:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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