# Wolfram Language™

## Solve an Initial Value Problem for the Wave Equation

Specify the wave equation with unit speed of propagation.

In:= `weqn = D[u[x, t], {t, 2}] == D[u[x, t], {x, 2}];`

Prescribe initial conditions for the equation.

In:= `ic = {u[x, 0] == E^(-x^2), Derivative[0, 1][u][x, 0] == 1};`

Solve the initial value problem.

In:= `DSolveValue[{weqn, ic}, u[x, t], {x, t}]`
Out= The wave propagates along a pair of characteristic directions.

In:= ```DSolveValue[{weqn, ic}, u[x, t], {x, t}]; Plot3D[%, {x, -7, 7}, {t, 0, 4}, Mesh -> None]```
Out= Solve the initial value problem with piecewise data.

In:= ```ic = {u[x, 0] == UnitBox[x] + UnitTriangle[x/3], Derivative[0, 1][u][x, 0] == 0};```
In:= `DSolveValue[ {weqn, ic}, u[x, t], {x, t}]`
Out= Discontinuities in the initial data are propagated along the characteristic directions.

In:= ```DSolveValue[ {weqn, ic}, u[x, t], {x, t}]; Plot3D[%, {x, -7, 7}, {t, 0, 4}, PlotRange -> All, Mesh -> None, ExclusionsStyle -> Red]```
Out= Solve the initial value problem with a sum of exponential functions as initial data.

In:= ```ic = {u[x, 0] == E^(-(x - 6)^2) + E^(-(x + 6)^2), Derivative[0, 1][u][x, 0] == 1/2};```
In:= `sol = DSolveValue[ {weqn, ic}, u[x, t], {x, t}]`
Out= Visualize the solution.

In:= ```Plot3D[sol, {x, -30, 30}, {t, 0, 20}, PlotRange -> All, Mesh -> None, PlotPoints -> 30]```
Out= 