Re: too many zero's and orbital mechanics.



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
.



Relevant Pages

  • Re: too many zeros and orbital mechanics.
    ... How do I tell Matlab not to do that? ... Matlab still reads the eccentricity as ... I can try round(e) which does round that to zero, ...
    (comp.soft-sys.matlab)
  • too many zeros and orbital mechanics.
    ... an eccentricity of zero is a circle. ... How do I tell Matlab not to do that? ... I can try round(e) which does round that to zero, ...
    (comp.soft-sys.matlab)
  • Re: no zero mean of the function randn
    ... function of the Matlab, I do not get zero mean, what it should be, ... estimates of the true mean and variance. ... they will never be exact. ...
    (comp.soft-sys.matlab)
  • Re: zero based arrays?
    ... John D'Errico wrote: ... There is a very real and very 'physical' reason for zero based ... of this, but c came before Matlab, and in fact, Matlab is written in ... them, or else programming would never work, ever, at all. ...
    (comp.soft-sys.matlab)
  • Re: doubt on indeterminate forms
    ... I forgot about the other common sci.math question, ... Steve Lord ... with f and g both approaching zero and both ... matlab to investigate the behavior of x^y in the immediate vicinity of the ...
    (comp.soft-sys.matlab)