THE PUZZLET PAGE


PUZZLET 97 - THE SOLUTION


The heart of this problem is to be able to express the ratio of the area of the triangle to that of the enclosed circle in terms of the triangle's base angle.  Here's one way to develop a suitable formula:

Formula

With the formula in our metaphorical toolkit, we can write some code.


' Puzzlet #097
' A circle is enclosed by an  isosceles
' triangle so that the circumference is
' just touching the two sides and base.
' What base angle gives a ratio of  the
' the  triangle's  area to the area  of
' the circle equal to 2? 3? 4? 5?  Work
' to an accuracy of four decimal places.
' By Dave Ellis.

declare Func (angle: float)
declare RadToDeg (rads: float)
declare DegToRad (degs: float)
declare PrintResult()
def ave, fAve, max, min, pi: float
def ratio: int

pi = 3.141593
color 14, 0
openconsole
print "Calculating ...": print
print "Ratio   Angle (degs)": print

for ratio = 2 to 5
  max = DegToRad(89)
  min = DegToRad(1)
  do
    ave = (max + min)/2
        fAve = Func(ave)
    if fAve > ratio
      max = ave
    else
      min = ave
    endif
  until abs(fAve - ratio) < .00001
    PrintResult()
next ratio

print: print "Press a key ... ",
do: until inkey$ <> ""
closeconsole
end

sub Func(angle)
' returns the ratio of the triangle's area
' to that of the circle as a function of the
' triangle's base angle
def numerator, denominator: float
numerator = tan(angle)
denominator = pi*(tan(angle/2))^2
return numerator/denominator

sub DegToRad (degs)
' converts degrees to radians
def rads: float
rads = degs * pi/180
return rads

sub RadToDeg (rads)
' converts radians to degrees
def degs: float
degs = rads * 180/pi
return degs

sub PrintResult
' pretty printer
color 11,0
print "  ", ratio,
print "      ",
print using ("##.####", RadToDeg(ave))
color 14,0
return


PROGRAM NOTES

The program is very simple once you have the formula.  An outer loop iterates variable ratio over the target values of 2 to 5 to provide the solutions required for those values.

Within that an inner DO loop applies the bisection method. This has been used in puzzlets many times before. If you would like more information, please refer back using the archives or e-mail me directly.

At each iteration of the bisection method, the formula is applied when the function Func() is called, since that's where the formula is located. The result is returned as an angle. If the resolution is insufficient, the DO loop is executed again with the latest values, otherwise the program prints the result and quits.

When you run the program, you'll see the inset results printed out onto your computer's screen.

Larger ratios are successively closer to 90o, and the angular differences get smaller.

       


Calculating ...

Ratio   Angle (degs)

  2       74.7350
  3       82.0100
  4       84.4888
  5       85.7807

Press a key ...



Site design/maintenance: Dave Ellis E-mail me!
Last Updated: October 10th, 2009.