Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I wonder if anyone can assist/show me how to complete this task...

I have the following equation which models a dual axis magnetic field:

$$\begin{equation} B_{H}^2 = B_x^2 + B_y^2 \tag{1}\end{equation}$$

Where $ B_{H}^2 $ is the 'ideal' earths magnetic field, $ {B}_{x}, {B}_{y} $ are the 'ideal' x and y axis mag. field values.

Now, the 'actual' measured fields can be given by:

$$\begin{equation} \hat{B}_x = aB_x + x_0 \tag{2}\end{equation}$$ $$\begin{equation} \hat{B}_y = b\left(B_y\cos{(p)} + B_x\sin{(p)}\right) + y_0\tag{3} \end{equation}$$

Where, $ a, b $ are scaling factors for each axis, $ p $ is an angular offset and $ x_0, y_0 $ are bias offset values.

Now, solving for $ B_x $ in $ (2) $ gives:

$$ B_x = \left(\frac{\hat{B}_{x} - x_{0}}{a}\right) $$

Plugging into $ (3) $ and solving for $ B_y $ gives:

$$ B_y = \frac{\left(\frac{\hat{B}_y - y_0}{b} - \frac{\left(\hat{B}_x - x_0\right) * \sin{(p)}}{a}\right)}{\cos{(p)}} $$

Which simplified gives:

$$ B_y = \frac{\left(a\hat{B}_y + ay_0 + \hat{B}_x\sin{(p)}b - \sin{(p)}b^2\right)}{ab\cos{(p)}} $$

Plugging $ B_x, B_y $ into $ (1) $ gives:

$$ B_{H}^2 = \left(\frac{\hat{B}_{x} - x_{0}}{a}\right)^2 + \left(\frac{\left(a\hat{B}_y + ay_0 + \hat{B}_x\sin{(p)}b - \sin{(p)}b^2\right)}{ab\cos{(p)}}\right)^2 $$

Now this is the bit I can't seem to figure out... Apparently this can written in the form of a shifted, distorted ellipse with the general ellipse form:

$$ A\hat{B}_x^2 + B\hat{B}_x\hat{B}_y + C\hat{B}_y^2 + D\hat{B}_x + E\hat{B}_y + F = 0 $$

Can anyone point me in the right direction as to how to do this? I've been trying all day with zero success, I could put my attempts here but I would be here all day! I think it's the reversal of Completing the Squares but I'm not 100% sure.

Any help appreciated, Thankyou.

Carrying on from the above and based upon Grahams observation.

Subtract $ B_H^2 $ from both sides gives:

$$ \left(\frac{\hat{B}_{x} - x_{0}}{a}\right)^2 + \left(\frac{\left(a\hat{B}_y + ay_0 + \hat{B}_x\sin{(p)}b - \sin{(p)}b^2\right)}{ab\cos{(p)}}\right)^2 - B_H^2 = 0 $$

Removing the denominators gives:

$$ \left(\hat{B}_x-x_0\right)^2\left(ab\cos(p)\right)^2 + a^2\left(a\hat{B}_y+ay_0+\hat{B}_x\sin(p)b-\sin(p)b^2\right)^2-B_H^2a^2\left(ab\cos(p)\right)^2 = 0 $$

Expanding the first term $ \left(\hat{B}_x-x_0\right)^2\left(ab\cos(p)\right)^2 $ gives:

$$ \left(\hat{B}_x^2-2\hat{B}_xx_0+x_0^2\right)\left(ab\cos(p)\right)^2 = \hat{B}_x^2\left(ab\cos(p)\right)^2-2\hat{B}_xx_0\left(ab\cos(p)\right)^2+x_0^2\left(ab\cos(p)\right)^2 \qquad\qquad\mathbf{(4)}$$

Expanding the second term gives:

$$ a^2\left(\left(a\hat{B}_y+ay_0+\hat{B}_x\sin(p)b-\sin(p)b^2\right)\left(a\hat{B}_y+ay_0+\hat{B}_x\sin(p)b-\sin(p)b^2\right)\right) \\ = a^2\left(a^2\hat{B}_y^2+a^2y_0\hat{B}_y+\hat{B}_y\hat{B}_xab\sin(p)-\hat{B}_yab^2\sin(p)+\hat{B}_ya^2y_0+a^2y_0^2+\hat{B}_x^2aby_0\sin(p)-ab^2y_0\sin(p)+\hat{B}_x\hat{B}_yab\sin(p)+\hat{B}_xaby_0\sin(p)+\hat{B}_x^2\sin^2(p)b^2-\hat{B}_xb^3\sin^2(p)-\hat{B}_yab^2\sin(p)-ab^2y_0\sin(p)-\hat{B}_xb^3\sin^2(p)+\sin^2(p)b^4\right) $$

Collecting the terms and multiplying by $ a^2 $ gives:

$$ \hat{B}_x^2\left(a^2b^2\sin^2(p)\right)+\hat{B}_x\hat{B}_y\left(2a^3b\sin(p)\right)+\hat{B}_y^2\left(a^4\right)+\hat{B}_x\left(2a^3by_0\sin(p)-2a^2b^3\sin^2(p)\right)+\hat{B}_y\left(2a^2y_0-2a^2b^2\sin(p)\right)+a^4y_0^2-2a^3b^2y_0\sin(p)+a^2b^4\sin^2(p)\qquad\qquad \mathbf{(5)}$$

Combining $ \mathbf{(4)}, \mathbf{(5)}, $ and $ -B_H^2a^2\left(ab\cos(p)\right)^2 $ gives:

$$ \hat{B}_x^2\left(a^2b^2\right)+\hat{B}_x\hat{B}_y\left(2a^3b\sin(p)\right)+\hat{B}_y^2\left(a^4\right)+\hat{B}_x\left(2a^3by_0\sin(p)-2a^2b^3\sin^2(p)-2a^2b^2x_0\cos^2(p)\right)+\hat{B}_y\left(2a^2y_0-2a^2b^2\sin(p)\right)+a^4y_0^2-2a^3b^2y_0\sin(p)+a^2b^4\sin^2(p)+x_0^2\left(ab\cos(p)\right)^2-B_H^2a^4b^2\cos^2(p) $$

So finally, we have:

$$ A=a^2b^2 \\ B=2a^3b\sin(p) \\ C=a^4 \\ D=2a^3by_0\sin(p)-2a^2b^3\sin^2(p)-2a^2b^2x_0\cos^2(p) \\ E=2a^2y_0-2a^2b^2\sin(p) \\ F=a^4y_0^2-2a^3b^2y_0\sin(p)+a^2b^4\sin(p)+x_0^2\left(ab\cos(p)\right)^2-B_H^2a^4b^2\cos^2(p) $$

After tidying up a little gives:

$$ A=b^2 \\ B=a\left(2b\sin(p)\right) \\ C=a^2 \\ D=\left(2aby_0\sin(p)-2b^3\sin^2(p)-2b^2x_0\cos^2(p)\right) \\ E=\left(2y_0-2b^2\sin(p)\right) \\ F=\left(a^2y_0^2-2ab^2y_0\sin(p)+b^4\sin(p)+x_0^2b^2\cos^2(p)-B_H^2b^2\cos^2(p)\right) $$

Does this look ok?

share|cite|improve this question
I think you want a $\hat{B^2}_y$ term in that final equation. I'm a bit confused what you're trying to do are you trying to make the second from last equation resemble the last? If so can't you just expand and equate the coefficients? – Graham Hesketh May 2 '13 at 14:59
Hi, you are correct I missed the squared term, I have updated the question. Thankyou. Yes, essentially I am trying to take the second from last equation to generate the last equation but I'm struggling to see how to do it. Can't see the wood for the trees I think! – Mike May 2 '13 at 15:04
Subtract $\hat{B^2}_H$ from both sides in the second from last equation to get an equation equal to zero. Expand out all the brackets and collect all the terms together in front of each term appearing in the last equation, so everything multiplying $\hat{B^2}_x$ for instance will be $A$. – Graham Hesketh May 2 '13 at 15:10
There is a couple of mistakes I think. You dropped the contribution to $F$ coming from (4) and the $a^4$ multiplying $\sin$ in $Y$ should be $a^2$, also you can divide everything by $a^2$. That's the correct method though. – Graham Hesketh May 3 '13 at 8:42
Last comment because this should be in chat apparently... $E={a}^{2} \left( 2\,{a}^{2}y_{{0}}-2\,a\sin \left( p \right) {b}^{2} \right) $ and you can divide the whole thing, i.e. all the coefficients, by $a^2$ (provided $a$ is not zero) because the polynomial is equal to zero anyway. Everything else is correct. – Graham Hesketh May 3 '13 at 10:04

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.