comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Divide By Zero error
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Divide By Zero error [message #27877] Sat, 10 November 2001 14:10 Go to next message
Logan Lindquist is currently offline  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 #27878 is a reply to message #27877] Sat, 10 November 2001 14:06 Go to previous messageGo to next message
Logan Lindquist is currently offline  Logan Lindquist
Messages: 50
Registered: October 2001
Member
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2600.0" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Paul,</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>As far as I know :) The log[base 10]&nbsp;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&nbsp;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></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>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&nbsp;suggestions to what I should do
with&nbsp;the zero's in my array would be helpful!</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Regards,</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Logan</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<BLOCKQUOTE
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Paul Manusiu" &lt;<A
href="mailto:phpvm@alinga.newcastle.edu.au">phpvm@alinga.newcastle.edu.au</A>&gt;
wrote in message <A
href="news:3BEB6874.8305BCD@alinga.newcastle.edu.au">news:3BEB6874.8305BCD@alinga.newcastle.edu.au</A>...</DIV>
<DIV>What is the log of zero ?? </DIV></BLOCKQUOTE></BODY></HTML>
Re: Divide By Zero error [message #27884 is a reply to message #27878] Fri, 09 November 2001 14:59 Go to previous messageGo to next message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
"Logan Lindquist" <llindqusit@mrdoc.cc> writes:

> This is a multi-part message in MIME format.
>
> ------=_NextPart_000_0009_01C16841.6350B0C0
> Content-Type: text/plain;
> charset="iso-8859-1"
> Content-Transfer-Encoding: quoted-printable
>
> Does anyone know what the minum window size is for the fft function? =
> Does it have to be divisble by a certain number? I am getting 0's with a =
> 8x8 array. The array is pretty flat and dark [all around pixel value of =
> 50] but I wouldn't think that I should get zero's returned as a =
> frequency component.=20
>
> The solution that I see is to check to see if there are zero's in the =
> array and then either change them to 0.1 or skip that array when trying =
> to display it. [with a note to the user letting them know that no =
> frequency component can be found.]
>
> Hopefully someone will read this! I am going to try calling RSI to see =
> if they have an answer.=20

Logan, the usual way fourier power is defined, is the *squared
magnitude* of the fourier coefficients.

If you define

power = -alog10( abs(f)^2 )

then I think your problems will be alleviated.

Craig

--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
Re: Divide By Zero error [message #27898 is a reply to message #27884] Thu, 08 November 2001 07:37 Go to previous messageGo to next message
Logan Lindquist is currently offline  Logan Lindquist
Messages: 50
Registered: October 2001
Member
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2600.0" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Does anyone know what the minum window size is for
the fft function? Does it have to be divisble by a certain number? I am getting
0's with a 8x8 array. The array is pretty flat and dark [all around pixel value
of 50] but I wouldn't think that I should get zero's returned as a frequency
component. </FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>The solution that I see is to check to see if there
are zero's in the array and then either change them to 0.1 or skip that array
when trying to display it. [with a note to the user letting them know that no
frequency component can be found.]</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Hopefully someone will read this! I am going to try
calling RSI to see if they have an answer. </FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Thanks, </FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Logan Lindquist</FONT></DIV>
<BLOCKQUOTE dir=ltr
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Logan Lindquist" &lt;<A
href="mailto:llindqusit@mrdoc.cc">llindqusit@mrdoc.cc</A>&gt; wrote in message
<A
href="news:9sc8tm$otu$1@sulawesi-fi.lerc.nasa.gov">news:9sc8tm$otu$1@sulawesi-fi.lerc.nasa.gov</A>...</DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV></BLOCKQUOTE></BODY></HTML >
Re: Divide By Zero error [message #27901 is a reply to message #27898] Wed, 07 November 2001 13:25 Go to previous messageGo to next message
Logan Lindquist is currently offline  Logan Lindquist
Messages: 50
Registered: October 2001
Member
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2600.0" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Uh nevermind. I went and checked what was going on.
Apparently I can't take the logrithm of zero. [oh ya!] That was giving my the
error. I am going to solve this by checking my freqency component for any zero's
before I take the log of it and replace it with a 1.&nbsp;Hopefully that will
stop giving me the error. Then I can move onto display problems. Don't ya just
love debugging? </FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Logan</FONT></DIV>
<BLOCKQUOTE dir=ltr
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Logan Lindquist" &lt;<A
href="mailto:llindqusit@mrdoc.cc">llindqusit@mrdoc.cc</A>&gt; wrote in message
<A
href="news:9s995b$bnq$1@sulawesi-fi.lerc.nasa.gov">news:9s995b$bnq$1@sulawesi-fi.lerc.nasa.gov</A>...</DIV></BLOCKQUOTE></BODY></HTML>
Re: Divide By Zero error [message #27902 is a reply to message #27901] Fri, 09 November 2001 01:34 Go to previous messageGo to next message
Nigel Wade is currently offline  Nigel Wade
Messages: 286
Registered: March 1998
Senior Member
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,
University of Leicester, Leicester, LE1 7RH, UK
E-mail : nmw@ion.le.ac.uk
Phone : +44 (0)116 2523568, Fax : +44 (0)116 2523555
Re: Divide By Zero error [message #27904 is a reply to message #27901] Thu, 08 November 2001 21:24 Go to previous messageGo to next message
Paul Manusiu is currently offline  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>&nbsp;<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>&nbsp;<font face="Arial"><font size=-1>&nbsp;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>&nbsp;&nbsp;<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>&nbsp;<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>&nbsp;<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>&nbsp;&nbsp;<font face="Arial"><font size=-1>What
is this NaN business and why am I getting Infinity? Arg :)</font></font>&nbsp;<font face="Arial"><font size=-1>Thanks
to the math geeks,</font></font><font face="Arial"><font size=-1>Logan</font></font></blockquote>

<br>&nbsp;
<br>&nbsp;
</body>
</html>
Re: Divide By Zero error [message #27932 is a reply to message #27878] Tue, 13 November 2001 17:57 Go to previous message
Paul Manusiu is currently offline  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&nbsp; 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,&nbsp; x is not defined.&nbsp; (i.e. there is no power of 10
that can give you y = 0)
<p>Therefore, log (0) does not exist.&nbsp;&nbsp;
<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>&nbsp;<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>&nbsp;<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>&nbsp;<font face="Arial"><font size=-1>Regards,</font></font>&nbsp;<font face="Arial"><font size=-1>Logan</font></font>&nbsp;
<blockquote
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">"Paul
Manusiu" &lt;<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&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& amp;nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Tel: +61 0249 215566
<br>CRC for Satellite Systems&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&am p;nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&am p;nbsp;&nbsp;&nbsp;&nbsp;&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>&nbsp;
</body>
</html>
Re: Divide By Zero error [message #27966 is a reply to message #27902] Mon, 12 November 2001 08:52 Go to previous message
Stein Vidar Hagfors H[1] is currently offline  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
------------------------------------------------------------ --------------
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: dumb question--floating
Next Topic: Re: dumb question--floating

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 15:39:30 PDT 2025

Total time taken to generate the page: 0.00886 seconds