3
$\begingroup$

I have a large symbolic expression containing many terms of the form, LaplaceTransform[u2[z], z, s], with various functions for the first argument. I wish to replace these terms by l[u2[z]], but

LaplaceTransform[u2[z], z, s] /. LaplaceTransform[u_, z, s] -> l[u]

returns unevaluated. On the other hand,

Hypergeometric1F1[u2[z], z, s] /. Hypergeometric1F1[u_, z, s] -> l[u]

or

Plus[u2[z], z, s] /. Plus[u_, z, s] -> l[u]

return l[u2[z]], as expected. What subtlety am I missing?

$\endgroup$
6
$\begingroup$

The issue here is that the replacement rule LHS evaluates:

LaplaceTransform[u_, z, s] -> l[u]

(* Out[1402]= u_/s -> l[u] *)

To address this one can just prevent this with HoldPattern

LaplaceTransform[u2[z], z, s] /. 
 HoldPattern[LaplaceTransform[u_, z, s]] -> l[u]

(* Out[1401]= l[u2[z]] *)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.