Cylinder Optimization

A mathematical optimization program that finds the optimal height/radius ratio for a cylinder to maximize the volume/surface area ratio. The program uses an iterative approach with adaptive step size: it starts with a large step size (dh = -1), calculates volume and surface area for different heights, compares the volume/surface area ratios, and when it finds a local maximum, it reduces the step size by a factor of 10 and continues searching. This demonstrates numerical optimization techniques and iterative refinement.

Source Code:

h = 10000
r = 1000
pi = 3.14
dh = -1
v2# = pi * r * r * h
s2# = 2 * pi * r * r + h * 2 * pi * r
10 :
v# = v2#
s# = s2#
h = h + dh
v2# = pi * r * r * h
s2# = 2 * pi * r * r + h * 2 * pi * r
'PRINT v# / s#, v2# / s2#, h
IF v# / s# > v2# / s2# THEN GOTO 100 ELSE GOTO 10
'GOTO 10
100 :
IF i = 100 THEN END ELSE i = i + 1
PRINT h / r, v#, s#, dh
dh = dh / (-10)
GOTO 10