comp.lang.idl-pvwave archive - RDF feed
type: channel
description: Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado
items: Re: Divide By Zero error

Re: Divide By Zero error
type: item
description: 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? &nbsp; Logan <BLOCKQUOTE dir=ltr style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px"> "Logan Lindquist" &lt;<A href="mailto:llindqusit@mrdoc.cc">llindqusit@mrdoc.cc&gt; wrote in message <A href="news:9s995b$bnq$1@sulawesi-fi.lerc.nasa.gov">news:9s995b$bnq$1@sulawesi-fi.lerc.nasa.gov...
creator: Logan Lindquist
date: 2001-11-07T21:25:05-00:00

Re: Divide By Zero error
type: item
description: 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. &nbsp; 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.] &nbsp; Hopefully someone will read this! I am going to try calling RSI to see if they have an answer. &nbsp; Thanks, &nbsp; Logan Lindquist <BLOCKQUOTE dir=ltr style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px"> "Logan Lindquist" &lt;<A href="mailto:llindqusit@mrdoc.cc">llindqusit@mrdoc.cc&gt; wrote in message <A href="news:9sc8tm$otu$1@sulawesi-fi.lerc.nasa.gov">news:9sc8tm$otu$1@sulawesi-fi.lerc.nasa.gov... &nbsp;
creator: Logan Lindquist
date: 2001-11-08T15:37:39-00:00

Re: Divide By Zero error
type: item
description: What is the log of zero ?? Logan Lindquist wrote: I got another one for all you math whiz's!&nbsp;Here is the error*****IDL> .STEP% Program caused arithmetic error: Floating divide by 0% Program caused arithmetic error: Floating illegal operand&nbsp;&nbsp;Caused by second statement [log]****f = fft(tempfft, -1)power = -alog10(double(f))&nbsp;&nbsp;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:&nbsp;print, f*****( 55.0313, 0.000000)( 0.378331, 1.10309)( -0.281250, 0.312500)( -0.284581, 0.134343)( -0.281250, 0.000000)( -0.284581, -0.134343)( -0.281250, -0.312500)( 0.378331, -1.10309)( 0.467505, 0.265950)( 0.117743, -0.359700)( 0.0514515, -0.0800206)( 0.0514515, -0.0175206)( 0.0643956, -0.00457645)( 0.0735485, 0.00457646)( 0.0643956, 0.0396177)( 0.139840, 0.0266735)( -0.234375, 0.265625)( 0.0312500, -0.0845971)( -0.0156250, -0.0156250)( -0.0129442, -0.0533471)( 0.0156250, -0.0468750)( 0.0312500, -0.0404029)( -0.0156250, -0.0156250)( 0.0754442, -0.00915291)( -0.217505, 0.109700)( 0.0735485, -0.0487706)( -0.00189563, 0.0708677)( 0.00725728, -0.0159502)( -0.00189563, 0.0266735)( -0.0148398, -0.00457646)( 0.0735485, 0.0137294)( 0.0514515, -0.0266735)( -0.187500, 0.000000)( 0.0377221, -0.0156250)( 0.000000, 0.000000)( -0.00647209, 0.0156250)( 0.000000, 0.000000)( -0.00647209, -0.0156250)( 0.000000, 0.000000)( 0.0377221, 0.0156250)( -0.217505, -0.109700)( 0.0514515, 0.0266735)( 0.0735485, -0.0137294)( -0.0148398, 0.00457646)( -0.00189563, -0.0266735)( 0.00725728, 0.0159502)( -0.00189563, -0.0708677)( 0.0735485, 0.0487706)( -0.234375, -0.265625)( 0.0754442, 0.00915291)( -0.0156250, 0.0156250)( 0.0312500, 0.0404029)( 0.0156250, 0.0468750)( -0.0129442, 0.0533471)( -0.0156250, 0.0156250)( 0.0312500, 0.0845971)( 0.467505, -0.265950)( 0.139840, -0.0266735)( 0.0643956, …
creator: Paul Manusiu
date: 2001-11-09T05:24:04-00:00

Re: Divide By Zero error
type: item
description: 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
creator: Nigel Wade
date: 2001-11-09T09:34:25-00:00

Re: Divide By Zero error
type: item
description: "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 ------------------------------------------------------------ --------------
creator: Craig Markwardt
date: 2001-11-09T22:59:44-00:00

Re: Divide By Zero error
type: item
description: Paul, &nbsp; 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. &nbsp; 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! &nbsp; Regards, &nbsp; Logan &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&gt; wrote in message <A href="news:3BEB6874.8305BCD@alinga.newcastle.edu.au">news:3BEB6874.8305BCD@alinga.newcastle.edu.au... What is the log of zero ??
creator: Logan Lindquist
date: 2001-11-10T22:06:20-00:00

Re: Divide By Zero error
type: item
description: "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
creator: Logan Lindquist
date: 2001-11-10T22:10:29-00:00

Re: Divide By Zero error
type: item
description: 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 ------------------------------------------------------------ --------------
creator: Stein Vidar Hagfors H[1]
date: 2001-11-12T16:52:00-00:00

Re: Divide By Zero error
type: item
description: 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. given, y = 10 ^ x than, log_base_10 both sides gives log(y) = x if x = 0, than, in the first equation y = 1, if y = 0,&nbsp; x is not defined.&nbsp; (i.e. there is no power of 10 that can give you y = 0) Therefore, log (0) does not exist.&nbsp;&nbsp; As for what you do with zeros, I usually set a limit on my arrays. If array[i] less than limit, than array[i] equal limit. 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. You can use the "where" function for quick search of array. Cheers Paul M. Logan Lindquist wrote: Paul,&nbsp;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.&nbsp;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!&nbsp;Regards,&nbsp;Logan&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> wrote in message <a href="news:3BEB6874.8305BCD@alinga.newcastle.edu.au">news:3BEB6874.8305BCD@alinga.newcastle.edu.au...What is the log of zero ?? -- ------------------------------------------------------------ -- Tapu'osi Paul Manusiu …
creator: Paul Manusiu
date: 2001-11-14T01:57:26-00:00