Questions / Quant development, Numerics & testing

Recover the small root without cancellation

Challenge, about 10 minutes. Question D161.

For x² − 10x + 1 = 0, compute the small root with 2/(B + √(B² − 4)), B = 10.

Answer it in the app It's free. You get hints, a second try if you miss, and a follow-up question.

Show the answer and worked solution

Answer: 0.101 value

  1. √(100 − 4) = √96 ≈ 9.79796.
  2. B + √(B² − 4) ≈ 19.79796.
  3. 2/19.79796 ≈ 0.101021.

Interview shortcut. 2/(10 + √96) ≈ 0.1010.

Takeaway. Rewrite to avoid subtracting nearly equal numbers.

In the app this has a follow-up where one thing about the setup changes. Try the follow-up.

More numerics & testing questions