## Transcribed Text

7.
(COMPUTER) In the case of plane-wave propagation in the x direction within
a uniform medium, the homogeneous momentum equation (3.9) for shear waves
can be expressed as
azu = B2 a²u ax²'
where u is the displacement. Write a computer program that uses finite differences
to solve this equation for a bar 100 km in length, assuming B = 4km/s. Use
dx = 1 km for the length spacing and dt = 0.1s for the time spacing. Assume a
source-time function at u (50km) of the form
uso(t) = sin2(tt/5),0 <t <5s.="<br">Apply a stress-free boundary condition at u (0km) and a fixed boundary condi-
tion at u (100km). Approximate the second derivatives using the finite difference
3.10 EXERCISES
63
scheme:
alu =
Plot u(x) at 4s intervals from 1 to 33s. Verify that the pulses travel at velocities
of 4 km/s. What happens to the reflected pulse at each endpoint? What happens
when the pulses cross?
Hint: Here is the key part of a FORTRAN program to solve this problem:
(initialize t, dx, dt, tlen, beta and ul,u2,u3 arrays)
10
t=t+dt
do i=2,100
rhs=beta* 2* (u2 (i+1)-2. *u2 (i) +u2 (i-1)) /dx**2
u3(i)=dt**2*rhs+2.*u2(i)-ul(i)
enddo
u3(1)=u3(2)
u3 (101) =0.
if t.le.tlen) then
u3 (51) (3.1415927*t/tlen) **2
end if
do i=1, 101
ul (i) =u2(i)
u2 (i)=u3(i)
enddo
(output u2 at desired intervals, stop when t is big
enough)
go to 10
</t>

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction
of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice.
Unethical use is strictly forbidden.

% Given:

clear all;

close all

clc;

t=0; dt = 0.1; dx = 1;

tlen = 5;

beta = 4;

tol = 1e-4;

Xlen = 100;

tend = 33;

n = (Xlen/dx)+1; %n is the number of nodes

%initializing u1,u2

u1 = zeros...