Re: Magnitude of a 3d vector

On Mar 29, 5:54 pm, Clay <c...@xxxxxxxxxxxxxxx> wrote:
On Mar 27, 9:52 am, Vladimir Vassilevsky <nos...@xxxxxxxxxxx> wrote:

There was a need for quick and dirty approximation of the magnitude of
the 3-dimensional vector (x,y,z). This is what worked best:

Let x = max(x,y,z)
Then magnitude ~ x + 0.25*(y+z)
Accuracy ~ 13%

Interestingly, this provides for better accuracy then the sequential use
of the two 2d approximations (see Lyons's "Root of all evils").

Vladimir Vassilevsky
DSP and Mixed Signal Design Consultant

Hey Vlad,

I wrote some Monte Carlo test code and I get:

|r| = 0.90 x + 0.38 (y+z) with avg err=0 and standard deviation
(relative length) of 0.029

where x is the max of the absolute values of x,y,z and y+z is the sum
of the remaining two absolute values.

These coefs are close to minimizing the variance of the relative

You are using the uniform distribution on the unit sphere, are you?