# Parabola always through two points.

I need to draw parabola through two points, but also need to be able to change the width of the parabola. In more details let's say I have parabola:

$$f ( x ) = - \frac { ( x - 1 ) ^ { 2 } } { W } + 1$$

And no matter what $$W$$ I define I want my parabola goes through points (0,0) and (1,1) which for that case happens only if $$W=1$$.

I suppose I need to rotate the parabola or move whole parabola in some way. But don't know how to do that.

My aim is to increase $$W$$ to infinity until I get straight line (infinity almost straight) through mentioned points. And in the future of course I want to be able to manipulate those points.

For any help thanks in advance.

• I edited my answer, now I derived the equation in terms of W. It's slightly different form than you expected, but it's very similar. – KKZiomek Nov 24 '18 at 16:14
• You've already accepted an answer, but I want to point out that in your equation, you were also forcing your parabola to be centered around the $y$-axis. That, along with requiring that it pass through $(0,0)$ and $(1,1)$ takes alway all three degrees of freedom in an upward-opening parabola. That is why you had nothing left to adjust the width with. The two solutions drop the "centered around the $y$-axis" requirement, leaving them a degree of freedom to adjust the width. – Paul Sinclair Nov 24 '18 at 18:02

## 2 Answers

You can simply set up a system of equations in the quadratic form:

$$y=ax^2+bx+c$$

So plugging in $$x$$ and $$y$$ from your points $$(0,0)$$ and $$(1,1)$$, you make two equations:

$$0=a(0)^2+b(0)+c$$ $$1=a(1)^2+b(1)+c$$

The equations simplify to:

$$c=0$$ $$1=a+b$$

So the $$c$$ of your quadratic equation will be always 0. $$a$$ is your "width" of the parabola. The lower the value, the wider it is, the higher the value, the narrower it is. Just remember that whatever $$a$$ you chose, you have to chose $$b$$ so that $$a+b=1$$ as can be seen in the second equation.

To get the equation in terms of $$W$$ simply complete the square and manipulate the standard quadratic form (note that $$c$$ is $$0$$, so we exclude $$c$$):

$$y=ax^2+bx$$ $$y=a\Big(x^2+\frac{b}{a}x\Big)$$ $$y=a\Big(x+\frac{b}{2a}\Big)^2-\frac{b^2}{4a}$$

Now, since $$a+b=1$$ then $$b=1-a$$:

$$y=a\Big(x+\frac{1-a}{2a}\Big)^2-\frac{(1-a)^2}{4a}$$

Now, simply define $$W=\frac{1}{a}$$ and the equation will change into:

$$y=\frac{\big(x+\frac{W-1}{2}\big)^2}{W}-\frac{(W-1)^2}{4W}$$

Then, combine the two fractions into one and expand exponent:

$$y=\frac{4\Big(x^2+(W-1)x+\frac{(W-1)^2}{4}\Big)-(W-1)^2}{4W}$$ $$y=\frac{4x^2+4(W-1)x}{4W}$$ $$y=\frac{x^2+(W-1)x}{W}$$ $$y=\frac{x^2}{W}+\frac{(W-1)}{W}x$$

And that's it! We derived the equation in terms of $$W$$. Now, simply to change the width of the parabola, you change $$W$$. The bigger $$W$$, the wider the parabola, the lower $$W$$, the narrower the parabola. (Opposite of what happens if you change $$a$$ because we defined $$W=\frac{1}{a}$$). The parabola will rest on the points $$(0,0)$$ and $$(1,1)$$ as expected.

Also, notice what happens when you increase $$W$$ to infinity. With some further analysis, and taking $$\lim_{W\to\infty} y$$, you can see that the equation slowly becomes the line $$y=x$$, which is exactly what you predicted and wanted!

Note: If you would ever need three points instead of two, you won't be able to change the width of the parabola because three points describe exactly one parabola. With two points you have infinite parabolas, hence the ability to change width.

EDIT: I was answering it fast, and now I realized, that you don't have to complete the square at all! You simply need to start with:

$$y=ax^2+bx$$

Then just plug in $$b=1-a$$, and then $$a=\frac{1}{W}$$:

$$y=ax^2+(1-a)x$$ $$y=\frac{x^2}{W}+\Big(1-\frac{1}{W}\Big)x$$ $$y=\frac{x^2}{W}+\frac{(W-1)}{W}x$$

Sorry for making it more complicated than it should be.

• Great it works. Thanks :) it seems to be very simple that I am embarased that I asked :) – pajczur Nov 24 '18 at 16:54
• It's fine, that's what this site is for :) – KKZiomek Nov 24 '18 at 17:00

I think $$f(x) = \frac{x(x-1)}{W} + x$$ will do what you want.

For large $$W$$ this will be nearly straight between the two points you specified. For very large $$x$$ (positive or negative) it will grow without bound.

(This is what happens if you finish the algebra that @KKZiomek started.)

• This is the answer KKZiomek would eventually get, but it's easier to see this as (A) all quadratics with roots 0 and 1 plus (B) a polynomial of degree ≤2 through (0,0) and (1,1). – Teepeemm Nov 25 '18 at 1:34