
Physics Program--Haven't Programmed in years
I need help finishing or readjusting a code using the Runge-Kutta
algorithim.
I have some code which i wrote with a text editor... When I Import the
code to Visual Basic--it gives errors.
So I used qbasic and it ran fine.
I need to make the program an exe which I only know how to do with visual
basic.
Also, I need simple graphic output of 'vv' vs. 'tt'. If anyone could help
on that I would appreciate it.
Here is my code for the Runge Kutta alg.
------------------------------------------
INPUT "x (suggested initial value-0)"; xx
INPUT "v (suggested initial value-0)"; vv
INPUT "t (suggested initial value-0)"; tt
INPUT "A (suggested value-2)"; A
INPUT "B (suggested value-2)"; B
INPUT "stepsize (suggested value-0.5)"; h
INPUT "number of steps (suggested value-20)"; nstep
h2 = h / 2: h6 = h / 6
For i = 1 To nstep
x = xx: v = vv: t = tt: GoSub 500: p1 = xp: q1 = vp
x = xx + h2 * p1: v = vv + h2 * q1: t = tt + h2: GoSub 500: p2 = xp: q2 =
vp
x = xx + h2 * p2: v = vv + h2 * q2: t = tt + h2: GoSub 500: p3 = xp: q3 =
vp
x = xx + h * p3: v = vv + h * q3: t = tt + h: GoSub 500: p4 = xp: q4 = vp
xx = xx + h6 * (p1 + 2 * (p2 + p3) + p4)
vv = vv + h6 * (q1 + 2 * (q2 + q3) + q4)
tt = tt + h
Print tt, xx, vv
Next
End
500 xp = v
vp = A - B * v
Return
This is where I am on the graphical output.
----------------------------------------
......
PSet (tt%, vv%)
----------------
I really have no idea on the graph part :-(
--
Posted via CNET Help.com
http://www.*-*-*.com/