Skip to content

Instantly share code, notes, and snippets.

@tatyusa
Created March 3, 2014 09:09
Show Gist options
  • Save tatyusa/9321192 to your computer and use it in GitHub Desktop.
Save tatyusa/9321192 to your computer and use it in GitHub Desktop.
Simulation of van der pol equation
{-
van der Pol Equation
http://mathworld.wolfram.com/vanderPolEquation.html
dx/dt = y
dy/dt = m(1-x^2)y - x
-}
type R2 = (Double, Double) --(x, y)
van_der_pol :: Double -> Double -> R2 -> R2
van_der_pol mu dt (x, y) = (x+dx, y+dy)
where
dx = dt * y
dy = dt * (mu*(1-x**2)*y - x)
main = do
let result = let expansion = van_der_pol 0.5 0.01
in take 5000 $ iterate expansion (2,2)
mapM_ putStrLn $ map form result
where form (x,y) = (show x)++", "++(show y)
@tatyusa
Copy link
Author

tatyusa commented Mar 3, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment