# Plot graph of 1D wave equation (using d'Alembert's formula)

1. Oct 18, 2015

### whatisreality

1. The problem statement, all variables and given/known data
Don't know if this goes here or in the advanced bit, thought I'd try here first!

I know the general solution of a 1D wave equation is given by d'Alembert's formula

$u(x,t) = 0.5[u(x+vt,0) + u(x-vt,0)] + \frac{1}{2v} \int_{x-vt}^{x+vt} \frac{\partial u}{\partial t}(x,0) \mathrm dx$.

And I've been given that for my particular wave, $\frac{\partial u}{\partial t}(x,0)$ = 0 for all x, so that's nice because I don't have to worry about the integral in d'Alembert's.

I've also been given that u(x,0) is x+a for -a≤x≤0
and u(x,0) is a-x for 0≤x≤a
and 0 otherwise.

$a$ is a real positive constant.

Plot u(x,t) as a function of x at time t=2a/v.
2. Relevant equations

3. The attempt at a solution
My y axis is going to be labelled u(x) and my x-axis is x. I've subbed in t=2a/v into d'Alembert's, and got

$u(x, \frac{2a}{v}) = 0.5[u(x+2a,0) + u(x-2a,0)]$

So u(x+2a) = x+3a for -a≤x≤0
u(x-2a) = x-a for -a≤x≤0

Which means that for -a≤x≤0, my u(x) = 0.5(2x+2a) = x+a

Is that the right sort of thing to do? I'm pretty sure it's not, since it takes me back to where I started.I don't know how to make use of that set of conditions for -a≤x≤0 etc.

I'm really confused about how to plot this.

Last edited: Oct 18, 2015
2. Oct 18, 2015

### TSny

OK

I don't follow what you did here. Recall that if you know the graph of f(x), then you can easily plot the graph of f(x+b) where b is a constant. In this problem, you know the graph of u(x, 0) for all x. So, it should be easy to plot the graphs of u(x+2a, 0) and u(x-2a, 0).

3. Oct 18, 2015

### whatisreality

The graph I'm actually plotting is u(x, 2a/v), and I have no idea how that relates to u(x,0).

What I did here:
So I'm having to plot $u(x, \frac{2a}{v}) = 0.5[u(x+2a,0) + u(x-2a,0)]$

Then I tried to work out the values of u(x+2a,0) and u(x-2a,0) to sub into the equation for u(x, 2a/v). I did this using the constraints given: u(x,0) is x+a for -a≤x≤0

I'm working out u(x+2a,0), so I replaced x with x+2a to get u(x+2a,0) is (x+2a)+a for -a≤x≤0, and repeated the same process with (x-2a).

Then u(x, 2a/v) = 0.5[u(x+2a,0) + u(x-2a,0)] = 0.5( x+3a + x-a ) = x+a for -a≤x≤0.

I don't know how to plot y = x+a for -a≤x≤0. Or even if that's what I should be plotting.

4. Oct 18, 2015

### TSny

Recall, you have $u(x, \frac{2a}{v}) = 0.5[u(x+2a,0) + u(x-2a,0)]$.

5. Oct 18, 2015

### whatisreality

Oh, right, I see. I have trouble plotting u(x,0) in the first place though, which is why I did those calculations. I suppose both ways should give the same answer?

6. Oct 18, 2015

### whatisreality

Actually, to be more specific, I have trouble plotting u(x,0) because I'm not sure what

u(x,0) is x+a for -a≤x≤0

means for a graph, for example y=x+a for x between -a and 0? What does that look like? A horizontal line?

7. Oct 18, 2015

### TSny

It means that when x is greater than -a and less than 0, you want to graph the function y = x + a. You can see it's a linear function. So, the graph will be a straight line. What is the value of y at x = -a? What is the value at x = 0?

8. Oct 18, 2015

### whatisreality

I can't believe I even wrote that. I can definitely graph y = x+a! But I'd convinced myself I didn't know. It's the graph of y = x translated down by a, so at x = 0 y= -a and at x = 0 y = a. What an incredibly silly thing to do!

Thank you for being very patient and helping!

Last edited: Oct 18, 2015
9. Oct 18, 2015

### TSny

OK. I guess you meant to type at x = -a, y = 0.

Last edited: Oct 18, 2015
10. Oct 18, 2015

### whatisreality

Yes, I did. Sorry. Must be a sign, too late at night for maths.