# Steady state response and transfer function

For an LTI system in frequency domain, Y(s) = H(s)X(s), where symbols have their usual meanings. I am confused in what this represents, i.e., is it true only in steady state (in other words is it only the forced response) or is it true for all times including the transient time (forced plus the natural response).
Because when we take the sinusoidal response of a system we calculate the steady state response by calculating the magnitude of the transfer function H(s) and multiplying it by the input sine.
But when we calculate the inverse laplace transform we get the total output of the system.

Not quite, $H(s)X(s)$ is the response to the signal $X(s)$ if the system is initially at rest, i.e. with "zero" initial conditions.

You can understand this in the following way. A LTI system can be described in the time domain by a linear differential equation with constant coefficients like the following:

$a_ny^{(n)}(t) + a_{n-1}y^{(n-1)}(t) + \dots + a_1y^{(1)}(t) + a_0y(t) = b_mx^{(m)}(t) + b_{m-1}x^{(m-1)}(t) + \dots + b_1x^{(1)}(t) + b_0x(t)$

Keeping in mind the differentiation property of the one-sided Laplace transform:

$L\{D[q(t)]\} = sQ(s) - q(0^-) \qquad\qquad \text{where} ~~ Q(s) = L\{q(t)\}$

you can take the L-transform of both members of the differential equation and you obtain the following equation in the s domain:

$a_ns^nY(s) + a_{n-1}s^{(n-1)}Y(s) + \dots + a_1sY(s) + a_0Y(s) + R(s) = b_ms^mX(s) + b_{m-1}s^{(m-1)}X(s) + \dots + b_1sX(s) + b_0X(s) + K(s)$

Where $R(s)$ is a polynomial expression in $s$ where the coefficients are combinations of the derivatives of $y$ computed at $0^-$ (this term comes from the $q(0^-)$ in the differentiation property). Analogously $K(s)$ is a polynomial whose coefficients are combinations of $x$ computed at $0^-$.

If you factor out $X(s)$ and $Y(s)$ in the transformed equation and then isolate $Y$ you obtain the following, which is an expression for the entire response (zero-state + zero-input):

$Y(s) = \dfrac {b_ms^m + b_{m-1}s^{m-1}+\dots+b_0} {a_ns^n + a_{n-1}s^{n-1}+\dots+a_0} X(s) + \dfrac{K(s)-R(s)}{a_ns^n + a_{n-1}s^{n-1}+\dots+a_0}$

The first term is $H(s) X(s)$ and gives you the full response of the system when it is excited by $x(t)$ when its initial state is "zero" (i.e. no energy stored in caps and inductors, if we are talking about electrical circuits), the other term represents the part of the transient response due to the energy stored in the system at time 0.

Note that this latter depends on the values at $0^-$ of y, x and their derivatives. From a circuit POV these values are related to the initial conditions of the circuit: currents in inductors and voltages across caps.

Take as a simple example an RC circuit like the following:

from the KVL and Ohm's law we have:

$v(t) = R i(t) + v_c(t)$

but the v-i relationship for the capacitor tells us that

$i(t) = C \dfrac{dv_c(t)}{dt}$

Thus we have the following differential equation for the circuit:

$v(t) = R C \dfrac{dv_c(t)}{dt} + v_c(t)$

Where $v$ is the excitation (x) and $v_c$ is the unknown response (y). If we now apply the L-transform to both sides we get:

$V(s) = R C \left[ sV_c(s) - v_c(0^-) \right] + V_c(s) = (R C s + 1 ) V_c(s) - R C v_c(0-)$

which, after simple passages, becomes:

$V_c(s) = \dfrac{1}{R C s + 1} V(s) + \dfrac{RC v_c(0^-)}{R C s + 1}$

If the system is stable, then Y(s) = H(s)X(s) can be used at all times. This means if you know the transfer function of the underlying system, then for a given input you can compute a simulated output of the system. In the example you used, the reason you obtain the steady stade response that way is because the magnitude of the transfer function H(s) is defined as the gain of the system.