Function | Interval | Bisection Method | Secant Method | ||
---|---|---|---|---|---|
Root | Iterations | Root | Iterations | ||
$x^2 - 9$ | $[0,5]$ | ||||
$x^5 - x - 1$ | $[1,2]$ | ||||
$xe^{-x}$ | $[-1,2]$ | ||||
$2\cos(3x)-e^{x}$ | $[0,6]$ | ||||
$(x-1)^5$ | $[0,3]$ | ||||
$xe^{-x}$ | $[-1.5,1]$ |
In the above table, you can see that the secant method can be either faster or slower than bisection. You may also observe convergence failures: either convergence to a value that is not near a root or convergence to a value substantially less accurate than expected. Regarding the bisection roots as accurate, are there any examples of convergence to a value that is not near a root in the table? If so, which? Are there any examples of inaccurate roots? If so, which?
Size (N) | Time (ms) | |
---|---|---|
Gauss Elimination | Gauss Seidel | |
100 | ||
200 | ||
300 | ||
400 | ||
500 | ||
1000 | ||
5000 | ||
10000 | ||
20000 |
import time
import numpy as np
st_time = time.time()
# Put your code here. For example, multiplying two matrices!
A = np.random.uniform(-10., 10., (5000,1000))
B = np.random.uniform(-20., 20., (1000, 700))
C = A.dot(B)
print 'Time taken to multiply A(5000,1000) and B(1000, 700): ', \
time.time() - st_time, ' s.'
# When you do your own code, replace the above lines with your code