Hello Giannakos, This script outputs approx._output as NAN becasse f(pi/2) is evaluated to be NAN. The anonymous function 'f' is defined to be as
f(x)= -x -x^2/4-x^3/9-x^4/16-...
Now, notice that the series is divergent whenever x>1, because the numerator grows exponentially whereas the growth of the denominator is polynomial. So the sum keeps on increasing as we proceed to infinite. Hence, MATLAB evaluates the sum to be NAN. So
Verify the appropriate definition of Taylor series. In Taylor series, ith term is something like x^i/i! and hence converges.