misc.tst 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. % Miscellaneous ODESolve 1+ tests
  2. % Check for a problem in 1.03, spotted by David Hartley
  3. % <DHartley@physics.adelaide.edu.au>, caused by the reval in
  4. % `get_k_list' with caching enabled. The following should all give
  5. % the same result:
  6. odesolve(df(u,x,x)=df(u,x));
  7. odesolve(df(u,x,2)=df(u,x));
  8. odesolve(df(u,x,x)=df(u,x), u, x);
  9. % Linear first-order ODE:
  10. odesolve(df(y,t) = -w*y*tan(w*t - d));
  11. % The solution, by inspection, is y = A cos(w t - d)
  12. % Variation of parameters:
  13. depend y, x;
  14. ode := df(y,x,2) + y - csc(x)$
  15. odesolve(ode, y, x);
  16. sub(ws, ode);
  17. trigsimp ws;
  18. ode := 2*df(y,x,2) + y - csc(x)$
  19. odesolve(ode, y, x);
  20. sub(ws, ode);
  21. trigsimp ws;
  22. % Bernoulli:
  23. ode := df(y,x)*y*x^2 - y^2*x - x^3 + 1;
  24. odesolve(ode, y, x, explicit);
  25. sub(ws, ode);
  26. % Implicit dependence:
  27. % (NB: Wierd constants need to be mopped up by the arbconst
  28. % simplification code!)
  29. % These should all behave equivalently:
  30. operator f, g;
  31. depend {y, ff}, x, {gg}, y;
  32. odesolve(df(y,x) = f(x), y, x);
  33. odesolve(df(y,x) = ff, y, x);
  34. odesolve(df(y,x) = g(y), y, x);
  35. odesolve(df(y,x) = gg, y, x);
  36. odesolve(df(y,x) = f(x)*g(y), y, x);
  37. odesolve(df(y,x) = ff*gg, y, x);
  38. odesolve(df(y,x) = 1/f(x)*g(y), y, x);
  39. odesolve(df(y,x) = 1/ff*gg, y, x);
  40. odesolve(df(y,x) = f(x)/g(y), y, x);
  41. odesolve(df(y,x) = ff/gg, y, x);
  42. % These should all fail (they are too implicit):
  43. depend {ff}, y, {gg}, x;
  44. odesolve(df(y,x) = ff, y, x);
  45. odesolve(df(y,x) = gg, y, x);
  46. odesolve(df(y,x) = ff*gg, y, x);
  47. odesolve(df(y,x) = 1/ff*gg, y, x);
  48. odesolve(df(y,x) = ff/gg, y, x);
  49. % NONlinear ODEs:
  50. odesolve(df(y,x) + y**(5/3)*arbconst(-1)=0);
  51. % Do not re-evaluate the solution without turning the algint switch on!
  52. odesolve(df(y,x,2) + c/(y^2 + k^2)^(3/2) = 0, y, x, algint);
  53. % Good test of ODESolve!-Alg!-Solve. Takes forever with fullroots on,
  54. % but with fullroots off ODESolve solves it. (Slightly tidier with
  55. % algint, but not necessary. However, the explicit option misses the
  56. % non-trivial solution that can fairly easily be found by hand!)
  57. odesolve(df(y,x,3) = 6*df(y,x)*df(y,x,2)/y - 6*df(y,x)^3/(y^2), y, x, algint);
  58. % Hangs with algint option!
  59. % off odesolve_plus_or_minus;
  60. odesolve(a*tan(asin((df(y,x) - y)/(2*y))/2)^2 + a -
  61. 2*sqrt(3)*tan(asin((df(y,x) - y)/(2*y))/2)*y + 4*sqrt(3)*y +
  62. tan(asin((df(y,x) - y)/(2*y))/2)^2*y -
  63. 4*tan(asin((df(y,x) - y)/(2*y))/2)*y + 7*y, y, x);
  64. % on odesolve_plus_or_minus;
  65. % From: K Sudhakar <ks@maths.qmw.ac.uk>
  66. odesolve(2*df(f,x,3)*df(f,x)*f^2*x^2 - 3*df(f,x,2)^2*x^2*f^2 +
  67. df(f,x)^4*x^2 - df(f,x)^2*f^2, f, x);
  68. % Related intermediate problem:
  69. odesolve(2*df(y,x)*x*y + x^2 - 2*x*y - y^2, y, x, explicit);
  70. % Anharmonic oscillator problem (which apparently Maple V R5.1 solves
  71. % in terms of a root of an expression involving unevaluated integrals
  72. % but Maple 6 cannot!).
  73. % General solution:
  74. odesolve(M*L*df(phi(tt),tt,2) = -M*g*sin(phi(tt)));
  75. % Use of `t' as independent variable:
  76. odesolve(M*L*df(phi(t),t,2) = -M*g*sin(phi(t)));
  77. % Conditional (eigenvalue) solution:
  78. %% odesolve(M*L*df(phi(t),t,2) = -M*g*sin(phi(t)),
  79. %% {t=0, phi(t)=0, df(phi(t),t)=Pi});
  80. %%
  81. %% Conditional solutions need more work! This fails with
  82. %% ***** 0 invalid as kernel
  83. % Try setting
  84. %% L:=1; g:=10; ws;
  85. end;