Different values when calculating signal's energy by hand vs MATLAB Given the following signal:
$$
x(n) = 
\left\{
\begin{array}{ll}
      u(0.01n-0.025)2.3704e^{(-0.287682n)},   &amp; n\ge 0 \\
      u(-(0.01n+0.025))2.3704e^{(0.287682n)}, &amp; n&lt; 0 \\
\end{array} 
\right.
$$
I'm finding the energy using the summation formula:
$$E_{x(n)}=\sum_{n=-\infty}^\infty |x(n)|^2=\sum_{n=0}^\infty(2.3704e^{(-0.287682n)}u(0.01n-0.025))^2+\sum_{n=-\infty}^0 (2.3704e^{(0.287682n)}u(-(0.01n+0.025)))^2 =\sum_{n=0}^\infty(2.3704e^{(-0.287682n)}u(0.01n-0.025))^2+\sum_{n=0}^\infty(2.3704e^{(-0.287682n)}u(-(0.01n+0.025)))^2 = 2\times2.3704^2\times \sum_{n=0}^\infty (e^{(-0.287682\times 2)}u(0.01n-0.025))^n$$
So due to the sampling frequency and other information given about the problem, the sampling doesn't start until $n=3$ so I adjusted the limits of summation and removed the u(n) function:
$$=2\times2.3704^2\times \sum_{n=3}^\infty (e^{(-0.287682\times 2)})^n$$
And then adjusted the series to begin at $n=1$ so I could use the summation formula:
$$=2\times2.3704^2\times(\sum_{n=1}^\infty (e^{(-0.287682\times 2)})^n - (e^{(-0.287682\times 2)})^1 - (e^{(-0.287682\times 2)})^2)$$
So the series converges since the common ratio $&lt;1$ and the sum of the series is:
$$S_{\infty}=\frac{a_1}{1-r}=\frac{(e^{(-0.287682\times 2)})^1}{1-e^{(-0.287682\times 2)}}=1.2857$$
Replacing the number above in the energy summation equation, I get:
$$E_{x(n)}=2\times 2.3704^2\times(1.2857-0.5625-0.3164)=4.5715$$
However, when I use MATLAB to find the energy of the signal using the following code:
E = 0
for i=1:fs+1
    E = E + abs(x(i))^2
end

where fs is the sampling frequency, the code yields the following result:
$$E=2.2858$$
which doesn't match my mathematical method. However, I noticed that the answer that MATLAB gives me is half the answer of what I got by hand. I also know with certainty that the MATLAB answer is correct.
So how do I go from $4.5715$ to $2.2858$? What's the step/reasoning that I'm missing?
Thank you!
Since I don’t know rest of the given code, I’ve decided to calculate the energy other way round.
The MATLAB code for calculating the given function’s energy is given below:
syms n; % Symbol assignment for summation

Energy_1 = symsum(power((2.3704 * exp(0.287682 * n)), 2), n, -Inf, -3); % Energy for the left-hand side of the sample domain

Energy_2 = symsum(power((2.3704 * exp(-0.287682 * n)), 2), n, 3, Inf ); % Energy for the right-hand side of the sample domain

Energy = Energy_1 + Energy_2 % Overall energy


According to this code above, the resultant overall energy becomes $E = 4.5715$.
As the number of samples increases, the result gets accurate. Also, the coefficient in the exponential’s power affects the accuracy of the result too, but this is not the main case.