Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2007
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2007

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

Search the Archive

Re: IsExact

  • To: mathgroup at smc.vnet.net
  • Subject: [mg80561] Re: [mg80523] IsExact
  • From: DrMajorBob <drmajorbob at bigfoot.com>
  • Date: Sun, 26 Aug 2007 03:03:15 -0400 (EDT)
  • References: <20461890.1187966104775.JavaMail.root@m35>
  • Reply-to: drmajorbob at bigfoot.com

ClearAll[n, x, y, a, a1, a2, b, r];
c1 = {1, 2*I/5, E^(25*n), 3/4 + I, Cos[n*x*Pi], y*Sqrt[-5]};
c2 = {a/b, r + 2/5, a1, a2};
c3 = {1.5, 0, Sqrt[3], 0, 4};
c4 = {(r + 0.5)/3, 3/7, 3 + Sin[4*x*y]};
c5 = {1, 2, 3, 4, 5, 6} + 0.0;
c6 = {N[x]};
test = {c1, c2, c3, c4, c5, c6};

noReals = FreeQ[#, _Real] &;

noReals /@ test

{True, True, False, False, False, True}

That's correct if the undefined variables are exact. Define them, and you  
may get different results. For c6, it also depends on whether x is defined  
before, or after, c6:

Clear[x]
c6 = {N[x]}
noReals@c6
x = 7
noReals@c6
x = 7.
noReals@c6

{x}

True

7

True

7.

False

or

x = 7
c6 = {N[x]};
noReals@c6

7

{7.}

False

Bobby

On Fri, 24 Aug 2007 01:00:28 -0500, <carlos at colorado.edu> wrote:

> Let c be a 1D list of scalar coefficients, numeric or symbolic,
> real or complex. No entry is a list. Examples:
>
> ClearAll[n,x,y,a,a1,a2,b,r];
> c1={1,2*I/5,E^(25*n),3/4+I,Cos[n*x*Pi],y*Sqrt[-5]};
> c2={a/b,r+2/5,a1,,,,,a2};
> c3={1.5,0,Sqrt[3],0,4};
> c4={(r+0.5)/3,3/7,3+Sin[4*x*y]};
> c5={1,2,3,4,5,6}+0.0;
> c6={N[x]};
>
> I need a function IsExact[c] that returns False if
> at least one entry of c is floating, or if it contains one
> floating number; else True.  For example, tests on
> c1 and c2  should return True; the others False.
>
> Any simple way to implement this? It should work on V.5.
> Thanks.
>
>
>



-- =

DrMajorBob at bigfoot.com


  • Prev by Date: Re: FindFit and complex function?
  • Next by Date: Re: Style in Manipulate
  • Previous by thread: Re: IsExact
  • Next by thread: Re: IsExact