For the example used with the Python (sage) code:
mwh@coyote2:[~]:
$ ----> irroots2
What is the degree of your polynomial? 2
coefficient of x^2: 1
coefficient of x^1: 0
constant term: -5
endpoints of interval to be searched: 1 4
Enter the LEAST number of significant figures required: 4
x | | f(x)
---------------------------------------------------
0 | 1 0 -5
1 1 1 -4
2 1 2 -1
3 1 3 4
There is a zero between 2 and 3.
x = 3 | | f(3)
---------------------------------------------------
1 3 4
x = 3 | f'(3)
---------------------------------------------------
| 1 6
row2.at(1) = 6 = dy = 6
Next X =
x - f(x)/f'(x) = 3 - [f(3)/f'(3)]
= 3 - (4/6) = 2.33
CHOOSE X: 2.33
With precision 1, x = nextX = 2.3 = 2.3
The zero is approximately 2.3
Is this approximation satisfactory <Y/N> ? : n
Our two consecutive integers have been found.
Previous value of x = 3.0 nextX = 2.3
We've updated x = nextX = x - f(x)/f'(x).
current value of x = 2.3
Since dx = 1.0 and x2 = 4.0 we're done
applying the Location Principle, and now proceed to
apply Newton's method using repeated synthetic division.
Press ENTER [ <-----||| ] to continue.
x = 2.3 | | f(2.3)
---------------------------------------------------
1.000 2.300 0.290
x = 2.3 | f'(2.3)
---------------------------------------------------
| 1.000 4.600
row2.at(1) = 4.600 = dy = 4.600
Next X =
x - f(x)/f'(x) = 2.3 - [f(2.3)/f'(2.3)]
= 2.3 - (0.290/4.600) = 2.23696
CHOOSE X: 2.2370
Approximate X: With precision (2^RSD) = (4), nextX = 2.2370
The zero is approximately 2.2370
Is this approximation satisfactory <Y/N> ? : n
x = 2.2370 | | f(2.2370)
---------------------------------------------------
1.00000000 2.23700000 0.00416900
x = 2.2370 | f'(2.2370)
---------------------------------------------------
| 1.00000000 4.47400000
row2.at(1) = 4.47400000 = dy = 4.47400000
Next X =
x - f(x)/f'(x) = 2.2370 - [f(2.2370)/f'(2.2370)]
= 2.2370 - (0.00416900/4.47400000) = 2.2360681717
CHOOSE X: 2.23606817
Approximate X: With precision (2^RSD-1) = (7), nextX = 2.2360682
The zero is approximately 2.2360682
Is this approximation satisfactory <Y/N> ? : n
This approximation is already good to 8 figures.
There were 3 repeated synthetic divisions.
Z E R O S:
There is a zero between 2 and 3.
Our efforts yield: x = 2.2360682
________________________________________________________
For f(x) = 2*x^3 - 6*x^2 + 6*x - 3 = 0
mwh@coyote2:[~]:
$ ----> irroots2
What is the degree of your polynomial? 3
coefficient of x^3: 2
coefficient of x^2: -6
coefficient of x^1: 6
constant term: -3
endpoints of interval to be searched: 0 3
Enter the LEAST number of significant figures required: 7
x | | f(x)
---------------------------------------------------
0 | 2 -6 6 -3
0 2 -6 6 -3
1 2 -4 2 -1
2 2 -2 2 1
There is a zero between 1 and 2.
x = 2 | | f(2)
---------------------------------------------------
2 -2 2 1
x = 2 | f'(2)
---------------------------------------------------
| 2 2 6
row2.at(1) = 6 = dy = 6
Next X =
x - f(x)/f'(x) = 2 - [f(2)/f'(2)]
= 2 - (1/6) = 1.83
CHOOSE X: 1.83
With precision 1, x = nextX = 1.8 = 1.8
The zero is approximately 1.8
Is this approximation satisfactory <Y/N> ? : n
Our two consecutive integers have been found.
Previous value of x = 2.0 nextX = 1.8
We've updated x = nextX = x - f(x)/f'(x).
current value of x = 1.8
Since dx = 1.0 and x2 = 3.0 we're done
applying the Location Principle, and now proceed to
apply Newton's method using repeated synthetic division.
Press ENTER [ <-----||| ] to continue.
x = 1.8 | | f(1.8 )
---------------------------------------------------
2.000 -2.400 1.680 0.024
x = 1.8 | f'(1.8 )
---------------------------------------------------
| 2.000 1.200 3.840
row2.at(1) = 3.840 = dy = 3.840
Next X =
x - f(x)/f'(x) = 1.8 - [f(1.8 )/f'(1.8 )]
= 1.8 - (0.024/3.840) = 1.79375
CHOOSE X: 1.7938
Approximate X: With precision (2^RSD) = (4), nextX = 1.7938
The zero is approximately 1.7938
Is this approximation satisfactory <Y/N> ? : n
x = 1.7938 | | f(1.7938 )
---------------------------------------------------
2.00000000 -2.41240000 1.67263690 0.00037600
x = 1.7938 | f'(1.7938 )
---------------------------------------------------
| 2.00000000 1.17520000 3.78071060
row2.at(1) = 3.78071060 = dy = 3.78071064
Next X =
x - f(x)/f'(x) = 1.7938 - [f(1.7938 )/f'(1.7938 )]
= 1.7938 - (0.00037604/3.78071064) = 1.7937005384
CHOOSE X: 1.79370054
Approximate X: With precision (2^RSD-1) = (7), nextX = 1.7937005
The zero is approximately 1.7937005
Is this approximation satisfactory <Y/N> ? : n
This approximation is already good to 8 figures.
There were 3 repeated synthetic divisions.
Z E R O S:
There is a zero between 1 and 2.
Our efforts yield: x = 1.7937005
____________________________________________
Now I look forward to spending a few days with pencil, scratch paper, and having the code as a back-up so I don't become too irritable with the arithmetic operations. The goal is to be able to this by hand with maybe just a basic calculator or with pencil (or with one of those toys Holden found that kids use for doodling ... that too would work, drawing tables then erasing them. just using them for the values f(x) and f'(x).
I ought to mention that this method works only if neither the first or second derivative is = 0. That is, the slope cannot be a horizontal line.
Also, including rational numbers is not at all related to this, and I only added that aspect "for a cheap thrill".
Messing around with say 16 figures of precision gave a fraction like this:
-[450*2^(218/245) * 3^(4/35) * 5^(9/49) * 7^(148/245)] / 343
Believe it or not, this is -12.000304
This has nothing to do with anything, really, but I find it interestingly weird, this different representations for the same "number". For the kind of precision we want (4 figures), the rational numbers remain "tame". When I increase the precision unnecessarily, the fractions get "weirder."
Breaking it down: 2^(216/245) = 1.84245917558579
2^(216/245) * 450 = 829.106629013606
3^(4/35) = 1.13377830746771, so [2^(216/245) * 450 * 3^(4/35)] = 940.023110553305
5^(9/49) = 1.34394732031821, so [2^(216/245) * 450 * 3^(4/35) * 5^(9/49)] = 1263.34154046530
7^(148/245) = 3.23972542174317, so [2^(216/245) * 450 * 3^(4/35) * 5^(9/49) * 7^(148/245)
= 4092.87970498962
Lastly, inserting the negative sign and dividing by 343: -4092.87970498962/343 = -11.9325938920980
and yet, (-450*2**(218/245)*3**(4/35)*5**(9/49)*7**(148/245)/343).n() =-12.0003040000000
0.0677101080000000 difference is considerable round-off error.
The Lesson? When programming machines, stick to decimals. When working by hand, suit yourself working with fractions until they become a burden, then switch to decimal format. Do not be ashamed to check work with calculator as arithmetic errors are quite common for us. No amount of study will make arithmetic any "easier." That's why I call it "work." So I am usually always "working on something," but not somebody's "code-monkey" to be handed a "to do list."
The world may be uninterested in this old stuff mixed with new stuff, but the feeling is mutual, for I have very little interest in what the masses seem to find so "thrilling".
I don't push this stuff on anyone, and I strongly suspect the math has made me even a little crazier than I would be otherwise. That is, I can become excited about gaining understanding of this material, just going with the flow, growing inwardly, but simultaneously reflecting on how rapidly each of us will vanish from this earth.