3
$\begingroup$

I am trying to simplify the (exponential) result of an inverse Laplace Transform. The expression could be simpler than shown and I don't understand why the simplification will not work. Usually when this happens to me it's because of some assumptions I have implicitly made about the constants, but this has simply to do with multiplication/cancellation of exponentials which doesn't seem to need assumptions. Why is this happening and how can I get the desired result?

Here are my steps:

F[s_, a_, b_, c_] := (a b)/((a + s) (b + s) (c + s))

That defines the function to subject to the inverse Laplace Transform. Then I do the Laplace transform:

f[t_, a_, b_, c_] := FullSimplify[InverseLaplaceTransform[F[s, a, b, c], s, t]]
f[t, a, b, c]

That seems to work:

(a b ((b - c) E^(-a t) + (-a + c) E^(-b t) + (a - b) E^(-c t)))/((a - b) (a - c) (b - c))

The problem comes when I divide that result by another function and try to simplify that.

g[t_, a_, b_, c_] := f[t, a, b, c]/Exp[-a t]
g[t, a, b, c]

(a b E^(a t) ((b - c) E^(-a t) + (-a + c) E^(-b t) + (a - b) E^(-c t)))/((a - b) (a - c) (b - c))

But then:

FullSimplify[g[t, a, b, c]]

(a b E^(a t) ((b - c) E^(-a t) + (-a + c) E^(-b t) + (a - b) E^(-c t)))/((a - b) (a - c) (b - c))

The FullSimplify result of g is the same. It clearly seems like (independent of assumptions about a,b,c) it should be able to multiply through by Exp[a t] and remove some complexity.

$\endgroup$

1 Answer 1

6
$\begingroup$

sometimes Simplify does not always produce the lowest LeafCount. It might have heuristics which makes it decide which is a "simpler" looking expression over another.

Simplification of math expressions seems to be 25% heuristics, 50% actual math and 25% art. I think it is one of the hardest problems in computer algebra. I always wondered how big the Simplify code is. I bet over one million lines of code?

But one trick to use to simplify the numerator and denominator on their own.

F[s_, a_, b_, c_] := (a b)/((a + s) (b + s) (c + s))
f[t_, a_, b_, c_] := FullSimplify[InverseLaplaceTransform[F[s, a, b, c], s, t]]
expr = f[t, a, b, c]/Exp[-a t]

Mathematica graphics

LeafCount[expr]
(* 66 *)

FullSimplify[expr] // LeafCount
(* 66 *)

I assume you were looking for this

desiredOne = Simplify[Numerator[expr]]/Simplify[Denominator[expr]]

Mathematica graphics

LeafCount[desiredOne]
(*  59 *)

it is also possible to customize the simplify command with your own TransformationFunctions if needed.

For me, I think the form with 66 LeafCount is easier to read actually (it has symmetry in it), than the one with smaller 59 LeafCount. But this might be just a personal choice.

$\endgroup$
2
  • $\begingroup$ Thank you! Ancillary question: how did you get the nicely formatted output lines in your answer? That's something I've been struggling with--it's so much easier to read in your format. $\endgroup$
    – villaa
    May 27 at 15:13
  • $\begingroup$ @villaa oh, I just copy/paste the output cell as an image. You could either do it by taking screen shot and crop the area of the cell. Or use like I do by using SEUploader which makes it much easier. see can-i-easily-post-images-to-this-site-directly-from-mathematica-yes This will then install as Palettes in your notebook. So if you want to copy an output cell, simply select the output cell first, then use SEUploader to copy it, then paste into your post. $\endgroup$
    – Nasser
    May 27 at 17:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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