laplace.tst 11 KB

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