# NDsolve of partial differential equation - integral of the function [duplicate]

I am try to solve the following differential equation numerically: $$\frac{\partial p}{\partial t}=\frac{\partial^2 p}{\partial x^2}-e^{-t}\frac{\partial p}{\partial x}$$ with boundary conditions $p(x=0,t)=p(x=L,t)=0$ and initial condition $p(x,0)=\delta(x-x_0)$. I am also interested in computing the quantity: $$q(t)=\int_0^L p(x,t)dx$$ which satisfies the equation: $$q(t)=\frac{\partial p}{\partial x}(L,t)-\frac{\partial p}{\partial x}(0,t)$$ with initial condition $q(0)=1$.

I have tried the following in Mathematica:

NDSolve[{D[p[x, t], {t, 1}] == D[p[x, t], {x, 2}] - Exp[-t] D[p[x, t],x],
p[0, t] == 0, p[L, t] == 0,
p[x, 0] == 1/Sqrt[2 Pi sigma^2] Exp[-(x-x0)^2/(2 sigma^2)],
q'[t]==D[p[L, t], x] - D[p[0, t], x],q[0]==1},
{p[x, t],q[t]}, {x, 0, L}, {t, 0, T}]


Note that I have approximated the initial delta-function condition with a Gaussian. When I run this code I get the error:

Function::fpct: Too many parameters in {x,t} to be filled from Function[{x,t},1][t].


Could you help me to understand why? Thank you

• What are the numerical values for x0, L, T and sigma? – zhk May 15 '17 at 16:32
• What is p^{0, 1}[L, t] ? – rhermans May 15 '17 at 16:32
• I use sigma=1/32, L=10, T=1. The derivative p^{1,0} is the first derivative with respect to x (there was a mistake in the previous formula), I don't know how to write it properly here sorry – Andrea May 15 '17 at 16:34
• I think you mean D[p[x, t], {x, 1}] ? – rhermans May 15 '17 at 16:36
• it's D[p[x,t],{x,1}], but evaluated at x=0 and x=L, I have now updated the code above thank you (the error is still the same) – Andrea May 15 '17 at 16:36

sigma = 1/32; x0 = 1; L = 10; T = 1;