npv
std.seq.npv · Level L2The net present value of a cash flow c₀, c₁, … at one per period, at rate i per period: Σ cₜ/(1 + i)ᵗ, with c₀ undiscounted. Computed as the discounted return at factor 1/(1 + i), by Horner's rule from the last cash flow back.
Signature
npv(c: f64[T], i: f64[]) → 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.
- input
- operation
- constant
- call
- output
Verification
- Signature proven by NOVA’s shape solver, for every size.
- Equal to the reference
sum(c[t] / (1 + i)**t)in exact rational arithmetic, on all 40 test cases. - All 40 float64 results inside the running error bound; the closest uses 47% of it.
- Interpreter and NumPy backend return bit-identical results.
- At float32 too: the 40 test cases rounded to float32, and 40 of them inside the running error bound at u = 2⁻²⁴; the closest uses 27% of it.
- correctly rounded (the float64 nearest the exact value)
- 73%
- bit-equal to the NumPy formula in float64
- 65%
- largest error, in units in the last place
- 17
Large ulp counts appear where a result is tiny next to the numbers it is computed from (after cancellation, for example), so one unit in the last place is tiny too; the absolute error is still inside the bound. Results within their own error of zero are not counted.
Identity
sha256:31da393c8a9f16100825f5719efc54b2dc198dc50adb6744f364814643041fd8The semantic hash of the graph. It changes when the program changes, and never when only its documentation does.
Control handle
- Symbol
- Ω:std.seq.npv · Ω:npv
- Pins
sha256:16abd86fba70e48dfe9d0d19fac3875f07bcf58e7cce4fd5f475e7e1496fc977this graph and the 2 it reaches through calls- Evidence
sha256:02fb74fc962d12ec7032a82bd1a98bbc74be151238c58b2297b5bd2524a97229the hash of its verification record- Needs
- no capability: a pure function
Through NOVA’s control layer, the symbol launches this function only while the program still matches what it pins: a change to this graph, or to any graph it reaches, needs a migration first.