From: vexx on
Lets say that I have defined some simple scalar function for example:
DEFINE('P(X,Y,Z)=X^2+Y^2+Z^2')
NOVAL
Then I stored a simple vector:
[X,Y,Z]|>J
[X Y Z]
If I want do calculate gradient of my scalar function the manual states:
DERIV(X^2+Y^2+Z^2,[X,Y,Z])
[2X 2Y 2Z]
If I use:
DERIVE('P(X,Y,Z),[X,Y,Z]')
[2X 2Y 2Z]
It's still ok...
But if I use :
DERIVE('P(X,Y,Z),J')
0
No results....
Suggestion?


Second problem is how to save a vector function... My attempt is:
DEFINE('O(X,Y,Z)=[2*X,2*Y,2*Z]')
"Bad Argument Type"
So how to save a vector function?

P.S. for people who know mats/physics: I am trying to calculate a
gradient of scalar function and get a vector function which I would like
too save for later calculation...

Tnx!
From: supergems on
On 25 Nov, 23:46, vexx <vexxm...(a)gmail.com> wrote:
> Lets say that I have defined some simple scalar function for example:
>         DEFINE('P(X,Y,Z)=X^2+Y^2+Z^2')
>                 NOVAL
> Then I stored a simple vector:
>         [X,Y,Z]|>J
>                 [X Y Z]
> If I want do calculate gradient of my scalar function the manual states:
>         DERIV(X^2+Y^2+Z^2,[X,Y,Z])
>                 [2X 2Y 2Z]
> If I use:
>         DERIVE('P(X,Y,Z),[X,Y,Z]')
>                 [2X 2Y 2Z]
> It's still ok...
> But if I use :
>         DERIVE('P(X,Y,Z),J')
>                 0
> No results....
> Suggestion?
>
> Second problem is how to save a vector function... My attempt is:
>         DEFINE('O(X,Y,Z)=[2*X,2*Y,2*Z]')
>                 "Bad Argument Type"
> So how to save a vector function?
>
> P.S. for people who know mats/physics: I am trying to calculate a
> gradient of scalar function and get a vector function which I would like
> too save for later calculation...
>
> Tnx!

Hi vexx, in RPN mode:

\<< [ 'X' 'Y' 'Z' ] DERIV EXPAND \>> 'GRADIENT' STO
'P(X,Y,Z)=X^2+Y^2+Z^2' DEF
'P(X,Y,Z)' GRADIENT --> [ '2*X' '2*Y' '2*Z' ]

\<< \-> X Y Z \<< '2*X' EVAL '2*Y' EVAL '2*Z' EVAL \>> \>> 'O' STO
ex. 2 3 4 O --> 4 6 8

supergems