Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to make a function like Norm but defined like so: MyNorm[{x_,y_,z_}]=Sqrt[x^2+y^2+z^2]. Mathematica assumes that x, y, and z are constants, and gives MyNorm'[{x,y,z}] to be 0 for any x, y, or z. This would be fine, except that my x, y, and z will be functions of t, and I would like MyNorm'[{x,y,z}] to be equal to $$\frac{\mathrm d}{\mathrm dt} \mathtt{MyNorm[\{}x(t),y(t),z(t)\mathtt{\}]}$$

Does anyone know how to do this?

share|improve this question
myNorm'[{x_, y_, z_}] := Dt[myNorm[{x, y, z}], t]? – wxffles Sep 19 '12 at 4:14
In the $\LaTeX$ example you have MyNorm with 3 arguments, but in the code definition is has a single, vector argument. What is it now? – Sjoerd C. de Vries Sep 19 '12 at 8:43
up vote 5 down vote accepted

' or Derivative has the following attributes:


{NHoldAll, ReadProtected}

Conspicuously absent is the Protected attribute. This means that, unlike many other system functions, downvalues for Derivative can be defined directly.

In this case you seem to want this definition (as suggested by wxffles in comments):

MyNorm'[{x_, y_, z_}] := Dt[MyNorm[{x, y, z}], t]

The total derivative Dt is needed here to explicitly indicate that all variables depend on t.

Show it works:

MyNorm'[{x, y, z}]

(2 x Dt[x, t] + 2 y Dt[y, t] + 2 z Dt[z, t])/(2 Sqrt[ x^2 + y^2 + z^2])

If you clear the ReadProtected attribute you can see the definition is indeed assigned to Derivative:

ClearAttributes[Derivative, ReadProtected];

Mathematica graphics

Usually you would use TagSet or TagSetDelayed (/: = or /: :=) to associate this definition with MyNorm but in this case it would appear to deeply nested:

MyNorm /: MyNorm'[{x_, y_, z_}] := Dt[MyNorm[{x, y, z}], t]

Mathematica graphics

share|improve this answer
myNorm[{x_, y_, z_}] := Sqrt[x^2 + y^2 + z^2];
Dt[myNorm[{x, y, z}], t]
share|improve this answer
While this does give the derivative of the norm function, when I attempt deriving myNorm[r[t]] where r[t] is a piecewise parametric function in three parts {x[t], y[t], z[t]}, it still returns an error message. – Ben7005 Sep 19 '12 at 2:05
In addition, I need to have MyNorm'[{x,y,z}] evaluate to Dt[myNorm[{x, y, z}], t]. – Ben7005 Sep 19 '12 at 2:09
@Ben7005 Edit your question and add all the relevant info – Dr. belisarius Sep 19 '12 at 2:18
belisarius' answer strikes me as correct. If $x$, $y$, and $z$ are, in fact, functions (even in symbolic, as in x[t]), then this works fine. If they are not, then their derivatives should be zero. – Mark McClure Sep 19 '12 at 2:28
Yes but as I said above I need to have MyNorm'[{x,y,z}] evaluate to Dt[myNorm[{x, y, z}], t] – Ben7005 Sep 19 '12 at 2:49

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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