HP Forums

Full Version: Using linear regression to find the intersection of two lines
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

Using linear regression to find the intersection of two 2-d
lines.
------------------------------------------------------------------

Linear regression can be used to find the line through two
2-d points as follows:

1. Clear the stats.
2. Do y1 ENTER x1 sigma+.
3. Do y2 ENTER x2 sigma+.

Then (on the 33s), do L.R.; the line is y = m*x + b, with m
and b displayed.

To get the value into the x-reg, get the value displayed
and press ENTER.

Since, projectively, two lines determine a point just as
well as two points
determine a line, we should be able to use linear
regression to determine
the intersection of two lines.

The problem is to determine a representation of lines such
that we can easily
enter the representations of two lines and get their
intersection.

L.R. is given (xi, yi) (i = 1..2) and returns (m, b).
We would like to enter (mi, bi) (i=1..2) and get (x, y).

We can't quite do this, but if we write b = -x*m + y, we
see that b corresponds
to y and -m corresponds to x.

That is,
y = m*x + b
b = x*(-m) + y

So, if we enter (-mi, bi) for each line as the (x, y) input
for sigma+,
we should get x for m and y for b from L.R.

Example: Find the intersection of y=6x-1 and y=3x+2.

The (m, b) values are (6, -1), (3, 2), so we enter (-6, -1)
and (-3, 2)
(i.e., CLEAR sums(4) -1 ENTER -6 sigma+ 2 ENTER -3 sigma+).
The result is m=1, b=5, so the intersection is (1, 5)

----------------------------------

Martin Cohen
5/27/04

Very clever, Martin!