University of Waterloo
Faculty of Engineering
Department of Electrical and Computer Engineering
MATH 211/MATH 215
Pre-Laboratory 1
Prepared by
Surname, Surname, Legal Given Name(s)
UW Student ID Number: 2NNNNNNN
UW User ID: uwuserid @uwaterloo.ca
2A Electrical/Computer Engineering
9 January 2012
You will note that the number of each question is associated with a section within Laboratory 1 (http://ece.uwaterloo.ca/~math211/Laboratories/01/). The answer for each question can be found in that section.
1.1a Not including the prompts (>>), enter the following into Matlab:
>> 22/7
>> pi
>> sqrt(2)
>> exp(1)
>> format long
>> 22/7
>> pi
>> sqrt(2)
>> exp(1)
>> 22/7
ans =
3.1429
>> pi
ans =
3.1416
>> sqrt(2)
ans =
1.4142
>> exp(1)
ans =
2.7183
>> format long
22/7
ans =
3.142857142857143
>> pi
ans =
3.141592653589793
>> sqrt(2)
ans =
1.414213562373095
>> exp(1)
ans =
2.718281828459046
1.1b Continue to use format long throughout the rest of this pre-laboratory and all `future laboratories unless instructed otherwise. Use Matlab to evaluate the expression
523 – 5 × 522 + 4 × 52 + 78.
>> 52^3 - 5 * 52^2 + 4 * 52 + 78
ans =
127374
1.1c Use Matlab to evaluate the following expression by intelligently assigning one of the numbers to a variable first:
52.8479281533 – 5 × 52.8479281532 + 4 × 52.847928153 + 78
You are, of course, welcome to simplify your life by using variables.
>> x = 52.847928153
x =
52.847928152999998
>> x
x =
52.847928152999998
>> x^3 - 5*x^2 + 4*x + 78
ans =
1.339240382004469e+005
1.1d Demonstrate that the two formulas, and , do in fact give the correct roots by finding the roots of by finding the roots of the polynomial .
(-b+sqrt(b^2-4*a*c))/(2*a);
(-b-sqrt(b^2-4*a*c))/(2*a);
(-2*c)/(b+sqrt(b^2-4*a*c));
(-2*c)/(b-sqrt(b^2-4*a*c));
Ensure you use format long
Copy and paste your Matlab commands and the output here.
1.1e If you want to enter 1020 in Matlab, do you use 10e20 or 1e20?
Enter the correct input here.
1.1f If you want to enter 3.54 × 10-5 in Matlab, do you use 354e-5, 3.54e-5, 0.354e-5 or -3.54e5?
Enter the correct input here.
1.1g Use both formulas to find the roots of the polynomial .
Copy and paste your Matlab commands and the output here.
Are these answers as accurate as the answers in Question 1.1d?
Yes/No
1.1h Consider the output of 3.2i and 3.2j and discuss using j as the imaginary unit in Matlab. Does the choice make a difference?
Yes/No
1.1.2.1a Using the appropriate mathematical functions in Matlab, calculate the following mathematical expressions: e2, tan(1), sin–1(sin(5)), sin (sin–1(5)), ln(e-2 + 3j).
Copy and paste your Matlab commands and the output here.
1.1.2.1b Compare the output of atan(3/(-2)), atan(-3/2), atan2(-3,2),
atan2(3,-2), atan2( 3, -2 ) - pi.
Copy and paste your Matlab commands and the output here.
1.1.2.2a If z = 5.32 – 3.24j, demonstrate that where is the complex conjugate of z; ; , and where and are the real and imaginary parts of z, respectively.
Copy and paste your Matlab commands and the output here.
1.1.2.3a Approximate ln(100!) and 100•ln(100) – 100 in Matlab.
Copy and paste your Matlab commands and the output here.
1.1.3a Using Matlab, what are the absolute and relative errors of 2.718 as an approximation to e (see Question 1.1a)?
Copy and paste your Matlab commands and the output here.
1.1.4a In your own words, describe rounding to n digits. It should be clear from your description that 12750 and 0.08245 round to 12800 and 0.0824 when rounding to three digits of precision.
Your discussion here.
1.1.5a By putting an “x” in the most appropriate column, explain which type of rounding we are using when we round the following numbers to four decimal digits of precision.
Value Four-Decimal Digits of Precision Round
Down 50•••
and
Round
Down 50•••
and
Round
Up Round
Up
0.841470984807897 8.415 × 10-1
485164995.4097903 4.852 × 108
858.515 8.585 × 102
0.00757055 7.571 × 10-3
50.080500 5.008 × 101
31789500. 3.179 × 107
1.1.5b By putting an “x” in the most appropriate column, explain which type of rounding we are using when we round the following numbers to five decimal digits of precision.
Value Five-Decimal Digits of Precision Round
Down 50•••
and
Round
Down 50•••
and
Round
Up Round
Up
0.841470984807897 8.4147 × 10-1
485164995.4097903 4.8516 × 108
858.515 8.5852 × 102
0.00757055 7.5706 × 10-3
50.080500 5.0080 × 101
31789500. 3.1790 × 107
1.2.1a What number is represented by +654321 represented as a number in the form m.nnn × 10ee?
m.nnn × 10ee
1.2.1.1a Using Matlab, what is the ratio between the largest positive floating-point number +999999 and the smallest positive (denormalized) floating-point number +000001?
Copy and paste your Matlab commands and the output here.
1.2.1.2a Assuming we allowed the first digit of the mantissa to be zero; which value is different from the others: +300050, +270500, +285000, +310005, +290500?
Your answer.
1.2.1.3a Sort the following six numbers from smallest (most negative) to largest:
-255617 +665624 -835723 +665623 +187278 -255672
1 2 3 4 5 6
1.2.1.4a Using Matlab, what is the relative error of the floating-point number +522981 as an approximation of e8?
Copy and paste your Matlab commands and the output here.
1.2.2.1a As we have a signed zero, what would the product of -471932 and -000000 ?
Your answer.
1.2.2.2a The result of dividing +001935 by 10 is +000194. What is the result of dividing +001935 by 2?
Your answer.
1.2.2.3a The result of multiplying +991935 by 10 is +990000. What is the result of multiplying +991935 by 2?
Your answer.
1.2.3a What is the result of adding +372583 and +374923?
Your answer.
1.2.3b What is the result of adding +615323 and +619492?
Your answer.
1.2.3c What is the result of multiplying +474500 and +448190?
Your answer.