Numerical solution to a partial differential equation

Click For Summary
SUMMARY

The discussion focuses on solving the inhomogeneous partial differential equation using the NDSolve function in Mathematica. The correct formulation of the equation requires adjustments, specifically changing the sign in front of the term involving u^5 and ensuring that all parameters, such as 'a', are assigned constant numeric values before execution. The initial conditions must also be properly defined using u[0, x] == Tanh[x] and Derivative[1, 0][u][0, x] == 0. Following these corrections allows for successful execution and plotting of the solution.

PREREQUISITES
  • Understanding of partial differential equations (PDEs)
  • Familiarity with Mathematica and its NDSolve function
  • Knowledge of initial and boundary conditions in PDEs
  • Basic programming skills in Mathematica syntax
NEXT STEPS
  • Review Mathematica documentation on NDSolve for PDEs
  • Learn about defining and using parameters in Mathematica
  • Explore techniques for validating numerical solutions of PDEs
  • Study common errors and debugging strategies in Mathematica
USEFUL FOR

Mathematics students, researchers in computational physics, and anyone working with numerical methods for solving partial differential equations.

Catria
Messages
145
Reaction score
4

Homework Statement



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

Homework Equations



Initial conditions:

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

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...
 
Physics news on Phys.org
You have a few problems.

You appear to be missing a minus sign in front of

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]

and your second boundary condition

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:

Similar threads

  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 12 ·
Replies
12
Views
2K
Replies
6
Views
3K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 105 ·
4
Replies
105
Views
11K
  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
Replies
8
Views
1K
  • · Replies 7 ·
Replies
7
Views
2K