Stop Microsoft

Miscellaneous => Programming & Networking => Topic started by: SameBrian on 13 October 2004, 00:39

Title: checking for infinity
Post by: SameBrian on 13 October 2004, 00:39
I was fooling around with an inflation rate calculation program in school, and I was wondering if there is a way to see when a number hits infinity.
I can't just use if (number == Infinity) because it expects infinity to be a function/variable. Is there some other way?
Title: checking for infinity
Post by: KernelPanic on 13 October 2004, 02:58
Infinity has no numerical value, how is the program supposed to know when the variable hits 'infinity'?
Title: checking for infinity
Post by: mobrien_12 on 13 October 2004, 07:36
Some software packages like MATALB, GNU Octave, Maple, and Mathematica know how to treat Infinity as a special number.  

If you want to know how to check for a singularity (infinity) in a general function without specialized mathematical programs, you need to break the function down into the pieces that cause it to spike to infinity and check the components individually.

For example, the function f(x)
Code: [Select]
Has two singularities, at X=-2 and X=-1.  As x approaches these values, f(x) approaches -infinity or +infinity, depending on the direction.

Hope this is of some help.

[ October 12, 2004: Message edited by: M. O'Brien ]

[ October 12, 2004: Message edited by: M. O'Brien ]