CS‑01 calc stackhp first, all calculators welcome
#10 — Any

The Swinging Blade

The problem

Edgar Allan Poe’s The Pit and the Pendulum (1842) leaves its narrator strapped to a wooden frame in a cell of the Inquisition, with a painted figure of Time on the ceiling above him. From the figure swings a pendulum with a blade of steel, and it comes lower with every pass. The prisoner can do nothing but watch it and count.

Poe gives no length for the pendulum and no arc for its swing, so every figure below is an assumption of this puzzle. Treat the blade as the weight on the end of a light, rigid rod, hanging from a fixed pivot in the ceiling:

  • Length of the pendulum, pivot to blade: L = 10 m.
  • Amplitude: the blade is drawn aside and released from 60° either side of the vertical, and is held to that 60° every swing. (The blade really does come down in the story. Here it is held at one length while you count.)
  • Gravity: g = 9.80665 m/s².
  • One swing means one complete cycle: out to one side, across to the other, and back to where it began.

How long does the blade take to make 30 complete swings? Give the answer in seconds, to the nearest second.

Notes

  • Ignore air resistance and friction. Treat the blade and rod as a single point weight on a massless rod, a simple pendulum.
  • Work in degrees throughout, unless you choose a method that needs radians.
  • Not every pendulum formula applies to this one. The amplitude is large, and the usual textbook result was derived for small swings. Whichever method you use, check what it assumes.
  • This needs an addition somewhere, so no slide rule this time.

Hint

Click for a hint

The familiar T = 2π√(L/g) is the limit of the true period as the swing gets small. At 60° each side the true period is noticeably longer, and over thirty swings the gap is big enough to change the rounded answer.

The exact period is T = 4√(L/g)·K(k), where K is the complete elliptic integral of the first kind and k = sin(θ₀/2). You do not need to evaluate an integral. Gauss showed that K can be had by repeatedly taking an arithmetic mean and a geometric mean of two numbers, and the two means converge on each other with astonishing speed. Start from 1 and cos(θ₀/2): replace the pair (a, g) by ((a + g)/2, √(a·g)) and repeat. After two rounds the two numbers agree to about six digits. Then

T = 2π·√(L/g) / AGM(1, cos(θ₀/2))

If you would rather not iterate, there is also a series in the amplitude (in radians) that multiplies the small-angle period by 1 + θ₀²/16 + 11θ₀⁴/3072 + 173θ₀⁶/737280 + …

Solution

Click to reveal the solution

The small-angle period. The textbook value would be

T₀ = 2π · √(L/g) = 2π · √(10/9.80665) = 2π · 1.009810 = 6.344823 s

but that formula replaces sin θ with θ, which is only good for small swings.

The exact period. For a swing of amplitude θ₀ the period is

T = 4 · √(L/g) · K(k),     k = sin(θ₀/2)

and Gauss’s arithmetic-geometric mean gives K(k) = π / ( 2 · AGM(1, k′) ) with k′ = cos(θ₀/2). The two factors of 2 combine, so

T = 2π · √(L/g) / AGM(1, cos(θ₀/2)) = T₀ / AGM(1, cos 30°)

The AGM. Start with a = 1 and g = cos 30° = 0.866025. Each round replaces a with (a + g)/2 and g with √(a·g), using the old values of both:

Round a g
0 1.0000000 0.8660254
1 0.9330127 0.9306049
2 0.9318088 0.9318080
3 0.9318084 0.9318084

So AGM(1, cos 30°) = 0.931808. The last row is only there to show that both columns have settled; the average of round 2’s pair already gives it.

The period and the thirty swings.

T = 6.344823 / 0.931808 = 6.80915 s
30 T = 204.2745 s

Answer: 204 seconds (3 minutes 24 seconds).

What the small-angle formula would have said. 30 T₀ = 190.34 s. That is about 14 seconds short, a 7.3% error on a swing that looks quite gentle. The series gives the same correction factor as the AGM: 1 + 0.06854 + 0.00431 + 0.00031 + … = 1.0732, and T/T₀ = 6.80915/6.344823 = 1.0732.

Check. The period must lie between T₀ and the period for a much wider swing, and the correction factor of 1.0732 is the right size for 60°. ✓

Calculator solutions

Every machine below uses the same plan. Put the calculator in degrees. Start with a = 1 and g = cos 30°. Do two rounds of the arithmetic and geometric means, each time using the old a and g to make the new pair, then average once more to finish the AGM. Divide the small-angle period 2π√(L/g) by that, and multiply by 30.

The two registers hold a and g between rounds. The geometric mean is built first and left on the stack while the arithmetic mean is built, so a swap puts each back in its register.

HP-42S

Set DEG (MODES menu).

30  COS  STO 02                 g = cos 30°
1  STO 01                       a = 1

RCL 01  RCL 02  ×  √x           g′ = √(a·g)
RCL 01  RCL 02  +  2  ÷         a′ = (a + g)/2
STO 01  X<>Y  STO 02            a′ and g′ back in their registers
                                (the same eleven keys again, for round 2)
RCL 01  RCL 02  +  2  ÷         the AGM
10  ENTER  9.80665  ÷  √x       √(L/g)
X<>Y  ÷                         √(L/g) / AGM
π  ×  60  ×                     × 2π × 30

Display (FIX 4): 204.2745. The full value is 204.274505…, so it is 204 seconds.

HP-15C

The 15C powers up in degrees. The swap key is the one labelled x≷y, and π is g EEX.

30  COS  STO 2
1  STO 1

RCL 1  RCL 2  ×  √x
RCL 1  RCL 2  +  2  ÷
STO 1  x≷y  STO 2
(the same keys again, for round 2)
RCL 1  RCL 2  +  2  ÷
10  ENTER  9.80665  ÷  √x
x≷y  ÷
g π  ×  60  ×

Display (FIX 4): 204.2745 → 204 seconds.

HP-41C

Degrees is the power-up mode. X<>Y is the key labelled x≷y, and PI is the gold shift of 0.

30  COS  STO 02
1  STO 01

RCL 01  RCL 02  ×  SQRT
RCL 01  RCL 02  +  2  ÷
STO 01  X<>Y  STO 02
(the same keys again, for round 2)
RCL 01  RCL 02  +  2  ÷
10  ENTER  9.80665  ÷  SQRT
X<>Y  ÷
PI  ×  60  ×

Display (FIX 4): 204.2745 → 204 seconds. The 41C takes a few seconds over each COS and SQRT, and a key pressed while it is still working is lost, so let the display settle before pressing the next one.

HP-48GX

RPL needs an ENTER between two numbers, and the stack is deep, so this version skips registers and keys the first two rounds out in full. It builds the constant 60π√(L/g) first and divides by the AGM at the end. Set DEG (type it as a command name; the 48 has no key for it). √x is an unshifted key and π is ← SPC. π is symbolic on the 48, so finish with →NUM.

DEG
10 ENTER 9.80665 ÷ √x  π  ×  60  ×       60π √(L/g)

30 COS 1 + 2 ÷                           a₁ = (1 + cos 30°)/2
30 COS √x                                g₁ = √cos 30°
+  2 ÷                                   a₂ = (a₁ + g₁)/2

30 COS 1 + 2 ÷                           a₁ again
30 COS √x                                g₁ again
×  √x                                    g₂ = √(a₁ g₁)

+  2 ÷                                   the AGM = (a₂ + g₂)/2
÷  →NUM                                  the whole thing, divided by the AGM

Result: 204.274505579 → 204 seconds, matching the HP-42S to ten significant digits.

HP-25

Degrees is the default. Press f FIX 4 first so the display is not stuck at two decimals. π is g π, and XY is the x≷y key. The HP-25 has eight registers, numbered 0 to 7.

30  COS  STO 2
1  STO 1

RCL 1  RCL 2  ×  f √x
RCL 1  RCL 2  +  2  ÷
STO 1  x≷y  STO 2
(the same keys again, for round 2)
RCL 1  RCL 2  +  2  ÷
10  ENTER  9.80665  ÷  f √x
x≷y  ÷
g π  ×  60  ×

Be patient: the HP-25 takes a couple of seconds over every COS and √x, and a key pressed while it is still working is simply lost. Wait for the display to settle before each next key.

Display: 204.2745 → 204 seconds.

Elektronika MK-61

Slide the angle switch to Г (degrees). cos is F 8, √ is F -, π is F +, В↑ is the Enter key, and x→П and П→x store and recall (x→П 1 stores in register 1). ↔ swaps X and Y.

A recall already lifts the stack on this machine, so two recalls in a row need no В↑ between them. The constant 10 is typed straight after an arithmetic key, never straight after a recall, because a number typed right after a recall replaces what it recalled.

3 0  F cos  x→П 2
1  x→П 1

П→x 1  П→x 2  ×  F √
П→x 1  П→x 2  +  2  ÷
x→П 1  ↔  x→П 2
(the same keys again, for round 2)
П→x 1  П→x 2  +  2  ÷
1 0  В↑  9 . 8 0 6 6 5  ÷  F √
↔  ÷
F π  ×  6 0  ×

Display: 204.27448 → 204 seconds.

The MK-61 carries eight significant digits, so its last two sit a little off the HP machines’ 204.27451. All of them round to 204 seconds.

TI-84

Set MODE → Degree. Store a and g in variables, then repeat the update line twice by pressing ENTER on it:

1→A:cos(30)→B
(A+B)/2→C:√(A*B)→B:C→A        press ENTER twice
(A+B)/2→A
60π√(10/9.80665)/A

Result: ≈ 204.2745 → 204 seconds. After the two rounds, A holds 0.931808.

Casio fx-991

The same plan as the TI-84. Set Degree mode first: on a ClassWiz (fx-991EX/CW) that is SHIFT MENU → Angle Unit → Degree; on an older fx-991ES it is SHIFT MODE → Degree. Multi-statements are separated by : (ALPHA CALC).

1 → A : cos(30) → B
(A+B)÷2 → C : √(A×B) → B : C → A       press = twice (replay with ▲ to repeat)
(A+B)÷2 → A
60π√(10÷9.80665)÷A

Result: ≈ 204.2745 → 204 seconds.

Bonus: The Descending Blade

For programmable calculators only.

In the story the blade does not swing at one length for ever. A little at a time, it comes down. A different pendulum swings at every length, and the inquisitors’ schedule needs to know how long each swing will take.

The task. Write a program that takes a length L in metres in register 1 and an amplitude θ₀ in degrees in register 2 (each side of the vertical, anywhere from 0° up to but not including 180°), and stops with the period in seconds on the display. Use g = 9.80665 and the same exact method as the main challenge.

The main challenge needed two rounds of the AGM. A program cannot assume that: the wider the swing, the more rounds it needs. Your program must keep going until it has converged, then stop.

Set your calculator to degrees, then test your program on these cases:

Case L (m) θ₀ (°)
A 10 60
B 10 120
C 3 10
D 10 170
Click for a hint

Keep a and g in two registers. Each pass of the loop replaces them both from their old values, so one of the new values has to wait on the stack while the other is calculated. Then test whether a and g have come together before you go round again.

You do not need to wait for them to be equal. The two means close in on each other so fast that once a − g is smaller than a small tolerance, such as 0.00001, one more average of the pair is already correct to ten digits or so. So test, then loop, and when the test passes take the average and finish the arithmetic: 2π√(L/g) divided by the AGM.

The arccosine is not involved here, but a swing close to 180° makes cos(θ₀/2) small, and the first rounds then shrink the gap much more slowly. Do not hard-code the number of rounds.

Click to reveal the solution
Case AGM(1, cos θ₀/2) Rounds to converge Period T
A 0.931808 2 6.8092 s
B 0.728396 3 8.7107 s
C 0.998096 1 3.4818 s
D 0.409943 4 15.4773 s

The method. The period is

T = 2π · √(L/g) / AGM(1, cos(θ₀/2))

Set a = 1 and g = cos(θ₀/2). While a − g is at least 0.00001, replace the pair with ((a + g)/2, √(a·g)). Since a is always the larger of the two, a − g is never negative. When the gap is smaller than the tolerance, the answer is (a + g)/2, because the AGM converges quadratically: the gap after the next round would be roughly (a − g)²/(8a), far below anything a calculator shows.

Why a loop, not a count. Case C converges after one round and case D after four. A program with a fixed number of rounds is either wasteful on narrow swings or wrong on wide ones. The test costs only a few steps.

Programs

Programs follow for the HP-42S, HP-15C, HP-41C and Elektronika MK-61. The HP-25 is left out: keyed in one step per key as the HP-25 requires, this program comes to 53 steps, against the HP-25’s 49. Open the one for your calculator, key it in once, then store a length and an amplitude and run it. The text to the right of a listing explains it; do not key it in. Put the calculator in degrees first.

HP-42S

This program uses 45 lines. Press PRGM, key in the lines, press PRGM again.

01      LBL 01                            start
02-05   RCL 02   2   ÷   COS               cos(θ₀/2)
06      STO 04                            g = cos(θ₀/2)
07-08   1   STO 03                        a = 1
09      LBL 02                            top of the loop
10-11   0.00001   RCL 03                  tolerance in Y
12-14   RCL 04   −   X≤Y?                  a − g, against the tolerance
15      GTO 03                            a − g ≤ tolerance: finish
16-19   RCL 03   RCL 04   ×   √x          g′ = √(a·g)
20-24   RCL 03   RCL 04   +   2   ÷       a′ = (a + g)/2
25-27   STO 03   X<>Y   STO 04            a′ and g′ saved
28      GTO 02                            round again
29      LBL 03                            converged
30-34   RCL 03   RCL 04   +   2   ÷       the AGM
35-38   RCL 01   9.80665   ÷   √x          √(L/g)
39-45   2   ×   π   ×   X<>Y   ÷   RTN    2π√(L/g) / AGM

To run it, put the calculator in DEG, store the length and the amplitude, and start it. For case A:

10   STO 01
60   STO 02
XEQ 01

The period in seconds appears in X: ≈ 6.8092.

HP-15C

g P/R toggles program mode; LBL 1 is f LBL 1, the test is g x≤y (the g ÷ key), and x≷y swaps X and Y. The 15C powers up in degrees. The 15C works at its own speed, so wait for the program to stop before reading the display.

f LBL 1                                   start
RCL 2   2   ÷   COS   STO 4                g = cos(θ₀/2)
1   STO 3                                 a = 1
f LBL 2                                   top of the loop
0 . 0 0 0 0 1   RCL 3   RCL 4   −          tolerance in Y, a − g in X
g x≤y   GTO 3                             a − g ≤ tolerance: finish
RCL 3   RCL 4   ×   √x                    g′ = √(a·g)
RCL 3   RCL 4   +   2   ÷                 a′ = (a + g)/2
STO 3   x≷y   STO 4                       a′ and g′ saved
GTO 2                                     round again
f LBL 3                                   converged
RCL 3   RCL 4   +   2   ÷                 the AGM
RCL 1   9 . 8 0 6 6 5   ÷   √x             √(L/g)
2   ×   g π   ×   x≷y   ÷   R/S           2π√(L/g) / AGM

To run it, store the length and the amplitude and start it. For case A:

10  STO 1
60  STO 2
GSB 1

The period shows when the program stops: ≈ 6.8092.

HP-41C

PRGM toggles program mode; LBL is the gold shift of STO, and the test X<=Y? is the gold shift of +. The 41C powers up in degrees, and is slow: wait for the program to stop before reading the display.

LBL 01                                    start
RCL 02   2   ÷   COS   STO 04              g = cos(θ₀/2)
1   STO 03                                a = 1
LBL 02                                    top of the loop
0.00001   RCL 03   RCL 04   −              tolerance in Y, a − g in X
X<=Y?   GTO 03                            a − g ≤ tolerance: finish
RCL 03   RCL 04   ×   SQRT                 g′ = √(a·g)
RCL 03   RCL 04   +   2   ÷                a′ = (a + g)/2
STO 03   X<>Y   STO 04                    a′ and g′ saved
GTO 02                                    round again
LBL 03                                    converged
RCL 03   RCL 04   +   2   ÷                the AGM
RCL 01   9.80665   ÷   SQRT                √(L/g)
2   ×   PI   ×   X<>Y   ÷   R/S          2π√(L/g) / AGM

To run it, store the length and the amplitude and start it. For case A:

10  STO 01
60  STO 02
XEQ 01

The period shows when the program stops: ≈ 6.8092.

Elektronika MK-61

This program uses 58 of the machine’s 105 steps. Put the angle switch on Г (degrees). F ПРГ enters program mode and F АВТ leaves it. cos is F 8, √ is F -, π is F +. Addresses start at 00. A conditional jump takes its two-digit address as one step and jumps when its test is false. The test F x<0 falls through when X is negative, which here means the loop is done, and jumps to the address given when it is not, which sends the program round again.

00-03   П→x 2   В↑   2   ÷                cos argument: θ₀/2
04-05   F cos   x→П 4                      g = cos(θ₀/2)
06-07   1   x→П 3                          a = 1
08-10   П→x 3   П→x 4   −                  top of the loop: a − g
11-17   0 . 0 0 0 0 1                      the tolerance
18-19   −   F x<0                           (a − g) − tolerance: negative means converged
20      44                                 not negative: go to 44 for another round
21-25   П→x 3   П→x 4   +   2   ÷          converged: the AGM
26-27   П→x 1   В↑                         L
28-34   9 . 8 0 6 6 5                      g
35-36   ÷   F √                            √(L/g)
37-40   2   ×   F π   ×                    2π√(L/g)
41-43   ↔   ÷   С/П                        2π√(L/g) / AGM, then stop
44-47   П→x 3   П→x 4   ×   F √            g′ = √(a·g)
48-52   П→x 3   П→x 4   +   2   ÷          a′ = (a + g)/2
53-55   x→П 3   ↔   x→П 4                  a′ and g′ saved
56-57   БП   08                            round again

To run it, store the length and the amplitude and start it. For case A:

1 0   x→П 1
6 0   x→П 2
БП 0 0
С/П

The period shows when it stops: ≈ 6.8091.

The MK-61 works to eight digits, so its last digits differ a little from the HP machines’.

Anyhardphysicspendulumarithmetic-geometric-meanhalloweenpoeliterature

Solvable on: HP-42S, HP-15C, HP-41C, HP-48GX, HP-25, Elektronika MK-61, TI-84, Casio fx-991