# Small difference in IRR, big difference in NPV?

I calculated the following in Matlab 2019a, see code below. I was surprised about the big difference in present values (DiffPV, DiffPVpercentage) for only a small difference (DiffIRR, DiffIRRpercentage) in discount rates. Is there a coding error somewhere? Or is it maybe just the normal effect of discounting? How could I check for that? As it does not occur for other cashflow data I thought it was a coding/programming problem, but I am not sure how I can check.

clc
clear
close all

CF = 1.0e+12 * [-1.767330098188526...
0.060733504300760...
0.060733504300760...
0.060733503508760...
0.060733504300760...
0.060733504300760...
0.060733503508760...
0.060733504300760...
0.060733504300760...
0.060733503508760...
0.060733504300760...
0.060733504300760...
0.060733501978648...
0.060733502770648...
0.060733502770648...
0.060733501990451...
0.060733502770648...
0.060733502770648...
0.060733502002254...
0.060733502770648...
0.060733502770648...
0.060733502014057...
0.060733502770648...
0.060733502770648...
0.060733502025860...
0.060733502770648...
0.060733502770648...
0.060733502037663...
0.060733502770648...
0.060733502770648...
0.060733502049466...
0.060733502770648...
0.060733502770648...
0.060733502061269...
0.060733502770648...
0.060733502770648...
0.060733502073072...
0.060733502770648...
0.060733502770648...
0.060733502084875...
0.060733502770648...
0.060733502770648...
0.060733502096678...
0.060733502770648...
0.060733502770648...
0.060733502108481...
0.060733502770648...
0.060733502770648...
0.060733502120284...
0.060733502770648...
0.060733502770648...
0.060733502132087...
0.060733502770648...
0.060733502770648...
0.060733502143890...
0.060733502770648...
0.060733502770648...
0.060733502155693...
0.060733502770648...
0.060733502770648...
0.060733502167497...
0.060733502770648...
0.060733502770648...
0.060733502179300...
0.060733502770648...
0.060733502770648...
0.060733502191103...
0.060733502770648...
0.060733502770648...
0.060733502202906...
0.060733502770648...
0.060733502770648...
0.060733502214709...
0.060733502770648...
0.060733502770648...
0.060733502226512...
0.060733502770648...
0.060733502770648...
0.060733502238315...
0.060733502770648...
0.060733502770648...
0.060733502250118...
0.060733502770648...
0.060733502770648...
0.060733502261921...
0.060733502770648...
0.060733502770648...
0.060733502273724...
0.060733502770648...
0.060733502770648...
0.060733502285527...
0.060733502770648...
0.060733502770648...
0.060733502297330...
0.060733502770648...
0.060733502770648...
0.060733502309133...
0.060733502770648...
0.060733502770648...
0.060733502320936...
0.060733502770648...
0.060733502770648...
0.060733502332739...
0.060733502770648...
0.060733502770648...
0.060733502344542...
0.060733502770648...
0.060733502770648...
0.060733502356345...
0.060733502770648...
0.060733502770648...
0.060733502368148...
0.060733502770648...
0.060733502770648...
0.060733502379951...
0.060733502770648...
0.060733502770648...
0.060733502391754...
0.060733502770648...
0.060733502770648...
0.060733502376682...
0.060733502770648...
0.060733502770648...
0.060733502389829...
0.060733502770648...
0.060733502770648...
0.060733502402976...
0.060733502770648...
0.060733502770648...
0.060733502416123...
0.060733502770648...
0.060733502770648...
0.060733502429270...
0.060733502770648...
0.060733502770648...
0.060733502442416...
0.060733502770648...
0.060733502770648...
0.060733502455563...
0.060733502770648...
0.060733502770648...
0.060733502468710...
0.060733502770648...
0.060733502770648...
0.060733502481857...
0.060733502770648...
0.060733502770648...
0.060733502495004...
0.060733502770648...
0.060733502770648...
0.060733502508150...
0.060733502770648...
0.060733502770648...
0.060733502521297...
0.060733502770648...
0.060733502770648...
0.060733502534444...
0.060733502770648...
0.060733502770648...
0.060733502547591...
0.060733502770648...
0.060733502770648...
0.060733502560738...
0.060733502770648...
0.060733502770648...
0.060733502573884...
0.060733502770648...
0.060733502770648...
0.060733502587031...
0.060733502770648...
0.060733502770648...
0.060733502600178...
0.060733502770648...
0.060733502770648...
0.060733502613325...
0.060733502770648...
0.060733502770648...
0.060733502626472...
0.060733502770648...
0.060733502770648...
0.055556792699142...
0.055556792830172...
0.055556792830172...
0.055556792710061...
0.055556792830172...
0.055556792830172...
0.055556792720980...
0.055556792830172...
0.055556792830172...
0.055556792731900...
0.055556792830172...
0.055556792830172...
0.055556792742819...
0.055464744371412...
0.055464744371412...
0.055464744294978...
0.055464744371412...
0.055464744371412...
0.055464744305897...
0.055464744371412...
0.055464744371412...
0.055464744316816...
0.055464744371412...
0.055464744371412...
0.055464744327735...
0.055464744371412...
0.055464744371412...
0.055464744338654...
0.055464744371412...
0.055464744371412...
0.055464744349574...
0.055464744371412...
0.055464744371412...
0.055464744360493...
0.055464744371412...
0.055464744371412...
0.055464745842000...
0.055464745842000...
0.055464745842000...
0.055464745842000...
0.055464745842000...
0.055464745842000...
0.055464745842000...
0.055464745842000...
0.055464745842000...
0.055464745842000...
0.055464745842000...
0.055464745842000...
0.055464745842000...
0.055464745842000...
0.055464745842000...
0.055464745842000...
0.055464745842000...
0.055464745842000...
0.055464745842000...
0.055464745842000...
0.055464745842000...
0.055464745842000...
0.055464745842000...
0.055464745842000...
0.105013255842000...
0.105136510842000...
0.105259765842000...
0.105383020842000...
0.105506275842000...
0.105629530842000...
0.105752785842000...
0.105876040842000...
0.105999295842000...
0.106122550842000...
0.106245805842000...
0.106369060842000...
0.106492315842000...
0.106615570842000...
0.106738825842000...
0.106862080842000...
0.106985335842000...
0.107108590842000...
0.107231845842000...
0.107355100842000...
0.107478355842000...
0.107601610842000...
0.107724865842000...
0.107848120842000...
0.107971375842000...
0.108094630842000...
0.108217885842000...
0.108341140842000...
0.108464395842000...
0.108587650842000...
0.108710905842000...
0.108834160842000...
0.108957415842000...
0.109080670842000...
0.109203925842000...
0.109327180842000...
0.109450435842000...
0.109573690842000...
0.109696945842000...
0.109820200842000...
0.109943455842000...
0.110066710842000...
0.110189965842000...
0.110313220842000...
0.110436475842000...
0.110559730842000...
0.110682985842000...
0.110806240842000...
0.110929495842000...
0.110929495842000...
0.110929495842000...
0.110929495842000...
0.110929495842000...
0.110929495842000...
0.110929495842000...
0.110929495842000...
0.110929495842000...
0.110929495842000...
0.110929495842000...
0.110929495842000...
0.110929495842000];

%% Test
IRR1 = 0.034366083131917;
IRR2 = 0.034364293602634;

DiffIRR = IRR1-IRR2
DiffIRRpercentage = (IRR1-IRR2)/IRR2

% PV1
for index = 1:length(CF)
CFdiscounted1(index) = CF(index)/((1+IRR1)^(index-1));
end
PV1 = sum(CFdiscounted1)

% PV2
for index = 1:length(CF)
CFdiscounted2(index) = CF(index)/((1+IRR2)^(index-1));
end
PV2 = sum(CFdiscounted2)

DiffPV = PV1-PV2
DiffPVpercentage = (PV1-PV2)/PV2

• 3.3436% is indeed the correct IRR. With 300 years of cash flows it is not too surprising that is numerical error in the final decimal places... computer precision is always limited. – Alex C Jun 4 at 17:08
• Yes, but DiffPV = -1.6e9 and DiffIRR = 5.2e-5. That is the PV of CF discounted with one IRR is hugely different from the PV of CF discounted with the other - almost identical - IRR. And my question is why. (I corrected a typo in the earlier formula!) – LenaH Jun 5 at 7:43
• When you are raising numbers on the order of 1.0e+12 to the power of 300 things can easily go wrong. The capacity of a "double" is approximately 10**308. Try it without the 1.0e+12 factor and see what you get... – Alex C Jun 5 at 12:12
• You are right. When I take away the factor of 1e12, the differences in percentages still stay the same, but IRR1-IRR2 and PV1-PV2 are both very small numbers. If you submit an answer, I can accept it! – LenaH Jun 7 at 7:09