Code:

<script>
rate = 0.1;
gradient = 0;
nper = 31536000;
pmt_deferred_by = 0;
pmt = -0.01;
pv = 0;
atype = 0;
compounding = 1.0/31536000;
period = 1.0/31536000;
distribution = 1;
infinity = 0;
document.write("RATE = "+ rate +"<br/>");
document.write("GRADIENT = "+ gradient +"<br/>");
document.write("NPER = "+ nper +"<br/>");
document.write("PMT deferred by = "+ pmt_deferred_by +"<br/>");
document.write("PMT = "+ pmt +"<br/>");
document.write("PV = "+ pv +"<br/>");
document.write("TYPE = "+ atype +"<br/>");
document.write("COMPOUNDING = "+ compounding +"<br/>");
document.write("PERIOD = "+ period +"<br/>");
document.write("DISTRIBUTION = "+ distribution +"<br/>");
document.write("INFINITY = "+ infinity +"<br/>");
fv = FV(rate, gradient, nper, pmt_deferred_by, pmt, pv, atype, compounding, period, distribution, infinity);
document.write("FV = "+fv);
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 aey(r, c)
{
if (r==0.0)
return 0.0;
if (c==0.0)
return exp(r) - 1;
else
return Math.exp(1/c * ln1(r*c)) - 1;
}
function fvif(r, n, c)
{
return Math.exp(n * ln1(aey(r,c)));
}
function pvif(r, n, c)
{
return Math.exp(-n * ln1(aey(r,c)));
}
function pvif2(r, n, c, p, d)
{
t = (n-1)*p+p*d;
return Math.exp(-t * ln1(aey(r,c)));
}
function pvifga(r, g, f, dt, atype, c, p, d,inf)
{
pv=0.0;
t=0.0;
gt=0.0;
nn=0.0;
NN=0.0;
remaining=0.0;
aif=0.0;
af1n=0.0;
af1d=0.0;
af2n=0.0;
af2d=0.0;
af1=0.0;
af2=0.0;
af=0.0;
if (inf == 0)
{
n = Math.floor(f);
for (i=0; i<n; i++)
{
if (atype == 0)
t = (i*p+d*p) + ((dt-1)*p+d*p);
else
{
if (i==0)
t = ((dt-1)*p+d*p);
else
t = ((i-1)*p+d*p) + ((dt-1)*p+d*p);
}
if (i==0)
gt = 0;
else
gt = (i-1)*p+d*p;
pv += fvif(g,gt,c) * pvif(r,t,c);
}
}
else
{
pv += Math.pow(aey(r,c)-aey(g,c),-1.0) * pvif2(r,dt,c,p,d);
}
remaining = f - Math.floor(f);
if (remaining != 0.0)
{
NN = (f-1)*p+p*d;
nn = (Math.floor(f)-1)*p+p*d;
if (r==g)
{
af1n = f * fvif(aey(r,c)*atype,p*d,1);
af1d = fvif(aey(g,c),p*d,1);
af2n = Math.floor(f) * fvif(aey(r,c)*atype,p*d,1);
af2d = fvif(aey(g,c),p*d,1);
af1 = af1n/af1d;
af2 = af2n/af2d;
af = af1 - af2;
}
else
{
aif = fvif(aey(r,c)*atype,p*d,1);
af1n = fvif(g,nn,c)*pvif(r,nn,c);
af1d = (aey(r,c)-aey(g,c));
af2n = fvif(g,NN,c)*pvif(r,NN,c);
af2d = (aey(r,c)-aey(g,c));
af1 = (aif*af1n)/af1d;
af2 = (aif*af2n)/af2d;
af = af1 - af2;
}
pv += af * pvif2(r,dt,c,p,d);
}
return pv;
}
function FV(rate, gradient, nper, pmt_deferred_by, pmt, pv, atype, compounding, period, distribution, infinity) {
atype = (typeof atype !== "undefined") ? atype : 0;
compounding = (typeof compounding !== "undefined") ? compounding : 1;
period = (typeof period !== "undefined") ? period : 1;
distribution = (typeof distribution !== "undefined") ? distribution : 1;
infinity = (typeof infinity !== "undefined") ? infinity : 0;
return (-pv - pmt * pvifga(rate, gradient, nper, pmt_deferred_by, atype, compounding, period, distribution, infinity) ) / pvif2(rate, nper, compounding, period, distribution);
}
</script>