I have an algorithm for calibrating a vector magnetometer. The input is N readings of the x, y, z ax

anginih86

anginih86

Answered question

2022-06-21

I have an algorithm for calibrating a vector magnetometer. The input is N readings of the x, y, z axes: ( x 1 , x 2 , , x N ), ( y 1 , y 2 , , y n ), and ( z 1 , z 2 , , z N ).
The algorithm fits an ellipsoid to the data by estimating a symmetric 3 × 3 matrix A. In order to calibrate the system, it needs to calculate A . I am adapting the algorithm for a microcontroller with very little memory, so cannot load standard matrix manipulation libraries.
Is there an explicit formula for calculating the square root of 3 × 3 positive definite matrix?

Answer & Explanation

Savanah Hernandez

Savanah Hernandez

Beginner2022-06-22Added 16 answers

I would rather use an iterative method (e.g. QR iteration or Jacobi's algorithm) to diagonalise A and find its square root, but there is a semi-closed-form formula for B = A . By Cayley-Hamilton theorem,
(1) B 3 tr ( B ) B 2 + tr ( B 1 ) det ( B ) B det ( B ) I = 0.
Multiply both sides of (1) by B, we obtain
(2) B 4 tr ( B ) B 3 + tr ( B 1 ) det ( B ) B 2 det ( B ) B = 0.
Substitute (1) into (2) and using the fact that B 2 = A, we obtain
A 2 + tr ( B ) [ tr ( B ) A + tr ( B 1 ) det ( B ) B det ( B ) I ] + tr ( B 1 ) det ( B ) A det ( B ) B = 0.
Therefore
B = A 2 + ( tr ( B ) 2 tr ( B 1 ) det ( B ) ) A + tr ( B ) det ( B ) I ( tr ( B ) tr ( B 1 ) 1 ) det ( B ) (3) = A 2 + ( α + β ) A + γ δ I α γ δ
where
α = λ 1 λ 2 + λ 2 λ 3 + λ 3 λ 1 , β = tr ( A ) , γ = λ 1 + λ 2 + λ 3 , δ = det ( A )
and λ 1 , λ 2 , λ 3 are the eigenvalues of A.
So, to find B using (3), we need the eigenvalues A. Let s = tr ( A 2 ). The characteristic equation of A is then
(4) x 3 β x 2 + 1 2 ( β 2 s ) x δ 2 = 0
and λ 1 , λ 2 , λ 3 are its roots. Now (4) can be solved by radicals.

Do you have a similar question?

Recalculate according to your conditions!

Ask your question.
Get an expert answer.

Let our experts help you. Answer in as fast as 15 minutes.

Didn't find what you were looking for?