Genaille's Rods

[Home]   [Puzzles & Projects]    [Delphi Techniques]   [Math topics]   [Library]   [Utilities]

 

 

Search

Search WWW

Search DelphiForFun.org

As of October, 2016, Embarcadero is offering a free release of Delphi (Delphi 10.1 Berlin Starter Edition ).     There are a few restrictions, but it is a welcome step toward making more programmers aware of the joys of Delphi.  They do say "Offer may be withdrawn at any time", so don't delay if you want to check it out.  Please use the feedback link to let me know if the link stops working.

 

Support DFF - Shop

 If you shop at Amazon anyway,  consider using this link. 

     

We receive a few cents from each purchase.  Thanks

 


Support DFF - Donate

 If you benefit from the website,  in terms of knowledge, entertainment value, or something otherwise useful, consider making a donation via PayPal  to help defray the costs.  (No PayPal account necessary to donate via credit card.)  Transaction is secure.

Mensa® Daily Puzzlers

For over 15 years Mensa Page-A-Day calendars have provided several puzzles a year for my programming pleasure.  Coding "solvers" is most fun, but many programs also allow user solving, convenient for "fill in the blanks" type.  Below are Amazon  links to the two most recent years.

Mensa® 365 Puzzlers  Calendar 2017

Mensa® 365 Puzzlers Calendar 2018

(Hint: If you can wait, current year calendars are usually on sale in January.)

Contact

Feedback:  Send an e-mail with your comments about this program (or anything else).

Search DelphiForFun.org only

 

 

 

 

Problem Description

Genaille's Rods, also called Genaille-Lucas Rulers, are an extension of a graphical method of multiplying and dividing developed by Napier in the 16th century.   I thought they were kind of cool - so decided to develop a program to make a printable version.   This is it.

Reference:  Knotted Doughnuts, Martin Gardner, W. H. Freeman & Co.

Background & Techniques

Baron John Napier gave the world it's first table of logarithms and coined the word logarithm.  In the days before calculators, methods of simplifying calculations were of much interest.  In 1617 Napier also published a book describing a method to multiply, divide and extract square roots using a set of bars or rods.   These became known as Napier's Bones.   

In the late 1800s, Henri Genaille, a French civil engineer,  invented an improvement to Napier's Bones that eliminates the need to handle carries from one digit position to the next.  The problem was posed by Edouard Lucas and thus the alternate name of Genaille-Lucas Rulers .  

The  process of multiplying any integer of any length by a digit 1-9 is reduced to looking up numbers on the rods.   Studying how and why these rods work gives real insight into the nature of multiplication.     

Here's an example which shows partial rods set up to multiply 8563 by a digit from 1 to 4.   Starting from the rightmost, topmost digit for a particular index value, the answer can be read directly by following the arrows to the left.  For example 8563 X 4 is 34252

The program has over 400 lines of source code, which puts it in the Advanced category per my arbitrary classification system.  However a couple of hundred lines handle various display options that were implemented for debugging (draw a single box, draw a single row, draw a single rod, etc.)  so I'm calling it an Intermediate.   The heart of the code is an exercise in drawing directly on a canvas.  By displaying the image in a TImage,  we can let the component worry about redrawing the image as required.  

A simple TRodSet object is defined to hold the basic parameters used while drawing rods.  TRodSet.DrawBox is the key procedure - it displays a particular multiplier/multiplicand box at a given set of coordinates - and was the most fun to write.

The print routine draws directly on the printer canvas.  If memory is limited (for example on my old Dell laptop)  - an "out of resources"  error may occur.   There's some commented code that I used to draw the image on a half size bitmap and StretchDraw it full-sized  to the printer canvas in this case.  

Running/Exploring the Program 

bulletBrowse source extract
bulletDownload source
bulletDownload  executable

Suggestions for Further Explorations

It would be fairly simple to generalize the program to draw a set of rods to solve a particular problem.  As delivered a single sample problem is displayed.  I would probably also remove all of the partial rod set drawing code that was implemented for debugging.  
There is a version of Genaille's Rods that can be used for division although it is considerably messier - the "arrows" of the multiplying version become lines connecting each quotient digit with the next.   
  
 
 
  [Feedback]   [Newsletters (subscribe/view)] [About me]
Copyright © 2000-2018, Gary Darby    All rights reserved.