# Solving a system of first-order partial differential equations (Analytically and Numerically)

I am trying to use Mathematica 10 to solve a system of partial differential equations but I could not. This system has an exact solution and my question is: How do I solve it exactly and numerically if possible?

\begin{align*} \frac{\partial u}{\partial t}-\frac{\partial v}{\partial x}+u+v &=(1+t)x+(x-1)t^{2}\\ \frac{\partial v}{\partial t}-\frac{\partial u}{\partial x}+u+v &=(2x-1)t+(1+t)x\,t\\ \text{The constraints are:} \\ u(x,0)&=u(0,t)=v(x,0)=v(0,t)=0 \end{align*} The exact solution to this problem is:

$u(x,t)=x\,t$, and $v(x,t)=x\,t^2$.

Thank you so much and I am looking forward to hearing from you.

• How did you try? please show us your trial so we can give you pointed suggestion. – xzczd Mar 11 '17 at 8:40

Writing:

pde1 = D[u[x, t], t] - D[v[x, t], x] + u[x, t] + v[x, t] == (1 + t) x + (x - 1) t^2;
pde2 = D[v[x, t], t] - D[u[x, t], x] + u[x, t] + v[x, t] == (1 + t) x t + (2 x - 1) t;
constrains = u[x, 0] == u[0, t] == v[x, 0] == v[0, t] == 0;
domain = ImplicitRegion[0 <= x <= 1 && 0 <= t <= 1, {x, t}];

sol = NDSolve[{pde1, pde2, constrains}, {u[x, t], v[x, t]}, {x, t} \[Element] domain];

f1 = Evaluate[u[x, t] /. sol];
f2 = Evaluate[v[x, t] /. sol];
Plot3D[{f1, f2}, {x, t} \[Element] domain, AxesLabel -> {x, t, z}]


I get:

that is the solution of the equation system considered.

Unfortunately, if he later writes:

DSolve[{pde1, pde2, constrains}, {u[x, t], v[x, t]}, {x, t}]


MMA returns the same system, effectively raising the white flag.

• I really do feel grateful for your help and I have compared your solution with exact one and it sounds match each other. This is the numerical one and how can I get the exact solution by using Mathematica?, please. – A. Alali Mar 11 '17 at 19:20
• @A.Alali: I edited the answer. Unfortunately, it seems that MMA is not able to calculate, at least if not "helped" in some other way that does not know. – TeM Mar 11 '17 at 21:07

The analytic solution can be found by Laplace transform, I'll use pdeSolveWithLaplaceTransform for the task:

pde1 = D[u[x, t], t] - D[v[x, t], x] + u[x, t] + v[x, t] == (1 + t) x + (x - 1) t^2;
pde2 = D[v[x, t], t] - D[u[x, t], x] + u[x, t] + v[x, t] == (1 + t) x t + (2 x - 1) t;
ic = {u[x, 0] == 0, v[x, 0] == 0};
bc = {u[0, t] == 0, v[0, t] == 0};

(* Definition of pdeSolveWithLaplaceTransform isn't included here,