Note G

Last updated
Note G, originally published in Sketch of The Analytical Engine Invented by Charles Babbage Diagram for the computation of Bernoulli numbers.jpg
Note G, originally published in Sketch of The Analytical Engine Invented by Charles Babbage

Note G [lower-alpha 1] is a computer algorithm written by Ada Lovelace that was designed to calculate Bernoulli numbers using the hypothetical analytical engine. Note G is generally agreed to be the first algorithm specifically for a computer, [1] [2] [3] [4] and Lovelace is considered as the first computer programmer as a result. [5] [6] [7] [8] The algorithm was the last note in a series labelled A to G, which she employed as visual aids to accompany her English translation of Luigi Menabrea's 1842 French transcription of Charles Babbage's lecture on the analytical engine at the University of Turin, "Notions sur la machine analytique de Charles Babbage" ("Elements of Charles Babbage’s Analytical Machine"). [7] [9] Lovelace's Note G was never tested, as the engine was never built. Her notes, along with her translation, were published in 1843. [6] [7]

Contents

In the modern era, thanks to more readily available computing equipment and programming resources, Lovelace's algorithm has since been tested, after being "translated" into modern programming languages. These tests have independently concluded that there was a bug in the script, due to a minor typographical error, rendering the algorithm in its original state unusable. [10] [11]

Origin

Ada Lovelace Ada Lovelace portrait.jpg
Ada Lovelace

In 1840, Charles Babbage was invited to give a seminar in Turin on his analytical engine, [12] the only public explanation he ever gave on the engine. [13] During Babbage's lecture, mathematician Luigi Menabrea wrote an account of the engine in French. [12] A friend of Babbage's, Charles Wheatstone, suggested that in order to contribute, Lovelace should translate Menabrea's account. [12] [14] Babbage suggested that she augment the account with appendices, which she compiled at the end of her translation as a series of seven "notes" labelled A-G. Her translation was published in August 1843, [12] in Taylor's Scientific Memoirs, [14] [15] wherein Lovelace's name was signed "A.A.L". [12] [lower-alpha 2] In these notes, Lovelace described the capabilities of Babbage's analytical engine if it were to be used for computing, laying out a more ambitious plan for the engine than even Babbage himself had. [3] [15] [16]

Lovelace's notes for the article were three times longer than the article itself. [17] In the first notes, she explores beyond the numerical ambitions that Babbage had for the machine, and suggests the machine could take advantage of computation in order to deal with the realms of music, graphics, [18] and language. [8] [19] [20]

Again, it might act upon other things besides number, were objects found whose mutual fundamental relations could be expressed by those of the abstract science of operations, and which should be also susceptible of adaptations to the action of the operating notation and mechanism of the engine. Supposing, for instance, that the fundamental relations of pitched sounds in the science of harmony and of musical composition were susceptible of such expression and adaptations, the engine might compose elaborate and scientific pieces of music of any degree of complexity or extent.

Ada Lovelace, Notes upon the memoir "Sketch of The Analytical Engine Invented by Charles Babbage" by the translator Ada Augusta, Countess of Lovelace, Note A

She explains to readers how the analytical engine was separate from Babbage's earlier difference engine, [21] and likens its function to the Jacquard machine, [22] in that it used binary punch cards to denote machine language. In note C, this point is furthered by the fact that simultaneous and iterated actions can be made by the machine, ensuring that any card or collection of cards can be used several times in the solution of a single problem, [20] essentially anticipating modern methods of control flow and looping. [17] [23] These ideas were brought to a head in the final note, G, where Lovelace sought to demonstrate an example of computation.

Note G only made use of only the four arithmetical operations: addition, subtraction, multiplication and division, the implementation of Babbage's vision:

Under the impossibility of my here explaining the process through which this end is attained, we must limit ourselves to admitting that the first four operations of arithmetic, that is addition, subtraction, multiplication and division, can be performed in a direct manner through the intervention of the machine. This granted, the machine is thence capable of performing every species of numerical calculation, for all such calculations ultimately resolve themselves into the four operations we have just named.

Charles Babbage, "Sketch of The Analytical Engine Invented by Charles Babbage"

It also uses Babbage's idea of storing information in columns of discs, each denoted by (for variable) and a subscript number denoting which column is being referred to.

Function

Lovelace used a recursive equation to calculate Bernoulli numbers, [12] wherein she used the previous values in an equation to generate the next one. her method ran thus: [24]

where is a binomial coefficient,

.

Bernoulli numbers can be calculated in many ways, but Lovelace deliberately chose an elaborate method in order to demonstrate the power of the engine. In Note G, she states: "We will terminate these Notes by following up in detail the steps through which the engine could compute the Numbers of Bernoulli, this being (in the form in which we shall deduce it) a rather complicated example of its powers." [20] The particular algorithm used by Lovelace in Note G generates the eighth Bernoulli number (labelled as , as she started with .) [24]

Notation

The table of the algorithm organises each command in order. Each command denotes one operation being made on two terms. The second column states only the operator being used. Variables are notated as "", [lower-alpha 3] where the superscript before it represents the amount of different values the variable has been assigned to, and the subscript after it represents the ordinal assignment of the variable, that is which variable it is. (For example, refers to the second assignment of variable number 4. Any variables hitherto undefined have a superscript of 0.) The variables are numbered starting from . The third column tells the computer exactly what command is taking place, (For example, on line 1, the command performed is "" - the first iteration of variable 2 is multiplied by the first iteration of variable 3.) and only incorporates one operation between two terms per line. Column 4 - "Variables receiving results" takes note of where the result of the operation in column 3 should be stored. In this way, any variables in this column have their superscript number incremented by one each time. (e.g. on line 1, the result of is assigned to variables , , and .)

Column 5 states whether either of the variables used in the operation of the command has been changed. Enclosed in curly braces, two rows per command put the original variable on the left side of an equals sign, and the new variable on the other side - that is, if the variable has been changed, its superscript is incremented by one, and if not, it remains the same. (e.g. line three assigns the result of to the second iteration of the variable , and the fifth column reflects this by noting;

has changed, but hasn't.

In column 6, "Statement of Results", the result assigned to the variable in column 4 is shown in its exact value based on the values of the two terms previously assigned. (e.g. on line 1 - - was set at the beginning to be , and was set to be the variable . Therefore, , in mathematical notation.) This column is ostensibly not computed by the engine, and appears to be more to aid clarity and the reader's ability to follow the steps of the program. (For example, line 5 has a fraction being divided by two, which is notated as it being multiplied by a half, probably for coherence and the typographical complexity of a nested fraction.) It also makes use of separate variable notation outside of the program, the and variables, which are multiplied successively to find the final value, , thus: [10]

Beyond this, each successive column shows the values of a given variable over time. Each time a variable either changes, or has its value become relevant by token of its presence as one of the terms in the current command, its value is stated or restated in its respective column. Otherwise, it is marked with an ellipsis to denote its irrelevancy. This presumably mimics the computer's need for only relevant information, thereby tracking the value of a variable as the program parses. [10]

Method

The program sought to calculate what is known by modern convention as the eighth Bernoulli number, listed as , as Lovelace begins counting from . [24]

Error

In operation 4, the division supposedly taking place is "", to be stored in variable . However, the "Statement of results" says that the division should be:

As a matter of fact, the division is the wrong way round; is the second iteration of , as can be seen in operation 2. Likewise, is the second iteration of , as can be seen in operation 3. Thus, operation 4 should not be , but rather . This bug means that if the engine were ever to run this algorithm in this state, it would fail to generate Bernoulli numbers correctly, and would find its final goal value (the eighth Bernoulli number, ) to be .

Modern implementations

Lovelace's program can be implemented in a modern programming language, though due to the above stated error, if transcribed exactly it would return an incorrect final value for . The original program generalised in pseudocode follows as thus:

V[1] = 1 V[2] = 2 V[3] = n (n = 4 in Lovelace's program.)  V[4] = V[4] - V[1] V[5] = V[5] + V[1] V[11] = V[5] / V[4] V[11] = V[11] / V[2] V[13] = V[13] - V[11] V[10] = V[3] - V[1] V[7] = V[2] + V[7] V[11] = V[6] / V[7] V[12] = V[21] * V[11] V[13] = V[12] + V[13] V[10] = V[10] - V[1] V[6] = V[6] - V[1] V[7]= V[1] + V[7] //Finish Later 

The implementation in pseudocode highlights the fact that computer languages define variables on a stack, which obviates the need for tracking and specifying the current iteration of a variable. In addition, Lovelace's program only allowed for variables to be defined by performing addition, subtraction, multiplication or division on two terms that were previously defined variables. Modern syntax would be capable of performing each calculation more concisely. This restriction becomes apparent in a few places, for example on command 6 (). Here Lovelace defines a hitherto undefined variable () by itself, thereby assuming that all undefined variables are automatically equal to 0, where most modern programming languages would return an error or list the variable as null. What she intended was "", but had constrained herself to only using variables as terms. Likewise, in command 8 (), the strict notation of two-term arithmetic becomes cumbersome, as in order to define as 2, Lovelace assigns its value (0) to itself plus (2). It is due to this restrictive notation that is defined thus.

Notes

  1. Fully titled "Diagram for the computation by the Engine of the Numbers of Bernoulli", but is synecdochally known by "Note G"
  2. In the memoir, her initials were misprinted as "A. L. L." [14]
  3. These variables technically refer to columns of discs, at Babbage's suggestion that that is how they ought to be notated. [20]

Related Research Articles

<span class="mw-page-title-main">Ada Lovelace</span> English mathematician (1815–1852)

Augusta Ada King, Countess of Lovelace was an English mathematician and writer, chiefly known for her work on Charles Babbage's proposed mechanical general-purpose computer, the Analytical Engine. She was the first to recognise that the machine had applications beyond pure calculation.

<span class="mw-page-title-main">Analytical engine</span> Proposed mechanical general-purpose computer

The analytical engine was a proposed mechanical general-purpose computer designed by English mathematician and computer pioneer Charles Babbage. It was first described in 1837 as the successor to Babbage's difference engine, which was a design for a simpler mechanical calculator.

<span class="mw-page-title-main">Binary search algorithm</span> Search algorithm finding the position of a target value within a sorted array

In computer science, binary search, also known as half-interval search, logarithmic search, or binary chop, is a search algorithm that finds the position of a target value within a sorted array. Binary search compares the target value to the middle element of the array. If they are not equal, the half in which the target cannot lie is eliminated and the search continues on the remaining half, again taking the middle element to compare to the target value, and repeating this until the target value is found. If the search ends with the remaining half being empty, the target is not in the array.

In mathematics, the Bernoulli numbersBn are a sequence of rational numbers which occur frequently in analysis. The Bernoulli numbers appear in the Taylor series expansions of the tangent and hyperbolic tangent functions, in Faulhaber's formula for the sum of m-th powers of the first n positive integers, in the Euler–Maclaurin formula, and in expressions for certain values of the Riemann zeta function.

<span class="mw-page-title-main">Charles Babbage</span> English mathematician, philosopher, and engineer (1791–1871)

Charles Babbage was an English polymath. A mathematician, philosopher, inventor and mechanical engineer, Babbage originated the concept of a digital programmable computer.

<span class="mw-page-title-main">Difference engine</span> Automatic mechanical calculator designed to tabulate polynomial functions

A difference engine is an automatic mechanical calculator designed to tabulate polynomial functions. It was designed in the 1820s, and was first created by Charles Babbage. The name difference engine is derived from the method of divided differences, a way to interpolate or tabulate functions by using a small set of polynomial co-efficients. Some of the most common mathematical functions used in engineering, science and navigation are built from logarithmic and trigonometric functions, which can be approximated by polynomials, so a difference engine can compute many useful tables.

<span class="mw-page-title-main">Principal component analysis</span> Method of data analysis

Principal component analysis (PCA) is a popular technique for analyzing large datasets containing a high number of dimensions/features per observation, increasing the interpretability of data while preserving the maximum amount of information, and enabling the visualization of multidimensional data. Formally, PCA is a statistical technique for reducing the dimensionality of a dataset. This is accomplished by linearly transforming the data into a new coordinate system where the variation in the data can be described with fewer dimensions than the initial data. Many studies use the first two principal components in order to plot the data in two dimensions and to visually identify clusters of closely related data points. Principal component analysis has applications in many fields such as population genetics, microbiome studies, and atmospheric science.

<span class="mw-page-title-main">Bernoulli process</span> Random process of binary (boolean) random variables

In probability and statistics, a Bernoulli process is a finite or infinite sequence of binary random variables, so it is a discrete-time stochastic process that takes only two values, canonically 0 and 1. The component Bernoulli variablesXi are identically distributed and independent. Prosaically, a Bernoulli process is a repeated coin flipping, possibly with an unfair coin. Every variable Xi in the sequence is associated with a Bernoulli trial or experiment. They all have the same Bernoulli distribution. Much of what can be said about the Bernoulli process can also be generalized to more than two outcomes ; this generalization is known as the Bernoulli scheme.

<span class="mw-page-title-main">System of linear equations</span> Several equations of degree 1 to be solved simultaneously

In mathematics, a system of linear equations is a collection of one or more linear equations involving the same variables. For example,

In mathematical optimization, Dantzig's simplex algorithm is a popular algorithm for linear programming.

An integer programming problem is a mathematical optimization or feasibility program in which some or all of the variables are restricted to be integers. In many settings the term refers to integer linear programming (ILP), in which the objective function and the constraints are linear.

<span class="mw-page-title-main">1843 in science</span> Overview of the events of 1843 in science

The year 1843 in science and technology involved some significant events, listed below.

<span class="mw-page-title-main">Inverse kinematics</span> Computing joint values of a kinematic chain from a known end position

In computer animation and robotics, inverse kinematics is the mathematical process of calculating the variable joint parameters needed to place the end of a kinematic chain, such as a robot manipulator or animation character's skeleton, in a given position and orientation relative to the start of the chain. Given joint parameters, the position and orientation of the chain's end, e.g. the hand of the character or robot, can typically be calculated directly using multiple applications of trigonometric formulas, a process known as forward kinematics. However, the reverse operation is, in general, much more challenging.

Data-flow analysis is a technique for gathering information about the possible set of values calculated at various points in a computer program. A program's control-flow graph (CFG) is used to determine those parts of a program to which a particular value assigned to a variable might propagate. The information gathered is often used by compilers when optimizing a program. A canonical example of a data-flow analysis is reaching definitions.

Partial least squares regression is a statistical method that bears some relation to principal components regression; instead of finding hyperplanes of maximum variance between the response and independent variables, it finds a linear regression model by projecting the predicted variables and the observable variables to a new space. Because both the X and Y data are projected to new spaces, the PLS family of methods are known as bilinear factor models. Partial least squares discriminant analysis (PLS-DA) is a variant used when the Y is categorical.

<span class="mw-page-title-main">History of computer science</span> Aspect of history

The history of computer science began long before the modern discipline of computer science, usually appearing in forms like mathematics or physics. Developments in previous centuries alluded to the discipline that we now know as computer science. This progression, from mechanical inventions and mathematical theories towards modern computer concepts and machines, led to the development of a major academic field, massive technological advancement across the Western world, and the basis of a massive worldwide trade and culture.

Karmarkar's algorithm is an algorithm introduced by Narendra Karmarkar in 1984 for solving linear programming problems. It was the first reasonably efficient algorithm that solves these problems in polynomial time. The ellipsoid method is also polynomial time but proved to be inefficient in practice.

Numerical linear algebra, sometimes called applied linear algebra, is the study of how matrix operations can be used to create computer algorithms which efficiently and accurately provide approximate answers to questions in continuous mathematics. It is a subfield of numerical analysis, and a type of linear algebra. Computers use floating-point arithmetic and cannot exactly represent irrational data, so when a computer algorithm is applied to a matrix of data, it can sometimes increase the difference between a number stored in the computer and the true number that it is an approximation of. Numerical linear algebra uses properties of vectors and matrices to develop computer algorithms that minimize the error introduced by the computer, and is also concerned with ensuring that the algorithm is as efficient as possible.

Quasi-Newton methods are methods used to either find zeroes or local maxima and minima of functions, as an alternative to Newton's method. They can be used if the Jacobian or Hessian is unavailable or is too expensive to compute at every iteration. The "full" Newton's method requires the Jacobian in order to search for zeros, or the Hessian for finding extrema. Some iterative methods that reduce to Newton's method, such as SLSQP, may be considered quasi-Newtonian.

Events from the year 1843 in the United Kingdom.

References

  1. Demming, Anna. "Ada Lovelace". New Scientist. Retrieved 2022-06-01.
  2. Krysa, Joasia. Ada Lovelace - There Never was a Note G.
  3. 1 2 "Ada Lovelace, the First Tech Visionary". The New Yorker. 2013-10-15. Retrieved 2022-06-02.
  4. Hertz 2009, p. 59.
  5. "Celebrating Ada Lovelace: the 'world's first programmer' - Short Sharp Science - New Scientist". 2009-03-27. Archived from the original on 2009-03-27. Retrieved 2022-06-01.
  6. 1 2 "Ada Lovelace | Babbage Engine | Computer History Museum". www.computerhistory.org. Retrieved 2022-06-01.
  7. 1 2 3 "Ada Lovelace | Biography, Computer, & Facts". Encyclopedia Britannica. Retrieved 2022-06-01.
  8. 1 2 "Ada Lovelace: The First Computer Programmer". Mental Floss. 2015-10-13. Retrieved 2022-06-02.
  9. Stein 1984, p. 44.
  10. 1 2 3 "What Did Ada Lovelace's Program Actually Do?". twobithistory.org. Retrieved 2022-06-01.
  11. "Ada Lovelace and the Story of Note G". NYC Media Lab. Retrieved 2022-06-01.
  12. 1 2 3 4 5 6 "How Ada Lovelace's notes on the Analytical Engine created the first computer program". BBC Science Focus Magazine. Retrieved 2022-06-01.
  13. "Charles Babbage left a computer program in Turin in 1840. Here it is". Wired. ISSN   1059-1028 . Retrieved 2022-06-01.
  14. 1 2 3 "Mathematical Treasure: Ada Lovelace's Notes on the Analytic Engine | Mathematical Association of America". www.maa.org. Retrieved 2022-06-02.
  15. 1 2 Lovelace & Babbage and the Creation of the 1843 ‘Notes’
  16. Stein 1984, p. 46.
  17. 1 2 "Ada Lovelace". Biography. April 2, 2014. Retrieved 2022-06-02.
  18. Toole, Betty Alexandra (2004-09-23). "Byron, (Augusta) Ada [married name (Augusta) Ada King, countess of Lovelace] (1815–1852), mathematician and computer pioneer" . Oxford Dictionary of National Biography . Vol. 1 (online ed.). Oxford University Press. doi:10.1093/ref:odnb/37253. ISBN   978-0-19-861412-8.(Subscription or UK public library membership required.)
  19. "Ada Lovelace - Biography, Facts and Pictures" . Retrieved 2022-06-02.
  20. 1 2 3 4 "Sketch of The Analytical Engine". www.fourmilab.ch. Retrieved 2022-06-02.
  21. Woolley 1999.
  22. "Celebrating Ada Lovelace". MIT Press. 2016-10-11. Retrieved 2022-06-02.
  23. "Ada Lovelace". History. 2021-02-26. Retrieved 2022-06-02.
  24. 1 2 3 "Ada Lovelace's Note G | Project Lovelace". projectlovelace.net. Retrieved 2022-06-01.

Sources