# Intersection of 2d plane and n-dimensional ellipsoid

English is not my native language and I'm neither a mathematician nor a statistican by trade so please excuse me if I fail to explain my problem in a concise way.

I'm trying to visualize a multivariate reference region of normally distributed measurements. A multivariate reference region can mathematically be described as an $n$-dimensional ellipsoid of the form: $$(x-cx)'A(x-cx)=1$$ where $cx$ is a $n \times 1$ vector representing the center of the ellipsoid and where the eigenvectors and eigenvalues of $A$ ($n \times n$ pos definite matrix) contains information on the orientation and semiaxis of the ellipsoid (wiki).

In order to present this I would like to plot the 2D intersection ellipse when $n-2$ positions of the vector $x$ is known. In the above equation $A$ and $cx$ will also be known.

Example: Let's say I have an multivariate reference region ($A$ and $cx$ known) for age, systolic blood pressure and diastolic blood pressure ($n=3$). Then I would like to plot the ellipse describing what systolic and diastolic blood pressure could be expected in subjects with the exact age of $60$ for instance. Then the vector $x=(60, s, d)$ where $s$ and $d$ are the unknowns describing the ellipse I want to visualize.

With the help of this article I've managed to find the orientation and dimensions of the 2D intersection ellipse of a 3-dimensional ellipsoid. It is, however, beyond me to generalize the solution into $n>3$ dimensions. One aspect that might simplify the problem is that the intersection plane will be perpendicular to the axes of the coordinate system.

Suggestions? Solutions? Anyone?

Assuming the first two components of $x$ are free we can have the quadratic form evaluated to \begin{align} 1 =& \, ((x_1, x_2, rx) - (cx_1, cx_2, rcx))^t A ((x_1, x_2, rx) - (cx_1, cx_2, rcx)) \\ =& \, a_{11} (x_1-cx_1)^2 + a_{22} (x_2 - cx_2)^2 + (a_{12} + a_{21}) (x_1-cx_1)(x_2 - cx_2) + \\ & ((a_{13}+a_{31}) (x_3 - cx_3) + \ldots + (a_{1n}+a_{n1}) (x_n-cx_n)) (x_1 - cx_1) + \\ & ((a_{23}+a_{32}) (x_3 - cx_3) + \ldots + (a_{2n}+a_{n2}) (x_n-cx_n)) (x_2 - cx_2) + \\ & \sum_{i,j \ge 3} a_{ij} (x_i-cx_i)(x_j-cx_j) \\ =& \, a (x_1-cx_1)^2 + b (x_2-cx_2)^2 + c (x_1-cx_1)(x_2-cx_2) + d (x_1 - cx_1) + e (x_2 - cx_2) + (f + 1) \end{align} The coefficients $a, b, c, d, e, f$ contain only known values (the $x$ vector coordinates $x_3$ to $x_n$, the center vector coordinates $cx_i$ and matrix components $a_{ij}$).

Introducing $u = x_1 - cx_1$ and $v = x_2 - cx_2$ the above equation turns into $$a u^2 + b v^2 + c u v + d u + e v + f = 0$$ which is the general form of a conic section in the $u, v$-plane, see conic sections.

If $b = a_{22} \ne 0$ we can try to solve for $v$: \begin{align} 0 &= v^2 + \left(\frac{c}{b} u + \frac{e}{b} \right) v + \frac{a}{b} u^2 + \frac{d}{b} u + \frac{f}{b} \\ &= \left( v + \frac{cu+e}{2b} \right)^2 - \left( \frac{cu+e}{2b} \right)^2 + \frac{a}{b} u^2 + \frac{d}{b} u + \frac{f}{b} \end{align} which gives $$v = -\frac{cu+e}{2b}\pm\sqrt{\left( \frac{cu+e}{2b} \right)^2 - \frac{au^2 + du + f}{b}}$$

• It is possible that I have made an error somewhere. The basic idea you should get is: You have two variables and if you start sorting all terms into terms with variables and those which are constant you should end up with a similar conic section in the two variables, like that formula that leads to the one for $u$ and $v$. – mvw Jan 3 '16 at 20:56
• This is the solution I was looking for. Beautiful! Upon implementation in Stata I fail miserably however... I have interpreted the coefficients a-f like this for n=3: a=A[1,1], b=A[2,2], c=A[1,2]+A[2,1], d=(A[1,3]+A[3,1])(x3-cx3), e=(A[2,3]+A[3,2])(x3-cx3) and f=A[3,3](x3-cx3)(x3-cx3). Have I interpreted this correctly? I get a negative value within the square root when there should be a solution. Most likely I've got some typo in the code I can't find, but I would like to check that I've understood you correctly. – Jonas Selmeryd Jan 3 '16 at 21:05
• A "1" disappered in your solution above when introducing u and v. When correcting for this it seems to work fine! Thanks! – Jonas Selmeryd Jan 3 '16 at 21:20
• The constant part $f+1$ of the first equation was written that way, so that both sides of the equation can be substracted by $1$. – mvw Jan 3 '16 at 21:23
• Thanks John. Happy to read this. – mvw Jul 17 '18 at 9:18

Without loss of generality suppose $x_3,\ldots,x_n$ are fixed. The resulting quadratic equation in $x_1$ and $x_2$ has a quadratic, a linear and a constant part. You can obtain those by separating $A,$ $c$ and $x$ into blocks separating the first two coordinates from the other ones.

The quadratic part is still given by the upper left $2\times2$ submatrix of the original matrix $A.$ That gives us the orientation of the axes of the intersection ellipse. The linear part is the sum of the original linear part (first two elements of the matrix product $Ac$) and the upper right $2\times(n-2)$ part of $A$ applied to the separate blocks $(x_1\ x_2)$ and $(x_3 \ldots x_n)$. That gives us the center of the intersection. For the actual size of the two axes we need to complete the squares in the quadratic and linear terms.