       Re: Partial derviatives in mathematica

• To: mathgroup at smc.vnet.net
• Subject: [mg95771] Re: [mg95753] Partial derviatives in mathematica
• From: Bob Hanlon <hanlonr at cox.net>
• Date: Tue, 27 Jan 2009 06:56:15 -0500 (EST)

```Partial derivatives are done with D

D[f[x, y], x]

Derivative[1, 0][f][x, y]

For further info, execute:

?D

Bob Hanlon

---- xareon at gmail.com wrote:

=============
Hi all, i got thi Newton-Raphson mathematica code:

Code:

F[{x_, y_}] = {f1[{x, y}], f2[{x, y}]};

jacobian[{x_, y_}] = Transpose[{\[PartialD]x F[{x, y}], \[PartialD]y F
[{x, y}]}];

MatrixForm[jacobian[{x, y}]];

NewtonSystem[X0_, max_] := Module[{},
n = 2;
k = 0;
Dp = {0, 0};
P0 = X0;
F0 = F[P0];
Print["F[", P0, "]=", N[F0, 3]];
P1 = P0;
F1 = F0;
While[k < max,
k = k + 1;
P0 = P1;
F0 = F1;
J0 = jacobian[P0];
det = Det[J0];
If[det == 0, Dp = {0, 0}, Dp = Inverse[J0].F0];
P1 = P0 - Dp;
F1 = F[P1];
Print["F[", P1, "]=", N[F1, 3]];];];

where f1[x, y] and f2[x, y] are defined in this way

Code:

f1[{x_, y_}] = n/x - Sum[y*Exp[-y*A*t[i]]*T[i+1], {i, 0, n-1}];

f2[{x_, y_}] = n/y - Sum[A*t[i], {i, 0, n-1}] - Sum[x*Exp[-y*A*t[i]]*T
[i+1], {i, 0, n-1}] + Sum[y*x*A*t[i]*Exp[-y*A*t[i]]*T[i+1], {i, 0,
n-1}];

T[i] e t[i] are functions defined point-by-point  (from T to T
and from t to t) with this syntax:

Code:

t = *un certo numero*; t = *un altro numero*; t = *ancora un
altro numero*; ... T = *numero*; T = *altro numero* ...

I got an error on the second line

Code:

jacobian[{x_, y_}] = Transpose[{\[PartialD]x F[{x, y}], \[PartialD]y F
[{x, y}]}];

Mathematica's kernel warns me with this message when i try to insert
it:

Code:

Syntax::sntxf: "jacobian[{x_, y_}] = Transpose[{" cannot be followed
by
"\[PartialD]x F[{x, y}], \[PartialD]y F[{x, y}]}];".

This line should define a 2-variables function named jacobian, that is
a jacobian matrix. I'm not a Mathematica-guru, but the code should
work anyway.

What's wrong there? f1 and f2 seem well defined (i.e., when i write
them Mathematica doesn't say nothing bad):

Thank you all ;)

```

• Prev by Date: Re: Multiple Shooting Method
• Next by Date: Re: Partial derviatives in mathematica
• Previous by thread: Re: Partial derviatives in mathematica
• Next by thread: Re: Partial derviatives in mathematica