logo Use CA10RAM to get 10%* Discount.
Order Nowlogo
(5/5)

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

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

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]

 

Expanded Task Definitions

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

(5/5)
Attachments:

Related Questions

. Introgramming & Unix Fall 2018, CRN 44882, Oakland University Homework Assignment 6 - Using Arrays and Functions in C

DescriptionIn this final assignment, the students will demonstrate their ability to apply two ma

. The standard path finding involves finding the (shortest) path from an origin to a destination, typically on a map. This is an

Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t

. 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. The LineItem class will represent an individual

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

. SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

. Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

Ask This Question To Be Solved By Our ExpertsGet A+ Grade Solution Guaranteed

expert
Um e HaniScience

680 Answers

Hire Me
expert
Muhammad Ali HaiderFinance

556 Answers

Hire Me
expert
Husnain SaeedComputer science

804 Answers

Hire Me
expert
Atharva PatilComputer science

540 Answers

Hire Me
August
January
February
March
April
May
June
July
August
September
October
November
December
2025
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
SunMonTueWedThuFriSat
27
28
29
30
31
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1
2
3
4
5
6
00:00
00:30
01:00
01:30
02:00
02:30
03:00
03:30
04:00
04:30
05:00
05:30
06:00
06:30
07:00
07:30
08:00
08:30
09:00
09:30
10:00
10:30
11:00
11:30
12:00
12:30
13:00
13:30
14:00
14:30
15:00
15:30
16:00
16:30
17:00
17:30
18:00
18:30
19:00
19:30
20:00
20:30
21:00
21:30
22:00
22:30
23:00
23:30