07-401/Andrei Litvin Poly Solution: Difference between revisions
No edit summary |
No edit summary |
||
(5 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
{{Begin Side Note|30%}} |
|||
<center><math>\sqrt[3]{7} - \sqrt[4]{\sqrt{5}\left/\sqrt[3]{\sqrt{2}+\sqrt[5]{7}}\right.}</math></center> |
|||
See the "Just for Fun" part of [[07-401/Homework Assignment 7]] |
|||
{{End Side Note}} |
|||
Here is what I have so far in terms of polynomials: |
Here is what I have so far in terms of polynomials: |
||
Line 46: | Line 51: | ||
::<math>100118652346710314482731150749632703657021113788752749525948078496866540654\backslash</math> |
::<math>100118652346710314482731150749632703657021113788752749525948078496866540654\backslash</math> |
||
:::<math>8665959513826347108430640406618155029520076750443339789185589187423680</math> |
:::<math>8665959513826347108430640406618155029520076750443339789185589187423680</math> |
||
(223 decimal digits) |
|||
==Program== |
|||
A zip file containing the program can be downloaded [http://www.bitrover.com/polysolve/polysolve_andrei_litvin2.zip here] (I hope this works .. if not send me an e-mail). |
|||
It does require [http://www.python.org/download/ Python] (I developed and tested it with version 2.5) and the file you probably want to edit is "test.py" (or you can also create your own program files if you wish). |
|||
It starts with a statement of the form "x = Poly()" which by default creates the polynomial "x". The object overloads +,-,* and ** (power),so that you can build your own fancy polynomials (e.g. "x**2 + 4*x + 1" or "(x + 256)*((x**34 + 1)**3) + 1). |
|||
After you have built one or more polynomials (the sample starts with simple ones, like "x - 7" and " x- 5), you have an array of functions that you can build new polynomials. These are: |
|||
* "solve_inverse(p)": |
|||
** if <math>p(a) = 0</math> then return q, such that <math>q({1 \over a}) = 0</math> |
|||
* "solve_sqrt(p, n)": |
|||
** if <math>p(a) = 0</math>, then return q, such that <math>q(\sqrt[n]{a}) = 0</math> |
|||
* "solve_sum(p1, p2)" |
|||
** if <math>p1(a) = 0</math> and <math>p2(a) = 0</math>, then return q, such that <math>q(a+b) = 0</math> |
|||
* "solve_diff(p1, p2)" |
|||
** if <math>p1(a) = 0</math> and <math>p2(a) = 0</math>, then return q, such that <math>q(a-b) = 0</math> |
|||
* "solve_prod(p1, p2)" |
|||
** if <math>p1(a) = 0</math> and <math>p2(a) = 0</math>, then return q, such that <math>q(a*b) = 0</math> |
|||
Now you are ready to do things like: |
|||
from poly import * # these imports are needed |
|||
from polysolve import * |
|||
x = Poly() # the most basic poly you can get |
|||
p1 = solve_sum(x**3 - 3, x**5 - 6) |
|||
p2 = solve_sum(x**2 - 2, x - 1) |
|||
p3 = solve_sum(p1, p2) |
|||
print p3 |
Latest revision as of 09:40, 28 March 2007
See the "Just for Fun" part of 07-401/Homework Assignment 7 |
Here is what I have so far in terms of polynomials:
Polynomial with root :
- (duh)
Polynomial with root :
- (duh as well)
Polynomial with root :
- (more interesting!)
Polynomial with root :
- (similar to the above)
Polynomial with root :
-
- (just invert the above .. quite the same as the above 2)
Polynomial with root :
-
- (ok .. this is ugly)
Polynomial with root :
- (very ugly .. especially considering you are not done yet and the next matrix to compute will be quite large)
This is how far I got so far. The program itself will do any polynomials just fine (I tweaked it a lot to get the final poly, so it may still have some bugs, however it works). The problem is working with such large numbers. The reducing part will multiply with 289 each time a is reduced, so we could potentially get coefficients of the order , which is very large indeed. On my computer, I get about 30% done, when it starts running out of memory and I had to stop. This is why the program just generates the matrices for the last part (and by the way, Maxima crashed when trying to load the matrix to invert, so I will have to find another program that will handle such large sets of data)
Comments by Dror. Great work! Your grade for the class is bounded below by 80; the exams and HW will determine which fraction of the other 20 you will get. To raise your lower bound to 85, you'll have to post the programs (either here, as text files, or elsewhere with a link from here) along with a brief manual page that will allow anybody else to run them. To raise your lower bound to 90, you'll also have to tell me, I don't care how, what is the second largest coefficient that occurs in the solution to the overall problem. The largest is
(223 decimal digits)
Program
A zip file containing the program can be downloaded here (I hope this works .. if not send me an e-mail).
It does require Python (I developed and tested it with version 2.5) and the file you probably want to edit is "test.py" (or you can also create your own program files if you wish).
It starts with a statement of the form "x = Poly()" which by default creates the polynomial "x". The object overloads +,-,* and ** (power),so that you can build your own fancy polynomials (e.g. "x**2 + 4*x + 1" or "(x + 256)*((x**34 + 1)**3) + 1).
After you have built one or more polynomials (the sample starts with simple ones, like "x - 7" and " x- 5), you have an array of functions that you can build new polynomials. These are:
- "solve_inverse(p)":
- if then return q, such that
- "solve_sqrt(p, n)":
- if , then return q, such that
- "solve_sum(p1, p2)"
- if and , then return q, such that
- "solve_diff(p1, p2)"
- if and , then return q, such that
- "solve_prod(p1, p2)"
- if and , then return q, such that
Now you are ready to do things like:
from poly import * # these imports are needed from polysolve import * x = Poly() # the most basic poly you can get p1 = solve_sum(x**3 - 3, x**5 - 6) p2 = solve_sum(x**2 - 2, x - 1) p3 = solve_sum(p1, p2) print p3