MMME1037 Programming, Professional and Laboratory Skills

Post New Homework

MMME1037 Programming, Professional and Laboratory Skills Assignment - University of Nottingham, UK

An exercise in coding algorithms - Polynomials.

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

(1) Develop two functions - called poly_input and poly_output respectively. These interact with the user to take-in or display polynomials respective.

(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.

(3) 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).

(4) 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.

(5) 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.

(6) 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.

(7) Create a function called poly_intg for integrating polynomials.

(8) Create a function called poly_diff for differentiating polynomials.

(9) Create a single script called task 9 which exercises all of the above following the instructions given in the expanded task definition below.

Expanded Task Definitions -

Task 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.

Task 3 - Develop a function called poly_eval which evaluates the polynomial at a set of values of x.

Task 4 - Develop a function called poly_sum which determines the sum of two polynomials

Task 5 - Develop a function called poly_prod which determines the product of two polynomials

Task 6 - Create a function called poly_fact which decomposes P(x) as P(x) = S(x) × Q(x) + R(x).

In the use of this function, the two polynomials P(x) and Q(x) are given and the requirement is to determine S(x) and R(x). Obviously:

The order of P(x) must be at least as high as the order of Q(x). Usually it is higher. Note that the order of S(x) is the difference between the other two orders so that if P(x) and Q(x) have the same order, then S(x) is simply a scalar.

The order of R(x) must be lower than the order of Q(x).

Task 7 - Create a function called poly_intg which integrates P(x) with respect to x - setting the constant term of the result equal to 0. This function should have only one input argument and should generate only one output argument. Recall that the integral of axn with respect to x is (a/(n+1)) xn+1 and note that the integration being discussed here is analytical integration (not numerical integration).

Task 8 - Create a function called poly_diff which differentiates P(x) with respect to x. This function should have only one input argument and should generate only one output argument. Recall that the differentiation of axn with respect to x is (an) xn-1 and note that the differentiation being discussed here is analytical differentiation (not numerical differentiation).

Task 9 - Create a single script called task_9 which exercises all of the above as instructed here:

Establish the row vector representing the polynomial P(x) = 14x6 + 18x5 - 5x4 + 28x3 - 12x3 + 11x - 95 and call poly_output to display it.

Get the user to input a polynomial, Q(x), of order 4 using poly_input and call poly_eval to compute its values for a range of values of x from -3 to +3 in 2000 steps. Plot the resulting curve. Your report should include the curve produced and the 4 polynomial coefficients actually input to form that curve.

Find the sum of P(x) and Q(x), denoted U(x) here, and use poly_output to display it.

Find the product of P(x) and Q(x), denoted V(x) here, and use poly_output to display that.

Get the user to input a new polynomial, W(x), of order 4 using poly_input and apply poly_fact to decompose V(x) as V(x) = W(x) S(x) + R(x). Your report should include the coefficients used for W(x).

Differentiate V(x) three times and report the result.

In the above, the coefficients input by the user to describe Q(x) and W(x) should be integers.

Attachment:- Programming, Professional and Laboratory Skills Assignment File.rar

Post New Homework
Captcha

Looking tutor’s service for getting help in UK studies or college assignments? Order Now