It happens that I quite like scientific calculators, and lately I’ve been adding a few to my collection. Several calculators are **CAS** (“Computer Algebra System”)-capable, meaning they are powerful enough to do symbolic / algebraic processing, and thus are able to understand and manipulate algebraic expressions containing any mix of unknowns, operators and numbers, and simplify, expand, and solve those in a general form. They normally can also do **symbolic** differentiation and integration, computing the general derivative/integral “function” from a expression first, before you can evaluate them at given points, if desired.

But I’ve always found quite fascinating that some less advanced calculators still offer the possibility of doing **numerical** integration and differentiation. They don’t know for instance that the derivative function of **3⋅x²** is **6⋅x**, but they can still tell you that **when x = 2** the derivative of **3⋅x² **is **12**.

Before you ask; I got into this rabbit hole because numerical differentiation and integration are kinda standard features nowadays of any decent calculator. It doesn’t need to be a high end or an expensive calc. In fact, I noticed that even my **fx-570MS** “entry level” scientific calculator I purchased like 10 years ago can do both operations, while three of my “high end” vintage programmable Casio calculators can’t. As they were “programmable” I think Casio kinda expected users to write their own programs for whatever “advanced” feature they needed. So I started wondering what is the method/algorithm used by current scientific calculators to compute these functions, so I could add the same functionality to my vintage calcs.

Now, I’ll focus on differentiation here because it’s way easier to deconstruct and understand how that works. A post about integration may follow, if this doesn’t turn out to be a massive borefest.

## The concept of derivative

So if you go back to the formal definition of a derivative;

You’ll see that it basically attempts to find the “slope” of the function **f(x)** at a point **x** by evaluating the expression at **x** and **(x+h) **(as you would do with a straight line), and trying to reduce the difference in the X-axis between those two points (**h**) to a tiny fraction. In fact, it uses the concept of **limit** to find out where that expression converges when **h** approaches 0 (It never really gets there though, because the whole expression becomes a division by zero at that point). Read More