Taylor Series Python Program
The Taylor series is a useful tool often taught to undergraduates during Calculus 1 and 2. During my sophomore year of college, I enrolled in an algorithms development course. One of the first assignments my classmates and I received was to write a C++ program that calculates the values of the cosine and sine series using while and for loops.

This week, I decided to review this assignment and solve it using Python, as it had been a few months since I had used the language. The code below calculates the results of the series using while loops and for loops, and it allows the user to enter the x term and the number of terms to be included in the series. There is a negligible difference between the two results that isn’t noticed until approximately the 16th significant digit. Additionally, the code provides convergence study plots that indicate the series usually converge on the value around the 3rd to 4th term in the series (shown below).

The code in Jupyter Notebook format can be found here. The code in .py format can be found here.
Hopefully, this program can help someone interested in creating it as well! As always, please use the message form on the “Contact” page if you have any questions.