Re: too many zero's and orbital mechanics.
- From: ellieandrogerxyzzy@xxxxxxxxxxxxxxxxxxxxxx (Roger Stafford)
- Date: Sun, 13 May 2007 08:05:31 GMT
In article <ef56bdc.-1@xxxxxxxxxxxxxxxxxxxxxxx>, tony
<napoleaninmud@xxxxxxxxx> wrote:
In Orbital Mechanics, an eccentricity of zero is a circle.--------------------
When my program calculates eccentricity, instead of giving me a
simple "0.0000," the program outputs " e: 2.2204e-16 "
which for me...is essentially zero.
How do I tell Matlab not to do that?
I've tried "format bank" and "format compact" to try and limit the
decimal places, but apparently that only works for the output and not
the actual calculation. Matlab still reads the eccentricity as
greater than 0.00.
I can try round(e) which does round that to zero, but can i round to
two decimal places without the crazy scientific notation?
Thanks!
Tony, my own recommendation would be that, rather than altering 'e'
itself for cosmetic purposes when it produces a value like your 2.2204e-16
(which in fact is just 1/2^52), you should in general revise your
criterion as to when an orbit is to be considered as essentially having no
eccentricity, and leave the value of 'e' you obtain untouched. The same
applies to a great many other circumstances, such as when a set of points
is to be regarded as coplanar, when a number y is considered an integral
multiple of a number x, or when you have found a solution to the equation
tan(x) = x. In your case, instead of insisting that 'e' should have the
exact value of zero, clear down to the least significant bit, you can
loosen the requirement to say only that it be within some reasonably small
range of zero, as for example abs(e) < 1e-14. The particular value you
use for this would depend on how much round off error you can expect in
your computations. Matlab's relational operator for exact equality, '==',
should be applied only in special cases when it is known that no round off
error can possibly have occurred.
In all digital computers, round off errors are a fact of life and must
be allowed for in the vast majority of computations, and this would be
particularly true of orbital mechanics. With computers that use binary
floating point arithmetic, as matlab does, about the only computations
that can be counted on to be exact are certain of those involving integers
or fractions whose denominators are powers of two. For example, if you
multiply 3/8 by 41/64, you will get the exact answer of 123/512 =
0.240234375, but such exactitude is a rarity. Doing division of the same
numbers would produce a round off error out in the 53rd bit of the answer,
because binary floating point numbers cannot represent the fraction 24/41
exactly. A related fact is that most decimal fractions cannot be
represented as exact binary fractions. You cannot, for example, achieve
an exact 0.1 value, (much to the despair of a great many beginning
students of matlab who have attempted to do just that in numerous frantic
communications on comp.soft-sys.matlab.)
Roger Stafford
.
- References:
- too many zero's and orbital mechanics.
- From: tony
- too many zero's and orbital mechanics.
- Prev by Date: Re: no warnings
- Next by Date: Re: no warnings
- Previous by thread: Re: too many zero's and orbital mechanics.
- Next by thread: no warnings
- Index(es):
Relevant Pages
|