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 single '='.
# ratfr2ser rational fraction to power series á la Euler Archive June 2005
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 = (ser*ratfr_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-2*x^2)
ratfr.show()
ratfr2ser(ratfr, 4)