Exercise
,
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] |
(1)
∴ |
function f(n) q = n÷2; r = n%2; s = 1-2*r; s*(q+r) end |
f
∴ |
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
Exercise
Define a one-to-one correspondence
Let , . Assume . Express in terms of .
Assume . Express in terms of .
Exercise
Exercise
Exercise
∴ |
function MachEps(type) one=type(1.0); half=type(0.5); eps=one; while (one+half*eps != one) eps=half*eps; end return eps; end; |
∴ |
[MachEps(Float32) eps(Float32) MachEps(Float64) eps(Float64)] |
(3)
∴ |
Exercise
The floating point axiom states , with , leading to
or in this case
The operations in are computed in Float64 in the following, with randomly chosen.
∴ |
function ErrPlot(n) pi32=Float32(pi); pi64=Float64(pi); half=Float64(0.5); one=Float64(1.0); rscale = 1.0e3*half; e32 = eps(Float32); r64=Float64.( rscale*(rand(n) .- half) ); r32=Float32.(r64); result32 = pi32 .+ r32; result64 = pi64 .+ r64; ε = result32 ./ result64 .- one; rmin=minimum(r64); rmax=maximum(r64); clf(); plot(r32,ε,".",[rmin rmax],[e32 e32],"dg",[rmin rmax],[-e32 -e32],"dg"); xlabel("r"); ylabel("ε"); title("Float32 addition error"); end; |
∴ |
ErrPlot(1000); savefig(homedir()*"/courses/MATH661/images/E01Fig02.eps") |
∴ |
![]() |
Exercise
Write Julia functions to compute , .
∴ |
function S(n) fact=1.0; sum=1.0; for k=2:n fact = k*fact; sum = sum + 1/fact; end return sum; end; |
∴ |
function T(n) fact=1.0; for k=n:-1:2 fact=k*fact; end sum=0.0; for k=n:-1:1 sum = sum + 1/fact; fact = fact/k; end return sum; end; |
∴ |
Determine if for all .
In , indeed by commutativity (proof by induction). In there must exist some such that for , as a consequence of the existence of machine epsilon. Verify by computation (note organization of computations to use Julia broadcasting and presentation of results in a single table)
∴ |
r=1:8; s=S.(r); t=T.(r); chk = s.==t; [r s t chk] |
(4)
∴ |
Determine if ( is machine epsilon). Is the floating point axiom verified?
Determine if . Is the floating point axiom verified?
Exercise
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
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
Construct a scatter plot of . Does the plot indicate convergence of the numerical approximation?
Compute .
Suppose . What is an upper bound for ?
Exercise
Construct a scatter plot of . Does the plot indicate convergence of the numerical approximation?
Compute .
Suppose . What is an upper bound for ?
Exercise
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
Exercise
Exercise