Solve system of linear equations symbolically with Maple

114 Views Asked by At

Trying to understand derivations of the Laplacian in spherical-polar coordinates I've seen on the net and I would like to use Maple to verify a formula which expresses the basis vectors $\hat{x},\hat{y},\hat{z}$ in basisvectors $\hat{r}, \hat{\theta}, \hat{\phi}$, not because it is difficult to do by hand with Cramer's rule but thinking it is useful to know Maple.

I am writing:

   f1:=sin(theta)*cos(phi)*x+ sin(theta)*sin(phi)*y+cos(theta)*z;
   f2:=cos(theta)*cos(phi)*x+cos(theta)*sin(phi)*y-sin(theta)*z;
   f3:=-sin(phi)*x+cos(phi)*y;
   eqns:=[f1,f2,f3];
   solve(eqns,[x,y,z]);

Why doesn't Maple understand what I want to do? what is missing? (Please link a good text of the derivation of the Laplacian which contains no hand waiving. This is no school assignment!) Edit: This is solved in Octave, giving unitvectors $\hat{x},\hat{y}, \hat{z}$ as

pkg load symbolic; %Octave only
syms theta;
syms phi;
syms x;
syms y;
syms z;

A= [sin(theta)*cos(phi),sin(theta)*sin(phi), cos(theta);...
    cos(theta)*cos(phi), cos(theta)*sin(phi), -sin(theta);...
    -sin(phi),cos(phi),0]
B=inv(A)
C=simplify(B)```
1

There are 1 best solutions below

0
On

What do you believe is shown by those Octave computations? Is not the Maple equivalent something more like this:

with(LinearAlgebra):

f1:=sin(theta)*cos(phi)*x+ sin(theta)*sin(phi)*y+cos(theta)*z:
f2:=cos(theta)*cos(phi)*x+cos(theta)*sin(phi)*y-sin(theta)*z:
f3:=-sin(phi)*x+cos(phi)*y:

A:=GenerateMatrix([f1,f2,f3],[x,y,z])[1];

     [cos(phi) sin(theta)  sin(theta) sin(phi)  cos(theta) ]
     [                                                     ]
     [cos(theta) cos(phi)  sin(phi) cos(theta)  -sin(theta)]
     [                                                     ]
     [     -sin(phi)            cos(phi)             0     ]

simplify(A^(-1));

    [cos(phi) sin(theta)  cos(theta) cos(phi)  -sin(phi)]
    [                                                   ]
    [sin(theta) sin(phi)  sin(phi) cos(theta)  cos(phi) ]
    [                                                   ]
    [    cos(theta)           -sin(theta)          0    ]

Norm(simplify(A^(-1) - A^%T));

            0