From: atlas shrugger on
Hi,

Let's say have function f of vector variable x.
f[x_] := x[[1]]^2 + x[[2]]^2

How to compute partial derivate by x_1?
Something like D[f[x], {{x[[1]]}}] does not work.

I don't want to rewrite function f as f[x1_,x2_].

Thanks for help.

From: dh on
Hi,
f[x_]:=..
is a function of one argument (even if your scalar is a list) and not a
function of several variables. Therefore there are no partial derivatives.
The easiest soultion would be to define a function of several variables,
but you do not want to do this.
Another solution is to "create" a function of several variables on the
fly, e.g. using dummy variables like:
D[f[{x1,x2},x1]]/.{x1->first argument, x2->second argument}
or we may use a pure function like:
Derivative[1, 0][Evaluate@f[{#1, #2}] &]
or another simpler possibility:
Evaluate@D[f[{#1, #2}], #1]&

Daniel

On 25.03.2010 10:22, atlas shrugger wrote:
> Hi,
>
> Let's say have function f of vector variable x.
> f[x_] := x[[1]]^2 + x[[2]]^2
>
> How to compute partial derivate by x_1?
> Something like D[f[x], {{x[[1]]}}] does not work.
>
> I don't want to rewrite function f as f[x1_,x2_].
>
> Thanks for help.
>


--

Daniel Huber
Metrohm Ltd.
Oberdorfstr. 68
CH-9100 Herisau
Tel. +41 71 353 8585, Fax +41 71 353 8907
E-Mail:<mailto:dh(a)metrohm.com>
Internet:<http://www.metrohm.com>


From: Bob Hanlon on

f[x_] := x.x

x = {x1, x2, x3};

f[x]

x1^2 + x2^2 + x3^2

D[f[x], #] & /@ x

{2 x1,2 x2,2 x3}

D[f[x], x[[1]]]

2 x1


Bob Hanlon

---- atlas shrugger <ashrugger(a)gmail.com> wrote:

=============
Hi,

Let's say have function f of vector variable x.
f[x_] := x[[1]]^2 + x[[2]]^2

How to compute partial derivate by x_1?
Something like D[f[x], {{x[[1]]}}] does not work.

I don't want to rewrite function f as f[x1_,x2_].

Thanks for help.



From: Vasyl&#39; on
Many thanks for help.

I got that there is advanced level mathematica I need to study :)