Skip to content

Instantly share code, notes, and snippets.

@angs

angs/laplace.hs Secret

Last active November 7, 2016 18:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save angs/0cccfd2b85aceb31feca4afb53ed2978 to your computer and use it in GitHub Desktop.
Save angs/0cccfd2b85aceb31feca4afb53ed2978 to your computer and use it in GitHub Desktop.
import Data.List --for zipWith4
p f l h n=head.dropWhile((>1e-9).r).iterate j$0<$[1..n]
where
m=[0..]!!n
b=map((/(m-1)^2).f.(/(m-1)))[0..m-1]
r u=sqrt.sum.map(^2).tail$zipWith4(\a b c d->a+b+d-2*c)b(tail u)u(0:u)
j u=l:(tail$zipWith3(\a b c->0.5*(a+b+c))b(tail u)(0:u))++[h]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment