Tivadar Danka Profile picture
Nov 3, 2022 18 tweets 6 min read Read on X
Behold one of the mightiest tools in mathematics: the camel principle.

I am dead serious. Deep down, this tiny rule is the cog in many methods. Ones that you use every day.

Here is what it is, how it works, and why it is essential.
First, the story.

The old Arab passes away, leaving half of his fortune to his eldest son, third to his middle son, and ninth to his smallest.

Upon opening the stable, they realize that the old man had 17 camels.
This is a problem, as they cannot split 17 camels into 1/2, 1/3, and 1/9 without cutting some in half.

So, they turn to the wise neighbor for advice.
The wise man says "hold my camel", and solves the problem by lending one to the boys.

Now the stable has 18. The eldest son takes 9 home, while the middle and smallest son leaves with 6 and 2, as their father wished.

The wise man takes his camel back, and everybody is happy.
Thus, the camel principle is born: adding and subtracting the same quantity doesn't change the equality, but can help in the computation.

In mathematics, you cannot live without this principle.

I'll show you two examples.
The first one is the quadratic equation.

Its solution formula is one of the few things that everybody remembers from high school. Even if they are woken up in the middle of the night.

This formula is derived from the camel principle. Let me show you how!
After factoring out 𝑎 from the equation, we notice that the famous identity

(α + β)² = α² + 2αβ + β²

might help to factor the quadratic equation into a product.

To achieve that, we apply the camel principle!
After adding and subtracting the same quantity, the terms with 𝑥 factor into a product.
This leads straight to the solution formula.
There is an alternative version of the camel principle, performing a similar feat: multiplying and dividing with the same quantity.

This doesn't change the equality either.
To illustrate, let's look at derivatives, the main engine behind mathematics, physics, and optimization.

(And tons of other fields that allowed technology to get where it is now.)
How would you calculate the derivative of a composite function?

This is a quintessential question. Without this, you don't have backpropagation, gradient descent, and thus neural networks.

(At least until someone invents a clever alternative. But that'll take a while.)
You guessed right: the camel principle!

(At least, the second version, where you multiply and divide with the same quantity.)
After the camel principle is applied, the limit can be carried out termwise.
(For those with the eagle's eyes: yes, the denominator can be zero. You can epsilon-delta your way out of that, but I won't do it here.)
And thus, we have the chain rule, one massive pillar of science and technology.

This is what we use to perform backpropagation, enabling us to train our neural networks in a reasonable time.
The lesson here: tiny mathematical curios such as the camel principle are often dismissed as "lacking any applications".

However, such short-sightedness frequently leads astray.

By understanding atoms, you are able to build skyscrapers.
If you have enjoyed this explanation, share it with your friends and give me a follow! I regularly post deep-dive explainers such as this.

Understanding mathematics will make you a better engineer, and I want to help you with that.

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Tivadar Danka

Tivadar Danka Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @TivadarDanka

Sep 11
Logistic regression is one of the simplest models in machine learning, and one of the most revealing.

It shows how to move from geometric intuition to probabilistic reasoning. Mastering it sets the foundation for everything else.

Let’s dissect it step by step! Image
Let’s start with the most basic setup possible: one feature, two classes.

You’re predicting if a student passes or fails based on hours studied.

Your input x is a number, and your output y is either 0 or 1.

Let's build a predictive model! Image
We need a model that outputs values between 0 and 1.

Enter the sigmoid function: σ(ax + b).

If σ(ax + b) > 0.5, we predict pass (1).

Otherwise, fail (0).

It’s a clean way to represent uncertainty with math. Image
Read 15 tweets
Sep 8
Matrix multiplication is not easy to understand.

Even looking at the definition used to make me sweat, let alone trying to comprehend the pattern. Yet, there is a stunningly simple explanation behind it.

Let's pull back the curtain! Image
First, the raw definition.

This is how the product of A and B is given. Not the easiest (or most pleasant) to look at.

We are going to unwrap this. Image
Here is a quick visualization before the technical details.

The element in the i-th row and j-th column of AB is the dot product of A's i-th row and B's j-th column. Image
Read 16 tweets
Sep 7
Behold one of the mightiest tools in mathematics: the camel principle.

I am dead serious. Deep down, this tiny rule is the cog in many methods. Ones that you use every day.

Here is what it is, how it works, and why it is essential: Image
First, the story:

The old Arab passes away, leaving half of his fortune to his eldest son, third to his middle son, and ninth to his smallest.

Upon opening the stable, they realize that the old man had 17 camels. Image
This is a problem, as they cannot split 17 camels into 1/2, 1/3, and 1/9 without cutting some in half.

So, they turn to the wise neighbor for advice. Image
Read 18 tweets
Sep 7
The way you think about the exponential function is wrong.

Don't think so? I'll convince you. Did you realize that multiplying e by itself π times doesn't make sense?

Here is what's really behind the most important function of all time: Image
First things first: terminologies.

The expression aᵇ is read "a raised to the power of b."

(Or a to the b in short.) Image
The number a is called the base, and b is called the exponent.

Let's start with the basics: positive integer exponents. By definition, aⁿ is the repeated multiplication of a by itself n times.

Sounds simple enough. Image
Read 18 tweets
Sep 5
In machine learning, we use the dot product every day.

However, its definition is far from revealing. For instance, what does it have to do with similarity?

There is a beautiful geometric explanation behind: Image
By definition, the dot product (or inner product) of two vectors is defined by the sum of coordinate products. Image
To peek behind the curtain, there are three key properties that we have to understand.

First, the dot product is linear in both variables. This property is called bilinearity. Image
Read 16 tweets
Sep 5
The single biggest argument about statistics: is probability frequentist or Bayesian?

It's neither, and I'll explain why.

Deep-dive explanation incoming: Image
First, let's look at what probability is.

Probability quantitatively measures the likelihood of events, like rolling six with a die. It's a number between zero and one.

This is independent of interpretation; it’s a rule set in stone. Image
In the language of probability theory, the events are formalized by sets within an event space.

The event space is also a set, usually denoted by Ω.) Image
Read 34 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us!

:(