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