From 21ab12cc9cb402ba7dcb36177077021954ca3f60 Mon Sep 17 00:00:00 2001 From: opfez Date: Wed, 26 Oct 2022 10:28:05 +0200 Subject: [PATCH] small algorithm to approximate an integral --- integral-approx.hs | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 integral-approx.hs diff --git a/integral-approx.hs b/integral-approx.hs new file mode 100644 index 0000000..9a1dcc4 --- /dev/null +++ b/integral-approx.hs @@ -0,0 +1,7 @@ +f x = x * x + +n = 10000 + +integral f startX endX = + sum $ map (\x -> squareLen * f (x * squareLen)) [1..n] + where squareLen = (endX - startX) / n