Subjects numerical methods

Bisection Sqrt5

Step-by-step solutions with LaTeX - clean, fast, and student-friendly.

Search Solutions

Bisection Sqrt5


1. **State the problem:** We want to find the square root of 5 using the bisection method with a tolerance of $10^{-2}$. This means we want to find $x$ such that $x^2 = 5$ with an error less than 0.01. 2. **Set up the function:** Define $f(x) = x^2 - 5$. We want to find the root of $f(x)$, i.e., where $f(x) = 0$. 3. **Choose initial interval:** Since $2^2 = 4 < 5$ and $3^2 = 9 > 5$, the root lies in the interval $[2, 3]$. 4. **Bisection method steps:** - Compute midpoint $m = \frac{a+b}{2}$. - Evaluate $f(m)$. - If $|f(m)| < 0.01$, stop; $m$ is the approximate root. - Else, if $f(a)f(m) < 0$, set $b = m$; else set $a = m$. - Repeat until tolerance is met. 5. **MATLAB code example:** ```matlab f = @(x) x.^2 - 5; a = 2; b = 3; tol = 1e-2; while (b - a)/2 > tol m = (a + b)/2; if abs(f(m)) < tol break; elseif f(a)*f(m) < 0 b = m; else a = m; end end root = (a + b)/2; disp(root) ``` 6. **Result:** Running this code will give an approximate square root of 5 with error less than 0.01. **Final answer:** The approximate square root of 5 is about $2.236$ with tolerance $10^{-2}$.