check if a number is rational



The predicate ratnump returns true when the input is an explicit rational number:

 (%i7) ratnump(2/3);
 (%o7) true

The function featurep is a mess. Sometimes featurep only consults
the fact database, other times it tries harder; for rational it seems
that featurep looks for expressions that were declared rational

 (%i1) featurep(x,'rational);
 (%o1) false

 (%i2) declare(x,rational);
 (%o2) done

 (%i3) ratnump(x);
 (%o3) false

 (%i4) featurep(x,'rational);
 (%o4) true

 (%i5) featurep(x + 2/3,'rational);
 (%o5) false

Barton

-----maxima-bounces at math.utexas.edu wrote: -----


>Dear?list,
>
>I?want?to?check?if?a?number?is?rational.?If?I?use
>
>featurep(2/3,?rational);
>
>I?get?the?answer?false.?Can?someone?explain?this?behaviour?to?me?
>(featurep(sqrt(2),?real),?however,?yields?true).
>
>Thanks?for?any?help,
>
>Christian
>
>_______________________________________________
>Maxima?mailing?list
>Maxima at math.utexas.edu
>http://www.math.utexas.edu/mailman/listinfo/maxima