# Solution to a non homogeneous wave equation

First, I define a constant I'll use later:

eyng = (1/(1 + 0.25*Sin[2 Pi y]))^2;
cfec = 1/\!$$\*SubsuperscriptBox[\(\[Integral]$$, $$0$$, $$1$$]$$\(( \*FractionBox[\(1$$, $$eyng$$])\) \[DifferentialD]y\)\)


Then I try to solve the following PDE following a similar idea to this:

wqn = D[u[t, x], {t, 2}] == cfec*D[u[t, x], {x, 2}] + Exp[-t]
bc1 = {u[t, x] == 0, x == 0};
bc2 = {u[t, x] == 0, x == 1};
ic1 = {u[t, x] == 0, t == 0};
ic2 = {Derivative[1, 0][u][x, 0] == 0};
sol = DSolveValue[{wqn, ic1, ic2, bc1, bc2}, u[t, x], {t, x}]


However, Mathematica doesn't really solve the problem, it just rewrites it, and I'm not sure what I'm doing wrong. I need to plot the solution to it at a fixed t, then compare it with another problem's solution, but I cannot continue.

Any advice will be greatly appreciated

• Well, I solved the PDE the old fashioned way, plotted it, and then used Show to compare both graphics. Maybe this will help someone with a similar problem. – REVB Jun 15 '18 at 18:54

## 1 Answer

I edited your try a little bit and it seems to work:

wqn = D[u[t, x], {t, 2}] == cfec*D[u[t, x], {x, 2}] + Exp[-t]
bc1 = u[t, 0] == 0  ;
bc2 = u[t, 1] == 0  ;
ic1 = u[0, x] == 0  ;
ic2 = Derivative[1, 0][u][0, x ] == 0 ;
sol = NDSolveValue[{wqn, ic1, ic2, bc1, bc2},u , {t, 0, 4}, {x, 0, 1 }]

Plot[Table[sol[t, x], {t, 0, 1, .1}], {x, 0, 1}] • Much appreciated! However, I don't understand why there are multiple plots, even when inputing a single value of t. The solution should be unique because of the initial and boundary conditions. – REVB Jun 16 '18 at 2:48
• I tried using Plot[(sol[3, x]) // Evaluate, {x, 0, 1}] and changing to {t, 0, 5} and got something more along the lines of what I obtained by the method I described before. – REVB Jun 16 '18 at 2:55
• The solution is unique! In my plot you see the solution for different times. – Ulrich Neumann Jun 16 '18 at 7:33