Showing posts with label pi. Show all posts
Showing posts with label pi. Show all posts

Friday, 31 July 2026

Euler's Formula


Graphic created using Gemini

Courtesy of Gemini:

Often cited as the most beautiful theorem in mathematics, Euler’s identity (\(e^{i\pi} + 1 = 0\)) achieves its fame by elegantly linking the most fundamental constants and operations in a single, concise equation.

Here is the history behind its discovery and the mathematical proof of why it works.

The History Behind the Identity

The equation is a specific case of Euler’s formula, which states that for any real number \(x\):

\[e^{ix} = \cos(x) + i\sin(x)\]

While the identity bears the name of the brilliant Swiss mathematician Leonhard Euler, the groundwork was laid slightly earlier. In 1714, the English mathematician Roger Cotes discovered a precursor to this relationship, expressing it in terms of natural logarithms: \(\ln(\cos x + i\sin x) = ix\).

However, it was Euler who, in 1748, formalized the mathematics into the modern exponential form we use today. He published it in his foundational text Introductio in analysin infinitorum (Introduction to the Analysis of the Infinite).

The identity is celebrated because it connects five foundational mathematical constants from entirely different disciplines:

  • \(0\): The additive identity (the foundation of arithmetic).
  • \(1\): The multiplicative identity (the foundation of counting).
  • \(\pi\): The fundamental constant of geometry (the ratio of a circle's circumference to its diameter).
  • \(e\): The fundamental constant of growth and continuous change (the base of natural logarithms).
  • \(i\): The imaginary unit (\(\sqrt{-1}\)), which unlocks complex algebra.

It also seamlessly utilizes the three most basic mathematical operations: addition, multiplication, and exponentiation.


Why the Equation Holds True

To prove why this works, we must look to Taylor series (specifically, Maclaurin series expansions). A Maclaurin series allows us to express complex functions as an infinite sum of polynomial terms.

The series expansion for the exponential function \(e^x\) is:

\[e^x = 1 + x + \frac{x^2}{2!} + \frac{x^3}{3!} + \frac{x^4}{4!} + \frac{x^5}{5!} + \dots\]

If we substitute \(x = i\theta\) into this series, we get:

\[e^{i\theta} = 1 + (i\theta) + \frac{(i\theta)^2}{2!} + \frac{(i\theta)^3}{3!} + \frac{(i\theta)^4}{4!} + \frac{(i\theta)^5}{5!} + \dots\]

Next, we evaluate the powers of \(i\). By definition, \(i = \sqrt{-1}\), which creates a repeating pattern:

  • \(i^1 = i\)
  • \(i^2 = -1\)
  • \(i^3 = -i\)
  • \(i^4 = 1\)
  • \(i^5 = i\)

Substituting these evaluated powers back into our series gives:

\[e^{i\theta} = 1 + i\theta - \frac{\theta^2}{2!} - \frac{i\theta^3}{3!} + \frac{\theta^4}{4!} + \frac{i\theta^5}{5!} - \dots\]

Now, we group the real terms (those without an \(i\)) and the imaginary terms (those multiplied by \(i\)) together:

\[e^{i\theta} = \left( 1 - \frac{\theta^2}{2!} + \frac{\theta^4}{4!} - \dots \right) + i\left( \theta - \frac{\theta^3}{3!} + \frac{\theta^5}{5!} - \dots \right)\]

This is where Euler's brilliant connection becomes visible. These two grouped polynomial expansions perfectly match the standard Maclaurin series expansions for the trigonometric functions cosine and sine:

\[\cos(\theta) = 1 - \frac{\theta^2}{2!} + \frac{\theta^4}{4!} - \dots\]

\[\sin(\theta) = \theta - \frac{\theta^3}{3!} + \frac{\theta^5}{5!} - \dots\]

By substituting \(\cos(\theta)\) and \(\sin(\theta)\) back into our grouped equation, we arrive at Euler's formula:

\[e^{i\theta} = \cos(\theta) + i\sin(\theta)\]

Reaching the Final Identity

To get Euler's Identity, we evaluate the formula at \(\theta = \pi\) radians (which corresponds to \(180\) degrees on the unit circle):

\[e^{i\pi} = \cos(\pi) + i\sin(\pi)\]

Looking at a standard trigonometric unit circle, we know that:

  • \(\cos(\pi) = -1\)
  • \(\sin(\pi) = 0\)

Substituting these values in:

\[e^{i\pi} = -1 + 0i\]

\[e^{i\pi} = -1\]

By simply adding \(1\) to both sides, we arrive at the final state of the identity, linking the five constants perfectly together:

\[e^{i\pi} + 1 = 0\]

Here is a Gemini link to information about the mathematicians Taylor and MacLaurin.

Tuesday, 20 January 2026

Newton's Approximation For Pi

I watched an interesting YouTube video about how Newton approximated \( \pi \) and I thought it would be an interesting exercise to get Gemini to access the video and recreate the steps outlined. Once Gemini had created its response, I then got it to create a HTML version of the information for easy pasting into Blogger. Here is what it came up with and it's really quite impressive:

Based on the video provided, specifically the section starting around [00:06:50], here is the step-by-step derivation of Newton’s approximation of $\pi$.

Newton's method combines two different ways of calculating the area of a specific portion of a circle: using calculus (integration of an infinite series) and geometry. By equating these two results, he solved for $\pi$.

Step 1: The Equation of the Circle

Newton started with the equation of a unit circle centered at the origin:

$$x^2 + y^2 = 1$$

Solving for $y$ gives the function for the upper semicircle:

$$y = \sqrt{1 - x^2} = (1 - x^2)^{\frac{1}{2}}$$

Newton wanted to find the area under this curve from $x = 0$ to $x = \frac{1}{2}$. This can be expressed as the definite integral:

$$\text{Area} = \int_{0}^{\frac{1}{2}} (1 - x^2)^{\frac{1}{2}} \, dx$$

Step 2: Binomial Expansion

Since calculus was in its infancy, Newton applied his generalized binomial theorem to expand $(1 - x^2)^{\frac{1}{2}}$ into an infinite series. The general form for $(1+u)^n$ is:

$$(1+u)^n = 1 + nu + \frac{n(n-1)}{2!}u^2 + \frac{n(n-1)(n-2)}{3!}u^3 + \dots$$

By substituting $u = -x^2$ and $n = \frac{1}{2}$, he derived the series for the circle's equation:

$$(1 - x^2)^{\frac{1}{2}} = 1 - \frac{1}{2}x^2 - \frac{1}{8}x^4 - \frac{1}{16}x^6 - \frac{5}{128}x^8 - \dots$$

Step 3: Term-by-Term Integration

Newton then found the area (fluxion) by integrating the series term by term:

$$\int \left( 1 - \frac{1}{2}x^2 - \frac{1}{8}x^4 - \frac{1}{16}x^6 - \dots \right) \, dx$$

This yields the algebraic formula for the area:

$$\text{Area}(x) = x - \frac{1}{6}x^3 - \frac{1}{40}x^5 - \frac{1}{112}x^7 - \frac{5}{1152}x^9 - \dots$$

Step 4: Calculating the Area for $x = \frac{1}{2}$

Newton improved efficiency by choosing the limit $x = \frac{1}{2}$ (instead of 1), which makes the powers of $x$ shrink very rapidly. Substituting $x = \frac{1}{2}$ into the series:

$$\text{Area} \approx \frac{1}{2} - \frac{1}{6}\left(\frac{1}{2}\right)^3 - \frac{1}{40}\left(\frac{1}{2}\right)^5 - \frac{1}{112}\left(\frac{1}{2}\right)^7 - \dots$$

Simplifying the fractions:

$$\text{Area} \approx \frac{1}{2} - \frac{1}{48} - \frac{1}{1280} - \frac{1}{14336} - \dots$$

This sum gives a numerical value for the area.

Step 5: Equating to Geometry



Screenshot from video

Geometrically, the area under the unit circle from $x=0$ to $x=\frac{1}{2}$ corresponds to a slice of the circle. As described in the video, this region consists of two shapes:

  1. A triangle with base $\frac{1}{2}$ and height $\frac{\sqrt{3}}{2}$ (since $y = \sqrt{1 - (0.5)^2} = \sqrt{0.75} = \frac{\sqrt{3}}{2}$).
  2. A circular sector of $30^{\circ}$ (or $\frac{\pi}{6}$ radians).

The total geometric area is:

$$\text{Area} = \text{Area}_{\text{triangle}} + \text{Area}_{\text{sector}}$$ $$\text{Area} = \left( \frac{1}{2} \cdot \text{base} \cdot \text{height} \right) + \left( \frac{\theta}{2\pi} \cdot \pi r^2 \right)$$ $$\text{Area} = \left( \frac{1}{2} \cdot \frac{1}{2} \cdot \frac{\sqrt{3}}{2} \right) + \left( \frac{\pi/6}{2\pi} \cdot \pi (1)^2 \right)$$ $$\text{Area} = \frac{\sqrt{3}}{8} + \frac{\pi}{12}$$

Step 6: Solving for $\pi$

Finally, Newton equated the Algebraic Area (from Step 4) with the Geometric Area (from Step 5) and solved for $\pi$:

$$\frac{\sqrt{3}}{8} + \frac{\pi}{12} = \text{Series Sum}$$ $$\frac{\pi}{12} = \text{Series Sum} - \frac{\sqrt{3}}{8}$$ $$\pi = 12 \left( \text{Series Sum} - \frac{\sqrt{3}}{8} \right)$$ $$\pi = 12 \left[ \left( \frac{1}{2} - \frac{1}{48} - \frac{1}{1280} - \dots \right) - \frac{\sqrt{3}}{8} \right]$$

Using just the first few terms of the series, Newton achieved an approximation of $\pi \approx 3.14161$.

Saturday, 13 December 2025

Pi and Pythagoras

Figure 1 shows a screenshot of a tweet from Cliff Pickover illustrating a surprising connection between the most famous 3 : 4 : 5 Pythagorean triangle and \(\pi\).

Figure 1

I asked Gemini to explain this as I was too lazy to think it through (it was too early in the day for me). It's first proof was algebraic and went like this:

Explanation Provided By Gemini

To understand why the area of the incircle is $\pi$, we simply need to prove that the radius of that circle is exactly 1. Since the area of a circle is calculated as $A = \pi r^2$, if $r=1$, the area is $\pi (1)^2 = \pi$. Here is the step-by-step breakdown of why the radius works out to be exactly 1 for a 3-4-5 triangle.

1. Find the Area of the Triangle


First, we calculate the area of the triangle itself. Since a 3-4-5 triangle is a right-angled triangle (because $3^2 + 4^2 = 5^2$), we can use the two legs (3 and 4) as the base and height.
$$ \begin{align} \text{Area } &= \frac{1}{2} \times \text{base} \times \text{height} \\ \text{Area } &= \frac{1}{2} \times 3 \times 4 = \mathbf{6} \end{align} $$

2. Find the Semi-perimeter ($s$)


The semi-perimeter is half of the total perimeter of the triangle.

$$s = \frac{3 + 4 + 5}{2} = \frac{12}{2} = \mathbf{6}$$

3. Calculate the Inradius ($r$)


There is a standard geometric formula connecting the Area of a triangle ($A$), its semi-perimeter ($s$), and the radius of its inscribed circle ($r$):

$$A = r \cdot s$$

We substitute the values we found in steps 1 and 2:

$$6 = r \cdot 6$$

Solving for $r$:

$$r = 1$$


Figure 2


Alternative Visual Proof (The "Tangent" Method)


You can also visualize this without using the area formula (see Figure 2).

  1. The Square in the Corner: In a right-angled triangle, the incircle creates a perfect square at the 90-degree corner. The sides of this square correspond to the radius $r$.

  2. Tangent Lengths: The distance from a triangle vertex to the point where the circle touches the side is equal on both sides of the corner.

  3. The Calculation:

    • The leg of length 3 is made of the radius $r$ and a remaining segment $(3-r)$.

    • The leg of length 4 is made of the radius $r$ and a remaining segment $(4-r)$.

    • The hypotenuse (length 5) is composed of these two remaining segments connected together.

Therefore:

$$(3 - r) + (4 - r) = 5$$
$$7 - 2r = 5$$
$$2r = 2$$
$$r = \mathbf{1}$$

Conclusion


Since the radius ($r$) is 1, the area of the incircle is:

$$ \text{Area } = \pi r^2 = \pi (1)^2 = \mathbf{\pi}$$

Would you like to know if there are other Pythagorean triples (like 5-12-13) that result in integer radii?

Yes. In fact, there is a fascinating rule in geometry: Every single Pythagorean triangle (where sides are integers) has an incircle with an integer radius.

So, the 3-4-5 triangle isn't a lucky exception—it is just the first in an infinite series.

The Shortcut Formula


You don't need to calculate the full area and semi-perimeter every time. As we saw in the "Tangent Method" previously, for any right-angled triangle with legs $a, b$ and hypotenuse $c$, the radius $r$ is simply:

$$r = \frac{a + b - c}{2}$$

Because of how Pythagorean triples work (number theory), the top number $(a + b - c)$ is always an even number, meaning $r$ is always a clean integer.

Common Examples


Here are a few famous Pythagorean triples and their incircle areas.

Triangle (a,b,c)Calculation 2a+b−c​Radius (r)Incircle Area (Ï€r2)
3 - 4 - 5$(3+4-5)/2$1$\mathbf{1\pi}$
5 - 12 - 13$(5+12-13)/2$2$\mathbf{4\pi}$
8 - 15 - 17$(8+15-17)/2$3$\mathbf{9\pi}$
7 - 24 - 25$(7+24-25)/2$3$\mathbf{9\pi}$
20 - 21 - 29$(20+21-29)/2$6$\mathbf{36\pi}$

Why is the radius always an integer?


For the radius to be an integer, the numerator $(a + b - c)$ must be divisible by 2.

In any primitive Pythagorean triple:

  1. One leg is always odd.

  2. The other leg is always even.

  3. The hypotenuse is always odd.

If you add an Odd + Even number, you get an Odd number.

If you then subtract the Odd hypotenuse, you get an Even number.

Since an even number divided by 2 is always an integer, the radius is always an integer.


Now back to me. What's great about Gemini is that the LaTeX formatting is built into the response which saves a great deal in time and effort to get things looking good. It's also made me realise that the $ is for easier to use for inline formatting than the \( that I've been using previously. I'm thinking of transitioning but first I thought I'd consult Gemini. It provided a comprehensive response and I was surprised about what was said about display format.

Is there any advantage or disadvantage to using "\)" versus "$" in LaTeX for inline formatting?

For most users, this is a choice between theoretical correctness (using \( \)) and practical convenience (using $).

While \( \) is technically the "official" LaTeX standard, the vast majority of LaTeX users—including experts—still use $ because it is faster to type and easier to read in the source code.

Here is the breakdown of the advantages and disadvantages.

Quick Comparison

Feature\( ... \) (LaTeX Standard)$ ... $ (TeX Primitive)
TypingSlower (2 keys: \ + ()Faster (1 key: $)
Error MessagesClearer (specific errors)Cryptic ("Missing $ inserted")
ParsingClear start/end delimitersAmbiguous start/end
ReadabilityCluttered in source codeCleaner in source code
RecommendationBest for macros & strictnessBest for manual editing

Deep Dive: Why use \( ... \)?

The \( ... \) syntax is a LaTeX wrapper around the primitive $. It adds a layer of logic that provides two main benefits:

1. Better Error Reporting

Because \( and \) are distinct commands for "start" and "end," LaTeX can tell you exactly what went wrong.

  • Scenario: You accidentally forget to close a math environment.

  • $ Result: LaTeX gets confused until it hits the next dollar sign later in the document, often breaking the rest of your text with a confusing Missing $ inserted error.

  • \( Result: LaTeX checks if you are already in math mode. If you try to open math mode when you are already inside it (or close it when you aren't in it), it stops immediately and gives you a LaTeX Error: Bad math environment delimiter.

2. Programmability & Search

  • Regex: It is much easier to search and replace math in your code using Regular Expressions because the start \( and end \) are different. With $, it is difficult for a script to tell if a specific $ marks the beginning or the end of a formula.

  • Macros: If you are writing your own packages or complex macros, \( \) is safer because it explicitly defines the boundary.


Deep Dive: Why use $ ... $?

Despite the advantages above, $ remains the dominant choice for one simple reason: ergonomics.

1. Source Code Readability

LaTeX source code can get messy. Adding backslashes and parentheses adds visual noise.

  • With $ : Let $x$ be a value such that $x > 0$. (Easy to scan)

  • With \(: Let \(x\) be a value such that \(x > 0\). (Harder to scan)

2. Muscle Memory

Pressing Shift+4 (on US keyboards) is significantly faster than typing \, Shift+9. Over the course of a long paper with hundreds of inline variables, this friction adds up.


Important Note: Display Math is Different

While $ vs \( is mostly a matter of preference, the rule for display math (equations on their own line) is much stricter.

You should always use \[ ... \] and never use $$...$$.

  • $$ is a plain TeX command that modifies vertical spacing in ways that are inconsistent with LaTeX style standards (especially the fleqn option).

  • \[ is the correct LaTeX command that handles spacing and checks properly.

Summary

  • For Inline Math: Use $ if you prefer speed and readability. Use \( if you want better error checking or are processing your files with external scripts.

  • For Display Math: Always use \[ ... \].