Example #1
0
"""
A convenience class that uses Sympy to allow easier command line input.
Asks user for a polynomial and for the number of desired terms. Poly can
be input as, for example, (x^3-y)*(2x+4). Sympy takes care of the simplification and the script transforms it into a mypoly object and calls the solutionList function.
"""
if len(sys.argv)==3:
    s = sys.argv[1]
    n = int(sys.argv[2])
else:
    s = raw_input("Enter a polynomial in x and y --> ") 
    n = input("Enter the number of desired terms --> ")
s = s.replace('^','**')
p = poly(eval(s),x,y,domain='CC')
"""
d = {item[0][1]:puiseux({item[0][0]:complex(item[1])}) for item in p.terms()}
for item in p.terms():
    if item[0][1] in d.keys():
        d[item[0][1]]+=puiseux({item[0][0]:complex(item[1])})
    else: d[item[0][1]] = puiseux({item[0][0]:complex(item[1])})
m = mypoly(d)
"""
d = {item[0][1]:0 for item in p.terms()}
for item in p.terms():
    d[item[0][1]]+=puiseux({item[0][0]:complex(item[1])})
m = mypoly(d)
print m
for sol in solutionList(m,n,True):
    print
    print sol.LT()
    print sol
Example #2
0
from puiseuxPoly import puiseux
from mypoly import mypoly
from expandParallel import solutionList
from fractions import Fraction as fr
import cPickle
if __name__=='__main__':
    p = mypoly({0:puiseux({5:1}),1:puiseux({fr(7,2):1}),2:puiseux({1:1}),3:puiseux({-1:1}),5:puiseux({fr(-1,2):1}),6:puiseux({fr(1,2):1}),7:puiseux({fr(10,3):1}),8:puiseux({fr(5,2):1})})
    p = mypoly({0:puiseux({0:(0.602188930612+0.991723585529j)}),4:puiseux({3:0.991343060948+0.811367139699j})})
    p = cPickle.load(open("failurePoly.p","rb"))
    n=4
    sols = solutionList(p,n,True)
    for sol in sols:
        expList = [p(sol.trunc(j)).order() for j in xrange(1,len(sol.internal))]
        print sol.trunc(1),'\r\t\t\t\t\t\t',[str(item) for item in expList]
Example #3
0
"""
A convenience class that uses Sympy to allow easier command line input.
Asks user for a polynomial and for the number of desired terms. Poly can
be input as, for example, (x^3-y)*(2x+4). Sympy takes care of the simplification and the script transforms it into a mypoly object and calls the solutionList function.
"""
if len(sys.argv) == 3:
    s = sys.argv[1]
    n = int(sys.argv[2])
else:
    s = raw_input("Enter a polynomial in x and y --> ")
    n = input("Enter the number of desired terms --> ")
s = s.replace('^', '**')
p = poly(eval(s), x, y, domain='CC')
"""
d = {item[0][1]:puiseux({item[0][0]:complex(item[1])}) for item in p.terms()}
for item in p.terms():
    if item[0][1] in d.keys():
        d[item[0][1]]+=puiseux({item[0][0]:complex(item[1])})
    else: d[item[0][1]] = puiseux({item[0][0]:complex(item[1])})
m = mypoly(d)
"""
d = {item[0][1]: 0 for item in p.terms()}
for item in p.terms():
    d[item[0][1]] += puiseux({item[0][0]: complex(item[1])})
m = mypoly(d)
print m
for sol in solutionList(m, n, True):
    print
    print sol.LT()
    print sol