MCS 320 Exam 1 Wednesday 21 February 2007
| > |
1. Consider the polynomial
Give Maple commands (with output)
| > | p := x^3 + 3*x^2 + 8; |
(a) to show that p is irreducible over the rational numbers :
| > |
(b) to factor p symbolically into a product of linear polynomials, adding sufficiently many formal roots :
| > |
| > |
| > |
| > |
| > |
(c) to factor p numerically :
| > |
![]()
(d) to show the relation between the numerical and the symbolic factorization :
| > |
![]()
2. Execute the commands
| > | restart; k := 3; sum(x[k],k=1..5); |
Error, (in sum) summation variable previously assigned, second argument evaluates to 3 = 1 .. 5
(a) Explain why the third command does not give the desired result.
The variable k has already a value before the sum command is executed.
The sum command can therefore not use k to evaluate the range 1..5.
(b) Modify ONLY the third command so that is returns
| > | sum(x['k'],'k'=1..5); |
3. The sequence
gives rational approximations to
When answering the questions below, also give the Maple commands used:
(a) How many decimal places in
as rational approximation for
are correct?
| > | s2 := evalf(sqrt(2)); |
| > | r := evalf(66441/46981); |
We see that six decimal places agree.
(b) What is the next element in the sequence?
As the previous number is correct up to six decimal places, we evaluate sqrt(2) with 7 decimal places before converting it to a rational number:
| > | convert(evalf(sqrt(2),7),rational); |
4. Do q := (x/y - 1)/(y/x - 1); and consider the expression assigned to q.
| > | q := (x/y - 1)/(y/x - 1); |
(a) Give the Maple command(s) to display the internal representation of this expression.
| > |
PROD(135277496,5)
SUM(135277424,5)
PROD(135277400,5)
NAME(135011340,4): x
INTPOS(3,2): 1
NAME(135232876,4): y
INTNEG(-1,2): -1
INTPOS(3,2): 1
INTNEG(-1,2): -1
INTPOS(3,2): 1
INTPOS(3,2): 1
SUM(135277472,5)
PROD(135277448,5)
NAME(135232876,4): y
INTPOS(3,2): 1
NAME(135011340,4): x
INTNEG(-1,2): -1
INTPOS(3,2): 1
INTNEG(-1,2): -1
INTPOS(3,2): 1
INTNEG(-1,2): -1
(b) Draw the directed acyclic graph which represents this expression.
See the handout on paper.
(c) Explain the outcome of subs(-1=+2,q). Why are all the divisions gone?
| > |
| > |
Maple represents every object only once. Not only do the coefficients "-1" turn into "+2", but also the divisions disappear, because a division is represented as a power product with a negative exponent for the denominator.
5. Let
. Give all Maple commands and their output when answering the questions below.
| > | ![]() |
(a) Convert
into a Horner form.
| > |
(b) Compare to the given form of
, how many arithmetical operations are gained when using the Horner form of
to evaluate
| > |
| > |
| > |
We gained 28 multiplications at the expense of one division.
(c) What is the most efficient way to evaluate
?
| > |
t1 = x*x;
t2 = t1*t1;
t4 = t2*t2;
t10 = t2*x;
t18 = (t4*t2*t1-8.0*t4*t2+9.0*x)/(t4*t10+14.0*t2*t1*x-3.0*t10);
Here we count only 14 multiplications, 4 additions, and one division.
6. Consider the polynomials
and
(a) Are these polynomials the same or are they different?
| > | p := x^2 - 7/4; q := x^2 - 1.75; |
They look different, but
| > |
they are only the same if 1.75 = 7/4. In computer algebra 7/4 is an exact rational number and consequently p is a polynomial with coefficients in the rational number field, whereas 1.75 is regarded as a floating-point number of limited precision, here by default 10. So the polynomial q is seen by Maple as a polynomial with floating-point real coefficients.
(b) Explain why the outcome of factor is then so different.
The polynomial p has rational coefficients, we call it a rational polynomial.
The polynomial p has real floating-point coefficients, we call it a real polynomial.
| > |
| > |
The rational polynomial p has no rational roots, so it does not factor over the rational numbers.
The real polynomial q has two real roots, so it factors.