Correction: it should be 64 + 4/129, which comes out to 4099.969954,=20 still close enough. Kerry Kerry Wentworth wrote: > OK, here's some wild speculation. > > Assuming he'd want to live to collect the first royalty check, he=20 > probably wouldn't be doing a lot of floating point math. > Ada Lovelace (daughter of Lord Byron and Baroness Wentworth) no doubt=20 > knew that squares were the sum of successive odd numbers, i.e 4 =3D 1+3, = 9=20 > =3D 1+3+5, 16 =3D 1+3+5+7, with the number of odds added together equalin= g=20 > the square root. A fair approximation of a square root calculated in=20 > this manner would be the number of odds added + (current number - last=20 > perfect square) / next odd number. > For example, the (approximate) square root of 4100 would be 64 (square=20 > root of 4096, which is 1+3+5...+127) + 4 / 127. My calculator shows=20 > that to actually be the square root of 4100.032488, which is close enough= .. > So, by tracking the square root as you go instead of calculating it each= =20 > time can greatly speed up the calculations. With a little cleverness=20 > applied to scaling and rounding, I'm sure this is the method she would=20 > have used. > > Kerry > > > James Newton wrote: > =20 >> Lets say you needed to calculate the successive values of some function.= Not >> any specific value, but the values for successive integer inputs. E.g. n= ot >> f(x), but first f(0) then f(1), f(2), f(3) and so on. >> >> Charles Babbage's difference engine design used Newton's method of divid= ed >> differences to calculate 8th order polynomials via finite differences. I >> thought that this would allow him to effectively calculate just about an= y >> useful function with high enough precision to print a sellable table... = but >> perhaps not? >> >> I'm trying to figure out how he would have setup the difference engine f= or >> an "interesting" function and see if that method can be adapted to a PIC= or >> other small uC. >> >> Specifically, I wanted to calculate Yx^(-0.5) for fixed values of Y and = x=3D1 >> to whatever as x is incremented by 1 each calculation... For example, >> 1132x^(-.5), or 432x^(-.5) >> >> I tried in an excel spreadsheet, to just set up a series of columns, whe= re >> each cell in the column is calculated from the difference of the cell to= the >> left, and the cell one to the left and one down. But the values never ze= ro >> out as you add columns. The first cell in each column always has (an eve= r >> smaller) value, but they don't get small enough, quickly enough to make = it >> practical to calculate that by finite differences. >> >> That method seems to work for the data from e.g. 1322x^0.5, y =3D -0.001= 4x4 + >> 0.1987x3 - 11.134x2 + 394x + 1151.9 is a very close fit and so just 4 >> columns gives a good approximation. I could store 4 32 bit numbers in th= e >> PIC, and do a few subtractions at each step along the way, and have a re= ally >> good output. >> >> So I tried getting excel to approximate the function 1132x^(-.5) as a po= ly, >> but even with an order of 6, the poly is a poor fit. Excel won't do 8th >> order, but I doubt even that would have been good enough. >> >> Is it that there are certain functions which can not be practically >> approximated in this way? E.g. most polynomials are fine, but negative p= ower >> functions don't work well at all?=20 >> >> If so, did Babbage not plan on publishing a table of negative square roo= ts? >> And was that perhaps one of the things that drove him to design the >> analytical engine? >> >> Or is there some neat mathematical manipulation of "to the power of nega= tive >> one half" that makes it easy to fit to a polynomial? >> >> -- >> James Newton >> 1-970-462-7764=20 >> >> P.S. Hi Scott! >> >> =20 >> =20 > > > > =20 --=20 Internal Virus Database is out-of-date. Checked by AVG Anti-Virus. Version: 7.0.289 / Virus Database: 267.11.13 - Release Date: 10/6/05 --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .