Sunday 19 July 2015

The wave equation

Imagine you have an ideal string of length L and would like to find an equation that describes the oscillation of the string. Assuming the string is fixed at its ends and starts its motion in a known position f(x) the simplest assumption one can make is that the acceleration of each piece of the string is somewhat proportional to the curvature of the string as such:

im

We can express the considerations above in the following way:

clip_image002[5]

The equation above is a partial differential equation (PDE) called the wave equation and can be used to model different phenomena such as vibrating strings and propagating waves.The constant term C has dimensions of m/s and can be interpreted as the wave speed.
It turns out that the problem above has the following general solution

clip_image002[7]

The thing that strikes me about this equation is how powerful the solution is. To think about it, any function that has the argument x-ct or x+ct or a combination of both is a solution to the wave equation. This means that we can model a lot of different waves!  Furthermore, as you could probably spot, the general solution is a combination of a wave travelling to the left and one travelling to the right.
Assuming let’s try the following solution

clip_image002[17]

By implementing the equation in Python for a string of length 2pi and of speed 1 m/s we obtain the following animation:




The range of animation you can run is infinite. I tried out a couple of solutions:

Shortening the string, L=pi


Click here to download the code for the above video.

Trying out f(x-ct) + g(x+ct)= cos(x-ct)**3 + cos(x+ct)**3


Click here to download the code for the above video.

The solution

clip_image002[19]
yields the following:



Click here to download the code for the above video.

Note how the resulting wave (cyan) is the sum of two cosine waves travelling in opposite directions.

What happens if you input the f(x-ct) term only and set g = 0? Basically what you get is a single travelling wave. The same happens if f = 0 and g = g(x+ct).


Click here to download the code for the above video.

Hope this was entertaining and helpful!

9 comments:

  1. Hi Mic,
    Thank you for the interesting article. I really enjoyed the read.
    I have the following questions which I think worthwhile to pause and ponder by anyone.

    1. If a wave equation/differential equation has multiple solutions how do we select from them?. In the example given by you, the string can vibrate in different ways. So what determines whether the string vibration follow one solution or other?.

    2. Why would someone start with wave equation/differential equation and then solve it?. Why can't they directly mention the function which describes the string vibration of 2D waves?

    3. You have written, "the simplest assumption one can make is that the acceleration of each piece of the string is somewhat proportional to the curvature of the string". But how does one come up with this? by observation or by guessing?

    4. How can one solve the wave equation and reach the general solution?

    ReplyDelete
  2. Excellent Work Sir. Please carry on.

    ReplyDelete
  3. Hey man can you derive the equation for a wave 750m long with a wavelength of 0.572m and a positive amplitude of 0.143m and a negative amplitude of 0

    ReplyDelete
  4. I never animated in python before... but somehow the animation wont render on my system (I am getting an empty figure). any idea why?

    all I am getting is a warning.
    C:\Users\yairs\Anaconda3\lib\site-packages\matplotlib\animation.py:973: UserWarning: Animation was deleted without rendering anything. This is most likely unintended. To prevent deletion, assign the Animation to a variable that exists for as long as you need the Animation.

    ReplyDelete