I am trying to solve this system of pde numerically. I am unable to find any method in Mathematica that can handle this problem. The issue is having this integration condition in the domain. I tried the method of lines but failed because NDSolve does not work with extra equations except initial and boundary conditions. And, I need to solve this for positive $u(t,x)$ and $v(t,x)$.

$\frac{\partial u(t,x)}{\partial t}=\frac{\partial^2 u(t,x)}{\partial x^2}-(\frac{2x+1}{1+x})u(t,x)(1-u(t,x)-v(t,x)); (0,1)$

$\frac{\partial v(t,x)}{\partial t}=\frac{\partial^2 v(t,x)}{\partial x^2}-v(t,x)(1-v(t,x)-u(t,x)); (0,1)$

boundary conditions $\frac{\partial u(t,0)}{\partial x}=0$, $\frac{\partial u(t,1)}{\partial x}=0$, $\frac{\partial v(t,0)}{\partial x}=0$, $\frac{\partial v(t,1)}{\partial x}=0$

initial conditions $u(0,x)=a$ (where a is a parameter), $v(0,x)=0.5$

interior conditions $\int_0^1{u(t^*,x)+v(t^*,x)dx=1}$ for all $t^*\in[0,1]$

This is what I tried:


u0 = 0.5 % this should be the parameter a%;

v0 = 0.5;

X = 1;

T = 1;

Tplot = 1;

sol = NDSolve[{D[u[t,x],t]==D[u[t,x],x,x]-p[x]*u[t,x]*(1-u[t,x]-v[t,x]), D[v[t,x],t]==D[v[t,x],x,x]-v[t,x]*(1-u[t,x]-v[t,x]), (D[u[t,x],x]/.x->0) == 0,(D[u[t,x],x]/.x->X) == 0,(D[v[t,x],x]/.x->0) == 0,(D[v[t,x],x]/.x->X) == 0, u[0,x]==u0,v[0,x]==v0},{u,v},{t,0,T},{x,0,X}]

Plot3D[{Evaluate[u[t,x]]/.sol[[1,1]],Evaluate[v[t,x]]/.sol[[1,2]]},{t,0,Tplot},{x,0,X},PlotRange->All,AxesLabel->{"t","x","Sol"}, PlotLegends->{"U","V"}]

Obviously, this is not what I should do. I have not included the integration condition (interior condition) in the code and not implemented a technique to find positive solutions.

  • $\begingroup$ You may find the answers to question 175080 of value. $\endgroup$
    – bbgodfrey
    Sep 23, 2021 at 17:38
  • $\begingroup$ Hi, I tried that idea before. Those intregrodiffrential equations are different from these problems. This problem is an over determined problem. NDSolve method does not handle extra equations such as the given integration condition. $\endgroup$
    – mathfun
    Sep 23, 2021 at 18:38
  • 1
    $\begingroup$ You are correct that this system is overdetermined. Why do you believe that it has any solution at all? By the way, the initial conditions do not satisfy the "interior conditions", although that is a separate issue. $\endgroup$
    – bbgodfrey
    Sep 23, 2021 at 18:58
  • $\begingroup$ Sorry it is a typo, I changed it. $\endgroup$
    – mathfun
    Sep 23, 2021 at 19:38
  • $\begingroup$ If $a$ is a constant (i.e., $u(x,0)$ is independent of $x$), the interior condition at $t = 0$ forces $a = \frac12$ and you're back where you started. More generally, if $u(x,0) = a$ and $v(x,0) = b$ (both constants), the interior condition requires that $a + b = 1$, and the solution to the ODEs is $u(x,t) = a$ and $v(x,t) = b$ for all $x$ and $t$. $\endgroup$ Sep 23, 2021 at 20:03

1 Answer 1


If you provide enough initial and boundary conditions for a PDE, then there are various theorems proving that the solution is uniquely determined. For your equations, a solution is uniquely determined if you provide two initial conditions (since there are two functions and the highest derivatives in $t$ are first-order) and four boundary conditions (since there are two functions and the highest derivatives in $x$ are second order.)

You have provided a sufficient number of initial and boundary conditions, so there will be one unique solution without imposing the "interior condition." If this unique solution satisfies your "interior condition", great! But NDSolve will generally find (a numerical approximation to) this unique solution without your needing to impose this extra condition by hand. If, on the other hand, the unique solution does not satisfy the "interior condition", then there are simply no functions that satisfy all of the equations you have imposed, and you must weep and wail and gnash your teeth.

So in principle, you could just run NDSolve without imposing these conditions and then check whether the interior condition holds. In this case, you would run the code:

intcond[t_] := Integrate[(u[x, t] + v[x, t]) /. First[sol], {x, 0, 1}] - 1
Plot[intcond[t], {t, 0, 1}]

If the interior condition is satisfied at all $t$, then this plot should be close to 0. And it is!

enter image description here

In fact, the solution to your equations without imposing the interior condition is $u(x,t) = v(x,t) = \frac12$ for all $x$ and $t$; and NDSolve returns (a numerical approximation to) this solution when you run your code. It is fairly obvious to see that it satisfies the boundary conditions.

However, for a general set of initial conditions $u(x,0) = u_0(x)$ & $v(x,0) = v_0(x)$, it is unlikely that this interior condition will be satisfied. In particular, if the interior condition holds for all $t$, then we have \begin{align} \frac{d}{dt} \left[ \int_0^1 (u+v) dx \right] &= 0 \\ \int_0^1 (\partial_t u+ \partial_t v) dx &= 0\\ \int_0^1 \left[ \partial_{xx} u + \partial_{xx} v - \frac{2x+1}{1+x} u(1 - u - v) - v (1 - u - v) \right] dx &= 0\\ - \int_0^1 \left[ \left( \frac{2x+1}{1+x} u + v \right)(1 - u - v) \right] dx &= 0 \end{align} (In the third step I have applied the ODEs; in the fourth step I have integrated the first two terms, which then vanish because $\partial_x u$ and $\partial_x v$ vanish on the boundaries.) It is unlikely that an arbitrary pair of functions $u_0$ and $v_0$ will satisfy this condition. However, I think that if they do satisfy this condition at $t = 0$ then the solution will automatically satisfy the interior condition for all $t \in [0,1]$.

  • $\begingroup$ That make sense. What if I make u0 to be a variable and try to find a solution so that it satisfies all conditions including the interior condition? Maybe I will change the problem. $\endgroup$
    – mathfun
    Sep 23, 2021 at 19:52
  • $\begingroup$ Nice analysis. However, you may have missed that @mathpur recently edited his question so that the integral equals 1 everywhere, which it does. $\endgroup$
    – bbgodfrey
    Sep 23, 2021 at 19:56
  • $\begingroup$ @bbgodfrey: Thanks for the heads-up. I have edited my answer to reflect the edited problem. $\endgroup$ Sep 23, 2021 at 20:28
  • $\begingroup$ Nice work, thank you $\endgroup$
    – mathfun
    Sep 24, 2021 at 22:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.