I cannot figure out why division by 0 gives different results in the following two cases.
amort
is a function that calculates a constant amortization schedule. The only thing we care about now is that the last element of A is exactly 0.
amort = @(r,M) ((1+r).^(0:M)' - (1+r).^M) ./ (1-(1+r).^M)
A = amort(0.03, 20);
>> A(end)==0
ans =
1
What looks strange is the following:
>> 1/0
ans =
Inf
>> 1/A(end)
ans =
-Inf
However
>> sign(A(end))
ans =
0
>> 1/abs(A(end))
ans =
Inf
How is this possible and why? Is there some kind of hidden "sign"?