1 | initial version |
My session does not paste very well but at the bottom is the solution I want to parse into A, B etc. I hope you will see what I am trying to do, and you will also see the singke '='
def ratfr2ser(ratfr, num_terms): var("A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z") lets=[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z] rnt=range(num_terms) ser = [ lets[i] * x^i for i in rnt ] ser=sum(ser) # converts from list to symbolic show(ser) ratfr_num = ratfr.numerator() ratfr_den = ratfr.denominator() eqn = (serratfr_den - ratfr_num).expand().collect(x) show(eqn) cfs = [eqn.coefficient(x, n=p) for p in rnt] show(cfs) sol = [solve(ec, ec.variables()) for ec in cfs] show(sol) for i in rnt: sol = solve(cfs[i], cfs[i].variables()) #sage_eval(str(sol[0])) #show(A) ratfr=(1-x)/(1-x-2x^2) ratfr.show() ratfr2ser(ratfr, 4)
x−12x2+x−1 x 1 2 x 2 x 1 Dx3+Cx2+Bx+A D x 3 C x 2 B x A 2Dx5+(2C+D)x4+(2B+C−D)x3+(2A+B−C)x2+(A−B−1)x−A+1 2 D x 5 2 C D x 4 2 B C D x 3 2 A B C x 2 A B 1 x A 1 [−A+1,A−B−1,2A+B−C,2B+C−D] A 1 A B 1 2 A B C 2 B C D [[A=1],[[A=r1+1,B=r1]],[[A=12r2−12r3,B=r3,C=r2]],[[B=12r4−12r5,C=r5,D=r4]]]
2 | No.2 Revision |
My session does not paste very well but at the bottom bottom
is the solution I want to parse into A, B etc. A
, B
etc.
I hope you will see what I am trying to do, and you will also see the singke '='single '='.
#
ratfr2ser rational fraction to power series á la Euler Archive June x−12x2+x−1 x 1 2 x 2 x 1 Dx3+Cx2+Bx+A D x 3 C x 2 B x A 2Dx5+(2C+D)x4+(2B+C−D)x3+(2A+B−C)x2+(A−B−1)x−A+1 2 D x 5 2 C D x 4 2 B C D x 3 2 A B C x 2 A B 1 x A 1 [−A+1,A−B−1,2A+B−C,2B+C−D] A 1 A B 1 2 A B C 2 B C D [[A=1],[[A=r1+1,B=r1]],[[A=12r2−12r3,B=r3,C=r2]],[[B=12r4−12r5,C=r5,D=r4]]]