Rates of Convergence¶
Copyright (C) 2020 Andreas Kloeckner
MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import numpy as np
C = 1/2
e0 = 0.1*np.random.rand()
rate = 1
e = e0
for i in range(20):
print(e)
e = C*e**rate
0.00216056864310018 0.00108028432155009 0.000540142160775045 0.0002700710803875225 0.00013503554019376126 6.751777009688063e-05 3.3758885048440315e-05 1.6879442524220158e-05 8.439721262110079e-06 4.219860631055039e-06 2.1099303155275197e-06 1.0549651577637599e-06 5.274825788818799e-07 2.6374128944093996e-07 1.3187064472046998e-07 6.593532236023499e-08 3.2967661180117495e-08 1.6483830590058748e-08 8.241915295029374e-09 4.120957647514687e-09
- What do you observe about the number of iterations it takes to decrease the error by a factor of 10 for
rate=1,2,3
? - Is there a point to faster than cubic convergence?
Now let's see if we can figure out the convergence order from the data.
Here's a function that spits out some fake errors of a process that converges to $q$th order:
def make_rate_q_errors(q, e0, n=10, C=0.7):
errors = []
e = e0
for i in range(n):
errors.append(e)
e = C*e**q
return errors
errors = make_rate_q_errors(1, e0)
for e in errors:
print(e)
0.00216056864310018 0.001512398050170126 0.0010586786351190881 0.0007410750445833616 0.0005187525312083531 0.00036312677184584713 0.00025418874029209295 0.00017793211820446505 0.00012455248274312553 8.718673792018786e-05
for i in range(len(errors)-1):
print(errors[i+1]/errors[i])
0.7 0.7 0.7 0.6999999999999998 0.7 0.6999999999999998 0.7 0.7 0.7