英文:
A bisection recursive function behave not as expected (R)
问题
我尝试使用递归实现一个简单的二分算法。我以为它有效,但后来想测试它与使用while循环的效率。
由于某种原因,递归在条件满足之前停止,而while循环(双关语)执行了我期望的操作。
当尝试将x除以2直到x==0(基本上是计算机的极限)时,x的值停在x = 0.003051758
代码:
# 尝试比较递归和while方法的二分效率
# 但是递归方法的行为方式不符合预期
# 安装包 "tictoc"
# 方法1:递归
bisect <- function(x,epsilon=0){
while(x>epsilon){
cat(x/2,"\n")
return(bisect(x/2))
}
return(x)
}
# 方法2:while
bisectwhile <- function(x,epsilon=0){
while(x>epsilon){
x <- x/2
print(x)
}
return(x)
}
N <- 100
# M1
tictoc::tic()
bisect(N)
tictoc::toc()
#50
#25
#.
#.
#.
#0.003051758
#[1] 0.003051758
# M2
tictoc::tic()
bisectwhile(N)
tictoc::toc()
英文:
I tried to implement a simple bisection algorithm using recursion. I thought it worked but then i wanted to test its efficiency against using while loop.
For some reason, the recursion stops before the condition is met, while the while loop (pun intended) does what i would expect.
When trying to bisect x/2 untill x==0 (the very limit of the computer basically), its tops at value of x = 0.003051758
Code:
# Trying to compare between recursion and while methods of bisection in terms of efficiency
# However the recursion method behaves in an unexpected way
# install.packages("tictoc")
# Mehod 1: recursion
bisect <- function(x,epsilon=0){
while(x>epsilon){
cat(x/2,"\n")
return(bisect(x/2))
}
return(x)
}
# Method 2: while
bisectwhile <- function(x,epsilon=0){
while(x>epsilon){
x <- x/2
print(x)
}
return(x)
}
N <- 100
# M1
tictoc::tic()
bisect(N)
tictoc::toc()
#50
#25
#.
#.
#.
#0.003051758
#[1] 0.003051758
# M2
tictoc::tic()
bisectwhile(N)
tictoc::toc()
答案1
得分: 1
A loop is faster than recursion here:
bisect_recursive <- function(x) if(x == 0) x else bisect_recursive(x/2)
bisect_loop <- function(x) { while(x != 0) x <- x/2; 0 }
Both of which end up at 0, as you can see:
bisect_recursive(100)
#> x is 100
#> x is 50
#> x is 25
#> x is 12.5
#> x is 6.25
#> x is 3.125
#> x is 1.5625
#> x is 0.78125
#> x is 0.390625
#> x is 0.1953125
#> x is 0.09765625
#> x is 0.04882812
#> x is 0.02441406
#> x is 0.01220703
#> x is 0.006103516
#> x is 0.003051758
#> x is 0.001525879
#> x is 0.0007629395
#> x is 0.0003814697
#> x is 0.0001907349
#> x is 9.536743e-05
#> x is 4.768372e-05
#> x is 2.384186e-05
#> x is 1.164153e-05
#> x is 5.820766e-09
#> x is 2.910383e-09
#> x is 1.455192e-09
#> x is 7.275958e-10
#> x is 3.637979e-10
#> x is 1.818989e-10
#> x is 9.094947e-11
#> x is 4.547474e-11
#> x is 2.328306e-11
#> x is 1.164153e-11
#> x is 5.820766e-12
#> x is 2.842171e-12
#> x is 1.421085e-12
#> x is 7.105427e-13
#> x is 3.552714e-13
#> x is 1.776357e-13
#> x is 8.881784e-14
#> x is 4.440892e-14
#> x is 2.220446e-14
#> x is 1.110223e-14
#> x is 5.551115e-15
#> x is 2.775558e-15
#> x is 1.387779e-15
#> x is 6.938894e-16
#> x is 3.469447e-16
#> x is 1.734723e-16
#> x is 8.673617e-17
#> x is 4.336809e-17
#> x is 2.168404e-17
#> x is 1.084202e-17
#> x is 5.421011e-18
#> x is 2.710505e-18
#> x is 1.355253e-18
#> x is 6.776264e-19
#> x is 3.388132e-19
#> x is 1.694066e-19
#> x is 8.470329e-20
#> x is 4.235165e-20
#> x is 2.117582e-20
#> x is 1.058791e-20
#> x is 5.293956e-21
#> x is 2.646978e-21
#> x is 1.323489e-21
#> x is 6.617445e-22
#> x is 3.308722e-22
<details>
<summary>英文:</summary>
A loop is faster than recursion here:
```r
bisect_recursive <- function(x) if(x == 0) x else bisect_recursive(x/2)
bisect_loop <- function(x) { while(x != 0) x <- x/2; 0 }
N <- 100
microbenchmark::microbenchmark(bisect_recursive(N), bisect_loop(N))
#> Unit: microseconds
#> expr min lq mean median uq max neval cld
#> bisect_recursive(N) 916.0 941.95 961.515 953.3 962.8 1334.3 100 b
#> bisect_loop(N) 491.1 499.20 512.297 508.5 516.6 628.1 100 a
If you want to display all the values, try:
bisect_recursive <- function(x) {
cat("x is", x, "\n")
if(x != 0) bisect_recursive(x/2)
}
bisect_loop <- function(x) {
while(x != 0) {
cat("x is", x, "\n")
x <- x/2
}
cat("x is", x, "\n")
}
Both of which end up at 0, as you can see:
bisect_recursive(100)
#> x is 100
#> x is 50
#> x is 25
#> x is 12.5
#> x is 6.25
#> x is 3.125
#> x is 1.5625
#> x is 0.78125
#> x is 0.390625
#> x is 0.1953125
#> x is 0.09765625
#> x is 0.04882812
#> x is 0.02441406
#> x is 0.01220703
#> x is 0.006103516
#> x is 0.003051758
#> x is 0.001525879
#> x is 0.0007629395
#> x is 0.0003814697
#> x is 0.0001907349
#> x is 9.536743e-05
#> x is 4.768372e-05
#> x is 2.384186e-05
#> x is 1.192093e-05
#> x is 5.960464e-06
#> x is 2.980232e-06
#> x is 1.490116e-06
#> x is 7.450581e-07
#> x is 3.72529e-07
#> x is 1.862645e-07
#> x is 9.313226e-08
#> x is 4.656613e-08
#> x is 2.328306e-08
#> x is 1.164153e-08
#> x is 5.820766e-09
#> x is 2.910383e-09
#> x is 1.455192e-09
#> x is 7.275958e-10
#> x is 3.637979e-10
#> x is 1.818989e-10
#> x is 9.094947e-11
#> x is 4.547474e-11
#> x is 2.273737e-11
#> x is 1.136868e-11
#> x is 5.684342e-12
#> x is 2.842171e-12
#> x is 1.421085e-12
#> x is 7.105427e-13
#> x is 3.552714e-13
#> x is 1.776357e-13
#> x is 8.881784e-14
#> x is 4.440892e-14
#> x is 2.220446e-14
#> x is 1.110223e-14
#> x is 5.551115e-15
#> x is 2.775558e-15
#> x is 1.387779e-15
#> x is 6.938894e-16
#> x is 3.469447e-16
#> x is 1.734723e-16
#> x is 8.673617e-17
#> x is 4.336809e-17
#> x is 2.168404e-17
#> x is 1.084202e-17
#> x is 5.421011e-18
#> x is 2.710505e-18
#> x is 1.355253e-18
#> x is 6.776264e-19
#> x is 3.388132e-19
#> x is 1.694066e-19
#> x is 8.470329e-20
#> x is 4.235165e-20
#> x is 2.117582e-20
#> x is 1.058791e-20
#> x is 5.293956e-21
#> x is 2.646978e-21
#> x is 1.323489e-21
#> x is 6.617445e-22
#> x is 3.308722e-22
#> x is 1.654361e-22
#> x is 8.271806e-23
#> x is 4.135903e-23
#> x is 2.067952e-23
#> x is 1.033976e-23
#> x is 5.169879e-24
#> x is 2.584939e-24
#> x is 1.29247e-24
#> x is 6.462349e-25
#> x is 3.231174e-25
#> x is 1.615587e-25
#> x is 8.077936e-26
#> x is 4.038968e-26
#> x is 2.019484e-26
#> x is 1.009742e-26
#> x is 5.04871e-27
#> x is 2.524355e-27
#> x is 1.262177e-27
#> x is 6.310887e-28
#> x is 3.155444e-28
#> x is 1.577722e-28
#> x is 7.888609e-29
#> x is 3.944305e-29
#> x is 1.972152e-29
#> x is 9.860761e-30
#> x is 4.930381e-30
#> x is 2.46519e-30
#> x is 1.232595e-30
#> x is 6.162976e-31
#> x is 3.081488e-31
#> x is 1.540744e-31
#> x is 7.70372e-32
#> x is 3.85186e-32
#> x is 1.92593e-32
#> x is 9.62965e-33
#> x is 4.814825e-33
#> x is 2.407412e-33
#> x is 1.203706e-33
#> x is 6.018531e-34
#> x is 3.009266e-34
#> x is 1.504633e-34
#> x is 7.523164e-35
#> x is 3.761582e-35
#> x is 1.880791e-35
#> x is 9.403955e-36
#> x is 4.701977e-36
#> x is 2.350989e-36
#> x is 1.175494e-36
#> x is 5.877472e-37
#> x is 2.938736e-37
#> x is 1.469368e-37
#> x is 7.34684e-38
#> x is 3.67342e-38
#> x is 1.83671e-38
#> x is 9.18355e-39
#> x is 4.591775e-39
#> x is 2.295887e-39
#> x is 1.147944e-39
#> x is 5.739719e-40
#> x is 2.869859e-40
#> x is 1.43493e-40
#> x is 7.174648e-41
#> x is 3.587324e-41
#> x is 1.793662e-41
#> x is 8.96831e-42
#> x is 4.484155e-42
#> x is 2.242078e-42
#> x is 1.121039e-42
#> x is 5.605194e-43
#> x is 2.802597e-43
#> x is 1.401298e-43
#> x is 7.006492e-44
#> x is 3.503246e-44
#> x is 1.751623e-44
#> x is 8.758115e-45
#> x is 4.379058e-45
#> x is 2.189529e-45
#> x is 1.094764e-45
#> x is 5.473822e-46
#> x is 2.736911e-46
#> x is 1.368456e-46
#> x is 6.842278e-47
#> x is 3.421139e-47
#> x is 1.710569e-47
#> x is 8.552847e-48
#> x is 4.276424e-48
#> x is 2.138212e-48
#> x is 1.069106e-48
#> x is 5.345529e-49
#> x is 2.672765e-49
#> x is 1.336382e-49
#> x is 6.681912e-50
#> x is 3.340956e-50
#> x is 1.670478e-50
#> x is 8.35239e-51
#> x is 4.176195e-51
#> x is 2.088097e-51
#> x is 1.044049e-51
#> x is 5.220244e-52
#> x is 2.610122e-52
#> x is 1.305061e-52
#> x is 6.525304e-53
#> x is 3.262652e-53
#> x is 1.631326e-53
#> x is 8.156631e-54
#> x is 4.078315e-54
#> x is 2.039158e-54
#> x is 1.019579e-54
#> x is 5.097894e-55
#> x is 2.548947e-55
#> x is 1.274474e-55
#> x is 6.372368e-56
#> x is 3.186184e-56
#> x is 1.593092e-56
#> x is 7.96546e-57
#> x is 3.98273e-57
#> x is 1.991365e-57
#> x is 9.956824e-58
#> x is 4.978412e-58
#> x is 2.489206e-58
#> x is 1.244603e-58
#> x is 6.223015e-59
#> x is 3.111508e-59
#> x is 1.555754e-59
#> x is 7.778769e-60
#> x is 3.889385e-60
#> x is 1.944692e-60
#> x is 9.723461e-61
#> x is 4.861731e-61
#> x is 2.430865e-61
#> x is 1.215433e-61
#> x is 6.077163e-62
#> x is 3.038582e-62
#> x is 1.519291e-62
#> x is 7.596454e-63
#> x is 3.798227e-63
#> x is 1.899114e-63
#> x is 9.495568e-64
#> x is 4.747784e-64
#> x is 2.373892e-64
#> x is 1.186946e-64
#> x is 5.93473e-65
#> x is 2.967365e-65
#> x is 1.483682e-65
#> x is 7.418412e-66
#> x is 3.709206e-66
#> x is 1.854603e-66
#> x is 9.273015e-67
#> x is 4.636508e-67
#> x is 2.318254e-67
#> x is 1.159127e-67
#> x is 5.795635e-68
#> x is 2.897817e-68
#> x is 1.448909e-68
#> x is 7.244543e-69
#> x is 3.622272e-69
#> x is 1.811136e-69
#> x is 9.055679e-70
#> x is 4.52784e-70
#> x is 2.26392e-70
#> x is 1.13196e-70
#> x is 5.659799e-71
#> x is 2.8299e-71
#> x is 1.41495e-71
#> x is 7.074749e-72
#> x is 3.537375e-72
#> x is 1.768687e-72
#> x is 8.843437e-73
#> x is 4.421718e-73
#> x is 2.210859e-73
#> x is 1.10543e-73
#> x is 5.527148e-74
#> x is 2.763574e-74
#> x is 1.381787e-74
#> x is 6.908935e-75
#> x is 3.454467e-75
#> x is 1.727234e-75
#> x is 8.636169e-76
#> x is 4.318084e-76
#> x is 2.159042e-76
#> x is 1.079521e-76
#> x is 5.397605e-77
#> x is 2.698803e-77
#> x is 1.349401e-77
#> x is 6.747007e-78
#> x is 3.373503e-78
#> x is 1.686752e-78
#> x is 8.433758e-79
#> x is 4.216879e-79
#> x is 2.10844e-79
#> x is 1.05422e-79
#> x is 5.271099e-80
#> x is 2.635549e-80
#> x is 1.317775e-80
#> x is 6.588874e-81
#> x is 3.294437e-81
#> x is 1.647218e-81
#> x is 8.236092e-82
#> x is 4.118046e-82
#> x is 2.059023e-82
#> x is 1.029512e-82
#> x is 5.147558e-83
#> x is 2.573779e-83
#> x is 1.286889e-83
#> x is 6.434447e-84
#> x is 3.217223e-84
#> x is 1.608612e-84
#> x is 8.043059e-85
#> x is 4.021529e-85
#> x is 2.010765e-85
#> x is 1.005382e-85
#> x is 5.026912e-86
#> x is 2.513456e-86
#> x is 1.256728e-86
#> x is 6.28364e-87
#> x is 3.14182e-87
#> x is 1.57091e-87
#> x is 7.85455e-88
#> x is 3.927275e-88
#> x is 1.963637e-88
#> x is 9.818187e-89
#> x is 4.909093e-89
#> x is 2.454547e-89
#> x is 1.227273e-89
#> x is 6.136367e-90
#> x is 3.068183e-90
#> x is 1.534092e-90
#> x is 7.670459e-91
#> x is 3.835229e-91
#> x is 1.917615e-91
#> x is 9.588073e-92
#> x is 4.794037e-92
#> x is 2.397018e-92
#> x is 1.198509e-92
#> x is 5.992546e-93
#> x is 2.996273e-93
#> x is 1.498136e-93
#> x is 7.490682e-94
#> x is 3.745341e-94
#> x is 1.872671e-94
#> x is 9.363353e-95
#> x is 4.681676e-95
#> x is 2.340838e-95
#> x is 1.170419e-95
#> x is 5.852095e-96
#> x is 2.926048e-96
#> x is 1.463024e-96
#> x is 7.315119e-97
#> x is 3.65756e-97
#> x is 1.82878e-97
#> x is 9.143899e-98
#> x is 4.57195e-98
#> x is 2.285975e-98
#> x is 1.142987e-98
#> x is 5.714937e-99
#> x is 2.857468e-99
#> x is 1.428734e-99
#> x is 7.143671e-100
#> x is 3.571836e-100
#> x is 1.785918e-100
#> x is 8.929589e-101
#> x is 4.464794e-101
#> x is 2.232397e-101
#> x is 1.116199e-101
#> x is 5.580993e-102
#> x is 2.790497e-102
#> x is 1.395248e-102
#> x is 6.976241e-103
#> x is 3.488121e-103
#> x is 1.74406e-103
#> x is 8.720302e-104
#> x is 4.360151e-104
#> x is 2.180075e-104
#> x is 1.090038e-104
#> x is 5.450189e-105
#> x is 2.725094e-105
#> x is 1.362547e-105
#> x is 6.812736e-106
#> x is 3.406368e-106
#> x is 1.703184e-106
#> x is 8.51592e-107
#> x is 4.25796e-107
#> x is 2.12898e-107
#> x is 1.06449e-107
#> x is 5.32245e-108
#> x is 2.661225e-108
#> x is 1.330612e-108
#> x is 6.653062e-109
#> x is 3.326531e-109
#> x is 1.663266e-109
#> x is 8.316328e-110
#> x is 4.158164e-110
#> x is 2.079082e-110
#> x is 1.039541e-110
#> x is 5.197705e-111
#> x is 2.598852e-111
#> x is 1.299426e-111
#> x is 6.497131e-112
#> x is 3.248566e-112
#> x is 1.624283e-112
#> x is 8.121414e-113
#> x is 4.060707e-113
#> x is 2.030353e-113
#> x is 1.015177e-113
#> x is 5.075884e-114
#> x is 2.537942e-114
#> x is 1.268971e-114
#> x is 6.344855e-115
#> x is 3.172427e-115
#> x is 1.586214e-115
#> x is 7.931068e-116
#> x is 3.965534e-116
#> x is 1.982767e-116
#> x is 9.913835e-117
#> x is 4.956918e-117
#> x is 2.478459e-117
#> x is 1.239229e-117
#> x is 6.196147e-118
#> x is 3.098074e-118
#> x is 1.549037e-118
#> x is 7.745184e-119
#> x is 3.872592e-119
#> x is 1.936296e-119
#> x is 9.68148e-120
#> x is 4.84074e-120
#> x is 2.42037e-120
#> x is 1.210185e-120
#> x is 6.050925e-121
#> x is 3.025462e-121
#> x is 1.512731e-121
#> x is 7.563656e-122
#> x is 3.781828e-122
#> x is 1.890914e-122
#> x is 9.45457e-123
#> x is 4.727285e-123
#> x is 2.363643e-123
#> x is 1.181821e-123
#> x is 5.909106e-124
#> x is 2.954553e-124
#> x is 1.477277e-124
#> x is 7.386383e-125
#> x is 3.693191e-125
#> x is 1.846596e-125
#> x is 9.232979e-126
#> x is 4.616489e-126
#> x is 2.308245e-126
#> x is 1.154122e-126
#> x is 5.770612e-127
#> x is 2.885306e-127
#> x is 1.442653e-127
#> x is 7.213265e-128
#> x is 3.606632e-128
#> x is 1.803316e-128
#> x is 9.016581e-129
#> x is 4.50829e-129
#> x is 2.254145e-129
#> x is 1.127073e-129
#> x is 5.635363e-130
#> x is 2.817681e-130
#> x is 1.408841e-130
#> x is 7.044204e-131
#> x is 3.522102e-131
#> x is 1.761051e-131
#> x is 8.805255e-132
#> x is 4.402627e-132
#> x is 2.201314e-132
#> x is 1.100657e-132
#> x is 5.503284e-133
#> x is 2.751642e-133
#> x is 1.375821e-133
#> x is 6.879105e-134
#> x is 3.439553e-134
#> x is 1.719776e-134
#> x is 8.598881e-135
#> x is 4.299441e-135
#> x is 2.14972e-135
#> x is 1.07486e-135
#> x is 5.374301e-136
#> x is 2.68715e-136
#> x is 1.343575e-136
#> x is 6.717876e-137
#> x is 3.358938e-137
#> x is 1.679469e-137
#> x is 8.397345e-138
#> x is 4.198673e-138
#> x is 2.099336e-138
#> x is 1.049668e-138
#> x is 5.248341e-139
#> x is 2.62417e-139
#> x is 1.312085e-139
#> x is 6.560426e-140
#> x is 3.280213e-140
#> x is 1.640106e-140
#> x is 8.200532e-141
#> x is 4.100266e-141
#> x is 2.050133e-141
#> x is 1.025067e-141
#> x is 5.125333e-142
#> x is 2.562666e-142
#> x is 1.281333e-142
#> x is 6.406666e-143
#> x is 3.203333e-143
#> x is 1.601666e-143
#> x is 8.008332e-144
#> x is 4.004166e-144
#> x is 2.002083e-144
#> x is 1.001042e-144
#> x is 5.005208e-145
#> x is 2.502604e-145
#> x is 1.251302e-145
#> x is 6.25651e-146
#> x is 3.128255e-146
#> x is 1.564127e-146
#> x is 7.820637e-147
#> x is 3.910319e-147
#> x is 1.955159e-147
#> x is 9.775796e-148
#> x is 4.887898e-148
#> x is 2.443949e-148
#> x is 1.221975e-148
#> x is 6.109873e-149
#> x is 3.054936e-149
#> x is 1.527468e-149
#> x is 7.637341e-150
#> x is 3.81867e-150
#> x is 1.909335e-150
#> x is 9.546676e-151
#> x is 4.773338e-151
#> x is 2.386669e-151
#> x is 1.193335e-151
#> x is 5.966673e-152
#> x is 2.983336e-152
#> x is 1.491668e-152
#> x is 7.458341e-153
#> x is 3.72917e-153
#> x is 1.864585e-153
#> x is 9.322926e-154
#> x is 4.661463e-154
#> x is 2.330731e-154
#> x is 1.165366e-154
#> x is 5.826829e-155
#> x is 2.913414e-155
#> x is 1.456707e-155
#> x is 7.283536e-156
#> x is 3.641768e-156
#> x is 1.820884e-156
#> x is 9.10442e-157
#> x is 4.55221e-157
#> x is 2.276105e-157
#> x is 1.138052e-157
#> x is 5.690262e-158
#> x is 2.845131e-158
#> x is 1.422566e-158
#> x is 7.112828e-159
#> x is 3.556414e-159
#> x is 1.778207e-159
#> x is 8.891035e-160
#> x is 4.445517e-160
#> x is 2.222759e-160
#> x is 1.111379e-160
#> x is 5.556897e-161
#> x is 2.778448e-161
#> x is 1.389224e-161
#> x is 6.946121e-162
#> x is 3.473061e-162
#> x is 1.73653e-162
#> x is 8.682651e-163
#> x is 4.341326e-163
#> x is 2.170663e-163
#> x is 1.085331e-163
#> x is 5.426657e-164
#> x is 2.713329e-164
#> x is 1.356664e-164
#> x is 6.783321e-165
#> x is 3.391661e-165
#> x is 1.69583e-165
#> x is 8.479152e-166
#> x is 4.239576e-166
#> x is 2.119788e-166
#> x is 1.059894e-166
#> x is 5.29947e-167
#> x is 2.649735e-167
#> x is 1.324867e-167
#> x is 6.624337e-168
#> x is 3.312169e-168
#> x is 1.656084e-168
#> x is 8.280422e-169
#> x is 4.140211e-169
#> x is 2.070105e-169
#> x is 1.035053e-169
#> x is 5.175264e-170
#> x is 2.587632e-170
#> x is 1.293816e-170
#> x is 6.469079e-171
#> x is 3.23454e-171
#> x is 1.61727e-171
#> x is 8.086349e-172
#> x is 4.043175e-172
#> x is 2.021587e-172
#> x is 1.010794e-172
#> x is 5.053968e-173
#> x is 2.526984e-173
#> x is 1.263492e-173
#> x is 6.31746e-174
#> x is 3.15873e-174
#> x is 1.579365e-174
#> x is 7.896825e-175
#> x is 3.948413e-175
#> x is 1.974206e-175
#> x is 9.871032e-176
#> x is 4.935516e-176
#> x is 2.467758e-176
#> x is 1.233879e-176
#> x is 6.169395e-177
#> x is 3.084697e-177
#> x is 1.542349e-177
#> x is 7.711744e-178
#> x is 3.855872e-178
#> x is 1.927936e-178
#> x is 9.639679e-179
#> x is 4.81984e-179
#> x is 2.40992e-179
#> x is 1.20496e-179
#> x is 6.0248e-180
#> x is 3.0124e-180
#> x is 1.5062e-180
#> x is 7.531e-181
#> x is 3.7655e-181
#> x is 1.88275e-181
#> x is 9.413749e-182
#> x is 4.706875e-182
#> x is 2.353437e-182
#> x is 1.176719e-182
#> x is 5.883593e-183
#> x is 2.941797e-183
#> x is 1.470898e-183
#> x is 7.354492e-184
#> x is 3.677246e-184
#> x is 1.838623e-184
#> x is 9.193115e-185
#> x is 4.596557e-185
#> x is 2.298279e-185
#> x is 1.149139e-185
#> x is 5.745697e-186
#> x is 2.872848e-186
#> x is 1.436424e-186
#> x is 7.182121e-187
#> x is 3.59106e-187
#> x is 1.79553e-187
#> x is 8.977651e-188
#> x is 4.488826e-188
#> x is 2.244413e-188
#> x is 1.122206e-188
#> x is 5.611032e-189
#> x is 2.805516e-189
#> x is 1.402758e-189
#> x is 7.01379e-190
#> x is 3.506895e-190
#> x is 1.753447e-190
#> x is 8.767237e-191
#> x is 4.383619e-191
#> x is 2.191809e-191
#> x is 1.095905e-191
#> x is 5.479523e-192
#> x is 2.739762e-192
#> x is 1.369881e-192
#> x is 6.849404e-193
#> x is 3.424702e-193
#> x is 1.712351e-193
#> x is 8.561755e-194
#> x is 4.280878e-194
#> x is 2.140439e-194
#> x is 1.070219e-194
#> x is 5.351097e-195
#> x is 2.675549e-195
#> x is 1.337774e-195
#> x is 6.688871e-196
#> x is 3.344436e-196
#> x is 1.672218e-196
#> x is 8.361089e-197
#> x is 4.180545e-197
#> x is 2.090272e-197
#> x is 1.045136e-197
#> x is 5.225681e-198
#> x is 2.61284e-198
#> x is 1.30642e-198
#> x is 6.532101e-199
#> x is 3.26605e-199
#> x is 1.633025e-199
#> x is 8.165126e-200
#> x is 4.082563e-200
#> x is 2.041282e-200
#> x is 1.020641e-200
#> x is 5.103204e-201
#> x is 2.551602e-201
#> x is 1.275801e-201
#> x is 6.379005e-202
#> x is 3.189502e-202
#> x is 1.594751e-202
#> x is 7.973756e-203
#> x is 3.986878e-203
#> x is 1.993439e-203
#> x is 9.967195e-204
#> x is 4.983597e-204
#> x is 2.491799e-204
#> x is 1.245899e-204
#> x is 6.229497e-205
#> x is 3.114748e-205
#> x is 1.557374e-205
#> x is 7.786871e-206
#> x is 3.893436e-206
#> x is 1.946718e-206
#> x is 9.733589e-207
#> x is 4.866794e-207
#> x is 2.433397e-207
#> x is 1.216699e-207
#> x is 6.083493e-208
#> x is 3.041747e-208
#> x is 1.520873e-208
#> x is 7.604366e-209
#> x is 3.802183e-209
#> x is 1.901092e-209
#> x is 9.505458e-210
#> x is 4.752729e-210
#> x is 2.376364e-210
#> x is 1.188182e-210
#> x is 5.940911e-211
#> x is 2.970456e-211
#> x is 1.485228e-211
#> x is 7.426139e-212
#> x is 3.713069e-212
#> x is 1.856535e-212
#> x is 9.282674e-213
#> x is 4.641337e-213
#> x is 2.320668e-213
#> x is 1.160334e-213
#> x is 5.801671e-214
#> x is 2.900836e-214
#> x is 1.450418e-214
#> x is 7.252089e-215
#> x is 3.626044e-215
#> x is 1.813022e-215
#> x is 9.065111e-216
#> x is 4.532555e-216
#> x is 2.266278e-216
#> x is 1.133139e-216
#> x is 5.665694e-217
#> x is 2.832847e-217
#> x is 1.416424e-217
#> x is 7.082118e-218
#> x is 3.541059e-218
#> x is 1.770529e-218
#> x is 8.852647e-219
#> x is 4.426324e-219
#> x is 2.213162e-219
#> x is 1.106581e-219
#> x is 5.532905e-220
#> x is 2.766452e-220
#> x is 1.383226e-220
#> x is 6.916131e-221
#> x is 3.458065e-221
#> x is 1.729033e-221
#> x is 8.645164e-222
#> x is 4.322582e-222
#> x is 2.161291e-222
#> x is 1.080645e-222
#> x is 5.403227e-223
#> x is 2.701614e-223
#> x is 1.350807e-223
#> x is 6.754034e-224
#> x is 3.377017e-224
#> x is 1.688509e-224
#> x is 8.442543e-225
#> x is 4.221271e-225
#> x is 2.110636e-225
#> x is 1.055318e-225
#> x is 5.276589e-226
#> x is 2.638295e-226
#> x is 1.319147e-226
#> x is 6.595736e-227
#> x is 3.297868e-227
#> x is 1.648934e-227
#> x is 8.24467e-228
#> x is 4.122335e-228
#> x is 2.061168e-228
#> x is 1.030584e-228
#> x is 5.152919e-229
#> x is 2.57646e-229
#> x is 1.28823e-229
#> x is 6.441149e-230
#> x is 3.220574e-230
#> x is 1.610287e-230
#> x is 8.051436e-231
#> x is 4.025718e-231
#> x is 2.012859e-231
#> x is 1.006429e-231
#> x is 5.032147e-232
#> x is 2.516074e-232
#> x is 1.258037e-232
#> x is 6.290184e-233
#> x is 3.145092e-233
#> x is 1.572546e-233
#> x is 7.86273e-234
#> x is 3.931365e-234
#> x is 1.965683e-234
#> x is 9.828413e-235
#> x is 4.914207e-235
#> x is 2.457103e-235
#> x is 1.228552e-235
#> x is 6.142758e-236
#> x is 3.071379e-236
#> x is 1.53569e-236
#> x is 7.678448e-237
#> x is 3.839224e-237
#> x is 1.919612e-237
#> x is 9.59806e-238
#> x is 4.79903e-238
#> x is 2.399515e-238
#> x is 1.199757e-238
#> x is 5.998787e-239
#> x is 2.999394e-239
#> x is 1.499697e-239
#> x is 7.498484e-240
#> x is 3.749242e-240
#> x is 1.874621e-240
#> x is 9.373105e-241
#> x is 4.686553e-241
#> x is 2.343276e-241
#> x is 1.171638e-241
#> x is 5.858191e-242
#> x is 2.929095e-242
#> x is 1.464548e-242
#> x is 7.322738e-243
#> x is 3.661369e-243
#> x is 1.830685e-243
#> x is 9.153423e-244
#> x is 4.576711e-244
#> x is 2.288356e-244
#> x is 1.144178e-244
#> x is 5.720889e-245
#> x is 2.860445e-245
#> x is 1.430222e-245
#> x is 7.151112e-246
#> x is 3.575556e-246
#> x is 1.787778e-246
#> x is 8.93889e-247
#> x is 4.469445e-247
#> x is 2.234722e-247
#> x is 1.117361e-247
#> x is 5.586806e-248
#> x is 2.793403e-248
#> x is 1.396701e-248
#> x is 6.983507e-249
#> x is 3.491754e-249
#> x is 1.745877e-249
#> x is 8.729384e-250
#> x is 4.364692e-250
#> x is 2.182346e-250
#> x is 1.091173e-250
#> x is 5.455865e-251
#> x is 2.727933e-251
#> x is 1.363966e-251
#> x is 6.819832e-252
#> x is 3.409916e-252
#> x is 1.704958e-252
#> x is 8.524789e-253
#> x is 4.262395e-253
#> x is 2.131197e-253
#> x is 1.065599e-253
#> x is 5.327993e-254
#> x is 2.663997e-254
#> x is 1.331998e-254
#> x is 6.659992e-255
#> x is 3.329996e-255
#> x is 1.664998e-255
#> x is 8.32499e-256
#> x is 4.162495e-256
#> x is 2.081247e-256
#> x is 1.040624e-256
#> x is 5.203119e-257
#> x is 2.601559e-257
#> x is 1.30078e-257
#> x is 6.503898e-258
#> x is 3.251949e-258
#> x is 1.625975e-258
#> x is 8.129873e-259
#> x is 4.064936e-259
#> x is 2.032468e-259
#> x is 1.016234e-259
#> x is 5.08117e-260
#> x is 2.540585e-260
#> x is 1.270293e-260
#> x is 6.351463e-261
#> x is 3.175732e-261
#> x is 1.587866e-261
#> x is 7.939329e-262
#> x is 3.969664e-262
#> x is 1.984832e-262
#> x is 9.924161e-263
#> x is 4.962081e-263
#> x is 2.48104e-263
#> x is 1.24052e-263
#> x is 6.202601e-264
#> x is 3.1013e-264
#> x is 1.55065e-264
#> x is 7.753251e-265
#> x is 3.876625e-265
#> x is 1.938313e-265
#> x is 9.691564e-266
#> x is 4.845782e-266
#> x is 2.422891e-266
#> x is 1.211445e-266
#> x is 6.057227e-267
#> x is 3.028614e-267
#> x is 1.514307e-267
#> x is 7.571534e-268
#> x is 3.785767e-268
#> x is 1.892883e-268
#> x is 9.464417e-269
#> x is 4.732209e-269
#> x is 2.366104e-269
#> x is 1.183052e-269
#> x is 5.915261e-270
#> x is 2.95763e-270
#> x is 1.478815e-270
#> x is 7.394076e-271
#> x is 3.697038e-271
#> x is 1.848519e-271
#> x is 9.242595e-272
#> x is 4.621298e-272
#> x is 2.310649e-272
#> x is 1.155324e-272
#> x is 5.776622e-273
#> x is 2.888311e-273
#> x is 1.444156e-273
#> x is 7.220778e-274
#> x is 3.610389e-274
#> x is 1.805194e-274
#> x is 9.025972e-275
#> x is 4.512986e-275
#> x is 2.256493e-275
#> x is 1.128246e-275
#> x is 5.641232e-276
#> x is 2.820616e-276
#> x is 1.410308e-276
#> x is 7.051541e-277
#> x is 3.52577e-277
#> x is 1.762885e-277
#> x is 8.814426e-278
#> x is 4.407213e-278
#> x is 2.203606e-278
#> x is 1.101803e-278
#> x is 5.509016e-279
#> x is 2.754508e-279
#> x is 1.377254e-279
#> x is 6.88627e-280
#> x is 3.443135e-280
#> x is 1.721568e-280
#> x is 8.607838e-281
#> x is 4.303919e-281
#> x is 2.151959e-281
#> x is 1.07598e-281
#> x is 5.379898e-282
#> x is 2.689949e-282
#> x is 1.344975e-282
#> x is 6.724873e-283
#> x is 3.362437e-283
#> x is 1.681218e-283
#> x is 8.406091e-284
#> x is 4.203046e-284
#> x is 2.101523e-284
#> x is 1.050761e-284
#> x is 5.253807e-285
#> x is 2.626904e-285
#> x is 1.313452e-285
#> x is 6.567259e-286
#> x is 3.283629e-286
#> x is 1.641815e-286
#> x is 8.209074e-287
#> x is 4.104537e-287
#> x is 2.052268e-287
#> x is 1.026134e-287
#> x is 5.130671e-288
#> x is 2.565336e-288
#> x is 1.282668e-288
#> x is 6.413339e-289
#> x is 3.206669e-289
#> x is 1.603335e-289
#> x is 8.016673e-290
#> x is 4.008337e-290
#> x is 2.004168e-290
#> x is 1.002084e-290
#> x is 5.010421e-291
#> x is 2.50521e-291
#> x is 1.252605e-291
#> x is 6.263026e-292
#> x is 3.131513e-292
#> x is 1.565757e-292
#> x is 7.828783e-293
#> x is 3.914391e-293
#> x is 1.957196e-293
#> x is 9.785978e-294
#> x is 4.892989e-294
#> x is 2.446495e-294
#> x is 1.223247e-294
#> x is 6.116236e-295
#> x is 3.058118e-295
#> x is 1.529059e-295
#> x is 7.645296e-296
#> x is 3.822648e-296
#> x is 1.911324e-296
#> x is 9.556619e-297
#> x is 4.77831e-297
#> x is 2.389155e-297
#> x is 1.194577e-297
#> x is 5.972887e-298
#> x is 2.986444e-298
#> x is 1.493222e-298
#> x is 7.466109e-299
#> x is 3.733054e-299
#> x is 1.866527e-299
#> x is 9.332636e-300
#> x is 4.666318e-300
#> x is 2.333159e-300
#> x is 1.16658e-300
#> x is 5.832898e-301
#> x is 2.916449e-301
#> x is 1.458224e-301
#> x is 7.291122e-302
#> x is 3.645561e-302
#> x is 1.822781e-302
#> x is 9.113903e-303
#> x is 4.556951e-303
#> x is 2.278476e-303
#> x is 1.139238e-303
#> x is 5.696189e-304
#> x is 2.848095e-304
#> x is 1.424047e-304
#> x is 7.120236e-305
#> x is 3.560118e-305
#> x is 1.780059e-305
#> x is 8.900295e-306
#> x is 4.450148e-306
#> x is 2.225074e-306
#> x is 1.112537e-306
#> x is 5.562685e-307
#> x is 2.781342e-307
#> x is 1.390671e-307
#> x is 6.953356e-308
#> x is 3.476678e-308
#> x is 1.738339e-308
#> x is 8.691695e-309
#> x is 4.345847e-309
#> x is 2.172924e-309
#> x is 1.086462e-309
#> x is 5.432309e-310
#> x is 2.716155e-310
#> x is 1.358077e-310
#> x is 6.790387e-311
#> x is 3.395193e-311
#> x is 1.697597e-311
#> x is 8.487983e-312
#> x is 4.243992e-312
#> x is 2.121996e-312
#> x is 1.060998e-312
#> x is 5.304989e-313
#> x is 2.652495e-313
#> x is 1.326247e-313
#> x is 6.631237e-314
#> x is 3.315618e-314
#> x is 1.657809e-314
#> x is 8.289046e-315
#> x is 4.144523e-315
#> x is 2.072262e-315
#> x is 1.036131e-315
#> x is 5.180654e-316
#> x is 2.590327e-316
#> x is 1.295163e-316
#> x is 6.475817e-317
#> x is 3.237909e-317
#> x is 1.618954e-317
#> x is 8.094772e-318
#> x is 4.047386e-318
#> x is 2.023693e-318
#> x is 1.011846e-318
#> x is 5.059232e-319
#> x is 2.529616e-319
#> x is 1.264808e-319
#> x is 6.32404e-320
#> x is 3.16202e-320
#> x is 1.58101e-320
#> x is 7.90505e-321
#> x is 3.952525e-321
#> x is 1.976263e-321
#> x is 9.881313e-322
#> x is 4.940656e-322
#> x is 2.470328e-322
#> x is 1.235164e-322
#> x is 5.928788e-323
#> x is 2.964394e-323
#> x is 1.482197e-323
#> x is 9.881313e-324
#> x is 4.940656e-324
#> x is 0
<sup>Created on 2023-03-06 with reprex v2.0.2</sup>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论