Math Tools

Nothing fancy here, just some quick code I wrote to get the job done. These programs are short and sweet, as it were.

Polynomial cruncher - a polynomial cruncher program - adds, subtracts, multiplies, and divides polynomials of degrees up to 8. Try it out; it’s pretty useful.
Completing the square - just a quick way to let the computer complete the square on a quadratic instead of using paper and pencil. For example, to solve 2x2 + 8x + 4 = 0 for x, completing the square on it yields the following: 2x2 + 8x + 4 = 2(x2 + 4x) + 4 = 2(x2 + 4x + 4 - 4) + 4 = 2(x2 + 4x + 4) - 8 + 4 = 2(x + 2)2 - 4. This can be then solved for x, so that 2(x + 2) is seen to be the square root of 4, x + 2 = +- 2 / 2, and x = -2 + 1 = -1 or -2 - 1 = -3. So, to fulfill the equation 2x2 + 8x + 4 = 0, x must be either -3 or -1. Of course, you could solve for x with the quadratic formula x=(-b +- sqrt(b2 - 4ac))/(2a), and get the same answer; this is an alternate way to do that, and it is actually what the quadratic formula is derived from.
Synthetic Division - this program just speeds up the process of writing synthetic division on paper. Type in the coefficients of x (in the dividend) one by one pressing enter after each. If the polynomial is 3x3 + 4x2 - 7x + 2, type 3 (enter) 4 (enter) -7 (enter) 2 (enter), and press enter once more. Then type c in the divisor (x-c). If you are dividing by x - 2/3, type 2/3 (enter); the program will change the fraction to the decimal .6666667 automatically and display the results of the division. Press any key to try a different value for c. When you are done, press enter without entering anything for c and the program will exit. The output of the program for that problem would look something like:
Synthetic Division
.6666667|      3       4      -7       2
        |      0       2       4      -2
        +--------------------------------
               3       6      -3       0

3x^3 + 4x^2 - 7x + 2 =
(x - .666666666666667)(3x^2 + 6x - 3)
Synthetic division is a shortcut to long division on polynomials where the divisor is of the form x-c. For example, to do my example problem,
3x3 + 4x2 - 7x + 2=(x - 2/3)(3x2 + 6x - 3)
x - 2/3
by synthetic division, you would write:
2/334-72
024-2
36-30
Each green number is the sum of the two numbers above it. The numbers on the middle row are the product of the last green number and the blue number, ie, 2/3 times 3 is 2, 2/3 times 6 is 4, etc. (The first number is always 0.)
QwikGrapher - this program takes ordered pairs and draws a connected-point scatter graph from them. It’s really pretty elementary. Type the ordered pairs into Notepad, putting the X and Y values into two vertical columns. You can separate them with spaces, tabs, or a comma, it doesn't matter. Save it as a regular text file (the type really doesn’t matter) then in Windows Explorer drag the file you just created onto the Qwikgrph icon. It should run fine. If not, then use a Dos prompt window, CD to the folder that QwikGrapher is in, and type “qwikgrph filename” where filename is the name of the file you created with Notepad, including the path.
Site hosted by Angelfire.com: Build your free website today!