Output of series wrong without applying full_simplify

asked 2023-07-28 13:04:33 +0200

Declaminius gravatar image

I am interested in extracting coefficients of generating functions. However, without applying full_simplify, the series function produces wrong results, where the coefficients appear to be shifted.

For example:

z = var("z")
u_1(z) = ( 1 - sqrt(1-4*z^2) )/(2*z)
D(z) = 1/(1 - u_1(z))

D(z).series(z,7)

produces 1*z^(-1) + 1 + 1*z + 2*z^2 + 3*z^3 + 6*z^4 + 10*z^5 + 20*z^6 + Order(z^7), while

D(z).full_simplify().series(z,7)

produces the correct result 1 + 1*z + 1*z^2 + 2*z^3 + 3*z^4 + 6*z^5 + 10*z^6 + Order(z^7).

D(z) evaluates to 2/((sqrt(-4*z^2 + 1) - 1)/z + 2), while D(z).full_simplify() evaluates to 2*z/(2*z + sqrt(-4*z^2 + 1) - 1), so the only simplification done here is to multiply the numerator and denominator with a factor z.

Why is it necessary to apply full_simplify to get correct results from series?

edit retag flag offensive close merge delete

Comments

1

Looks like a bug. Btw, D(z).taylor(z,0,7) works fine without simplification.

Max Alekseyev gravatar imageMax Alekseyev ( 2023-07-29 01:08:19 +0200 )edit