laplace.tst 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. % Title: Examples of Laplace Transforms.
  2. % Author: L. Kazasov.
  3. % Date: 24 October 1988.
  4. order p;
  5. % Elementary functions with argument k*x, where x is object var.
  6. laplace(1,x,p);
  7. laplace(c,x,p);
  8. laplace(sin(k*x),x,p); laplace(sin(x/a),x,p);
  9. laplace(sin(17*x),x,p);
  10. laplace(sinh x,x,p);
  11. laplace(cosh(k*x),x,p);
  12. laplace(x,x,p); laplace(x**3,x,p);
  13. off mcd; laplace(e**(c*x) + a**x, x, s);
  14. laplace(e**x - e**(a*x) + x**2, x, p);
  15. laplace(one(k*t) + sin(a*t) - cos(b*t) - e**t, t, p);
  16. laplace(sqrt(x),x,p); laplace(x**(1/2),x,p); on mcd;
  17. laplace(x**(-1/2),x,p); laplace(x**(5/2),x,p);
  18. laplace(-1/4*x**2*c*sqrt(x), x, p);
  19. % Elementary functions with argument k*x - tau,
  20. % where k>0, tau>=0, x is object var.
  21. laplace(cos(x-a),x,p);
  22. laplace(one(k*x-tau),x,p);
  23. laplace(sinh(k*x-tau),x,p); laplace(sinh(k*x),x,p);
  24. laplace((a*x-b)**c,x,p);
  25. % But ...
  26. off mcd; laplace((a*x-b)**2,x,p); on mcd;
  27. laplace(sin(2*x-3),x,p);
  28. on lmon; laplace(sin(2*x-3),x,p); off lmon;
  29. off mcd; laplace(cosh(t-a) - sin(3*t-5), t, p); on mcd;
  30. % More complicated examples - multiplication of functions.
  31. % We use here on lmon - a new switch that forces all
  32. % trigonometrical functions which depend on object var
  33. % to be represented as exponents.
  34. laplace(x*e**(a*x)*cos(k*x), x, p);
  35. laplace(x**(1/2)*e**(a*x), x, p);
  36. laplace(-1/4*e**(a*x)*(x-k)**(-1/2), x, p);
  37. laplace(x**(5/2)*e**(a*x), x, p);
  38. laplace((a*x-b)**c*e**(k*x)*const/2, x, p);
  39. off mcd; laplace(x*e**(a*x)*sin(7*x)/c*3, x, p); on mcd;
  40. laplace(x*e**(a*x)*sin(k*x-tau), x, p);
  41. % The next is unknown if lmon is off.
  42. laplace(sin(k*x)*cosh(k*x), x, p);
  43. laplace(x**(1/2)*sin(k*x), x, p);
  44. on lmon; % But now is OK.
  45. laplace(x**(1/2)*sin(a*x)*cos(a*b), x, p);
  46. laplace(sin(x)*cosh(x), x, p);
  47. laplace(sin(k*x)*cosh(k*x), x, p);
  48. % Off exp leads to very messy output in this case.
  49. % off exp; laplace(sin(k*x-t)*cosh(k*x-t), x, p); on exp;
  50. laplace(sin(k*x-t)*cosh(k*x-t), x, p);
  51. laplace(cos(x)**2,x,p);laplace(c*cos(k*x)**2,x,p);
  52. laplace(c*cos(2/3*x)**2, x, p);
  53. laplace(5*sinh(x)*e**(a*x)*x**3, x, p);
  54. off exp; laplace(sin(2*x-3)*cosh(7*x-5), x, p); on exp;
  55. laplace(sin(a*x-b)*cosh(c*x-d), x, p);
  56. % To solve this problem we must tell the program which one-function
  57. % is rightmost shifted. However, in REDUCE 3.4, this rule is still
  58. % not sufficient.
  59. for all x let one(x-b/a)*one(x-d/c) = one(x-b/a);
  60. laplace(sin(a*x-b)*cosh(c*x-d), x, p);
  61. for all x clear one(x-b/a)*one(x-d/c) ;
  62. off lmon;
  63. % Floating point arithmetic.
  64. % laplace(3.5/c*sin(2.3*x-4.11)*e**(1.5*x), x, p);
  65. on rounded;
  66. laplace(3.5/c*sin(2.3*x-4.11)*e**(1.5*x), x, p);
  67. laplace(x**2.156,x,p);
  68. laplace(x**(-0.5),x,p);
  69. off rounded; laplace(x**(-0.5),x,p); on rounded;
  70. laplace(x*e**(2.35*x)*cos(7.42*x), x, p);
  71. laplace(x*e**(2.35*x)*cos(7.42*x-74.2), x, p);
  72. % Higher precision works, but uses more memory.
  73. % precision 20; laplace(x**2.156,x,p);
  74. % laplace(x*e**(2.35*x)*cos(7.42*x-74.2), x, p);
  75. off rounded;
  76. % Integral from 0 to x, where x is object var.
  77. % Syntax is intl(<expr>,<var>,0,<obj.var>).
  78. laplace(c1/c2*intl(2*y**2,y,0,x), x,p);
  79. off mcd; laplace(intl(e**(2*y)*y**2+sqrt(y),y,0,x),x,p); on mcd;
  80. laplace(-2/3*intl(1/2*y*e**(a*y)*sin(k*y),y,0,x), x, p);
  81. % Use of delta function and derivatives.
  82. laplace(-1/2*delta(x), x, p); laplace(delta(x-tau), x, p);
  83. laplace(c*cos(k*x)*delta(x),x,p);
  84. laplace(e**(a*x)*delta(x), x, p);
  85. laplace(c*x**2*delta(x), x, p);
  86. laplace(-1/4*x**2*delta(x-pi), x, p);
  87. laplace(cos(2*x-3)*delta(x-pi),x,p);
  88. laplace(e**(-b*x)*delta(x-tau), x, p);
  89. on lmon;
  90. laplace(cos(2*x)*delta(x),x,p);
  91. laplace(c*x**2*delta(x), x, p);
  92. laplace(c*x**2*delta(x-pi), x, p);
  93. laplace(cos(a*x-b)*delta(x-pi),x,p);
  94. laplace(e**(-b*x)*delta(x-tau), x, p);
  95. off lmon;
  96. laplace(2/3*df(delta x,x),x,p);
  97. off exp; laplace(e**(a*x)*df(delta x,x,5), x, p); on exp;
  98. laplace(df(delta(x-a),x), x, p);
  99. laplace(e**(k*x)*df(delta(x),x), x, p);
  100. laplace(e**(k*x)*c*df(delta(x-tau),x,2), x, p);
  101. on lmon;laplace(e**(k*x)*sin(a*x)*df(delta(x-t),x,2),x,p);off lmon;
  102. % But if tau is positive, Laplace transform is not defined.
  103. laplace(e**(a*x)*delta(x+tau), x, p);
  104. laplace(2*c*df(delta(x+tau),x), x, p);
  105. laplace(e**(k*x)*df(delta(x+tau),x,3), x, p);
  106. % Adding new let rules for Laplace operator. Note the syntax.
  107. for all x let laplace(log(x),x) = -log(gam*il!&)/il!&;
  108. laplace(-log(x)*a/4, x, p); laplace(-log(x),x,p);
  109. laplace(a*log(x)*e**(k*x), x, p);
  110. for all x clear laplace(log(x),x);
  111. operator f; for all x let
  112. laplace(df(f(x),x),x) = il!&*laplace(f(x),x) - sub(x=0,f(x));
  113. for all x,n such that numberp n and fixp n let
  114. laplace(df(f(x),x,n),x) = il!&**n*laplace(f(x),x) -
  115. for i:=n-1 step -1 until 0 sum
  116. sub(x=0, df(f(x),x,n-1-i)) * il!&**i ;
  117. for all x let laplace(f(x),x) = f(il!&);
  118. laplace(1/2*a*df(-2/3*f(x)*c,x), x,p);
  119. laplace(1/2*a*df(-2/3*f(x)*c,x,4), x,p);
  120. laplace(1/2*a*e**(k*x)*df(-2/3*f(x)*c,x,2), x,p);
  121. clear f;
  122. % Or if the boundary conditions are known and assume that
  123. % f(i,0)=sub(x=0,df(f(x),x,i)) the above may be overwritten as:
  124. operator f; for all x let
  125. laplace(df(f(x),x),x) = il!&*laplace(f(x),x) - f(0,0);
  126. for all x,n such that numberp n and fixp n let
  127. laplace(df(f(x),x,n),x) = il!&**n*laplace(f(x),x) -
  128. for i:=n-1 step -1 until 0 sum il!&**i * f(n-1-i,0);
  129. for all x let laplace(f(x),x) = f(il!&);
  130. let f(0,0)=0, f(1,0)=1, f(2,0)=2, f(3,0)=3;
  131. laplace(1/2*a*df(-2/3*f(x)*c,x), x,p);
  132. laplace(1/2*a*df(-2/3*f(x)*c,x,4), x,p);
  133. clear f(0,0), f(1,0), f(2,0), f(3,0); clear f;
  134. % Very complicated examples.
  135. on lmon;
  136. laplace(sin(a*x-b)**2, x, p);
  137. off mcd; laplace(x**3*(sin x)**4*e**(5*k*x)*c/2, x,p);
  138. a:=(sin x)**4*e**(5*k*x)*c/2; laplace(x**3*a,x,p); clear a; on mcd;
  139. % And so on, but is very time consuming.
  140. % laplace(e**(k*x)*x**2*sin(a*x-b)**2, x, p);
  141. % for all x let one(a*x-b)*one(c*x-d) = one(c*x-d);
  142. % laplace(x*e**(-2*x)*cos(a*x-b)*sinh(c*x-d), x, p);
  143. % for all x clear one(a*x-b)*one(c*x-d) ;
  144. % laplace(x*e**(c*x)*sin(k*x)**3*cosh(x)**2*cos(a*x), x, p);
  145. off lmon;
  146. % Error messages.
  147. laplace(sin(-x),x,p);
  148. on lmon; laplace(sin(-a*x), x, p); off lmon;
  149. laplace(e**(k*x**2), x, p);
  150. laplace(sin(-a*x+b)*cos(c*x+d), x, p);
  151. laplace(x**(-5/2),x,p);
  152. % With int arg, can't be shifted.
  153. laplace(intl(y*e**(a*y)*sin(k*y-tau),y,0,x), x, p);
  154. laplace(cosh(x**2), x, p);
  155. laplace(3*x/(x**2-5*x+6),x,p);
  156. laplace(1/sin(x),x,p); % But ...
  157. laplace(x/sin(-3*a**2),x,p);
  158. % Severe errors.
  159. % laplace(sin x,x,cos y);
  160. % laplace(sin x,x,y+1);
  161. % laplace(sin(x+1),x+1,p);
  162. Comment Examples of Inverse Laplace transformations;
  163. symbolic(ordl!* := nil); % To nullify previous order declarations.
  164. order t;
  165. % Elementary ratio of polynomials.
  166. invlap(1/p, p, t);
  167. invlap(1/p**3, p, t);
  168. invlap(1/(p-a), p, t); invlap(1/(2*p-a),p,t); invlap(1/(p/2-a),p,t);
  169. invlap(e**(-k*p)/(p-a), p, t); invlap(b**(-k*p)/(p-a), p, t);
  170. invlap(1/(p-a)**3, p, t);
  171. invlap(1/(c*p-a)**3, p, t); invlap(1/(p/c-a)**3, p, t);
  172. invlap((c*p-a)**(-1)/(c*p-a)**2, p, t);
  173. invlap(c/((p/c-a)**2*(p-a*c)), p, t);
  174. invlap(1/(p*(p-a)), p, t);
  175. invlap(c/((p-a)*(p-b)), p, t);
  176. invlap(p/((p-a)*(p-b)), p, t);
  177. off mcd; invlap((p+d)/(p*(p-a)), p, t);
  178. invlap((p+d)/((p-a)*(p-b)), p, t);
  179. invlap(1/(e**(k*p)*p*(p+1)), p, t); on mcd;
  180. off exp; invlap(c/(p*(p+a)**2), p, t); on exp;
  181. invlap(1, p, t); invlap(c1*p/c2, p, t);
  182. invlap(p/(p-a), p, t); invlap(c*p**2, p, t);
  183. invlap(p**2*e**(-a*p)*c, p, t);
  184. off mcd;invlap(e**(-a*p)*(1/p**2-p/(p-1))+c/p, p, t);on mcd;
  185. invlap(a*p**2-2*p+1, p, x);
  186. % P to non-integer power in denominator - i.e. gamma-function case.
  187. invlap(1/sqrt(p), p, t); invlap(1/sqrt(p-a), p, t);
  188. invlap(c/(p*sqrt(p)), p, t); invlap(c*sqrt(p)/p**2, p, t);
  189. invlap((p-a)**(-3/2), p, t);
  190. invlap(sqrt(p-a)*c/(p-a)**2, p, t);
  191. invlap(1/((p-a)*b*sqrt(p-a)), p, t);
  192. invlap((p/(c1-3)-a)**(-3/2), p, t);
  193. invlap(1/((p/(c1-3)-a)*b*sqrt(p/(c1-3)-a)), p, t);
  194. invlap((p*2-a)**(-3/2), p, t);
  195. invlap(sqrt(2*p-a)*c/(p*2-a)**2, p, t);
  196. invlap(c/p**(7/2), p, t); invlap(p**(-7/3), p, t);
  197. invlap(gamma(b)/p**b,p,t); invlap(c*gamma(b)*(p-a)**(-b),p,t);
  198. invlap(e**(-k*p)/sqrt(p-a), p, t);
  199. % Images that give elementary object functions.
  200. % Use of new switches lmon, lhyp.
  201. invlap(k/(p**2+k**2), p, t);
  202. % This is made more readable by :
  203. on ltrig; invlap(k/(p**2+k**2), p, t);
  204. invlap(p/(p**2+1), p, t);
  205. invlap((p**2-a**2)/(p**2+a**2)**2, p, t);
  206. invlap(p/(p**2+a**2)**2, p, t);
  207. invlap((p-a)/((p-a)**2+b**2), p, t); off ltrig;
  208. on lhyp; invlap(s/(s**2-k**2), s, t);
  209. invlap(e**(-tau/k*p)*p/(p**2-k**2), p, t); off lhyp;
  210. % But it is not always possible to convert expt. functions, e.g.:
  211. on lhyp; invlap(k/((p-a)**2-k**2), p, t); off lhyp;
  212. on ltrig; invlap(e**(-tau/k*p)*k/(p**2+k**2), p, t); off ltrig;
  213. % In such situations use the default switches:
  214. invlap(k/((p-a)**2-k**2), p, t); % i.e. e**(a*t)*cosh(k*t).
  215. invlap(e**(-tau/k*p)*k/(p**2+k**2), p, t); % i.e. sin(k*t-tau).
  216. % More complicated examples.
  217. off exp,mcd; invlap((p+d)/(p**2*(p-a)), p, t);
  218. invlap(e**(-tau/k*p)*c/(p*(p-a)**2), p, t);
  219. invlap(1/((p-a)*(p-b)*(p-c)), p, t);
  220. invlap((p**2+g*p+d)/(p*(p-a)**2), p, t); on exp,mcd;
  221. invlap(k*c**(-b*p)/((p-a)**2+k**2), p, t);
  222. on ltrig; invlap(c/(p**2*(p**2+a**2)), p, t);
  223. invlap(1/(p**2-p+1), p, t); invlap(1/(p**2-p+1)**2, p, t);
  224. invlap(2*a**2/(p*(p**2+4*a**2)), p, t);
  225. % This is (sin(a*t))**2 and you can get this by using the let rules :
  226. for all x let sin(2*x)=2*sin x*cos x, cos(2*x)=(cos x)**2-(sin x)**2,
  227. (cos x)**2 =1-(sin x)**2;
  228. invlap(2*a**2/(p*(p**2+4*a**2)), p, t);
  229. for all x clear sin(2*x),cos(2*x),cos(x)**2; off ltrig;
  230. on lhyp;invlap((p**2-2*a**2)/(p*(p**2-4*a**2)),p,t);
  231. off lhyp; % Analogously, the above is (cosh(a*t))**2.
  232. % Floating arithmetic.
  233. invlap(2.55/((0.5*p-2.0)*(p-3.3333)), p, t);
  234. on rounded;
  235. invlap(2.55/((0.5*p-2.0)*(p-3.3333)), p, t);
  236. invlap(1.5/sqrt(p-0.5), p, t);
  237. invlap(2.75*p**2-0.5*p+e**(-0.9*p)/p, p, t);
  238. invlap(1/(2.0*p-3.0)**3, p, t); invlap(1/(2.0*p-3.0)**(3/2), p, t);
  239. invlap(1/(p**2-5.0*p+6), p, t);
  240. off rounded;
  241. % Adding new let rules for the invlap operator. note the syntax:
  242. for all x let invlap(log(gam*x)/x,x) = -log(lp!&);
  243. invlap(-1/2*log(gam*p)/p, p, t);
  244. invlap(-e**(-a*p)*log(gam*p)/(c*p), p, t);
  245. for all x clear invlap(1/x*log(gam*x),x);
  246. % Very complicated examples and use of factorizer.
  247. off exp,mcd; invlap(c**(-k*p)*(p**2+g*p+d)/(p**2*(p-a)**3), p, t);
  248. on exp,mcd;
  249. invlap(1/(2*p**3-5*p**2+4*p-1), p, t);
  250. on ltrig,lhyp; invlap(1/(p**4-a**4), p, t);
  251. invlap(1/((b-3)*p**4-a**4*(2+b-5)), p, t); off ltrig,lhyp;
  252. % The next three examples are the same:
  253. invlap(c/(p**3/8-9*p**2/4+27/2*p-27)**2,p,t);invlap(c/(p/2-3)**6,p,t);
  254. off exp; a:=(p/2-3)**6; on exp; invlap(c/a, p, t); clear a;
  255. % The following two examples are the same :
  256. invlap(c/(p**4+2*p**2+1)**2, p, t); invlap(c/((p-i)**4*(p+i)**4),p,t);
  257. % The following three examples are the same :
  258. invlap(e**(-k*p)/(2*p-3)**6, p, t);
  259. invlap(e**(-k*p)/(4*p**2-12*p+9)**3, p, t);
  260. invlap(e**(-k*p)/(8*p**3-36*p**2+54*p-27)**2, p, t);
  261. % Error messages.
  262. invlap(e**(a*p)/p, p, t);
  263. invlap(c*p*sqrt(p), p, t);
  264. invlap(sin(p), p, t);
  265. invlap(1/(a*p**3+b*p**2+c*p+d),p,t);
  266. invlap(1/(p**2-p*sin(p)+a**2),p,t);
  267. on rounded; invlap(1/(p**3-1), p, t); off rounded;
  268. % Severe errors:
  269. %invlap(1/(p**2+1), p+1, sin(t) );
  270. %invlap(p/(p+1)**2, sin(p), t);
  271. end;