Take the 2-minute tour ×
Computational Science Stack Exchange is a question and answer site for scientists using computers to solve scientific problems. It's 100% free, no registration required.

If one wants to solve a problem in physics, one often has to deal with very small numbers because of the units, e.g. the energy range of interest of semiconductors lies in the region $eV \approx 10^{-19}J$. For a given problem one could derive equations that are using scaled properties, e.g. instead of SI units using a different set of units so the numbers in use are not so small. Since deriving equations in scaled units is another source of error I am interested if there are any drawbacks (speed, precision,...) when computing with SI units and therefore very small numbers compared to scaled units and larger numbers?

share|improve this question

3 Answers 3

up vote 6 down vote accepted

It is the difference in scales between terms in your equations that tend to cause numerical difficulties. You may work in any units you like as long as you are consistent. My approach has been to always consistently non-dimensionalize my equations in order to reduce the number of parameters to the minimum required, but this is only for my convenience.

share|improve this answer
    
Since the difference will be much less in scaled equations, it is better to use those then, correct? –  DaPhil Jun 4 at 12:32
    
No, changing the scale is dividing through by a constant factor. It's really the relative difference between the scales of the terms that matters, and rescaling the equations can't change that. –  Bill Barth Jun 4 at 13:00
1  
@DaPhil I think what you describe would be an issue in fixed point arithmetic, but not in floating point, hence why it is the relative difference between the scales of the terms and not simply their magnitude (whether it be small or large) that is important –  user2697246 Jun 4 at 13:49
    
I assume when you say "relative difference" you really mean the "ratio" -- because that's the relevant quantity. –  Wolfgang Bangerth Jun 5 at 4:04

In contrast to Bill Barth, I usually try to keep things in dimensional form. Within a single equation, this of course does not change the relative scaling of terms. However, not doing the scaling requires that one pays attention to the relative scaling between different equations of a system of equations. A discussion of one case we have documented can be found in this paper, section 3.2.4.

share|improve this answer
    
This is an excellent point from Wolfgang. –  Bill Barth Jun 4 at 18:27

In most cases, it does not matter what system of units you use. However, physics deals with quite small an quite large numbers (in SI), and particularly if you're using single-precision floating points you can get into trouble very quickly. For instance, the electron charge squared is very close to what can be represented. In these cases using units in which your quantities are close to 1 makes sense.

Why would you use single-precision floating points you ask? Speed! HPC is often done using single-precision for instance.

I have to say that I don't think using scaled units will increase the number of bugs you see. In my field, the common unit of energy is $MeV$ and the common length unit is $cm$ which is usually quite convenient. The trick is to only do the unit conversion once, if you really need the SI quantity. If you're worried about converting physical constants, most are typically quoted in a number of unit systems, depending on how they're most often used.

share|improve this answer
    
Use of single-precision is confined to a handful of problems in HPC in my experience. Double is much more common. –  Bill Barth Jun 4 at 18:21
    
I agree that double is far more common, but almost all GPU computations are single precision which has somewhat revived the use. Still, not something to worry about for your Matlab/python code. –  LKlevin Jun 4 at 19:36
    
I'd love to see a citation of this. My experience differs. –  Bill Barth Jun 4 at 19:48
    
Somewhat difficult to give a citation for this. My comment was based on personal experience and the fact that on most GPUs single precision performance is 8-16 times higher than double precision. On some (but not all) HPC cards, the difference is only a factor of 3, but in the applications I have seen, none have defaulted to double precision. –  LKlevin Jun 4 at 20:10
    
I think you're a bit behind the times. HPC cards are basically the standard factor of 2 now (just like CPUs). I don't keep track of this on gaming-class cards, but my experience tends towards double-precision now. –  Bill Barth Jun 4 at 20:43

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.