schattenjaeger said:
Ok, thanks! I'm using the second-order RK, btw...
for the actual differential equation...
A=F/m, A=d^2x/dt^2
introduce V=dx/dt
dx/dt=V
dv/dt=(-kx-10v)/m -did I fix that right?
Xo=.08, Vo = 0
so I have
dx/dt=v
dv/dt=(-kx-10v)/m
To solve for x(t)
k1=h*(v)
k2=h*.08+(h*v/2)
and here's where I see my problem, x should be the variable, not v, 'cuz I'm going to need to find X(n+1) and plug that into the Xn+k2 equation to find step after step, right?
I would write it out in vector notation (x,v). It's much easier to see that way.
As you said: vector(f(x,v)) = (v, (-kx - 10v)/m).
vector(k1) = h* (v_0, (-k*x_0 - 10*v_0)/m)
Now you need vector(k2). In order to calculate vector(k2), you need:
vector(x_0) + vector(k1)/2 =
(x_0,v_0) + (0.5 *h) * (v_0, (-k*x_0 - 10*v_0)/m) = Something simplified, call it "vector(a)" = (a1,a2)
Now, you need to calculate vector(f(vector(a))). That's equal to:
(a2, (-ka1 - 10a2)/m)
You know what a1, a2 are in terms of x0,v0, so you can rewrite f(vector(a)) in terms of x0, v0.
Then vector(k2) = h * f(vector(a)).
I hope you can take it from there.