0

I have a parabola defined by the quadratic equation $y = -(x + 0)(x - endPoint)$, which also passes through a particular point $(a, b)$. I would like to know how to alter the equation so that I can ensure that the vertex of the parabola reaches a particular $height$ while still passing through point $(a, b)$ and while still passing through the $endPoint$ when $y = 0$ (although I don't mind if the other side of the parabola no longer passes through the origin).

For reference, I'm programming a computer game where a projectile moves in a parabolic arc. Point $(a, b)$ is the point from which the projectile is launched, and point $(endPoint, 0)$ is where the projectile lands, which is why those two points must remain immutable. But I need to be able to define how high the parabola is at its apex so that I can ensure the projectile will pass over certain obstacles.

Also, as far as my mathematical skill goes, I've spent the last couple of days digging up my memories of high school quadratics, and that was nearly 20 years ago.

2 Answers2

0

I will assume that you want the projectile to land at endpoint $(P, 0)$.

A quadratic function that goes through the points $(0,0)$ and $(P,0)$ is of the form $y = mx(x-P)$.

To ensure this also passes through the point $(a, b)$, we would need to plug in $x = a$ and get $y= b$.

This would mean $b = ma(a-P)$ so that $m = b/a(a-p)$.

Therefore, you can use the quadratic function defined by:

$$x \mapsto \frac{bx(x-P)}{a(a-P)}$$

Here is a link to a working example in Desmos: graph

You can alter $a, b, P$ as you wish to see the effects on the graph.


Edit: In keeping with the comment below, here is a modified graph in Desmos.

This is a quadratic function with roots $x=p$ and $x=q$, where the vertex occurs at $(\frac{p+q}{2},H)$ for which each of the three parameters $p, q, H$ is adjustable. The quadratic function is defined by:

$$x \mapsto -\frac{4H}{(p-q)^2}(x-p)(x-q)$$

  • Thanks for that, but I'm still unsure how to change the height of the graph without missing point (a, b) or point (P, 0). I don't mind if the graph no longer passes through (0, 0) – ashaquick Mar 14 '19 at 01:00
  • @ashaquick Which points, precisely, do you want to be on the parabola? You want it to have $(a,b)$ and $(P, 0)$; what else? Three points determine a parabola uniquely, so if you specify one more point then I will edit accordingly. – Benjamin Dickman Mar 14 '19 at 01:03
  • I would like the vertex to have a y-value of $height$, where $height$ is a value I'm defining. The x-value of the vertex should be the mid-point between the two places where the parabola crosses the x-axis (Q and P), so it would have a value of $(P - Q)/2$. It's figuring out Q that I'm having trouble with, and how to then express the whole thing as an equation. – ashaquick Mar 14 '19 at 01:23
  • @ashaquick Check the Edit and let me know if this worked! You can adjust $p$ and $q$ as you wish, and also $H$ (the Height of the vertex) as you wish, and the corresponding parabola is given there. – Benjamin Dickman Mar 14 '19 at 01:49
  • This no longer appears to ensure that the parabola passes through point $(a, b)$ though? – ashaquick Mar 14 '19 at 03:25
  • @ashaquick Once you specify two points at the same height (e.g., $x$-intercepts) you then have halfway between them the line of symmetry, i.e., the $x$-coordinate of the vertex. Since you also specified the $y$-coordinate of the vertex ("height") you have three points locked in: two roots and the vertex. This defines a unique quadratic. If you want something different, then please describe it; but, please note again that three points uniquely define a parabola. – Benjamin Dickman Mar 14 '19 at 03:28
0

The general parabola $y = f(x)$ with a given root $p$ (i.e., given $x$-coordinate of the endpoint) has the form $$y = f(x) = - A (x - p) (q - x),$$ where $A$ and $q$ are arbitrary constants. The condition that the parabola passes through $(a, b)$ is that $f(a) = b$, so that $$\boxed{A(a - p)(a - q) = b} .$$ By symmetry the vertex of the parabola has $x$-coordinate $\frac{p + q}{2}$, so the requirement that the parabola has (for $A > 0$) maximum height (i.e., $y$-coordinate) $h$ there is $f\left(\frac{p + q}{2}\right) = h$, or $$\boxed{A (p - q)^2 = -4 h} .$$

Multiplying the equations and canceling $A$ gives $$-4h (a - p) (a - q) = b (p - q)^2 .$$ This is a quadratic equation in $q$, and expanding, collecting like terms in $q$, and applying the quadratic formula gives an expression for $q$ in terms of $a, b, h, p$. Substituting this expression in either of the above boxed equations (the first is easier to use, since it is linear, not quadratic, in $q$) and solving gives an expression for $A$. The result is: $$\boxed{A = \frac{z}{(a - p)^2}, \qquad q = \frac{a z + (p - a) b}{z}, \qquad \textrm{where} \qquad z := b - 2 h + 2 \sqrt{h (h - b)}}.$$

Travis Willse
  • 99,363
  • I'll need to study this a bit more to figure out how it works, because right now it appears to be some magic that solved my problem. Thanks! – ashaquick Mar 14 '19 at 03:35
  • @ashaquick If you solve for $A$ in the latter boxed equation, then you have precisely the leading coefficient provided in my Edit... – Benjamin Dickman Mar 14 '19 at 03:57
  • @ashaquick You're welcome. I'm glad you found it useful! To see how you might solve manually, dividing the two equations eliminates $A$, and then rearranging gives a quadratic equation in $q$. Applying the quadratic formula gives $q$, then you can substitute in either equation (probably the first is easier, since it is linear in $q$ rather than quadratic) and solve for $A$. – Travis Willse Mar 14 '19 at 04:14
  • @BenjaminDickman Sorry. I looked at that, but I didn't see how to solve it without knowing the x-values of both roots. It might just be that I'm a bit hard of understanding. This one made more sense to me because the equations were expressed in terms of values I already know (the "landing point" root, the desired height, and the point (a, b)). – ashaquick Mar 14 '19 at 04:16
  • @Travis I've been staring at this for a while now, and I don't understand what you did (I know it works because I plugged the equations into my code and it creates perfect parabolas now). I'm not entirely sure how you arrived at $A(p−q)2=−4h$, or what you mean by "divide the equations". – ashaquick Mar 14 '19 at 11:03
  • @Travis Okay, I figured out how you got to $A(p−q)^2=−4h$ after a lot of work with a pen and paper, but I'm still not sure how you combined that with $A(a−p)(a−q)=b$ to get the equations inside the box. I assume you replaced A with $-4h/(p-q)^2$? – ashaquick Mar 14 '19 at 14:31
  • @ashaquick I've added a little more detail about how to solve for $A, q$ in the spoiler box. – Travis Willse Mar 14 '19 at 19:31
  • @Travis I've tried expanding and collecting like terms, but all I wind up with is a soup of letters, and I can't see how to group them in such a way that I could apply the quadratic formula. I get $-4ha^2+4haq+4hap-4hpq=bp^2-2bpq+bq^2$ – ashaquick Mar 15 '19 at 11:31
  • Move everything to one side and then collect like terms in $q$, to write the equation in the form $Rq^2 + Sq + T = 0$. – Travis Willse Mar 15 '19 at 17:33
  • Ah. Okay. I'm pretty sure I get it now - I didn't really understand what "like terms in q" meant, but this clarified it for me. I think I've got a bit of work with pen and paper ahead of me (I used to drive my maths teacher nuts in high school, because I was the kid who would never just accept that a formula worked - I needed to know how it worked). Thanks so much for all the help. – ashaquick Mar 16 '19 at 01:09
  • You're welcome. I'm glad you found it helpful. – Travis Willse Mar 16 '19 at 01:11