Thread: Calculator torture test in a FV problem

1. Calculator torture test in a FV problem

Stumbled across this seemingly simple FV problem here.

an accountant is paid $0.01 per second every day and night for a year. the money is deposited directly into her bank account which pays 10% interest pa compounded every second. what is the correct bank balance after one year? Author's scicalc gets 331667.006690776891780341908435 Both my calculators are only up to 331665.995684669 Maybe I should get a ti. Samsung phone: 331667.01312868 Google calculator: 331667.01255977619 Excel: ?????? Sorry, no access right now. Perhaps Sir AbrahamA, with tadRATE function, could match the author's results. 2. Re: Calculator torture test in a FV problem Originally Posted by jonah Stumbled across this seemingly simple FV problem here. an accountant is paid$0.01 per second every day and night for a year. the money is deposited directly into her bank account which pays 10% interest pa compounded every second. what is the correct bank balance after one year?

Author's scicalc gets 331667.006690776891780341908435
Both my calculators are only up to 331665.995684669
Maybe I should get a ti.
Samsung phone: 331667.01312868
Excel: ?????? Sorry, no access right now.
Perhaps Sir AbrahamA, with tadRATE function, could match the author's results.
I am getting the following results by using tadFV function found in tadXL v2.5

http://finance.thinkanddone.com/32_b....5_en_demo.zip

The only results I am having problem with is the end of period payments in a 366 days a year that is showing a future value higher than start of period payments ( not sure why, would have to check the code on this one)

Edit

I looked at the workbook and the incorrect answer for end of period payments in a 366 days a years was showing as I entered a tadNominal formula in the RATE column thus resulting in the wrong rate

After the corrected the rate to 10% it is now showing the correct result

Start of period payments - 365 days in a year
FV = 331,667.008053862

 Days in a year 365 RATE 10% GRADIENT 0% TAX_RATE 0% NPER 31536000 PMT -0.01 PV 0 TYPE 1 GTYPE 0 COMPOUNDING =1/31536000 PERIOD =1/31536000 DISTRIBUTION 1 FV 331,667.008053862

End of period payments - 365 days in a year
FV = 331,667.007002152

 Days in a year 365 RATE 10% GRADIENT 0% TAX_RATE 0% NPER 31536000 PMT -0.01 PV 0 TYPE 0 GTYPE 0 COMPOUNDING =1/31536000 PERIOD =1/31536000 DISTRIBUTION 1 FV 331,667.007002152

Start of period payments - 366 days in a year
FV = 332,575.684355556

 Days in a year 366 RATE 10% GRADIENT 0% TAX_RATE 0% NPER 31622400 PMT -0.01 PV 0 TYPE 1 GTYPE 0 COMPOUNDING =1/31622400 PERIOD =1/31622400 DISTRIBUTION 1 FV 332,575.684355556

End of period payments - 366 days in a year
FV = 332,575.683303847

 Days in a year 366 RATE 10% GRADIENT 0% TAX_RATE 0% NPER 31622400 PMT -0.01 PV 0 TYPE 0 GTYPE 0 COMPOUNDING =1/31622400 PERIOD =1/31622400 DISTRIBUTION 1 FV 332,575.683303847

3. Re: Calculator torture test in a FV problem

Wolframalpha's results:
End of period payments, 365 days in a year: 331667.00701154734

Start of period payments, 365 days in a year: 331667.0080632565

End of period payments, 366 days in a year: 332575.683316027

Start of period payments, 366 days in a year: 332575.6843677362

4. Re: Calculator torture test in a FV problem

Originally Posted by SlipEternal
Wolframalpha's results:
Start of period payments, 365 days in a year: 331667.00701154734

End of period payments, 365 days in a year: 331667.0080632565

Start of period payments, 366 days in a year: 332575.683316027

End of period payments, 366 days in a year: 332575.6843677362
Are you sure you didn't confuse start of period with end of period as an annuity due (start of period) should have higher future value than ordinary annuity (end of periods)

Now I can see one of my number is out of the mark so I will have to check the code

I don't find much time to go back to something I had done in past but this time I have recheck the code

Edit

there was nothing wrong in the code, it is just that RATE value had the incorrect rate when I used tadNOMINAL function rather than 10% as the rate.

The correct values are being displayed now

5. Re: Calculator torture test in a FV problem

Originally Posted by AbrahamA
Are you sure you didn't confuse start of period with end of period as an annuity due (start of period) should have higher future value than ordinary annuity (end of periods)

Now I can see one of my number is out of the mark so I will have to check the code

I don't find much time to go back to something I had done in past but this time I have recheck the code
I wasn't sure which one was which. I noticed that in your calculations, the start of period payments yielded less future value than the end of period payments, so I assumed that was how it was supposed to be.

6. Re: Calculator torture test in a FV problem

Originally Posted by SlipEternal
I wasn't sure which one was which. I noticed that in your calculations, the start of period payments yielded less future value than the end of period payments, so I assumed that was how it was supposed to be.
The correct values from Wolfram would be when you switch them

Ordinary Annuity begins at period t=1 so it has lesser present and future value
End of period payments, 365 days in a year: 331667.00701154734

Annuity due begins at period t=0 so it has higher present and future value
Start of period payments, 365 days in a year: 331667.0080632565

Ordinary Annuity begins at period t=1 so it has lesser present and future value
End of period payments, 366 days in a year: 332575.683316027

Annuity due begins at period t=0 so it has higher present and future value
Start of period payments, 366 days in a year: 332575.6843677362

7. Re: Calculator torture test in a FV problem

Stumbled across this seemingly simple FV problem here.

an accountant is paid $0.01 per second every day and night for a year. the money is deposited directly into her bank account which pays 10% interest pa compounded every second. what is the correct bank balance after one year? Author's scicalc gets 331667.006690776891780341908435 Both my calculators are only up to 331665.995684669 Maybe I should get a ti. Samsung phone: 331667.01312868 Google calculator: 331667.01255977619 Excel: ?????? Sorry, no access right now. Perhaps Sir AbrahamA, with tadRATE function, could match the author's results. It doesn't quite match the author's results but it comes closer to it when I change the compounding frequency of interest to infinite or continuous. Author's scicalc gets 331667.006690776891780341908435 Abaraham's tadXL gets 331667.006717537  Daysinayear 365 365 Daysinayear 366 366 RATE 10% 10% RATE 10% 10% GRADIENT 0% 0% GRADIENT 0% 0% TAX_RATE 0% 0% TAX_RATE 0% 0% NPER 31536000 31536000 NPER 31622400 31622400 PMT -0.01 -0.01 PMT -0.01 -0.01 PV 0 0 PV 0 0 TYPE 1 1 TYPE 1 1 GTYPE 0 0 GTYPE 0 0 COMPOUNDING 3.17098E-08 0 COMPOUNDING 3.16232E-08 0 PERIOD 3.17098E-08 3.17098E-08 PERIOD 3.16232E-08 3.16232E-08 DISTRIBUTION 1 1 DISTRIBUTION 1 1 FV 331,667.008053862 331,667.007769246 FV 332,575.684355556 332,575.684501353 Daysinayear 365 365 Daysinayear 366 366 RATE 10% 10% RATE 10% 10% GRADIENT 0% 0% GRADIENT 0% 0% TAX_RATE 0% 0% TAX_RATE 0% 0% NPER 31536000 31536000 NPER 31622400 31622400 PMT -0.01 -0.01 PMT -0.01 -0.01 PV 0 0 PV 0 0 TYPE 0 0 TYPE 0 0 GTYPE 0 0 GTYPE 0 0 COMPOUNDING 3.17098E-08 0 COMPOUNDING 3.16232E-08 0 PERIOD 3.17098E-08 3.17098E-08 PERIOD 3.16232E-08 3.16232E-08 DISTRIBUTION 1 1 DISTRIBUTION 1 1 FV 331,667.007002152 331,667.006717537 FV 332,575.683303847 332,575.683449644 8. Re: Calculator torture test in a FV problem Originally Posted by jonah Stumbled across this seemingly simple FV problem here. an accountant is paid$0.01 per second every day and night for a year. the money is deposited directly into her bank account which pays 10% interest pa compounded every second. what is the correct bank balance after one year?

Author's scicalc gets 331667.006690776891780341908435
Both my calculators are only up to 331665.995684669
Maybe I should get a ti.
Samsung phone: 331667.01312868
Excel: ?????? Sorry, no access right now.
Perhaps Sir AbrahamA, with tadRATE function, could match the author's results.
The author definitely has a point about loss of precision when interest rates are too small to be fully represented by limitations of computers

The author's results are for future value of ordinary annuity with 31536000 payments in amount of \$0.01 using interest rate that is compounded per second

TVM calculations in tadXL are programmed to use the annual effective yield in finding present and future value and it uses the long form sum of series rather than the closed form annuity formula

But as you have seen finding the effective yield for secondly compounding led to loss of trailing digits thus the results for future value were not accurate

However as there will be very a small difference in resulting future value once we change the compounding of interest to continuous as compared to secondly. We will come very to close to the actual future value for secondly compounding of interest by using continuous compounding instead

Thus for our purposes finding the annual effective yield will not go through division by a large number instead

AEY(i, INFINITY) = e^i - 1

Still there will be a small difference in the results of future value calculations as the length of the period itself is too small to be represented correctly in computers such as 1/31536000

Yet by using continuous compounding of interest, the results will be quite close to the actual future value when interest is compounded per second

The author's example was for an ordinary annuity, let us revisit the author's results for an ordinary annuity and an annuity due and compare it to results produced by tadXL using continuous compounding of interest for secondly annuity payments

Code:
End of period payments (ordinary annuity)
-----------------------------------------
Author's result   = 331,667.006690776891780341908435
Abraham's result  = 331,667.006717537

Start of period payments (annuity due)
-----------------------------------------
Author's result   = 331,667.00774248607078458116446094
Abraham's result  = 331,667.007769246

9. Re: Calculator torture test in a FV problem

Wolfram Alpha

Continuously compounded rate at 10%

exp(0.1)-1 - Wolfram|Alpha

Using the continuously compounded rate to find future value of 31536000 start of period payments in amount of 0.01

0.01*Sum[(1+0.10517091807564762481170782649025)^(k/31536000),{k,1,31536000}] - Wolfram|Alpha

Using the continuously compounded rate to find future value of 31536000 end of period payments in amount of 0.01

0.01*Sum[(1+0.10517091807564762481170782649025)^(k/31536000),{k,0,31535999}] - Wolfram|Alpha

But the results on Wolfram do not show the decimal places

10. Re: Calculator torture test in a FV problem

When rates are that small then it will cause problems finding PMT, NPER, PV and RATE as well. Since all such functions including FV are tied to the same equation

The only fix to the problem is what the author described as finding an intermediate rate to avoid such garbage results in TVM calculations when rates drop below 0.1%

11. Re: Calculator torture test in a FV problem

@Jonah

These are rather trivial FV, PV and PMT function based on the ln1(x) function that was given by the author

I tested FV, PV and PMT functions using the secondly compounding of interest and the results are correct

The output

Code:
FV(i=3.170979198376459e-9 n=31536000 pmt=-0.01 pv=0 type=0) = 331667.0066907767
FV(i=3.170979198376459e-9 n=31536000 pmt=-0.01 pv=0 type=1) = 331667.0077424859
PV(i=3.170979198376459e-9 n=31536000 pmt=-0.01 fv=331667.0077424859 type=1) = 0
PV(i=3.170979198376459e-9 n=31536000 pmt=-0.01 fv=331667.0077424859 type=1) = 0
PMT(i=3.170979198376459e-9 n=31536000 pv=0 fv=331667.0077424859 type=1) = -0.01
PMT(i=3.170979198376459e-9 n=31536000 pv=0 fv=331667.0077424859 type=1) = -0.01
The JavaScript code

Code:
i = 0.1/31536000;
n = 31536000;
pv = 0;
pmt = -0.01;
atype = 0;

fv = FV(i,n,pmt,pv,atype);
document.write("FV(i="+i+" n="+n+" pmt="+pmt+" pv="+pv+" type="+atype+") = "+fv);
document.write("<br/>");

atype = 1;

fv = FV(i,n,pmt,pv,atype);
document.write("FV(i="+i+" n="+n+" pmt="+pmt+" pv="+pv+" type="+atype+") = "+fv);
document.write("<br/>");

pv = PV(i,n,pmt,fv,atype);
document.write("PV(i="+i+" n="+n+" pmt="+pmt+" fv="+fv+" type="+atype+") = "+pv);
document.write("<br/>");

atype = 1;

pv = PV(i,n,pmt,fv,atype);
document.write("PV(i="+i+" n="+n+" pmt="+pmt+" fv="+fv+" type="+atype+") = "+pv);
document.write("<br/>");

pmt = PMT(i,n,pv,fv,atype);
document.write("PMT(i="+i+" n="+n+" pv="+pv+" fv="+fv+" type="+atype+") = "+pmt);
document.write("<br/>");

atype = 1;

pmt = PMT(i,n,pv,fv,atype);
document.write("PMT(i="+i+" n="+n+" pv="+pv+" fv="+fv+" type="+atype+") = "+pmt);
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 FVIF(r, n)
{
if (r==0.0)
return 1.0;
if (n==0.0)
return 1.0;
return Math.exp(n * ln1(r));
}

function FVIFA(r, n)
{
if (r==0.0)
return 1.0;
if (n==0.0)
return 0.0;
return (FVIF(r,n)  - 1.0)/r;
}

function FV(rate, nper, pmt, pv, atype) {
var fv = 0.0;
atype = (typeof atype !== "undefined") ? atype : 0;
return -pv * FVIF(rate, nper) - pmt * (1.0+rate*atype) * FVIFA(rate, nper);
}

function PV(rate, nper, pmt, fv, atype) {
atype = (typeof atype !== "undefined") ? atype : 0;
return ( -fv - pmt * (1.0+rate*atype) * FVIFA(rate, nper) ) / FVIF(rate, nper);
}

function PMT(rate, nper, pv, fv, atype) {
atype = (typeof atype !== "undefined") ? atype : 0;
return (-pv * FVIF(rate, nper) - fv)/((1.0+rate*atype) * FVIFA(rate, nper));
}