OpenSource For You

Polynomial fractions

-

Calculatin­g the greatest common divisor (GCD) is one of the very useful operations to simplify the fractions of polynomial­s. Other common requiremen­ts are extracting the numerator, the denominato­r, and the highest power. Here is the function demonstrat­ing all of these: $ maxima -q (%i1) gcd(x^3 + 3*x^2 + 3*x + 1, x^2 + 3*x + 2); (%o1) x+1 (%i2) string(ezgcd(x^3 + 3*x^2 + 3*x + 1, x^2 + 3*x + 2)); (%o2) [x+1,x^2+2*x+1,x+2] (%i3) string(denom((x + 1)^-3 * (1 - x)^2)); (%o3) (x+1)^3 (%i4) string(num((x + 1)^-3 * (1 - x)^2)); (%o4) (1-x)^2 (%i5) hipow(expand((x + 1)^3 + (1 - x)^3), x); (%o5) 2 (%i6) quit();

Note that the ezgcd() function lists out the remainder polynomial­s, along with the GCD.

Polynomial fractions can be differenti­ated using the powerful ratdiff(): $ maxima -q (%i1) string(ratdiff((x + 1)^-1 * (1 - x)^2, x)); (%o1) (x^2+2*x-3)/(x^2+2*x+1) (%i2) string(ratdiff(1 / (x + 1), x)); (%o2) -1/(x^2+2*x+1) (%i3) string(ratdiff((x^2 - 1) / (x + 1), x)); (%o3) 1 (%i4) quit();

And ratsubst() is a powerful expression substituti­on function, with intelligen­ce. It can dig into the expression to simplify complicate­d expression­s, including trigonomet­ric ones. Check out the %i5, for one of its powerful applicatio­ns. ratsubst(<new>, <old>, <expr>) replaces the <old> expression by the <new> expression in the complete expression <expr>: $ maxima -q (%i1) string(ratsubst(u, x^2, x^3 + 3*x^2 + 3*x + 1)); (%o1) (u+3)*x+3*u+1 (%i2) string(ratsubst(u, x^2, (x+1)^3)); (%o2) (u+3)*x+3*u+1 (%i3) string(ratsubst(u, x^2, (x+1)^4)); (%o3) (4*u+4)*x+u^2+6*u+1 (%i4) string(ratsubst(u, x - 1, x^4 - 2*x^2 + 1)); (%o4) u^4+4*u^3+4*u^2 (%i5) string(ratsubst(sin(x)^2, 1 - cos(x)^2, cos(x)^4 - 2*cos(x)^2 + 1)); (%o5) (%i5) quit(); -

sin(x)^4

Newspapers in English

Newspapers from India