Mon Mar 9 16:44:21 MST 1998 aquarius% mupad *----* MuPAD 1.4.0 -- Multi Processing Algebra Data Tool /| /| *----* | Copyright (c) 1997 - 98 by SciFace Software GmbH | *--|-* All rights reserved. |/ |/ *----* Licensed to: Michael Wester >> # ----------[ M u P A D ]---------- # >> # ---------- Initialization ---------- # >> TEXTWIDTH:= 80: >> read("../../Time.mupad"): >> # ---------- Vector Analysis ---------- # >> export(Dom): export(linalg): >> matrix:= Matrix(ExpressionField(normal)): >> # Vector norm => sqrt(15) # >> norm(matrix([[1 + I, -2, 3*I]]), 2); 1/2 15 Time: 4240 msec Type: Dom::ExpressionField(normal, iszero@normal) >> # Cross product: (2, 2, -3) x (1, 3, 1) => (11, -5, 4) # >> crossProduct(matrix([[2, 2, -3]]), matrix([[1, 3, 1]])); +- -+ | 11, -5, 4 | +- -+ Time: 520 msec Type: Dom::Matrix(Dom::ExpressionField(normal, iszero@normal)) >> # (a x b) . (c x d) => (a . c) (b . d) - (a . d) (b . c) # >> scalarProduct(crossProduct(a, b), crossProduct(c, d)); Error: expecting vectors of dimension 3 [linalg::crossProduct] >> # => (2 y z^3 - 2 x^2 y^2 z, x y, 2 x y^2 z^2 - x z) # >> curl([x*y*z, x^2*y^2*z^2, y^2*z^3], [x, y, z]); 3 2 2 2 2 [2 y z - 2 x y z, x y, 2 x y z - x z] Time: 370 msec Type: DOM_LIST >> # DEL . (f x g) => g . (DEL x f) - f . (DEL x g) # >> divergence(crossProduct(f, g)); Error: expecting vectors of dimension 3 [linalg::crossProduct] >> # Express DEL . a in spherical coordinates (r, theta, phi) for &> a = (a_r(r, theta, phi), a_theta(r, theta, phi), a_phi(r, theta, phi)). &> Here, phi is in the x-y plane and theta is the angle with the z-axis. &> => 1/r^2 d/dr[r^2 a_r] + 1/[r sin(theta)] d/dtheta[sin(theta) a_theta] &> + 1/[r sin(theta)] da_phi/dphi &> => da_r/dr + (2 a_r)/r + 1/r da_theta/dtheta + a_theta/[r tan(theta)] &> + 1/[r sin(theta)] da_phi/dphi &> See Keith R. Symon, _Mechanics_, Third Edition, Addison-Wesley Publishing &> Company, 1971, p. 103. # >> divergence([a_r(r, Theta, Phi), a_theta(r, Theta, Phi), a_phi(r, Theta, Phi)], &> [r, Theta, Phi], Spherical); (2 sin(Theta) a_r(r, Theta, Phi) + diff(a_phi(r, Theta, Phi), Phi) + cos(Theta) a_theta(r, Theta, Phi) + r sin(Theta) diff(a_r(r, Theta, Phi), r) + sin(Theta) diff(a_theta(r, Theta, Phi), Theta)) / (r sin(Theta)) Time: 1930 msec Type: "_mult" >> expand(%); 2 a_r(r, Theta, Phi) diff(a_r(r, Theta, Phi), r) + -------------------- + r diff(a_theta(r, Theta, Phi), Theta) diff(a_phi(r, Theta, Phi), Phi) ----------------------------------- + ------------------------------- + r r sin(Theta) cos(Theta) a_theta(r, Theta, Phi) --------------------------------- r sin(Theta) Time: 210 msec Type: "_plus" >> # Express dR/dt in spherical coordinates (r, theta, phi) where R is the &> position vector r*Rhat(theta, phi) with Rhat being the unit vector in the &> direction of R => (dr/dt, r dtheta/dt, r sin(theta) dphi/dt) &> [Symon, p. 98] # >> diff(matrix([[r(t)*rhat(Theta(t), Phi(t)), 0, 0]]), t); array(1..1, 1..3, (1, 1) = diff(r(t), t)*rhat(Theta(t), Phi(t)) + r(t)*diff(Phi(t), t)*D([2], r\ hat)(Theta(t), Phi(t)) + r(t)*diff(Theta(t), t)*D([1], rhat)(Theta(t), Phi(t)), (1, 2) = 0, (1, 3) = 0 ) Time: 590 msec Type: Dom::Matrix(Dom::ExpressionField(normal, iszero@normal)) >> # Scalar potential => x^2 y + y + 2 z^3 # >> #potential([2*x*y, x^2 + 1, 6*z^2], [x, y, z]);# >> # Vector potential => (x y z, x^2 y^2 z^2, y^2 z^3) is one possible solution. &> See Harry F. Davis and Arthur David Snider, _Introduction to Vector &> Analysis_, Third Edition, Allyn and Bacon, Inc., 1975, p. 97. # >> vectorPotential([2*y*z^3 - 2*x^2*y^2*z, x*y, 2*x*y^2*z^2 - x*z], [x, y, z]); -- 4 -- | 2 2 2 y z | | x y z, x y z - ----, 0 | -- 2 -- Time: 490 msec Type: DOM_LIST >> curl(%, [x, y, z]); 3 2 2 2 2 [2 y z - 2 x y z, x y, 2 x y z - x z] Time: 160 msec Type: DOM_LIST >> # Orthogonalize the following vectors (Gram-Schmidt). See Lee W. Johnson and &> R. Dean Riess, _Introduction to Linear Algebra_, Addison-Wesley Publishing &> Company, 1981, p. 104 => [[0 1 2 1], [0 -1 1 -1], [2 1 0 -1]]^T # >> matrix([[0, 1, 2, 1], [0, 1, 3, 1], [1, 1, 1, 0], [1, 3, 6, 2]]); +- -+ | 0, 1, 2, 1 | | | | 0, 1, 3, 1 | | | | 1, 1, 1, 0 | | | | 1, 3, 6, 2 | +- -+ Time: 270 msec Type: Dom::Matrix(Dom::ExpressionField(normal, iszero@normal)) >> #gramschmidt(%);# >> # ---------- Quit ---------- # >> quit real 11.63 user 10.87 sys 0.65