Sum of a series

From Fōrmulæ wiki
Jump to: navigation, search

This page is the answer to the task Sum of a series in the Rosetta Code.

Description (from Rosetta Code)

Compute the nth term of a series, i.e. the sum of the n first terms of the corresponding sequence.

Informally this value, or its limit when n tends to infinity, is also called the sum of the series, thus the title of this task.

For this task, use:

And compute

This approximates the zeta function for S=2, whose exact value

is the solution of the Basel problem.

Program

The series is provided as a lambda expression.

SumSeriesCode.png

Test case

SumSeriesOutput1.png

Forcing to give a decimal result:

SumSeriesOutput2.png

Another case

The following approximates to the value of

SumSeriesOutput3.png