Invitation to dinner

Suppose that you want to invite friends to dinner, where you expect the total number of people to be eight. You intend to serve a main dish to everyone, a salad in three big bowls—one at the center of the table and two at the sides. You'll have 8 plates, 8 glasses, 8 forks and knives and 2 bread pans, which will be the only ones with oval form. You are nervous, because the clock is ticking, your dish is in oven and you have no time to test whether your table could accomodate all the servings. You also don't have a lot of flexibility, having only three types of plates in various diameter sizes (26, 22 and 18cm). Can that work?

This is a typical geometric problem which might seem slightly dull on the surface. What is more interesting is that such geometric problems arise frequently in our daily lives, no matter whether we have to deal with web design, interior design, computational geometry, street pavement blocks, street light pole heights or wind turbine hubs.

The beauty of geometric problems is that by design they relate directly to the environment. This means that solving them is often more practical and has direct effect on they way we live. To gather our variables/dimensions we only need a meter and some time to measure. Contrast this with data obtained through sensors, where each one may be expensive to obtain and install. The sensors may need to speak together which may require additional infrastructure.

The reason why the iPhone has particular dimensions is again geometric—to fit well within a human hand. What about key sizes on our keyboard? The mainboard circuit layout? The size of the door handle? The area required to host a number of container pots for gardening?

After this small deviation, let's return to our problem and write some code.

# All dimensions are in cm from math import pi table_width, table_height = 170, 80 # rectangle number_people = 8 plate_diameter = 26 # circle glass_diameter = 14 # circle salad_bowls = 3 salad_bowl_diameter = 50 # circle bread_pans = 2 bread_pan_small_diameter, bread_pan_big_diameter = 28, 42 # ellipse fork_length, knife_length = 16, 19 # assume rectangles utensil_width = 4 table_area = table_width * table_height servings_area = pi * (number_people * ((plate_diameter/2)**2 + (glass_diameter/2)**2) + salad_bowls * (salad_bowl_diameter / 2) ** 2 + bread_pans * (bread_pan_small_diameter * bread_pan_big_diameter) / 4) + (fork_length + knife_length) * utensil_width * number_people print(table_area) print(servings_area)

As we can see from this example, the table area is 13600cm2, while the servings area becomes slightly over 14336cm2. This is disappointing, because it means that our original plan to use the plates with diameter 26cm won't work. At least we didn't waste time to put anything on the table. But what happens if we try to swap these plates with the smaller sized ones (22cm)? Now we only need to change the value of a single variable and run the code again. The servings area becomes 13130cm2, which is smaller than the table area. In theory, this has a good chance to work if we optimize the positioning. Hopefully our guests won't learn how this small tradeoff will affect the amount of food they receive.