This commit is contained in:
Vyacheslav Matyukhin 2022-09-20 03:06:56 +04:00
parent 5cf17f5dbf
commit cdc49b378a
No known key found for this signature in database
GPG Key ID: 3D2A774C5489F96C

View File

@ -1,13 +0,0 @@
integrate(fun, min, max) = {
// assume that min and max are integers.
epsilon = 1
l = max - min
meanF(t) = fun(t)
intervals = map(List.upTo(0, (l/epsilon)), ({|n| min + n*epsilon}))
values = map(intervals, ({ |x | meanF(x)}))
result = reduce(values, 0, ({|acc, x| acc + x})) * epsilon
result
}
f(x) = x
integrate(f, 1, 100k)