# Numerical solution to a partial differential equation

1. Feb 3, 2014

### Catria

1. The problem statement, all variables and given/known data

Solve the inhomogenous partial differential equation $\frac{∂^{2}u}{∂t^{2}}-\frac{∂^{2}u}{∂x^{2}}=-6u^{5}+(8+4ε)u^3-(2+4ε)u$ by using the NDSolve function in Mathematica for the interval [0,10] x [-5,5].

2. Relevant equations

Initial conditions:

u(0,x)= tanh(x)
u'(0,x)= 0

3. The attempt at a solution

NDSolve[{D[u[t, x], t, t] - D[u[t, x], x, x] ==
6 u^5 + (8 + 4 a) u^3 - (2 + 4 a) u, u[t, x] /. t -> 0 == Tanh[x],
D[u[t, x], t] /. t -> 0 == 0, u}, u[t, x], {t, 0, 10}, {x, -5, 5}]

But when I enter this into Mathematica, I get the message NDSolve::deqn: "Equation or list of equations expected instead of u[0==Tanh[x],x] in the first argument...

2. Feb 5, 2014

### Bill Simpson

You have a few problems.

6 u^5

and this

6 u^5 + (8 + 4 a) u^3 - (2 + 4 a) u

should be this

-6 u[t, x]^5 + (8 + 4 a) u[t, x]^3 - (2 + 4 a) u[t, x]

which is a very common mistake that newer users make

and this

u[t, x] /. t -> 0 == Tanh[x]

should probably be this

u[0, x] == Tanh[x]

D[u[t, x], t] /. t -> 0 == 0

might perhaps be

Derivative[1, 0][0, x] == 0

But I don't think that is enough to resolve your boundary condition problems because with these changes I'm getting a "non-numerical" complaint about derivatives when t is 0 and I can't track that down.

Unfortunately at the moment my Mathematica PDE brain cells are hiding and I can't find them. Hopefully either these will be enough hints to help you solve this or I will track down what I've forgotten and provide a little more assistance.

Ah, what was I thinking, I should have caught this instantly. Inside NDSolve all parameters are going to have to have been assigned constant numeric values, so your parameter a without a defined value isn't going to pass. If I put

a=1;

in front of your NDSolve then the "non-numerical" complaint goes away, that may have been because of your variable, but with this

a = 1;
sol = NDSolve[{D[u[t,x], {t,2}]-D[u[t,x], {x,2}] == -6 u[t,x]^5 + (8+4 a) u[t,x]^3-(2+4 a) u[t,x],
u[0, x] == Tanh[x], Derivative[1, 0][0, x] == 0},
u[t, x], {t, 0, 10}, {x, -5, 5}][[1, 1]];
Plot3D[u[t, x] /. sol, {t, 0, 10}, {x, -5, 5}]

does provide a plot, correct or probably not.

Now there is a lot more work for you to do to deal with the error and warning messages and all the rest.

You want to test all this very carefully when you are done to make certain the result is correct.

Last edited: Feb 5, 2014