CHANGEVR.LOG 6.1 KB

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