Luke a Pro

Luke Sun

Developer & Marketer

šŸ‡ŗšŸ‡¦

Math & Geometry: Overview

| , 3 minutes reading.

Math & Geometry: Overview

Typical Business Scenarios

Mathematical algorithms are often the hidden engines behind visual and security systems:

  • Security (RSA): How do we calculate AB(modM)A^B \pmod M when BB is a 2048-bit number? (Binary Exponentiation).
  • Game Development: Detecting collisions or calculating the ā€œvision coneā€ of an enemy (Geometry / Convex Hull).
  • Finance: Pricing complex derivatives by simulating millions of possible market futures (Monte Carlo).
  • Data Layout: Calculating the optimal grid size or scheduling periodic tasks (GCD / LCM).

Selection Framework: How to Choose?

  1. Are you dealing with huge numbers?
    • Yes: Use Binary Exponentiation for powers and Euclidean Algorithm for divisors.
  2. Is the problem deterministic or probabilistic?
    • Deterministic: Use exact formulas (Geometry, Matrix Math).
    • Too complex for formulas: Use Monte Carlo Simulations to approximate the answer.
  3. Are you processing 2D/3D shapes?
    • Boundary Finding: Use Convex Hull (Graham Scan).
    • Intersection: Use Line Sweep algorithms.

Quick Look at Common Algorithms

  • 7.1 Binary Exponentiation: Calculating xnx^n in O(log⁔n)O(\log n) time. Essential for cryptography.
  • 7.2 GCD (Euclidean Algorithm): The 2,000-year-old algorithm that is still the fastest way to find the Greatest Common Divisor.
  • 7.3 Monte Carlo: Solving impossible integrals by throwing random darts at a board.
  • 7.4 Convex Hull (Graham Scan): Wrapping a set of points in the tightest possible rubber band.

Selection Cheat Sheet

RequirementAlgorithmComplexityApplication
Large Powers (ABA^B)Binary ExponentiationO(log⁔B)O(\log B)RSA, Diffie-Hellman
Divisors / PrimesEuclidean AlgorithmO(log⁔(min⁔(A,B)))O(\log (\min(A, B)))Cryptography, Scheduling
Simulation / ApproxMonte CarloDepends on samplesRay Tracing, Risk Analysis
Shape BoundaryConvex HullO(Nlog⁔N)O(N \log N)Collision, Robotics
IntersectionLine SweepO(Nlog⁔N)O(N \log N)Vector Graphics, Maps

The ā€œOne-Sentence Mindsetā€

ā€œMath algorithms are shortcuts. They use properties of numbers and space to skip billions of unnecessary calculation steps.ā€