Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Sum of Elements of The Series | Basic Mathematical Concepts and Definitions
Mathematics for Data Analysis and Modeling
course content

Зміст курсу

Mathematics for Data Analysis and Modeling

Mathematics for Data Analysis and Modeling

1. Basic Mathematical Concepts and Definitions
2. Linear Algebra
3. Mathematical Analysis

book
Sum of Elements of The Series

What is the sum of the series?

The sum of a series refers to adding up the values in the sequence. There are two situations to consider: finding the sum of a finite number of elements or the sum of all elements in the sequence. Depending on the situation, different approaches are used to calculate the sum.

Finite sums

If we work with finite sums, we can loop through all the elements to calculate the sum. Also, some types of sequences have ready-made formulas for calculating the sum.
For example, the sum of n elements of arithmetic progression can be calculated as follows:

1234567891011121314151617181920212223242526
def sum_arithmetic_progression_formula(a, d, n): # Calculate the sum of an arithmetic progression using the formula sum_formula = (n / 2) * (2 * a + (n - 1) * d) # Sum formula for arithmetic progression return sum_formula def sum_arithmetic_progression_loop(a, d, n): # Calculate the sum of an arithmetic progression using a loop progression_sum = 0 # Initialize the sum of the arithmetic progression current_term = a # Set the current term to the first term for _ in range(n): # Loop through each term in the arithmetic progression progression_sum += current_term # Add the current term to the sum current_term += d # Move to the next term by adding the common difference return progression_sum # Example usage a = 2 # First term d = 3 # Common difference n = 5 # Number of terms in the arithmetic progression # Calculate the sum using the formula sum_formula = sum_arithmetic_progression_formula(a, d, n) print(f'Sum using formula is {sum_formula}') # Calculate the sum using a loop sum_loop = sum_arithmetic_progression_loop(a, d, n) print(f'Sum using loop is {sum_loop}')
copy

Infinite sums

In the case of summing absolutely all elements of the sequence, we will encounter certain problems. For example, consider a sequence like this:

Let's look at the sum of 10000 first elements of the sequence. We will also print partial sums of 1000, 2000, 3000, etc. elements.

123456789101112131415161718
def calculate_sequence_sum(): # Initialize variables sequence_sum = 0 # Initialize the sum of the sequence partial_sums = [] # Initialize a list to store partial sums # Loop through elements in the sequence for n in range(1, 10001): term = 1 / n # Calculate the term of the sequence sequence_sum += term # Add the term to the sequence sum # Check if current index is a multiple of 1000 if n % 1000 == 0: partial_sums.append(sequence_sum) # Store the partial sum # Print partial sum up to the current index print(f'Partial sum of elements 1 to {n}: {sequence_sum:.5f}') # Call the function to calculate the sequence sum calculate_sequence_sum()
copy

We can see that partial sums are constantly increasing, and thus we cannot calculate the sum of all elements - it will be infinite. This conclusion seems quite logical - the more elements we summarize, the larger the sum. But since, formally, this sequence can be continued for an arbitrarily long time, the sum will be arbitrarily large.

But in fact, it's not so simple. Let's look at another sequence:

123456789101112131415
def calculate_sequence_sum(): sequence_sum = 0 partial_sums = [] for n in range(1, 10001): term = 1 / (n ** 2) sequence_sum += term if n % 1000 == 0: partial_sums.append(sequence_sum) print(f'Partial sum of elements 1 to {n}: {sequence_sum:.5f}') calculate_sequence_sum()
copy

Here we see that the partial sums are identical up to 3 digits, and the sum does not grow so rapidly with increased elements.
This is explained by the fact that elements with a large order are extremely small and eventually cease to affect the final sum significantly.

Convergent sums of the series

Thus, there is a certain class of sequences for which we can calculate the sum of absolutely all elements, which will be finite. This property is also called the convergence of the sum of a number series.

Note

In practice, the sum of the following sequence is often used: S(i) = 1 / i^a. Provided that a is greater than 1, the infinite sum of this sequence converges and is equal to some finite number.

Assume we have the following sequence `S(i) = i^7 / i^8`. Can we calculate the infinite sum of this sequence?

Assume we have the following sequence S(i) = i^7 / i^8. Can we calculate the infinite sum of this sequence?

Виберіть правильну відповідь

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 1. Розділ 3
We're sorry to hear that something went wrong. What happened?
some-alt