Bisection Sqrt3
1. **State the problem:** We want to compute the square root of 3 using the bisection method with a tolerance of $10^{-2}$. The bisection method finds roots of a function by repeatedly halving an interval where the function changes sign.
2. **Define the function:** Let $f(x) = x^2 - 3$. We want to find $x$ such that $f(x) = 0$, which corresponds to $x = \sqrt{3}$.
3. **Choose initial interval:** Since $1^2 = 1 < 3$ and $2^2 = 4 > 3$, the root lies in the interval $[1, 2]$.
4. **Bisection steps:**
- Compute midpoint $m = \frac{a+b}{2}$.
- Evaluate $f(m)$.
- If $f(m) = 0$ or the interval length $|b - a| < 10^{-2}$, stop.
- Otherwise, replace $a$ or $b$ with $m$ depending on the sign of $f(m)$.
5. **MATLAB code snippet:**
```matlab
f = @(x) x.^2 - 3;
a = 1; b = 2;
tol = 1e-2;
while (b - a) / 2 > tol
m = (a + b) / 2;
if f(m) == 0
break;
elseif f(a) * f(m) < 0
b = m;
else
a = m;
end
end
root = (a + b) / 2;
disp(root)
```
6. **Explanation:** The code repeatedly halves the interval $[a,b]$ until the interval length is less than the tolerance $10^{-2}$. The midpoint at the end is an approximation of $\sqrt{3}$.
7. **Final answer:** The approximate square root of 3 with tolerance $10^{-2}$ is about $1.73$.