Inverse Laplace transform - Getting a compact solution

I had the following inverse laplace transform:

InverseLaplaceTransform[(s + Subscript[k, 2] + Subscript[k, 12])/(
Subscript[V,
1] (s^2 +
s (Subscript[k, 1] + Subscript[k, 2] + Subscript[k, 12] +
Subscript[k, 21]) + Subscript[k, 1] Subscript[k, 2] +
Subscript[k, 1] Subscript[k, 12] +
Subscript[k, 2] Subscript[k, 21])), s, t]


The solution is:

My goal is to get a compact solution like this:

$$A exp(at) + B exp(bt)$$

Thank you so much for your time.

• What is V? Did you try FullSimplify? Commented Dec 7, 2017 at 19:09
• Hello @David G. Stork all k and V are positive constants. Your solution works also very good! Commented Dec 7, 2017 at 19:47
• Never use an upper-case letter (e.g., V) for a function or variable as it may conflict with Mathematica's internal names. Commented Dec 7, 2017 at 19:52

Just use Collect:

InverseLaplaceTransform[(s + Subscript[k, 2] +
Subscript[k, 12])/(Subscript[V,
1] (s^2 +
s (Subscript[k, 1] + Subscript[k, 2] + Subscript[k, 12] +
Subscript[k, 21]) + Subscript[k, 1] Subscript[k, 2] +
Subscript[k, 1] Subscript[k, 12] +
Subscript[k, 2] Subscript[k, 21])), s, t] //
Collect[#, Exp[__]] &


$\frac{\left(\sqrt{\left(k_1+k_2+k_{12}+k_{21}\right){}^2-4 \left(k_1 k_2+k_{21} k_2+k_1 k_{12}\right)}-k_1+k_2+k_{12}-k_{21}\right)}{2 \sqrt{\left(k_1+k_2+k_{12}+k_{21}\right){}^2-4 \left(k_1 k_2+k_{21} k_2+k_1 k_{12}\right)} V_1}\times\\\exp \left[\left(\frac{1}{2} \sqrt{\left(k_1+k_2+k_{12}+k_{21}\right){}^2-4 \left(k_1 k_2+k_{21} k_2+k_1 k_{12}\right)}-\frac{k_1}{2}-\frac{k_2}{2}-\frac{k_{12}}{2}-\frac{k_{21}}{2}\right) t\right]+\frac{\left(\sqrt{\left(k_1+k_2+k_{12}+k_{21}\right){}^2-4 \left(k_1 k_2+k_{21} k_2+k_1 k_{12}\right)}+k_1-k_2-k_{12}+k_{21}\right) }{2 \sqrt{\left(k_1+k_2+k_{12}+k_{21}\right){}^2-4 \left(k_1 k_2+k_{21} k_2+k_1 k_{12}\right)} V_1} \times\\ \exp \left[\left(-\frac{1}{2} \sqrt{\left(k_1+k_2+k_{12}+k_{21}\right){}^2-4 \left(k_1 k_2+k_{21} k_2+k_1 k_{12}\right)}-\frac{k_1}{2}-\frac{k_2}{2}-\frac{k_{12}}{2}-\frac{k_{21}}{2}\right) t\right]$

• thank you very much for your extremely clear answer! Commented Dec 7, 2017 at 19:49
• Can you tell me what is the meaning of the last & in your code please? I know its meaning only if it is followed by another argument. Commented Dec 7, 2017 at 21:11
• You can see that Collect has an # inside. Therefore \\Collect[#,Exp[___]]& does the same as Collect[InverseLaplaceTransform[...],Exp[___]], i.e., take the previous result as its argument in #. That is why & should be after. It is a pure like Function construction Commented Dec 8, 2017 at 11:26
• See postfix form at Special Ways to Input Expressions Commented Mar 2, 2019 at 18:38