changevar.log 6.1 KB

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