MathGroup Archive 1998

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Newbe: Wave equation



> I got the trial version of Mathematica 3.0. One of the first problems I
> want to solve was (is) the wave equation:
> 
> I wrote the following lines:
> c[x_] := if[ (x > 0.5) && ( x < 0.75), 3, 2]; R = 2+0.5 I;
> solve = NDSolve{D[y[x, t], x, x]-D[y[x, t], t,
> t]/(c[x]*c[x])-D[y[x,t],t]/R==0,
>     y[x, 0] == 0, Derivative[0,1][y][x, 0] == 0,
>        y[0, t] == Cos[t],
>        y[1, t]==Exp[-1]}, y, {x, 0, 1}, {t, 0, 2*Pi}]
> 
> I received the message: <Equations may not give solutions for all
> "solve" variables>
> After further "research" I have discovered none solution was given
>
> Real "R" (instead of complex) do not change anything.
> 
> My question is:
> Is mathematica able to solve such simple equations? Any help?
> 
> If anyone knows the answer please write me on my e-mail address
> morawski@zsku.p.lodz.pl

Mathematica can solve this type of problem.  This particular example has
a few syntax errors and mathematical obstacles that need to be
addressed before the calculation can begin.

The "if" in

> c[x_] := if[ (x > 0.5) && ( x < 0.75), 3, 2]; R = 2+0.5 I;

should probably be "If", and there seems to be a missing square bracket
in

> solve = NDSolve{D[y[x, t], x, x]-D[y[x, t], t,
> t]/(c[x]*c[x])-D[y[x,t],t]/R==0,
>     y[x, 0] == 0, Derivative[0,1][y][x, 0] == 0,
>        y[0, t] == Cos[t],
>        y[1, t]==Exp[-1]}, y, {x, 0, 1}, {t, 0, 2*Pi}]

With these changes this input will generate a warning message about
inconsistent boundary and initial conditions:

In[1]:= c[x_] := If[ (x > 0.5) && ( x < 0.75), 3, 2]; R = 2+0.5 I;

In[2]:= solve = NDSolve[{D[y[x, t], x, x]-D[y[x, t], t,
        t]/(c[x]*c[x])-D[y[x,t],t]/R==0,
             y[x, 0] == 0, Derivative[0,1][y][x, 0] == 0,
                y[0, t] == Cos[t],
                y[1, t]==Exp[-1]}, y, {x, 0, 1}, {t, 0, 2*Pi}]

NDSolve::ibcinc: Warning: Boundary and initial conditions are
inconsistent.

Out[2]= {{y -> InterpolatingFunction[{{0, 1.}, {0., 6.28319}}, <>]}}

The warning message warns you that, since the boundary an initial
conditions in this example are inconsistent, they cannot all be used,
and will not all be reflected in the solution.

The condition y[x, 0] == 0 indicates that this function is initially
zero, and the condition Derivative[0,1][y][x, 0] == 0 indicates that
the function is initially not moving.

The condition y[0, t] == Cos[t], which indicates that y[0,0] is 1, is
inconsistent with the condition y[x, 0] == 0, which indicates that
y[0,0] is 0, and the condition y[1, t]==Exp[-1], which indicates that
y[1,0] is Exp[-1], is also inconsistent with the condition y[x, 0] ==
0.

If these conditions are thought of as limits, then y[0, t] == Cos[t]
indicates that the function changes instantly from 0 to 1 and one
endpoint, and the condition y[1, t]==Exp[-1] indicates that the
function changes instantly from 0 to Exp[-1] at the other endpoint. 
These inconsistencies (or instant changes) indicate that these boundary
and initial conditions are unphysical, and that (depending on
interpretation) the solution either does not exist or will contain
singularities.

If the conditions are changes to represent a physical situation, as in

solve = NDSolve[{D[y[x, t], x, x]-D[y[x, t], t,
        t]/(c[x]*c[x])-D[y[x,t],t]/R==0,
             y[x, 0] == 0, Derivative[0,1][y][x, 0] == 0,
                y[0, t] == Cos[t] - 1, y[1,t] == 0},
           y, {x, 0, 1}, {t, 0, 2*Pi}]

then the calculation will proceed without difficulty.

If you have an example that generates a message such as "Equations may
not give solutions for all solve variables" and you have a question
about the cause of that message, you might try sending your exact input
to Wolfram Research technical support (support@wolfram.com).  I am sure
that they could offer an explanation.

Dave Withoff
Wolfram Research



  • Prev by Date: Re: A Bug / Feature
  • Next by Date: Re: Return inside Do, For and While
  • Prev by thread: Newbe: Wave equation
  • Next by thread: Re: Newbe: Wave equation