MathGroup Archive 2008

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

Search the Archive

Re: Re: Derivative of Dot[]


>> Consider the following function:
>>
>> F[x_] := Dot[x,x]
>>
>> Evaluating this function works as expected: F[{1,2}] evaluates to 5.
>>
>> I differentiate this function w.r.t. its sole argument, F' evaluates
>> to 1.#1+#1.1&
>>
>> This is reasonable, and as expected. I would think that, since the
>
> The above expression make sense only for one dimensional vectors, say on
> the real line; in other words, a vector space where the unit vector is
> {1} and any vector {x} has only one component x.

Why? Even of a vector {x}, the resulting derivative cannot be
evaluated successfully: (1.#1+#1.1&)[{x}] does not simplify (the 1.
remains).

> You may want to write you own differentiating function such as the
> following:

I have done so before; but the question is what is the intended use of
the built in derivative of Dot? I can't find one.

Eitan

>
>   In[1]:=
>     SetAttributes[myDiff, HoldFirst]
>     myDiff[fun_[x_?VectorQ]] :=
>      Module[{v = Array[a, Length[x]]},
>       D[fun[v], {v}] /. Thread[v -> x]]
>
>     f[x_?VectorQ] := Dot[x, x]
>     myDiff[f[{1, 2}]]
>     myDiff[f[{1, 2}]].{3, 4}
>
>     g[y_] := 2 f[y]
>     myDiff[g[{1, 2}]]
>     myDiff[g[{1, 2}]].{3, 4}
>
>   Out[4]= {2, 4}
>
>   Out[5]= 22
>
>   Out[7]= {4, 8}
>
>   Out[8]= 44
>
> Regards,
> -- Jean-Marc
>
>


  • Prev by Date: Re: Re: Derivative of Dot[]
  • Next by Date: Re: No preferences for OSX
  • Previous by thread: Re: Derivative of Dot[]
  • Next by thread: Re: Re: Derivative of Dot[]