Lecture 4 - Polynomials in Matlab

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
welcome to engineering 240 computational methods for engineering election for polynomials in MATLAB this video is designed to be used with the given readings and the PowerPoint of lecture 4 available on blackboard the following is an outline of lecture 4 let's start with a description of polynomials a polynomial is an expression of more than two algebraic threads mainly the sum of several terms that contain different powers of the same variable this is the general form of the nth degree polynomial note that the number of coefficients is always 1 more than the power of the polynomial let's learn how to represent a polynomial in matha MATLAB represents a polynomial by a row vector which contains all the coefficients of the polynomial is starting with the highest power for example the first polynomial is a first degree polynomial and it has two coefficients the second polynomial is a second degree polynomial therefore it has three coefficients the third polynomial is a second degree polynomial and he has three coefficients notice that the coefficient to the X to the first power is equal to zero the fourth polynomial is a fifth degree polynomial therefore has to have six coefficients notice that the polynomial doesn't have the values of X to the fourth X to the third and X to the zero therefore the coefficients are equal to zero let's now learn how to evaluate a polynomial in MATLAB in order to evaluate a polynomial for a given value or a set of values use the built-in function bali-ba in this function P represents the polynomial and X represents either the value or the set of values that you would like to evaluate this is an example of the purpose of polygons let's see you task is to take the function f of x + y for the values of x from zero to five to do this task you would have taken every value of x you would have plugging it into the function and then you would have gotten that result however you would have to do this task six different times fully bound does this process all at once we will show how to do that now in MATLAB this is the representation of MATLAB for this particular polynomial remember since it is a fourth degree polynomial he has five different coefficients let's now evaluate this particular polynomial with different values of X if I want only evaluate a single value simply define the value use the poly Val function the polynomial name and the value of x that you would like to evaluate it by if you want multiple values simply create an array of all the values that you would like to evaluate and then do the same procedure by replacing them you are right but notice if you have only one variable in the x-axis it would only give you what output once you evaluate the polynomial however in this case you get six different values of x therefore it gives you six values for the evaluation of the polynomial let us now show how to calculate the roots of a polynomial in MATLAB the root or the solution of a polynomial are the values of the independent variable that make the polynomial equal to 0 the building function rules is used to calculate the solutions of a polynomial P the function roots can calculate the roots which are gonna be either real or imaginary let's now do an example in math in this example we will use the same polynomial use previously this is a fourth degree polynomial therefore it has four roots this polynomial has four real roots as shown in the graph to calculate those roots in polynomial simply give the coefficients for the polynomial and then simply say roots MP which is the name of the polynomial run it and now these are the values of the different roots notice that are the same as given by the graph in this example we will use another fourth degree polynomial however this polynomial only has two real roots as shown by the graph we will set up exactly the same way in matlab and notice when it gives you the solution it gives you the solution of the two real values in the two their imaginary let's now learn how to obtain a polynomial from its roots in math if you know the roots of the polynomial you may obtain the corresponding polynomial using the poly function where R is the row vector with the roots of the polynomial let's do one example in MATLAB in this example we would like to obtain a polynomial that has roots located at points six to negative 9 and 0 we simply write these values in a row vector and we evaluate the poly function once we run it we get the coefficient for the function that crosses through those points if you notice this is the particular function any crosses through the given values of x let's do some mathematical operations with polynomials in math law let's start with addition and subtraction in order to add subtract any polynomials the vectors must have the same size if they are not user must place as many zeros as necessary in front of one of them to make them the same size for example we would like to add this polynomial which is a sixth degree polynomial any third degree polynomial the sixth degree polynomial would will be represented with seven coefficients and the third degree with four coefficients in order to add them or subtract them you need to add three zeros at the beginning of the second polynomial for you to add them simply write one pulling on one plus the other to subtract them simply one polynomial - any other notice that the solutions are equal to the mathematical values for both addition and subtraction in this example we will do addition and subtraction of three different polynomials we have a fourth effect in a sixth degree polynomial the sixth degree is the highest out of the three therefore it does not have a serum before it the fourth degree polynomial has two zeros before it and the fifth degree polynomial has one zero before all of them have to have exactly the same size before adding them also Stratton to add them simply write the name of the polynomial plus the name of the second polynomial and then to subtract and simply do what - the other these are the results notice that the size of any addition or subtraction of polynomials have to have exactly the same size of the highest polynomial in your operation let's continue with multiplication of polynomials in order to multiply two polynomials use the building function come and write it in this particular way use Kahn open parentheses by the name of the two vectors that you would like to multiply and then close parentheses notice that the degrees of a and B could be completely different for example we have a six degree polynomial and we have a third degree polynomial to fly them the power that is gonna get us is enough this is six plus three will give us in nine degree polynomial to undo it in MATLAB simply right can open parentheses then name of the two polynomials then that was right once you get it notice it you get ten different coefficients which indicates that is in ninth degree polynomial let's do an example in math we have two different point almost a seventh degree polynomial and they fought the gratefully not if we multiply these two polynomials 7 plus 4 will give us the 11th degree in order you'll be set it up using the current building function we simply write calm and the name of the polynomials the order the polynomial in is not important we run this they will get a solution notice that we have 12 different coefficients which represents 11 between polynomial let's continue with the division of polynomials in MATLAB a division always requires a quotient and a remainder therefore the function requires two outputs the building function that you will use will be deacon and you will set it up in this particular way first you set up the two outputs equal sign deacon and then the two vectors that you would like to use in this case you is the numerator of the polynomial and V is the denominator of the pole or is that the order of U and V cannot be exchanged for example we're gonna take the first polynomial which is a third degree polynomial and we're gonna divided by the second polynomial which is a first degree polynomial we set them up in this particular way and their result and give us a second degree polynomial and the quotient is going to be 156 divided by its original polynomial let's not do an example in mouths that take two different polynomials and we're gonna divide one by the other we're gonna divide a third degree polynomial by a second degree fully not and we'll set it up in this particular way remember since it is division it always requires two outputs the quotient and the remainder when you set it up use the deccan built-in function and the first polynomial divided by this we've run it and this is the solution we get the Q is a solution of the quotient in R is a solution for the remainder of the division let's not continue with the derivative of polynomials in MATLAB the built-in function is fully there however it can be used in three different ways the first method is to calculate the derivative of a single poly not the way that is set up is the following you will write politer and inside of the parenthesis you will write only one polynomial for example we have this particular polynomial which derivative it is given by this function in MATLAB we will write it using this row vector and we simply calculate the derivative by typing Bohlander and the name of the polynomial and it will give us these coefficients notice that it's exactly the same as the one given mathematic the second is to calculate the derivative of the multiplication of two polynomials in MATLAB you will set it up as a poly turn and inside of the parentheses we will write the two polynomials mathematically the way that you will calculate this derivative is by using this function in this case we have two polynomials and we have set them up in MATLAB using the coefficients to calculate the derivative of its multiplication you simply write polylearn and in parentheses write the name of the two polynomials separated by a comma the third calculates the derivative of the ratio of two polynomials once again since it is a division it requires two outputs in MATLAB you will set it up in this way you will have the two outputs equal Polydor and inside of the parentheses the two polynomials the first polynomial is the numerator and the second will be the denominator mathematically the derivative is calculated using this particular formula for example you will have two polynomials you will set them up in this particular way and once you calculate it it will give you a value for the numerator and the denominator of the division which correspond to the upper and the bottom part of the derivative let's now do a example of how to calculate the derivatives in math the first method calculates the derivative of a single polynomial notice this is a fourth degree polynomial always the derivative of the polynomial is going to be one degree lower than the original polynomial so the original is a fourth degree polynomial you know it's a derivative it's one less therefore it is a third degree polynomial calculates the derivative of the multiplication of two polynomials if you simply take the two polynomials and write politer and the two polynomials inside the parentheses it will give you this result if you notice the politer has two operations at once fix the multiplication and takes the derivative to show that this is the case we calculate the polynomial using the cont built-in function and now we can take the derivative of that particular polynomial notice the results are exactly the same the advantage of using polyter is that it saves you one calculation the third method calculates the derivative of the ratio of two polynomials since it is a division it requires two items then you will set it up exactly the same way politer and the name of the two polynomials we run notice that is structure for the politer for a multiplication and for the division is exactly the same after the equal sign the only way that MATLAB knows that you would like to do a multiplication versus a division is the number of output before the equal sign so please be careful when you indicate the number of outputs it is one output or no variable alone it means multiplication if he has two output it means the better this concludes lecture for polynomials in MATLAB for engineering 240 computational methods for engineering make sure to complete the assigned readings for this lecture take the required quizzes and be ready to start class assignments
Info
Channel: Prof. Amaya - CCSU
Views: 5,819
Rating: 4.9428573 out of 5
Keywords:
Id: krvjHAn7rz8
Channel Id: undefined
Length: 16min 8sec (968 seconds)
Published: Wed May 18 2016
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.