misc.rlg 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  1. REDUCE Development Version, Wed Sep 13 20:40:41 2000 ...
  2. ODESolve 1.065
  3. % Miscellaneous ODESolve 1+ tests
  4. % Check for a problem in 1.03, spotted by David Hartley
  5. % <DHartley@physics.adelaide.edu.au>, caused by the reval in
  6. % `get_k_list' with caching enabled. The following should all give
  7. % the same result:
  8. odesolve(df(u,x,x)=df(u,x));
  9. *** Dependent var(s) assumed to be u
  10. *** Independent var assumed to be x
  11. *** depend u , x
  12. x
  13. {u=e *arbconst(2) + arbconst(1)}
  14. odesolve(df(u,x,2)=df(u,x));
  15. *** Dependent var(s) assumed to be u
  16. *** Independent var assumed to be x
  17. x
  18. {u=e *arbconst(4) + arbconst(3)}
  19. odesolve(df(u,x,x)=df(u,x), u, x);
  20. x
  21. {u=e *arbconst(6) + arbconst(5)}
  22. % Linear first-order ODE:
  23. odesolve(df(y,t) = -w*y*tan(w*t - d));
  24. *** Dependent var(s) assumed to be y
  25. *** Independent var assumed to be t
  26. *** depend y , t
  27. {y=arbconst(7)*cos(d - t*w)}
  28. % The solution, by inspection, is y = A cos(w t - d)
  29. % Variation of parameters:
  30. depend y, x;
  31. ode := df(y,x,2) + y - csc(x)$
  32. odesolve(ode, y, x);
  33. {y=arbconst(9)*sin(x) + arbconst(8)*cos(x) - cos(x)*x + log(sin(x))*sin(x)}
  34. sub(ws, ode);
  35. 2 2
  36. cos(x) - csc(x)*sin(x) + sin(x)
  37. -----------------------------------
  38. sin(x)
  39. trigsimp ws;
  40. 0
  41. ode := 2*df(y,x,2) + y - csc(x)$
  42. odesolve(ode, y, x);
  43. x x
  44. {y=(2*arbconst(11)*sin(---------) + 2*arbconst(10)*cos(---------)
  45. sqrt(2) sqrt(2)
  46. x
  47. sin(---------)
  48. x sqrt(2)
  49. - sqrt(2)*cos(---------)*int(----------------,x)
  50. sqrt(2) sin(x)
  51. x
  52. cos(---------)
  53. sqrt(2) x
  54. + sqrt(2)*int(----------------,x)*sin(---------))/2}
  55. sin(x) sqrt(2)
  56. sub(ws, ode);
  57. x 2 x 2
  58. cos(---------) - csc(x)*sin(x) + sin(---------)
  59. sqrt(2) sqrt(2)
  60. ---------------------------------------------------
  61. sin(x)
  62. trigsimp ws;
  63. 0
  64. % Bernoulli:
  65. ode := df(y,x)*y*x^2 - y^2*x - x^3 + 1;
  66. 2 3 2
  67. ode := df(y,x)*x *y - x - x*y + 1
  68. odesolve(ode, y, x, explicit);
  69. 3 3
  70. sqrt(3*arbconst(13)*x + 6*log(x)*x + 2)*plus_or_minus(tag_1)
  71. {y=----------------------------------------------------------------}
  72. sqrt(x)*sqrt(3)
  73. sub(ws, ode);
  74. 0
  75. % Implicit dependence:
  76. % (NB: Wierd constants need to be mopped up by the arbconst
  77. % simplification code!)
  78. % These should all behave equivalently:
  79. operator f, g;
  80. depend {y, ff}, x, {gg}, y;
  81. odesolve(df(y,x) = f(x), y, x);
  82. {y=arbconst(14) + int(f(x),x)}
  83. odesolve(df(y,x) = ff, y, x);
  84. {y=arbconst(15) + int(ff,x)}
  85. odesolve(df(y,x) = g(y), y, x);
  86. 1
  87. {arbconst(16) + int(------,y) - x=0}
  88. g(y)
  89. odesolve(df(y,x) = gg, y, x);
  90. 1
  91. {arbconst(17) + int(----,y) - x=0}
  92. gg
  93. odesolve(df(y,x) = f(x)*g(y), y, x);
  94. 1
  95. {arbconst(18)*f(0) - int(f(x),x) + int(------,y)=0}
  96. g(y)
  97. odesolve(df(y,x) = ff*gg, y, x);
  98. 1
  99. {arbconst(19)*ff! + int(----,y) - int(ff,x)=0}
  100. gg
  101. odesolve(df(y,x) = 1/f(x)*g(y), y, x);
  102. 1 1
  103. {arbconst(20) - f(0)*int(------,x) + f(0)*int(------,y)=0}
  104. f(x) g(y)
  105. odesolve(df(y,x) = 1/ff*gg, y, x);
  106. 1 1
  107. {arbconst(21) - int(----,x)*ff! + int(----,y)*ff!=0}
  108. ff gg
  109. odesolve(df(y,x) = f(x)/g(y), y, x);
  110. {arbconst(22)*f(0) - int(f(x),x) + int(g(y),y)=0}
  111. odesolve(df(y,x) = ff/gg, y, x);
  112. {arbconst(23)*ff! - int(ff,x) + int(gg,y)=0}
  113. % These should all fail (they are too implicit):
  114. depend {ff}, y, {gg}, x;
  115. odesolve(df(y,x) = ff, y, x);
  116. {df(y,x) - ff=0}
  117. odesolve(df(y,x) = gg, y, x);
  118. {df(y,x) - gg=0}
  119. odesolve(df(y,x) = ff*gg, y, x);
  120. {df(y,x) - ff*gg=0}
  121. odesolve(df(y,x) = 1/ff*gg, y, x);
  122. {df(y,x)*ff - gg=0}
  123. odesolve(df(y,x) = ff/gg, y, x);
  124. {df(y,x)*gg - ff=0}
  125. % NONlinear ODEs:
  126. odesolve(df(y,x) + y**(5/3)*arbconst(-1)=0);
  127. *** Dependent var(s) assumed to be y
  128. *** Independent var assumed to be x
  129. 2/3 2/3
  130. {2*y *arbconst(24)*arbconst(-1) - 2*y *arbconst(-1)*x + 3=0}
  131. % Do not re-evaluate the solution without turning the algint switch on!
  132. odesolve(df(y,x,2) + c/(y^2 + k^2)^(3/2) = 0, y, x, algint);
  133. {2*arbconst(26)*plus_or_minus(tag_2)*c + sqrt(k)*sqrt(c)*sqrt(2)*arbconst(25)*
  134. 2 2 2 2 2 2
  135. sqrt(arbconst(25)*k + arbconst(25)*y - sqrt(k + y )*k*y)*sqrt(k + y )
  136. int(---------------------------------------------------------------------------
  137. 2 2 2 2 2 2
  138. arbconst(25) *k + arbconst(25) *y - k *y
  139. ,y)*k + sqrt(k)*sqrt(c)*sqrt(2)
  140. 2 2 2 2
  141. sqrt(arbconst(25)*k + arbconst(25)*y - sqrt(k + y )*k*y)*y 2
  142. *int(---------------------------------------------------------------,y)*k
  143. 2 2 2 2 2 2
  144. arbconst(25) *k + arbconst(25) *y - k *y
  145. - 2*plus_or_minus(tag_2)*c*x=0}
  146. % Good test of ODESolve!-Alg!-Solve. Takes forever with fullroots on,
  147. % but with fullroots off ODESolve solves it. (Slightly tidier with
  148. % algint, but not necessary. However, the explicit option misses the
  149. % non-trivial solution that can fairly easily be found by hand!)
  150. odesolve(df(y,x,3) = 6*df(y,x)*df(y,x,2)/y - 6*df(y,x)^3/(y^2), y, x, algint);
  151. {sqrt(y)*arbconst(30)*arbconst(29)*arbconst(28)
  152. - sqrt(y)*arbconst(29)*arbconst(28)*x - 2*sqrt(arbconst(28) + y)=0,
  153. y=arbconst(31)}
  154. % Hangs with algint option!
  155. % off odesolve_plus_or_minus;
  156. odesolve(a*tan(asin((df(y,x) - y)/(2*y))/2)^2 + a -
  157. 2*sqrt(3)*tan(asin((df(y,x) - y)/(2*y))/2)*y + 4*sqrt(3)*y +
  158. tan(asin((df(y,x) - y)/(2*y))/2)^2*y -
  159. 4*tan(asin((df(y,x) - y)/(2*y))/2)*y + 7*y, y, x);
  160. x
  161. { - e *arbconst(32) - sqrt( - 4*sqrt(3)*y - a - 8*y) - sqrt(a)*sqrt(3)=0,
  162. x
  163. - e *arbconst(33) - sqrt( - 4*sqrt(3)*y - a - 8*y) + sqrt(a)*sqrt(3)=0}
  164. % on odesolve_plus_or_minus;
  165. % From: K Sudhakar <ks@maths.qmw.ac.uk>
  166. odesolve(2*df(f,x,3)*df(f,x)*f^2*x^2 - 3*df(f,x,2)^2*x^2*f^2 +
  167. df(f,x)^4*x^2 - df(f,x)^2*f^2, f, x);
  168. *** depend f , x
  169. {arbconst(37)*arbconst(36)*arbconst(35)*log(f) + arbconst(37)*arbconst(36)
  170. - arbconst(36)*arbconst(35)*log(f)*log(x) - arbconst(36)*log(x) + log(f)=0,
  171. f=arbconst(38)}
  172. % Related intermediate problem:
  173. odesolve(2*df(y,x)*x*y + x^2 - 2*x*y - y^2, y, x, explicit);
  174. - (2*x)/(x - y_) 2 2 2
  175. {y=root_of(e *arbconst(39)*e *x + x - 2*x*y_ + y_ ,y_,tag_19)}
  176. % Anharmonic oscillator problem (which apparently Maple V R5.1 solves
  177. % in terms of a root of an expression involving unevaluated integrals
  178. % but Maple 6 cannot!).
  179. % General solution:
  180. odesolve(M*L*df(phi(tt),tt,2) = -M*g*sin(phi(tt)));
  181. *** phi declared operator
  182. *** Dependent var(s) assumed to be phi(tt)
  183. *** Independent var assumed to be tt
  184. {2*arbconst(41)*plus_or_minus(tag_20)*g + sqrt(l)*sqrt(g)*sqrt(2)
  185. sqrt(arbconst(40)*sin(1) + cos(phi(tt)))
  186. *int(------------------------------------------,phi(tt))
  187. arbconst(40)*sin(1) + cos(phi(tt))
  188. - 2*plus_or_minus(tag_20)*g*tt=0}
  189. % Use of `t' as independent variable:
  190. odesolve(M*L*df(phi(t),t,2) = -M*g*sin(phi(t)));
  191. *** Dependent var(s) assumed to be phi(t)
  192. *** Independent var assumed to be t
  193. {2*arbconst(43)*plus_or_minus(tag_21)*g + sqrt(l)*sqrt(g)*sqrt(2)
  194. sqrt(arbconst(42)*sin(1) + cos(phi(t)))
  195. *int(-----------------------------------------,phi(t))
  196. arbconst(42)*sin(1) + cos(phi(t))
  197. - 2*plus_or_minus(tag_21)*g*t=0}
  198. % Conditional (eigenvalue) solution:
  199. %% odesolve(M*L*df(phi(t),t,2) = -M*g*sin(phi(t)),
  200. %% {t=0, phi(t)=0, df(phi(t),t)=Pi});
  201. %%
  202. %% Conditional solutions need more work! This fails with
  203. %% ***** 0 invalid as kernel
  204. % Try setting
  205. %% L:=1; g:=10; ws;
  206. end;
  207. Time for test: 24198 ms, plus GC time: 1520 ms