Float comparison

J

jameskuyper

Richard said:
Richard Tobin said:


For CBF's benefit, a transcendental number is a number that is not
the root of any integer polynomial. Here is an integer polynomial:

f(x) = 2x^0

i.e. 2

So 2 is an integer polynomial. Therefore, the square root of 2 is a
root of an integer polynomial.

In this context, "root" refers to a value for the variable that gives
the polynomial a value of 0. The integer polynomial "2" has no roots.
The integer polynomial you're looking for is 2-x^2, which does have a
root of sqrt(2). As you can see, there is a connection between the
concept of a "ROOT of a polynomial" and a "square ROOT", but it's not
the connection you were implying.
 
C

Carl

jameskuyper said:
In this context, "root" refers to a value for the variable that gives
the polynomial a value of 0. The integer polynomial "2" has no roots.
The integer polynomial you're looking for is 2-x^2, which does have a
root of sqrt(2). As you can see, there is a connection between the
concept of a "ROOT of a polynomial" and a "square ROOT", but it's not
the connection you were implying.

Wiki says: "In mathematics, a transcendental number is a number
(possibly a complex number) that is not algebraic, that is, not a
solution of a non-constant polynomial equation with rational coefficients."


I have heard that transcendental numbers are those which cannot be
constructed using a pen and compass. Perhaps the two definitions are
the same?
 
C

CBFalconer

Dik T. Winter said:
(e-mail address removed) writes:
.... snip ...

But the new range is *not* the range you get by multiplying the
result by x_EPSILON. Do the algebra.

Alright. The value in x has a range x - x*ex to x + x*ex.
Similarly the value in y has a range y - y*ey to y + y*ey.
The size of ex is known to be orders of magnitude smaller than x.
Similarly the size of ey is orders of magnitude smaller than y. We
can assume x and y to be positive (else change some signs).

We form xmy by multiplying the values (ranges) in x and y:

xmy = x*y - x*y*ex - x*y*ey - x*y*ex*ey
= x*y *(1 - ex - ey - ex*ey) (lower range)

and all I said is that we can neglect ex*ey, since its magnitude is
at least several orders below that of ex or ey. Notice that the
calculation of the upper range is very similar. Note that the
range is still centered on x*y, i.e. the product of the nominal
(repeat, nominal) values of x and y. I don't even care if I have
given it the correct sign.

Note that the original value stored in x can have been ANYTHING in
the x range. Similarly for the value stored in y. To assert
anything else you have to go to the actual program.
 
C

CBFalconer

Keith said:
.... snip ...


You keep asserting that. You have yet to support your assertion
with reference to the standard. The things you've cited from the
standard do not support your claims.

The standard specifies the minimum error size. The point is that
you have no clue whether any particular value within that range was
stored in the FP value, without going to the program proper and
analyzing the operations performed.
 
M

Mark Wooding

CBFalconer said:
In particular rationals, reals, integers can all be put in one to one
correspondence with the set of integers. They form one form of
infinity. Transcendentals cannot, and are thus infinitely more
'dense' than the other forms.

The transcendental reals are, ummm..., real. And, as you rightly say,
the transcendental reals are uncountable; it follows that the reals are
also uncountable.

Density doesn't seem to be the right concept: the rationals are dense in
the reals. The obvious topological difference is that the reals are
locally compact, which the rationals are not.
PI, e, root(2) are all transcendental. Integers are not closed sets
under division. Reals are.

No, root-two is algebraic (indeed, an algebraic integer), being a root
of x^2 - 2.
FP values are another class.

IEEE floating point can represent things other than real numbers: in
particular, positive and negative infinities, and a not-a-number point.
(However, all the reals which can be represented as floating-point
values are in fact rationals.)

I'll shut up now.

-- [mdw]
 
M

Mark Wooding

Carl said:
I have heard that transcendental numbers are those which cannot be
constructed using a pen and compass. Perhaps the two definitions are
the same?

No. The cube root of 2 is not constructable using ruler and compasses
(hence duplicating the cube is impossible), but it is certainly
algebraic being a root of x^3 - 2.

I think that either whoever told you this was confused, or you've
misremembered.

-- [mdw]
 
E

Eric Sosman

CBFalconer said:
[...] In particular rationals, reals,
integers can all be put in one to one correspondence with the set
of integers. [...]

Nonsense. The integers are 1-1 with the integers, and
the integers are 1-1 with the rationals. But the integers
are *not* 1-1 with the reals. Look up "diagonal argument,"
and try to refrain from posting about what you wot not.
 
C

CBFalconer

Eric said:
CBFalconer said:
[...] In particular rationals, reals, integers can all be put
in one to one correspondence with the set of integers. [...]

Nonsense. The integers are 1-1 with the integers, and
the integers are 1-1 with the rationals. But the integers
are *not* 1-1 with the reals. Look up "diagonal argument,"
and try to refrain from posting about what you wot not.

I think I was posting about what I once wot, but have not wotted
for a few decades.
 
K

Kaz Kylheku

In particular rationals, reals, integers can all be put in one to one
correspondence with the set of integers.

Ouch! Cantor called, asking whether he could have his diagonalization back,
since we aren't using it.
 
K

Keith Thompson

Golden California Girls said:
(s/konw/know/


Once again what gets stored (domain of representable values) has
little if any relation to what should have been stored (domain of
real numbers).

Perhap, but (a) how do you know what *should* have been stored* and
(b) we were discussing what actually *is* stored.

[snip]
Every new programmer should be taught this until it sinks in, then
they can take a class in numeric analysis and realize that any
floating point number in base 2 is always just one possibility out
of a range, that being from that number to the upper error bound
down to the number less the lower error bound. Then they will
understand one of the truths of the universe that if a floating
point number turns out to be correct it is a miracle and the counter
example to Murphy's law.

Or it's a result of careful programming and analysis.

double x = 1.0;

x contains exactly what I want it to. In this particular case, there
is no error.
 
D

Dik T. Winter

> Wiki says: "In mathematics, a transcendental number is a number
> (possibly a complex number) that is not algebraic, that is, not a
> solution of a non-constant polynomial equation with rational coefficients."
>
> I have heard that transcendental numbers are those which cannot be
> constructed using a pen and compass. Perhaps the two definitions are
> the same?

No. The numbers that cannot be constructed are the non-constructable
numbers. The transcendental numbers are a subset of them.
 
D

Dik T. Winter

> Alright. The value in x has a range x - x*ex to x + x*ex.
> Similarly the value in y has a range y - y*ey to y + y*ey.
> The size of ex is known to be orders of magnitude smaller than x.
> Similarly the size of ey is orders of magnitude smaller than y. We
> can assume x and y to be positive (else change some signs).
>
> We form xmy by multiplying the values (ranges) in x and y:
>
> xmy = x*y - x*y*ex - x*y*ey - x*y*ex*ey
> = x*y *(1 - ex - ey - ex*ey) (lower range)
>
> and all I said is that we can neglect ex*ey, since its magnitude is
> at least several orders below that of ex or ey. Notice that the
> calculation of the upper range is very similar. Note that the
> range is still centered on x*y, i.e. the product of the nominal
> (repeat, nominal) values of x and y. I don't even care if I have
> given it the correct sign.

Yes, it is a range centered on x*y, but the bounds of the range are
*not* eps(x*y), but eps(x + y), which can be much larger (e.g. if
|x|,|y| < 1).
 
R

Richard Tobin

Wiki says: "In mathematics, a transcendental number is a number
(possibly a complex number) that is not algebraic, that is, not a
solution of a non-constant polynomial equation with rational coefficients."

Note that they could equally well have said "integer" instead of
"rational", as you can multiply through by the LCM of the denominators
to get an equivalent equation.

I'm not sure what the implication of "non-constant" is supposed to be.
Perhaps it means "non-zero", to exclude 0x = 0.

-- Richard
 
R

Richard Bos

CBFalconer said:
This is a chimera. The errors are small, compared with the
values. The sort of effect you are worrying about is of the form
error_ratio squared, and thus negligible.

In other words, you have never worked with floating-point matrices.

Richard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top