Skip to content

Analyze a given series with useful calculations, particularly the nth partial sum. Integrates well with data analysis and visualization libraries in Python.

Notifications You must be signed in to change notification settings

hezbranch/Partial-Sum-Playground

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 

Repository files navigation

Hezekiah Branch
Wed Feb 16 2022
Partial Sums

Partial Sum Playground

Purpose: Analyze a given series with useful calculations, including the nth partial sum

Usage: Designed for terminal/command line usage. Clone, unzip, and launch a terminal from repo location.

Alternate Environment(s): Jupyter Notebooks, analysis programs, scripts, etc.

Options: To run the calculation automatically, set the last parameter 'auto' to 'True'.

p = PartialSum(function, lower, upper, auto=True)

Example

>>> from partial_sum import PartialSum
>>> fx = lambda x : (-1)**x / (x)**0.5
>>> p = PartialSum(fx, 1, 1000000, True)
Final result available at .result or by calling 'print()' on PartialSum object.
To view the output of f(x) for each n as n approaches infinity, use .test to view the entire list.
To view the nth partial sum (i.e. the limit if input is a convergent infinite series), use .tail to view output.
To observe if tail approaches zero, use .zero_tail (checks margin of 1e-7).
>>> p.tail
5.000011249218367e-10
>>> p.zero_tail
True

Displaying graphs

The output from .result integrates well with data analysis and plotting libraries such as pandas and matplotlib.

>>> import pandas as pd
>>> import matplotlib.pyplot as plt

>>> small_data = {i : p.test[i-1] for i in range(p.lower, 100)}
>>> pd.Series(small_data).plot.line(title="Terms of Series Distributed by N", xlim=(1, len(small_data)))
<matplotlib.axes._subplots.AxesSubplot object at >
>>> plt.show()

Sample visualization of series terms

>>> small_sum_data = {i : p.result[i-1] for i in range(1, 100)}
>>> pd.Series(small_sum_data).plot.line(title="Partial Sums Distributed by N", xlim=(1, len(small_sum_data)))
<matplotlib.axes._subplots.AxesSubplot object at >
>>> plt.show()

Sample visualization of partial sums as n approaches infinity

Additional Info

In the images above, we have an alternating series with non-increasing term magnitude and a limit that approaches zero, indicating convergence. This tool provides visual artifacts of convergence which can supplement tests such as the Alternating Series Test.

For more information about mathematical analysis and convergence tests, see:

https://en.wikipedia.org/wiki/Alternating_series_test

Citation: Wikipedia contributors. (2022, January 24). Alternating series test. In Wikipedia, The Free Encyclopedia. Retrieved 03:33, February 17, 2022, from https://en.wikipedia.org/w/index.php?title=Alternating_series_test&oldid=1067674590

About

Analyze a given series with useful calculations, particularly the nth partial sum. Integrates well with data analysis and visualization libraries in Python.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages