Enter the following code into an input cell in a worksheet, and evaluate the cell:
var('x, n, k') f(x) = sin(x) / x^2 f.show() print("Power series expansion around x=1:") s(x) = f.series(x==1, 3) s.show() print("Sum of alternating harmonic series:") h(k) = (-1)^(k + 1) * 1 / k print h.sum(k, 1, infinity) print("Sum of binomial series:") h(k) = binomial(n, k) print h.sum(k, 1, infinity) print("Sum of harmonic series:") h(k) = 1 / k print h.sum(k, 1, infinity) # Diverges
The results are shown in the following screenshot:
We started by defining a function and using the series
method to compute a power series around the point x=1. The first argument to series
is the point at which to create the series, and the second argument is the order of the computed series. Notice that Sages uses "big O" notation to denote the order of the series.
We then created several infinite series and computed their sums. Sage can compute the sum...