Is it a defect to center a simulation in [0.5, 0.5, 0.5] with a box size of 1?
Asked Answered
A

1

6

I am a numerical physicist, and I've seen some simulation codes in my community which use a 3D simulation box with a center in [0.5, 0.5, 0.5] and a normalized length of 1 (so the box coordinates goes from 0. to 1.). In this box a lot of physical computations are performed and generally the best possible precision is required.

I think that doing a such thing can be viewed as a defect, but I would like to have the confirmation of that. I tends to think this is a defect, because as we have more numerical precision near 0., the numerical accuracy is not well balanced in the whole box.

To have a good balance I think that such a box :

  • should be centered around 0. (going from -0.5 to 0.5) if one wants a symmetric accuracy around the center of the box
  • should be centered around 1.5 (going from 1. to 2.) if one wants a quasi-homogeneous accuracy in the entire box

Am I correct or completely wrong ?

Alard answered 25/6, 2014 at 18:29 Comment(3)
scicomp.stackexchange.com?Cockleboat
If the domain is bounded like this, fixed point arithmetic may be more appropriate. Using the [1.0-2.0] domain in FP will only use 23 out of 32 bits, or 53 out of 64 (assuming IEEE754).Revolve
I agree with the fixed point. If this is done using 32 bit or 64 bit integers, it is probably more performant as well. And the precision is uniform across the entire range.Scoria
T
7

You are correct.

The precision from 1.0 to 2.0 will be uniform across the surface, like you are using fixed point.

The precision from -0.5 to 0.5 will be highest around the center point, and lower near the edges (but still quite good).

The precision from 0.0 to 1.0 will be highest around the (0.0, 0.0) corner and lowest around the (1.0, 1.0) corner, so it will behave in a slightly non-uniform manner.

Tetramethyldiarsine answered 25/6, 2014 at 18:32 Comment(4)
As someone who only knows that float isn't completely accurate because of rounding errors, could you explain why is the accuracy higher around some numbers than others? Also, does the accuracy just drop the further you are from 0?Simarouba
Because floating point numbers have three parts of fixed length: sign-bit, exponent and mantissa. `number = sign(+/- 1) * mantissa * 2**exponent. (This is not quite accurate though. Search, and you will find more accurate answers)Clank
steve.hollasch.net/cgindex/coding/ieeefloat.html If you are genuinely curious and enjoy math.Tetramethyldiarsine
@A.Andevski: because floating-point numbers are approximately logarithmically spaced, there are as many floating-point numbers between, say, 1/64th and 1/32nd as there are between 1/4 and 1/2 or 1/2 and 1. Thus, there are over 100 times as many floats between 0 and 0.5 as there are between 0.5 and 1.0; for double there are more than 1000 times as many.Toein

© 2022 - 2024 — McMap. All rights reserved.