ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 18 Mar 2021 18:56:33 +0100Taking elements in solve and multiplying to a polynomialhttps://ask.sagemath.org/question/56231/taking-elements-in-solve-and-multiplying-to-a-polynomial/So I want a function that solves a system of two equations and the move those numerical results to polynomials f and g.
def PolynomialCoefficient(fcn1, fcn2):
var ('a b')
eqn1 = 2*a + 2*b == 0
eqn2 = 3*a - b == 1
List = solve([eqn1, eqn2], a, b)
Now I want to move this to `a*f(x)+b*g(x)` without hitting solve each time
and manually typing what `a` and `b` are. For example,
`PolynomialCoefficient(x, y)` should output `1/4 x - 1/4 y`.
The issue is `len(List)` outputs 1. If it was length 2 with `a` in first slot
and `b` in 2nd slot, I could do
Poly = List[0]*fcn1 + List[1]*fcn2
return Poly
Any ideas on how to move `a` and `b`?whatupmattThu, 18 Mar 2021 18:56:33 +0100https://ask.sagemath.org/question/56231/