randRange( -8, 7 ) randRange( -7, 8 ) randRange( -9, 8 ) randRange( -9, 8 ) ( X1 + X2 ) / 2 ( Y1 + Y2 ) / 2 { color: BLUE, stroke: BLUE, fill: BLUE } { color: GREEN, stroke: GREEN, fill: GREEN, strokeWidth: 1.5 } { color: PURPLE, stroke: PURPLE, fill: PURPLE, strokeWidth: 1.5 }

Point `\blue{A}` is at `\blue{(X1, Y1)}` and point `\green{B}` is at `\green{(X2, Y2)}`.

What is the midpoint of line segment `\overline{AB}`?

graphInit({ range: 10, scale: 20, tickStep: 1, labelStep: 1, unityLabels: false, labelFormat: function( s ) { return "\\small{" + s + "}"; }, axisArrows: "<->", }); path([ [ X1, Y1 ], [ X2, Y2 ] ], {stroke:"#000000"}); style(point1Style); label([X1, Y1], "A", getPos([X1, Y1], [X2, Y2])); circle([X1, Y1], 0.15); style(point2Style); label([X2, Y2], "B", getPos([X2, Y2], [X1, Y1])); circle([X2, Y2], 0.15);

`(`XM, YM`)`

The `x` coordinate of the midpoint is the average of the `x` coordinates of `\blue{A}` and `\green{B}`.

`x = \dfrac{1}{2}(\blue{X1} + \green{X2})`

`x = \dfrac{1}{2}(X1 + X2)`

`x = \purple{XM}`

style( midPtStyle ); graph.vert = path( [ [ XM, -10], [ XM, 10] ] );

The `y` coordinate of the midpoint is the average of the `y` coordinates `\blue{A}` and `\green{B}`.

`y = \dfrac{1}{2}(\blue{Y1} + \green{Y2})`

`y = \dfrac{1}{2}(Y1 + Y2)`

`y = \purple{YM}`

graph.horiz = path( [ [ -10, YM], [ 10, YM ] ] );

The midpoint is `(\purple{XM}, \purple{YM})`.

circle([XM, YM], 0.15); label([XM, YM], "M", getPos([XM, YM], [X1, Y1], true));
graph.vert.remove(); graph.horiz.remove();

Point `\blue{A}` is at `\blue{(X1, Y1)}` and point `\purple{M}` is at `\purple{(XM, YM)}`.
Point `\purple{M}` is the midpoint of point `\blue{A}` and point `\green{B}`.

What are the coordinates of point `\green{B}`?

graphInit({ range: 10, scale: 20, tickStep: 1, labelStep: 1, unityLabels: false, labelFormat: function( s ) { return "\\small{" + s + "}"; }, axisArrows: "<->", }); style(point1Style); label([X1, Y1], "A", getPos([X1, Y1], [XM, YM])); graph.first = circle([X1, Y1], 0.15); style(midPtStyle); label([XM, YM], "M", getPos([XM, YM], [X1, Y1], true)); graph.midpoint = circle([XM, YM], 0.15);

`(`X2, Y2`)`

The average of the `x` coordinates of point `\blue{A}` and point `\green{B}` should be `\purple{XM}`.

`\dfrac{1}{2}(\blue{X1} + \green{x}) = \purple{XM}`

Solving for `\green{x}`:

`\blue{X1} + \green{x} = 2 * XM`

`\green{x} = X2`

style( point2Style ); graph.vert = path( [ [ X2, -10], [ X2, 10] ] );

The average of the `y` coordinates of point `\blue{A}` and point `\green{B}` should be `\purple{YM}`.

`\dfrac{1}{2}(\blue{Y1} + \green{y}) = \purple{YM}`

Solving for `\green{y}`:

`\blue{Y1} + \green{y} = 2 * YM`

`\green{y} = Y2`

graph.horiz = path( [ [ -10, Y2 ], [ 10, Y2 ] ] );

Point `\green{B}` is `(\green{X2}, \green{Y2})`.

path([[X1, Y1], [X2, Y2]], {stroke:"#000000"}); circle([X2, Y2], 0.15); label([X2, Y2], "B", getPos([X2, Y2], [XM, YM])); graph.first.toFront(); graph.midpoint.toFront();
graph.vert.remove(); graph.horiz.remove();