An idea on-- Round[Log[2]/Log[4]]
- To: mathgroup at smc.vnet.net
- Subject: [mg14022] An idea on-- Round[Log[2]/Log[4]]
- From: "Ersek, Ted R" <ErsekTR at navair.navy.mil>
- Date: Wed, 16 Sep 1998 14:12:02 -0400
- Sender: owner-wri-mathgroup at wolfram.com
Improving on my earlier solution we can give Round an option! With the lines below I give it the option UseFullSimplify->True. In[1]:= $DoThis=True; Unprotect[Round]; Round[expr_,opts___]/;$DoThis:=Block[{$DoThis}, If[ (UseFullSimplify/.{opts}/.Options[Round])=!=True, Round[expr], Block[{$Messages}, Check[ Round[expr], Round[FullSimplify[expr]], $MaxExtraPrecision::meprec ] ] ] ]; Options[Round]={UseFullSimplify->True}; Protect[Round]; UseFullSimplify::usage="UseFullSimplify is an option for select functions that determines whether FullSimplify should be used on the arguments when numerical evaluation has trouble determining the result."; Now we get the desired answer for Round[Log[2]/Log[4]] As with my previous solution, FullSimplify is only used when needed. In[3]:= Round[Log[2]/Log[4]] Out[3]= 0 If you don't want Round to use FullSimplify you can specify that with the option (see In[4]). You can also change the default setting of the option using; SetOptions[Round, UseFullSimplify->False] In[4]:= Round[Log[2]/Log[4], UseFullSimplify->False] $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[4]= Round[Log[2]/Log[4]] As far as I can tell this will work as if this new option was a built-in feature. Well I suspect Wolfram Research could make it work more efficiently if they made it a built-in feature. I don't include the code here, but similar enhancements can be made for Floor, Ceiling, Equal, and Unequal. Cheers, Ted Ersek