This project is based on a project by Brian Winkle. https://www.simiode.org/resources/2981/supportingdocs
Match the expression of the Laplace tranform with known transforms and work backwards.
$$Q(s)=\frac{1}{(s)(s+k)}-e^{-s/2}\cdot \frac{1}{(s)(s+k)}+\frac{2}{(s+k)}$$We do a little partial fractions:
$$\frac{1}{(s)(s+k)}=\frac{1/k}{s}-\frac{1/k}{s+k}$$syms s k f(s)
f(s)=1/(s*(s+k))
partfrac(f(s),s)
$$\begin{array}{cccc} &Q(s)&&\\ &\shortparallel&&\\ &\frac{1}{k}\cdot \frac{1}{s}& \xleftarrow{\mathscr{L}}&\frac{1}{k}\cdot h(t)\\ &-\frac{1}{k}\cdot \frac{1}{s+k}&\xleftarrow{\mathscr{L}}&-\frac{1}{k}\cdot e^{-kt}\\ &-\frac{1}{k}\cdot e^{-s/2}\frac{1}{s}&\xleftarrow{\mathscr{L}}&-\frac{1}{k} h\left(t-\frac{1}{2}\right)\\ &+\frac{1}{k}\cdot e^{-s/2}\frac{1}{s+k}&\xleftarrow{\mathscr{L}}&+\frac{1}{k}\cdot h\left(t-\frac{1}{2}\right)e^{-k\left(t-\frac{1}{2}\right)}\\ &+2 \frac{1}{s+k}&\xleftarrow{\mathscr{L}}& +2 e^{-kt}\\ && &\shortparallel\\ &&&q(t)\\ \end{array}$$
Which isn't really as bad as it looks. The function $h(t)$ is really just 1 since we're only concerned with $t>0$. The function $h(t-1/2)$ just means that piece "turns on" at $\ t=1/2$.
Qs
qt=ilaplace(Qs, s, t)
pretty(qt)
qtnum=subs(qt, k, -log(1/2))
fplot(qtnum, [0,5])