Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I will suppose c0 is 1, else we divide with its square root, which should exist in the ground field for the coefficients. (Feel free to change the following code, so that c0 is also a general variable.)

The following does the job for me:

c = [1,] + list( var( 'c1,c2,c3,c4,c5,c6' ) )
print "c is", c
var( 'x' );
T = taylor( sqrt( 1 + sum( [ c[k]*x^k for k in [1..6] ] ) ), x, 0, 6 )
# print T # for a long story
print "T has the following coefficients:"
for coeff, deg in T.coefficients( x ):
    print "Degree %s: %s" % ( deg, coeff )

Results:

c is [1, c1, c2, c3, c4, c5, c6]
x
T has the following coefficients:
Degree 0: 1
Degree 1: 1/2*c1
Degree 2: -1/8*c1^2 + 1/2*c2
Degree 3: 1/16*c1^3 - 1/4*c1*c2 + 1/2*c3
Degree 4: -5/128*c1^4 + 3/16*c1^2*c2 - 1/8*c2^2 - 1/4*c1*c3 + 1/2*c4
Degree 5: 7/256*c1^5 - 5/32*c1^3*c2 + 3/16*c1*c2^2 + 1/16*(3*c1^2 - 4*c2)*c3 - 1/4*c1*c4 + 1/2*c5
Degree 6: -21/1024*c1^6 + 35/256*c1^4*c2 - 15/64*c1^2*c2^2 + 1/16*c2^3 - 1/32*(5*c1^3 - 12*c1*c2)*c3 - 1/8*c3^2 + 1/16*(3*c1^2 - 4*c2)*c4 - 1/4*c1*c5 + 1/2*c6