mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 09:48:32 +00:00
Minor revision to numerical integration code
This commit is contained in:
committed by
Thomas Krijnen
parent
2d14ad1667
commit
fdc0c0cbd1
@@ -40,11 +40,11 @@ namespace
|
||||
double integrate(double a, double b, unsigned n, std::function<double(double)> fn)
|
||||
{
|
||||
double area = 0;
|
||||
double h = (b - a) / (n + 1);
|
||||
for (auto i = 0; i < n; i++)
|
||||
double h = (b - a) / n;
|
||||
for (auto i = 1; i <= n; i++)
|
||||
{
|
||||
auto x1 = a + h * i;
|
||||
auto x2 = a + h * (i + 1);
|
||||
auto x1 = a + h * (i - 1);
|
||||
auto x2 = a + h * i;
|
||||
auto f1 = fn(x1);
|
||||
auto f2 = fn(x2);
|
||||
area += h * (f1 + f2) / 2.0;
|
||||
|
||||
Reference in New Issue
Block a user