polygon_area

std.geometry.polygon_area · Level L2

Signed area of a polygon by the shoelace formula: positive when the vertices run counter-clockwise. The next vertex of each one comes from joining P[1:] and P[:1].

½·Σᵢ (xᵢ·yᵢ₊₁ − xᵢ₊₁·yᵢ), index n ≡ 0

Signature

polygon_area(P: f64[n, 2]) → f64[]

Structure

The function as NOVA stores it: one box per input, operation and output, and arrows that carry values. A double border marks another library function this one runs — called once, or by Scan once per element; select it to open that function.

Pf64[n, 2]SlicerestSlicefirstSlicexSliceyConcatQSliceynSlicexnMultiplyaMultiplycSubtractcrossReduceSumtotal2.0Divideareaareaf64[]
  • input
  • operation
  • constant
  • call
  • output

Verification

  • Signature proven by NOVA’s shape solver, for every size.
  • Equal to the reference 0.5 * np.sum(x * np.roll(y, -1) - np.roll(x, -1) * y) in exact rational arithmetic, on all 40 test cases.
  • All 40 float64 results inside the running error bound; the closest uses 24% of it.
  • Interpreter and NumPy backend return bit-identical results.
Accuracy in detail
correctly rounded (the float64 nearest the exact value)
85%
bit-equal to the NumPy formula in float64
100%
largest error, in units in the last place
17

Large ulp counts appear only where cancellation drives a result toward zero; the absolute error is still inside the bound.

Identity

Calls
—
Called by
—
sha256:77cfdb73ef5ad13aaeae438c80ec03f77bdb52044963dd314703a127c1bf8399

The semantic hash of the graph. It changes when the program changes, and never when only its documentation does.