Matlab Calculate Roots of Polynomial
Finding the roots of a polynomial is a fundamental problem in mathematics with applications in engineering, physics, and computer science. MATLAB provides several powerful functions to solve polynomial equations. This guide explains how to use MATLAB to calculate the roots of a polynomial, including the different methods available and practical examples.
Introduction
A polynomial is an expression consisting of variables and coefficients, involving only the operations of addition, subtraction, multiplication, and non-negative integer exponentiation. The roots of a polynomial are the values of the variable that make the polynomial equal to zero.
MATLAB offers several functions to find the roots of polynomials, including roots, poly, and fzero. Each method has its own advantages and is suitable for different types of polynomials.
How to Use the Calculator
Our built-in calculator allows you to input the coefficients of a polynomial and see the roots calculated using MATLAB's roots function. Simply enter the coefficients in descending order of powers and click "Calculate".
Note: The calculator uses MATLAB's roots function, which finds all roots of a polynomial with real coefficients, including complex roots.
MATLAB Methods for Finding Roots
The roots Function
The roots function computes the roots of a polynomial whose coefficients are given in vector form. The coefficients are ordered from the highest power to the lowest.
Syntax: r = roots(c)
where c is a vector of polynomial coefficients.
The poly Function
The poly function generates the coefficients of a polynomial whose roots are specified in vector form.
Syntax: p = poly(r)
where r is a vector of polynomial roots.
The fzero Function
The fzero function finds a zero of a function of one variable. It is useful for finding roots of non-polynomial functions.
Syntax: x = fzero(fun,x0)
where fun is a function handle and x0 is an initial guess.
Worked Example
Let's find the roots of the polynomial \( x^3 - 6x^2 + 11x - 6 \).
- Enter the coefficients in descending order: 1, -6, 11, -6.
- Click "Calculate" to see the roots.
The roots of the polynomial are 1, 2, and 3.
Verification: You can verify the roots by substituting them back into the polynomial equation.
FAQ
roots and poly?roots function finds the roots of a polynomial given its coefficients, while the poly function generates the coefficients of a polynomial given its roots.roots function can find both real and complex roots of a polynomial.