Background:
The following is an example of a polynomial:
12x5 + 2x4  7x3 + 13x2 + 6
We can represent that polynomial by storing its coefficients in a rowvector – starting with the coefficient of the highest power of x and working down. The following rowvector, (called P here) would represent the polynomial above:
>> P = [12 2 7 13 0 6]
Note that a “zero” has to be inserted to indicate that the coefficient of x1 is zero. Note also that we will deal only with polynomials whose coefficients are real. (Complex coefficients sometimes arise but are not relevant here). The order of the polynomial is the highest power of x. The above polynomial is “5th order” but notice that there are 6 coefficients – since there must be a coefficient of x0.
This coursework concerns developing a set of tools for working with polynomials.
These tools are useful for a number of engineering applications – and they are especially useful for understanding control theory but the applications themselves are outside of the scope of this assignment.
In this coursework assignment, polynomials are denoted P(x), Q(x), R(x) etc. in mathematical notation.
If any function intended to return a polynomial result encounters some critical error, then it should return a null array (i.e. an array with zero columns and zero rows).
The following 9 tasks are set
These interact with the user to takein or display polynomials respective. [20 marks]
array is either a row or a column and then outputs a row vector. [20 marks]
set of values of x provided. (This must work correctly with complex values of x). [20 marks]
R(x) = P(x) + Q(x) where P(x) and Q(x) may have different orders. [20 marks]
polynomials R(x) = P(x) × Q(x) where P(x) and Q(x) may have different orders. [20 marks]
P(x) = S(x) × Q(x) + R(x). Here, the polynomials P(x) and S(x) are given and the
polynomials Q(x) and R(x) are to be determined. [30 marks]
Task 1.
The following function call should work for inputting a polynomial.
>> P = poly_input( 5 );
If an input argument is supplied, this indicates the order of the polynomial. The function should be able to operate even if no input argument is supplied – by asking the user instead.
The following function call should work for displaying a polynomial.
>> iok = poly_output( P );
The format of the output expected is indicated by the following MATLAB commandline instructions and the associated output
>> P = [ 1 11 3 4 1 ];
>> iok = poly_output( P );
The polynomial of interest has 
order 
4 
The coefficient of s^4 is 
1 

The coefficient of s^3 is 
11 

The coefficient of s^2 is 
3 

The coefficient of s^1 is 
4 

The coefficient of s^0 is 
1 

In your writeup of task 1, only the MATLAB code for the two functions is required.
Task 2. Develop a function called poly_row which takes in an array, checks that this array is either a row or a column and then outputs a row vector.
The intention of this function is implicit from the following MATLAB commandline instructions and the corresponding output expected.
>> P = [ 1 11 3 4 1 ]; Q = poly_row( P ) Q =
1 11 3 4 1
>> P = [ 1; 11; 3; 4; 1 ]; Q = poly_row( P ) Q =
1 1 3 4 1
>> P = [ 1 3 7; 4 1 12 ]; Q = poly_row( P )
** Error **
The input array here has dimensions 2 by 3 Its minimum dimension was expected to be 1.
Q = []
In your writeup of task 2, only the MATLAB code for the function is required.
Task 3. Develop a function called poly_eval which evaluates the polynomial at a set of values of x.
The set of values of x can be allowed to be an array of any dimensions.
Thus, the following should work and should deliver the plot shown in Figure T3 below.
>> P = [ 1 1 7 15 6 14 12];
>> uvals = ((4:0.01:4)'); vvals = (0:1:4);
>> xvals = uvals*ones(1,5) + ones(801,1)*vvals*sqrt(1);
>> yvals = poly_eval( P, xvals );
>> semilogy(uvals, abs(yvals))
In your writeup of task 3, only the MATLAB code for the function is required.
Task 4. Develop a function called poly_sum which determines the sum of two polynomials
This function should make good use of poly_row (from Task 2) to convert either (or both) of the input polynomial arguments into row format if necessary.
The following should work and should deliver the answer indicated below.
>> P = [ 1 1 7 15]; Q = [ 6; 14; 12];
>> R = poly_sum( P, Q ); R =
1 5 7 3
Table T4 below illustrates why this answer is expected.
Polynomial 
Coeff. of x3 
Coeff. of x2 
Coeff. of x1 
Coeff. of x 
P(x) 
1 
1 
7 
15 
Q(x) 

6 
14 
12 
R(x)= P(x)+ Q(x) 
1 
5 
7 
3 
Table T4
In your writeup of task 4, present the MATLAB code for the function as well as a concise description of what logical steps are taken in the code to achieve the result.
Task 5. Develop a function called poly_prod which determines the product of two polynomials
This function should again make good use of poly_row (from Task 2) to convert either (or both) of the input polynomial arguments into row format if necessary.
CS 340 Milestone One Guidelines and Rubric Overview: For this assignment, you will implement the fundamental operations of create, read, update,
Retail Transaction Programming Project Project Requirements: Develop a program to emulate a purchase transaction at a retail store. This
7COM1028 Secure Systems Programming Referral Coursework: Secure
Create a GUI program that:Accepts the following from a user:Item NameItem QuantityItem PriceAllows the user to create a file to store the sales receip
CS 340 Final Project Guidelines and Rubric Overview The final project will encompass developing a web service using a software stack and impleme
Get Free Quote!
271 Experts Online