Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You can define all variables but x4 as symbolic and then define a power series ring in variable x4 over the symbolic ring with the default precision 8, the coefficient of x4^7 is then simply g[7]:

var('x1 x2 x3 w1 w2 w3 w4 w5 w6')
R.<x4> = PowerSeriesRing(SR,default_prec=8)
g = ... # copy your expression here
print( g[7] )

You can define all variables but x4 as symbolic and then define a power series ring in variable x4 over the symbolic ring with the default precision 8, 8 (or anything at least one more than the power of the required coefficient), the coefficient of x4^7 is then simply g[7]:

var('x1 x2 x3 w1 w2 w3 w4 w5 w6')
R.<x4> = PowerSeriesRing(SR,default_prec=8)
g = ... # copy your expression here
print( g[7] )

You can define all variables but x4 as symbolic and then define a power series ring in variable x4 over the symbolic ring with the default precision 8 (or anything at least one more than the power of the required coefficient), the coefficient of x4^7 is then simply g[7]:

var('x1 x2 x3 w1 w2 w3 w4 w5 w6')
R.<x4> = PowerSeriesRing(SR,default_prec=8)
g = ... # copy your expression here
print( g[7] )

ADDED. From discussion with @Emmanuel Charpentier in the comments: in the setup of the code given in the question, the following addition will do the job:

...
R1.<p4> = PowerSeriesRing(SR,default_prec=8)
print( eval(preparse(str(g).replace('x4','p4')))[7] )

You can define all variables but x4 as symbolic and then define a power series ring in variable x4 over the symbolic ring with the default precision 8 (or anything at least one more than the power of the required coefficient), the coefficient of x4^7 is then simply g[7]:

var('x1 x2 x3 w1 w2 w3 w4 w5 w6')
R.<x4> = PowerSeriesRing(SR,default_prec=8)
g = ... # copy your expression here
print( g[7] )

ADDED. From discussion with @Emmanuel Charpentier in the comments: in the setup of the code given in the question, the following addition will do the job:

...
R1.<p4> = PowerSeriesRing(SR,default_prec=8)
print( eval(preparse(str(g).replace('x4','p4')))[7] )

It does not require re-defining x4 as power-series variable.

You can define all variables but x4 as symbolic and then define a power series ring in variable x4 over the symbolic ring with the default precision 8 (or anything at least one more than the power of the required coefficient), the coefficient of x4^7 is then simply g[7]:

var('x1 x2 x3 w1 w2 w3 w4 w5 w6')
R.<x4> = PowerSeriesRing(SR,default_prec=8)
g = ... # copy your expression here
print( g[7] )

ADDED. From discussion with @Emmanuel Charpentier in the comments: in the setup of the code given in the question, the following addition will do the job:

R1.<p4> = PowerSeriesRing(SR,default_prec=8)
print( eval(preparse(str(g).replace('x4','p4')))[7] )

It does not require re-defining x4 as a power-series variable.variable, but rather introduces a new variable p4 for that purpose.