CODING ★ AMSTRAD ACTION DISCOURSE - HERO'S ALGORITHM TO APPROXIMATE THE SQUARE ROOT OF A NUMBER|Amstrad Action) ★

Amstrad Action Discourse - Hero's Algorithm to Approximate the Square Root of a Number
★ Ce texte vous est présenté dans sa version originale ★ 
 ★ This text is presented to you in its original version ★ 
 ★ Este texto se presenta en su versión original ★ 
 ★ Dieser Text wird in seiner Originalfassung präsentiert ★ 

This month Hero's engine gets a demonstration at the capable hands of JAMES WILSON.

In 50 BC Egypt. fell into the hands of the Roman Empire and the decline of Alexandria as a centre of intellectual innovation and excellence got well under way. But the great school still had a genius or two left from whom we inherit some useful algorithms.

In Discourse II Diophantus was mentioned in connection with his implicit use of the idea of a limit. Such a method was also used by Hero to estimate square roots of numbers which were not perfect squares.

We apologise for the three errors that crept into June's Discourse.

x2 -p = y2 and thus p=x2-y2=(x=y)

should have read

x2 -p = y2 and thus p = x2-y2=(x+y) (x-y)

series is 2n=m wherem is 1,3,5... as the should have read

series is 2n+m where m is 1,3,5... as the

and

from above, P=(x+y)(x-y) , 9271 = 123x73

should have read

from above , P=(x+y)(x-y),9271 = 127x73
Thanks to those readers who wrote or phoned to question or correct these errors!

Hero of Alexandria (ca.62 AD) was a practical man rather than a philosophical mathematician. In his book Pneumatica he describes the famous Hero's Engine whereby a small tank of water mounted on an axle is made to spin by heating the tank and allowing the steam to escape through two opposing holes - the first suggestion of a steam engine.

In his Mechanica he discusses gear trains, worm wheels, pulleys and levers in various combinations. His surveyor's Dioptra a form of theodolite, used screws and worm gears for fine adjustments.

Hero also advanced Euclid's optical work. He was the first to demonstrate the Law of Reflection of light - that the angle a: which light is reflected from a surface is equal the angle at which it strikes and he designed other surveying instruments which depended upon this.

He also investigated refraction are he mused on the effect of refraction on astronomical observations made near the horizon. But like the rest he also spent some time studying numbers.

The square roots of many integers are not only themselves not integers, but cannot even be represented properly and completely as a fraction.

For instance , 2, the square root of 4 , can be equally well written as 2/1 or 36/18. However, SQR(2) cannot be represented as a fraction no matter how large the numerator (top number) 0n denominator (bottom number) and therefore is called an irrational number.

Hero developed an algorithm that makes it possible to create a fraction which is as close as we wish to get to the actual value of the square root of any integer.

The Heronian Algorithm depends on the fact that if we have any two numbers which, when multiplied together, form a third, then the average of these two numbers is closer to the square root of the third than either of them.

For example. 4 x 9 = 36. One could say that cither 4 or 9 are approximations of SQR(36): but their average (6 ½) is closer still. This is clearly true. If we can find a number n so that n x 6 ½ = 36, then the average of n and 6 ½ will be even closer still!

This number n is known as the inverse of the approximation (6 ½ i:i this instance). By schoolboy algebra this must be 72/13.

Interestingly, the values of the approximation approach the square root from 'above' , whereas the inverse approaches it from 'below' , the two converging on the actual limiting value. The gap between them narrows quickly and the values of both the numerator and denominators of these fractions increase very rapidly.

For this reason, though we are dealing with integers , their values so quickly exceed 32676 that we have had to use Real numbers to represent them and, even then, after a couple of iterations we exceed the real top limit of 1..7E+38. This restriction of the CPC means the algorithm looses too much accuracy after about SQR(36) to be of real use, but is is a very fine example of a convergent algorithm.

AA#47

★ YEAR: 1989
★ AUTHOR: James Wilson
 

★ AMSTRAD CPC ★ DOWNLOAD ★

Type-in/Listing:
» Hero  s  Algorithm  To  Approximate  the  Square  Root  of  a  Number    (Amstrad  Action)    ENGLISHDATE: 2021-02-08
DL: 111
TYPE: ZIP
SiZE: 4Ko
NOTE: 40 Cyls
.HFE: Χ

★ AMSTRAD CPC ★ A voir aussi sur CPCrulez , les sujets suivants pourront vous intéresser...

Lien(s):
» Coding » Clefs1 03 - Instructions Basic
» Coding » Essai Compilateur Basic
» Coding » Clefs1 31 Adr Exec Basic 464
» Coding » Reduction du Code Basic (Amstar&CPC)
» Coding » SID Basic
» Coding » Basic - Tout sur les Fichiers (CPC Revue)
Je participe au site:
» Vous avez des infos personnel, des fichiers que nous ne possédons pas concernent ce programme ?
» Vous avez remarqué une erreur dans ce texte ?
» Aidez-nous à améliorer cette page : en nous contactant via le forum ou par email.

CPCrulez[Content Management System] v8.7-desktop/c
Page créée en 467 millisecondes et consultée 398 fois

L'Amstrad CPC est une machine 8 bits à base d'un Z80 à 4MHz. Le premier de la gamme fut le CPC 464 en 1984, équipé d'un lecteur de cassettes intégré il se plaçait en concurrent  du Commodore C64 beaucoup plus compliqué à utiliser et plus cher. Ce fut un réel succès et sorti cette même années le CPC 664 équipé d'un lecteur de disquettes trois pouces intégré. Sa vie fut de courte durée puisqu'en 1985 il fut remplacé par le CPC 6128 qui était plus compact, plus soigné et surtout qui avait 128Ko de RAM au lieu de 64Ko.