Category: Math

Mathematics

  • Fourier Series Are Just Coordinates

    Fourier Series Are Just Coordinates

    Why an infinite wiggle can be treated like a point in a room you can’t draw

    Fourier series often look like formulas you’re supposed to memorise.

    They aren’t.

    The idea is almost embarrassingly simple:

    A function is a point in an infinite-dimensional space.
    Sines and cosines are orthogonal axes.
    Fourier coefficients are just the coordinates of that point.

    Once you see this, the formulas stop looking mystical.
    They become inevitable.


    1. Coordinates: machinery your brain already owns

    On a sheet of paper, a point has two coordinates.
    In 3D, it has three.
    In 10D, it has ten.

    Nothing new happens — you just add axes.

    Given a vector vv and an axis ee, the coordinate of vv along ee is always

    coordinate=v⋅ee⋅etext{coordinate} = frac{v cdot e}{e cdot e}

    That’s it.

    Dot product over length squared.
    Projection, nothing more.

    Every coordinate system you’ve ever used works this way.


    2. Swap points for functions. The geometry survives.

    Functions behave like vectors:

    • you can add them
    • you can scale them

    So they live in a vector space.

    What replaces the dot product?
    An integral:⟨f,g⟩=∫−ππf(x) g(x) dxlangle f, g rangle = int_{-pi}^{pi} f(x),g(x),dx

    Two functions are orthogonal if this integral is zero.

    This isn’t exotic.
    It works for essentially every function encountered in physics, engineering, and applied maths. (If you want the precise functional-analysis caveats, they exist — but they don’t change the picture.)

    Once you have:

    • a vector space
    • an inner product
    • orthogonal axes

    coordinates are automatic.

    So the only real question is:

    What are the axes?


    3. Why sines and cosines are orthogonal (the symmetry doing all the work)

    The orthogonality of sine and cosine functions is not a miracle.
    It’s symmetry.

    Two facts do everything:

    • Sine is odd, cosine is even
    • The integral of an odd function over [−π,π][-pi, pi] is zero

    So:

    • sine × cosine integrates to zero
    • different frequencies cancel perfectly
    • only matching frequencies survive

    This gives an infinite family of mutually perpendicular axes:

    1, cos⁡x, cos⁡2x, cos⁡3x, …1, cos x, cos 2x, cos 3x, dotssin⁡x, sin⁡2x, sin⁡3x, …sin x, sin 2x, sin 3x, dots

    That’s not decoration.

    That is the coordinate frame.


    4. Fourier coefficients are literally coordinates

    Once the axes are fixed, the coordinates of a function f(x)f(x) are forced:

    an=⟨f,cos⁡(nx)⟩⟨cos⁡(nx),cos⁡(nx)⟩bn=⟨f,sin⁡(nx)⟩⟨sin⁡(nx),sin⁡(nx)⟩a_n = frac{langle f, cos(nx) rangle}{langle cos(nx), cos(nx) rangle} quad b_n = frac{langle f, sin(nx) rangle}{langle sin(nx), sin(nx) rangle}

    For n>0n > 0:⟨cos⁡(nx),cos⁡(nx)⟩=π,⟨sin⁡(nx),sin⁡(nx)⟩=πlangle cos(nx), cos(nx) rangle = pi,quad langle sin(nx), sin(nx) rangle = pi

    For the constant axis:⟨1,1⟩=2πlangle 1, 1 rangle = 2pi

    That’s where the famous formulas come from:

    a0=12π∫f(x) dxa_0 = frac{1}{2pi} int f(x),dxan=1π∫f(x)cos⁡(nx) dxa_n = frac{1}{pi} int f(x)cos(nx),dxbn=1π∫f(x)sin⁡(nx) dxb_n = frac{1}{pi} int f(x)sin(nx),dx

    The factors of πpi are not magic.
    They are just the squared lengths of the axes.

    Remember the idea, not the formula:

    Coordinates = projections.

    Everything else is arithmetic.


    5. Reconstruction is not a metaphor

    Once you have coordinates, you rebuild the vector:

    f(x)=a0+∑n=1∞(ancos⁡(nx)+bnsin⁡(nx))f(x) = a_0 + sum_{n=1}^{infty} left( a_n cos(nx) + b_n sin(nx) right)

    This is not an analogy.
    It is literal reconstruction from coordinates in an orthogonal basis.

    A Fourier series is not “approximating” a function in some vague sense.
    It is expressing the same point in a different coordinate system.


    6. Smoothness, corners, and why convergence looks the way it does

    This geometric picture explains convergence instantly.

    • A smooth function lies mostly along low-frequency directions
      → large a1,a2a_1, a_2 tiny high-nn coefficients
    • A function with a corner points diagonally across the space
      → energy spread across many axes
      → slow coefficient decay

    Sharp edges require high-frequency directions.

    That is the real reason behind:

    • Gibbs phenomenon
    • ringing
    • slow convergence near discontinuities

    No mystery.
    Just geometry.


    7. Example: f(x)=xf(x) = x on [−π,π][-pi, pi]

    The function is odd, so all cosine coefficients vanish.

    The sine coefficients are:bn=1π∫xsin⁡(nx) dx=2(−1)n+1nb_n = frac{1}{pi} int x sin(nx),dx = frac{2(-1)^{n+1}}{n}

    So the series builds as:

    S1(x)=2sin⁡xS_1(x) = 2sin xS2(x)=2sin⁡x−sin⁡2xS_2(x) = 2sin x – sin 2xS3(x)=2sin⁡x−sin⁡2x+23sin⁡3xS_3(x) = 2sin x – sin 2x + frac{2}{3}sin 3x

    Fourier Series: Functions as Coordinates

    A function is a point in infinite-dimensional space. Fourier coefficients are its coordinates.
    The Core Idea: Just like a point in 3D space has (x, y, z) coordinates, a function has coordinates along sin(x), sin(2x), sin(3x)… The Fourier series is reconstructing the function from its coordinates in an orthogonal basis.
    Target Function: f(x) = x
    Fourier Reconstruction (Adding Coordinates)
    Number of Terms (Axes)
    5
    Mean squared error (distance in function space)
    0.000
    f(x) ≈ 2sin(x) – sin(2x) + 0.67sin(3x) + …

    Each term adds another coordinate.

    Geometrically, this is no different from reconstructing a 3D point by first adding its xxx coordinate, then yy, then zz.
    The picture sharpens as you include more axes.


    8. The room you’ll never draw — but always use

    Every sin⁡(nx)sin(nx) and cos⁡(nx)cos(nx) is a perpendicular direction.

    Your function is a point in that infinite-dimensional room.

    Fourier coefficients are its coordinates.

    The Fourier series is the reconstruction.

    Once you internalise “Fourier = coordinates”:

    • the formulas stop looking arbitrary
    • convergence becomes geometric
    • smoothness becomes visible
    • memorisation disappears

    You don’t remember Fourier series.

    You remember one rule:

    A coordinate is a projection onto an axis.

    Everything else follows.
    Everything else is arithmetic.

  • How to remember Bayes’ Theorem without really trying

    How to remember Bayes’ Theorem without really trying

    Bayes’ Theorem crops up a lot. There’s even a picture of it in neon tubes on the Wikipedia page.

    Its beauty is that it relates the probability of one event occurring after another to its inverse. That is, it relates
    P(A∣B)P(A \mid B)— the probability of AA given BB
    to
    P(B∣A)P(B \mid A) — the probability of BB given AA.

    The standard textbook example goes like this.

    Let AA be the event that an individual in a population has a disease (say cancer). Let BB be the event that a medical test for that disease comes back positive.

    We are given:

    • P(A)P(A): the prevalence of the disease (say 1%).
    • P(B∣A)P(B \mid A): the probability the test is positive given the disease is present (the true positive rate, say 98%).
    • P(B∣¬A)P(B \mid \neg A): the probability the test is positive given the disease is absent (the false positive rate, say 3%).

    Now imagine you — yes, you — take the test, and it comes back positive.

    What is the probability you actually have cancer?

    It’s not 99%.

    Using Bayes’ Theorem, the answer in this case is only 24.8% — far lower than most people would guess.

    Unfortunately, if Bayes’ Theorem is learned as a magic formula into which numbers are blindly plugged, it’s very easy to get confused by all the P(A)P(A)’s, P(B)P(B)’s, and P(A∣B)P(A \mid B)’s. Which is a shame, because the underlying ideas are extremely simple.

    In fact, if you understand what’s going on geometrically, you don’t need to memorise any formulae at all.

    Just the pictures.


    The Picture

    Think of a sample space, represented by a rectangle. This rectangle contains every possible outcome.

    Inside the rectangle are two ovals:

    • Oval A (blue): event AA
    • Oval B (yellow): event BB

    Where they overlap is green — this region represents A∩BA \cap B.

    The area of each shape represents probability. If an oval is large, the event is likely. If it’s small, the event is rare.

    Imagine closing your eyes and randomly sticking a pin into the rectangle. The probability of landing in any region is proportional to its area.

    To understand Bayes’ Theorem, we only need three scenarios.


    Scenario 1: No Overlap

    In this case, events AA and BB do not intersect at all.

    P(A∩B)=0P(A \cap B) = 0

    Imagine you stick the pin into oval BB (you test positive). The moment the pin lands, you shrink to the size of an ant and a ten-foot barbed-wire fence shoots up around oval BB. This fence is now the boundary of your world.

    You’re terrified to look down.

    If you see green, you have cancer.
    If you see yellow, you’re safe.

    But in this scenario, there is no green inside BBB. The events don’t overlap.

    So:P(A∣B)=0P(A \mid B) = 0

    A positive test guarantees safety (an unrealistic test, but a useful limiting case).


    Scenario 2: BB Entirely Inside AA

    Now imagine oval BBB lies completely inside oval AA.

    Every point in BB is green.

    Again, you stick the pin into BBB. The fence rises. You look down.

    This time you are definitely standing on green.

    P(A∩B)=P(B)P(A \cap B) = P(B)

    and thereforeP(A∣B)=1P(A \mid B) = 1

    A positive test guarantees disease.


    Scenario 3: The Mixed Case (The Real World)

    This is the interesting case.

    Oval BB partially overlaps oval AA.

    You stick the pin into BB, shrink to ant size, and the fence rises. Inside the fence, some floor is green, some is yellow.

    What is the probability you’re standing on green?

    It is simply:P(A∣B)=P(A∩B)P(B)(1)P(A \mid B) = \frac{P(A \cap B)}{P(B)} \tag{1}

    This single formula covers all three scenarios.

    Bayesian “Fence” Visualizer

    The total box is the population. The colored rectangles are people who tested positive.

    Probability you have the disease given the positive test:
    0.0%
    Ratio of Green to (Green + Yellow)

    Swapping the Question

    So far we’ve been asking:

    Given a positive test, what is the probability of disease?

    Now let’s reverse it.

    Suppose we know we have the disease. What is the probability the test is positive?

    That is P(B∣A)P(B \mid A).

    By symmetry, swapping AA and BB in (1) gives:P(B∣A)=P(B∩A)P(A)(2)P(B \mid A) = \frac{P(B \cap A)}{P(A)} \tag{2}

    But P(B∩A)=P(A∩B)P(B \cap A) = P(A \cap B), so combining (1) and (2) gives:

    P(A∣B)=P(B∣A) P(A)P(B)P(A \mid B) = \frac{P(B \mid A)\, P(A)}{P(B)}

    This is the compact form of Bayes’ Theorem — the one in neon lights.


    The Extended Form

    We’re not quite finished, because P(B)P(B) is often unknown.

    In the test example, P(B)P(B) is the probability that a random person tests positive — either because they have the disease or because of a false positive.

    From the diagram:

    P(B)=P(A∩B)+P(¬A∩B)P(B) = P(A \cap B) + P(\neg A \cap B)

    Using conditional probabilities:

    P(B)=P(B∣A)P(A)+P(B∣¬A)P(¬A)P(B) = P(B \mid A) P(A) + P(B \mid \neg A) P(\neg A)

    Substituting this into Bayes’ formula gives the extended version:

    P(A∣B)=P(B∣A) P(A)P(B∣A) P(A)+P(B∣¬A) P(¬A)P(A \mid B) = \frac{P(B \mid A)\, P(A)} {P(B \mid A)\, P(A) + P(B \mid \neg A)\, P(\neg A)}


    The Numbers

    In our example:

    • P(A)=0.01P(A) = 0.01
    • P(B∣A)=0.98P(B \mid A) = 0.98
    • P(B∣¬A)=0.03P(B \mid \neg A) = 0.03

    Plugging these in:

    P(A∣B)=0.98×0.01(0.98×0.01)+(0.03×0.99)=24.8%P(A \mid B) = \frac{0.98 \times 0.01} {(0.98 \times 0.01) + (0.03 \times 0.99)} = 24.8\%

    There is hope — a positive test is not the near-certainty most people imagine.


    Final Note

    Many people find it helpful to lay these probabilities out in a table to avoid mistakes. There are excellent examples of that approach online.

    But ultimately, Bayes’ Theorem isn’t about algebra.

    It’s about areas, fences, and what information actually does to your world.