Skip to main content

6.2b Bisection labs

Source: Lab ideas from Computational Physics (Landau, Páez, Bordeianu), §6.1–6.2. Rewritten as original drills — not textbook Bisection.py. Continues 6.2 Bisection search.

Implement interval halving, probe the even square-well residual, and lock EBE_{B}. Stubs fail until filled in.

Use

g(E)=E cot⁡V0−E−V0−Eg(E)=\sqrt{E}\,\cot\sqrt{V_0-E}-\sqrt{V_0-E}

with cot⁡θ=cos⁡θ/sin⁡θ\cot\theta=\cos\theta/\sin\theta (math.sin / math.cos). Hint only: guard against sin⁡κ≈0\sin\kappa\approx 0 if you leave the safe bracket.

Bisection convention for graded output: while (b−a)/2>ε(b-a)/2>\varepsilon with ε=10−14\varepsilon=10^{-14}, set m=(a+b)/2m=(a+b)/2; if f(a) f(m)≤0f(a)\,f(m)\le 0 then b←mb\leftarrow m, else a←ma\leftarrow m (update the stored f(a)f(a)). Return the final midpoint (a+b)/2(a+b)/2.

Formula refresh​

Warm up: pick the matching equation among lookalikes (same walk as the theory lesson).

Labs​

Activity: Bisect a cubic

Find a root of h(x)=x3−x−2h(x)=x^{3}-x-2 on [1,2][1,2] by bisection (ε=10−14\varepsilon=10^{-14}). Print the root with 10 decimals.

No input.

Write-ups​

0/3 solved
6.2b.W1

Using “sign”, “bracket”, and “half”, explain:

In one sentence: what does bisection do with the midpoint when f(x−)f(x)<0f(x_{-})f(x)<0?

Minimum 3 words. Your answer must include: “sign”, “bracket”, “half”.

0 words/ 3 min

Meet the writing requirements, then you can open the model answer.

Explorers​

Figure 6.1 — interval halving.

Next: 6.3 Newton–Raphson search — faster local root-finding (then labs, then §6.5 Lagrange).