Code:

<script>
i = 0.1/31536000;
n = 31536000;
pv = 0;
pmt = -0.01;
atype = 0;
document.write("Secondly payments, secondly compounding frequency of interest");
document.write("<br/>");
fv = FV(i,n,pmt,pv,atype);
document.write("FV(i= "+i+" n= "+n+" pmt= "+pmt+" pv= "+pv+" type= "+atype+") <br/>"+fv);
document.write("<br/>");
rate = RATE( n, pmt, pv, fv, atype)*n;
document.write("RATE(fv= "+fv+" n= "+n+" pmt= "+pmt+" pv= "+pv+" type= "+atype+") <br/>"+rate*100+"%");
document.write("<br/>");
document.write("<br/>");
i = 0.1/31536000/1000;
n = 31536000*1000;
pv = 0;
pmt = -0.01/1000;
atype = 0;
document.write("Milli-second payments, milli-second compounding frequency of interest");
document.write("<br/>");
fv = FV(i,n,pmt,pv,atype);
document.write("FV(i= "+i+" n= "+n+" pmt= "+pmt+" pv= "+pv+" type= "+atype+") <br/>"+fv);
document.write("<br/>");
rate = RATE( n, pmt, pv, fv, atype)*n;
document.write("RATE(fv= "+fv+" n= "+n+" pmt= "+pmt+" pv= "+pv+" type= "+atype+") <br/>"+rate*100+"%");
document.write("<br/>");
document.write("<br/>");
i = 0.1/31536000/1000000;
n = 31536000*1000000;
pv = 0;
pmt = -0.01/1000000;
atype = 0;
document.write("Micro-second payments, micro-second compounding frequency of interest");
document.write("<br/>");
fv = FV(i,n,pmt,pv,atype);
document.write("FV(i= "+i+" n= "+n+" pmt= "+pmt+" pv= "+pv+" type= "+atype+") <br/>"+fv);
document.write("<br/>");
rate = RATE( n, pmt, pv, fv, atype)*n;
document.write("RATE(fv= "+fv+" n= "+n+" pmt= "+pmt+" pv= "+pv+" type= "+atype+") <br/>"+rate*100+"%");
document.write("<br/>");
document.write("<br/>");
i = 0.1/31536000/1000000000;
n = 31536000*1000000000;
pv = 0;
pmt = -0.01/1000000000;
atype = 0;
document.write("Giga-second payments, giga-second compounding frequency of interest");
document.write("<br/>");
fv = FV(i,n,pmt,pv,atype);
document.write("FV(i= "+i+" n= "+n+" pmt= "+pmt+" pv= "+pv+" type= "+atype+") <br/>"+fv);
document.write("<br/>");
rate = RATE( n, pmt, pv, fv, atype)*n;
document.write("RATE(fv= "+fv+" n= "+n+" pmt= "+pmt+" pv= "+pv+" type= "+atype+") <br/>"+rate*100+"%");
document.write("<br/>");
document.write("<br/>");
function ln1 (x)
{
var s = x;
var c = 2;
var t;
var s1;
if (Math.abs(x) >= 0.01) return Math.log(1+x);
x = -x;
t = x;
for (;;) {
t *= x;
s1 = s - t/c;
if (s1 == s) break;
c += 1;
s = s1;
}
return s1;
}
function future_value_of_a_single_dollar(r, n)
{
if (r==0.0)
return 1.0;
if (n==0.0)
return 1.0;
return Math.exp(n * ln1(r));
}
function future_value_of_periodic_payments_in_amount_of_single_dollar(r, n)
{
if (r==0.0)
return 1.0;
if (n==0.0)
return 0.0;
return (future_value_of_a_single_dollar(r,n)-1.0)/r;
}
function present_value_of_a_single_dollar(r, n)
{
if (r==0.0)
return 1.0;
if (n==0.0)
return 1.0;
return Math.exp(-n * ln1(r));
}
function derivative_of_present_value_of_a_single_dollar(r, n)
{
if (r==0.0)
return 0.0;
if (n==0.0)
return 0.0;
return -n*Math.exp(-(n+1)*ln1(r));
}
function present_value_of_periodic_payments_in_amount_of_single_dollar(r, n)
{
if (r==0.0)
return 1.0;
if (n==0.0)
return 0.0;
return (1.0-present_value_of_a_single_dollar(r,n))/r;
}
function derivative_of_present_value_of_periodic_payments_in_amount_of_single_dollar(r, n)
{
if (r==0.0)
return 0.0;
if (n==0.0)
return 0.0;
return ( r*-derivative_of_present_value_of_a_single_dollar(r,n) - 1.0 + present_value_of_a_single_dollar(r,n) ) / Math.pow(r,2);
}
function FV(rate, nper, pmt, pv, atype) {
atype = (typeof atype !== "undefined") ? atype : 0;
return -pv * future_value_of_a_single_dollar(rate, nper) - pmt * (1.0+rate*atype) * future_value_of_periodic_payments_in_amount_of_single_dollar(rate, nper);
}
function PV(rate, nper, pmt, fv, atype) {
atype = (typeof atype !== "undefined") ? atype : 0;
return -fv * present_value_of_a_single_dollar(rate, nper) - pmt * (1.0+rate*atype) * present_value_of_periodic_payments_in_amount_of_single_dollar(rate, nper);
}
function derivative_of_PV(rate, nper, pmt, fv, atype) {
atype = (typeof atype !== "undefined") ? atype : 0;
return -fv * derivative_of_present_value_of_a_single_dollar(rate, nper) - pmt * derivative_of_present_value_of_periodic_payments_in_amount_of_single_dollar(rate, nper);
}
function RATE(nper, pmt, pv, fv, atype)
{
eb = 0.00000000000001;
if (pv)
x0 = (-fv-pv-pmt*n)/pv/n;
else
x0 = -fv/pmt/n/n;
for (i=0; i<100; i++)
{
f = PV(x0, nper, pmt, fv, atype);
fbar = derivative_of_PV(x0, nper, pmt, fv, atype);
if (fbar == 0.0)
return null;
x = x0 - f/fbar;
if ( Math.abs((x-x0)/x) < eb )
return x;
x0 = x;
}
return null;
}
</script>