expand

Sage

Cette fonction s'applique à une expression symbolique (calcul symbolique).

g(x) = expand ((x ^ 2 -1) ^ 3 * (x ^2 + 1) * (x - 2) );

g.show ();

x --> x9 -2x8 -2x7 .....

sage: a = (x-1)*(x^2 - 1); a (x - 1)*(x^2 - 1)
sage:
expand(a) x^3 - x^2 - x + 1

Et
sage: x = polygen(ZZ) # polynomial over a given base ring.
sage: F = factor(x^12 - 1); F
(x - 1) * (x + 1) * (x^2 - x + 1) * (x^2 + 1) * (x^2 + x + 1) * (x^4 - x^2 + 1)
sage: expand(F)
x^12 - 1
sage: F.expand()
x^12 - 1
sage: F = factor(2007); F
3^2 * 223
sage: expand(F)
Et puis
sage: x = polygen(ZZ) # polynomial over a given base ring.
sage: f = sum(x^n for n in range(5))
sage: f*f # much faster, even if the degree is huge
x^8 + 2*x^7 + 3*x^6 + 4*x^5 + 5*x^4 + 4*x^3 + 3*x^2 + 2*x + 1

» Glossaire de Sage