Calculus calculator
A Python calculator that works through Euler's method and infinite series with real-world examples.

I built the Calculus Calculator to better understand my Calculus II homework. When I learn a new subject, I apply concepts to real-life implementations, and my work involves translating mathematical analysis to code.
Premade calculators already solve these problems, but I enjoyed the challenge of building my own. Writing these functions took longer than solving the problems by hand, but it was certainly more fun.
The Jupyter Notebook has Python functions to complete my once-tedious homework solutions: Euler’s method, Newton’s law of cooling, sequences, and series.
The visual above illustrates my eulers_method function to solve y′ = x·cos(πy) from y(0) = 1. The curve settles at y = 0.5, a stable equilibrium where the slope is zero.
| x | Euler (h = 0.1) | Exact | Error |
|---|---|---|---|
| 0.5 | 0.9008 | 0.8781 | 0.023 |
| 1.0 | 0.6376 | 0.6305 | 0.007 |
| 1.5 | 0.5131 | 0.5186 | 0.006 |
| 2.0 | 0.5003 | 0.5012 | 0.001 |
The equation also has an exact solution to measure the approximation’s error, shown in the table. The error grows as the curve steepens, then shrinks as it flattens near the equilibrium.
Euler’s method
Euler’s method approximates solutions to differential equations. It starts at a given initial value and proceeds in the direction indicated by the direction field, the slope at each point. At each small step of size h, it checks a new direction. The pattern repeats until a table of values approximates the solution. Engineers use Euler’s method to simulate circuits, reaction rates, and population growth.
Newton’s law of cooling
In the notebook’s example, I made a cup of coffee at 200°F in a 72°F room. The coffee cools quickly, then the rate of cooling slows as it reaches room temperature.
My functions solve T(t) = (T₀ − A)e−kt + A for the cooling rate, the time to a target temperature, or a table of temperatures in °F and °C. T₀ represents the initial temperature, k represents the rate of cooling, and A represents the ambient temperature. Learn more about the US’s stubborn dedication to the imperial system.

Sequences and series
A sequence is a list of numbers with a definite order. My sequence_table function lists each term as a decimal and a fraction. The terms of aₙ = n/(n+1) climb toward 1, and with n in the exponent, aₙ = (n+2)/5ⁿ quickly converges to 0.
The function’s table shows whether a sequence is convergent, approaching a limit, or divergent, infinitely increasing or decreasing. The sequence aₙ = 1 + n/2 diverges, climbing by 1/2 with each term.
A series converges when its partial sums approach a stable number, a reliable limit that becomes the sum (the series’ solution). Diverging series never settle, growing without bound or oscillating back and forth.
Documentation
The Jupyter Notebook explains each function in Markdown cells, with a sample input, its output, and links to further reading.
