Earn Higher Grades With Instant Assignment Help.Ask Question!

Matlab & Mathematica
(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.

Attachments:
(5/5)

Related Questions

CSI 1420 Introduction to C Programming & 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 majorconstructs of the C programming language – Fu

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 Assignment To Be Done By Our ExpertsGet A+ Grade Solution Guaranteed

expert
joyComputer science
(4/5)
12 Answers Hire Me
expert
Robert DLaw
(4.8/5)
648 Answers Hire Me
expert
Dr Samuel BarberaStatistics
(5/5)
670 Answers Hire Me
expert
Tutor For YouEconomics
(5/5)
801 Answers Hire Me