%mathpiper,def="LaplaceTransform"

10 # LaplaceTransform(_var1,_var2, _expr )	<-- LapTran(var1,var2,expr);

// Linearity properties
10 # LapTran(_var1,_var2,_x + _y)      		<-- LapTran(var1,var2,x) + LapTran(var1,var2,y);
10 # LapTran(_var1,_var2,_x - _y)		<-- LapTran(var1,var2,x) - LapTran(var1,var2,y);
10 # LapTran(_var1,_var2,    - _y)       	<-- LapTran(var1,var2,y);
10 # LapTran(_var1,_var2, c_IsConstant*_y)	<-- c*LapTran(var1,var2,y);
10 # LapTran(_var1,_var2, _y*c_IsConstant)	<-- c*LapTran(var1,var2,y);
10 # LapTran(_var1,_var2, _y/c_IsConstant) 	<-- LapTran(var1,var2,y)/c;

// Shift properties
10 # LapTran(_var1,_var2, Exp(c_IsConstant*_var1)*_expr  ) <-- LapTran(var1,var2-c,expr);
10 # LapTran(_var1,_var2, Exp(-c_IsConstant*_var1)*_expr ) <-- LapTran(var1,var2+c,expr);
10 # LapTran(_var1,_var2, _expr*Exp(c_IsConstant*_var1)  ) <-- LapTran(var1,var2-c,expr);
10 # LapTran(_var1,_var2, _expr*Exp(-c_IsConstant*_var1) ) <-- LapTran(var1,var2+c,expr);

// Other operational properties
10 # LapTran(_var1,_var2, _expr/_var1 )		<-- Integrate(var2,var2,Infinity) LapTran(var1,var2,expr) ;
10 # LapTran(_var1,_var2, _var1*_expr )		<-- - Deriv(var2) LapTran(var1,var2,expr);
10 # LapTran(_var1,_var2, _var1^(n_IsInteger)*_expr )  <-- (-1)^n * Deriv(var2,n) LapTran(var1,var2,expr);
10 # LapTran(_var1,_var2, _expr*_var1 )                <-- - Deriv(var2) LapTran(var1,var2,expr);
10 # LapTran(_var1,_var2, _expr*_var1^(n_IsInteger)  ) <-- (-1)^n * Deriv(var2,n) LapTran(var1,var2,expr);

// didn't match, return unevaled
100 # LapTran(_var1,_var2, _expr )	<-- `Hold(LaplaceTransform(@var1,@var2,@expr));

LapTranDef(_in,_out) <--
[
  Local(i,o);

  //Echo("50 # LapTran(_t,_s,",in,") <-- ",out,";");
  `(50 # LapTran(_t,_s,@in) <-- @out );

  i:=Subst(_t,c_IsPositiveInteger*_t) in;
  o:=Subst(s,s/c) out;

  //Echo("50 # LapTran(_t,_s,",i,") <-- ",o/c,";");
  `(50 # LapTran(_t,_s,@i ) <-- @o/c );

  i:=Subst(_t,_t/c_IsPositiveInteger) in;
  o:=Subst(s,s*c) out;

  //Echo("50 # LapTran(_t,_s,",i,") <-- ",o/c,";");
  `(50 # LapTran(_t,_s,@i ) <-- @o*c );

];

// transforms of specific functions
LapTranDef( (_t)^(n_IsConstant),	Gamma(n+1)/s^(n+1) );
LapTranDef( _t, 			1/s^2 );
LapTranDef( Sqrt(_t), 			Sqrt(Pi)/(2*s^(3/2)) );
LapTranDef( c_IsFreeOf({t,s}),		c/s );
LapTranDef( Sin(_t),	 		1/(s^2+1) );
LapTranDef( Cos(_t), 			s/(s^2+1) );
LapTranDef( Sinh(_t),			c/(s^2-1) );
LapTranDef( Cosh(_t),			s/(s^2-1) );
LapTranDef( Exp(_t),			1/(s-1) );
LapTranDef( BesselJ(n_IsConstant,_t),	(Sqrt(s^2+1)-s)^n /Sqrt(s^2+1) );
LapTranDef( BesselI(n_IsConstant,_t),	(s-Sqrt(s^2+1))^n /Sqrt(s^2-1) );
LapTranDef( Ln(_t),			-(gamma+Ln(s))/s);
LapTranDef( Ln(_t)^2,			Pi^2/(6*s)+(gamma+Ln(s))/s );
LapTranDef( Erf(_t),			Exp(s^2/4)*Erfc(s/2)/s );
LapTranDef( Erf(Sqrt(_t)),		1/(Sqrt(s+1)*s) );


%/mathpiper



%mathpiper_docs,name="LaplaceTransform",categories="User Functions;Transforms"
*CMD LaplaceTransform --- Laplace Transform
*STD
*CALL
	LaplaceTransform(t,s,func)	
*PARMS

{t} -- independent variable that is being transformed

{s} -- independent variable that is being transformed into

{f} -- function

*DESC

This function attempts to take the function {f(t)} and find the Laplace transform
of it,{F(s)}, which is defined as {Integrate(t,0,Infinity) Exp(-s*t)*f}. This is
also sometimes referred to the "unilateral" Laplace tranform. {LaplaceTransform}
can transform most elementary functions that do not require a convolution integral,
as well as any polynomial times an elementary function. If a transform cannot
be found then {LaplaceTransform} will return unevaluated. This can happen
for function which are not of "exponential order", which means that they grow
faster than exponential functions.


*E.G.

In> LaplaceTransform(t,s,2*t^5+ t^2/2 )
Result: 240/s^6+2/(2*s^3);
In> LaplaceTransform(t,s,t*Sin(2*t)*Exp(-3*t) )
Result: (2*(s+3))/(2*(2*(((s+3)/2)^2+1))^2);
In> LaplaceTransform(t,s, BesselJ(3,2*t) )
Result: (Sqrt((s/2)^2+1)-s/2)^3/(2*Sqrt((s/2)^2+1));
In> LaplaceTransform(t,s,Exp(t^2)); // not of exponential order
Result: LaplaceTransform(t,s,Exp(t^2));
In> LaplaceTransform(p,q,Ln(p))
Result: -(gamma+Ln(q))/q;
%/mathpiper_docs