From 50ff1f7f31d0a3d96c2b691e605a4c61d51dc5cd Mon Sep 17 00:00:00 2001 From: vaishnavi902 Date: Fri, 20 Feb 2026 00:23:51 +0530 Subject: [PATCH 1/2] Added comment --- maths/area_under_curve.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/maths/area_under_curve.py b/maths/area_under_curve.py index 10aec768fa09..3edcd15dded8 100644 --- a/maths/area_under_curve.py +++ b/maths/area_under_curve.py @@ -6,7 +6,7 @@ from collections.abc import Callable - +# The trapezoidal rule is a numerical method to approximate the area under a curve def trapezoidal_area( fnc: Callable[[float], float], x_start: float, @@ -33,17 +33,17 @@ def trapezoidal_area( >>> f"{trapezoidal_area(f, -4.0, 4.0, 10000):.4f}" '384.0000' """ - x1 = x_start + xone = x_start fx1 = fnc(x_start) area = 0.0 for _ in range(steps): # Approximates small segments of curve as linear and solve # for trapezoidal area - x2 = (x_end - x_start) / steps + x1 + x2 = (x_end - x_start) / steps + xone fx2 = fnc(x2) - area += abs(fx2 + fx1) * (x2 - x1) / 2 + area += abs(fx2 + fx1) * (x2 - xone) / 2 # Increment step - x1 = x2 + xone = x2 fx1 = fx2 return area From d54d51420da9c94d4982e595cc483e0af330e9df Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 19 Feb 2026 18:57:24 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- maths/area_under_curve.py | 1 + 1 file changed, 1 insertion(+) diff --git a/maths/area_under_curve.py b/maths/area_under_curve.py index 3edcd15dded8..cc45dcad010a 100644 --- a/maths/area_under_curve.py +++ b/maths/area_under_curve.py @@ -6,6 +6,7 @@ from collections.abc import Callable + # The trapezoidal rule is a numerical method to approximate the area under a curve def trapezoidal_area( fnc: Callable[[float], float],