There are many functions on a scientific or graphing calculator that we are introduced to as high school students that, we are told, just work. You select the function, put in the value that you need to calculate, hit “=” or “ENTER”, and SHABAM! You have the correct answer to some arbitrary number of digits that you are ensured are all 100% accurate.
Pictured: The natural log of 2 to (an arbitrary) 32 digits on the built-in Microsoft calculator.
This is wonderful! Necessary, even, because if our calculators and computers calculated logarithms inaccurately, as well as exponentials, trig functions, and square roots, a lot of scientific and engineering work would be broken and end in catastrophe. But how do we know that the value on the calculator is, in fact, accurate? How did the calculator crunch the input number and give us the output?
I remember this question being asked in high school, and the answer being no more than a handwave. To be fair to Algebra II teachers, the answer is beyond the scope of algebra and lies in calculus. But it is an answer worth knowing, and it’s an answer that is very knowable, even if you don’t have a background in calculus. Calculus is the method for deriving the formula used in calculators and computers, but the formula itself is a pretty simple polynomial.
The Geometric Series
Most of us were introduced to polynomial equations in algebra. For a quick refresher, a polynomial is an expression involving at least one variable (usually x) and addition, subtraction, multiplication, division, and integer power operators.
Here are a few examples:
Line: $y = 5 + 2x$
Parabola: $y = 1 - x - x^{2}$
Quartic: $y = 4 - 2x - 5x^{2} + \frac{1}{2}x^{3} + x^{4}$
While these equations of polynomials contain a finite number of terms, we can have polynomials with an infinite number of terms. These are called series, and one of the simplest types of series is called a geometric series. A geometric series contains an initial term, usually denoted by the variable a, and each successive term is multiplied by a ratio, usually denoted by r.
The general formula for a geometric series is:
$s = a + ar + ar^2 + ar^3 + ...$
One special geometric series relevant to logarithms is when a = 1 and r = -x, leading to a series known as the polynomial series for natural logarithms.
Getting a Series for the Natural Logarithm
“This is all very interesting, but what does this have to do with computing logarithms?” It turns out that the function $\frac{1}{1+x}$ and the natural logarithm are directly related. Specifically, the area under the curve from $t = 0$ to any value $x$ is the natural logarithm of $1+x$. In mathematical symbols, this is rendered as:
$ln(1+x) = \int_{0}^{x} \frac{1}{1+t} dt$
While the understanding of the calculus involved is beyond the scope of this article, taking integrals can get us the series that effectively computes the natural logarithm.
Here is a series derived for the natural logarithm:
$ln(1+x) = x - \frac{x^2}{2} + \frac{x^3}{3} - \frac{x^4}{4} + ...$
This series converges quickly for $|x| < 1$ and $|x| < \frac{1}{2}$. However, larger values of x can be addressed by strategically reducing them using properties of logarithms.
Properties of Logarithms
Luckily, logarithms are special functions with useful properties that help reduce arguments for calculation:
Multiplication in the input is equivalent to addition of the outputs.
$ln(ab) = ln(a) + ln(b)$Exponentiation in the input becomes multiplication in the output.
$ln(a^b) = b \cdot ln(a)$
Using these properties, even large logarithmic inputs can be broken down into smaller parts that fit within the convergence range of the series.
The Better Formula
While the polynomial series for $ln(1+x)$ is good, there's a better series that converges much faster:
$ln(x) = 2 \sum_{n=0}^{\infty} \frac{1}{2n+1} \biggl( \frac{x-1}{x+1} \biggr)^{2n+1}$
This series skips a degree for each term, making it faster. For example, calculating to double-floating-point precision (11 decimal places), the new series might need only 12 terms compared to 36 for the older series.
Pictured: A comparison of the 3-term approximations for the two series to $\ln(x)$. The latter series converges faster.
Remember these 3 key ideas for your startup:
Understand the Basics: Grasp the concept of how series and polynomials work, as they lay the foundation of many complex algorithms. This insight can be a game-changer for solving intricate problems efficiently.
Leverage Properties: Utilizing properties of logarithms to simplify complex computations can enhance productivity and reduce computational load on your systems.
Efficient Calculations: Opt for optimized algorithms, like the faster converging polynomials, for quicker and more accurate results, ensuring robustness in your mathematical computations which is critical for tech and data-driven startups.
Edworking is the best and smartest decision for SMEs and startups to be more productive. Edworking is a FREE superapp of productivity that includes all you need for work powered by AI in the same superapp, connecting Task Management, Docs, Chat, Videocall, and File Management. Save money today by not paying for Slack, Trello, Dropbox, Zoom, and Notion.
For an in-depth comparison of some leading productivity tools, check out this article on Microsoft Teams vs. Slack vs. Edworking. If you’re keen to explore alternatives to Google Keep for note-taking, see this list of top 5 Google Keep alternatives.
For more details, see the original source.