Hamilton LaboratoriesHamilton C shell 2012User guideSamples

finance.csh

Oregon Coast

finance.csh
Previous | Next

#  Calculate various financial factors related to the "time value of money".
#  Copyright (c) 1989-2012 by Hamilton Laboratories.  All rights reserved.

proc PV_FutureAmount(i, n)
   #  Calculate the multiplier to convert $1 in period n to a
   #     present value, given interest rate i% per period.
   return 1/(1 + i/100)**n
end

proc FV_PresentAmount(i, n)
   #  Calculate the multiplier to convert $1 now to a
   #     future value, given an interest rate i% per period.
   return (1 + i/100)**n
end

proc PV_Annuity(i, n)
   #  Calculate the multiplier to convert $1 paid each period for n periods
   #     to a present value, given an interest rate i% per period.
   local j
   @ i /= 100
   @ j = (1 + i)**n
   return (j - 1)/(i*j)
end

proc Annuity_PV(i, n)
   #  Calculate the multiplier to convert $1 in present value into an amount
   #     paid each period for n periods, given an interest i% per period.
   local j
   @ i /= 100
   @ j = (1 + i)**n
   return (i*j)/(j - 1)
end

proc FV_Annuity(i, n)
   #  Calculate the multiplier to convert $1 paid each period for n periods
   #     to a future value, given an interest rate i% per period.
   @ i /= 100
   return ((1 + i)**n - 1)/i
end

proc Annuity_FV(i, n)
   #  Calculate the multiplier to convert $1 in future value into an amount
   #     paid each period for n periods, given an interest rate i% per period.
   @ i /= 100
   return i/((1 + i)**n - 1)
end

proc Periods_PV(i, PV)
   #  Calculate the multipler to convert an annuity of $1 paid each period,
   #     given present value and interest rate, to a number of periods.
   @ i /= 100
   return ceil(-(log(1/i - PV) + log(i))/log(i + 1))
end

proc Periods_FV(i, FV)
   #  Calculate the multipler to convert an annuity of $1 paid each period,
   #     given future value and interest rate, to a number of periods.
   @ i /= 100;
   return ceil(log(i*FV + 1)/log(i + 1))
end

Previous | Next