0% found this document useful (0 votes)
80 views

MATH 211 Assignment 1

This document provides the details of Assignment 01 for the Numerical Analysis I course at the University of Saskatchewan. The assignment consists of 7 questions involving MATLAB coding and calculations with floating point numbers. Students are asked to write MATLAB functions, plot functions, perform iterative calculations, and evaluate polynomials to examine properties of floating point arithmetic including machine epsilon and whether operations are associative.

Uploaded by

James Hom
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
80 views

MATH 211 Assignment 1

This document provides the details of Assignment 01 for the Numerical Analysis I course at the University of Saskatchewan. The assignment consists of 7 questions involving MATLAB coding and calculations with floating point numbers. Students are asked to write MATLAB functions, plot functions, perform iterative calculations, and evaluate polynomials to examine properties of floating point arithmetic including machine epsilon and whether operations are associative.

Uploaded by

James Hom
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

University of Saskatchewan

Department of Mathematics and Statistics


Numerical Analysis I
(MATH 211)
Instructor: Dr. Raymond J. Spiteri
ASSIGNMENT 01
Due: 8:30 a.m. Tuesday, January 26, 2021
1. [10 marks] In Matlab, define z = [10 40 20 80 30 70 60 90].
(a) What vectors are specified by z(1:2:7), z(7:-2:1), and z([3 1 4 8 1]). Ex-
plain your answers.
(b) What is z after each of the following commands? Explain your answers.
z(1:2:7) = zeros(1,4)
z(7:-2:1) = zeros(1,4)
z([3 1 4 8 1]) = zeros(1,5)
2. [20 marks] A barn is a unit of area equal to 10−28 m2 used by nuclear physicists to
measure effective cross-sections of very small particles.1
Explain how this unit could be derived from the size of the atomic nucleus.
A parsec is a unit of length equal to 3.261584 light-years used by astronomers to
measure faraway objects such as galaxies.2
Draw a figure to explain the concept of parallax and illustrate a parsec.
Given that the speed of light is defined to be 299,792,458 m/s and a teaspoon is 5 ml,
write a Matlab function

function tsp = bMpc2tsp(bMPc)

to convert barn-megaparsecs (bMpc) to teaspoons (tsp).


Use bMpc2tsp to give the equivalent in tsp of 3 bMpc.
3. [20 marks] Define a function f (x) in Matlab using a function handle

f = @(x) tan(sin(x)) - sin(tan(x))

Plot the function on the interval [−π, π] using ezplot.


Create a plot of f (x) vs. x for x ∈ [−π, π] with spacing π/256. Add the labels y and
x to the y- and x-axes, respectively, and the title “A wiggly function”.
Derive the supremum (least upper bound) of f (x)?
Show how to use the calculations performed in producing your plot to provide confi-
dence in your calculation of the supremum.
1
In their experiments, the nuclear physicists use high-energy particle beams try to hit the side of a barn.
2
A parsec is the distance that produces a parallax of one second.

1
4. [20 marks] The golden ratio (ϕ) has intrigued many people (not just mathematicians!)
for over two millennia. The ratio is purported to occur naturally in many places,
e.g., proportions within animal and human bodies, plants, and shells. The earliest
deliberate use of the golden ratio by humans is considered to be made by Phidias
(490–430 BC) in his construction of the Parthenon statues.
Give an illustration of the golden ratio in terms of line segments.
The golden ratio can be expressed as an infinite continued fraction:
1
ϕ=1+ .
1
1+
1
1+
1
1+
1 + ···

We notice that the (overall) denominator of this expression is in fact ϕ; hence we can
write
1
ϕ=1+ .
ϕ
Solve this equation to derive an analytical formula for ϕ.
Starting from an initial iterate of x = 1, write a Matlab script that implements a
while loop to compute ϕ to within a tolerance tol by the iteration x = 1 + 1/x.
How many iterations does your loop take to converge to within 10eps of ϕ?
5. [10 marks] Using the numbers

a = 2.3371258 × 10−4 , b = 3.3678429 × 102 , c = −3.3677811 × 102 ,

and 8-digit arithmetic, show that floating-point addition (⊕) is not associative, i.e.,

a ⊕ (b ⊕ c) 6= (a ⊕ b) ⊕ c.

You may assume that “8-digit arithmetic” means the answer is rounded off to 8 digits
after each operation. For example, 1.2345678 + 0.12345678 = 1.3580246.
6. [10 marks] On a certain computer, the distance between 7 and the next larger
floating-point number is 2−12 . What is machine epsilon on that computer? What
is the distance between 70 and the next larger floating-point number on that com-
puter? Assume of course that the computer represents numbers in base 2.
7. [10 marks] Literally evaluate the polynomial

p(x) = x3 − 6x2 + 3x − 0.149

at x = 4.71 using 3-digit arithmetic. What is the relative error in your answer? Now
evaluate p(x) using Horner’s algorithm and 3-digit arithmetic. What is the relative
error now? Is the more efficient calculation more accurate as well?

You might also like