Solving polynomial equations using Matlab

Polynomial equations are some of the most popular type of equations in Math. Knowing how to solve them is a thing but actually solving them is another thing.

The methods you can use to solve them are many, but if you happen to have Matlab or the free Matlab alternative Octave you might as well be good using them to buy time if the purpose of solving the equation is more than simply solving the equation.

Caution: The following methods will help you solve polynomial equations quickly but will not show you how to manually solve a polynomial equations, it will simply help you get results faster. This can be helpful if you are not interested on the method but on the answers and may also be very useful to check your result after manually solving your equations.

Solving polynomial equations using Matlab

Solving quadratic equations using Matlab

Quadratic equation are equations on the form

matlab-solve-equation

Where

matlab-solve-equation

So you will also find quadratic equations on the form

matlab-solve-equation

or

matlab-solve-equation

Let’s go ahead and solve the following equation with Matlab

matlab-solve-equation

To solve this equation with Matlab you will enter the following code

roots([1 -3 2])

and Matlab will give you the roots of the polynomial equation

matlab-solve-equation

If the equation was the following

matlab-solve-equation

the code would be

roots([1 0 -4])

and the result

matlab-solve-equation

Solving cubic equations using Matlab

Let’s use the following equation

matlab-solve-equation

The line of code to solve it wont be that different compared to the previous one. The only difference here is that we have non zero third order coefficient to add to it

roots([1 6 0 -20])

Do not forget to add 0 between 6 and -20 since the first-order-coefficient is zero

The result will be

matlab-solve-equation

Solving quartic equations using Matlab

Using the following polynomial equation

matlab-solve-equation

The code will be

roots([1 2 -6*sqrt(10) +1])

And the result will be

matlab-solve-equation

The higher order the higher number of coefficient. Remember the order which with you enter coefficients in the code affect the result, and always remember to put 0 to indicate where the coefficient is not existent for lower exponents of the equation.

tchouken2

Related Posts