>
(4)
>
>
>
(6)
>
>
(5)
>
(1)
>
(2)
(3)
>
>
Douglas Piranha, student ID 987654321
restart
(a) part (i)
direct_sum := proc( G :: posint , delta :: positive )
#Sum the series (-1)^j * ( 1 + j )^(-h), j = 0,1,...
local j :
local h , S , t :
h := evalf( ( 2 + G ) / ( 1 + G ) ) :
S := 1 :
for j from 1 do
t := evalf( ( 1 + j )^(-h) ) :
if t < abs( S ) * delta then
break :
end if :
if type( j , even ) then
S := S + t :
else
S := S - t :
end if :
end do :
return S , j :
end proc :
(a) part (ii)
direct_sum( 1 , 0.5 * 10^(-5) )
direct_sum( 1 , 0.5 * 10^(-6) )
#First result is correct to 5 s.f. but a lot of terms
#are used (so the summation is rather slow).
direct_sum( 5 , 0.5 * 10^(-5) )
direct_sum( 5 , 0.5 * 10^(-6) )
#Same again; number of terms is even larger
direct_sum( 20 , 0.5 * 10^(-5) )
direct_sum( 20 , 0.5 * 10^(-6) )
Overall, we do get accurate results - we get five correct s.f. with delta = 0.5 * 10^(-5)
in all three cases. However, the method is not very efficient. A very large number of
terms are used, and this gets worse as G is increased.
Part (b)
(i) We start by writing
(1 + x)−p−1 =
∞∑
n=0
cnx
n.
Letting x→ 0 shows that c0 = 1. Differentiating j times, we find that
(−p− 1)(−p− 2) · · · (−p− j)︸ ︷︷ ︸
j terms
(1 + x)−p−j−1 =
∞∑
n=j
cn n(n− 1) · · · (n− j + 1)︸ ︷︷ ︸
j terms
xn−j.
Letting x→ 0 shows causes all terms on the right-hand side to vanish, except the term with
n = j. Hence,
cjj! = (−1)j(p + 1)(p + 2) · · · (p + j) = (−1)j (p + j)!
p! .
Consequently,
(1 + x)−p−1 =
∞∑
n=0
(p + n)!
n!p! (−x)
n
=
∞∑
n=0
(
p + n
p
)
(−x)n.
Setting x = −1/2, this becomes
2p+1 =
∞∑
n=0
(
p + n
p
)
1
2n =
∞∑
n=p
(
n
p
)
1
2n−p .
The result now follows after cancelling a factor 2p.
(ii) The formula is clearly true if n = 0. Assume it holds for n = 0, 1, . . . , k. Then
∆k+1aj = ∆(∆kaj)
= ∆
k∑
p=0
(−1)p
(
k
p
)
aj+p
=
k∑
p=0
(−1)p
(
k
p
)
(aj+p − aj+p+1)
=
(
k∑
p=0
(−1)p
(
k
p
)
aj+p
)
−
(
k∑
p=0
(−1)p
(
k
p
)
aj+p+1
)
=
(
k∑
p=0
(−1)p
(
k
p
)
aj+p
)
+
(
k+1∑
p=1
(−1)p
(
k
p− 1
)
aj+p
)
= aj +
(
k∑
p=1
(−1)p
(
k
p
)
aj+p
)
+
(
k∑
p=1
(−1)p
(
k
p− 1
)
aj+p
)
+ (−1)k+1aj+k+1.
Now (
k
p
)
+
(
k
p− 1
)
= (k + 1)!
p!(k − p + 1)!
=
(
k + 1
p
)
,
1
and using this we obtain
∆k+1aj = aj +
k∑
p=1
(−1)p
(
k + 1
p
)
aj+p + aj+k+1 =
k+1∑
p=0
(−1)p
(
k + 1
p
)
aj+p.
Hence, the result holds for all k + 1, and so by induction it holds for all n.
(iii) Using the formula for ∆na0, we find that
∞∑
n=0
∆na0
2n+1 =
∞∑
n=0
1
2n+1
n∑
p=0
(−1)p
(
n
p
)
aj+p.
Changing the order of the summations, this becomes
∞∑
n=0
∆na0
2n+1 =
∞∑
p=0
(−1)pap
∞∑
n=p
1
2n+1
(
n
p
)
=
∞∑
p=0
(−1)pap,
having used the result of part (i).
2
>
>
>
(8)
>
>
(10)
(7)
>
(12)
>
(9)
>
(11)
>
>
part (c)
tabular_sum := proc( G :: posint , delta :: positive )
#Series sum as in part (a), using tabulation method
local j , p :
local h , S :
local T := table() :
h := evalf( ( 2 + G ) / ( 1 + G ) ) :
S := 0 :
for j from 0 do
#Note: here we make this a bit more efficient
#by dividing column 0 by 2, column 1 by 4, etc.
T[j,0] := 0.5 * evalf( ( 1 + j )^(-h) ) :
for p from 1 to j do
T[j,p] := 0.5 * ( T[j-1,p-1] - T[j,p-1] ) :
end do :
if abs( T[j,j] ) < delta * abs( S ) then
break :
end if :
S := S + T[j,j] :
end do :
return S , j :
end proc :
tabular_sum( 1 , 0.5 * 10^(-5) )
tabular_sum( 1 , 0.5 * 10^(-6) )
#Similar to results from part (a), but the number
#of terms summed is much smaller.
tabular_sum( 5 , 0.5 * 10^(-5) )
tabular_sum( 5 , 0.5 * 10^(-6) )
#Same again; number of terms doesn't seem to be
#affected by G.
tabular_sum( 20 , 0.5 * 10^(-5) )
tabular_sum( 20 , 0.5 * 10^(-6) )
#Try with large G and very small delta