ztrans.rlg 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551
  1. Tue Apr 15 00:36:13 2008 run on win32
  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. (z - a) *(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. *** airy_ai already defined as operator
  897. *** airy_bi already defined as operator
  898. *** ci already defined as operator
  899. *** si already defined as operator
  900. oderesult:=odesolve(equation,tmp(z),z);
  901. 1/z
  902. oderesult := {tmp(z)=e *arbconst(1)}
  903. preresult:=invztrans(part(first(oderesult),2),z,n);
  904. arbconst(1)
  905. preresult := --------------
  906. factorial(n)
  907. solveresult:=
  908. solve({sub(n=0,preresult)=f(0),sub(n=1,preresult)=f(1)},arbconst(1));
  909. solveresult := {arbconst(1)=1}
  910. result:=preresult where solveresult;
  911. 1
  912. --------------
  913. factorial(n)
  914. end;
  915. Time for test: 2380 ms, plus GC time: 179 ms