FILE ATTACHED: rsd.py
rsd.py is a python file (homegrown created specifically with my own intentions in mind, my own "agenda") I import while within the sage shell
-----------------------------------------------------------------------------------------
from rsd import *
There is a special version of this Repeated Synthetic Division function called rsd_Rational. The code is to assist me with my hand-written pencil/paper work. I spent three weeks building code to assist me with just one section of exercises (8.9) APPROXIMATING ZEROS from Modern Introductory Analysis, circa 1965.
The code was in
C++, and it turned out very well with many learning experiences along the way. However, since I do not require a full-fledged program, and want perform much of the beginning estimates in a more spontaneous, free-flowing, electro-digital-technology independent manner, apply a more rational [potentially]
in-my-head, but certainly with pencil and paper, approach.
I am studying methods which would be extremely useful in some situation when no computers or even calculators (YIKES!) were at hand. In such scenarios, pencil and paper techniques become Mind Treasure … if you can track down pen and paper! This method would literally work with a stone in the sand.
Now, since I am comprising a step by step solution key to the future, I wish to check my arithmetic carefully. It would be stress-inducing and make me horribly irritable. So, I invested my mental energies in building code to assist me, to make the process of serving my Muse, Mary Dolciani, more fulfilling and perhaps leaving behind useful Mathematical Assistance along the way.
The thing is, while I will use the C++ code, for aiding me in arithmetic involved in the By Hand Techniques, this Python version for Sage is more direct and flexible on the fly run from a sage shell.
I have another version for SymPy but the Rational version has not been built yet.
I devote the Rational versions to Pythagoras, and I shall see at what point dealing with Rational Fractions becomes a hinderence. I already know the drudgery of squaring decimal representations. I know we do not think of such things often since we usually have at least a calculator for arithmetic. Schopenhauer was so on point with the comments about the drudgery of arithmetic. I sense he would respect and honor my decision to expend efforts in building mathematical assistance in order to reduce the Tedium and Mechanical mental operations.
I prefer to explore patterns and other things. The exercises in the book provide the opportunity for me to investigate different things, such as the structure of our different "number systems" and why rounding, precision and numerical computing gets so technical on the level of the hardware and the programming, making approximations of abstract concepts. I will be on the look out to see if any of the exercises expose a flaw in my code. The back and forth would make the code more robust. The end goal is always to preserve the TECHNIQUE, not so much simply provide an answer or result.
Once again, I have used programming to write command line software which aims to preserve a hand-written technique, serving as an assistant, or just showing the process of how to do it just by running some example through it.
There is harmony in this irony.
---------------------------------------------
Post Scriptum
________________________
While this method (by hand) can be used for polynomials of high degree, you can also get to the root (pun intended) of the Nightmares of Pythagoras by feeding the "technique" [mental machine discovered/invented/preserved] f(x) = x^2 - 2 = 0 to find the square root of 2 or 5 or 17 ... whatever.
The Method preserved uses something called "repeated" synthetic division. The repeated part is important, since the coefficients for the first row become the polynomial for the second row.
I would like to upload an example or two to show how my little snippets of code (the core of the C++ program) written in Python can display how I will be working it out by hand. This is the beauty of this. I went through great trouble to be sure I would be fascinated by the arithmetic operations, rather than perturbed by them. I will have created a mathematical assistant, so to speak.
Now, rather than allow myself to be intimidated or even defeated by the exercises, as were the students who struggled through those challenging textbooks (instructors were advised to assign 1 or 2 out of 12 and the last two (13, 14), whereas I will be solving each in detail with much scratch paper and hand-rolled (custom designed = homemade by the meat in my own head, no $$$) software.
I approach the exercises with confidence, but it was my humility which urged me to build such stress-reducing mind tools in preparation for the inevitible "drudgery of arithmetic.". I do what I can to find some kind of Mojo.
_____________________________________________________
I felt obliged to show one quick example:
f(x) = x^2 - 5 = 0 would be input in sage shell (or Python with the imports) as:
from rsd import *
P = [-5, 0, 1]
explanation: coefficient of x^2 is 1, coefficient of x^1 is 0, and the constant term is -5.
x^2 = 5 ----> x = sqrt(5)
So, all you do in a sage shell to run this code is create P and feed it to rsd along with other parameters: degree of polynomial (2), value of X (?), and LEVEL OF PRECISION (given as the number of significant digits required in results.)
OK, so, say you want to start off with 4 figures:
rsd(P, 2, ?, 4)
The ? will always be changing.
I like this down and dirty Python way because it forces me to feed it an initial approximation. I like my own in-the-head technique for that step, but I had to build it into the C++ program from the ground up [full-fledged].
These Sage versions, on the other hand focus very well on the important algorithm itself. By the way, I used the instructions in the 1965 text for this method as inspiration for the main operations in the code. It has been the fire of my heartbeat, and I am now relishing the documentation of my interaction with this material, rather than looking to drown drunk in the ocean.
WARNING: the combination of symbolic mathematics and digital computing may increase your desire to sustain your animal body and thus submit to most of the demands made by biological necessity. Do not let that discourage you from your quest to find solace in arithmetic difficulties. Death is the norm. It will come when least expected, I suppose.
Eventually, like I said, I would return to this site to "copy and paste" some output which will simultaneously show the work.
The function is evaluated at x |------> the last element in the first row is f(x)
Then, without calculus (with brute force arithmetic you need paper for [and could program software to do] --- the most tedious part of the process I hope to make more interesting by exploring which steps might be "more elegant in rational form" where one long division at the end is preferable to all the nasty decimal multiplications, additions and subtractions along the way when using decimal representation from the start.
The machines have no choice, but I did find a way to make a version I will run along with the pure decimal version which will in fact display much of the work in rational form, which is the form I am most comfortable with when at liberty to take up a pencil for "reckoning."
you would call it with:
rsd(P, 2, 2, 4) where we chose 2.
Why 2 for sqrt(5)?
This is the part I like to do in my head because it's kind of fun to think it through.
4 is less than 5
sqrt(4) = 2 < sqrt(5) < sqrt(9) = 3 so the root is between 2 and 3. That is,
2 < sqrt(5) < 3.
(I pause and post for a smoke?)