Miscellaneous > Programming & Networking
checking for infinity
(1/1)
SameBrian:
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?
KernelPanic:
Infinity has no numerical value, how is the program supposed to know when the variable hits 'infinity'?
mobrien_12:
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: ---
--- End code ---
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 ]
Navigation
[0] Message Index
Go to full version