Science
vfinance
Present and future value, NPV, IRR, loan schedules and compound interest.
Released v1.0.0 · 2026-09-28use "stdlib/finance.ven"
Present and future value, net present value, internal rate of return, loan schedules and compound interest, in plain period by period arithmetic.
print round(present_value(1100, 0.1, 1), 2)
:: 1000.0
Reference (8 functions)
API reference
present_value(future_value, rate, periods)
Discounts a single future cash amount back to its value today.
round(present_value(1100, 0.1, 1), 2)
:: 1000.0future_value(present_value, rate, periods)
Projects a present cash amount forward to its value after compounding.
future_value(1000, 0.1, 1)
:: 1100.0net_present_value(rate, cash_flows)
Discounts every cash flow in cash_flows back to today and sums the result.
round(net_present_value(0.1, [-1000, 600, 600, 600]), 2)
:: 492.11internal_rate_of_return(cash_flows)
Finds the discount rate at which cash_flows has a net present value of zero.
round(internal_rate_of_return([-1000, 1100]), 4)
:: 0.1loan_payment(principal, annual_rate, periods)
Computes the fixed periodic payment that fully amortizes a loan.
round(loan_payment(100000, 0.005, 12), 2)
:: 8606.64amortization_schedule(principal, annual_rate, periods)
Builds a full period by period amortization schedule for a loan.
amortization_schedule(1000, 0.05, 3)
:: [(367.21, 50.0, 317.21, 682.79), (367.21, 34.14, 333.07, 349.72), (367.21, 17.49, 349.72, 0.0)]compound_interest(principal, annual_rate, times_per_year, years)
Compounds principal at annual_rate, applied times_per_year times a year, over years years.
compound_interest(1000, 0.05, 1, 1)
:: 1050.0compound_annual_growth_rate(start_value, end_value, years)
Computes the constant annual growth rate that takes start_value to end_value over years years.
compound_annual_growth_rate(100, 200, 1)
:: 1.0