 Chinese solved a number of very complicated geometric problems using what's called the out-in principle. And this emerges from a useful geometric result that involves complementary parallelograms. And the basic idea is this. If we take a parallelogram and draw the diagonal, if we then draw intersecting lines parallel to the sides, we end up with what are known as complementary parallelograms. You can think about these as parallelograms where one vertex is on the diagonal. The useful geometric result is that the areas of the complementary parallelograms are equal. In this case, that means the blue and green parallelograms have the same area. Now in Chinese sources, our parallelogram is typically a rectangle. And, once again, the areas of the blue and green rectangles are the same. So, from Liu He's commentary on the nine chapters, we have the following problem. A square city with unknown side has gate openings in the middle of each side. 20 bu from the north gate, there's a tree, which is visible when one goes 14 bu southward from the south gate. And 1,775 bu westward. What is the length of each side? Now to solve this, Liu He gives the following instructions. Multiply the northward distance by the westward distance, then double the product, which will be the constant. Take the sum of the distances from the north and south gates as the linear coefficient, and then extract the root. Remember that this phrase extract the root really means to solve a quadratic equation. And so Liu He's solution is essentially to solve the quadratic equation, where our linear coefficient is the sum of the north and south distances, and our constant is twice the northward distance times the westward distance. Now let's see why that works. So let's take a bird's eye view. So remember our city is a square, and we went south some distance, and then west some distance until we could see the tree. Now the key to this problem is identifying the complementary rectangles, and the key to that is identifying the diagonal. Well there's only one thing here that could possibly be identified as the diagonal, which is the line of sight from our southern position to the tree. And we make that the diagonal of a rectangle and fill out the rectangle. And even though my animation of the city is brilliant, and I'm waiting for my letter from Pixar, we don't actually need it to solve the problem, so let's fade it out. And let's fill in some of our values. Remember the tree was 20-boo north of the city. We walked 14-boo south, then 1775-west. So while we have the diagonal, we don't really have the complementary rectangles, so let's fill those in. And so here's a couple important things. First, the blue areas are equal because they're complementary rectangles. Now notice our complementary rectangles meet in this corner piece. The blue and red regions together have an area of 20, that's the northward distance, by 1775, that's the westward distance. Now even though we calculated this as the area of the horizontal blue and red regions, it's the same as the area of the vertical blue and red regions. Now if I double that area, well that double area can also be represented here, and we see that twice this area is going to give us the area of the city itself, plus 20x this top area, plus 14x this bottom area. And that's where our equation comes from. 2 times 20 times 1775, that's the city, plus the top area, plus the bottom area, and there's the equation we need to solve to find the length of one side of the city. The Uruguay Sea Island Mathematical Manual consists of several problems solved using the out-in method. By the Tang Dynasty, this particular work was considered so important that the official curriculum devoted three years to its study, even though it just contained nine problems. The Tidal Problem concerns the following situation. Two poles of height 3 zhang are set up 1000 bu apart, and form a straight line with a peak of a sea island. From the ground level 123 bu behind the first pole, the peak of the island and the tip of the first pole coincide. From the ground level 127 bu behind the second pole, the peak of the island and the tip of the second pole coincide. What is the height of the island and its distance from the first pole? So through the magic of 3D animation, we'll see what this given information corresponds to. And if we look at this from the side, those sight lines form the diagonals of some rectangles that we can use the out-in method on. So we have the height of the island and let's complete a few rectangles. So remember we know the height of the poles, the distance apart, and how far behind the pole the sight line reaches the ground. Now to try and avoid squashing all of that into a little space, we'll redraw our picture, not to scale. And if we do that, we'll get something like this. So remember the poles are 1000 bu apart, they're 3 jang high, and the sight line falls 123 bu behind the first pole and 127 bu behind the second pole. And so we have these two complementary rectangles. However it's convenient to think about this lower one as being split into two parts, a blue section and a yellow section. And that's because the blue section is a complementary rectangle to this vertical one. And that's useful because the height of the vertical blue is the same as the height of the vertical green, while the width is 123 and we can mark that segment off. And that means this vertical green can be split into a vertical blue and a vertical yellow. And now we can use this information and the equality of the areas to find the unknown quantities. So the yellows have to have the same area and the horizontal yellow has area 3 by 1000 or 3000. Meanwhile the vertical, well the width is the last part of this 127 bu length. That's 127 minus 123 or 4. So we know the width and that means we know what the height is and that gives us the height and width of the vertical blue rectangles. But the blue rectangles also have the same area. We know the vertical blue is 750 high by 123 wide, so we know its area. We know the height of the horizontal blue is 3 jang and so its length must be and that gives us the distance of the sea island.