(/5)

Hire Me
(5/5)

Hire Me
(4/5)

Hire Me
(5/5)

Hire Me

# Develop two functions – called poly_input and poly_output These interact with the user to take-in or display polynomials respective.

INSTRUCTIONS TO CANDIDATES

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 row-vector – starting with the coefficient of the highest power of x and working down. The following row-vector, (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).

## Overall Requirement

The following 9 tasks are set

• Develop two functions – called poly_input and poly_output

These interact with the user to take-in or display polynomials respective.                            [20 marks]

• 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.                                          [20 marks]

• Develop a function called poly_eval which evaluates the polynomial at a

set of values of x provided. (This must work correctly with complex values of x).               [20 marks]

• Develop a function called poly_sum which determines the sum of two polynomials

R(x) = P(x) + Q(x) where P(x) and Q(x) may have different orders.                                   [20 marks]

• Develop a function called poly_prod which determines the product of two

polynomials R(x) = P(x) × Q(x) where P(x) and Q(x) may have different orders.               [20 marks]

• Create a function called poly_fact which decomposes P(x) as

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]

• Create a function called poly_intg for integrating [20 marks]
• Create a function called poly_diff for differentiating [20 marks]
• Create a single script called task 9 which exercises all of the above following the instructions given in the expanded task definition below.                                                       [30 marks]

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 command-line 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 write-up 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 command-line 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 write-up 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 write-up 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.

## Related Questions

##### . The fundamental operations of create, read, update, and delete (CRUD) in either Python or Java

CS 340 Milestone One Guidelines and Rubric  Overview: For this assignment, you will implement the fundamental operations of create, read, update,

##### . Develop a program to emulate a purchase transaction at a retail store. This  program will have two classes, a LineItem class and a Transaction class

Retail Transaction Programming Project  Project Requirements:  Develop a program to emulate a purchase transaction at a retail store. This

##### . The following program contains five errors. Identify the errors and fix them

7COM1028   Secure Systems Programming   Referral Coursework: Secure

##### . Accepts the following from a user: Item Name Item Quantity Item Price Allows the user to create a file to store the sales receipt contents

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

##### . The final project will encompass developing a web service using a software stack and implementing an industry-standard interface. Regardless of whether you choose to pursue application development goals as a pure developer or as a software engineer

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