1 | initial version |
Maybe the following is what you want.
Having defined:
sage: R2.<a0, a1, a2, a3, a4, b0, b1, b2, b3, b4, z, w, l, E, E1, v, t> = QQ[]
sage: R.<x> = PowerSeriesRing(R2)
sage: p = a1 * x - a1 * z * x^2 + a3 * x^3 + a4 * x^4 + O(x^12)
sage: p1 = p.derivative()
sage: p2 = p1.derivative()
sage: k = b1 * x + b2 * x^2 + b3 * x^3 + b4 * x^4 + O(x^12)
sage: y = 2/x * (z - v * x) - E
sage: g = x * (p2 + y * p - x - E1 * k)
we get:
sage: g
(-2*a1*z^2 - a1*E - b1*E1 - 2*a1*v + 6*a3 - 1)*x^2
+ (a1*z*E + 2*a1*z*v + 2*a3*z - b2*E1 + 12*a4)*x^3
+ (2*a4*z - a3*E - b3*E1 - 2*a3*v)*x^4
+ (-a4*E - b4*E1 - 2*a4*v)*x^5
+ O(x^11)
Let's look at the coefficients of g
, and specifically the constant one:
sage: cc = g.coefficients()
sage: cc
[-2*a1*z^2 - a1*E - b1*E1 - 2*a1*v + 6*a3 - 1,
a1*z*E + 2*a1*z*v + 2*a3*z - b2*E1 + 12*a4,
2*a4*z - a3*E - b3*E1 - 2*a3*v,
-a4*E - b4*E1 - 2*a4*v]
sage: c = cc[0]
sage: c
-2*a1*z^2 - a1*E - b1*E1 - 2*a1*v + 6*a3 - 1
Dirty trick: to solve, move to the symbolic ring via strings:
sage: eq = SR(str(c))
sage: eq
-2*a1*z^2 - E*a1 - E1*b1 - 2*a1*v + 6*a3 - 1
sage: symbolic_a3 = SR('a3')
sage: sol = solve([eq], symbolic_a3, solution_dict=True)
sage: sol
[{a3: 1/3*a1*z^2 + 1/6*E*a1 + 1/6*E1*b1 + 1/3*a1*v + 1/6}]
Extract the value and take it back to the polynomial ring:
sage: s = sol[0]
sage: s
{a3: 1/3*a1*z^2 + 1/6*E*a1 + 1/6*E1*b1 + 1/3*a1*v + 1/6}
sage: my_symbolic_a3 = s[symbolic_a3]
sage: my_symbolic_a3
1/3*a1*z^2 + 1/6*E*a1 + 1/6*E1*b1 + 1/3*a1*v + 1/6
sage: my_a3 = R2(my_symbolic_a3)
sage: my_a3
1/3*a1*z^2 + 1/6*E*a1 + 1/6*E1*b1 + 1/3*a1*v + 1/6