Ruggero Turra
Ruggero Turra

Reputation: 17670

calculate midpoint

Why in the bisection method it is better to compute the midpoint c between a and b with

c = a + (b - a) / 2.

instead of the simpler:

c = (a + b) / 2.

all variables are floating points.

Upvotes: 5

Views: 1055

Answers (1)

tenfour
tenfour

Reputation: 36896

it is to avoid any potential overflows / loss of precision in intermediate calculations.

Upvotes: 6

Related Questions