MathGroup Archive 1996

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Fourier[] malfunction?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg2961] Re: Fourier[] malfunction?
  • From: ianc (Ian Collier)
  • Date: Wed, 17 Jan 1996 03:08:24 -0500
  • Organization: Wolfram Research, Inc.

In article <4d511m$qe9 at dragonfly.wri.com>, bshoels at rs5.tcs.tulane.edu
(Brett Shoelson) wrote:

> Is my Fourier function malfunctioning?
> 
> In:
> Fourier[{I,2,3,4}]
> Out:
> Fourier[{I, 2, 3, 4}]
> 
> In:
> N[Fourier[{1,2,3,4}]]
> Out:
> {5. + 0. I, -1. - 1. I, -1. + 0. I, -1. + 1. I}
> 
> Should I have to use N[Fourier[list]] to get an appropriate response?
> Wolfram's book (*Mathematica: A System for Doing Mathematics by
> Computer*) seems to indicate that there is a malfunction here. Any
> ideas?
> 
> Thanks,
> Brett Shoelson
> bshoels at rs6000.tcs.tulane.edu

The command Fourier[] in Version 2.2 has slightly different behavior than
it did when the Mathematica book was written.  If all the elements in a
list are exact numbers, then Fourier[] will return the input unchanged.
If even one element is inexact, then the transform will be calculated.

Here is an example.

In[1]:= Fourier[{I,2,3,4}]

Out[1]= Fourier[{I, 2, 3, 4}]

In[2]:= Fourier[{I,2,3,4.0}]

Out[2]= {4.5 + 0.5 I, -1.5 - 0.5 I, -1.5 + 0.5 I, -1.5 + 1.5 I}

In[3]:= Fourier[N[{I,2,3,4}]]

Out[3]= {4.5 + 0.5 I, -1.5 - 0.5 I, -1.5 + 0.5 I, -1.5 + 1.5 I}

Fourier can be considered either as a symbolic function or as a numerical
function.  As a symbolic function, like Sin or Cos, it is inconsistent
for Fourier to artificially lower the precision of exact arguments.
For example, Sin[3/2] does not convert the exact number 3/2 into the
inexact number 1.5 and return an inexact result.  The guiding design
principle for symbolic functions is that exact inputs should lead to
exact outputs.

Fourier can also, however, be considered as a numerical function,
like NIntegrate, in which case the general principle is to use
inexact machine numbers when the input is exact.  This is the design
principle that was applied to Fourier prior to Version 2.2.

Although both designs are reasonable, and have advantages in particular
situations, it has become apparent as a practical matter that Fourier
is probably used more often as a numerical operation than as a
symbolic operation.  Because of this usage, this aspect of Fourier
has been changed back to its previous behavior for the next version
of Mathematica, so that Fourier will again automatically convert
exact numbers into inexact machine numbers.

If you wish, you can redefine Fourier in Version 2.2 of Mathematica
so that it will automatically convert exact inputs into inexact inputs.

In[4]:= Unprotect[Fourier]

Out[4]= {Fourier}

In[5]:= Fourier[e_] := With[{ne = N[e]},
                Fourier[ne] /; Precision[ne] =!= Infinity] /;
                                     Precision[e] === Infinity

In[6]:= Protect[Fourier]

Out[6]= {Fourier}

In[7]:= Fourier[{I,2,3,4}]

Out[7]= {4.5 + 0.5 I, -1.5 - 0.5 I, -1.5 + 0.5 I, -1.5 + 1.5 I}

I hope this helps.

--Ian

-----------------------------------------------------------
Ian Collier
Technical Sales Support
Wolfram Research, Inc.
-----------------------------------------------------------
tel:(217) 398-0700     fax:(217) 398-0747      ianc at wri.com
Wolfram Research Home Page:             http://www.wri.com/
-----------------------------------------------------------

==== [MESSAGE SEPARATOR] ====


  • Prev by Date: Speed up Mathematica for Windows 95
  • Next by Date: Re: Fourier[] malfunction?
  • Previous by thread: Fourier[] malfunction?
  • Next by thread: Re: Fourier[] malfunction?