functionareaLineSegment
Calculate the area under a line segment
Extends from Function (Icon for functions).
Information
This information is part of the Business Simulation Library (BSL). Please support this work and ► donate.
The output y is the area under a line given by two points p1, p2 which are assumed to be either both above or both below the abscissa, i.e., the ordinates of the points have the same sign.
Syntax
Functions.areaLineSegment(p1, p2);
Implementation
y := abs((p2[1] - p1[1]) * (p1[2] + p2[2]) / 2);
Examples
areaLineSegment({1,1},{2,1}); // 1.0
areaLineSegment({1,1},{2,2}); // 1.5
Inputs
| Type | Name | Default | Description |
|---|---|---|---|
| Real | p1 | ||
| Real | p2 | Points whose ordinates have the same sign |
Outputs
| Type | Name | Default | Description |
|---|---|---|---|
| Real | y | Area between the abscissa and the line within the closed interval [p1[1], p2[1]] |
Revisions
- Introduced in v2.1.0.