Resultant of two polynomials
Find the resultant of two polynomials.
syms x y p = x^2+y; q = x-2*y; resultant(p,q)
ans = 4*y^2 + y
Find the resultant with respect to a specific variable by using the third argument.
resultant(p,q,y)
ans = 2*x^2 + x
If two polynomials have a common root, then the resultant must be 0 at that root. Solve polynomial equations in two variables by calculating the resultant with respect to one variable, and solving the resultant for the other variable.
First, calculate the resultant of two polynomials with respect to
x to return a polynomial in
y.
syms x y p = y^3 - 2*x^2 + 3*x*y; q = x^3 + 2*y^2 - 5*x^2*y; res = resultant(p,q,x)
res = y^9 - 35*y^8 + 44*y^6 + 126*y^5 - 32*y^4
Solve the resultant for y values of the roots. Avoid
numerical roundoff errors by solving equations symbolically using the
solve function. solve
represents the solutions symbolically by using
root.
yRoots = solve(res)
yRoots =
0
0
0
0
root(z^5 - 35*z^4 + 44*z^2 + 126*z - 32, z, 1)
root(z^5 - 35*z^4 + 44*z^2 + 126*z - 32, z, 2)
root(z^5 - 35*z^4 + 44*z^2 + 126*z - 32, z, 3)
root(z^5 - 35*z^4 + 44*z^2 + 126*z - 32, z, 4)
root(z^5 - 35*z^4 + 44*z^2 + 126*z - 32, z, 5)Calculate numeric values by using vpa.
vpa(yRoots)
ans =
0
0
0
0
0.23545637976581197505601615070637
- 0.98628744767074109264070992415511 - 1.1027291033304653904984097788422i
- 0.98628744767074109264070992415511 + 1.1027291033304653904984097788422i
1.7760440932430169904041045113342
34.96107442233265321982129918627Assume that you want to investigate the fifth root. For the fifth root,
calculate the x value by substituting the
y value into p and
q. Then simultaneously solve the polynomials for
x. Avoid numerical roundoff errors by solving
equations symbolically using solve.
eqns = subs([p q], y, yRoots(5)); xRoot5 = solve(eqns,x);
Calculate the numeric value of the fifth root by using
vpa.
root5 = vpa([xRoot5 yRoots(5)])
root5 = [ 0.37078716473998365045397220797284, 0.23545637976581197505601615070637]
Verify that the root is correct by substituting root5
into p and q. The result is
0 within roundoff error.
subs([p q],[x y],root5)
ans = [ -6.313690360861895794753956010471e-41, -9.1835496157991211560057541970488e-41]
p — PolynomialPolynomial, specified as a symbolic expression or function.
q — PolynomialPolynomial, specified as a symbolic expression or function.
var — VariableVariable, specified as a symbolic variable.