- x^6/6 + x^5/5 - x^4/4 + x^3/3 - x^2/2 + x
Look at that more carefully. Suppose you have a loop index, K, then you have a term X^K/K*(-1)^(K+1)
After that what you need to know is to use the .^ operator instead of the ^ operator -- x.^K/K*(-1)^(K+1)
You do not need to loop over the x values; you can use vectorized calculations.