I would like to be able to calculate the intersections of two parabola's which accounts for one or both of the parabola's being shifted along the x axis
I have written an excel vba function to do this and it all works fine as long as the parabola's are in the form of $ax^2+bx+c$
If I try to use $a(x-h)^2+bx+c$ I cant seem to nut out the logic
I have included one of the VBA functions so you can see my working out, this function returns the intersecting x value(s)
Function QQInterceptX(a1, b1, c1, a2, b2, c2, pos)
' returns the x intercept
' y1=a1x^2+b1x+c1
' y2=a2x^2+b2x+c2
' when they intersect then the following is true
' a2x^2+b2x+c2=a1x^2+b1x+c1 as the y values are equivalent
' using algebra we get the following
' x=(a1x^2 - a2x^2) + (b1x - b2x) + (c1 - c2)
' x=(a1-a2)x^2 + (b1-b2)x + (c1-c2)
' we can then solve using the quadtratic formula
' x = (-(b1-b2) +/- sqrt((b1-b2)^2 - 4*(a1-a2)*(c1-c2)))/(2*(a1-a2))
' check for div by 0
If ((a1 - a2) <> 0) Then
' return the positive x intercept
If (pos) Then
QQInterceptX = (-(b1 - b2) + Sqr((b1 - b2) ^ 2 - 4 * (a1 - a2) * (c1 - c2))) / (2 * (a1 - a2))
Else
QQInterceptX = (-(b1 - b2) - Sqr((b1 - b2) ^ 2 - 4 * (a1 - a2) * (c1 - c2))) / (2 * (a1 - a2))
End If
Else
QQInterceptX = CVErr(xlErrNA)
End If
examples of the equations I am trying to solve are
$$x^2+138x+317=0$$ $$(x -33.33167)^2+2222=0$$
My online searches have produced no examples of what I am trying to do.
Its the step to the quadratic formula that loses me. and perhaps I should not be using the quadratic formula?
Attribution To get me to the point of creating the VBA function I used this resource http://zonalandeducation.com/mmts/intersections/intersectionOfTwoParabollas1/intersectionOfTwoParabolas1.htm
Disclosure: I have asked this question on physicsforums but am afraid I haven't understood the replies
Assuming a parabola means $y = x^2$.
The first parabola is shifted by $x_1$, the second by $x_2$: $$ y_1(x) = (x - x_1)^2 \\ y_2(x) = (x - x_2)^2 $$
If they are both shifted the same amount, thus $x_1 = x_2$, the intersection set $S$ is $$ S = \{ (x, y) \mid y = x^2 \} = G_{y_1} = G_{y_2} $$ The intersection contains the whole parabola graphs of $y_1$, $y_2$.
If they are both shifted by different amounts, without loss of generality $x_1 < x_2$, we have for the intersection $$ (x-x_1)^2 = (x-x_2)^2 \iff \\ x-x_1 = x - x_2 \vee x - x_1 = x_2 - x \iff \\ x_1 = x_2 \vee x = \frac{x_1 + x_2}{2} \Rightarrow \\ x = \frac{x_1 + x_2}{2} $$ Thus the intersection $S$ is $$ S = \left\{ \left( \frac{x_1 + x_2}{2}, \left(\frac{x_2-x_1}{2}\right)^2 \right) \right\} $$
For the problem of the intersection of two general parabolas we have $$ a_1 x^2 + b_1 x + c_1 = a_2 x^2 + b_2 x + c_2 \iff \\ (a_2 - a_1) x^2 + (b_2-b_1) x + (c_2 - c_1) = 0 $$ Depending on the parameters we can expect either infinite, 2, 1 or no point in the intersection set $S$.