Number Approximation - Exercises
1.Numbers
Exercise 1.
Define one-to-one correspondences between the following
sets of numbers:
-
,
Solution. ,
is one-to-one.
-
,
Solution. ,
with defined by is one possibility. Introducing
as the integer part of ,
i.e. with ,
can be expressed as
In Julia
is integer division, so for
,
and % is the modulo operator
∴ |
[4÷5 4÷4 4÷3 4÷2; 4%5 4%4 4%3 4%2] |
∴ |
function f(n)
q = n÷2; r = n%2; s = 1-2*r;
s*(q+r)
end |
∴ |
N=10; [collect(0:N)'; f.(0:N)'] |
|
(2) |
-
,
Solution. Construct a table and introduce diagonal traversal to
obtain the positive rationals .
From above deduce .
Exercise 2.
Provide an example to show .
Exercise 3. Let
. Answer the following questions
analytically. Also provide a Julia implementation.
-
Define a one-to-one correspondence
-
Let , . Assume .
Express in terms of
.
-
Assume .
Express in terms of
.
Exercise 4.
Construct a one-to-one representation of the positions of
atoms within an hexagonal lattice, .
Implement and
as Julia functions. Use to construct
a graphical representation of a two-dimensional hexagonal
lattice.
Exercise 5.
Construct a one-to-one representation of the positions of
atoms within an hexagonal lattice, .
Implement and
as Julia functions. Use to construct
a graphical representation of a three-dimensional hexagonal
lattice.
2.Approximation
Exercise 6. Write
Julia code to compute machine epsilon
for Float32 and Float64.
Exercise 7. Carry
out a numerical experiment to verify the Axiom of floating point
arithmetic within Float32, by computing
in Float32 and comparing to the result in Float64.
Construct a scatter plot of with the
error in computing
in Float32.
Exercise 8.
Consider the approximations of
-
Write Julia functions to compute ,
.
-
Determine if
for all .
-
Determine if ( is machine epsilon). Is the floating
point axiom verified?
-
Determine if . Is the floating
point axiom verified?
Exercise 9.
Consider the approximations of
given by Wallis's product
-
Find the general term .
-
Determine if
for all .
-
Determine if ( is machine epsilon). Is the floating
point axiom verified?
-
Determine if . Is the floating
point axiom verified?
Exercise 10.
Consider the approximations of
given by Pippenger's product
-
Find the general term .
-
Determine if
for all .
-
Determine if ( is machine epsilon). Is the floating
point axiom verified?
-
Determine if . Is the floating
point axiom verified?
3.Successive approximations
Exercise 11.
Assume errors in successive numerical approximation of , finite,
are given by ,
.
-
Construct a scatter plot of . Does the plot indicate convergence of
the numerical approximation?
-
Compute .
-
Suppose . What is
an upper bound for ?
Exercise 12.
Assume errors in successive numerical approximation of , finite,
are given by ,
.
-
Construct a scatter plot of . Does the plot indicate convergence of
the numerical approximation?
-
Compute .
-
Suppose . What is
an upper bound for ?
Exercise 13.
Consider a sequence of successive approximations of the
derivative
-
Is
a convergent sequence?
-
Is
a Cauchy sequence?
-
Construct a scatter plot of for ,
.
Does the plot indicate convergence of ?
-
Construct a scatter plot of , ,
for ,
.
Does the plot indicate convergence of ?
Exercise 14.
Consider errors in successive approximations
given by ,
i.e., errors at each step accumulate errors in previous two steps,
with .
Is this a convergent approximation? Present both an analytical
solution, and a numerical experiment.
Exercise 15.
Consider errors in successive approximations
given by ,
i.e., errors at each step are a weighted average of those in previous
two steps, with .
Is this a convergent approximation? Present both an analytical
solution, and a numerical experiment.
Exercise 16.
Consider errors in successive approximations
given by ,
i.e., errors at each step are less than a weighted average of those in
previous two steps, with .
Is this a convergent approximation? Present both an analytical
solution, and a numerical experiment.