Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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 af(x)+bg(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/4y. The issue is

len(List)

outputs 1. If it was length 2 with a in first slot and b in 2nd slot I can do,

Poly= List[0]*fcn1+List[1]*fcn2
return Poly

Any ideas on how to move a and b?

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)
  eqn1 = 2*a + 2*b == 0
    eqn2 = 3*a - b == 1
    List = solve([eqn1, eqn2], a, b)

Now I want to move this to af(x)+bg(x) a*f(x)+b*g(x) without hitting solve each time time and manually typing what a and b a and b are. For example, PolynomialCoefficient(x,y) example, PolynomialCoefficient(x, y) should output 1/4 x - 1/4y. 1/4 y. The issue is is

len(List)

outputs 1. If it was length 2 with a a in first slot and b b in 2nd slot slot, I can do, could do

Poly= List[0]*fcn1+List[1]*fcn2
    Poly = List[0]*fcn1 + List[1]*fcn2
    return Poly

Any ideas on how to move a and b?a and b?

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)

is len(List) outputs 1. If it was length 2 with a in first slot 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?