0
$\begingroup$

I have three points: $(0,0),(2,1),(3,2)$ and I get a graph like this:

Graph of points (0,0)(2,1)(3,2)

Is there a formula to draw this graph with the line (or two lines meeting in the middle, if you prefer- but definitely not a curve) continuing straight/linearly in both directions indefinitely?

I've hacked together an excel formula that uses a "IF" but it seems inelegant.

$\endgroup$
5
  • $\begingroup$ you should show us that you have tried something before coming to MSE to ask your question $\endgroup$
    – fonfonx
    Aug 1, 2017 at 2:22
  • $\begingroup$ Should we assume that you would like to have the line chunks continue on in their respective directions? $\endgroup$ Aug 1, 2017 at 2:24
  • $\begingroup$ @Chickenmancer yes I would like the lines to continue straight indefinitely $\endgroup$
    – Fowl
    Aug 1, 2017 at 2:28
  • $\begingroup$ @fonfonx I've got an awful excel formula with an "if" in the middle, but I didn't think it was appropriate here $\endgroup$
    – Fowl
    Aug 1, 2017 at 2:28
  • $\begingroup$ @Fowl actually this is the formula you are looking for. The simplest way to represent it is with this IF... $\endgroup$
    – fonfonx
    Aug 1, 2017 at 2:47

2 Answers 2

5
$\begingroup$

The simplest way to represent your function is indeed with an if:

For $x \leq 2$, you have $f(x)=\frac{x}{2}$, and for $x \geq 2$, you have $f(x)=x-1$. I assume here that the unit of a square in your graph is 0.5 and that the 3 dots represent the 3 points you are talking about (difference with @Chickenmancer)

Then $$f(x)=\left\{\begin{array}{cc} \dfrac{x}{2}, &\text{for } x\leq 2,\\ x-1, &\text{for } x>2.\end{array}\right. $$

If you don't want this if (or this disjunction of case), you can see that your function is actually the maximum of these 2 affine functions.

Therefore $f(x)=\max(\frac{x}{2}, x-1)$.

And we can "simplify" this expression using the fact that $\max(a,b)=\frac{|a-b|}{2}+\frac{a+b}{2}$:

$$\boxed{f(x)=\dfrac{|x-2|}{4}+\dfrac{3x-2}{4}}$$

$\endgroup$
0
$\begingroup$

Think of the function of a generic parabola

$y^2=ax+by+c$

This is identified by three numbers. You have three points, if they don't lie on the same line (and they don't), you can use those points to determine the equation of the parabola passing through them.

First step.

Substitute each of your point in the parabola equation above:

$0 = c$

$1 = 2a+1b$

$4=3a+2b$

Second step.

Easily solve the system above to get the values a=-2 and b=5.

Therefore, one curve you are looking for is: $y^2=-2x+5y$.

PS. Also remember the following: given 3 points (not lying on the same line) there exists a unique circle passing through these points. So in case you want a circle instead, it's also possible to find the equation for that.

EDIT: Based on the comments I seem to understand you just want each of the two lines you have continuing indefinitely. In this case you have to compute the slope of each of them (that is the lines passing through (0,0) and (2,1) of slope 1/2, and the line passing through (2,1) and (3,2) of slope 1) and define a piecewise function something like:

$y(x)=\frac{1}{2}x$, for x<=2

$y(x)=x-1$ for x>2

This because your lines intersect in (4,2).

$\endgroup$
10
  • $\begingroup$ Thanks, but unless I'm misunderstanding this will give me curved lines? I need a straight line. $\endgroup$
    – Fowl
    Aug 1, 2017 at 2:29
  • $\begingroup$ @Fowl Sorry from the way your question is posted this is not clear. My answer gives you a way to draw a curve through three points, which is I understood was what you needed $\endgroup$
    – Tommy
    Aug 1, 2017 at 2:31
  • $\begingroup$ @Fowl You cannot certainly get a "straight line" out of these 3 points as they don't line of the same line. I think what you want is an approximation of the curve passing through them. What my answer does is giving you exactly the curve, which I suppose is even better than an approximation.. Is like I gave you "infinite straight lines", to put it in a rough simple way. That does not work for you? $\endgroup$
    – Tommy
    Aug 1, 2017 at 2:34
  • $\begingroup$ @Fowl, anyhow Sorry I made a slight mistake I will update the answer. $\endgroup$
    – Tommy
    Aug 1, 2017 at 2:36
  • $\begingroup$ indeed my question is imprecise, apologies - it's been quite a long time since I've dealt with anything like this. I could describe it as "two lines that meet in the middle".? $\endgroup$
    – Fowl
    Aug 1, 2017 at 2:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .