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

MathGroup Archive 1998

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

Search the Archive

An idea on-- Round[Log[2]/Log[4]]

  • To: mathgroup at smc.vnet.net
  • Subject: [mg14015] An idea on-- Round[Log[2]/Log[4]]
  • From: "Ersek, Ted R" <ErsekTR at navair.navy.mil>
  • Date: Wed, 16 Sep 1998 14:11:57 -0400
  • Sender: owner-wri-mathgroup at wolfram.com

Recall the recent discussion on Round[Log[2]/Log[4]]. The line below
produces a message, and no progress on the problem.

In[1]:=
Round[Log[2]/Log[4]]

$MaxEtraPrecision::meprec:
In increasing internal precision while attempting to evaluate 
Round[Log[2]/Log[4]], the limit $MaxExtraPrecision=49.99  was reached. 
Increasing the value of $MaxExtraPrecision may help resolve the
uncertainty.

Out[1]=
Round[Log[2]/Log[4]]

As others pointed out, we need to use FullSimplify inside of Round to
get the desired result.  It would be nice if the kernel could figure
out when FullSimplify might help and use it, but only in cases where
the normal algorithm fails.  My definition below for Round does the
trick.


In[2]:= 
$UseFullSimplify=True;
Unprotect[Round];
Round[expr_]/;$UseFullSimplify:=
Block[{$UseFullSimplify,$Messages={}},
  Check[
     Round[expr],
     Round[FullSimplify[expr]], 
     $MaxExtraPrecision::meprec
  ]
];
Protect[Round];


In[3]:=
Round[Log[2]/Log[4]]

Out[3]=
0

We get the right answer, and FullSimplify is only used when it's needed!
The same improvement can be made for Floor, Ceiling and possibly
others.

Cheers,
Ted Ersek



  • Prev by Date: Mathematica Art - Gallery Openning
  • Next by Date: An idea on-- Round[Log[2]/Log[4]]
  • Previous by thread: Mathematica Art - Gallery Openning
  • Next by thread: An idea on-- Round[Log[2]/Log[4]]