"""The square-cube law: scale every length by k and areas grow as k^2, volumes as k^3.""" import sys from pathlib import Path sys.path.insert(0, str(Path(__file__).resolve().parents[1])) from labkit import Q, versions # noqa: E402 print("computed:", versions()) print() print("Scale every length of a body by k:") print(" k length area (strength) volume (weight) strength per weight") for k in (1, 2, 3, 10, 100, 1000): print(f"{k:>8} {k:>6} {k**2:>15,} {k**3:>15,} {'1' if k == 1 else '1/' + format(k, ',')}") print() print("An ant scaled up 1,000 times (5 mm -> 5 m):") ant = Q(5, "mm") big = (ant * 1000).to("m") print(f" length {ant} -> {big}") print(" its legs' cross-section grows 1,000,000 times, its weight 1,000,000,000 times") print(" each square millimetre of leg must hold up 1,000 times the weight it did") print() print("Surface-to-volume ratio of a cube of side s (6 s^2 / s^3 = 6/s):") for side in (Q(1, "cm"), Q(10, "cm"), Q(1, "m"), Q(3, "m")): ratio = (6 * side**2 / side**3).to("1/m") print(f" s = {side.magnitude:>3} {side.units:~}: {ratio.magnitude:>6.0f} square metres of skin per cubic metre of body") print(" a body 100 times smaller has 100 times more surface for each kilogram")