# wasting n-dimensional peanut butter

I was scraping the last peanut butter out of the jar during the Covid19 pandemic, and wondering how much of the good stuff was left down inside the jar, inaccessible but for the most desperate scrounging with my most creatively used kitchen utensils. At some point, I would grow weary of this process and simply throw away the jar. But, how much peanut butter would that be wasting?

I imagined that the inside of the jar must be a cylinder, and the bottom a circlur disk, and say, on average, some portion of this surface area has inaccessible butter on it. Now naturally the inaccessible butter is in strange shapes owing to the physical arrangement of my scraping device, little swirls and chunks and bits, but maybe we could imagine all this is equivalent to a smooth layer all over the inside, with a depth of, say, 1mm.

Now if my jar is 50 mm in radius and 150mm height, we could calculate an estimate of the lost butter by taking the volume of the peanut butter layers on the cylinder and on the bottom circle of the jar. Neglecting the corner between the bottom and the sides:

$$outercyl=\pi*radius^2*height\approx\pi*50^2*150 mm^3$$ $$innercyl=\pi*radius^2*height\approx\pi*49^2*150 mm^3$$ $$bottom=\pi*radius^2\approx\pi*50^2 mm^3$$ $$(bottom+outercyl-innercyl)\approx54506 mm^3$$

Fascinating. I'm wasting about 54506 cubic millimeters of peanut butter. That is roughly a cube of peanut butter 38 mm on each side! Maybe I should try harder with my spoon.

Then I started thinking... what if we had a different dimensional jar of peanut butter?

Well, what exactly is a jar? It is a circle, a 2 dimensional shape, that has been extruded in three dimensional space, with a circular disk on one end to close it so the contents won't fall out.

So what if we had less than 3 dimensions? Like, 2, say? What is a 2 dimensional jar? Well, we would have to also downgrade the dimensions of the circle - instead of 2, it is now 1. What is a 1 dimensional circle? It is all the points at radius r from a single point in 1 dimensional space - if drawn, this just looks like two dots equidistant from a center. And a filled circle, a disk, in 1 dimensions is all the points inbetween those two points. And if we extrude the circle, in 2 dimensions, it is just a sort of long bracket shape.

The peanut butter lost in 2 dimensional peanut butter jar, is therefore the height of the jar times 2, plus twice the radius of the bottom. If our 2 dimensional jar is 50 mm radius and 150mm height, the lost butter is this.

$$height *2 + radius * 2 = 50*2+100*2=400mm^2$$

Again, wow, that's a square of peanut butter 20mm on a side that's being wasted!

Now.

What if there is a 4 dimensional peanut butter jar?

A circle in n-1 dimensions, or 3 dimensions, is a sphere.

Can we extrude this sphere in the 4th dimension? Sure, to us 3 dimensional mortals we may imagine it as though we can take 'slices' of the hyper-jar, each of which looks like a hollow sphere of glass with peanut butter lining its interior. Just as a 2 dimensional person might see our 3d jar in "slices" - they could only see individual circles.

4 dimensional people, then, supposedly, could reach into the hyperjar with a hyper-spoon and pull out the hyper peanut butter and eat it. For us 3 dimensional mortals, this would look like peanut butter disappearing from the inside of a sphere, just as a 2 dimensional creature would imagine us eating a jar of peanut butter, as peanut butter disappearing from the inside of a circle, which represented a 'slice' of the 3 dimensional jar, shown in two dimensions.

Of course, the hyperjar must be closed on it's hyperbottom so the peanut butter doesn't fall out - this is why the bottom sphere is entirely solid glass.

But don't the 4 dimensional people have the same problem? It's hard to get all of the hyper-butter out of the hyper jar with the hyperspoon. There's always some little layer leftover inside.

For us 3 dimensional beings, this may be seen as a sphere of glass with little bits of peanut butter on the inside, which were never scraped out. Just as for a 2 dimensional person, it may seem that the waste butter of a 3d jar looks like a bunch of circles with their insides not completely scraped off.

How much butter is wasted though? Assuming we still can approximate the wasted butter as though it were a single smooth layer, 1 mm thick.

And here is the question:

Given a $$\n\$$-dimensional jar of peanut butter, of radius $$\r\$$ and height $$\h\$$, how much peanut butter is wasted, assuming a layer of unused butter 1mm thick coats the inside of the jar? Rounded to the nearest integer.

This is code golf. Lowest number of bytes wins! Usual rules apply.

• This question has a ton of story but simply boils down to evaluating a particular mathematical expression. I feel that the fluff needs to at the very least be significantly pared down. – Ad Hoc Garf Hunter Mar 22 at 19:59
• Just use a spatula. – S.S. Anne Mar 22 at 20:09
• @S.S.Anne in my country we have a special name for such a spatula, we call it a "salazar", because of a dictator we had that was called António de Oliveira Salazar. He saved a lot of money and didn't let anything go to waste, hence we call such a spatula a "salazar" :) – RGS Mar 22 at 20:32
• @S.S.Anne Obligatory link (sorry). – Arnauld Mar 22 at 20:58