Wave Equation Plot with Mathematica: Solutions for Different Regions and Time

Click For Summary
SUMMARY

The discussion focuses on plotting the wave equation defined by the piecewise function in Mathematica. The function is defined for different regions (R1 to R6) based on the values of x and t. Users encountered issues with their initial attempts to plot the function using the Manipulate and Plot commands. A suggested solution involves using If statements to define the function more explicitly, ensuring that the conditions for each region are clearly stated.

PREREQUISITES
  • Understanding of wave equations and piecewise functions.
  • Familiarity with Mathematica syntax and functions.
  • Knowledge of the Manipulate and Plot functions in Mathematica.
  • Basic concepts of conditional statements in programming.
NEXT STEPS
  • Explore advanced plotting techniques in Mathematica, such as using ListPlot and DensityPlot.
  • Learn about defining complex piecewise functions in Mathematica.
  • Investigate the use of If statements versus Piecewise for function definitions.
  • Study the implications of different boundary conditions on wave equations.
USEFUL FOR

Mathematics students, physicists, and software developers interested in visualizing wave equations using Mathematica.

Dustinsfl
Messages
2,217
Reaction score
5
$$
u(x,t) = \frac{1}{2}\int_{x - t}^{x + t}g(s)ds = \begin{cases}
t, & (x,t)\in R_1\\
\frac{1}{2}(1 - x + t), & (x,t)\in R_2\\
\frac{1}{2}(x + t + 1), & (x,t)\in R_3\\
1, & (x,t)\in R_4\\
0, & (x,t)\in R_5,R_6
\end{cases}
$$
where
\begin{alignat*}{3}
R_1 & = & \{(x,t):-1 < x - t < 1\text{ and } -1 < x + t < 1\}\\
R_2 & = & \{(x,t):-1 < x - t < 1\text{ and } x + t > 1\}\\
R_3 & = & \{(x,t):x - t < -1\text{ and } -1 < x + t < 1\}\\
R_4 & = & \{(x,t):x - t < -1\text{ and } x + t > 1\}\\
R_5 & = & \{(x,t):x + t < -1\}\\
R_5 & = & \{(x,t):x - t > 1\}
\end{alignat*}

How do I plot this in the Mathematica?
I tried this but it doesn't work.
Code:
u[x_, t_] = 
  Piecewise[{{t, -1 < x - t < 1 And - 1 < x + t < 
      1}, {1/2 (1 - x + t), -1 < x - t < 1 And x + t > 
      1}, {1/2 (x + t + 1), x - t < -1 And - 1 < x + t < 1}, {1, 
     x - t < -1 And x + t > 1}, {0, x + t < -1}, {0, x - t > 1}}];
Manipulate[Plot[u[x, t], {x, -10, 10}], {t, 0, 1, .01}]
 
Last edited:
Physics news on Phys.org
I would probably use If statements to define the function. Something like this:

Code:
u[x_,t_]=If[-1<x-t && x-t<1 && -1<x+t && x+t<1,t,
If[-1<x-t && x-t<1 && x+t>1,(1/2)(1-x+t),
...
...]]
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 8 ·
Replies
8
Views
2K
Replies
6
Views
2K