# Replacement rule for unevaluated LaplaceTransform

I am wanting to algebraically manipulate expressions resulting from LaplaceTransform applied to time domain expressions. Unknown variables are left unevaluated by the transform as they should be. I wish to replace unevaluated transform expressions with the traditional forms.

For example: LaplaceTransform[x[t],t,s] -> x[s]

Here is my naïve attempt which doesn't work:

eqs = -((k1 + k2)  LaplaceTransform[x1[t], t, s]) +
k2  LaplaceTransform[x2[t], t, s] -
m1  (s^2  LaplaceTransform[x1[t], t, s] - s  x1[0] -
Derivative[1][x1][0]) ==
dmp1  (s  LaplaceTransform[x1[t], t, s] - x1[0]);

eqs /. Unevaluated[LaplaceTransform[v_[t], t, s]] -> v[s]

(*-((k1+k2) LaplaceTransform[x1[t],t,s])+k2 \
LaplaceTransform[x2[t],t,s]-m1 (s^2 LaplaceTransform[x1[t],t,s]-s \
x1[0]-(x1^\[Prime])[0])\[Equal]dmp1 (s \
LaplaceTransform[x1[t],t,s]-x1[0])*)


Could someone please suggest an approach that works?

Thank you

Perhaps something like the following will work for you?

Unprotect[LaplaceTransform];

LaplaceTransform/:MakeBoxes[LaplaceTransform[x_Symbol[t_], t_, s_], StandardForm] := RowBox[{toCap[x], "[",MakeBoxes@s,"]"}]

Protect[LaplaceTransform];

toCap[x_Symbol] := With[{s=SymbolName[x]},
If[LowerCaseQ @ s, ToUpperCase[s], OverscriptBox[s, "^"]]
]


Example:

LaplaceTransform[f'[t],t,s]


-f[0] + s F[s]

• Thanks, Carl. That is close to working. But it results in symbols enclosed in OverHat which appear to interfere with the use of Solve. Can it be modified to keep symbols in lower case so they don't conflict with reserved symbols, and to eliminate the OverHat? Commented Jan 30 at 22:18
• I don't see why the OverHat interferes with Solve, since it is just a formatting construct, the underlying expression is still just a LaplaceTransform object. Perhaps you are using Solve[..., F[s]] when you should be using Solve[..., LaplaceTransform[f[t], t, s]]? I used OverHat/uppercase since I assumed you wouldn't want to use both f[0] and f[s] in your outputs, where the f[0] is in the t domain, and the f[s] is in the s domain. Commented Jan 31 at 15:01
• Thank you, Carl. That was the problem. I’ve been using Mathematica for a very long time. I consider myself a sophisticated user. But your incantations are a mystery to me. 😀 thanks again! Commented Feb 1 at 0:36

I came upon another solution to this when watching a video "Control Systems: An Overview" by @Suba Thomas. Thank you, Suba! (The video is here.)

The implementation is a rule that can be used to replace the Mathematica transform construct for a variable with a simpler one that is less verbose and easier to manipulate algebraically.

Here is the code, together with usage examples:

(*rule to abbreviate LaplaceTransform*)
replaceLaplaceTransform = {HoldPattern[LaplaceTransform][
var_[t], __] :>
(ToExpression@ToUpperCase@ToString@var)@s, _[0] :> 0};

(*rule to abbreviate ZTransform*)
replaceZTransform = {HoldPattern[ZTransform][var_[k], __] :>
(ToExpression@ToUpperCase@ToString@var)@z, _[_?IntegerQ] :> 0};

(*using replaceLaplaceTransform*)

expL = LaplaceTransform[x'[t] == -x[t], t, s]

(*s LaplaceTransform[x[t],t,s]-x[0]\[Equal]-LaplaceTransform[x[t],t,s]\
*)

expL /. replaceLaplaceTansform

(*s X[s]\[Equal]-X[s]*)

(*using replaceZTransform*)

expZ = ZTransform[x[k + 1] == 1/2  x[k], k, z]

(*-z x[0]+z ZTransform[x[k],k,z]\[Equal]1/2 ZTransform[x[k],k,z]*)

expZ /. replaceZTransform

(*z X[z]\[Equal]X[z]/2*)