Docsity

Newton Binomial Theorem - Assignment 1 | CMSC 878R, Assignments of Computer Science

Toggle sidebar
bg1
CMSC878R/AMSC698R Homework 1
This is similar to the simple example given in class. The goal is to develop fast algorithms for the
following matrix-vector product
v=Au,(1)
where
vi=
N
X
j=1
uj(xi−xj)n,j=1, ..., N, (2)
and
A=
0(x1−x2)n(x1−x3)n... (x1−xN)n
(x2−x1)n0(x2−x3)n... (x2−xN)n
(x3−x1)n(x3−x2)n0... (x3−xN)n
... ... ... ... ...
(xN−x1)n(xN−x2)n(xN−x3)n... 0
,u=
u1
u2
u3
...
uN
,v=
v1
v2
v3
...
vN
.
(3)
Here x1, ..., xN,u
1, ..., uN,are given. The matrix dimension N>0,and the power, n>0,are given
(fixed) positive integers.
1. Derive a formula that can be used for developing a “fast” (O(N)) method for arbitrary n.
2. Write a program that implements both straightforward computation based on Eq. (2) and the
“Fast” method. Use Matlab. Be sure that you can vary x1,..., xN,and u1, ..., uN.
3. Check that both methods produce the same results (within machine precision). Plot the absolute
maximum error between the straightforward and the “Fast” method for n=5and Nvarying
between 102and 103.
4. Plot a comparison of the CPU time required by the straightforward and the “Fast” methods for
n=5and Nvarying between 102and 103for the straightforward method, and with Nvar ying
between 102and 104for the “Fast” method. Make the plots log-log. Also plot lines corresponding
to linear and quadratic dependences of the CPU time on Nand compare with your computational
results.
5. Make a conclusion about the asymptotic complexity of each method.
Hints
1. Use the Newton binomial theorem
(a+b)n=an+µn
1an−1b+µn
2an−2b2+... +bn=
n
X
k=0 µn
kan−kbk,(4)
where the binomial coefficients are
µn
k=n(n−1)...(n−k+1)
1·2·... ·k=n!
(n−k)!k!.(5)
2. For CPU time measurement use the Matlab function cputime (see Matlab help).
1

Partial preview of the text

Download Newton Binomial Theorem - Assignment 1 | CMSC 878R and more Assignments Computer Science in PDF only on Docsity!

CMSC878R/AMSC698R Homework 1

This is similar to the simple example given in class. The goal is to develop fast algorithms for the

following matrix-vector product

v = Au, (1)

where

vi =

N X

j=

uj (xi − xj )

n , j = 1, ..., N, (2)

and

A =

0 (x 1 − x 2 ) n (x 1 − x 3 ) n ... (x 1 − xN ) n

(x 2 − x 1 )

n 0 (x 2 − x 3 )

n ... (x 2 − xN )

n

(x 3 − x 1 )

n (x 3 − x 2 )

n 0 ... (x 3 − xN )

n

(xN − x 1 )

n (xN − x 2 )

n (xN − x 3 )

n ... 0

, u =

u 1

u 2

u 3

...

uN

, v =

v 1

v 2

v 3

...

vN

Here x 1 , ..., xN , u 1 , ..., uN , are given. The matrix dimension N > 0 , and the power, n > 0 , are given

(fixed) positive integers.

  1. Derive a formula that can be used for developing a “fast” (O(N)) method for arbitrary n.
  2. Write a program that implements both straightforward computation based on Eq. (2) and the

“Fast” method. Use Matlab. Be sure that you can vary x 1 , ..., xN , and u 1 , ..., uN.

  1. Check that both methods produce the same results (within machine precision). Plot the absolute

maximum error between the straightforward and the “Fast” method for n = 5 and N varying

between 10

2 and 10

3 .

  1. Plot a comparison of the CPU time required by the straightforward and the “Fast” methods for

n = 5 and N varying between 10 2 and 10 3 for the straightforward method, and with N varying

between 10 2 and 10 4 for the “Fast” method. Make the plots log-log. Also plot lines corresponding

to linear and quadratic dependences of the CPU time on N and compare with your computational

results.

  1. Make a conclusion about the asymptotic complexity of each method.

Hints

  1. Use the Newton binomial theorem

(a + b)

n = a

n

μ n

1

a

n− 1 b +

μ n

2

a

n− 2 b

2

  • ... + b

n

n X

k=

μ n

k

a

n−k b

k , (4)

where the binomial coefficients are

μ n

k

n(n − 1)...(n − k + 1)

1 · 2 · ... · k

n!

(n − k)!k!

  1. For CPU time measurement use the Matlab function cputime (see Matlab help).