Re: Mathematicas simplifications
- To: mathgroup at smc.vnet.net
- Subject: [mg96333] Re: Mathematicas simplifications
- From: "Sjoerd C. de Vries" <sjoerd.c.devries at gmail.com>
- Date: Thu, 12 Feb 2009 06:32:06 -0500 (EST)
- References: <gmrmfk$a0f$1@smc.vnet.net>
I'm not sure whether I would call it a bug. Select works on lists, but Divisors[n] isn't a list until you provide the value of n explicitely. If n is not an integer you don't even get a list. With your function definition, the Select is given a specific value for n upon evaluation so everything is fine. I do think Select responds inconsistently to undecidable cases like this. If you try Select[Divisors[n], EvenQ] Select[Divisors[n], NumericQ] Select[Divisors[n], IntegerQ] Select[Divisors[n], PrimeQ] Select[Divisors[n], VectorQ] Select[Divisors[n], AtomQ] Select[Divisors[n], SquareFreeQ] the first five expressions give you an error message During evaluation of In[62]:= Divisors::argx: Divisors called with 0 arguments; 1 argument is expected. >> Out[62]= Divisors[] The last two yield simply: Divisors[n]. The strange thing is that it is Divisors[ ] that's giving the message in some cases and not in other, similar, cases. I would expect Select to give a message. Actually, in my opinion, in cases like this the best solution would be to have Select to return unevaluated. Cheers -- Sjoerd On Feb 10, 12:55 pm, Kilian Kilger <kil... at nihilnovi.de> wrote: > Hello, > > if I type in Mathematica 7 for example > > Select[Divisors[n],SquareFreeQ] > > It gives me > > Divisors[n] > > as a response, which is wrong. If I type > > f[n_] := Select[Divisors[n],SquareFreeQ] > > and then > > f[4] > > it gives me > > {1,2} > > which is correct. If I type (afterwards) > > f[n] > > again the wrong answer "Divisors[n]" is shown. What am I doing wrong? Sam= e happens in many other circumstances. > > Thanks in advance, > Kilian.