ztrans.rlg 27 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547
  1. Sun Aug 18 20:47:47 2002 run on Windows
  2. *** binomial already defined as operator
  3. *** ~f already defined as operator
  4. % test file for ztrans package
  5. %
  6. operator f;
  7. operator g;
  8. operator h;
  9. % Examples for Z transformation
  10. ztrans(1,n,z);
  11. z
  12. -------
  13. z - 1
  14. ztrans(a,n,z);
  15. a*z
  16. -------
  17. z - 1
  18. ztrans((-1)^n,n,z);
  19. z
  20. -------
  21. z + 1
  22. ztrans(n,n,z);
  23. z
  24. --------------
  25. 2
  26. z - 2*z + 1
  27. ztrans(n^2,n,z);
  28. z*(z + 1)
  29. ---------------------
  30. 3 2
  31. z - 3*z + 3*z - 1
  32. ztrans(n^k,n,z);
  33. k
  34. ztrans(n ,n,z)
  35. % should be output=input
  36. ztrans((-1)^n*n^2,n,z);
  37. z*( - z + 1)
  38. ---------------------
  39. 3 2
  40. z + 3*z + 3*z + 1
  41. ztrans(binomial(n,m),n,z);
  42. z
  43. ------------------
  44. m
  45. (z - 1) *(z - 1)
  46. ztrans((-1)^n*binomial(n,m),n,z);
  47. z
  48. ---------------------
  49. m
  50. ( - z - 1) *(z + 1)
  51. ztrans(binomial(n+k,m),n,z);
  52. k
  53. z *z
  54. ------------------
  55. m
  56. (z - 1) *(z - 1)
  57. ztrans(a^n,n,z);
  58. - z
  59. -------
  60. a - z
  61. ztrans(a^(n-1),n,z);
  62. - z
  63. -----------
  64. a*(a - z)
  65. ztrans(a^(n+k),n,z);
  66. k
  67. - a *z
  68. ---------
  69. a - z
  70. ztrans((-1)^n*a^n,n,z);
  71. z
  72. -------
  73. a + z
  74. ztrans(1-a^n,n,z);
  75. z*(a - 1)
  76. ------------------
  77. 2
  78. a*z - a - z + z
  79. ztrans(n*a^n,n,z);
  80. a*z
  81. -----------------
  82. 2 2
  83. a - 2*a*z + z
  84. ztrans(n^3*a^n,n,z);
  85. 2 2
  86. a*z*(a + 4*a*z + z )
  87. -------------------------------------
  88. 4 3 2 2 3 4
  89. a - 4*a *z + 6*a *z - 4*a*z + z
  90. ztrans(binomial(n,m)*a^n,n,z);
  91. m
  92. - a *z
  93. ---------------------
  94. m
  95. ( - a + z) *(a - z)
  96. ztrans(1/(n+1),n,z);
  97. z
  98. log(-------)*z
  99. z - 1
  100. ztrans(1/(n+2),n,z);
  101. z
  102. z*(log(-------)*z - 1)
  103. z - 1
  104. ztrans((-1)^(n)/(n+1),n,z);
  105. z
  106. - log(-------)*z
  107. z + 1
  108. ztrans((-1)^(n)/(n+2),n,z);
  109. z
  110. z*(log(-------)*z + 1)
  111. z + 1
  112. ztrans(a^(n-1)/(n+1),n,z);
  113. - z
  114. log(-------)*z
  115. a - z
  116. ----------------
  117. 2
  118. a
  119. ztrans(a^(n+k)/(n+1),n,z);
  120. k - z
  121. a *log(-------)*z
  122. a - z
  123. -------------------
  124. a
  125. ztrans(a^n/factorial(n),n,z);
  126. a/z
  127. e
  128. ztrans((n+1)*a^n/factorial(n),n,z);
  129. a/z
  130. e *(a + z)
  131. --------------
  132. z
  133. ztrans(1/factorial(n-1),n,z);
  134. 1
  135. ***** ERROR: zero divisor in sum(---------------------,n,0,infinity)
  136. n
  137. z *factorial(n - 1)
  138. % ERROR message o.k.
  139. ztrans((-1)^n/factorial(2*n+1),n,z);
  140. 1
  141. sqrt(z)*sin(---------)
  142. sqrt(z)
  143. ztrans((-1)^n/factorial(2*n),n,z);
  144. 1
  145. cos(---------)
  146. sqrt(z)
  147. ztrans(1/factorial(2*n+1),n,z);
  148. 1
  149. sqrt(z)*sinh(---------)
  150. sqrt(z)
  151. ztrans(1/factorial(2*n-1),n,z);
  152. 1
  153. ztrans(--------------------,n,z)
  154. factorial(2*n - 1)
  155. ztrans(1/factorial(2*n+3),n,z);
  156. 1
  157. z*(sqrt(z)*sinh(---------) - 1)
  158. sqrt(z)
  159. ztrans(1/factorial(2*n),n,z);
  160. 1
  161. cosh(---------)
  162. sqrt(z)
  163. ztrans(1/factorial(2*n+2),n,z);
  164. 1
  165. z*(cosh(---------) - 1)
  166. sqrt(z)
  167. ztrans(a^n/factorial(2*n+1),n,z);
  168. sqrt(a)
  169. sqrt(z)*sinh(---------)
  170. sqrt(z)
  171. -------------------------
  172. sqrt(a)
  173. ztrans(a^n/factorial(2*n),n,z);
  174. sqrt(a)
  175. cosh(---------)
  176. sqrt(z)
  177. ztrans(e^(a*n),n,z);
  178. - z
  179. --------
  180. a
  181. e - z
  182. ztrans(e^(a*(n+k)),n,z);
  183. a*k
  184. - e *z
  185. -----------
  186. a
  187. e - z
  188. ztrans(sinh(a*n),n,z);
  189. - sinh(a)*z
  190. ----------------------
  191. 2
  192. 2*cosh(a)*z - z - 1
  193. ztrans(cosh(a*n),n,z);
  194. z*(cosh(a) - z)
  195. ----------------------
  196. 2
  197. 2*cosh(a)*z - z - 1
  198. ztrans(sinh(a*n+p),n,z);
  199. - z*(sinh(a - p) + sinh(p)*z)
  200. --------------------------------
  201. 2
  202. 2*cosh(a)*z - z - 1
  203. ztrans(cosh(a*n+p),n,z);
  204. z*(cosh(a - p) - cosh(p)*z)
  205. -----------------------------
  206. 2
  207. 2*cosh(a)*z - z - 1
  208. ztrans(a^n*sinh(a*n),n,z);
  209. - sinh(a)*a*z
  210. -------------------------
  211. 2 2
  212. 2*cosh(a)*a*z - a - z
  213. ztrans(a^n*cosh(a*n),n,z);
  214. z*(cosh(a)*a - z)
  215. -------------------------
  216. 2 2
  217. 2*cosh(a)*a*z - a - z
  218. ztrans(n*sinh(a*n),n,z);
  219. 2
  220. sinh(a)*z*(z - 1)
  221. ------------------------------------------------------------
  222. 2 2 3 4 2
  223. 4*cosh(a) *z - 4*cosh(a)*z - 4*cosh(a)*z + z + 2*z + 1
  224. ztrans(n*cosh(a*n),n,z);
  225. 2
  226. z*(cosh(a)*z + cosh(a) - 2*z)
  227. ------------------------------------------------------------
  228. 2 2 3 4 2
  229. 4*cosh(a) *z - 4*cosh(a)*z - 4*cosh(a)*z + z + 2*z + 1
  230. ztrans(n^2*a^n*sinh(b*n),n,z);
  231. 2 4 2 2 2 4 3 3 6
  232. (sinh(b)*a*z*( - 4*cosh(b) *a *z - 4*cosh(b) *a *z + 16*cosh(b)*a *z + a
  233. 4 2 2 4 6 4 4 4 3 5 3
  234. - 5*a *z - 5*a *z + z ))/(16*cosh(b) *a *z - 32*cosh(b) *a *z
  235. 3 3 5 2 6 2 2 4 4
  236. - 32*cosh(b) *a *z + 24*cosh(b) *a *z + 48*cosh(b) *a *z
  237. 2 2 6 7 5 3 3 5
  238. + 24*cosh(b) *a *z - 8*cosh(b)*a *z - 24*cosh(b)*a *z - 24*cosh(b)*a *z
  239. 7 8 6 2 4 4 2 6 8
  240. - 8*cosh(b)*a*z + a + 4*a *z + 6*a *z + 4*a *z + z )
  241. ztrans(sin(b*n),n,z);
  242. - sin(b)*z
  243. ---------------------
  244. 2
  245. 2*cos(b)*z - z - 1
  246. ztrans(cos(b*n),n,z);
  247. z*(cos(b) - z)
  248. ---------------------
  249. 2
  250. 2*cos(b)*z - z - 1
  251. ztrans(sin(b*n+p),n,z);
  252. - z*(sin(b - p) + sin(p)*z)
  253. ------------------------------
  254. 2
  255. 2*cos(b)*z - z - 1
  256. ztrans(cos(b*n+p),n,z);
  257. z*(cos(b - p) - cos(p)*z)
  258. ---------------------------
  259. 2
  260. 2*cos(b)*z - z - 1
  261. ztrans(e^(a*n)*sin(b*n),n,z);
  262. a
  263. - e *sin(b)*z
  264. ---------------------------
  265. a 2*a 2
  266. 2*e *cos(b)*z - e - z
  267. ztrans(e^(a*n)*cos(b*n),n,z);
  268. a
  269. z*(e *cos(b) - z)
  270. ---------------------------
  271. a 2*a 2
  272. 2*e *cos(b)*z - e - z
  273. ztrans((-1)^n*e^(a*n)*sin(b*n),n,z);
  274. a
  275. - e *sin(b)*z
  276. ---------------------------
  277. a 2*a 2
  278. 2*e *cos(b)*z + e + z
  279. ztrans((-1)^n*e^(a*n)*cos(b*n),n,z);
  280. a
  281. z*(e *cos(b) + z)
  282. ---------------------------
  283. a 2*a 2
  284. 2*e *cos(b)*z + e + z
  285. ztrans(n*sin(b*n),n,z);
  286. 2
  287. sin(b)*z*(z - 1)
  288. ---------------------------------------------------------
  289. 2 2 3 4 2
  290. 4*cos(b) *z - 4*cos(b)*z - 4*cos(b)*z + z + 2*z + 1
  291. ztrans(n*cos(b*n),n,z);
  292. 2
  293. z*(cos(b)*z + cos(b) - 2*z)
  294. ---------------------------------------------------------
  295. 2 2 3 4 2
  296. 4*cos(b) *z - 4*cos(b)*z - 4*cos(b)*z + z + 2*z + 1
  297. ztrans(n^2*a^n*sin(b*n),n,z);
  298. 2 4 2 2 2 4 3 3 6
  299. (sin(b)*a*z*( - 4*cos(b) *a *z - 4*cos(b) *a *z + 16*cos(b)*a *z + a
  300. 4 2 2 4 6 4 4 4 3 5 3
  301. - 5*a *z - 5*a *z + z ))/(16*cos(b) *a *z - 32*cos(b) *a *z
  302. 3 3 5 2 6 2 2 4 4 2 2 6
  303. - 32*cos(b) *a *z + 24*cos(b) *a *z + 48*cos(b) *a *z + 24*cos(b) *a *z
  304. 7 5 3 3 5 7 8
  305. - 8*cos(b)*a *z - 24*cos(b)*a *z - 24*cos(b)*a *z - 8*cos(b)*a*z + a
  306. 6 2 4 4 2 6 8
  307. + 4*a *z + 6*a *z + 4*a *z + z )
  308. ztrans(cos(b*(n+1))/(n+1),n,z);
  309. z
  310. log(------------------------------)*z
  311. 2
  312. sqrt( - 2*cos(b)*z + z + 1)
  313. ztrans(sin(b*(n+1))/(n+1),n,z);
  314. sin(b)
  315. - atan(------------)*z
  316. cos(b) - z
  317. ztrans(cos(b*(n+2))/(n+2),n,z);
  318. z
  319. z*( - cos(b) + log(------------------------------)*z)
  320. 2
  321. sqrt( - 2*cos(b)*z + z + 1)
  322. ztrans((-1)^(n)*cos(b*(n+1))/(n+1),n,z);
  323. 2 3
  324. sqrt(2*cos(b)*z + z + 1)
  325. - log(----------------------------)*z
  326. sqrt(z)
  327. ztrans((-1)^(n)*sin(b*(n+1))/(n+1),n,z);
  328. sin(b)
  329. atan(------------)*z
  330. cos(b) + z
  331. ztrans(cos(b*n)/factorial(n),n,z);
  332. cos(b)/z sin(b)
  333. e *cos(--------)
  334. z
  335. ztrans(sin(b*n)/factorial(n),n,z);
  336. cos(b)/z sin(b)
  337. e *sin(--------)
  338. z
  339. ztrans(a*f(n)+b*g(n)+c*h(n),n,z);
  340. ztrans(f(n),n,z)*a + ztrans(g(n),n,z)*b + ztrans(h(n),n,z)*c
  341. ztrans(sum(f(k)*g(n-k),k,0,n),n,z);
  342. ztrans(f(n),n,z)*ztrans(g(n),n,z)
  343. ztrans(sum(f(k),k,0,n),n,z);
  344. ztrans(f(n),n,z)*z
  345. --------------------
  346. z - 1
  347. ztrans(sum(f(k),k,-2,n),n,z);
  348. 2
  349. (z*( - f(-1)*z + f(-1) - f(-2)*z + f(-2) + ztrans(f(n - 2),n,z)
  350. 2
  351. + ztrans(f(n - 2),n,z)*z - ztrans(f(n - 2),n,z)))/(z - 1)
  352. ztrans(sum(f(k),k,3,n),n,z);
  353. 2 2
  354. - f(2) - f(1)*z - f(0)*z + ztrans(f(n),n,z)*z
  355. --------------------------------------------------
  356. z*(z - 1)
  357. ztrans(sum(f(k),k,0,n+2),n,z);
  358. 2 2
  359. (z*( - f(1)*z + f(1) - f(0)*z + f(0) + ztrans(f(n),n,z) + ztrans(f(n),n,z)*z
  360. - ztrans(f(n),n,z)))/(z - 1)
  361. ztrans(sum(f(k),k,0,n-3),n,z);
  362. 2 2
  363. ztrans(f(n),n,z)*z - ztrans(f(n),n,z)*z + ztrans(f(n),n,z)
  364. --------------------------------------------------------------
  365. 2
  366. z *(z - 1)
  367. ztrans(sum(f(k),k,-2,n+3),n,z);
  368. 2 3 4
  369. (z*( - f(2)*z + f(2) - f(1)*z + f(1) - f(0)*z + f(0) - f(-1)*z + f(-1)
  370. 5 5
  371. - f(-2)*z + f(-2) + ztrans(f(n - 2),n,z) + ztrans(f(n - 2),n,z)*z
  372. - ztrans(f(n - 2),n,z)))/(z - 1)
  373. ztrans(sum(1/factorial(k),k,0,n),n,z);
  374. 1/z
  375. e *z
  376. --------
  377. z - 1
  378. ztrans(sum(1/factorial(k+2),k,0,n),n,z);
  379. 2 1/z
  380. z *(e *z - z - 1)
  381. ---------------------
  382. z - 1
  383. ztrans(n^2*sum(1/factorial(k),k,0,n),n,z);
  384. 1/z 3 2
  385. e *(2*z + 2*z - 3*z + 1)
  386. ------------------------------
  387. 3 2
  388. z*(z - 3*z + 3*z - 1)
  389. ztrans(sum(n^2/factorial(k),k,0,n),n,z);
  390. 1/z 3 2
  391. e *(2*z + 2*z - 3*z + 1)
  392. ------------------------------
  393. 3 2
  394. z*(z - 3*z + 3*z - 1)
  395. ztrans(sum(1/k,k,0,n),n,z);
  396. 1
  397. ***** ERROR: zero divisor in sum(------,n,0,infinity)
  398. n
  399. z *n
  400. % ERROR o.k.
  401. ztrans(sum(1/(k+1),k,0,n),n,z);
  402. z 2
  403. log(-------)*z
  404. z - 1
  405. -----------------
  406. z - 1
  407. ztrans(sum(1/(k+3),k,0,n),n,z);
  408. 2 z 2
  409. z *(2*log(-------)*z - 2*z - 1)
  410. z - 1
  411. ----------------------------------
  412. 2*(z - 1)
  413. ztrans(f(n+k),n,z);
  414. ztrans(f(k + n),n,z)
  415. % output=input
  416. ztrans(f(n+2),n,z);
  417. z*( - f(1) - f(0)*z + ztrans(f(n),n,z)*z)
  418. ztrans(f(n-k),n,z);
  419. ztrans(f( - k + n),n,z)
  420. % output=input
  421. ztrans(f(n-3),n,z);
  422. ztrans(f(n - 3),n,z)
  423. % output=input
  424. ztrans(a^n*f(n),n,z);
  425. z
  426. ztrans(f(n),n,---)
  427. a
  428. ztrans(n*f(n),n,z);
  429. - df(ztrans(f(n),n,z),z)*z
  430. ztrans(1/a^n,n,z);
  431. a*z
  432. ---------
  433. a*z - 1
  434. ztrans(1/a^(n+1),n,z);
  435. z
  436. ---------
  437. a*z - 1
  438. ztrans(1/a^(n-1),n,z);
  439. 2
  440. a *z
  441. ---------
  442. a*z - 1
  443. ztrans(2*n+n^2-3/4*n^3,n,x);
  444. 2
  445. x*(9*x - 28*x + 1)
  446. --------------------------------
  447. 4 3 2
  448. 4*(x - 4*x + 6*x - 4*x + 1)
  449. ztrans(n^2*cos(n*x),n,z);
  450. 3 4 3 2 6 4 2
  451. (z*( - 4*cos(x) *z + 4*cos(x) *z + cos(x)*z + 9*cos(x)*z - 9*cos(x)*z
  452. 5 4 4 3 5 3 3
  453. - cos(x) - 4*z + 4*z))/(16*cos(x) *z - 32*cos(x) *z - 32*cos(x) *z
  454. 2 6 2 4 2 2 7 5
  455. + 24*cos(x) *z + 48*cos(x) *z + 24*cos(x) *z - 8*cos(x)*z - 24*cos(x)*z
  456. 3 8 6 4 2
  457. - 24*cos(x)*z - 8*cos(x)*z + z + 4*z + 6*z + 4*z + 1)
  458. ztrans((1+n)^2*f(n),n,z);
  459. 2
  460. df(ztrans(f(n),n,z),z,2)*z - df(ztrans(f(n),n,z),z)*z + ztrans(f(n),n,z)
  461. ztrans(n^2*f(n),n,z);
  462. z*(df(ztrans(f(n),n,z),z,2)*z + df(ztrans(f(n),n,z),z))
  463. ztrans(n/factorial(n),n,z);
  464. 1/z
  465. e
  466. ------
  467. z
  468. ztrans(n^2/factorial(n),n,z);
  469. 1/z
  470. e *(z + 1)
  471. --------------
  472. 2
  473. z
  474. ztrans(a^n/factorial(n),n,z);
  475. a/z
  476. e
  477. ztrans(1/(a^n*factorial(n)),n,z);
  478. 1/(a*z)
  479. e
  480. ztrans(sum(f(k)*g(n-k),k,0,n),n,z);
  481. ztrans(f(n),n,z)*ztrans(g(n),n,z)
  482. ztrans(sum(f(k),k,0,n-1),n,z);
  483. ztrans(f(n),n,z)
  484. ------------------
  485. z - 1
  486. ztrans(sum(f(k),k,0,n),n,z);
  487. ztrans(f(n),n,z)*z
  488. --------------------
  489. z - 1
  490. ztrans(sum(1/factorial(k),k,0,n),n,z);
  491. 1/z
  492. e *z
  493. --------
  494. z - 1
  495. ztrans(sum(k/factorial(k),k,0,n),n,z);
  496. 1/z
  497. e
  498. -------
  499. z - 1
  500. ztrans(sum(a^k*k^2/factorial(k),k,0,n),n,z);
  501. a/z
  502. e *a*(a + z)
  503. ----------------
  504. z*(z - 1)
  505. ztrans(a^n*f(n),n,z);
  506. z
  507. ztrans(f(n),n,---)
  508. a
  509. ztrans(binomial(n,k),n,z);
  510. z
  511. ------------------
  512. k
  513. (z - 1) *(z - 1)
  514. ztrans(1/(n+1),n,z);
  515. z
  516. log(-------)*z
  517. z - 1
  518. ztrans(n/factorial(2*n+1),n,z);
  519. 1 1
  520. sqrt(z)*cosh(---------) - sinh(---------)*z
  521. sqrt(z) sqrt(z)
  522. ---------------------------------------------
  523. 2*sqrt(z)
  524. ztrans(a^n*sin(n*x+y),n,z);
  525. - z*(sin(x - y)*a + sin(y)*z)
  526. --------------------------------
  527. 2 2
  528. 2*cos(x)*a*z - a - z
  529. ztrans(n^3*sin(n*x+y),n,z);
  530. 3 4 2 4 2 2
  531. (z*(8*cos(x) *sin(y)*z + 4*cos(x) *sin(x - y)*z - 4*cos(x) *sin(x - y)*z
  532. 2 5 2 3 5
  533. + 16*cos(x) *sin(y)*z - 16*cos(x) *sin(y)*z + 8*cos(x)*sin(x - y)*z
  534. 6 4
  535. - 8*cos(x)*sin(x - y)*z + 2*cos(x)*sin(y)*z - 36*cos(x)*sin(y)*z
  536. 2 6 4 2
  537. + 10*cos(x)*sin(y)*z + sin(x - y)*z - 23*sin(x - y)*z + 23*sin(x - y)*z
  538. 5 3 4 4
  539. - sin(x - y) - 8*sin(y)*z + 32*sin(y)*z - 8*sin(y)*z))/(16*cos(x) *z
  540. 3 5 3 3 2 6 2 4
  541. - 32*cos(x) *z - 32*cos(x) *z + 24*cos(x) *z + 48*cos(x) *z
  542. 2 2 7 5 3
  543. + 24*cos(x) *z - 8*cos(x)*z - 24*cos(x)*z - 24*cos(x)*z - 8*cos(x)*z
  544. 8 6 4 2
  545. + z + 4*z + 6*z + 4*z + 1)
  546. ztrans((n+1)/factorial(n),n,z);
  547. 1/z
  548. e *(z + 1)
  549. --------------
  550. z
  551. ztrans(factorial(n)/(factorial(k)*factorial(n-k)),n,z);
  552. z
  553. ------------------
  554. k
  555. (z - 1) *(z - 1)
  556. % Examples for inverse Z transformation
  557. invztrans(z/(z-1),z,n);
  558. 2*n
  559. ( - 1)
  560. invztrans(z/(z+1),z,n);
  561. n
  562. ( - 1)
  563. invztrans(z/(z-1)^2,z,n);
  564. n
  565. invztrans(z*(z+1)/(z-1)^3,z,n);
  566. 2
  567. n
  568. invztrans(z/(z-1)^m,z,n);
  569. 2*n
  570. ( - 1) *binomial(n,m - 1)
  571. -----------------------------
  572. 2*m
  573. ( - 1)
  574. % invztrans(z/(z-1)^(m+1),z,n);
  575. % not yet supported
  576. invztrans(z/(z-1)^4,z,n);
  577. 2
  578. n*(n - 3*n + 2)
  579. ------------------
  580. 6
  581. invztrans((-1)^m*z/(z+1)^m,z,n);
  582. m
  583. ( - 1) *z
  584. invztrans(-----------,z,n)
  585. m
  586. (z + 1)
  587. % not yet supported
  588. invztrans(z/(z+1)^4,z,n);
  589. n 2
  590. ( - 1) *n*( - n + 3*n - 2)
  591. -----------------------------
  592. 6
  593. % invztrans(z^(k+1)/(z-1)^(m+1),z,n);
  594. % not yet supported
  595. invztrans(z^4/(z-1)^m,z,n);
  596. 2*n
  597. ( - 1) *binomial(n + 3,m - 1)
  598. ---------------------------------
  599. 2*m
  600. ( - 1)
  601. % invztrans(z^4/(z-1)^(m+1),z,n);
  602. % not yet supported
  603. % invztrans(z^4/(z-1)^m,z,n);
  604. % not yet supported
  605. % invztrans(z^(k+1)/(z-1)^5,z,n);
  606. % not yet supported
  607. invztrans(z^3/(z-a)^4,z,n);
  608. n 2
  609. a *n*(n + 3*n + 2)
  610. ---------------------
  611. 6*a
  612. invztrans(z/(z-a),z,n);
  613. n
  614. a
  615. invztrans(z/(z+a),z,n);
  616. n n
  617. a *( - 1)
  618. invztrans(z*(1-a)/((z-1)*(z-a)),z,n);
  619. n
  620. - a + 1
  621. invztrans(z*a/(z-a)^2,z,n);
  622. n
  623. a *n
  624. invztrans(z*3/(z-3)^2,z,n);
  625. n
  626. 3 *n
  627. % invztrans(a^m*z/(z-a)^(m+1),z,n);
  628. % not yet supported
  629. % invztrans(a^m*z/(z-a)^m,z,n);
  630. % not yet supported
  631. % invztrans(4^m*z/(z-4)^(m+1),z,n);
  632. % not yet supported
  633. invztrans(a^3*z/(z-a)^5,z,n);
  634. n 3 2
  635. a *n*(n - 6*n + 11*n - 6)
  636. -----------------------------
  637. 24*a
  638. invztrans(z*log(z/(z-1)),z,n);
  639. 2*n
  640. ( - 1)
  641. -----------
  642. n + 1
  643. invztrans(z*log(1+1/z),z,n);
  644. n
  645. ( - 1)
  646. ---------
  647. n + 1
  648. invztrans(z*log(z/(z-a)),z,n);
  649. n 2*n
  650. a *( - 1) *a
  651. ----------------
  652. n + 1
  653. invztrans(e^(a/z),z,n);
  654. n
  655. a
  656. --------------
  657. factorial(n)
  658. invztrans(e^(1/(a*z)),z,n);
  659. 1
  660. -----------------
  661. n
  662. a *factorial(n)
  663. invztrans((1+a/z)*e^(a/z),z,n);
  664. n
  665. a *(n + 1)
  666. --------------
  667. factorial(n)
  668. invztrans(e^(a/z)*(a+z)/z,z,n);
  669. n
  670. a *(n + 1)
  671. --------------
  672. factorial(n)
  673. invztrans(sqrt(z)*sin(1/sqrt(z)),z,n);
  674. n
  675. ( - 1)
  676. --------------------
  677. factorial(2*n + 1)
  678. invztrans(cos(1/sqrt(z)),z,n);
  679. n
  680. ( - 1)
  681. ----------------
  682. factorial(2*n)
  683. invztrans(sqrt(z)*sinh(1/sqrt(z)),z,n);
  684. 1
  685. --------------------
  686. factorial(2*n + 1)
  687. invztrans(cosh(1/sqrt(z)),z,n);
  688. 1
  689. ----------------
  690. factorial(2*n)
  691. invztrans(sqrt(z/a)*sinh(sqrt(a/z)),z,n);
  692. n
  693. a
  694. --------------------
  695. factorial(2*n + 1)
  696. invztrans(cosh(sqrt(a/z)),z,n);
  697. n
  698. a
  699. ----------------
  700. factorial(2*n)
  701. invztrans(z/(z-e^a),z,n);
  702. a*n
  703. e
  704. invztrans(z*sinh(a)/(z^2-2*z*cosh(a)+1),z,n);
  705. sinh(a*n)
  706. invztrans(z*(z-cosh(a))/(z^2-2*z*cosh(a)+1),z,n);
  707. cosh(a*n)
  708. invztrans(z*(z*sinh(p)+sinh(a-p))/(z^2-2*z*cosh(a)+1),z,n);
  709. cosh(a*n)*sinh(a)*sinh(p) + cosh(a)*sinh(a*n)*sinh(p) + sinh(a - p)*sinh(a*n)
  710. -------------------------------------------------------------------------------
  711. sinh(a)
  712. % trigsimp(ws);
  713. % trigsimp(ws,combine);
  714. invztrans(z*(z*cosh(p)-cosh(a-p))/(z^2-2*z*cosh(a)+1),z,n);
  715. ( - cosh(a - p)*sinh(a*n) + cosh(a*n)*cosh(p)*sinh(a)
  716. + cosh(a)*cosh(p)*sinh(a*n))/sinh(a)
  717. % trigsimp(ws);
  718. % trigsimp(ws,combine);
  719. invztrans(a*z*sinh(a)/(z^2-2*a*z*cosh(a)+a^2),z,n);
  720. n
  721. a *sinh(a*n)
  722. invztrans(z*(z-a*cosh(a))/(z^2-2*a*z*cosh(a)+a^2),z,n);
  723. n
  724. a *cosh(a*n)
  725. invztrans(z*(z^2-1)*sinh(a)/(z^2-2*z*cosh(a)+1)^2,z,n);
  726. 2
  727. sinh(a*n)*sinh(a) *n
  728. ----------------------
  729. 2
  730. cosh(a) - 1
  731. % trigsimp(ws);
  732. invztrans(z*((z^2+1)*cosh(a)-2*z)/(z^2-2*z*cosh(a)+1)^2,z,n);
  733. cosh(a*n)*n
  734. invztrans(z*sin(b)/(z^2-2*z*cos(b)+1),z,n);
  735. sin(b*n)
  736. invztrans(z*(z-cos(b))/(z^2-2*z*cos(b)+1),z,n);
  737. cos(b*n)
  738. invztrans(z*(z*sin(p)+sin(b-p))/(z^2-2*z*cos(b)+1),z,n);
  739. cos(b*n)*sin(b)*sin(p) + cos(b)*sin(b*n)*sin(p) + sin(b - p)*sin(b*n)
  740. -----------------------------------------------------------------------
  741. sin(b)
  742. % trigsimp(ws);
  743. % trigsimp(ws,combine);
  744. invztrans(z*(z*cos(p)-cos(b-p))/(z^2-2*z*cos(b)+1),z,n);
  745. - cos(b - p)*sin(b*n) + cos(b*n)*cos(p)*sin(b) + cos(b)*cos(p)*sin(b*n)
  746. --------------------------------------------------------------------------
  747. sin(b)
  748. % trigsimp(ws);
  749. % trigsimp(ws,combine);
  750. invztrans(z*e^(a)*sin(b)/(z^2-2*z*e^a*cos(b)+e^(2*a)),z,n);
  751. a*n
  752. e *sin(b*n)
  753. invztrans(z*(z-e^a*cos(b))/(z^2-2*z*e^a*cos(b)+e^(2*a)),z,n);
  754. a*n
  755. e *cos(b*n)
  756. invztrans(-z*e^a*sin(b)/(z^2+2*z*e^a*cos(b)+e^(2*a)),z,n);
  757. a*n n
  758. e *( - 1) *sin(b*n)
  759. invztrans(z*(z+e^a*cos(b))/(z^2+2*z*e^a*cos(b)+e^(2*a)),z,n);
  760. a*n n
  761. e *( - 1) *cos(b*n)
  762. invztrans(z*(z^2-1)*sin(b)/(z^2-2*z*cos(b)+1)^2,z,n);
  763. 2
  764. (sqrt(cos(b) - 1)*sin(b)*n
  765. 2 n 2 n
  766. *( - (cos(b) - sqrt(cos(b) - 1)) + (cos(b) + sqrt(cos(b) - 1)) ))/(2
  767. 2
  768. *(cos(b) - 1))
  769. % trigsimp(ws,expon);
  770. % trigsimp(ws,trig);
  771. invztrans(z*((z^2+1)*cos(b)-2*z)/(z^2-2*z*cos(b)+1)^2,z,n);
  772. 2 n 2 n
  773. n*((cos(b) - sqrt(cos(b) - 1)) + (cos(b) + sqrt(cos(b) - 1)) )
  774. -------------------------------------------------------------------
  775. 2
  776. % trigsimp(ws,expon);
  777. % trigsimp(ws,trig);
  778. invztrans(z*log(z/sqrt(z^2-2*z*cos(b)+1)),z,n);
  779. cos(b*n + b)
  780. --------------
  781. n + 1
  782. invztrans(z*atan(sin(b)/(z-cos(b))),z,n);
  783. sin(b*n + b)
  784. --------------
  785. n + 1
  786. invztrans(z*log(sqrt(z^2+2*z*cos(b)+1)/z),z,n);
  787. n
  788. ( - 1) *cos(b*n + b)
  789. ----------------------
  790. n + 1
  791. invztrans(z*atan(sin(b)/(z+cos(b))),z,n);
  792. n
  793. ( - 1) *sin(b*n + b)
  794. ----------------------
  795. n + 1
  796. invztrans(cos(sin(b)/z)*e^(cos(b)/z),z,n);
  797. cos(b*n)
  798. --------------
  799. factorial(n)
  800. invztrans(sin(sin(b)/z)*e^(cos(b)/z),z,n);
  801. sin(b*n)
  802. --------------
  803. factorial(n)
  804. invztrans((f+a*z+b*z^2)/(c+d*z+e*z^2),z,n);
  805. 2 n 2 n
  806. (2*(sqrt( - 4*c*e + d ) + d) *sqrt( - 4*c*e + d )*( - 1) *a*c*e
  807. 2 n 2 n
  808. - (sqrt( - 4*c*e + d ) + d) *sqrt( - 4*c*e + d )*( - 1) *b*c*d
  809. 2 n 2 n
  810. - (sqrt( - 4*c*e + d ) + d) *sqrt( - 4*c*e + d )*( - 1) *d*e*f
  811. 2 n n 2
  812. + 4*(sqrt( - 4*c*e + d ) + d) *( - 1) *b*c *e
  813. 2 n n 2
  814. - (sqrt( - 4*c*e + d ) + d) *( - 1) *b*c*d
  815. 2 n n 2
  816. - 4*(sqrt( - 4*c*e + d ) + d) *( - 1) *c*e *f
  817. 2 n n 2
  818. + (sqrt( - 4*c*e + d ) + d) *( - 1) *d *e*f
  819. 2 n 2
  820. - 2*(sqrt( - 4*c*e + d ) - d) *sqrt( - 4*c*e + d )*a*c*e
  821. 2 n 2
  822. + (sqrt( - 4*c*e + d ) - d) *sqrt( - 4*c*e + d )*b*c*d
  823. 2 n 2
  824. + (sqrt( - 4*c*e + d ) - d) *sqrt( - 4*c*e + d )*d*e*f
  825. 2 n 2 2 n 2
  826. + 4*(sqrt( - 4*c*e + d ) - d) *b*c *e - (sqrt( - 4*c*e + d ) - d) *b*c*d
  827. 2 n 2 2 n 2
  828. - 4*(sqrt( - 4*c*e + d ) - d) *c*e *f + (sqrt( - 4*c*e + d ) - d) *d *e*f)/(2
  829. n n 2
  830. *e *2 *c*e*(4*c*e - d ))
  831. % Example 1 in Bronstein/Semendjajew, p. 651
  832. f(0):=0;
  833. f(0) := 0
  834. f(1):=0;
  835. f(1) := 0
  836. f(2):=9;
  837. f(2) := 9
  838. f(3):=-2;
  839. f(3) := -2
  840. f(4):=23;
  841. f(4) := 23
  842. equation:=ztrans(f(n+5)-2*f(n+3)+2*f(n+2)-3*f(n+1)+2*f(n),n,z);
  843. 5 3 2
  844. equation := ztrans(f(n),n,z)*z - 2*ztrans(f(n),n,z)*z + 2*ztrans(f(n),n,z)*z
  845. 3 2
  846. - 3*ztrans(f(n),n,z)*z + 2*ztrans(f(n),n,z) - 9*z + 2*z - 5*z
  847. ztransresult:=solve(equation,ztrans(f(n),n,z));
  848. 2
  849. z*(9*z - 2*z + 5)
  850. ztransresult := {ztrans(f(n),n,z)=----------------------------}
  851. 5 3 2
  852. z - 2*z + 2*z - 3*z + 2
  853. result:=invztrans(part(first(ztransresult),2),z,n);
  854. n n n n n
  855. - i *( - 1) + 2*( - 1) *2 - i + 4*n
  856. result := -----------------------------------------
  857. 2
  858. % Example 2 in Bronstein/Semendjajew, p. 651
  859. clear(f);
  860. operator f;
  861. f(0):=0;
  862. f(0) := 0
  863. f(1):=1;
  864. f(1) := 1
  865. equation:=ztrans(f(n+2)-4*f(n+1)+3*f(n)-1,n,z);
  866. 3 2
  867. equation := (ztrans(f(n),n,z)*z - 5*ztrans(f(n),n,z)*z + 7*ztrans(f(n),n,z)*z
  868. 2
  869. - 3*ztrans(f(n),n,z) - z )/(z - 1)
  870. ztransresult:=solve(equation,ztrans(f(n),n,z));
  871. 2
  872. z
  873. ztransresult := {ztrans(f(n),n,z)=---------------------}
  874. 3 2
  875. z - 5*z + 7*z - 3
  876. result:=invztrans(part(first(ztransresult),2),z,n);
  877. n
  878. 3*3 - 2*n - 3
  879. result := ----------------
  880. 4
  881. % Other example:
  882. clear(f);
  883. operator f;
  884. f(0):=1;
  885. f(0) := 1
  886. f(1):=1;
  887. f(1) := 1
  888. operator tmp;
  889. equation:=ztrans((n+1)*f(n+1)-f(n),n,z);
  890. 2
  891. equation := - (df(ztrans(f(n),n,z),z)*z + ztrans(f(n),n,z))
  892. equation:=sub(ztrans(f(n),n,z)=tmp(z),equation);
  893. 2
  894. equation := - (df(tmp(z),z)*z + tmp(z))
  895. load_package odesolve;
  896. oderesult:=odesolve(equation,tmp(z),z);
  897. *** ci already defined as operator
  898. *** si already defined as operator
  899. 1/z
  900. oderesult := {tmp(z)=e *arbconst(1)}
  901. preresult:=invztrans(part(first(oderesult),2),z,n);
  902. arbconst(1)
  903. preresult := --------------
  904. factorial(n)
  905. solveresult:=
  906. solve({sub(n=0,preresult)=f(0),sub(n=1,preresult)=f(1)},arbconst(1));
  907. solveresult := {arbconst(1)=1}
  908. result:=preresult where solveresult;
  909. 1
  910. --------------
  911. factorial(n)
  912. end;
  913. Time for test: 69056 ms, plus GC time: 1482 ms