Your program: function s = etaylor_log(x, n) % Sum of first n non-zero terms of Taylor series of log(x) [natural logarithm] with a=1 % For example, etaylor_log(0.5, 0) should be 0, etaylor_log(0.5, 1) should be -0.5, % and etaylor_log(0.5, 2) should be -0.625