avector.tst 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. % Vector test routine
  2. % Author: David Harper (algebra@liverpool.ac.uk)
  3. % Computer Algebra Support Officer
  4. % University of Liverpool Computer Laboratory.
  5. % Please compare carefully the output from running this test file with the
  6. % log file provided to make sure your implementation is correct.
  7. linelength 72;
  8. off allfac; on div;
  9. vec a,b,c;
  10. matrix q;
  11. a := avec(ax,ay,az);
  12. b := avec(bx,by,bz);
  13. q := mat((q11,q12,q13),(q21,q22,q23),(q31,q32,q33));
  14. c := a+b;
  15. c := a-b;
  16. c := a cross b;
  17. d := a dot b;
  18. a dot c; b dot c;
  19. q*a;
  20. c:=2*f*a - b/7;
  21. c(0); c(1); c(2);
  22. 1/vmod(a);
  23. b/vmod(a);
  24. (a cross b)/(a dot b);
  25. 2/3*vmod(a)*a*(a dot c)/(vmod(a cross c));
  26. a := avec(x**2*y**3,log(z+x),13*z-y);
  27. df(a,x);
  28. df(a,x,y);
  29. int(a,x);
  30. exp(a);
  31. log sin b;
  32. a := avec(ax,ay,az);
  33. depend ax,x,y,z; depend ay,x,y,z; depend az,x,y,z;
  34. depend p,x,y,z;
  35. c := grad p;
  36. div c;
  37. delsq p;
  38. div a;
  39. curl a;
  40. delsq a;
  41. depend h1,x,y,z; depend h2,x,y,z; depend h3,x,y,z;
  42. scalefactors(h1,h2,h3);
  43. grad p;
  44. div a;
  45. curl a;
  46. dp1 := delsq p;
  47. dp2 := div grad p;
  48. dp1-dp2;
  49. delsq a;
  50. curl grad p;
  51. grad div a;
  52. div curl a;
  53. % Examples of integration : (1) Volume integrals
  54. getcsystem 'spherical;
  55. % Example 1 : integration of r**n over a sphere
  56. origin := avec(0,0,0);
  57. upperbound := avec(rr,pi,2*pi);
  58. volintegral(r**n,origin,upperbound);
  59. % Substitute n=0 to get the volume of a sphere
  60. sub(n=0,ws);
  61. % Example 2 : volume of a right-circular cone
  62. getcsystem 'cylindrical;
  63. upperbound := avec(pp*z,h,2*pi);
  64. volintorder := avec(2,0,1); % Integrate in the order : phi, r, z
  65. cone := volintegral(1,origin,upperbound);
  66. % Now we replace P*Z by RR to get the result in the familiar form
  67. let pp*h=rr;
  68. cone := cone; % This is the familiar form
  69. clear pp*h;
  70. % Example 3 : line integral to obtain the length of a line of latitude
  71. % on a sphere
  72. getcsystem 'spherical;
  73. a := avec(0,0,1); % Function vector is the tangent to the
  74. % line of latitude
  75. curve := avec(rr,latitude,phi); % Path is round a line of latitude
  76. deflineint(a,curve,phi,0,2*pi);
  77. end;