Post Reply 
CAS: log of large integers?
05-24-2015, 03:07 PM
Post: #18
RE: CAS: log of large integers?
Finally got it working, with Gerald's help.

"biglog", a CAS program.

Input: any positive integer (may be very large).
Output: its common log as a real, accurate to 12 significant places, even for tough inputs (see 3rd example below).

Examples:

biglog(2^7777) --> 2341.11027628 (large correct answer)
biglog(999999999884) --> 11.9999999999 (the correctly rounded answer)
biglog(999999999885) --> 12. (the correctly rounded answer)

#cas
biglog(d):=
BEGIN
LOCAL j,k;
IF type(d)<>DOM_INT THEN RETURN "Argument not integer" END;
d:=abs(d);
k:=string(d);
j:=expr(head(k)+"."+tail(k));
return size(k)-1+evalf(log10(j),13);
END;
#end

<0|ΙΈ|0>
-Joe-
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
CAS: log of large integers? - Joe Horn - 05-21-2015, 06:37 AM
RE: CAS: log of large integers? - parisse - 05-21-2015, 11:28 AM
RE: CAS: log of large integers? - Gerald H - 05-22-2015, 04:57 PM
RE: CAS: log of large integers? - Gerald H - 05-22-2015, 05:57 PM
RE: CAS: log of large integers? - parisse - 05-22-2015, 07:01 PM
RE: CAS: log of large integers? - Gerald H - 05-23-2015, 01:47 PM
RE: CAS: log of large integers? - DrD - 05-23-2015, 06:23 PM
RE: CAS: log of large integers? - Joe Horn - 05-24-2015, 02:01 AM
RE: CAS: log of large integers? - DrD - 05-24-2015, 10:05 AM
RE: CAS: log of large integers? - Joe Horn - 05-24-2015 03:07 PM
RE: CAS: log of large integers? - Joe Horn - 05-24-2015, 07:00 PM
RE: CAS: log of large integers? - parisse - 05-25-2015, 05:38 AM
RE: CAS: log of large integers? - Joe Horn - 05-25-2015, 07:20 AM



User(s) browsing this thread: 5 Guest(s)