Saturday, 28 September 2013

Differential equation numerical solution

Differential equation numerical solution

I have a differential equation(linear or non-linear), for example:
y''+2y'+y=0. When I try this code to solve it numerically:
ds=0.0001 ; y=1 ; y_prime=1
for i=1 to 10000
y_prime_next=y_prime_next+(-2*y_prime_next-y_next)*ds
y_next=y+y_prime_next*ds
y_prime=y_prime_next
y=y_next
next i
it does not produce the correct result. Why isn't this method working?

No comments:

Post a Comment