Finite Differences Method for Physics

Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
9 replies · 2K views
fredrogers3
Messages
40
Reaction score
0

Homework Statement


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.

Homework 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

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:
Physics news on Phys.org
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 continuous case?

EDIT: I'm guessing you reported the end-to-end swing. In which case are you sure it's not right?
 
Last edited:
rude man said:
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 continuous case?

How do I attach via email on physics forum?
 
fredrogers3 said:
How do I attach via email on physics forum?

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.
 
rude man said:
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.

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.
 
fredrogers3 said:
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.

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

Now you'd better be able to explain why! :smile:
 
rude man said:
Well I have news for you. That result is correct.

Now you'd better be able to explain why! :smile:

Am I calculating what the "theoretical max extension" should be incorrectly?
 
rude man said:
Well, the mass swings from 0 to - 9.8, so what would you call the "max. extension"?

Wouldn't it be 9.8 then?