# Gauss’s magic shoelace area formula and its calculus companion

Welcome to another Mathologer video. The

shoelace formula is a super simple way to calculate the exact area inside any

convoluted curve made up of straight line segments, like my cat head curve

over there. Even the great mathematician Carl Friedrich Gauss was impressed by

this formula and mentioned it in his writings. The formula was certainly not

invented by him, however it’s often also referred to as Gauss’s area formula,

probably because a lot of people first learned about it from Gauss (and not

because someone calculated Gauss’s area with it ðŸ™‚ In today’s video I’ll show you

how and why this formula works. The visual proof I’ll show you is just as

pretty as the formula itself and along the way I can promise you a couple of

very satisfying AHA moments to make your day. I’ve got a special treat for you at the end of the video: a simple way to morph

the shoelace formula into a very famous and very powerful integral formula for

calculating the area enclosed by really complicated curvy curves, like for

example this deltoid rolling curve here. Now obviously we call this crazy

formula the shoelace formula because it reminds us of the usual crisscross way

of lacing shoes. Now let’s make sense of the shoelace formula and use it to

calculate the orange area. I start by filling in the coordinates of the blue

points. Take one of these points and move its coordinates to the right. Now we

traverse the curve in the counterclockwise direction and do the

same for the other blue points we come across. Here, there, there, there. Now we’re

back at the point we started from and include its coordinates one more time at

the end of our list. Now draw in the crosses. Okay this green segment stands

for the product of the two numbers at its ends. So 4 times 1 equals 4.This red segment stands for minus the product of the number at its two ends.

So 4 times 0 equals 0. Minus that is – 0. Oh, well obviously

the “minus” is not important here but it will be later. Green again. So 0 times 5

equals 0. Red again, we need to calculate minus the product, so 1 times – 2

equals -2. Minus that, and so on. So we get two products for every cross, one taken

positive and one negative. Now adding up all the numbers gives 110. Okay, almost

there. The formula tells us to divide by two. So half of 110 is 55, and that’s the area

of my cat head. Really pretty and super simple to use. And this works for any

closed curve in the xy-plane no matter how complicated. The only thing you have

to make sure of is that the curve does not intersect itself like this fish

curve here. And it will become clear later on why you have to be careful in this

respect. Okay now for the really interesting bit, the explanation why the

shoelace formula works. It turns out that the individual crosses in the formula

correspond to these triangles which cover the whole shape. Note that all

these triangles have the point (0,0) in common. Okay, so the area of the first triangle here is just 1/2 times the first cross.

So, again, the first cross is equal to 4 times 1 minus 4 times 0 equals 4, and

half that is 2. And it’s actually easy to check that this is true using the good

old 1/2 base times height area formula for triangles. Now the area of the

second triangle is 1/2 times the second cross, and so on. But why is the area of

one of these triangles equal to 1/2 times the corresponding cross? Here’s a

nice, really really nice visual argument due to the famous mathematician Solomon Golomb. What we want to convince ourselves of is this. So let’s calculate

the area of this triangle from scratch. Actually what we’ll do is

to calculate the area of this parallelogram here whose area is double

that of the triangle. Okay let’s start with the special rectangle here. Then the

coordinates translate into the side lengths of these two triangles. First (a,b)

turns into these two side lengths, and then (c,d) into these. Color in the

remainder of the rectangle and shift the green triangles like this, and like

that, Now do you see the second small

rectangle materializing? Right there. The two triangles overlap in the dark

green area and so we can pull the colored bits apart so that they fill

exactly the parallelogram and the little rectangle. Since we started out with the

colored bits filling a large rectangle this means that “large rectangle area”

equals “parallelogram area” plus “small rectangle area”. But now the areas of the

rectangles are ad and bc. That’s almost it. Now, without any words… Pure magic,

right? And, of course, all of you who are familiar with vectors and matrices will

realize that another way of expressing what we just proved is the mega famous

result from elementary linear algebra that the area of the parallelogram spanned

by the two vectors (a,b) and (c,d) is equal to the determinant of the 2 x 2 matrix

a,b,c,d. Anyway, back to the shoeless formula. At this point we just need to divide by

2 to get the area of the triangle and that’s it, right? That completes the proof

that the shoeless formula will always work, right? Well, not quite. We are still missing one very important very magical step. Let’s have another

look at my cat hat, but let’s shift it so that the point (0,0) is no longer inside

and again move around the curve and highlight the triangles whose area the

shoeless formula adds. This time let’s start here. As we move around the curve

in the counterclockwise direction the green radius which chases us

also rotates around (0,0) in the counterclockwise direction. Something

does not look right here. The yellow triangles are sticking out of the cat

head and at this point the combined area of the triangle is larger than that of

the cat head and should get even larger as we keep going. However, whereas up to now the radius has been rotating in the counterclockwise direction, at this point

it starts rotating in the clockwise direction and this change in sweeping

direction has the effect that the shoeless formula subtracts the areas of

the blue triangles. And this means that the area calculated by the shoelace

formula will be the total area of the yellow triangles minus that of the blue

triangles which is exactly the area of our cat head again. The same sort of

nifty canceling of areas makes sure that no matter how convoluted a closed curve

is as long as it doesn’t intersect itself the shoelace formula will always

give the correct area. Here’s an animated complicated example in which I

dynamically update what area the shoelace formula has arrived at at

the different points of the radius changing sweeping direction. Real mathematical magic, isn’t it?

It’s also easy to see why reversing the sweeping direction leads to negative

area. Let’s see. Sweeping in the counterclockwise

direction we first come across (a,b) and record it, followed by (c,d). When we sweep clockwise the order in which we come across (a,b)

and (c,d) is reversed and this leads to these changes in the formulas. And the

last swap obviously leads to the number turning into it’s negative. And that’s

really it. Now you know how the shoelace formula does what it does. In these

videos we keep encountering really fancy curves like this cardioid in a coffee

cup in the “Mandelbrot and times tables” video or this deltoid rolling curve

whose area actually already played a quite important role in the video on the

Kakeya needle problem. At first glance it looks like we won’t be able to use the

shoelace formula to calculate the area of one of these curves because they are

not made up from line segments. Well you can definitely approximate the area by

calculating the area of a straight line approximation like this, with those blue

points on the curve. And by increasing the number of points we can get as close

to the true area as we wish. In fact, by taking this process to the limit in the

usual calculus way, we can turn the shoelace formula into a famous integral

formula for calculating the exact area enclosed by complicated curves like the

deltoid. Here’s how you do this. I’ve tried to make sure that even if you’ve

never studied calculus you’ll be able to get something out of this. Well we’ll see,

fingers crossed ðŸ™‚ A curve like this is often given in parametric form. For

example this is a parametrizations of this deltoid. Here x(t) and y(t) are the

coordinates of a moving point that traces the curve as the parameter t

changes from, in this case 0 to 2 pi. Let’s have a look. So here’s the position of the point at t=0. And once it gets going the

slider up there tells you what t we are up to. Right now we’ll translate all this

into the language of calculus. Let’s stop the point somewhere along its journey. A

little bit further along we find a second point. A tiny, tiny little bit

further on is usually expressed in terms of infinitesimal displacements in x and

y. It’s a bit lazy to do it this way but mathematicians are a bit lazy and love

doing this because it captures the intuition perfectly and in the end can

be justified in a rigorous way. Anyway just add dx and dy to the coordinates of

our first point to get the coordinates of our second point. Now, of course, these

displacements are not independent of each other. The connection is most easily

established in terms of the derivatives of the coordinate functions. So the

derivative of the x coordinate with respect to the parameter t is dx/dt

which I write at x'(t) and similarly for the y coordinate function.

Solving for dx and dy gives this and this then links both dx and dy to an

increment dt of the parameter t that’s changing, right? Now we substitute like this and now we’re ready to calculate the area of our infinitesimal triangle as before. 1/2 times a cross. And this evaluates to

this expression here. And this we can write in a slightly more compact form

like that. Okay now what we have to do is to add all these infinitely many

infinitesimal areas and as usual in calculus this is done with one of those

magical integrals. The little circle twirling in the counterclockwise

direction says that we’re supposed to integrate

around the curve exactly once in the counterclockwise direction.

Well let’s see: for our deltoid we have this parameterization here. We’ve already

seen that a full trace is accomplished by having t run from 0

to 2 pi. This means that in this special case our integral can be written

like this. Now evaluating and simplifying the expression in the brackets gives

this integral here, which can be broken up into two parts. Maths students won’t be

surprised that the trig(onometric) integral on the right evaluates to 0 which then means

that the area where after is equal to this baby integral which of course is equal

to 2 pi. Now the little rolling circle that is used to produce our deltoid is of

radius 1 and is therefore of area pi. This means that the area of the deltoid

is exactly double the area of the rolling circle. Neat isn’t it? Okay, up for a couple of challenges? Then explain in the comments

what the number stands for that the shoeless formula or the integral formula

produce in the case of self intersecting curves like these here. Another thing worth

pondering is how the argument for our triangle formula has to be adapted to

account for the blue points ending up in different quadrants, for example, like

this. And that’s it for today. I hope you enjoyed this video and as usual let me

know how well these explanations worked for you. Actually since I mentioned the Kakeya video and fish, I did end up turning my Kakeya fish

into a t-shirt. What do you think? Well and that’s really it for today.

Area of the cat is great and all but the more important question – is it alive or dead?

Why does the order have to be always counterclockwise? How do you see the order for . a complex shape like at 3:09 ? Do we get an incorrect answer with the wrong order?

We learned this in sophomore year …

I love ALL OF YOUR VIDEOS. MATH IS Beautiful!!!!

Greens theorem in the plane…( with a negative)… nice!

If a curve intersects itself , the direction of traversal reverses from anticlockwise to clockwise. Therefore the area after the intersection is counted as negative.

Very interesting and fascinating video. Guess I've never seen such a relatively easy formula with such a beautifulâ€‹ visual proof. Well done!!

Awsome

A clear and intuitive explanation of an amazingly useful and beautiful formula â€“ it's just perfect! I also liked how you show the connection between calculating areas and matrices ðŸ™‚ I presume that most students, when first encountering linear algebra, think that it's not that intuitive, useful or even simply neat. However, this video manages to show how even pretty basic stuff from linear algebra is connected to something we are used to from childhood. And it gives one extra bit to a general understanding of how deeply interconnected mathematics is. Fascinating ðŸ™‚

Fish area = Fish body area – Fish tail area (or Fish tail area – Fish body area; depends on chosen "counter clockwise" direction )

Infinite symbol area = 0

Add two identical points to the place where the curve intersects itself, those two points can count as new vertices of a normal shape that doesn't intersect itself. The same goes for parametric shapes, when traveling along the curve and you hit an intersection, always chose the path that keeps the inside of the area to your left, in the case of the infinity shape, it's the one that has a non continuous derivative.

Can this gentleman be my math professor? His voice is so soothing it feels like I'm listening to a bedtime story.

This is great. Unfortunately, since I learned Pick's theorem, I know longer have a need for this one when teaching my ACT students. Clearly the shoelace formula is far more broadly applicable though.

Das war echt cool

You should check out Milo Murphy's Law. There are a few equations here and there that I'm interested in understanding, primarily Athledecamathalon.

5:31 — This is sorcery! ðŸ™‚

sir what is the graph of y square = x square?

This is one of my favorite videos.

Hey Mathologer, awesome work, can you please do a video on the patters from anime "Kedo: the Right Answer", both from the opening and on the cube? You will not regret it, I promise!

I lost the tracks at 8:35 where Mathologer explained negative areas. But understood calculus part. Ughr.. But why exactly do 'ab' and 'cd' flip? Is it because when calculating area of parallelogram on to vectors, we go from 'cd' to 'ab'? And how does it work with proofs by triangles you used earlier. There was a shortcut here and I feel it doesn't make sense.

Please continue to do these vector calculus/differential geometry videos. Very enjoyable.

5:09 ??????????

Is the formula at 12.45 the way to find areas for parametric polar curves in calculus? Because it is definitely something i've never seen before.

nice video! a vid with taylor series proof would be great too.

When I taught computer programming, using this method (in the CRC book) was a always a favorite of students who were delighted to learn something most of their math teachers didn't even know. The animations sure make the "why" easier to understand.

Notice this AD and BC I bet the calendar confounders know this math.

This is such a neat visualization of a thing I've never heard of that I decided to go and graph it:

https://www.desmos.com/calculator/cmfuwvgyui

It's far from perfect but it's definitely relevant.

I know that the term "Math is Broken" can be accurate in many cases, (looking at you 0/0 and all of your implications) but I would argue that math itself is not "broken" it is just that it is an Axiomatic System. For those people who do not know, An Axiomatic System is basically a method of understanding made sometime B.C.E. . A very well known axiomatic system is Euclidean Geometry which consists of 2 components: Postulates which is things that are true without proof ex: if a triangle ABC has 2 congruent angles w/ triangle XYZ then the 2 triangles are Similar. The other is Theorems that are statements that must be proven true given postulates and other already proven Theorems ex: a^2 + b^2 = c^2 in a right triangle with c being the Hypotenuse, and a & b being the legs. Basically if you dig down deep enough in any logical system then you will ALWAYS find something you are just going to have to take on faith because else we have jack and squat to build our logic off of. if you want a better explanation then go watch the video God Does not Play Dice (on youtube).

I don't SEE the pattern here..

Nice explanation! I admit I was too lazy to try to understand everything regarding integrals, because at school we never worked with curves where x and y depend on t (much less using such functions in combination with geometry), but I like that you put difficult parts into your videos as well.

Im constantly blown away by how awesome calculus is! I love this place and how you explain complex ideas in such simple ways. I appreciate you guys for the joy I get from this.

Gauss the Bawws!

These video's are too cool and contain way too much math coolness, it should be illegal! Stop making them!

Awesome explanations as always thanks!!

How can we find a parameterization for curves that are more complicated than a simple circle/ellipse?

I love your animations. I wish I could have done the same kind of thing on my channel

You are brilliant and very creative at finding new ways of explaining things

Excellent video! As always, the visualizations are invaluable.

hi [email protected] … i dont understand something there i think its a bit mistake there , at 5:29 the formula you created isnt correct , since you count double time the area when you added the small rectangle , check it or maybe its mine mistake …

many thanks

dudi

Looked up that mathematician with the proof and was slightly disappointed to find his last name spelled Golomb 8D

This video is so well done, you completely blew my mind! I've seen a number of explanations of this formula over the years, but never one so clearly laid out and so intuitive. Bravo!

Shouldnâ€™t that be t âˆˆ [0, 2Ï€[, i.e. 2Ï€ exclusive, or is this negligible?

There must be a way to generalize this to curves with calculus! Right?

muhahaha vou dominar o mundo

I would be really pleased, if we could do simiral operation for n-dimnesional space.

Very good one! I had never seen (or completely blocked out) this formula before.

I really like that finding the area of a polygon can be translated as calculating the determinant of N 2 by 2 matrices.

Is there a related formula in 3D or higher dimensions?

Great video!

If you've done linear algebra it makes this so much easier to grasp

Oh

Ive been using this for over a year and only heard the name of it now xd

It looks like for intersecting curves, you can split the problem up into multiple shoelace problems by creating new points at the intersection points and calculating each sub area individually. I don't see why it wouldn't work, but it might not work in a general sense for an integral, just a finite, simple case of a small amount of intersection points.

Lol I love the SchrÃ¶dinger's cat shirt

The self intersections don't work because the formula doesn't "know" they're there, If you look at just the points of the fish, you would assume the lines connect into a pentagon. which is the way the formula would do it as well, so you'll end up with a wrong set of data. To properly do it, you'd have to add the point in the intersection, then do the tail and body as two seperate items and add them together.

it appears we are taking half of the determinant over and over…let's see!

wwHAT

we can think loop as two different structure and use green identity ,,,

00:28 Because we only have a couple of things named after Gauss …

but can't we deal with self-intersecting curves if we just map it around using the intersection point twice ?

<3 <3<3

For the case of self-intersections: the point is, of course, that when you get to the self-intersection, you do not have a well-defined rule for proceeding, as two ways of going further appear. If you take the “obvious'' one, you will get, as many have already noted, the difference between the fishtail and the head. But if you take the “wrong'' way, you will just get the area. This remark inspired by the obvious fact that any self-intersecting curve can be approximated to an arbitrary level of accuracy by one that does not. Since the shoelace formula applies in the case of the approximating curves, there should be, and indeed there is, a way of getting the area by shoelace for the self-intersecting case as well.

i need this t-shirt

Thanks for this video! I used what you taught me to help me calculate how far from a screen someone is using computer vision, by calculating the area of the triangle between your eyes and nose: https://twitter.com/LabOfOz/status/1020902462977294336

Watching this video just now and I can see a computer algo using this formula, but at the last step, you perform an absolute value function on it so that the direction you traverse the path no longer matters, or rather, the algo doesn't need to know about directionality.

Like, imagine a circularly linked list that holds X-Y coordinates for a closed loop (assuming no self-intersections and straight segments). Traverse said list using the shoelace method and find its absolute value to find the area. I oughta try that, actually.

â—‹â—‹

brilliant

is there a shoelace formula in 3d

This one I truly loved. The explanation as cross product made it clear why it works

I love that channel! Great explaination

These explanations are amazing!

man I love these videos – what's cool about this problem is you can use it to tell which direction a 3D face is facing.. Don't ask me how, but I managed to use this to cull objects facing away from you in my 3D engine. I wonder if there's a better way?

Make a new point at the intersection and consider it 2 different points.

The curve in a coffee cup is not a cardioid. If you take the virtual caustic curve of the reflections off the back of the cup, they form another cusp. So the overall curve is a nephroid, with two cusps. I'll leave you to prove this mathematically !

0:37 lol

how did u get those coordinates? slow down!!

For self-intersecting curves, the shoelace formula calculates the area of all the sections you go around counterclockwise, minus the areas of all the others.

Dear Sir,

you have the most beautiful style of explaining mathematical connections and relations. Very clear, very easy to follow and to top it all: very entertaining!

Thank you for your videos ðŸ™‚

couldn't you just split the shape apart and put points on the old intersection areas?

How cruel to put the small dot next to Gauss from 0:23–1:03; I thought my screen was dirty and tried to clean it for almost half a minute xD

What is the animation software used?

Does this work in R3, three dimensions ?

Can I use this method to calculate the area of a country?

Wow!

For a self-intersecting curve, the formula should yield the total net area enclosed by the corresponding simple curves which 'go' counterclockwise (clockwise boundary produces negative area contributions).

This gives me flashbacks to contour integration in Complex Analysis and winding numbers.

Is it possible to extend this to volumes?

I think that when the curve intersects itself, the only case where it would still logically work is if the intersection point itself becomes the origin (0,0).

Otherwise, when the triangle moves in the clockwise direction it would highlight over the area that's already calculated & we would be subtracting a needed area :C

If the intersection happens to be origin (0,0) however, it can be ignored as an intersection and simply calculated as two shapes.

… Wait, why not calculate it as two shapes regardless of whether it's at the origin or otherwise? Hmm…

add additional point(s) where the intersection is and use the same method, you just pass two times the point of intersection going around the figure

I think the Kakeya T-shirt would be awesome if those lines were extended all around it ðŸ˜€

Thank you! I didnâ€™t get the solution on AoPS

People familiar with basic CGI algorithms would likely come up with a different variation of the proof that doesn't need the generalised formula for the triangle area. TL;DR: Instead of (0,0) assume a point at (-inf, 0).

A simple algorithm for a polygon flood fill works as follows:

* Remember a number for each pixel on your screen, initialise that number to zero for every pixel.

* For each segment (x(j),y(j)) -> (x(j+1),y(j+1)) do this:

* If y(j) < y(j+1), then add 1 to all pixels to the left of that segment (i.e. all pixels with y(j) < y < y(j+1), 0 < x < line(y)).

* If y(j) > y(j+1), subtract 1 from all pixels to the left of that segment.

At the end, each pixel will have a value of 0 if it is outside the polygon, and a value of 1 if it is inside. This is because a pixel that has an odd number of segments to its right must necessarily be inside, and one with an even number of lines to its right must be outside. (Side-note #1: In fact, you don't need to remember an integer for each pixel, you need just one bit to store the parity. Side note #2: The algorithm can thus be implemented as a repeated line-wise XOR. The video memory is stored line-by-line, which makes the algorithm efficient).

To finish the proof: In each step, the area to the left of a line-segment corresponds to a quadrilateral that can be obtained by gluing together a triangle with an area of y((j+1)-y(j))*(x(j+1)-x(j))/2 and a rectangle with an area of (y(j+1)-y(j))*x(j). When you sum this over j and simplify, you get the shoe-lace formula. Incidentally, each quadrilateral can be considered a truncated triangle with a third point at (-inf, 0).

There is no problem with polygons whose sides intersect. What you get is called Meister-MÃ¶bius area, which, one could argue, is the one true area. ðŸ˜‰

Did anyone noticed SchrÃ¶dinger's cat on his t-shirt

Alive and dead at the same time

Habt sie diese Videos auch auf deutsch?

thanks for the help! ðŸ™‚

This is looking a lot like finding the determinant of a matrix. I suppose since the determinant of a matrix is its area scale factor thwt might explain where these stupidly complicated and random processes come from

explain 1+1+1=5…my coworkers niece got told this was true by her math teacher and i seriously need someone who knows something to back me up on calling them out

Production quality is amazing. Note, subtraction was (obviously) intended at 5'20".

This legit made my day!

Newton and his pet integral has joined the chatNewton and his pet integral has left the chat shamefullyI assume it Is a representation of SchrÃ¶dingers cat on your T-shirt

But what is the area of the Mathologer? Given the lack of hair, it could be calculated with great exactitude.