4
$\begingroup$

I am taking pre-calculus at my school. We are required to use Mathematica. We have been doing simple stuff to get used to this program. Before this, I have never have used it.

Here what I have been inputting:

x1 = 2; y = 3; x2 = 4; y2 = 6;

For the slope I input

(y2 - y1) / (x2 - x1) 

and evaluate with shift-enter. I get 1.5 on the next line.

I am trying to figure out how to compute the midpoint, I know the formula is

(x1 + x1/2), (y1 + y2/2)

I want the midpoint as coordinates, (x,y)

How can I make this computation?

$\endgroup$
2
  • $\begingroup$ see Mean in the docs. $\endgroup$
    – kglr
    Mar 3 '17 at 20:27
  • $\begingroup$ I want to thank everyone who contributed to this post. Thanks again Goldberg and Stork for helping me out. I will be sure to return here for my questions! $\endgroup$
    – J. Doe
    Mar 6 '17 at 17:36
6
$\begingroup$

Defining a function for midpoint, as D. G. Stork suggests, is good idea, but maybe too advanced for where you are in your Mathematica experience. So let's save function definition for the future and keep things simple.

A point in the xy-plane can be represented in Mathematica by list of two elements written as {x, y}. Lists can be added and subtracted just like individual numbers. Starting with the coordinates you give

x1 = 2; y2 = 3; x2 = 4; y2 = 6;

we can define two points, pt1 and pt2.

pt1 = {x1, y1}; pt2 = {x2, y2};

It is known from coordinate geometry that the midpoint of line segment bounded by two points, pt1 and pt2, is the mean point between p1 and p2, where "mean" is another word for average. So your midpoint is just

(pt1 + pt2)/2

{3, 9/2}

Advaced topic — applying symbolic computation to your problem.

Mathematica can do symbolic as well as numerical computation. We can use this capability to generate the midpoint formula from the geometric definition.

The symbols used in symbolic computation must be value-free, that is, not have numbers assigned to them. The function Clear makes symbols value-free.

Clear[x1, y1, x2, y2]
pt1 = {x1, y1}; pt2 = {x2, y2};
(pt1 + pt2)/2

{(x1 + x2)/2, (y1 + y2)/2}

$\endgroup$
4
$\begingroup$

You have a typo in your formula for the mid-point.

When fixed, then use:

midPoint[x1_,x2_,y1_,y2_]:= {(x1+x2)/2, (y1+y2)/2}

midPoint[2,4,3,6]

*)

{3, 9/2}

*)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.