fps.rlg 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695
  1. Sun Aug 18 18:40:08 2002 run on Windows
  2. % Examples for the algorithmic calculation of formal
  3. % Puiseux, Laurent and power series,
  4. %
  5. % Wolfram Koepf, Freie Universitaet Berlin, Germany
  6. % (taken from the original paper and adapted to REDUCE
  7. % form by Winfried Neun, ZIB Berlin)
  8. % Formal Laurent series
  9. fps(E^x,x);
  10. k
  11. x
  12. infsum(--------------,k,0,infinity)
  13. factorial(k)
  14. fps(E^x/(x^3),x);
  15. k
  16. x
  17. infsum(-----------------,k,0,infinity)
  18. 3
  19. factorial(k)*x
  20. fps(x * e^(x^4),x);
  21. 4*k
  22. x *x
  23. infsum(--------------,k,0,infinity)
  24. factorial(k)
  25. fps(sin (x + y),x);
  26. 2*k k
  27. x *( - 1) *cos(y)*x
  28. infsum(-----------------------,k,0,infinity)
  29. factorial(2*k + 1)
  30. 2*k k
  31. x *( - 1) *sin(y)
  32. + infsum(---------------------,k,0,infinity)
  33. factorial(2*k)
  34. simplede (sin x,x);
  35. df(y,x,2) + y
  36. %find a DE for sin
  37. simplede (sin (x)^2,x,w);
  38. df(w,x,3) + 4*df(w,x)
  39. % DE in w and x
  40. fps(asin x,x);
  41. 2*k
  42. x *factorial(2*k)*x
  43. infsum(------------------------------,k,0,infinity)
  44. 2*k 2
  45. 2 *factorial(k) *(2*k + 1)
  46. fps((asin x)^2,x);
  47. 2*k 2*k 2 2
  48. x *2 *factorial(k) *x
  49. infsum(----------------------------,k,0,infinity)
  50. factorial(2*k + 1)*(k + 1)
  51. fps(e^(asin x),x);
  52. 2*k k 2
  53. x *2 *prod(2*j - 2*j + 1,j,1,k)*x
  54. infsum(--------------------------------------,k,0,infinity)
  55. factorial(2*k + 1)
  56. 2*k 2
  57. x *prod(4*j - 8*j + 5,j,1,k)
  58. + infsum(---------------------------------,k,0,infinity)
  59. factorial(2*k)
  60. fps(e^(asinh x),x);
  61. 2*k k
  62. - x *( - 1) *factorial(2*k)
  63. infsum(--------------------------------,k,0,infinity) + x
  64. k 2
  65. 4 *factorial(k) *(2*k - 1)
  66. fps((x + sqrt(1+x^2))^A,x);
  67. 2*k k 2*k - a a
  68. x *( - 1) *2 *pochhammer(------,k)*pochhammer(---,k)
  69. 2 2
  70. infsum(----------------------------------------------------------,k,0,infinity)
  71. factorial(2*k)
  72. 2*k k 2*k - a + 1 a + 1
  73. x *( - 1) *2 *pochhammer(----------,k)*pochhammer(-------,k)*a*x
  74. 2 2
  75. + infsum(----------------------------------------------------------------------,
  76. factorial(2*k + 1)
  77. k,0,infinity)
  78. fps(e^(x^2)*erf x,x);
  79. 2*k 2*k
  80. 2*x *sqrt(pi)*2 *factorial(k)*x
  81. infsum(-------------------------------------,k,0,infinity)
  82. factorial(2*k + 1)*pi
  83. fps(e^x - 2 e^(-x/2) * cos(sqrt(3) * x/2 -pi/3),x);
  84. 3*k 2
  85. 9*x *x *(k + 1)
  86. infsum(--------------------,k,0,infinity)
  87. factorial(3*k + 3)
  88. % fps(int(e^(-a^2*t^2) * cos(2*x*t),t,0,infinity),x) % not yet
  89. % fps(4/x * int(e^(t^2)*erf(t),t,0,sqrt(x)/2),x);
  90. fps(sin x * e^x,x);
  91. k k/2 k*pi
  92. x *2 *sin(------)
  93. 4
  94. infsum(---------------------,k,0,infinity)
  95. factorial(k)
  96. fps(cos x * e^(2*x),x);
  97. k k/2 1
  98. x *5 *cos(atan(---)*k)
  99. 2
  100. infsum(--------------------------,k,0,infinity)
  101. factorial(k)
  102. fps(1/(x-x^3),x);
  103. k k k
  104. x *( - 1) - x
  105. infsum(-----------------,k,0,infinity)*x + 1
  106. k
  107. 2*( - 1)
  108. ----------------------------------------------
  109. x
  110. fps(1/(x^2 + 3 x + 2),x);
  111. k k k
  112. 2*x *2 - x
  113. infsum(--------------,k,0,infinity)
  114. k k
  115. 2*( - 1) *2
  116. fps(x/(1-x-x^2),x);
  117. x
  118. fps(--------------,x,0)
  119. 2
  120. (1 - x) - x
  121. % Logarithmic singularities and Puisieux series
  122. fps(sin sqrt x,x);
  123. (2*k + 1)/2 k
  124. x *( - 1)
  125. infsum(----------------------,k,0,infinity)
  126. factorial(2*k + 1)
  127. fps(((1 + sqrt x)/x)^(1/3),x);
  128. (6*k + 1)/6 2
  129. x *pochhammer(---,2*k)
  130. 3
  131. infsum(----------------------------------,k,0,infinity)
  132. 3*factorial(2*k + 1)
  133. k - 1
  134. x *pochhammer(------,2*k)
  135. 3
  136. + infsum(---------------------------,k,0,infinity)
  137. 1/3
  138. x *factorial(2*k)
  139. fps(asech x,x);
  140. % some more (Wolfram Koepf, priv. comm.)
  141. fps((1+x)^alpha,x);
  142. k k
  143. x *( - 1) *pochhammer( - alpha,k)
  144. infsum(-----------------------------------,k,0,infinity)
  145. factorial(k)
  146. fps((1+sqrt(1+x))^beta,x);
  147. k k beta
  148. x *( - 1) *2 *pochhammer( - beta,2*k)
  149. infsum(---------------------------------------------,k,0,infinity)
  150. 2*k
  151. 2 *factorial(k)*pochhammer( - beta + 1,k)
  152. fps(sin(x)^2+cos(x)^2,x);
  153. 1
  154. fps(sin(x)^2*cos(x)^2,x);
  155. 2*k k 4*k 2
  156. x *( - 1) *2 *x
  157. infsum(----------------------------,k,0,infinity)
  158. factorial(2*k + 1)*(k + 1)
  159. fps(sin(x)*cos(x^2),x);
  160. 2
  161. fps(sin(x)*cos(x ),x,0)
  162. fps((x-1)^(-1),x);
  163. k
  164. infsum( - x ,k,0,infinity)
  165. fps(atan(x+y),x);
  166. fps(atan(x + y),x,0)
  167. fps((1-x^5)^6,x);
  168. 30 25 20 15 10 5
  169. x - 6*x + 15*x - 20*x + 15*x - 6*x + 1
  170. fps(asec x,x);
  171. fps(besseli(0,x),x);
  172. 2*k
  173. x
  174. infsum(--------------------,k,0,infinity)
  175. 2*k 2
  176. 2 *factorial(k)
  177. fps(besseli(1,x),x);
  178. 2*k
  179. x *x
  180. infsum(--------------------------------------,k,0,infinity)
  181. 2*k
  182. 2*2 *factorial(k + 1)*factorial(k)
  183. fps(exp(x^(1/3)),x);
  184. (3*k + 1)/3
  185. x
  186. infsum(--------------------,k,0,infinity)
  187. factorial(3*k + 1)
  188. k
  189. x
  190. + infsum(----------------,k,0,infinity)
  191. factorial(3*k)
  192. (3*k + 2)/3
  193. 3*x *(k + 1)
  194. + infsum(------------------------,k,0,infinity)
  195. factorial(3*k + 3)
  196. fps(log(1-x),x);
  197. k
  198. - x *x
  199. infsum(---------,k,0,infinity)
  200. k + 1
  201. fps(exp x*sinh x,x);
  202. k k
  203. x *2 *x
  204. infsum(------------------,k,0,infinity)
  205. factorial(k + 1)
  206. fps(atan x,x);
  207. 2*k k
  208. x *( - 1) *x
  209. infsum(----------------,k,0,infinity)
  210. 2*k + 1
  211. fps(sin x+sinh x,x);
  212. 4*k
  213. 2*x *x
  214. infsum(--------------------,k,0,infinity)
  215. factorial(4*k + 1)
  216. fps(sin x*sinh x,x);
  217. 4*k k 2*k 2
  218. x *( - 1) *2 *x
  219. infsum(------------------------------,k,0,infinity)
  220. factorial(4*k + 1)*(2*k + 1)
  221. fps(int(erf(x),x),x);
  222. *** ci already defined as operator
  223. *** si already defined as operator
  224. 2*k k
  225. - x *sqrt(pi)*( - 1)
  226. infsum(---------------------------,k,0,infinity)
  227. factorial(k)*pi*(2*k - 1)
  228. fps(sqrt(2-x),x);
  229. k
  230. - x *sqrt(2)*factorial(2*k)
  231. infsum(------------------------------,k,0,infinity)
  232. k 2
  233. 8 *factorial(k) *(2*k - 1)
  234. fps(sqrt(1+x)+sqrt(1-x),x);
  235. 2*k
  236. - 2*x *factorial(4*k)
  237. infsum(--------------------------------,k,0,infinity)
  238. 2*k 2
  239. 4 *factorial(2*k) *(4*k - 1)
  240. fps(exp(a+b*x)*exp(c+d*x),x);
  241. k a + c k
  242. x *e *(b + d)
  243. infsum(--------------------,k,0,infinity)
  244. factorial(k)
  245. fps(1/cos(asin x),x);
  246. 2*k
  247. x *factorial(2*k)
  248. infsum(---------------------,k,0,infinity)
  249. 2*k 2
  250. 2 *factorial(k)
  251. fps(sqrt(1-x^2)+x*asin x,x);
  252. 2*k
  253. x *factorial(2*k)
  254. infsum(-----------------------------------,k,0,infinity)
  255. k 2 2
  256. 4 *factorial(k) *(4*k - 4*k + 1)
  257. fps(sqrt(1-sqrt(x)),x);
  258. (2*k + 1)/2
  259. - x *factorial(4*k)
  260. infsum(------------------------------------------,k,0,infinity)
  261. 4*k
  262. 2*2 *factorial(2*k + 1)*factorial(2*k)
  263. k
  264. - x *factorial(4*k)
  265. + infsum(--------------------------------,k,0,infinity)
  266. 2*k 2
  267. 4 *factorial(2*k) *(4*k - 1)
  268. fps(cos(n*acos x),x);
  269. 2*k 2*k n*pi - n n
  270. x *2 *cos(------)*pochhammer(------,k)*pochhammer(---,k)
  271. 2 2 2
  272. infsum(--------------------------------------------------------------,k,0,
  273. factorial(2*k)
  274. infinity) + infsum(
  275. 2*k 2*k - n + 1 n + 1 n*pi
  276. x *2 *pochhammer(----------,k)*pochhammer(-------,k)*sin(------)*n*x
  277. 2 2 2
  278. --------------------------------------------------------------------------,k,
  279. factorial(2*k + 1)
  280. 0,infinity)
  281. fps(cos x+I*sin x,x);
  282. k k
  283. x *i
  284. infsum(--------------,k,0,infinity)
  285. factorial(k)
  286. fps(cos(3*asinh x),x);
  287. 2*k k 2
  288. x *( - 1) *prod(4*j - 8*j + 13,j,1,k)
  289. infsum(------------------------------------------,k,0,infinity)
  290. factorial(2*k)
  291. fps(cos(n*asinh x),x);
  292. 2*k k 2*k - i*n i*n
  293. x *( - 1) *2 *pochhammer(--------,k)*pochhammer(-----,k)
  294. 2 2
  295. infsum(--------------------------------------------------------------,k,0,
  296. factorial(2*k)
  297. infinity)
  298. fps(sin(n*log(x+sqrt(1+x^2))),x);
  299. 2*k k 2*k - i*n + 1 i*n + 1
  300. infsum((x *( - 1) *2 *pochhammer(------------,k)*pochhammer(---------,k)*n*x
  301. 2 2
  302. )/factorial(2*k + 1),k,0,infinity)
  303. fps(sqrt(1+x^2)*asinh x-x,x);
  304. 2*k k 2*k 3
  305. 2*x *( - 1) *2 *factorial(k + 1)*factorial(k)*x
  306. infsum(------------------------------------------------------,k,0,infinity)
  307. factorial(2*k + 3)
  308. fps(int(erf(x)/x,x),x);
  309. 2*k k
  310. 2*x *sqrt(pi)*( - 1) *x
  311. infsum(----------------------------------,k,0,infinity)
  312. 2
  313. factorial(k)*pi*(4*k + 4*k + 1)
  314. erf(x)
  315. + sub(x=0,int(--------,x))
  316. x
  317. fps(asin(x)^2/x^4,x);
  318. 2*k 2*k 2
  319. x *2 *factorial(k)
  320. infsum(-------------------------------,k,0,infinity)
  321. 2
  322. factorial(2*k + 1)*x *(k + 1)
  323. % we had problems here:
  324. fps(cos(asin x),x);
  325. 2*k
  326. - x *factorial(2*k)
  327. infsum(----------------------------,k,0,infinity)
  328. k 2
  329. 4 *factorial(k) *(2*k - 1)
  330. fps(sinh(log x),x);
  331. fps(sinh(log(x)),x,0)
  332. fps(atan(cot x),x);
  333. Could not find the limit of: atan(cot(x)),x,0
  334. % we can cure this one by defining the limit:
  335. let limit(atan(cot ~x),x,0) => pi/2;
  336. fps(atan(cot x),x);
  337. pi - 2*x
  338. ----------
  339. 2
  340. fps(exp(nnn*x)*cos(mmm*x),x);
  341. k 2 2
  342. infsum((x *((impart(mmm) + 2*impart(mmm)*repart(nnn) + impart(nnn)
  343. 2 2 k
  344. - 2*impart(nnn)*repart(mmm) + repart(mmm) + repart(nnn) )**---
  345. 2
  346. impart(nnn) - repart(mmm) 2
  347. *cos(atan(---------------------------)*k) + (impart(mmm)
  348. impart(mmm) + repart(nnn)
  349. 2
  350. - 2*impart(mmm)*repart(nnn) + impart(nnn)
  351. 2 2 k
  352. + 2*impart(nnn)*repart(mmm) + repart(mmm) + repart(nnn) )**---
  353. 2
  354. impart(nnn) + repart(mmm) 2
  355. *cos(atan(---------------------------)*k) - (impart(mmm)
  356. impart(mmm) - repart(nnn)
  357. 2
  358. - 2*impart(mmm)*repart(nnn) + impart(nnn)
  359. 2 2 k
  360. + 2*impart(nnn)*repart(mmm) + repart(mmm) + repart(nnn) )**---
  361. 2
  362. impart(nnn) + repart(mmm) 2
  363. *sin(atan(---------------------------)*k)*i + (impart(mmm)
  364. impart(mmm) - repart(nnn)
  365. 2
  366. + 2*impart(mmm)*repart(nnn) + impart(nnn)
  367. 2 2 k
  368. - 2*impart(nnn)*repart(mmm) + repart(mmm) + repart(nnn) )**---
  369. 2
  370. impart(nnn) - repart(mmm)
  371. *sin(atan(---------------------------)*k)*i))/(2*factorial(k)),k,0,
  372. impart(mmm) + repart(nnn)
  373. infinity)
  374. fps(sqrt(2-x^2),x);
  375. 2*k
  376. - 2*x *factorial(2*k)
  377. infsum(------------------------------------,k,0,infinity)
  378. k 2
  379. sqrt(2)*8 *factorial(k) *(2*k - 1)
  380. fps(ci x,x);
  381. 2*k k
  382. x *( - 1) *infinity*x
  383. ci(0) + infsum(------------------------------,k,0,infinity)
  384. factorial(2*k + 1)*(2*k + 1)
  385. fps(log(1-2*x*y+x^2),x);
  386. 2
  387. fps(log(1 - 2*x*y + x ),x,0)
  388. FPS(sin x,x,pi);
  389. 2*k k
  390. ( - pi + x) *( - 1) *( - pi + x)
  391. infsum(------------------------------------,k,0,infinity)
  392. factorial(2*k + 1)
  393. % This one takes ages :
  394. %fps(acos(cos(x)),x);
  395. fps_search_depth := 7;
  396. fps_search_depth := 7
  397. % does not find aa DE with the default
  398. fps(sin(x^(1/3)),x);
  399. 2*k k k k
  400. infsum(( - x *( - 1) *108 *factorial(k)*x)/(6*46656 *factorial(3*k + 1)
  401. 7 5
  402. *factorial(2*k + 1)*pochhammer(---,k)*pochhammer(---,k)),k,0,infinity)
  403. 6 6
  404. (6*k + 2)/3 k 2*k 3*k k
  405. + infsum((x *( - 1) *2 *3 *factorial(k + 1)*x)/(20*46656
  406. 11
  407. *factorial(3*k + 3)*factorial(2*k + 1)*pochhammer(----,k)
  408. 6
  409. 7
  410. *pochhammer(---,k)),k,0,infinity) + infsum(
  411. 6
  412. (6*k + 1)/3 k 2*k 3*k
  413. x *( - 1) *2 *3 *factorial(k)
  414. --------------------------------------------------------------------------,k,
  415. k 7 5
  416. 46656 *factorial(3*k)*factorial(2*k)*pochhammer(---,k)*pochhammer(---,k)
  417. 6 6
  418. 0,infinity)
  419. end;
  420. Time for test: 447053 ms, plus GC time: 9435 ms