# How to solve a quadratic equation with vector coefficients

I am working on a hobby web application for a tabletop sci-fi RPG. The tl;dr is the app will provide a lightweight simulation so that the players can focus on the fun and not the math.

One of the simulations uses a quadratic equation where the coefficients are vectors. If I learned to solve such an equation in university linear algebra I have long since forgotten, and I cannot find a resource online.

The equation is the form $$At^2 + Bt + C = 0$$, where $$A, B,$$ and $$C$$ are $$3 \times 1$$ vectors. I know how to solve a quadratic equation with scalar coefficients. But how do we solve for t when the coefficients are vectors? The standard form would seem to be:

$$t = \frac{ -B \pm \sqrt{ B^2 - 4AC }}{2A}$$

Would the multiplications be cross products? Would the result of the expression be a vector? I am expecting a scalar result (or two). Is this even the correct approaching to find the solution?

I read through the answers listed below. But the questions (and answers) are about $$N \times N$$ or $$N \times M$$ matrices. One answer even says, "solve for $$\lambda_1$$ and $$\lambda_2$$ at any desired coordinate" as the answer, with no further details. But that is the part I don't know how to do.

To clarify, The vectors $$A, B,$$ and $$C$$ represent coordinates in three-dimensional space and $$t$$ is time.

It has been suggested in the comments that the solution is to solve the problem with three separate equations: solve one equation, then check if one of the solutions satisfies the other two equations. But this raises a question. Consider the case where $$A = \begin{bmatrix} 3 & 0 & 0 \end{bmatrix}$$, $$B = \begin{bmatrix} 5 & 0 & 0 \end{bmatrix}$$, and $$C = \begin{bmatrix} 2 & 0 & 0 \end{bmatrix}$$. In this case, there is no solution, not even an imaginary one, for two of the equations. Yet there does exist a t that satisfies the equation $$At^2+Bt+C=\begin{bmatrix} 0 & 0 & 0 \end{bmatrix}$$. So the suggested approach does not appear not to work. What am I missing?

• An important issue is what kind of thing the unknown $t$ is. Given that $A,B,C$ are 3 by 1 vectors, if t were real you'd have three separate quadratics, each of which could be solved, ut then only by luck would the one or two solutions work. On the other hand $t$ might also be a 3 by 1 vector and then it's just three separate quadratic equations. May 9, 2021 at 19:36
• @coffeemath If $t$ is a $3\times1$ vector, what is $t^2$? It seems to me that $t$ must be a scalar, and as you said, we have three quadratics in $t$, which may or may not have a common solution. May 9, 2021 at 19:38
• The one that says "solve for $\lambda_1, \lambda_2$ at the desired coordinate" is correct. You have $3$ quadratic equations, one in each row. Solve the first one; you will get at most two solutions for $t$. Test each of these to see if it also solves the other two equations. It's just the quadratic formula, which you have written in your question. May 9, 2021 at 19:44
• @saulspatz I can see where, in a strict mathematical sense, there might be separate equations with no common solution. But in this context, the vectors represent physical objects in three-dimensional space. Of course there may not be a solution for t, just as a scalar quadratic equation may not have real roots. May 9, 2021 at 19:45
• That is interesting. So the answer is to solve the scalar quadratic for one set of scalar coefficients, say a1, b1, and c1, and then test the roots for the other two sets of scalar coefficients? May 9, 2021 at 19:50

When $$P$$ is a vector with only nonzero components and $$t$$ is a real number, the equation $$P t^2 + Q t + R=0$$ is equivalent to $$t^2 + \left( P^{-1} Q \right) t + \left( P^{-1} R \right) = 0$$
where $$P^{-1}$$ is defined by $$P^{-1} P = 1$$. In particular, if $$P$$ has 3 components, then $$P^{-1} = \frac{1}{3}\begin{bmatrix} 1/P_x & 1/P_y & 1/P_z \end{bmatrix}$$. This allows you to solve the vector-coefficient quadratic using the familiar formula with substitutions $$A=1$$, $$B=P^{-1}Q$$, and $$C=P^{-1}R$$.
If any of the components of $$P$$ are zero, you may still find a solution by removing the problematic components from $$P$$, $$Q$$, and $$R$$ and solving those components individually. When the $$i$$th component of $$P$$ is $$0$$ and the corresponding component of $$Q$$ is nonzero, there is a solution $$t_i$$ of $$Q_it_i+R_i=0$$. No solution exists when $$P_i=0$$, $$Q_i=0$$, and $$R_i \neq 0$$.
Overall, a solution exists when all the $$t_i$$'s are equal -- that is, when for all $$i$$ such that $$P_i=0$$, $$Q_i\neq0$$ and $$t_i=t$$ where $$t$$ is the solution of the nonzero-component part.