changevr.tst 5.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. %*********************************************************************;
  2. % This is a test file for the CHANGEVAR package. ;
  3. % Make sure that before you attempt to run it the ;
  4. % MATRIX package and CHANGEVAR is loaded. ;
  5. %*********************************************************************;
  6. algebraic;
  7. %*********************************************************************;
  8. % ON DISPJACOBIAN; % To get the Jacobians printed, remove the... ;
  9. % ... percentage sign before the word ON ;
  10. %*********************************************************************;
  11. % ;
  12. % *** First test problem *** ;
  13. % ;
  14. % Here are two Euler type of differential equations, ;
  15. % ;
  16. % 3 2 ;
  17. % 2 x y''' + 3 x y'' - y = 0 ;
  18. % ;
  19. % ;
  20. % 2 ;
  21. % 5 x y'' - x y' + 7 y = 0 ;
  22. % ;
  23. % ;
  24. % An Euler equation can be converted into a (linear) equation with ;
  25. % constant coefficients by making change of independent variable: ;
  26. % ;
  27. % u ;
  28. % x = e ;
  29. % ;
  30. % The resulting equations will be ;
  31. % ;
  32. % ;
  33. % 2 y''' - 3 y'' + y' - y = 0 ;
  34. % ;
  35. % and ;
  36. % ;
  37. % 5 y'' - 6 y' + 7 y = 0 ;
  38. % ;
  39. % ;
  40. % Where, now (prime) denotes differentiation with respect to the new ;
  41. % independent variable: u ;
  42. % How this change of variable is done using CHANGEVAR follows. ;
  43. % ;
  44. %*********************************************************************;
  45. operator y;
  46. changevar(y, u, x=e**u, { 2*x**3*df(y(x),x,3)+3*x**2*df(y(x),x,2)-y(x),
  47. 5*x**2*df(y(x),x,2)-x*df(y(x),x)+7*y(x) } ) ;
  48. %*********************************************************************;
  49. % *** Second test problem *** ;
  50. % ;
  51. % Now, the problem is to obtain the polar coordinate form of Laplace's;
  52. % equation: ;
  53. % ;
  54. % 2 2 ;
  55. % d u d u ;
  56. % ------ + ------ = 0 ;
  57. % 2 2 ;
  58. % d x d y ;
  59. % ;
  60. % (The differentiations are partial) ;
  61. % ;
  62. % For polar coordinates the change of variables are : ;
  63. % ;
  64. % x = r cos(theta) , y = r sin(theta) ;
  65. % ;
  66. % As known, the result is : ;
  67. % ;
  68. % ;
  69. % 2 2 ;
  70. % d u 1 d u 1 d u ;
  71. % ------ + --- ------ + --- ---------- = 0 ;
  72. % 2 r d r 2 2 ;
  73. % d r r d theta ;
  74. % ;
  75. % How this change of variable is done using CHANGEVAR follows. ;
  76. % ;
  77. % 2 2 ;
  78. % (To get rid of the boring sin + cos terms we introduce a LET ;
  79. % statement) ;
  80. % ;
  81. %*********************************************************************;
  82. operator u;
  83. let sin theta**2 = 1 - cos theta**2 ;
  84. changevar(u, { r , theta }, { x=r*cos theta, y=r*sin theta },
  85. df(u(x,y),x,2)+df(u(x,y),y,2) ) ;
  86. end; % End of test programs for CHANGEVAR ;