Skip to content

Instantly share code, notes, and snippets.

@jtobin
Created November 7, 2012 01:24
Show Gist options
  • Save jtobin/4028961 to your computer and use it in GitHub Desktop.
Save jtobin/4028961 to your computer and use it in GitHub Desktop.
Stochastic partial differential equation
target :: [Double] -> Double
target xs = go 0 0 xs
where go t0 t1 [] = -0.5 * t0 / h - 0.5 * h * t1
go t0 t1 (u:us:uss) = go (t0 + (us - u)^2) (t1 + v (us + u)) uss
h = 1 / fromIntegral (length xs)
v x = (1 - x^2)^2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment