zimmerop.rlg 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881
  1. REDUCE Development Version, Wed Sep 13 20:40:41 2000 ...
  2. ODESolve 1.065
  3. % -*- REDUCE -*-
  4. % The Postel/Zimmermann (11/4/96) ODE test examples.
  5. % Equation names from Postel/Zimmermann.
  6. % This version uses Maple-style functional notation wherever possible.
  7. % on trode;
  8. on div, intstr;
  9. off allfac;
  10. % to look prettier
  11. % 1 Single equations without initial conditions
  12. % ==============================================
  13. % 1.1 Linear equations
  14. % ====================
  15. operator y;
  16. % (1) Linear Bernoulli 1
  17. odesolve((x^4-x^3)*df(y(x),x) + 2*x^4*y(x) = x^3/3 + C, y(x), x);
  18. - 2*x 1 -2 1 1
  19. e *arbconst(1) + ---*c*x + ---*x - ---
  20. 2 6 4
  21. {y(x)=-----------------------------------------------}
  22. 2
  23. x - 2*x + 1
  24. % (2) Linear Bernoulli 2
  25. odesolve(-1/2*df(y(x),x) + y(x) = sin x, y(x), x);
  26. 2*x 2 4
  27. {y(x)=e *arbconst(2) + ---*cos(x) + ---*sin(x)}
  28. 5 5
  29. % (3) Linear change of variables (FJW: shifted Euler equation)
  30. odesolve(df(y(x),x,2)*(a*x+b)^2 + 4df(y(x),x)*(a*x+b)*a + 2y(x)*a^2 = 0,
  31. y(x), x);
  32. 2 2
  33. arbconst(4)*a *x + arbconst(4)*a*b + arbconst(3)*a
  34. {y(x)=-----------------------------------------------------}
  35. 2 2 2
  36. a *x + 2*a*b*x + b
  37. % (4) Adjoint
  38. odesolve((x^2-x)*df(y(x),x,2) + (2x^2+4x-3)*df(y(x),x) + 8x*y(x) = 1,
  39. y(x), x);
  40. 2 2
  41. {df(y(x),x,2)*x - df(y(x),x,2)*x + 2*df(y(x),x)*x + 4*df(y(x),x)*x
  42. - 3*df(y(x),x) + 8*y(x)*x - 1=0}
  43. % (5) Polynomial solutions
  44. % (FJW: Currently very slow, and fails anyway!)
  45. % odesolve((x^2-x)*df(y(x),x,2) + (1-2x^2)*df(y(x),x) + (4x-2)*y(x) = 0,
  46. % y(x), x);
  47. % (6) Dependent variable missing
  48. odesolve(df(y(x),x,2) + 2x*df(y(x),x) = 2x, y(x), x);
  49. 1
  50. {y(x)=arbconst(6) + ---*sqrt(pi)*arbconst(5)*erf(x) + x}
  51. 2
  52. % (7) Liouvillian solutions
  53. % (FJW: INTEGRATION IMPOSSIBLY SLOW WITHOUT EITHER ALGINT OR NOINT OPTION)
  54. begin scalar !*allfac; !*allfac := t; return
  55. odesolve((x^3/2-x^2)*df(y(x),x,2) + (2x^2-3x+1)*df(y(x),x) + (x-1)*y(x) = 0,
  56. y(x), x, noint);
  57. end;
  58. -1
  59. - 1/2 - x - 1/2
  60. {y(x)=x *e *(x - 2)
  61. 1/x
  62. sqrt(x)*e *sqrt(x - 2)
  63. *(arbconst(8) + arbconst(7)*int(--------------------------,x))}
  64. 3 2
  65. x - 2*x
  66. % WARNING: DO NOT RE-EVALUATE RESULT WITHOUT TURNING ON THE NOINT SWITCH
  67. % (8) Reduction of order
  68. % (FJW: Attempting to make explicit currently too slow.)
  69. odesolve(df(y(x),x,2) - 2x*df(y(x),x) + 2y(x) = 3, y(x), x);
  70. {arbconst(10) + sqrt(pi)*arbconst(9)
  71. erf(i*x)
  72. *int(-----------------------------------------------------------,x)*i
  73. 2
  74. x
  75. sqrt(pi)*arbconst(9)*erf(i*x)*i*x + e *arbconst(9) - 2*x
  76. 1
  77. - 2*int(-----------------------------------------------------------,x)
  78. 2
  79. x
  80. sqrt(pi)*arbconst(9)*erf(i*x)*i*x + e *arbconst(9) - 2*x
  81. 3
  82. - log(y(x) - ---)=0}
  83. 2
  84. % (9) Integrating factors
  85. % (FJW: Currently very slow, and fails anyway!)
  86. % odesolve(sqrt(x)*df(y(x),x,2) + 2x*df(y(x),x) + 3y(x) = 0, y(x), x);
  87. % (10) Radical solution (FJW: omitted for now)
  88. % (11) Undetermined coefficients
  89. odesolve(df(y(x),x,2) - 2/x^2*y(x) = 7x^4 + 3*x^3, y(x), x);
  90. 2 -1 1 6 1 5
  91. {y(x)=arbconst(13)*x + arbconst(12)*x + ---*x + ---*x }
  92. 4 6
  93. % (12) Variation of parameters
  94. odesolve(df(y(x),x,2) + y(x) = csc(x), y(x), x);
  95. {y(x)=arbconst(15)*sin(x) + arbconst(14)*cos(x) - cos(x)*x + log(sin(x))*sin(x)}
  96. % (13) Linear constant coefficients
  97. << factor exp(x); write
  98. odesolve(df(y(x),x,7) - 14df(y(x),x,6) + 80df(y(x),x,5) - 242df(y(x),x,4)
  99. + 419df(y(x),x,3) - 416df(y(x),x,2) + 220df(y(x),x) - 48y(x) = 0, y(x), x);
  100. remfac exp(x) >>;
  101. 4*x 3*x
  102. {y(x)=e *arbconst(17) + e *arbconst(16)
  103. 2*x
  104. + e *(arbconst(19) + arbconst(18)*x)
  105. x 2
  106. + e *(arbconst(22) + arbconst(21)*x + arbconst(20)*x )}
  107. % (14) Euler
  108. odesolve(df(y(x),x,4) - 4/x^2*df(y(x),x,2) + 8/x^3*df(y(x),x) - 8/x^4*y(x) = 0,
  109. y(x), x);
  110. 4 2 -1
  111. {y(x)=arbconst(26)*x + arbconst(25)*x + arbconst(24)*x + arbconst(23)*x }
  112. % (15) Exact n-th order
  113. odesolve((1+x+x^2)*df(y(x),x,3) + (3+6x)*df(y(x),x,2) + 6df(y(x),x) = 6x,
  114. y(x), x);
  115. 1 2 1 4
  116. arbconst(29) + arbconst(28)*x + ---*arbconst(27)*x + ---*x
  117. 2 4
  118. {y(x)=--------------------------------------------------------------}
  119. 2
  120. x + x + 1
  121. % 1.2 Nonlinear equations
  122. % =======================
  123. % (16) Integrating factors 1
  124. odesolve(df(y(x),x) = y(x)/(y(x)*log y(x) + x), y(x), x);
  125. 1 2
  126. {x=arbconst(30)*y(x) + ---*log(y(x)) *y(x)}
  127. 2
  128. % (17) Integrating factors 2
  129. odesolve(2y(x)*df(y(x),x)^2 - 2x*df(y(x),x) - y(x) = 0, y(x), x);
  130. 4 2 - 1/3 - 2/3 1/3
  131. {{y(x)=2*(4*arbparam(1) - 12*arbparam(1) + 9) *arbparam(1) *2
  132. *arbconst(31)*arbparam(1),
  133. 4 2 - 1/3 - 2/3 1/3
  134. x=2*(4*arbparam(1) - 12*arbparam(1) + 9) *arbparam(1) *2
  135. 2 4 2 - 1/3
  136. *arbconst(31)*arbparam(1) - (4*arbparam(1) - 12*arbparam(1) + 9)
  137. - 2/3 1/3
  138. *arbparam(1) *2 *arbconst(31),
  139. arbparam(1)}}
  140. % This parametric solution is correct, cf. Zwillinger (1989) p.168 (41.10)
  141. % (except that first edition is missing the constant C)!
  142. % (18) Bernoulli 1
  143. odesolve(df(y(x),x) + y(x) = y(x)^3*sin x, y(x), x, explicit);
  144. {y(x)
  145. 2*x - 1/2
  146. =(5*e *arbconst(32) + 2*cos(x) + 4*sin(x)) *sqrt(5)*plus_or_minus(tag_1)
  147. }
  148. expand_plus_or_minus ws;
  149. 2*x - 1/2
  150. {y(x)=(5*e *arbconst(32) + 2*cos(x) + 4*sin(x)) *sqrt(5),
  151. 2*x - 1/2
  152. y(x)= - (5*e *arbconst(32) + 2*cos(x) + 4*sin(x)) *sqrt(5)}
  153. % (19) Bernoulli 2
  154. operator P, Q;
  155. begin scalar soln, !*exp, !*allfac; % for a neat solution
  156. on allfac;
  157. soln := odesolve(df(y(x),x) + P(x)*y(x) = Q(x)*y(x)^n, y(x), x);
  158. off allfac; return soln
  159. end;
  160. - n int(p(x),x)*n - int(p(x),x)
  161. {y(x) *y(x)= - e
  162. int(p(x),x)
  163. e *q(x)
  164. *((n - 1)*int(-------------------,x) - arbconst(33))}
  165. int(p(x),x)*n
  166. e
  167. odesolve(df(y(x),x) + P(x)*y(x) = Q(x)*y(x)^(2/3), y(x), x);
  168. 1/3 - 1/3*int(p(x),x)
  169. {y(x) =e *arbconst(34)
  170. 1 - 1/3*int(p(x),x) int(p(x),x)/3
  171. + ---*e *int(e *q(x),x)}
  172. 3
  173. % (20) Clairaut 1
  174. odesolve((x^2-1)*df(y(x),x)^2 - 2x*y(x)*df(y(x),x) + y(x)^2 - 1 = 0,
  175. y(x), x, explicit);
  176. 2
  177. {y(x)=arbconst(35)*x + sqrt(arbconst(35) + 1),
  178. 2
  179. y(x)=arbconst(35)*x - sqrt(arbconst(35) + 1),
  180. 2
  181. y(x)=sqrt( - x + 1),
  182. 2
  183. y(x)= - sqrt( - x + 1)}
  184. % (21) Clairaut 2
  185. operator f, g;
  186. odesolve(f(x*df(y(x),x)-y(x)) = g(df(y(x),x)), y(x), x);
  187. {f(arbconst(36)*x - y(x)) - g(arbconst(36))=0}
  188. % (22) Equations of the form y' = f(x,y)
  189. odesolve(df(y(x),x) = (3x^2-y(x)^2-7)/(exp(y(x))+2x*y(x)+1), y(x), x);
  190. y(x) 2 3
  191. {arbconst(37) + e + y(x) *x + y(x) - x + 7*x=0}
  192. % (23) Homogeneous
  193. odesolve(df(y(x),x) = (2x^3*y(x)-y(x)^4)/(x^4-2x*y(x)^3), y(x), x);
  194. 3 3
  195. {arbconst(38)*y(x)*x + y(x) + x =0}
  196. % (24) Factoring the equation
  197. odesolve(df(y(x),x)*(df(y(x),x)+y(x)) = x*(x+y(x)), y(x), x);
  198. - x
  199. {y(x)=e *arbconst(39) - x + 1,
  200. 1 2
  201. y(x)=arbconst(40) + ---*x }
  202. 2
  203. % (25) Interchange variables
  204. % (NB: Soln in Zwillinger (1989) wrong, as is last eqn in Table 68!)
  205. odesolve(df(y(x),x) = x/(x^2*y(x)^2+y(x)^5), y(x), x);
  206. 3
  207. 2 2/3*y(x) 3 3
  208. {x =e *arbconst(41) - y(x) - ---}
  209. 2
  210. % (26) Lagrange 1
  211. odesolve(y(x) = 2x*df(y(x),x) - a*df(y(x),x)^3, y(x), x);
  212. -1 1 3
  213. {{y(x)=2*arbconst(42)*arbparam(2) + ---*arbparam(2) *a,
  214. 2
  215. -2 3 2
  216. x=arbconst(42)*arbparam(2) + ---*arbparam(2) *a,
  217. 4
  218. arbparam(2)}}
  219. odesolve(y(x) = 2x*df(y(x),x) - a*df(y(x),x)^3, y(x), x, implicit);
  220. 3 2 2 2 2
  221. {64*arbconst(43) *a + 128*arbconst(43) *a*x - 144*arbconst(43)*y(x) *a*x
  222. 4 4 2 3
  223. + 64*arbconst(43)*x + 27*y(x) *a - 16*y(x) *x =0}
  224. % root_of quartic is VERY slow if explicit option used!
  225. % (27) Lagrange 2
  226. odesolve(y(x) = 2x*df(y(x),x) - df(y(x),x)^2, y(x), x);
  227. -1 1 2
  228. {{y(x)=2*arbconst(44)*arbparam(3) + ---*arbparam(3) ,
  229. 3
  230. -2 2
  231. x=arbconst(44)*arbparam(3) + ---*arbparam(3),
  232. 3
  233. arbparam(3)}}
  234. odesolve(y(x) = 2x*df(y(x),x) - df(y(x),x)^2, y(x), x, implicit);
  235. 2 3 3
  236. { - 9*arbconst(45) + 18*arbconst(45)*y(x)*x - 12*arbconst(45)*x - 4*y(x)
  237. 2 2
  238. + 3*y(x) *x =0}
  239. % (28) Riccati 1
  240. odesolve(df(y(x),x) = exp(x)*y(x)^2 - y(x) + exp(-x), y(x), x);
  241. - x - x
  242. e *arbconst(46)*sin(x) - e *cos(x)
  243. {y(x)=------------------------------------------}
  244. arbconst(46)*cos(x) + sin(x)
  245. % (29) Riccati 2
  246. << factor x; write
  247. odesolve(df(y(x),x) = y(x)^2 - x*y(x) + 1, y(x), x);
  248. remfac x >>;
  249. 2
  250. 1/2*x
  251. 2*e *arbconst(47)
  252. {y(x)=x + ----------------------------------------------------}
  253. i*x
  254. sqrt(pi)*sqrt(2)*arbconst(47)*erf(---------)*i - 2
  255. sqrt(2)
  256. % (30) Separable
  257. odesolve(df(y(x),x) = (9x^8+1)/(y(x)^2+1), y(x), x);
  258. 3 9
  259. {3*arbconst(48) + y(x) + 3*y(x) - 3*x - 3*x=0}
  260. % (31) Solvable for x
  261. odesolve(y(x) = 2x*df(y(x),x) + y(x)*df(y(x),x)^2, y(x), x);
  262. -1
  263. {{y(x)= - 2*arbconst(49)*arbparam(4) ,
  264. -2
  265. x= - arbconst(49)*arbparam(4) + arbconst(49),
  266. arbparam(4)}}
  267. odesolve(y(x) = 2x*df(y(x),x) + y(x)*df(y(x),x)^2, y(x), x, implicit);
  268. 2 2
  269. { - 4*arbconst(50) + 4*arbconst(50)*x + y(x) =0}
  270. % (32) Solvable for y
  271. begin scalar !*allfac; !*allfac := t; return
  272. odesolve(x = y(x)*df(y(x),x) - x*df(y(x),x)^2, y(x), x)
  273. end;
  274. 2
  275. - 1/2*arbparam(5) 2
  276. {{y(x)=e *arbconst(51)*(arbparam(5) + 1),
  277. 2
  278. - 1/2*arbparam(5)
  279. x=e *arbconst(51)*arbparam(5),
  280. arbparam(5)}}
  281. % (33) Autonomous 1
  282. odesolve(df(y(x),x,2)-df(y(x),x) = 2y(x)*df(y(x),x), y(x), x, explicit);
  283. {y(x)=
  284. 1 1 1
  285. - ---*arbconst(52)*tan(---*arbconst(53)*arbconst(52) - ---*arbconst(52)*x)
  286. 2 2 2
  287. 1
  288. - ---,
  289. 2
  290. y(x)=arbconst(54)}
  291. % (34) Autonomous 2 (FJW: Slow without either algint or noint option.)
  292. odesolve(df(y(x),x,2)/y(x) - df(y(x),x)^2/y(x)^2 - 1 + 1/y(x)^3 = 0,
  293. y(x), x, noint);
  294. {arbconst(57)*plus_or_minus(tag_4) + sqrt(3)
  295. 3 3 - 1/2
  296. *int(sqrt(y(x))*(3*arbconst(56)*y(x) + 6*log(y(x))*y(x) + 2) ,y(x))
  297. - plus_or_minus(tag_4)*x=0}
  298. % (35) Differentiation method
  299. odesolve(2y(x)*df(y(x),x,2) - df(y(x),x)^2 =
  300. 1/3(df(y(x),x) - x*df(y(x),x,2))^2, y(x), x, explicit);
  301. 2 2 2
  302. {y(x)=arbconst(59) *x + 2*sqrt(3)*arbconst(59)*arbconst(58)*x + 4*arbconst(58)
  303. ,
  304. 2 2 2
  305. y(x)=arbconst(60) *x - 2*sqrt(3)*arbconst(60)*arbconst(58)*x + 4*arbconst(58)
  306. ,
  307. y(x)=arbconst(61)}
  308. % (36) Equidimensional in x
  309. odesolve(x*df(y(x),x,2) = 2y(x)*df(y(x),x), y(x), x, explicit);
  310. 1
  311. {y(x)= - ---*arbconst(62)
  312. 2
  313. 1 1 1
  314. *tan(---*arbconst(63)*arbconst(62) - ---*arbconst(62)*log(x)) - ---,
  315. 2 2 2
  316. y(x)=arbconst(64)}
  317. % (37) Equidimensional in y
  318. odesolve((1-x)*(y(x)*df(y(x),x,2)-df(y(x),x)^2) + x^2*y(x)^2 = 0, y(x), x);
  319. 3 2
  320. arbconst(66) + arbconst(65)*x + 1/6*x + 1/2*x - x x
  321. e *(x - 1)
  322. {y(x)=---------------------------------------------------------------}
  323. x - 1
  324. % (38) Exact second order
  325. odesolve(x*y(x)*df(y(x),x,2) + x*df(y(x),x)^2 + y(x)*df(y(x),x) = 0,
  326. y(x), x, explicit);
  327. {y(x)=sqrt( - arbconst(68) + log(x))*sqrt(arbconst(67))*sqrt(2),
  328. y(x)= - sqrt( - arbconst(68) + log(x))*sqrt(arbconst(67))*sqrt(2),
  329. y(x)=arbconst(69)}
  330. % (39) Factoring differential operator
  331. odesolve(df(y(x),x,2)^2 - 2df(y(x),x)*df(y(x),x,2) + 2y(x)*df(y(x),x) -
  332. y(x)^2 = 0, y(x), x);
  333. x x
  334. {y(x)=e *arbconst(71) + e *arbconst(70)*x,
  335. x - x
  336. y(x)=e *arbconst(73) + e *arbconst(72)}
  337. % (40) Scale invariant (fails with algint option)
  338. odesolve(x^2*df(y(x),x,2) + 3x*df(y(x),x) = 1/(y(x)^3*x^4), y(x), x);
  339. {2*arbconst(75)*plus_or_minus(tag_7) + log(
  340. 2 - 1/2 2 - 1/2
  341. - 2*(4*arbconst(74) + 1) *arbconst(74) + (4*arbconst(74) + 1)
  342. 2 2 4 4
  343. *sqrt( - 4*arbconst(74)*y(x) *x + y(x) *x - 1)
  344. 2 - 1/2 2 2
  345. + (4*arbconst(74) + 1) *y(x) *x ) - 2*log(x)*plus_or_minus(tag_7)=0}
  346. % Revised scale-invariant example (hangs with algint option):
  347. ode := x^2*df(y(x),x,2) + 3x*df(y(x),x) + 2*y(x) = 1/(y(x)^3*x^4);
  348. 2 -3 -4
  349. ode := df(y(x),x,2)*x + 3*df(y(x),x)*x + 2*y(x)=y(x) *x
  350. % Choose full (explicit and expanded) solution:
  351. odesolve(ode, y(x), x, full);
  352. 1
  353. {y(x)= - ---*sqrt(15*arbconst(76)
  354. 2
  355. 2 - 1/2 -1
  356. - sqrt(225*arbconst(76) - 64)*sin(2*arbconst(77) - 2*log(x)))*2 *x ,
  357. 1
  358. y(x)= - ---*sqrt(15*arbconst(76)
  359. 2
  360. 2 - 1/2 -1
  361. + sqrt(225*arbconst(76) - 64)*sin(2*arbconst(77) - 2*log(x)))*2 *x ,
  362. 1
  363. y(x)=---*sqrt(15*arbconst(76)
  364. 2
  365. 2
  366. - sqrt(225*arbconst(76) - 64)*sin(2*arbconst(77) - 2*log(x)))
  367. - 1/2 -1
  368. *2 *x ,
  369. 1
  370. y(x)=---*sqrt(15*arbconst(76)
  371. 2
  372. 2
  373. + sqrt(225*arbconst(76) - 64)*sin(2*arbconst(77) - 2*log(x)))
  374. - 1/2 -1
  375. *2 *x }
  376. % or "explicit, expand"
  377. % Check it -- each solution should simplify to 0:
  378. foreach soln in ws collect
  379. trigsimp sub(soln, num(lhs ode - rhs ode));
  380. {0,0,0,0}
  381. % (41) Autonomous, 3rd order
  382. odesolve((df(y(x),x)^2+1)*df(y(x),x,3) - 3df(y(x),x)*df(y(x),x,2)^2 = 0,
  383. y(x), x);
  384. 2 2
  385. {y(x)=arbconst(81) + sqrt(arbconst(79) *arbconst(78)
  386. 2 2 2
  387. - 2*arbconst(79)*arbconst(78) *x + 2*arbconst(79) + arbconst(78) *x - 2*x)
  388. -1
  389. *arbconst(78) *i,
  390. y(x)=arbconst(82) + i*x,
  391. y(x)=arbconst(83) - i*x,
  392. y(x)=arbconst(84) + arbconst(80)*x}
  393. % odesolve((df(y(x),x)^2+1)*df(y(x),x,3) - 3df(y(x),x)*df(y(x),x,2)^2 = 0,
  394. % y(x), x, implicit);
  395. % Implicit form is currently too messy!
  396. % (42) Autonomous, 4th order
  397. odesolve(3*df(y(x),x,2)*df(y(x),x,4) - 5df(y(x),x,3)^2 = 0, y(x), x);
  398. {y(x)=arbconst(89)*x + arbconst(88)
  399. -3
  400. - 3*sqrt(arbconst(86) - x)*sqrt(6)*arbconst(85) ,
  401. y(x)=arbconst(91)*x + arbconst(90)
  402. -3
  403. + 3*sqrt(arbconst(86) - x)*sqrt(6)*arbconst(85) ,
  404. 1 2
  405. y(x)=arbconst(93)*x + arbconst(92) + ---*arbconst(87)*x }
  406. 2
  407. % 1.3 Special equations
  408. % =====================
  409. % (43) Delay
  410. odesolve(df(y(x),x) + a*y(x-1) = 0, y(x), x);
  411. ***** Arguments of y differ -- solving delay equations is not implemented.
  412. % (44) Functions with several parameters
  413. odesolve(df(y(x,a),x) = a*y(x,a), y(x,a), x);
  414. a*x
  415. {y(x,a)=e *arbconst(94)}
  416. % 2 Single equations with initial conditions
  417. % ===========================================
  418. % (45) Exact 4th order
  419. odesolve(df(y(x),x,4) = sin x, y(x), x,
  420. {x=0, y(x)=0, df(y(x),x)=0, df(y(x),x,2)=0, df(y(x),x,3)=0});
  421. 1 3
  422. {y(x)=sin(x) + ---*x - x}
  423. 6
  424. % (46) Linear polynomial coefficients -- Bessel J0
  425. odesolve(x*df(y(x),x,2) + df(y(x),x) + 2x*y(x) = 0, y(x), x,
  426. {x=0, y(x)=1, df(y(x),x)=0});
  427. {y(x)=besselj(0,sqrt(2)*x)}
  428. % (47) Second-degree separable
  429. soln :=
  430. odesolve(x*df(y(x),x)^2 - y(x)^2 + 1 = 0, y(x)=1, x=0, explicit);
  431. 1 2*sqrt(x)*plus_or_minus(tag_9)
  432. soln := {y(x)=---*e
  433. 2
  434. 1 - 2*sqrt(x)*plus_or_minus(tag_9)
  435. + ---*e }
  436. 2
  437. % Alternatively ...
  438. soln where e^~x => cosh x + sinh x;
  439. {y(x)=cosh(2*sqrt(x)*plus_or_minus(tag_9))}
  440. % but this works ONLY with `on div, intstr; off allfac;'
  441. % A better alternative is ...
  442. trigsimp(soln, hyp, combine);
  443. {y(x)=cosh(2*sqrt(x)*plus_or_minus(tag_9))}
  444. expand_plus_or_minus ws;
  445. {y(x)=cosh(2*sqrt(x))}
  446. % (48) Autonomous
  447. odesolve(df(y(x),x,2) + y(x)*df(y(x),x)^3 = 0, y(x), x,
  448. {x=0, y(x)=0, df(y(x),x)=2});
  449. 3
  450. {y(x) + 3*y(x) - 6*x=0}
  451. %% Only one explicit solution satisfies the conditions:
  452. begin scalar !*trode, !*fullroots; !*fullroots := t; return
  453. odesolve(df(y(x),x,2) + y(x)*df(y(x),x)^3 = 0, y(x), x,
  454. {x=0, y(x)=0, df(y(x),x)=2}, explicit);
  455. end;
  456. 2 1/3 2 - 1/3
  457. {y(x)=(sqrt(9*x + 1) + 3*x) - (sqrt(9*x + 1) + 3*x) }
  458. % 3 Systems of equations
  459. % =======================
  460. % (49) Integrable combinations
  461. operator x, z;
  462. odesolve({df(x(t),t) = -3y(t)*z(t), df(y(t),t) = 3x(t)*z(t),
  463. df(z(t),t) = -x(t)*y(t)}, {x(t),y(t),z(t)}, t);
  464. odesolve-system({df(x(t),t) + 3*y(t)*z(t),
  465. df(y(t),t) - 3*x(t)*z(t),
  466. df(z(t),t) + x(t)*y(t)},{x(t),y(t),z(t)},t)
  467. % (50) Matrix Riccati
  468. operator a, b;
  469. odesolve({df(x(t),t) = a(t)*(y(t)^2-x(t)^2) + 2b(t)*x(t)*y(t) + 2c*x(t),
  470. df(y(t),t) = b(t)*(y(t)^2-x(t)^2) - 2a(t)*x(t)*y(t) + 2c*y(t)},
  471. {x(t),y(t)}, t);
  472. 2 2
  473. odesolve-system({a(t)*x(t) - a(t)*y(t) - 2*b(t)*x(t)*y(t) + df(x(t),t)
  474. - 2*c*x(t),
  475. 2 2
  476. 2*a(t)*x(t)*y(t) + b(t)*x(t) - b(t)*y(t) + df(y(t),t)
  477. - 2*c*y(t)},{x(t),y(t)},t)
  478. % (51) Triangular
  479. odesolve({df(x(t),t) = x(t)*(1 + cos(t)/(2+sin(t))),
  480. df(y(t),t) = x(t) - y(t)}, {x(t),y(t)}, t);
  481. odesolve-system({( - cos(t)*x(t) + df(x(t),t)*sin(t) + 2*df(x(t),t)
  482. - sin(t)*x(t) - 2*x(t))/(sin(t) + 2),
  483. df(y(t),t) - x(t) + y(t)},{x(t),y(t)},t)
  484. % (52) Vector
  485. odesolve({df(x(t),t) = 9x(t) + 2y(t), df(y(t),t) = x(t) + 8y(t)},
  486. {x(t),y(t)}, t);
  487. odesolve-system({df(x(t),t) - 9*x(t) - 2*y(t),
  488. df(y(t),t) - x(t) - 8*y(t)},{x(t),y(t)},t)
  489. % (53) Higher order
  490. odesolve({df(x(t),t) - x(t) + 2y(t) = 0,
  491. df(x(t),t,2) - 2df(y(t),t) = 2t - cos(2t)}, {x(t),y(t)}, t);
  492. odesolve-system({df(x(t),t) - x(t) + 2*y(t),
  493. cos(2*t) + df(x(t),t,2) - 2*df(y(t),t) - 2*t},{x(t),y(t)},t)
  494. % (54) Inhomogeneous system
  495. equ := {df(x(t),t) = -1/(t*(t^2+1))*x(t) + 1/(t^2*(t^2+1))*y(t) + 1/t,
  496. df(y(t),t) = -t^2/(t^2+1)*x(t) + (2t^2+1)/(t*(t^2+1))*y(t) + 1};
  497. -1 -2 -1
  498. - x(t)*t + y(t)*t + t + t
  499. equ := {df(x(t),t)=----------------------------------,
  500. 2
  501. t + 1
  502. 2 -1 2
  503. - x(t)*t + 2*y(t)*t + y(t)*t + t + 1
  504. df(y(t),t)=-------------------------------------------}
  505. 2
  506. t + 1
  507. odesolve(equ, {x(t),y(t)}, t);
  508. 2 -1 -1 -2
  509. df(x(t),t)*t + df(x(t),t) - t + t *x(t) - t - y(t)*t
  510. odesolve-system({------------------------------------------------------------,
  511. 2
  512. t + 1
  513. 2 2 2
  514. (df(y(t),t)*t + df(y(t),t) + t *x(t) - t - 2*t*y(t)
  515. -1 2
  516. - y(t)*t - 1)/(t + 1)},{x(t),y(t)},t)
  517. end;
  518. Time for test: 20457 ms, plus GC time: 1387 ms