Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 756
Ruggero Turra Avatar asked Oct 31 '10 17:10

Ruggero Turra


People also ask

What is the midpoint formula example?

Let us look at this example and find the midpoint of two points in one-dimensional axis. Suppose, we have two points, 5 and 9, on a number line. The midpoint will be calculated as: (5 + 9)/2 = 14/2 = 7. So, 7 is the midpoint of 5 and 9.

What is the midpoint of A and B?

To answer what the midpoint of AB is, simply replace the values in the formula to find the coordinates of the midpoint. In this case these are (2 + 4) / 2 = 3 and (6 + 18) / 2 = 12. So (xM, yM) = (3, 12) is the midpoint of the segment defined by A and B.


1 Answers

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

like image 56
tenfour Avatar answered Sep 20 '22 06:09

tenfour