Characteristics for nonhomogeneous wave equation $y_{tt}=y_{xx} + f$ Consider the initial- and boundary-value problem
$$\eqalign{
  & {y_{tt}} = {y_{xx}} + f(t,x){\text{ }}{\text{, (t}}{\text{,x)}} \in {\text{(0}}{\text{,}}\infty {\text{)}} \times {\text{(0}}{\text{,1)}}  \cr 
  & y(t,0) = y(t,1) = 0  \cr 
  & y(0,x) = {y_0}(x),{\text{ }}{y_t}(0,x) = {y_1}(x) \cr} $$
To solve that, I reduced the above system to 1-d hyperbolic system by letting 
$$\eqalign{
  & p = {y_t} - {y_x}  \cr 
  & q = {y_t} + {y_x} \cr} $$
We obtain
$$\eqalign{
  & {p_t} = -{p_x} + f(t,x)  \cr 
  & {q_t} = {q_x} + f(t,x)  \cr 
  & p(t,0) + q(t,0) = p(t,1) + q(t,1) = 0  \cr 
  & p(0,x) = {p_0}(x),q(0,x) = {q_0}(x) \cr} $$
The characteristic lines are $x^-=t+c_1$ and $x^+=-t+c_2$ for the first and second equation respectively.
let us consider the first transport equation, 
We have along x^-:
$$\frac{d}{{dt}}p(t,t + {c_1}) = f(t,t + {c_1})$$
Let $f$ be defined as$$f(t,x) = \left\{ \matrix 
  {f_1}(t,x),{\text{ if x + t}} \in (0,1),  
  {f_2}(t,x),{\text{ if x + t}} \in (1,2).  
  \right.$$
The characteristic $x^-$ will cuts the line $x=t$ in the point $t=\frac{{1 - {c_1}}}{2}$. 
Integrating over $(0,t)$, we get
$$p(t,t+c_1) = {p_0}(c_1) + \int\limits_0^t {f(s,s+c_1)ds} $$
How can I write the solution in function of $f_1$ and $f_2$?
Is the following expression correct?
$$
p(t,x) = {p_0}(x-t) + \int\limits_0^{\frac{{1 - {c_1}}}{2}} {{f_1}(s,s - t + x)ds}  + \int\limits_{\frac{{1 - {c_1}}}{2}}^{1 - {c_1}} {{f_2}(s,s - t + x)ds} $$
Or that expression?
$$\eqalign{
  & p(t,t + {c_1}) = {p_0}({c_1}) + \int\limits_0^t {{f_1}(s,s+c_1)ds} ,{\text{ if t}} \in {\text{(0}}{\text{,}}\frac{{1 - {c_1}}}{2})  \cr 
  & p(t,t + {c_1}) = {p_0}({c_1}) + \int\limits_0^t {{f_1}(s,s + {c_1})ds}  +  + \int\limits_{\frac{{1 - {c_1}}}{2}}^t {{f_2}(s,s + {c_1})ds} ,{\text{ if t}} \in {\text{(}}\frac{{1 - {c_1}}}{2},1 - {c_1}) \cr} $$
 A: Here is a sketch of the $x$-$t$ plane, where the zones $0\leq x+t\leq 1$ and $1\leq x+t\leq 2$ are denoted by {1} and {2}, respectively:

Let us introduce the triangle $\mathcal{T} = \lbrace (t,x)$ s.t. $0\leq x+t\leq 1$ and $0\leq x-t\leq 1\rbrace$, which is located within the zone {1}. This triangle corresponds to the domain where the celebrated d'Alembert's formula is valid (see §12.5 p. 548 of the book (1)). Over this triangle, the expressions of $p$ and $q$ are deduced by integration of $\frac{\text d}{\text d t}p = f_1$ and $\frac{\text d}{\text d t}q = f_1$ along the characteristic curves $x = x_p + t$ and $x = x_q - t$, respectively.
If we consider a given point $(t,x)$ in the triangle $\mathcal{T}$, then the characteristic lines that pass through this point start respectively at the abscissas $x = x_p$ and $x = x_q$ at the time $t=0$. We have
$$
\begin{aligned}
p(t,x) &= p_0(x_p) + \int_0^t f_1(s,x_p+s)\, \text d s \\
&= p_0(x-t) + \int_0^t f_1(s,x-t+s)\, \text d s\, ,
\end{aligned}
$$
and similarly,
$$
q(t,x) = q_0(x+t) + \int_0^t f_1(s,x+t-s)\, \text d s \, .
$$
Evaluating the definition of $p = y_t - y_x$ and $q = y_t + y_x$ at the time $t=0$, we obtain $p_0 = y_1 - y'_0$ and $q_0 = y_1 + y'_0$, which can be substituted in the above equations. Then, d'Alembert's formula is obtained by integration of $y_t = \frac12 (p+q)$ w.r.t. $t$:
$$
y(t,x) = \frac{y_0(x+t) + y_0(x-t)}{2} + \frac12 \int_{x-t}^{x+t} y_1(s)\,\text d s + \frac12 \int_0^t\!\! \int_{x-t+\tau}^{x+t-\tau} f_1(\tau,s)\, \text d s\, \text d \tau
$$
for $(t,x)$ in $\mathcal{T}$ (cf. e.g. this post for the classical homogeneous case). Of course, we then need to follow the characteristic curves until the boundaries $x=0$ and $x=1$, where the waves are reflected -- and so on.

(1) R. Habermann, Applied Partial Differential Equations; with Fourier Series and Boundary Value Problems, 5th ed., Pearson Education Inc., 2013.
