Problem with solve()

asked 2016-08-02 08:27:59 -0600

this post is marked as community wiki

This post is a wiki. Anyone with karma >750 is welcome to improve it.

Hi, I'm unable to solve a polynomial using Sage.

I have a function that creates a polynomial given a vector of coefficients

def createPolynomForCoeff(Hcoefficient):
    indexMap = indexCoeffMap(len(Hcoefficient))
    xt,yt = var('xt, yt')
    h(xt,yt) = 0*xt*yt
    for i in range(len(Hcoefficient)):
        h = h + Hcoefficient[i]*(xt^indexMap[i][0])*( yt^indexMap[i][1])
    return h

Another function takes the polynomial, finds roots and do some calculations with the roots(not yet written)

def fRoots(h,N):
    xt, yt = var('xt, yt')
    tmpRoots = solve(h == 0, xt, yt)
    return tmpRoots

My problem is that solve solves only for xt, e.g: ([xt == -3/324958370652260843508466983800081371393543861233065*(211195885313944282936234464966717105743153589003712170900488769205796484783769135230857222907689545278*yt + 1)/(3379134165023108526979751439467473691890457424059394734407820307292743756540306163693715566523032724448*yt + 1)], [1])

Any help is very welcome!


edit retag flag offensive close merge delete


Does using solve(h == 0, [x1,y1]) or solve([h == 0], x1,y1) or solve([h == 0], [x1,y1]) give you the right answer? It seems that if solve is supplied with a single equation, it doesn't try to look for multiple variables in the arguments.

nbruin gravatar imagenbruin ( 2016-08-02 09:49:40 -0600 )edit

Please include an example of how you use your code and what error you get.

slelievre gravatar imageslelievre ( 2016-11-08 06:26:37 -0600 )edit

What about solve( h == 0, yt )? (There is a question, if the original question is this question which is solved by this solve...)

dan_fulea gravatar imagedan_fulea ( 2017-03-03 21:06:45 -0600 )edit