Popular – BetterExplained https://betterexplained.com Math lessons that click Mon, 08 Dec 2025 22:27:03 +0000 en-US hourly 1 How To Learn Trigonometry Intuitively https://betterexplained.com/articles/intuitive-trigonometry/ https://betterexplained.com/articles/intuitive-trigonometry/#comments Mon, 24 Feb 2014 16:30:11 +0000 http://betterexplained.com/?p=3844 Trig mnemonics like SOH-CAH-TOA focus on computations, not concepts:

body proportions

TOA explains the tangent about as well as $x^2 + y^2 = r^2$ describes a circle. Sure, if you’re a math robot, an equation is enough. The rest of us, with organic brains half-dedicated to vision processing, seem to enjoy imagery. And “TOA” evokes the stunning beauty of an abstract ratio.

I think you deserve better, and here’s what made trig click for me.

  • Visualize a dome, a wall, and a ceiling
  • Trig functions are percentages to the three shapes

Motivation: Trig Is Anatomy

Imagine Bob The Alien visits Earth to study our species.

Without new words, humans are hard to describe: “There’s a sphere at the top, which gets scratched occasionally” or “Two elongated cylinders appear to provide locomotion”.

After creating specific terms for anatomy, Bob might jot down typical body proportions:

  • The armspan (fingertip to fingertip) is approximately the height
  • A head is 5 eye-widths wide
  • Adults are 8 head-heights tall

body proportions trig analogy

How is this helpful?

Well, when Bob finds a jacket, he can pick it up, stretch out the arms, and estimate the owner’s height. And head size. And eye width. One fact is linked to a variety of conclusions.

Even better, human biology explains human thinking. Tables have legs, organizations have heads, crime bosses have muscle. Our biology offers ready-made analogies that appear in man-made creations.

Now the plot twist: you are Bob the alien, studying creatures in math-land!

Generic words like “triangle” aren’t overly useful. But labeling sine, cosine, and hypotenuse helps us notice deeper connections. And scholars might study haversine, exsecant and gamsin, like biologists who find a link between your tibia and clavicle.

And because triangles show up in circles…

circular path

…and circles appear in cycles, our triangle terminology helps describe repeating patterns!

Trig is the anatomy book for “math-made” objects. If we can find a metaphorical triangle, we’ll get an armada of conclusions for free.

Sine/Cosine: The Dome

Instead of staring at triangles by themselves, like a caveman frozen in ice, imagine them in a scenario, hunting that mammoth.

Pretend you’re in the middle of your dome, about to hang up a movie screen. You point to some angle “x”, and that’s where the screen will hang.

Trig dome analogy

The angle you point at determines:

  • sine(x) = sin(x) = height of the screen, hanging like a sign
  • cosine(x) = cos(x) = distance to the screen along the ground [“cos” ~ how “close”]
  • the hypotenuse, the distance to the top of the screen, is always the same

Want the biggest screen possible? Point straight up. It’s at the center, on top of your head, but it’s big dagnabbit.

Want the screen the furthest away? Sure. Point straight across, 0 degrees. The screen has “0 height” at this position, and it’s far away, like you asked.

The height and distance move in opposite directions: bring the screen closer, and it gets taller.

Tip: Trig Values Are Percentages

Nobody ever told me in my years of schooling: sine and cosine are percentages. They vary from +100% to 0 to -100%, or max positive to nothing to max negative.

Let’s say I paid \$14 in tax. You have no idea if that’s expensive. But if I say I paid 95% in tax, you know I’m getting ripped off.

An absolute height isn’t helpful, but if your sine value is .95, I know you’re almost at the top of your dome. Pretty soon you’ll hit the max, then start coming down again.

How do we compute the percentage? Simple: divide the current value by the maximum possible (the radius of the dome, aka the hypotenuse).

That’s why we’re told “Sine = Opposite / Hypotenuse”. It’s to get a percentage! A better wording is “Sine is your height, as a percentage of the hypotenuse”. (Sine becomes negative if your angle points “underground”. Cosine becomes negative when your angle points backwards.)

Let’s simplify the calculation by assuming we’re on the unit circle (radius 1). Now we can skip the division by 1 and just say sine = height.

Every circle is really the unit circle, scaled up or down to a different size. So work out the connections on the unit circle and apply the results to your particular scenario.

Try it out: plug in an angle and see what percent of the height and width it reaches:

The growth pattern of sine isn’t an even line. The first 45 degrees cover 70% of the height, and the final 10 degrees (from 80 to 90) only cover 2%.

This should make sense: at 0 degrees, you’re moving nearly vertical, but as you get to the top of the dome, your height changes level off.

Tangent/Secant: The Wall

One day your neighbor puts up a wall right next to your dome. Ack, your view! Your resale value!

But can we make the best of a bad situation?

trig wall analogy

Sure. What if we hang our movie screen on the wall? You point at an angle (x) and figure out:

  • tangent(x) = tan(x) = height of screen on the wall
  • distance to screen: 1 (the screen is always the same distance along the ground, right?)
  • secant(x) = sec(x) = the “ladder distance” to the screen

We have some fancy new vocab terms. Imagine seeing the Vitruvian “TAN GENTleman” projected on the wall. You climb the ladder, making sure you can “SEE, CAN’T you?”. (Yeah, he’s naked… won’t forget the analogy now, will you?)

Let’s notice a few things about tangent, the height of the screen.

  • It starts at 0, and goes infinitely high. You can keep pointing higher and higher on the wall, to get an infinitely large screen! (That’ll cost ya.)

  • Tangent is just a bigger version of sine! It’s never smaller, and while sine “tops off” as the dome curves in, tangent keeps growing.

How about secant, the ladder distance?

  • Secant starts at 1 (ladder on the floor to the wall) and grows from there
  • Secant is always longer than tangent. The leaning ladder used to put up the screen must be longer than the screen itself, right? (At enormous sizes, when the ladder is nearly vertical, they’re close. But secant is always a smidge longer.)

Remember, the values are percentages. If you’re pointing at a 50-degree angle, tan(50) = 1.19. Your screen is 19% larger than the distance to the wall (the radius of the dome).

(Plug in x=0 and check your intuition that tan(0) = 0, and sec(0) = 1.)

Cotangent/Cosecant: The Ceiling

Amazingly enough, your neighbor now decides to build a ceiling on top of your dome, far into the horizon. (What’s with this guy? Oh, the naked-man-on-my-wall incident…)

Well, time to build a ramp to the ceiling, and have a little chit chat. You pick an angle to build and work out:

trig ceiling

  • cotangent(x) = cot(x) = how far the ceiling extends before we connect
  • cosecant(x) = csc(x) = how long we walk on the ramp
  • the vertical distance traversed is always 1

Tangent/secant describe the wall, and COtangent and COsecant describe the ceiling.

Our intuitive facts are similar:

  • If you pick an angle of 0, your ramp is flat (infinite) and never reachers the ceiling. Bummer.
  • The shortest “ramp” is when you point 90-degrees straight up. The cotangent is 0 (we didn’t move along the ceiling) and the cosecant is 1 (the “ramp length” is at the minimum).

Visualize The Connections

A short time ago I had zero “intuitive conclusions” about the cosecant. But with the dome/wall/ceiling metaphor, here’s what we see:

Trig all functions in a single diagram

Whoa, it’s the same triangle, just scaled to reach the wall and ceiling. We have vertical parts (sine, tangent), horizontal parts (cosine, cotangent), and “hypotenuses” (secant, cosecant). (Note: the labels show where each item “goes up to”. Cosecant is the full distance from you to the ceiling.)

Now the magic. The triangles have similar facts:

Trig identities from similar triangles and pythagorean theorem

From the Pythagorean Theorem ($a^2 + b^2 = c^2$) we see how the sides of each triangle are linked.

And from similarity, ratios like “height to width” must be the same for these triangles. (Intuition: step away from a big triangle. Now it looks smaller in your field of view, but the internal ratios couldn’t have changed.)

This is how we find out “sine/cosine = tangent/1”.

I’d always tried to memorize these facts, when they just jump out at us when visualized. SOH-CAH-TOA is a nice shortcut, but get a real understanding first!

Gotcha: Remember Other Angles

Psst… don’t over-focus on a single diagram, thinking tangent is always smaller than 1. If we increase the angle, we reach the ceiling before the wall:

Trig alternative

The Pythagorean/similarity connections are always true, but the relative sizes can vary.

(But, you might notice that sine and cosine are always smallest, or tied, since they’re trapped inside the dome. Nice!)

Summary: What Should We Remember?

For most of us, I’d say this is enough:

  • Trig explains the anatomy of “math-made” objects, such as circles and repeating cycles
  • The dome/wall/ceiling analogy shows the connections between the trig functions
  • Trig functions return percentages, that we apply to our specific scenario

You don’t need to memorize $1^2 + \cot^2 = \csc^2$, except for silly tests that mistake trivia for understanding. In that case, take a minute to draw the dome/wall/ceiling diagram, fill in the labels (a tan gentleman you can see, can’t you?), and create a cheatsheet for yourself.

In a follow-up, we’ll learn about graphing, complements, and using Euler’s Formula to find even more connections.

Appendix: The Original Definition Of Tangent

You may see tangent defined as the length of the tangent line from the circle to the x-axis (geometry buffs can work this out).

Tangent

As expected, at the top of the circle (x=90) the tangent line can never reach the x-axis and is infinitely long.

I like this intuition because it helps us remember the name “tangent”, and here’s a nice interactive trig guide to explore:

Trig interactive

Still, it’s critical to put the tangent vertical and recognize it’s just sine projected on the back wall (along with the other triangle connections).

Appendix: Inverse Functions

Trig functions take an angle and return a percentage. $\sin(30) = .5$ means a 30-degree angle is 50% of the max height.

The inverse trig functions let us work backwards, and are written $\sin^{-1}$ or $\arcsin$ (“arcsine”), and often written asin in various programming languages.

If our height is 25% of the dome, what’s our angle?

Plugging asin(.25) into a calculator gives an angle of 14.5 degrees.

Now what about something exotic, like inverse secant? Often times it’s not available as a calculator function (even the one I built, sigh).

Looking at our trig cheatsheet, we find an easy ratio where we can compare secant to 1. For example, secant to 1 (hypotenuse to horizontal) is the same as 1 to cosine:

\displaystyle{\frac{\sec}{1} = \frac{1}{\cos}}

Suppose our secant is 3.5, i.e. 350% of the radius of the unit circle. What’s the angle to the wall?


\begin{aligned}
\frac{\sec}{1} &= \frac{1}{\cos} = 3.5 \\
\cos &= \frac{1}{3.5} \\
\arccos(\frac{1}{3.5}) &= 73.4
\end{aligned}

Appendix: A Few Examples

Example: Find the sine of angle x.

Sine Example

Ack, what a boring question. Instead of “find the sine” think, “What’s the height as a percentage of the max (the hypotenuse)?”.

First, notice the triangle is “backwards”. That’s ok. It still has a height, in green.

What’s the max height? By the Pythagorean theorem, we know


\begin{aligned}
3^2 + 4^2 &= \text{hypotenuse}^2 \\
25 &= \text{hypotenuse}^2 \\
5 &= \text{hypotenuse}
\end{aligned}

Ok! The sine is the height as a percentage of the max, which is 3/5 or .60.

Follow-up: Find the angle.

Of course. We have a few ways. Now that we know sine = .60, we can just do:

\displaystyle{\arcsin(.60) = 36.9}

Here’s another approach. Instead of using sine, notice the triangle is “up against the wall”, so tangent is an option. The height is 3, the distance to the wall is 4, so the tangent height is 3/4 or 75%. We can use arctangent to turn the percentage back into an angle:

\displaystyle{\tan = \frac{3}{4} = .75 }

\displaystyle{\arctan(.75) = 36.9}

Example: Can you make it to shore?

Boat Example

You’re on a boat with enough fuel to sail 2 miles. You’re currently .25 miles from shore. What’s the largest angle you could use and still reach land? Also, the only reference available is Hubert’s Compendium of Arccosines, 3rd Ed. (Truly, a hellish voyage.)

Ok. Here, we can visualize the beach as the “wall” and the “ladder distance” to the wall is the secant.

First, we need to normalize everything in terms of percentages. We have 2 / .25 = 8 “hypotenuse units” worth of fuel. So, the largest secant we could allow is 8 times the distance to the wall.

We’d like to ask “What angle has a secant of 8?”. But we can’t, since we only have a book of arccosines.

We use our cheatsheet diagram to relate secant to cosine: Ah, I see that “sec/1 = 1/cos”, so


\begin{aligned}
\sec &= \frac{1}{\cos} = 8 \\
\cos &= \frac{1}{8} \\
\arccos(\frac{1}{8}) &= 82.8
\end{aligned}

A secant of 8 implies a cosine of 1/8. The angle with a cosine of 1/8 is arccos(1/8) = 82.8 degrees, the largest we can afford.

Not too bad, right? Before the dome/wall/ceiling analogy, I’d be drowning in a mess of computations. Visualizing the scenario makes it simple, even fun, to see which trig buddy can help us out.

In your problem, think: am I interested in the dome (sin/cos), the wall (tan/sec), or the ceiling (cot/csc)?

Happy math.

Update: The owner of Grey Matters put together interactive diagrams for the analogies (drag the slider on the left to change the angle):

interactive-2

Thanks!

]]>
https://betterexplained.com/articles/intuitive-trigonometry/feed/ 153
An Interactive Guide To The Fourier Transform https://betterexplained.com/articles/an-interactive-guide-to-the-fourier-transform/ https://betterexplained.com/articles/an-interactive-guide-to-the-fourier-transform/#comments Thu, 20 Dec 2012 03:30:10 +0000 http://betterexplained.com/?p=2851 The Fourier Transform is one of deepest insights ever made. Unfortunately, the meaning is buried within dense equations:

\displaystyle{X_k = \sum_{n=0}^{N-1} x_n \cdot e^{-i 2 \pi k n / N}}

\displaystyle{x_n = \frac{1}{N} \sum_{k=0}^{N-1} X_k \cdot e^{i 2 \pi k n / N}}

Yikes. Rather than jumping into the symbols, let's experience the key idea firsthand. Here's a plain-English metaphor:

  • What does the Fourier Transform do? Given a smoothie, it finds the recipe.
  • How? Run the smoothie through filters to extract each ingredient.
  • Why? Recipes are easier to analyze, compare, and modify than the smoothie itself.
  • How do we get the smoothie back? Blend the ingredients.

Here's the "math English" version of the above:

  • The Fourier Transform takes a time-based pattern, measures every possible cycle, and returns the overall "cycle recipe" (the amplitude, offset, & rotation speed for every cycle that was found).

Time for the equations? No! Let's get our hands dirty and experience how any pattern can be built with cycles, with live simulations.

If all goes well, we'll have an aha! moment and intuitively realize why the Fourier Transform is possible. We'll save the detailed math analysis for the follow-up.

This isn't a force-march through the equations, it's the casual stroll I wish I had. Onward!

From Smoothie to Recipe

A math transformation is a change of perspective. We change our notion of quantity from "single items" (lines in the sand, tally system) to "groups of 10" (decimal) depending on what we're counting. Scoring a game? Tally it up. Multiplying? Decimals, please.

The Fourier Transform changes our perspective from consumer to producer, turning What do I have? into How was it made?

In other words: given a smoothie, let's find the recipe.

Why? Well, recipes are great descriptions of drinks. You wouldn't share a drop-by-drop analysis, you'd say "I had an orange/banana smoothie". A recipe is more easily categorized, compared, and modified than the object itself.

So... given a smoothie, how do we find the recipe?

fourier transform analogy smoothie to recipe

Well, imagine you had a few filters lying around:

  • Pour through the "banana" filter. 1 oz of bananas are extracted.
  • Pour through the "orange" filter. 2 oz of oranges.
  • Pour through the "milk" filter. 3 oz of milk.
  • Pour through the "water" filter. 3 oz of water.

We can reverse-engineer the recipe by filtering each ingredient. The catch?

  • Filters must be independent. The banana filter needs to capture bananas, and nothing else. Adding more oranges should never affect the banana reading.

  • Filters must be complete. We won't get the real recipe if we leave out a filter ("There were mangoes too!"). Our collection of filters must catch every possible ingredient.

  • Ingredients must be combine-able. Smoothies can be separated and re-combined without issue (A cookie? Not so much. Who wants crumbs?). The ingredients, when separated and combined in any order, must make the same result.

See The World As Cycles

The Fourier Transform takes a specific viewpoint: What if any signal could be filtered into a bunch of circular paths?

Whoa. This concept is mind-blowing, and poor Joseph Fourier had his idea rejected at first. (Really Joe, even a staircase pattern can be made from circles?)

And despite decades of debate in the math community, we expect students to internalize the idea without issue. Ugh. Let's walk through the intuition.

The Fourier Transform finds the recipe for a signal, like our smoothie process:

  • Start with a time-based signal
  • Apply filters to measure each possible "circular ingredient"
  • Collect the full recipe, listing the amount of each "circular ingredient"

Stop. Here's where most tutorials excitedly throw engineering applications at your face. Don't get scared; think of the examples as "Wow, we're finally seeing the source code (DNA) behind previously confusing ideas".

  • If earthquake vibrations can be separated into "ingredients" (vibrations of different speeds & amplitudes), buildings can be designed to avoid interacting with the strongest ones.

  • If sound waves can be separated into ingredients (bass and treble frequencies), we can boost the parts we care about, and hide the ones we don't. The crackle of random noise can be removed. Maybe similar "sound recipes" can be compared (music recognition services compare recipes, not the raw audio clips).

  • If computer data can be represented with oscillating patterns, perhaps the least-important ones can be ignored. This "lossy compression" can drastically shrink file sizes (and why JPEG and MP3 files are much smaller than raw .bmp or .wav files).

  • If a radio wave is our signal, we can use filters to listen to a particular channel. In the smoothie world, imagine each person paid attention to a different ingredient: Adam looks for apples, Bob looks for bananas, and Charlie gets cauliflower (sorry bud).

The Fourier Transform is useful in engineering, sure, but it's a metaphor about finding the root causes behind an observed effect.

Think With Circles, Not Just Sinusoids

One of my giant confusions was separating the definitions of "sinusoid" and "circle".

  • A "sinusoid" is a specific back-and-forth pattern (a sine or cosine wave), and 99% of the time, it refers to motion in one dimension.
  • A "circle" is a round, 2d pattern you probably know. If you enjoy using 10-dollar words to describe 10-cent ideas, you might call a circular path a "complex sinusoid".

Labeling a circular path as a "complex sinusoid" is like describing a word as a "multi-letter". You zoomed into the wrong level of detail. Words are about concepts, not the letters they can be split into!

The Fourier Transform is about circular paths (not 1-d sinusoids) and Euler's formula is a clever way to generate one:

euler path

Must we use imaginary exponents to move in a circle? Nope. But it's convenient and compact. And sure, we can describe our path as coordinated motion in two dimensions (real and imaginary), but don't forget the big picture: we're just moving in a circle.

Following Circular Paths

Let's say we're chatting on the phone and, like usual, I want us to draw the same circle simultaneously. (You promised!) What should I say?

  • How big is the circle? (Amplitude, i.e. size of radius)
  • How fast do we draw it? (Frequency. 1 circle/second is a frequency of 1 Hertz (Hz) or 2*pi radians/sec)
  • Where do we start? (Phase angle, where 0 degrees is the x-axis)

I could say "2-inch radius, start at 45 degrees, 1 circle per second, go!". After half a second, we should each be pointing to: starting point + amount traveled = 45 + 180 = 225 degrees (on a 2-inch circle).

circular path with parameters

Every circular path needs a size, speed, and starting angle (amplitude/frequency/phase). We can even combine paths: imagine tiny motorcars, driving in circles at different speeds.

The combined position of all the cycles is our signal, just like the combined flavor of all the ingredients is our smoothie.

Here's a simulation of a basic circular path:

(Based on this animation, here's the source code. Modern browser required. Click the graph to pause/unpause.)

The magnitude of each cycle is listed in order, starting at 0Hz. Cycles [0 1] means

  • 0 amplitude for the 0Hz cycle (0Hz = a constant cycle, stuck on the x-axis at zero degrees)
  • 1 amplitude for the 1Hz cycle (completes 1 cycle per time interval)

Now the tricky part:

  • The blue graph measures the real part of the cycle. Another lovely math confusion: the real axis of the circle, which is usually horizontal, has its magnitude shown on the vertical axis. You can mentally rotate the circle 90 degrees if you like.
  • The time points are spaced at the fastest frequency. A 1Hz signal needs 2 time points for a start and stop (a single data point doesn't have a frequency). The time values [1 -1] shows the amplitude at these equally-spaced intervals.

With me? [0 1] is a pure 1Hz cycle.

Now let's add a 2Hz cycle to the mix. [0 1 1] means "Nothing at 0Hz, 1Hz of amplitude 1, 2Hz of amplitude 1":

Whoa. The little motorcars are getting wild: the green lines are the 1Hz and 2Hz cycles, and the blue line is the combined result. Try toggling the green checkbox to see the final result clearly. The combined "flavor" is a sway that starts at the max and dips low for the rest of the interval.

The yellow dots are when we actually measure the signal. With 3 cycles defined (0Hz, 1Hz, 2Hz), each dot is 1/3 of the way through the signal. In this case, cycles [0 1 1] generate the time values [2 -1 -1], which starts at the max (2) and dips low (-1).

Oh! We can't forget phase, the starting angle! Use magnitude:angle to set the phase. So [0 1:45] is a 1Hz cycle that starts at 45 degrees:

This is a shifted version of [0 1]. On the time side we get [.7 -.7] instead of [1 -1], because our cycle isn't exactly lined up with our measuring intervals, which are still at the halfway point (this could be desired!).

The Fourier Transform finds the set of cycle speeds, amplitudes and phases to match any time signal.

Our signal becomes an abstract notion that we consider as "observations in the time domain" or "ingredients in the frequency domain".

Enough talk: try it out! In the simulator, type any time or cycle pattern you'd like to see. If it's time points, you'll get a collection of cycles (that combine into a "wave") that matches your desired points.

fourier transform examples

But… doesn't the combined wave have strange values between the yellow time intervals? Sure. But who's to say whether a signal travels in straight lines, or curves, or zips into other dimensions when we aren't measuring it? It behaves exactly as we need at the equally-spaced moments we asked for.

Making A Spike In Time

Can we make a spike in time, like (4 0 0 0), using cycles? I'll use parentheses () for a sequence of time points, and brackets [] for a sequence of cycles.

Although the spike seems boring to us time-dwellers (one data point, that's it?), think about the complexity in the cycle world. Our cycle ingredients must start aligned (at the max value, 4) and then "explode outwards", each cycle with partners that cancel it in the future. Every remaining point is zero, which is a tricky balance with multiple cycles running around (we can't just "turn them off").

Let's walk through each time point:

  • At time 0, the first instant, every cycle ingredient is at its max. Ignoring the other time points, (4 ? ? ?) can be made from 4 cycles (0Hz 1Hz 2Hz 3Hz), each with a magnitude of 1 and phase of 0 (i.e., 1 + 1 + 1 + 1 = 4).

  • At every future point (t = 1, 2, 3), the sum of all cycles must cancel.

Here's the trick: when two cycles are on opposites sides of the circle (North & South, East & West, etc.) their combined position is zero (3 cycles can cancel if they're spread evenly at 0, 120, and 240 degrees).

Imagine a constellation of points moving around the circle. Here's the position of each cycle at every instant:

Time 0 1 2 3 
------------
0Hz: 0 0 0 0 
1Hz: 0 1 2 3
2Hz: 0 2 0 2
3Hz: 0 3 2 1

Notice how the the 3Hz cycle starts at 0, gets to position 3, then position "6" (with only 4 positions, 6 modulo 4 = 2), then position "9" (9 modulo 4 = 1).

When our cycle is 4 units long, cycle speeds a half-cycle apart (2 units) will either be lined up (difference of 0, 4, 8…) or on opposite sides (difference of 2, 6, 10…).

OK. Let's drill into each time point:

  • Time 0: All cycles at their max (total of 4)
  • Time 1: 1Hz and 3Hz cancel (positions 1 & 3 are opposites), 0Hz and 2Hz cancel as well. The net is 0.
  • Time 2: 0Hz and 2Hz line up at position 0, while 1Hz and 3Hz line up at position 2 (the opposite side). The total is still 0.
  • Time 3: 0Hz and 2Hz cancel. 1Hz and 3Hz cancel.
  • Time 4 (repeat of t=0): All cycles line up.

The trick is having individual speeds cancel (0Hz vs 2Hz, 1Hz vs 3Hz), or having the lined-up pairs cancel (0Hz + 2Hz vs 1Hz + 3Hz).

When every cycle has equal power and 0 phase, we start aligned and cancel afterwards. (I don't have a nice proof yet -- any takers? -- but you can see it yourself. Try [1 1], [1 1 1], [1 1 1 1] and notice the signals we generate: (2 0), (3 0 0), (4 0 0 0)).

In my head, I label these signals as "time spikes": they have a value for a single instant, and are zero otherwise (the fancy name is a delta function.)

Here's how I visualize the initial alignment, followed by a net cancellation:

fourier transform constructive and destructive interference

Moving The Time Spike

Not everything happens at t=0. Can we change our spike to (0 4 0 0)?

It seems the cycle ingredients should be similar to (4 0 0 0), but the cycles must align at t=1 (one second in the future). Here's where phase comes in.

Imagine a race with 4 runners. Normal races have everyone lined up at the starting line, the (4 0 0 0) time pattern. Boring.

What if we want everyone to finish at the same time? Easy. Just move people forward or backwards by the appropriate distance. Maybe granny can start 2 feet in front of the finish line, Usain Bolt can start 100m back, and they can cross the tape holding hands.

Phase shifts, the starting angle, are delays in the cycle universe. Here's how we adjust the starting position to delay every cycle 1 second:

  • A 0Hz cycle doesn't move, so it's already aligned
  • A 1Hz cycle goes 1 revolution in the entire 4 seconds, so a 1-second delay is a quarter-turn. Phase shift it 90 degrees backwards (-90) and it gets to phase=0, the max value, at t=1.
  • A 2Hz cycle is twice as fast, so give it twice the angle to cover (-180 or 180 phase shift -- it's across the circle, either way).
  • A 3Hz cycle is 3x as fast, so give it 3x the distance to move (-270 or +90 phase shift)

If time points (4 0 0 0) are made from cycles [1 1 1 1], then time points (0 4 0 0) are made from [1 1:-90 1:180 1:90]. (Note: I'm using "1Hz", but I mean "1 cycle over the entire time period").

Whoa -- we're working out the cycles in our head!

The interference visualization is similar, except the alignment is at t=1.

fourier transform time spike

Test your intuition: Can you make (0 0 4 0), i.e. a 2-second delay? 0Hz has no phase. 1Hz has 180 degrees, 2Hz has 360 (aka 0), and 3Hz has 540 (aka 180), so it's [1 1:180 1 1:180].

Discovering The Full Transform

The big insight: our signal is just a bunch of time spikes! If we merge the recipes for each time spike, we should get the recipe for the full signal.

The Fourier Transform builds the recipe frequency-by-frequency:

  • Separate the full signal (a b c d) into "time spikes": (a 0 0 0) (0 b 0 0) (0 0 c 0) (0 0 0 d)
  • For any frequency (like 2Hz), the tentative recipe is "a/4 + b/4 + c/4 + d/4" (the amplitude of each spike is split among all frequencies)
  • Wait! We need to offset each spike with a phase delay (the angle for a "1 second delay" depends on the frequency).
  • Actual recipe for a frequency = a/4 (no offset) + b/4 (1 second offset) + c/4 (2 second offset) + d/4 (3 second offset).

We can then loop through every frequency to get the full transform.

Here's the conversion from "math English" to full math:

fourier transform plain english

A few notes:

  • N = number of time samples we have
  • n = current sample we're considering (0 .. N-1)
  • xn = value of the signal at time n
  • k = current frequency we're considering (0 Hertz up to N-1 Hertz)
  • Xk = amount of frequency k in the signal (amplitude and phase, a complex number)
  • The 1/N factor is usually moved to the reverse transform (going from frequencies back to time). This is allowed, though I prefer 1/N in the forward transform since it gives the actual sizes for the time spikes. You can get wild and even use $1/\sqrt{N}$ on both transforms (going forward and back creates the 1/N factor).
  • n/N is the percent of the time we've gone through. 2 * pi * k is our speed in radians / sec. e^-ix is our backwards-moving circular path. The combination is how far we've moved, for this speed and time.
  • The raw equations for the Fourier Transform just say "add the complex numbers". Many programming languages cannot handle complex numbers directly, so you convert everything to rectangular coordinates and add those.

Onward

This was my most challenging article yet. The Fourier Transform has several flavors (discrete/continuous/finite/infinite), covers deep math (Dirac delta functions), and it's easy to get lost in details. I was constantly bumping into the edge of my knowledge.

But there's always simple analogies out there -- I refuse to think otherwise. Whether it's a smoothie or Usain Bolt & Granny crossing the finish line, take a simple understanding and refine it. The analogy is flawed, and that's ok: it's a raft to use, and leave behind once we cross the river.

I realized how feeble my own understanding was when I couldn't work out the transform of (1 0 0 0) in my head. For me, it was like saying I knew addition but, gee whiz, I'm not sure what "1 + 1 + 1 + 1" would be. Why not? Shouldn't we have an intuition for the simplest of operations?

That discomfort led me around the web to build my intuition. In addition to the references in the article, I'd like to thank:

Today's goal was to experience the Fourier Transform. We'll save the advanced analysis for next time.

Happy math.

Appendix: Projecting Onto Cycles

Stuart Riffle has a great interpretation of the Fourier Transform:

fourier transform colorized

Imagine spinning your signal in a centrifuge and checking for a bias. I have a correction: we must spin backwards (the exponent in the equation above should be $e^{-i 2 \pi...}$). You already know why: we need a phase delay so spikes appear in the future.

Appendix: Another Awesome Visualization

Lucas Vieira, author of excellent Wikipedia animations, was inspired to make this interactive animation:

Fourier Toy - Click to download, requires flash

Fourier_Toy

(Detailed list of control options)

The Fourier Transform is about cycles added to cycles added to cycles. Try making a "time spike" by setting a amplitude of 1 for every component (press Enter after inputting each number). Fun fact: with enough terms, you can draw any shape, even Homer Simpson.

Check out http://www.jezzamon.com/fourier/ for a great tool to draw any shape using epicycles.

An Interactive Guide To The Fourier Transform

Appendix: Article with R code samples

João Neto made a great writeup, with technical (R) code samples here:

http://www.di.fc.ul.pt/~jpn/r/fourier/fourier.html

Appendix: Using the code

All the code and examples are open source (MIT licensed, do what you like).

]]>
https://betterexplained.com/articles/an-interactive-guide-to-the-fourier-transform/feed/ 421
An Intuitive Guide to Linear Algebra https://betterexplained.com/articles/linear-algebra-guide/ https://betterexplained.com/articles/linear-algebra-guide/#comments Tue, 09 Oct 2012 14:36:36 +0000 http://betterexplained.com/?p=2763 Despite two linear algebra classes, my knowledge consisted of “Matrices, determinants, eigen something something”.

Why? Well, let’s try this course format:

  • Name the course Linear Algebra but focus on things called matrices and vectors
  • Teach concepts like Row/Column order with mnemonics instead of explaining the reasoning
  • Favor abstract examples (2d vectors! 3d vectors!) and avoid real-world topics until the final week

The survivors are physicists, graphics programmers and other masochists. We missed the key insight:

Linear algebra gives you mini-spreadsheets for your math equations.

We can take a table of data (a matrix) and create updated tables from the original. It’s the power of a spreadsheet written as an equation.

Here’s the linear algebra introduction I wish I had, with a real-world stock market example.

What’s in a name?

“Algebra” means, roughly, “relationships”. Grade-school algebra explores the relationship between unknown numbers. Without knowing x and y, we can still work out that $(x + y)^2 = x^2 + 2xy + y^2$.

“Linear Algebra” means, roughly, “line-like relationships”. Let’s clarify a bit.

Straight lines are predictable. Imagine a rooftop: move forward 3 horizontal feet (relative to the ground) and you might rise 1 foot in elevation (The slope! Rise/run = 1/3). Move forward 6 feet, and you’d expect a rise of 2 feet. Contrast this with climbing a dome: each horizontal foot forward raises you a different amount.

Lines are nice and predictable:

  • If 3 feet forward has a 1-foot rise, then going 10x as far should give a 10x rise (30 feet forward is a 10-foot rise)
  • If 3 feet forward has a 1-foot rise, and 6 feet has a 2-foot rise, then (3 + 6) feet should have a (1 + 2) foot rise

In math terms, an operation F is linear if scaling inputs scales the output, and adding inputs adds the outputs:


\begin{aligned}
F(ax) &= a \cdot F(x) \\
F(x + y) &= F(x) + F(y)
\end{aligned}

In our example, $F(x)$ calculates the rise when moving forward x feet, and the properties hold:

\displaystyle{F(10 \cdot 3) = 10 \cdot F(3) = 10}

\displaystyle{F(3+6) = F(3) + F(6) = 3}

Linear Operations

An operation is a calculation based on some inputs. Which operations are linear and predictable? Multiplication, it seems.

Exponents ($F(x) = x^2$) aren’t predictable: $10^2$ is 100, but $20^2$ is 400. We doubled the input but quadrupled the output.

Surprisingly, regular addition isn’t linear either. Consider the “add three” function $F(x) = x + 3$:


\begin{aligned}
F(10) &= 13 \\
F(20) &= 23
\end{aligned}

We doubled the input and did not double the output. (Yes, $F(x) = x + 3$ happens to be the equation for an offset line, but it’s still not “linear” because $F(10) \neq 10 \cdot F(1)$. Fun.)

So, what types of functions are actually linear? Plain-old scaling by a constant, or functions that look like: $F(x) = ax$. In our roof example, $a = 1/3$.

But life isn’t too boring. We can still combine multiple linear functions ($A(x) = ax, B(x) = bx, C(x)=cx$) into a larger one, $G$:

\displaystyle{G(x,y,z) = A(x) + B(y) + C(z) = ax + by + cz }

$G$ is still linear, since doubling the input continues to double the output:

\displaystyle{G(2x, 2y, 2z) = a(2x) + b(2y) + c(2z) = 2(ax + by + cz) = 2 \cdot G(x, y, z)}

We have “mini arithmetic”: multiply inputs by a constant, and add the results. It’s actually useful because we can split inputs apart, analyze them individually, and combine the results:

\displaystyle{G(x,y,z) = G(x,0,0) + G(0,y,0) + G(0,0,z)}

If we allowed non-linear operations (like $x^2$) we couldn’t split our work and combine the results, since $(a+b)^2 \neq a^2 + b^2$. Limiting ourselves to linear operations has its advantages.

Organizing Inputs and Operations

Most courses hit you in the face with the details of a matrix. “Ok kids, let’s learn to speak. Select a subject, verb and object. Next, conjugate the verb. Then, add the prepositions…”

No! Grammar is not the focus. What’s the key idea?

  • We have a bunch of inputs to track
  • We have predictable, linear operations to perform (our “mini-arithmetic”)
  • We generate a result, perhaps transforming it again

Ok. First, how should we track a bunch of inputs? How about a list:

x
y
z

Not bad. We could write it (x, y, z) too — hang onto that thought.

Next, how should we track our operations? Remember, we only have “mini arithmetic”: multiplications by a constant, with a final addition. If our operation $F$ behaves like this:

\displaystyle{F(x, y, z) = 3x + 4y + 5z}

We could abbreviate the entire function as (3, 4, 5). We know to multiply the first input by the first value, the second input by the second value, the third input by the third value, and add the results.

Only need the first input?

\displaystyle{G(x, y, z) = 3x + 0y + 0z = (3, 0, 0)}

Let’s spice it up: how should we handle multiple sets of inputs? Let’s say we want to run operation F on both (a, b, c) and (x, y, z). We could try this:

\displaystyle{F(a, b, c, x, y, z) = ?}

But it won’t work: F expects 3 inputs, not 6. We should separate the inputs into groups:

1st Input  2nd Input
--------------------
a          x
b          y
c          z

Much neater.

And how could we run the same input through several operations? Have a row for each operation:

F: 3 4 5
G: 3 0 0

Neat. We’re getting organized: inputs in vertical columns, operations in horizontal rows.

Visualizing The Matrix

Words aren’t enough. Here’s how I visualize inputs, operations, and outputs:

linear algebra reference

Imagine “pouring” each input through each operation:

linear algebra pour in

As an input passes an operation, it creates an output item. In our example, the input (a, b, c) goes against operation F and outputs 3a + 4b + 5c. It goes against operation G and outputs 3a + 0 + 0.

Time for the red pill. A matrix is a shorthand for our diagrams:

\text{I}\text{nputs} = A = \begin{bmatrix} \text{i}\text{nput1}&\text{i}\text{nput2}\end{bmatrix} = \begin{bmatrix}a & x\\b & y\\c & z\end{bmatrix}

\text{Operations} = M = \begin{bmatrix}\text{operation1}\\ \text{operation2}\end{bmatrix} = \begin{bmatrix}3 & 4 & 5\\3 & 0 & 0\end{bmatrix}

A matrix is a single variable representing a spreadsheet of inputs or operations.

Trickiness #1: The reading order

Instead of an input => matrix => output flow, we use function notation, like y = f(x) or f(x) = y. We usually write a matrix with a capital letter (F), and a single input column with lowercase (x). Because we have several inputs (A) and outputs (B), they’re considered matrices too:

\displaystyle{MA = B}


\begin{bmatrix}3 & 4 & 5\\3 & 0 & 0\end{bmatrix} \begin{bmatrix}a & x\\b & y\\c & z\end{bmatrix}
= \begin{bmatrix}3a + 4b + 5c & 3x + 4y + 5z\\ 3a & 3x\end{bmatrix}

Trickiness #2: The numbering

Matrix size is measured as RxC: row count, then column count, and abbreviated “m x n” (I hear ya, “r x c” would be easier to remember). Items in the matrix are referenced the same way: aij is the ith row and jth column (I hear ya, “i” and “j” are easily confused on a chalkboard). Mnemonics are ok with context, and here’s what I use:

  • RC, like Roman Centurion or RC Cola
  • Use an “L” shape. Count down the L, then across

Why does RC ordering make sense? Our operations matrix is 2×3 and our input matrix is 3×2. Writing them together:

[Operation Matrix] [Input Matrix]
[operation count x operation size] [input size x input count]
[m x n] [p x q] = [m x q]
[2 x 3] [3 x 2] = [2 x 2]

Notice the matrices touch at the “size of operation” and “size of input” (n = p). They should match! If our inputs have 3 components, our operations should expect 3 items. In fact, we can only multiply matrices when n = p.

The output matrix has m operation rows for each input, and q inputs, giving a “m x q” matrix.

Fancier Operations

Let’s get comfortable with operations. Assuming 3 inputs, we can whip up a few 1-operation matrices:

  • Adder: [1 1 1]
  • Averager: [1/3 1/3 1/3]

The “Adder” is just a + b + c. The “Averager” is similar: (a + b + c)/3 = a/3 + b/3 + c/3.

Try these 1-liners:

  • First-input only: [1 0 0]
  • Second-input only: [0 1 0]
  • Third-input only: [0 0 1]

And if we merge them into a single matrix:

[1 0 0]
[0 1 0]
[0 0 1]

Whoa — it’s the “identity matrix”, which copies 3 inputs to 3 outputs, unchanged. How about this guy?

[1 0 0]
[0 0 1]
[0 1 0]

He reorders the inputs: (x, y, z) becomes (x, z, y).

And this one?

[2 0 0]
[0 2 0]
[0 0 2]

He’s an input doubler. We could rewrite him to 2*I (the identity matrix) if we were so inclined.

And yes, when we decide to treat inputs as vector coordinates, the operations matrix will transform our vectors. Here’s a few examples:

  • Scale: make all inputs bigger/smaller
  • Skew: make certain inputs bigger/smaller
  • Flip: make inputs negative
  • Rotate: make new coordinates based on old ones (East becomes North, North becomes West, etc.)

These are geometric interpretations of multiplication, and how to warp a vector space. Just remember that vectors are examples of data to modify.

A Non-Vector Example: Stock Market Portfolios

Let’s practice linear algebra in the real world:

  • Input data: stock portfolios with dollars in Apple, Google and Microsoft stock
  • Operations: the changes in company values after a news event
  • Output: updated portfolios

And a bonus output: let’s make a new portfolio listing the net profit/loss from the event.

Normally, we’d track this in a spreadsheet. Let’s learn to think with linear algebra:

  • The input vector could be (\$Apple, \$Google, \$Microsoft), showing the dollars in each stock. (Oh! These dollar values could come from another matrix that multiplied the number of shares by their price. Fancy that!)

  • The 4 output operations should be: Update Apple value, Update Google value, Update Microsoft value, Compute Profit

Visualize the problem. Imagine running through each operation:

linear algebra stock example

The key is understanding why we’re setting up the matrix like this, not blindly crunching numbers.

Got it? Let’s introduce the scenario.

Suppose a secret iDevice is launched: Apple jumps 20%, Google drops 5%, and Microsoft stays the same. We want to adjust each stock value, using something similar to the identity matrix:

New Apple     [1.2  0      0]
New Google    [0    0.95   0]
New Microsoft [0    0      1]

The new Apple value is the original, increased by 20% (Google = 5% decrease, Microsoft = no change).

Oh wait! We need the overall profit:

Total change = (.20 * Apple) + (-.05 * Google) + (0 * Microsoft)

Our final operations matrix:

New Apple       [1.2  0      0]
New Google      [0    0.95   0]
New Microsoft   [0    0      1]
Total Profit    [.20  -.05   0]

Making sense? Three inputs enter, four outputs leave. The first three operations are a “modified copy” and the last brings the changes together.

Now let’s feed in the portfolios for Alice \$1000, \$1000, \$1000) and Bob \$500, \$2000, \$500). We can crunch the numbers by hand, or use a Wolfram Alpha (calculation):

matrix stock computation

(Note: Inputs should be in columns, but it’s easier to type rows. The Transpose operation, indicated by t (tau), converts rows to columns.)

The final numbers: Alice has \$1200 in AAPL, \$950 in GOOG, \$1000 in MSFT, with a net profit of \$150. Bob has \$600 in AAPL, \$1900 in GOOG, and \$500 in MSFT, with a net profit of \$0.

What’s happening? We’re doing math with our own spreadsheet. Linear algebra emerged in the 1800s yet spreadsheets were invented in the 1980s. I blame the gap on poor linear algebra education.

Historical Notes: Solving Simultaneous equations

An early use of tables of numbers (not yet a “matrix”) was bookkeeping for linear systems:


\begin{aligned}
x + 2y + 3z &= 3 \\
2x + 3y + 1z &= -10 \\
5x + -y + 2z &= 14
\end{aligned}

becomes


\begin{bmatrix}1 & 2 & 3\\2 & 3 & 1\\5 & -1 & 2\end{bmatrix} \begin{bmatrix}x \\y \\ z \end{bmatrix}
= \begin{bmatrix}3 \\ -10 \\ 14 \end{bmatrix}

We can avoid hand cramps by adding/subtracting rows in the matrix and output, vs. rewriting the full equations. As the matrix evolves into the identity matrix, the values of x, y and z are revealed on the output side.

This process, called Gauss-Jordan elimination, saves time. However, linear algebra is mainly about matrix transformations, not solving large sets of equations (it’d be like using Excel for your shopping list).

Terminology, Determinants, and Eigenstuff

Words have technical categories to describe their use (nouns, verbs, adjectives). Matrices can be similarly subdivided.

Descriptions like “upper-triangular”, “symmetric”, “diagonal” are the shape of the matrix, and influence their transformations.

The determinant is the “size” of the output transformation. If the input was a unit vector (representing area or volume of 1), the determinant is the size of the transformed area or volume. A determinant of 0 means matrix is “destructive” and cannot be reversed (similar to multiplying by zero: information was lost).

The eigenvector and eigenvalue represent the “axes” of the transformation.

Consider spinning a globe: every location faces a new direction, except the poles.

An “eigenvector” is an input that doesn’t change direction when it’s run through the matrix (it points “along the axis”). And although the direction doesn’t change, the size might. The eigenvalue is the amount the eigenvector is scaled up or down when going through the matrix.

(My intuition here is weak, and I’d like to explore more. Here’s a nice diagram and video.)

Matrices As Inputs

A funky thought: we can treat the operations matrix as inputs!

Think of a recipe as a list of commands (Add 2 cups of sugar, 3 cups of flour…).

What if we want the metric version? Take the instructions, treat them like text, and convert the units. The recipe is “input” to modify. When we’re done, we can follow the instructions again.

An operations matrix is similar: commands to modify. Applying one operations matrix to another gives a new operations matrix that applies both transformations, in order.

If N is “adjust for portfolio for news” and T is “adjust portfolio for taxes” then applying both:

TN = X

means “Create matrix X, which first adjusts for news, and then adjusts for taxes”. Whoa! We didn’t need an input portfolio, we applied one matrix directly to the other.

The beauty of linear algebra is representing an entire spreadsheet calculation with a single letter. Want to apply the same transformation a few times? Use $N^2$ or $N^3$.

Can We Use Regular Addition, Please?

Yes, because you asked nicely. Our “mini arithmetic” seems limiting: multiplications, but no addition? Time to expand our brains.

Imagine adding a dummy entry of 1 to our input: (x, y, z) becomes (x, y, z, 1).

Now our operations matrix has an extra, known value to play with! If we want x + 1 we can write:

[1 0 0 1]

And x + y - 3 would be:

[1 1 0 -3]

Huzzah!

Want the geeky explanation? We’re pretending our input exists in a 1-higher dimension, and put a “1” in that dimension. We skew that higher dimension, which looks like a slide in the current one. For example: take input (x, y, z, 1) and run it through:

[1 0 0 1]
[0 1 0 1]
[0 0 1 1]
[0 0 0 1]

The result is (x + 1, y + 1, z + 1, 1). Ignoring the 4th dimension, every input got a +1. We keep the dummy entry, and can do more slides later.

Mini-arithmetic isn’t so limited after all.

Onward

I’ve overlooked some linear algebra subtleties, and I’m not too concerned. Why?

These metaphors are helping me think with matrices, more than the classes I “aced”. I can finally respond to “Why is linear algebra useful?” with “Why are spreadsheets useful?”

They’re not, unless you want a tool used to attack nearly every real-world problem. Ask a businessman if they’d rather donate a kidney or be banned from Excel forever. That’s the impact of linear algebra we’ve overlooked: efficient notation to bring spreadsheets into our math equations.

Happy math.

]]>
https://betterexplained.com/articles/linear-algebra-guide/feed/ 73
Intuitive Understanding Of Euler’s Formula https://betterexplained.com/articles/intuitive-understanding-of-eulers-formula/ https://betterexplained.com/articles/intuitive-understanding-of-eulers-formula/#comments Mon, 19 Jul 2010 17:55:21 +0000 http://betterexplained.com/?p=686 Euler's identity seems baffling:

\displaystyle{e^{i\pi} = -1}

It emerges from a more general formula:

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

Yowza -- we're relating an imaginary exponent to sine and cosine! And somehow plugging in pi gives -1? Could this ever be intuitive?

Not according to 1800s mathematician Benjamin Peirce:

It is absolutely paradoxical; we cannot understand it, and we don't know what it means, but we have proved it, and therefore we know it must be the truth.

Argh, this attitude makes my blood boil! Formulas are not magical spells to be memorized: we must, must, must find an insight. Here's mine:

Euler's formula describes two equivalent ways to move in a circle.

That's it? This stunning equation is about spinning around? Yes -- and we can understand it by building on a few analogies:

  • Starting at the number 1, see multiplication as a transformation that changes the number: $1 \cdot e^{i \pi}$
  • Regular exponential growth continuously increases 1 by some rate for some time period; imaginary exponential growth continuously rotates 1 for some time period
  • Growing for "pi" units of time means going pi radians around a circle
  • Therefore, $e^{i \pi}$ means starting at 1 and rotating pi (halfway around a circle) to get to -1

That's the high-level view, let's dive into the details. By the way, if someone tries to impress you with $e^{i \pi} = -1$, ask them about i to the i-th power. If they can't think it through, Euler's formula is still a magic spell to them.

Update: While writing, I thought a video might help explain the ideas more clearly:

Understanding cos(x) + i * sin(x)

The equals sign is overloaded. Sometimes we mean "set one thing to another" (like x = 3) and others we mean "these two things describe the same concept" (like $\sqrt{-1} = i$).

Euler's formula is the latter: it gives two formulas which explain how to move in a circle. If we examine circular motion using trig, and travel x radians:

imaginary numbers traversing a circle

  • cos(x) is the x-coordinate (horizontal distance)
  • sin(x) is the y-coordinate (vertical distance)

The statement

\displaystyle{\cos(x) + i \sin(x)}

is a clever way to smush the x and y coordinates into a single number. The analogy "complex numbers are 2-dimensional" helps us interpret a single complex number as a position on a circle.

When we set x to $\pi$, we're traveling $\pi$ units along the outside of the unit circle. Because the total circumference is $2\pi$, plain old $\pi$ is halfway around, putting us at -1.

Neato: The right side of Euler's formula ($\cos(x) + i \sin(x)$) describes circular motion with imaginary numbers. Now let's figure out how the e side of the equation accomplishes it.

What is Imaginary Growth?

Combining x- and y- coordinates into a complex number is tricky, but manageable. But what does an imaginary exponent mean?

Let's step back a bit. When I see $3^4$, I think of it like this:

  • 3 is the end result of growing instantly (using e) at a rate of ln(3). In other words: $3 = e^{\ln(3)}$
  • $3^4$ is the same as growing to 3, but then growing for 4x as long. So $3^4 = e^{\ln(3) \cdot 4} = 81$

Instead of seeing numbers on their own, you can think of them as something e had to "grow to". Real numbers, like 3, give an interest rate of ln(3) = 1.1, and that's what e "collects" as it's going along, growing continuously.

Regular growth is simple: it keeps "pushing" a number in the same, real direction it was going. 3 × 3 pushes in the original direction, making it 3 times larger (9).

imaginary growth

Imaginary growth is different: the "interest" we earn is in a different direction! It's like a jet engine that was strapped on sideways -- instead of going forward, we start pushing at 90 degrees.

The neat thing about a constant orthogonal (perpendicular) push is that it doesn't speed you up or slow you down -- it rotates you! Taking any number and multiplying by i will not change its magnitude, just the direction it points.

Intuitively, here's how I see continuous imaginary growth rate: "When I grow, don't push me forward or back in the direction I'm already going. Rotate me instead."

But Shouldn't We Spin Faster and Faster?

I wondered that too. Regular growth compounds in our original direction, so we go 1, 2, 4, 8, 16, multiplying 2x each time and staying in the real numbers. We can consider this $e^{\ln(2)x}$, which means grow instantly at a rate of ln(2) for "x" seconds.

And hey -- if our growth rate was twice as fast, 2ln(2) vs ln(2), it would look the same as growing for twice as long (2x vs x). The magic of e lets us swap rate and time; 2 seconds at ln(2) is the same growth as 1 second at 2ln(2).

Now, imagine we have some purely imaginary growth rate (Ri) that rotates us until we reach i, or 90 degrees upward. What happens if we double that rate to 2Ri, will we spin off the circle?

Nope! Having a rate of 2Ri means we just spin twice as fast, or alternatively, spin at a rate of R for twice as long, but we're staying on the circle. Rotating twice as long means we're now facing 180 degrees.

Once we realize that some exponential growth rate can take us from 1 to i, increasing that rate just spins us more. We'll never escape the circle.

However, if our growth rate is complex (a+bi vs Ri) then the real part (a) will grow us like normal, while the imaginary part (bi) rotates us. But let's not get fancy: Euler's formula, $e^{ix}$, is about the purely imaginary growth that keeps us on the circle (more later).

A Quick Sanity Check

While writing, I had to clarify a few questions for myself:

Why use $e^x$, aren't we rotating the number 1?

e represents the process of starting at 1 and growing continuously at 100% interest for 1 unit of time.

When we write e we're capturing that entire process in a single number -- e represents all the whole rigmarole of continuous growth. So really, $e^x$ is saying "start at 1 and grow continuously at 100% for x seconds", and starts from 1 like we want.

But what does i as an exponent do?

For a regular exponent like $3^4$ we ask:

  • What is the implicit growth rate? We're growing from 1 to 3 (the base of the exponent).
  • How do we change that growth rate? We scale it by 4x (the power of the exponent).

We can convert our growth into "e" format: our instantaneous rate is ln(3), and we increase it to ln(3) * 4. Again, the power of the exponent (4) just scaled our growth rate.

\displaystyle{3^4 = e^{\ln(3) \cdot 4} = (e^{\ln(3)})^4}

When the top exponent is i (as in $3^i$), we just multiply our implicit growth rate by i. So instead of growing at plain old ln(3), we're growing at ln(3) * i.

\displaystyle{3^i = e^{\ln(3) \cdot i} = (e^{\ln(3)})^i}

The top part of the exponent modifies the implicit growth rate of the bottom part.

The Nitty Gritty Details

Let's take a closer look. Remember this definition of e:

\displaystyle{e = e^{100\%} = \lim_{n\to\infty} \left( 1 + \frac{100\%}{n} \right)^n}

That $\frac{100\%}{n}$ represents the portion interest we earned in each microscopic period. We assumed the interest rate was 100% in the real dimension -- but what if it were 100% in the imaginary direction?

\displaystyle{e^{100\% \cdot i} = \lim_{n\to\infty} \left( 1 + \frac{100\%\cdot i}{n} \right)^n}

cumulative imaginary interest

Now, our newly formed interest adds to us in the 90-degree direction. Surprisingly, this does not change our length -- this is a tricky concept, because it appears to make a triangle where the hypotenuse must be larger. We're dealing with a limit, and the extra distance is within the error margin we specify. This is something I want to tackle another day, but take my word: continuous perpendicular growth will rotate you. This is the heart of sine and cosine, where your change is perpendicular to your current position, and you move in a circle.

We apply i units of growth in infinitely small increments, each pushing us at a 90-degree angle. There is no "faster and faster" rotation - instead, we crawl along the perimeter a distance of |i| = 1 (magnitude of i).

And hey -- the distance crawled around a circle is an angle in radians! We've found another way to describe circular motion!

To get circular motion: Change continuously by rotating at 90-degree angle (aka imaginary growth rate).

So, Euler's formula is saying "exponential, imaginary growth traces out a circle". And this path is the same as moving in a circle using sine and cosine in the imaginary plane.

In this case, the word "exponential" is confusing because we travel around the circle at a constant rate. In most discussions, exponential growth is assumed to have a cumulative, compounding effect.

Some Examples

You don't really believe me, do you? Here's a few examples, and how to think about them intuitively.

Example: $e^i$

Where's the x? Ah, it's just 1. Intuitively, without breaking out a calculator, we know that this means "travel 1 radian along the unit circle". In my head, I see "e" trying to grow 1 at 100% all in the same direction, but i keeps moving the ball and forces "1" to grow along the edge of a circle:

\displaystyle{e^i = \cos(1) + i \cdot \sin(1) = .5403 + .8415i}

Not the prettiest number, but there it is. Remember to put your calculator in radian mode when punching this in.

Example: $3^i$

This is tricky -- it's not in our standard format. But remember, \displaystyle{3^i = 1 \cdot 3^i}

We want an initial growth of 3x at the end of the period, or an instantaneous rate of ln(3). But, the i comes along and changes that rate of ln(3) to "i * ln(3)":

\displaystyle{3^i = (e^{\ln(3)})^i = e^{\ln(3)\cdot i}}

We thought we were going to transform at a regular rate of ln(3), a little faster than 100% continuous growth since e is about 2.718. But oh no, i spun us around: now we're transforming at an imaginary rate which means we're just rotating about. If i was a regular number like 4, it would have made us grow 4x faster. Now we're growing at a speed of ln(3), but sideways.

We should expect a complex number on the unit circle -- there's nothing in the growth rate to increase our size. Solving the equation:

\displaystyle{3^i = e^{\ln(3) \cdot i} = \cos(\ln(3)) + i \cdot \sin(\ln(3)) = .4548 + .8906i}

So, rather than ending up "1" unit around the circle (like $e^i$) we end up ln(3) units around.

Example: $i^i$

A few months ago, this would have had me tears. Not today! Let's break down the transformations:

\displaystyle{i^i = 1 \cdot i^i}

We start with 1 and want to change it. Like solving $3^i$, what's the instantaneous growth rate represented by i as a base?

Hrm. Normally we'd do ln(x) to get the growth rate needed to reach x at the end of 1 unit of time. But for an imaginary rate? We need to noodle this over.

In order to start with 1 and grow to i we need to start rotating at the outset. How fast? Well, we need to get 90 degrees (pi/2 radians) in 1 unit of time. So our rate is $i \frac{\pi}{2}$. Remember our rate must be imaginary since we're rotating, not growing! Plain old $\frac{\pi}{2}$ is about 1.57 and results in regular growth.

This should make sense: to turn 1.0 to i at the end of 1 unit, we should rotate $\frac{\pi}{2}$ radians (90 degrees) in that amount of time. So, to get "i" we can use $e^{i \frac{\pi}{2}}$.

\displaystyle{i = e^{i \frac{\pi}{2}}}

Phew. That describes i as the base. How about the exponent?

Well, the other i tells us to change our rate -- yes, that rate we spent so long figuring out! So rather than rotating at a speed of $i \frac{\pi}{2}$, which is what a base of i means, we transform the rate to:

\displaystyle{\frac{\pi}{2}i \cdot i = \frac{\pi}{2} \cdot -1 = -\frac{\pi}{2}}

The i's cancel and make the growth rate real again! We rotated our rate and pushed ourselves into the negative numbers. And a negative growth rate means we're shrinking -- we should expect $i^i$ to make things smaller. And it does:

\displaystyle{i^i = e^{- \frac{\pi}{2}} \sim .2}

Tada! (Search "i^i" on Google to use its calculator)

Take a breather: You can intuitively figure out how imaginary bases and imaginary exponents should behave. Whoa.

And as a bonus, you figured out ln(i) -- to make $e^x$ become i, make e rotate $\frac{\pi}{2}$ radians.

\displaystyle{\ln(i) = i \cdot \frac{\pi}{2}}

Example: (i^i)^i

A double imaginary exponent? If you insist. First off, we know what our growth rate will be inside the parenthesis:

\displaystyle{i^i = (e^{\frac{\pi}{2}i})^i = e^{-\frac{\pi}{2}}}

We get a negative (shrinking) growth rate of -pi/2. And now we modify that rate again by i:

\displaystyle{(i^i)^i = (e^{-\frac{\pi}{2}})^i = e^{-\frac{\pi}{2}i}}

And now we have a negative rotation! We're going around the circle a rate of $-\frac{\pi}{2}$ per unit time. How long do we go for? Well, there's an implicit "1" unit of time at the very top of this exponent chain; the implied default is to go for 1 time unit (just like $e = e^1$). 1 time unit gives us a rotation of $-\frac{\pi}{2}$ radians (-90 degrees) or -i!

\displaystyle{(i^i)^i = -i}

And, just for kicks, if we squared that crazy result:

\displaystyle{((i^i)^i)^2 = -1}

It's "just" twice the rotation: 2 is a regular number so doubles our rotation rate to a full -180 degrees in a unit of time. Or, you can look at it as applying -90 degree rotation twice in a row.

At first blush, these are really strange exponents. But with our analogies we can take them in stride.

Complex Growth

We can have real and imaginary growth at the same time: the real portion scales us up, and the imaginary part rotates us around:

real and imaginary growth

A complex growth rate like (a + bi) is a mix of real and imaginary growth. The real part a, means "grow at 100% for a seconds" and the imaginary part b means "rotate for b seconds". Remember, rotations don't get the benefit of compounding since you keep 'pushing' in a different direction -- rotation adds up linearly.

With this in mind, we can represent any point on any sized circle using (a+bi)! The radius is $e^a$ and the angle is determined by $e^{bi}$. It's like putting the number in the expand-o-tron for two cycles: once to grow it to the right size (a seconds), another time to rotate it to the right angle (b seconds). Or, you could rotate it first and then grow!

Let's say we want to know the growth amount to get to 6 + 8i. This is really asking for the natural log of an imaginary number: how do we grow e to get (6 + 8i)?

  • Radius: How big of a circle do we need? Well, the magnitude is $\sqrt{6^2 + 8^2} = \sqrt{100} = 10$. Which means we need to grow for ln(10) = 2.3 seconds to reach that amount.
  • Amount to rotate: What's the angle of that point? We can use arctan to figure it out: atan(8/6) = 53 degrees = .93 radian.
  • Combine the result: ln(6+8i) = 2.3 + .93i

That is, we can reach the random point (6 + 8i) if we use $e^{2.3 + .93i}$.

Why Is This Useful?

Euler's formula gives us another way to describe motion in a circle. But we could already do that with sine and cosine -- what's so special?

It's all about perspective. Sine and cosine describe motion in terms of a grid, plotting out horizontal and vertical coordinates.

euler's formula two paths

Euler's formula uses polar coordinates -- what's your angle and distance? Again, it's two ways to describe motion:

  • Grid system: Go 3 units east and 4 units north
  • Polar coordinates: Go 5 units at an angle of 53.13 degrees

Depending on the problem, polar or rectangular coordinates are more useful. Euler's formula lets us convert between the two to use the best tool for the job. Also, because $e^{ix}$ can be converted to sine and cosine, we can rewrite formulas in trig as variations on e, which comes in very handy (no need to memorize sin(a+b), you can derive it -- more another day). And it's beautiful that every number, real or complex, is a variation of e.

But utility, schmutility: the most important result is the realization that baffling equations can become intuitive with the right analogies. Don't let beautiful equations like Euler's formula remain a magic spell -- build on the analogies you know to see the insights inside the equation.

Happy math.

Appendix

The screencast was fun, and feedback is definitely welcome. I think it helps the ideas pop, and walking through the article helped me find gaps in my intuition.

References:

]]>
https://betterexplained.com/articles/intuitive-understanding-of-eulers-formula/feed/ 316