N
APR/12
Annuity Calculation in Excel
Function AnnuityToPvRatio(i As Double, N As Integer) As Double Dim fp As Double fp = FutureToPvRatio(i, N) AnnuityToPvRatio = (i * fp) / (fp - 1) End Function Function FutureToPvRatio(i As Double, N As Integer) As Double FutureToPvRatio = (1 + i) ^ N End Function
i (1+i)^N A/P = --------------- (1+i)^N - 1 i (F/P) = ------------- (F/P) - 1 Solving for N, -log(1 - PI/A) N = ---------------- log(1 + I)
create or alter function dbo.AnnuityPaymentQty( @apr decimal(20,10) ,@p decimal(20,10) ,@a decimal(20,10) ) returns int as begin /*-------------------------------------*/ /* declare @apr decimal(20,10) = 0.08 ,@p decimal(20,10) = 10000 ,@a decimal(20,10) = 202.76 -- Expected result: 60 */ /*-------------------------------------*/ declare @interest decimal(20,10) = @apr / 12.0 declare @n int = -log(1-(@p*@interest/@a)) / log(1 + @interest) return @n end
ScrewTurn Wiki version 3.0.1.400. Some of the icons created by FamFamFam. Except where noted, all contents Copyright © 1999-2024, Patrick Jasinski.