# Using Functions as Arguments to Function

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?

• 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

' or Derivative has the following attributes:

Attributes[Derivative]


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];
??Derivative 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] myNorm[{x_, y_, z_}] := Sqrt[x^2 + y^2 + z^2];
Dt[myNorm[{x, y, z}], t]

• 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. – diracdeltafunk Sep 19 '12 at 2:05
• In addition, I need to have MyNorm'[{x,y,z}] evaluate to Dt[myNorm[{x, y, z}], t]. – diracdeltafunk 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] – diracdeltafunk Sep 19 '12 at 2:49