INF - infinity


[ Zettels Traum ] [ search / suche ]

von dp am 08.Januar 98 um 14:59:43:

Alexander Palmo discovered:

>put tan(3*pi/2)
>-- INF

here are some further experiments by Mark Whybird:

put INF
-- Void

(i.e. the variable named INF is void. INF is not evaluated as a value)

put value("INF")
-- Void

set x = tan(3*pi/2)
put x
-- INF
put ilk(x)
-- #float

set y = tan(2*pi/4)
put y
-- INF
put y = x
-- 0
set y = x
put y = x
-- 0

put x = x
-- 0

put atan(y)
-- 1.5708
(this is equal to 2*pi/4, the smallest value that an angle with a tangent of
"infinity" (i.e. an undefined tangent) could be)

put atan(tan(3*pi/2))
-- 1.5708
(fair enough, I suppose, given what I just said above)

This works in Dir. 6. It also works in Dir. 5, provided you first
initialize pi with
set pi = 4*atan(1)

so it would appear that whoever programmed the TAN and ATAN functions made
up a strange value for float variables called INF, which never evaluates to
true when compared with anything, even itself, but does work correctly at
least within the context of the tan and atan functions.

Any Macromedia engineers care to comment, or tell us where else this INF
value works? I can't find any documentation on it - is it something we can
rely on in future releases? (or better yet, have it properly integrated so
that x/0 = INF, etc?)

Oh, and to answer Alexander's question
>Is this standard computer speak for 'undefined'?
the answer is no.

PS. It seems to me that "undefined" is a better term for this result than
the "infinity" implied by INF - at least it makes it easier to explain
things like

put x
-- INF
put x = x
-- 0

any mathematicians care to comment here?

Of course, for proper integration, it would be necessary to be able to test
such similarity (if not equality) somehow - maybe an isUndefined()
function - although even if not strictly mathematically correct (although it
could be for all I know), it would be helpful for practical reasons if
comparisons to INF worked as you might expect, and INF was predefined as a
"constant" (as pi is in Dir. 6).

To which Glenn M. Picher added:

>Is [INF] standard computer speak for 'undefined'?

For 'infinity', actually, although I don't know how
'standard' that abbreviation is.

The tangent is the ratio between the opposite and the
adjacent sides of a right triangle. As the opposite side
increases to the full height of the unit circle at 90
degrees, the adjacent side decreases to 0. A large number
divided by a small number makes for a huge number. At
90 degrees, the 'small number' really *is* 0; the
result of the division is 'so huge, it's infinity'. (One can not
really divide by 0-- that's what the odd return
value is meant to indicate.)

At 90 degrees and 270 degrees, there is no longer any
triangle to talk about since there's no third side. So
tan() is not really valid for such a non-angle. Graphs of the
tangent function make this pretty clear, as they
show a sort of tilted S-shaped curve that approaches,
but never touches, an asymptote (imaginary vertical
line) at 90 and 270 degrees. The center of the 's'
shape crosses 0 at 180 degrees (and half of an
's' shape crosses 0 at 0 degrees, and another half
an 's' shape crosses 0 at 360 degrees).

Since 180 degrees is the same thing as pi() radians, then
90 degrees is pi()/2.0 radians, and 270 degrees is 1.5 * pi()
radians. (You actually have 90 and 270 degrees reversed
in what you've shown above, but the numbers you suppy
boil down to the same numbers I've just listed).

So it's the values you are providing to tan() that are causing the
'INF' errors. You've discovered the only two values that
will produce that error. Well, except that rotations more than 360
degrees that also coincide with 90 and 270 can produce the error
too...

put tan((pi()*2.0) + (pi()/2.0)) --full circle, plus 90 degrees
-- INF

... as can negative rotations, which produce 'negative infinity'...

put tan(-(pi()/2.0))
-- -INF




Dazu:























D. Plänitz