Intel's Ronler Acres Plant

Silicon Forest
If the type is too small, Ctrl+ is your friend

Thursday, June 20, 2024

Spindle

The red arc describes the upper side of the hull, the blue follows the lower side. The straight green, red and black straight lines are radii for the upper arc. The length of the spindle is 70 meters and the diameter at the center is 8 meters.

I was reading about the Nautilus submarine from Jules Verne's 20,000 leagues under the sea. Seems the submarine in the novel was shaped like a spindle, not at all like the one in the movie. My question is: how do you compute the volume of a spindle? There might be a formula out there somewhere, but I have not found it. So I thought I would try calculating it on my own. Last week I made up a spreadsheet to sum the volume of sequential slices.

I used the Pythagorean formula to generate a formula to compute the radius of the hull from the distance from the bow. That seemed to work fine. The next day I tried to check my work, but being short on sleep my head was full of cotton and I could not make sense of it. Now I think I understand what it's like for people who have a hard time with math. It was like part of my brain was not working. Anyway, I'm doing better today so I took another look at it.

I decided the spread sheet was too cumbersome, so I wrote a little computer program to compute the volume by cutting the spindle into slices, computing the volume of each slice and then adding them all together. The volume is in cubic meters. Ten slices gets you to the nearest meter and a thousand slices will get you to the nearest cubic centimeter. Beyond that any differences that show up might be due to the limits of double precision arithmetic.

  CPU ticks      Slices        Volume
           4             1  3,518.583,772
           4            10  1,883.743,261
          17           100  1,883.565,830
         133         1,000  1,883.565,812
       1,339        10,000  1,883.565,812
      12,929       100,000  1,883.565,812
     131,847     1,000,000  1,883.565,812
   1,110,081    10,000,000  1,883.565,813
  10,897,789   100,000,000  1,883.565,810

The volume is in cubic meters. At one hundred slices we already have the volume to the nearest liter (one one-thousandth of a cubic meter). At one thousand slices we have the volume to down to one cubic centimeter (one milliliter). At ten million slices the last digit starts changing. I suspect we have reached the limit of what can be done with floating point math without taking a closer look at the equations. I'm not going to do that. The nearest cc is close enough for me.

Comma-fication

Big numbers without commas are hard to read, so I spent most of a day working out how to automatically place commas in the output. It made the program four times as long. In some versions of C you can use an apostrophe to tell printf to insert commas, but it wasn't available with the online compiler I used, so I wrote my own routines. And because I wasn't sure if it was working correctly, I wrote another one to verify the first.

I also added some rudimentary command line parsing so you can change the length, beam and number of slices without having to modify the code.

Blog post: Jules Verne - Nautilus

Desmos Calculator Graph

C program source code on github

OnlineGDB IDE (Interactive Development Environment) C compiler

The length of the Nautilus is given as 70 meters and the beam is 8 meters.



1 comment:

Anonymous said...

Count how many kegs it takes to fill it with beer.
xoxoxoBruce