You can compute symbolic summations, when they exist, by using the symsum command. For example, the p-series
sums to , while the geometric series
1 + x + x2 + ...
sums to 1/(1 – x), provided . These summations are demonstrated below:
syms x k s1 = symsum(1/k^2, 1, inf) s2 = symsum(x^k, k, 0, inf)
s1 = pi^2/6 s2 = piecewise([1 <= x, Inf], [abs(x) < 1, -1/(x - 1)])