Error in Exponential Sum Formula

81 Views Asked by At

I have noticed that, for the exponential sum formula: $$\sum_{n=0}^{N-1} r^n = \frac{1-r^N}{1-r}.$$ the formula is not correct (left side $\neq$ right side) when N has a factional part (not just integer). Could you please help me to understand why? Here is an example in Matlab

clc
clear all
r = 0.5;
N=2.4;
%% left side of equation
left = 0;
for n=0:N-1
    left = left + r^n;
end
%% right side of equaiton
right = (1-r^N)/(1-r);
right-left
1

There are 1 best solutions below

0
On BEST ANSWER

I think the problem comes from the fact that $N$ is not an integer. It makes no real sense here since your summation indices cannot be fractional (and thus the upper bound cannot be either).

Your summation will stop at index $N=2.4$ rounded down, so as suggested in the comments, there will be a discrepancy which yields a wrong result. Working with integer values for $N$ will solve the problem.