# Finite Differences Method for Physics

1. Apr 9, 2013

### fredrogers3

1. The problem statement, all variables and given/known data
I am to first write a differential equation that describes a hanging mass influenced by gravity and then write the finite differences equation. Then, the problem asks me to graph this numerical solution and make sure that maximum extension of the spring that I derive matches that of the finite differences result.

2. Relevant equations
The Differential equation is: m*(d^2x/dt^2)=-kx-mg
The second derivative is approximately equal to (Xn+1-2Xn+Xn-1)/Δt^2
Solved for Xn+1=

Xn+1=Δt^2*((-kXn-mg)/m)+2Xn-Xn-1

m=1kg
delta t= .1
3. The attempt at a solution
I worked out all of the above in the relevant equations section. I set k=2 (we were allowed to pick any value), so the max extension = 9.8/2 = 4.9

I did the finite differences on Excel but did not get 4.9 (or -4.9 if down is negative) as a max displacement. I got around 9.8. Anyone see my error?

Thanks

Last edited: Apr 9, 2013
2. Apr 9, 2013

### rude man

If you write mx'' = -kx - mg you are ipso facto calling x = 0 where the spring is relaxed. So now you're holding the mass attached to the spring at initial condition x = 0 and letting go. In other words, you are applying an initial condition F = -mg and then running the diff. eq. What will the mass do? Between what values of x will it vibrate?

I also ran an Excel (I used T = 0.01s.) and got about the right swing extrema.

If you want you can e-mail me your run. I use excel 2003 so I hope we'd be compatible. Or describe your program in detail. Also, what is your time response for the continous case?

EDIT: I'm guessing you reported the end-to-end swing. In which case are you sure it's not right?

Last edited: Apr 9, 2013
3. Apr 9, 2013

### fredrogers3

How do I attach via email on physics forum?

4. Apr 9, 2013

### rude man

Before you do that, what is your solution to the differential equation? And what were the end-points of your excel mass swing? I suspect your simulation's OK.

5. Apr 9, 2013

### fredrogers3

I found the numerical solution rather than the analytical solution, thus I didn't solve the Diffeq. I plugged into Excel what I have under the "relevant equation" section solved for Xn+1. My graph comes out as a cosine graph with min -9.81192 and max zero. I took n from -1 to 100.

6. Apr 9, 2013

### rude man

Well I have news for you. That result is correct.

Now you'd better be able to explain why!

7. Apr 9, 2013

### fredrogers3

Am I calculating what the "theoretical max extension" should be incorrectly?

8. Apr 9, 2013

### rude man

Well, the mass swings from 0 to - 9.8, so what would you call the "max. extension"?

9. Apr 9, 2013

### fredrogers3

Wouldn't it be 9.8 then?

10. Apr 9, 2013

### rude man

I would argue no.
Max. extension = 4.9, max. compression = 4.9, total swing = 9.8.