Re: Divide By Zero error [message #27877] |
Sat, 10 November 2001 14:10  |
Logan Lindquist
Messages: 50 Registered: October 2001
|
Member |
|
|
"Nigel Wade" <nmw@ion.le.ac.uk> wrote in message
news:9sg7v1$9ofc$1@rook.le.ac.uk...
> Also, what is the log of a negative number?
Nigel,
I guess those don't exist either and I should be taking the absolute value
or converting it to a data format that doesn't include negative numbers
BEFORE taking the log of it. That might help things a bit. Thanks for the
suggestion!
Regards,
Logan
|
|
|
|
|
|
|
|
Re: Divide By Zero error [message #27904 is a reply to message #27901] |
Thu, 08 November 2001 21:24   |
Paul Manusiu
Messages: 8 Registered: October 2001
|
Junior Member |
|
|
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<body bgcolor="#FFFFFF">
What is the log of zero ??
<p>Logan Lindquist wrote:
<blockquote TYPE=CITE><style></style>
<font face="Arial"><font size=-1>I
got another one for all you math whiz's!</font></font> <font face="Arial"><font size=-1>Here
is the error</font></font><font face="Arial"><font size=-1>*****</font></font><font size=-2>IDL>
.STEP</font><font size=-2>% Program caused arithmetic error: Floating divide
by 0</font><font size=-2>% Program caused arithmetic error: Floating illegal
operand</font> <font face="Arial"><font size=-1> Caused by second
statement [log]</font></font><font face="Arial"><font size=-1>****</font></font><font face="Arial"><font size=-1>f
= fft(tempfft, -1)</font></font><font face="Arial"><font size=-1>power
= -alog10(double(f))</font></font> <font face="Arial"><font size=-1>I
tried a bunch of different things trying to isolate the error and get it
to stop. That is why the code looks that way and not all nice and compact.
I don't understand exactly why it's givng me invalid numbers and so this
is why I shall include the output data:</font></font> <font face="Arial"><font size=-1>print,
f</font></font><font face="Arial"><font size=-1>*****</font></font><font size=-2>(
55.0313, 0.000000)( 0.378331, 1.10309)( -0.281250, 0.312500)( -0.284581,
0.134343)( -0.281250, 0.000000)( -0.284581, -0.134343)</font><font size=-2>(
-0.281250, -0.312500)( 0.378331, -1.10309)</font><font size=-2>( 0.467505,
0.265950)( 0.117743, -0.359700)( 0.0514515, -0.0800206)( 0.0514515, -0.0175206)(
0.0643956, -0.00457645)( 0.0735485, 0.00457646)</font><font size=-2>( 0.0643956,
0.0396177)( 0.139840, 0.0266735)</font><font size=-2>( -0.234375, 0.265625)(
0.0312500, -0.0845971)( -0.0156250, -0.0156250)( -0.0129442, -0.0533471)(
0.0156250, -0.0468750)( 0.0312500, -0.0404029)</font><font size=-2>( -0.0156250,
-0.0156250)( 0.0754442, -0.00915291)</font><font size=-2>( -0.217505, 0.109700)(
0.0735485, -0.0487706)( -0.00189563, 0.0708677)( 0.00725728, -0.0159502)(
-0.00189563, 0.0266735)( -0.0148398, -0.00457646)</font><font size=-2>(
0.0735485, 0.0137294)( 0.0514515, -0.0266735)</font><font size=-2>( -0.187500,
0.000000)( 0.0377221, -0.0156250)( 0.000000, 0.000000)( -0.00647209, 0.0156250)(
0.000000, 0.000000)( -0.00647209, -0.0156250)</font><font size=-2>( 0.000000,
0.000000)( 0.0377221, 0.0156250)</font><font size=-2>( -0.217505, -0.109700)(
0.0514515, 0.0266735)( 0.0735485, -0.0137294)( -0.0148398, 0.00457646)(
-0.00189563, -0.0266735)( 0.00725728, 0.0159502)</font><font size=-2>(
-0.00189563, -0.0708677)( 0.0735485, 0.0487706)</font><font size=-2>( -0.234375,
-0.265625)( 0.0754442, 0.00915291)( -0.0156250, 0.0156250)( 0.0312500,
0.0404029)( 0.0156250, 0.0468750)( -0.0129442, 0.0533471)</font><font size=-2>(
-0.0156250, 0.0156250)( 0.0312500, 0.0845971)</font><font size=-2>( 0.467505,
-0.265950)( 0.139840, -0.0266735)( 0.0643956, -0.0396177)( 0.0735485, -0.00457646)(
0.0643956, 0.00457645)( 0.0514515, 0.0175206)</font><font size=-2>( 0.0514515,
0.0800206)( 0.117743, 0.359700)</font> <font face="Arial"><font size=-1>print,
power</font></font><font face="Arial"><font size=-1>*****</font></font><font size=-2>IDL>
print, power</font><font size=-2>-1.7406094 0.42212772 NaN NaN NaN NaN
NaN 0.42212772</font><font size=-2>0.33021387 0.92906595 1.2886023 1.2886023
1.1911436 1.1334259 1.1911436 0.85436921</font><font size=-2>NaN 1.5051500
NaN NaN 1.8061800 1.5051500 NaN 1.1223743</font><font size=-2>NaN 1.1334259
NaN 2.1392261 NaN NaN 1.1334259 1.2886024</font><font size=-2>NaN 1.4234043
Infinity NaN Infinity NaN Infinity 1.4234043</font><font size=-2>NaN 1.2886024
1.1334259 NaN NaN 2.1392261 NaN 1.1334259</font><font size=-2>NaN 1.1223743
NaN 1.5051500 1.8061800 NaN NaN 1.5051500</font><font size=-2>0.33021387
0.85436921 1.1911436 1.1334259 1.1911436 1.2886023 1.2886023 0.92906595</font> <font face="Arial"><font size=-1>What
is this NaN business and why am I getting Infinity? Arg :)</font></font> <font face="Arial"><font size=-1>Thanks
to the math geeks,</font></font><font face="Arial"><font size=-1>Logan</font></font></blockquote>
<br>
<br>
</body>
</html>
|
|
|
Re: Divide By Zero error [message #27932 is a reply to message #27878] |
Tue, 13 November 2001 17:57  |
Paul Manusiu
Messages: 8 Registered: October 2001
|
Junior Member |
|
|
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<body bgcolor="#FFFFFF">
Yes, it was a rhetorical question. The reason why you can't take the log
of zero is simple. Best described by an example.
<br>given,
<br>y = 10 ^ x
<p>than,
<br>log_base_10 both sides gives
<p>log(y) = x
<p>if x = 0, than, in the first equation y = 1,
<p>if y = 0, x is not defined. (i.e. there is no power of 10
that can give you y = 0)
<p>Therefore, log (0) does not exist.
<p>As for what you do with zeros, I usually set a limit on my arrays.
<p>If array[i] less than limit,
<br>than array[i] equal limit.
<p>Usually I set limit equal to 10^(-6). But it depends on your array values.
Best thing to do is normalize array before setting limit, than scale back
to orginal values.
<p>You can use the "where" function for quick search of array.
<p>Cheers
<br>Paul M.
<p>Logan Lindquist wrote:
<blockquote TYPE=CITE><style></style>
<font face="Arial"><font size=-1>Paul,</font></font> <font face="Arial"><font size=-1>As
far as I know :) The log[base 10] of zero and the log[base 0] do not exist.
I am not qualified to give you an mathmatical rule or proof that proves
the reason behind this. I think of it as another of those rules in mathmatics
that are just because. I do think that it has something to do with how
logs [plural of the mathmatical term and not the wooden kind] describe
the curve of lines occuring in a coordinate system. Thus a zero would indicate
that no line exists.</font></font> <font face="Arial"><font size=-1>If
you question was meant to make me aware of the reason behind my error in
IDL, I thank you. I figured this out last week and now I am working on
a solution to solve it. Any suggestions to what I should do with the zero's
in my array would be helpful!</font></font> <font face="Arial"><font size=-1>Regards,</font></font> <font face="Arial"><font size=-1>Logan</font></font>
<blockquote
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">"Paul
Manusiu" <<a href="mailto:phpvm@alinga.newcastle.edu.au">phpvm@alinga.newcastle.edu.au</a>>
wrote in message <a href="news:3BEB6874.8305BCD@alinga.newcastle.edu.au">news:3BEB6874.8305BCD@alinga.newcastle.edu.au</a>...What
is the log of zero ??</blockquote>
</blockquote>
<p>--
<br> ------------------------------------------------------------ --
<br>Tapu'osi Paul Manusiu Loto'aniu & amp;nbsp;
Tel: +61 0249 215566
<br>CRC for Satellite Systems &am p;nbsp; &am p;nbsp;
Fax: +61 0249 216907
<br>Space Physics Group
<br>School of Mathematical and Physical Sciences
<br>University Of Newcastle, Australia
<br> ------------------------------------------------------------ --
<br>"The greatness of a nation and its moral progress can be judged
<br>by the way its animals are treated".
<br>- GANDHI
<br>
</body>
</html>
|
|
|
Re: Divide By Zero error [message #27966 is a reply to message #27902] |
Mon, 12 November 2001 08:52  |
Stein Vidar Hagfors H[1]
Messages: 56 Registered: February 2000
|
Member |
|
|
Nigel Wade <nmw@ion.le.ac.uk> writes:
> Paul Manusiu wrote:
>
>> What is the log of zero ??
>>
>> Logan Lindquist wrote:
>>
>> What is this NaN
>>> business and why am I getting Infinity?
>
> Also, what is the log of a negative number?
>
> --
> -----------------------------------------------------------
> Nigel Wade, System Administrator, Space Plasma Physics Group
Hey, someone else in the Space Plasma Physics dept might tell you
that alog(-1) should return complex(0,+/-!PI) !
e^(-i pi) + 1 = 0
And therein lies a lot!
--
------------------------------------------------------------ --------------
Stein Vidar Hagfors Haugan
ESA SOHO SOC/European Space Agency Science Operations Coordinator for SOHO
NASA Goddard Space Flight Center, Email: shaugan@esa.nascom.nasa.gov
Mail Code 682.3, Bld. 26, Room G-1, Tel.: 1-301-286-9028/240-354-6066
Greenbelt, Maryland 20771, USA. Fax: 1-301-286-0264
------------------------------------------------------------ --------------
|
|
|