Sponsored links: Algebra eBooks
 

Related

integerp

a:0.12345*10*10*10*10...

integerp(a);

truncate(0.12345);

Calculate

integerp

a:0.12345*10*10*10*10...

integerp(a);

truncate(0.12345);

Calculate

integerp-linsolve

eq1:x*2=y;

eq2:x+y=5;

linsolve([eq1,eq2,int...

Calculate

integerp

a:0.12345*10*10*10*10...

integerp(a);

truncate(a);

Calculate

integerp-not-sqrt

not(integerp(sqrt(2))...

Calculate

integerp-not-sqrt

not(integerp(sqrt(2))...

Calculate

integerp-sqrt

integerp(sqrt(156));

Calculate

integerp-not-sqrt

not(integerp(sqrt(2))...

Calculate

integerp

a:0.12345*10*10*10*10...

integerp(a);

truncate(a);

Calculate

integerp

a:0.12345*10*10*10*10...

integerp(a);

truncate(a);

Calculate

integerp

Run Example
(%i1)xprimep(x) := integerp(x) and (x <
 32);
(%o1)               xprimep(x) := integerp(x) and (x < 32)
(%i2) cardinality (subset (integer_partitions(30,3), lambda ([x], every (xprimep, x))));
(%o2)                                 91
(%i3) 
Run Example
kill(lastdigits,pidigits, a, b);
(%o1)                                done
(%i2) ratprint:false;
(%o2)                                false
(%i3) pidigits(prec):=block([fpprec:prec+1], ratprint:false, bftorat:false, ratepsilon:2.0e-16, float2bf:false, ans:float((%pi-mod(%pi, 10^(-prec)))), return(ans));
(%o3) pidigits(prec) := block([fpprec : prec + 1], ratprint : false, 
bftorat : false, ratepsilon : 2.0E-16, float2bf : false, 
                             - prec
ans : float(%pi - mod(%pi, 10      )), return(ans))
(%i4) lastdigits(fnum, lastn):=block([m:rat(fnum), n:lastn, ans], /* it doesn't help when lastn is bigger than the total digits in fnum it returns the whole digits in fnum anyway without erroring! and fnum=%pi stuff works only upto 8 digits cause num(rat(fnum)) has somuch only! */ratprint:false, ratio(num):=block([k, a], ratprint:false, for k:1 thru fpprec do (a:10^k/ratdenom(num), if(integerp(a)) then return(a))), ratepsilon:2.0e-16, bftorat:false,  ans:mod(ratio(fnum)*num(m), (10^n))/(ratio(fnum)*denom(m)), return(float(ans)));
(%o4) lastdigits(fnum, lastn) := block([m : rat(fnum), n : lastn, ans], 
ratprint : false, ratio(num) := block([k, a], ratprint : false, 
                                 k
                               10
for k thru fpprec do (a : -------------, if integerp(a) then return(a))), 
                          ratdenom(num)
                                                                       n
                                             mod(ratio(fnum) num(m), 10 )
ratepsilon : 2.0E-16, bftorat : false, ans : ----------------------------, 
                                                 ratio(fnum) denom(m)
return(float(ans)))
(%i5) lastdigits(4.1459, 5);
(%o5)                          4.14590001103631
(%i6) lastdigits(3.1459, 3);
(%o6)                               0.0459
(%i7) b:pidigits(5);
(%o7)                               3.14159
(%i8) lastdigits(3.14159, 3);
(%o8)                               0.00159
(%i9) lastdigits(pidigits(5), 3);
(%o9)                               0.00159
(%i10) pidigits(6);
(%o10)                             3.141592
(%i11) lastdigits(pidigits(6), 3);
(%o11)                       5.9199999999999997E-4
(%i12) lastdigits(4.14592, 3);
(%o12)                              0.00592
(%i13) lastdigits(b, 3);
(%o13)                              0.00159
(%i14) a:[0, float(%pi)];
(%o14)                      [0, 3.141592653589793]
(%i15) a;
(%o15)                      [0, 3.141592653589793]
(%i16) delete(pidigits(16), a);
(%o16)                                [0]
(%i17) delete(pidigits(fpprec), a);
(%o17)                                [0]
(%i18) delete(pidigits(fpprec), [0, float(%pi)]);
(%o18)                                [0]
(%i19) intervals(items, [granul]):=block([ start:first(items), stop:last(items), ans:[], granul:(if not(emptyp(granul)) then first(granul) else 1) ], ratprint:false, if (emptyp(items)) then [] elseif(listp(items)) then    if(emptyp(rest(items))) then []     else     while(float(rat(start))<
float(rat(stop))) do    (ans:delete([],             delete([float(rat(stop)), float(rat(stop+granul))],             if(float(rat(start+granul))>
float(rat(stop)))            then return() else            append(ans, [cons(float(rat(start)),  [float(rat(start+granul))])]))),      start:float(rat(start+granul))),     return(ans));
(%o19) intervals(items, [granul]) := block([start : first(items), 
stop : last(items), ans : [], granul : 
if not emptyp(granul) then first(granul) else 1], ratprint : false, 
if emptyp(items) then [] elseif listp(items)
 then (if emptyp(rest(items)) then [] else (while float(rat(start)) < 
float(rat(stop)) do (ans : delete([], delete([float(rat(stop)), 
float(rat(stop + granul))], if float(rat(start + granul)) > float(rat(stop))
 then return() else append(ans, [cons(float(rat(start)), 
[float(rat(start + granul))])]))), start : float(rat(start + granul))))), 
return(ans))
(%i20) intervals([0, 2*%pi], %pi);
(%o20) [[0.0, 3.141592653589793], [3.141592653589793, 6.283185307179585]]
(%i21) delete(pidigits(fpprec), intervals([0, 2*%pi], %pi));
(%o21) [[0.0, 3.141592653589793], [3.141592653589793, 6.283185307179585]]
(%i22) 
Run Example
delete(%pi, [0, 3.141592653589793]);
(%o1)                       [0, 3.141592653589793]
(%i2) ratprint:false;
(%o2)                                false
(%i3) lastdigits(fnum, lastn):=block([m:rat(ev(fnum-truncate(fnum))), n:lastn, ans], /* it doesn't help when lastn is bigger than the total digits in fnum it returns the whole digits in fnum anyway without erroring! and fnum=%pi stuff works only upto 8 digits cause num(rat(fnum)) has somuch only! */ratprint:false, ratio(num):=block([n], ratprint:false, for n:1 thru fpprec do (a:10^n/ratdenom(num), if(integerp(a)) then return(a))), ratepsilon:2.0e-16, bftorat:false,  ans:mod(ratio(fnum)*num(m), (10^n))/(ratio(fnum)*denom(m)), return(float(ans)));
(%o3) lastdigits(fnum, lastn) := block([m : rat(ev(fnum - 'truncate(fnum))), 
n : lastn, ans], ratprint : false, ratio(num) := 
block([n], ratprint : false, for n thru fpprec 
               n
             10
do (a : -------------, if integerp(a) then return(a))), ratepsilon : 2.0E-16, 
        ratdenom(num)
                                                 n
                       mod(ratio(fnum) num(m), 10 )
bftorat : false, ans : ----------------------------, return(float(ans)))
                           ratio(fnum) denom(m)
(%i4) pidigits(prec):=block([fpprec:prec+1], ratprint:false, bftorat:true, ratepsilon:2.0e-16, bftorat:false, ans:float((%pi-mod(%pi, 10^(-prec)))), return(ans));
(%o4) pidigits(prec) := block([fpprec : prec + 1], ratprint : false, 
bftorat : true, ratepsilon : 2.0E-16, bftorat : false, 
                             - prec
ans : float(%pi - mod(%pi, 10      )), return(ans))
(%i5) lastdigits(4.1459, 3);
(%o5)                               0.0459
(%i6) lastdigits(%pi, 3);
(%o6)                          0.14159265358979
(%i7) pidigits(8);
(%o7)                             3.14159265
(%i8) lastdigits(pidigits(8), 3);
(%o8)                        3.7422048968341514E-7
(%i9) lastdigits(3.1415, 3);
(%o9)                       6.6592647858382288E-11
(%i10) 
[and,apply,cardinality,every,integer_partitions,integerp,lambda,map,subset] [and,cardinality,every,integer_partitions,integerp,lambda,primep,subset] [and,cardinality,every,integer_partitions,integerp,lambda,subset] [and,every,integer_partitions,integerp,lambda,subset] [append,block,floor,integerp,makelist,mod,plot2d,random] [bfloat,bftorat,block,delete,ev,false,float2bf,if,integerp,mod,numer,ratdenom,ratepsilon,ratprint] [bfloat,bftorat,block,delete,false,float2bf,if,integerp,mod,ratdenom,ratepsilon,ratprint] [bfloat,bftorat,block,delete,false,if,integerp,mod,ratdenom,ratepsilon,ratprint] [bfloat,bftorat,block,delete,if,integerp,mod,rat,ratdenom,ratepsilon,ratprint] [bfloat,bftorat,block,emptyp,first,fpprec,if,integerp,mod,not,numer,ratepsilon,ratprint,return] [bfloat,bftorat,block,false,if,integerp,kill,mod,ratdenom,ratepsilon,ratprint] [bfloat,bftorat,block,false,if,integerp,mod,ratdenom,ratepsilon,ratprint] [bfloat,bftorat,block,if,integerp,mod,num,ratdenom,ratepsilon,ratprint] [bfloat,bftorat,block,if,integerp,mod,rat,ratdenom,ratepsilon,ratprint] [bfloat,bftorat,block,if,integerp,mod,ratdenom,ratepsilon,ratprint,true] [bfloat,delete,false,if,integerp,lambda,map,mod,numer,rat,ratprint] [bfloat,false,if,integerp,lambda,map,mod,numer,rat,ratprint] [bftorat,block,cons,delete,emptyp,false,first,float2bf,fpprec,if,integerp,kill,lambda,listp,map,mod,ratdenom,ratepsilon,ratprint,rest,return] [bftorat,block,delete,ev,false,float,float2bf,if,integerp,mod,numer,ratdenom,ratepsilon,ratprint] [bftorat,block,delete,ev,false,float,float2bf,if,integerp,mod,ratdenom,ratepsilon,ratprint] [bftorat,block,delete,ev,false,float,if,integerp,mod,ratdenom,ratepsilon,ratprint] [bftorat,block,delete,false,float,if,integerp,mod,ratdenom,ratepsilon,ratprint] [bftorat,block,delete,false,float2bf,fpprec,if,integerp,kill,mod,ratdenom,ratepsilon,ratprint,return] [bftorat,block,delete,float,if,integerp,mod,rat,ratdenom,ratepsilon,ratprint] [bftorat,block,emptyp,first,float,fpprec,if,integerp,mod,not,numer,ratepsilon,ratprint,return] [bftorat,block,ev,false,float2bf,fpprec,if,integerp,kill,mod,ratdenom,ratepsilon,ratprint,return] [bftorat,block,ev,float,if,integerp,mod,rat,ratdenom,ratepsilon,ratprint] [bftorat,block,ev,float2bf,fpprec,if,integerp,mod,ratdenom,ratepsilon,ratprint,return] [bftorat,block,false,float,if,integerp,mod,ratdenom,ratepsilon,ratprint] [bftorat,block,false,float2bf,fpprec,if,integerp,kill,mod,ratdenom,ratepsilon,ratprint,return] [bftorat,block,float,fpprec,if,integerp,kill,makelist,mod,rat,ratdenom,ratepsilon,ratprint] [bftorat,block,float,fpprec,if,integerp,kill,mod,rat,ratdenom,ratepsilon,ratprint] [bftorat,block,float,if,integerp,mod,num,ratdenom,ratepsilon,ratprint] [bftorat,block,float,if,integerp,mod,rat,ratdenom,ratepsilon,ratprint] [bftorat,block,float2bf,fpprec,if,integerp,kill,mod,ratdenom,ratepsilon,ratprint,return] [bftorat,block,float2bf,fpprec,if,integerp,mod,ratdenom,ratepsilon,ratprint,return] [block,do,floor,gcd,integerp,signum] [display2d,false,integerp,matchdeclare,tellsimpafter] [do,if,integerp] [do,integerp] [integerp,linsolve] [integerp,log] [integerp,not,sqrt] [integerp,rhs] [integerp,sqrt] [integerp]

Related Help

Help for Integerp