-
-
Save angs/0cccfd2b85aceb31feca4afb53ed2978 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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