>> for i=1:14, root(i) = bisect(0,2,10^(-i)); end >> root root = Columns 1 through 7 1.4375 1.4141 1.4150 1.4142 1.4142 1.4142 1.4142 Columns 8 through 14 1.4142 1.4142 1.4142 1.4142 1.4142 1.4142 1.4142 >> for i=1:14, err(i) = root(i)-sqrt(2); end >> format short e >> err err = Columns 1 through 6 2.3286e-002 -1.5106e-004 8.2550e-004 3.2043e-005 -6.1039e-006 5.7184e-007 Columns 7 through 12 3.5401e-008 -1.8515e-009 -9.2017e-010 -4.7055e-011 3.8767e-012 -6.7080e-013 Columns 13 through 14 -4.5519e-014 4.2188e-015 >> for i=1:14, root(i) = newton(5,10^(-i)); end >> for i=1:14, err(i) = root(i)-sqrt(2); end >> err err = Columns 1 through 6 2.7242e-002 2.5742e-004 2.5742e-004 2.3424e-008 2.3424e-008 2.3424e-008 Columns 7 through 12 2.3424e-008 0 0 0 0 0 Columns 13 through 14 0 0 >> [root,x_bisect] = bisect(0,2,10^(-14)); >> [root,x_newton] = newton(5,10^(-14)); >> x_bisect x_bisect = Columns 1 through 6 1.0000e+000 1.5000e+000 1.2500e+000 1.3750e+000 1.4375e+000 1.4063e+000 Columns 7 through 12 1.4219e+000 1.4141e+000 1.4180e+000 1.4160e+000 1.4150e+000 1.4146e+000 Columns 13 through 18 1.4143e+000 1.4142e+000 1.4142e+000 1.4142e+000 1.4142e+000 1.4142e+000 Columns 19 through 24 1.4142e+000 1.4142e+000 1.4142e+000 1.4142e+000 1.4142e+000 1.4142e+000 Columns 25 through 30 1.4142e+000 1.4142e+000 1.4142e+000 1.4142e+000 1.4142e+000 1.4142e+000 Columns 31 through 36 1.4142e+000 1.4142e+000 1.4142e+000 1.4142e+000 1.4142e+000 1.4142e+000 Columns 37 through 42 1.4142e+000 1.4142e+000 1.4142e+000 1.4142e+000 1.4142e+000 1.4142e+000 Columns 43 through 48 1.4142e+000 1.4142e+000 1.4142e+000 1.4142e+000 1.4142e+000 1.4142e+000 >> err_bisect = x_bisect - sqrt(2); >> err_newton = x_newton - sqrt(2); >> x_newton x_newton = Columns 1 through 6 5.0000e+000 2.7000e+000 1.7204e+000 1.4415e+000 1.4145e+000 1.4142e+000 Column 7 1.4142e+000 >> err_bisect err_bisect = Columns 1 through 6 -4.1421e-001 8.5786e-002 -1.6421e-001 -3.9214e-002 2.3286e-002 -7.9636e-003 Columns 7 through 12 7.6614e-003 -1.5106e-004 3.7552e-003 1.8021e-003 8.2550e-004 3.3722e-004 Columns 13 through 18 9.3078e-005 -2.8992e-005 3.2043e-005 1.5255e-006 -1.3733e-005 -6.1039e-006 Columns 19 through 24 -2.2892e-006 -3.8183e-007 5.7184e-007 9.5006e-008 -1.4341e-007 -2.4203e-008 Columns 25 through 30 3.5401e-008 5.5991e-009 -9.3021e-009 -1.8515e-009 1.8738e-009 1.1153e-011 Columns 31 through 36 -9.2017e-010 -4.5451e-010 -2.2168e-010 -1.0526e-010 -4.7055e-011 -1.7951e-011 Columns 37 through 42 -3.3993e-012 3.8767e-012 2.3870e-013 -1.5803e-012 -6.7080e-013 -2.1605e-013 Columns 43 through 48 1.1324e-014 -1.0236e-013 -4.5519e-014 -1.7097e-014 -2.8866e-015 4.2188e-015 >> err_newton err_newton = Columns 1 through 6 3.5858e+000 1.2858e+000 3.0616e-001 2.7242e-002 2.5742e-004 2.3424e-008 Column 7 0 >> diary off