- #106
jbriggs444
Science Advisor
Homework Helper
- 12,903
- 7,563
Fair enough. But my mind boggles at the length of the equations you are producing when your main loop should be something simple like:ROOT0X57B said:I don't want to solve a differential equation, I want to simulate it with programming :
I will set ##v_0## and the others parameters and will calculate ##v## and ##x## at each point by increments of time small enough so that ##\text{d}v## doesn't change a lot, this will give me a plot of distance traveled over time.
Vanilla Euler:
10 x = x + v * delta_t
20 v = v + a * delta_t
30 t = t + delta_t
40 print t, v, x
50 go to 10
More accurate:
10 x = x + v * delta_t + 1/2 * a * delta_t^2
20 v = v + a * delta_t
30 t = t + delta_t
40 print t, v, x
50 go to 10
If ##a## is the key input that you need for your main loop then ##a## is the constant that you should be using your equations to solve for. It is dead easy to solve for. ##a=\frac{F_e}{M_e}##. It falls straight out of Newton's second law.
Last edited: