From: SourceForge.net <no...@so...> - 2008-01-27 19:22:18
|
Bugs item #609464, was opened at 2002-09-14 23:18 Message generated for change (Comment added) made by macrakis You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=104933&aid=609464&group_id=4933 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Lisp Core - Floating point Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Stavros Macrakis (macrakis) Assigned to: Nobody/Anonymous (nobody) Summary: 1+%e,numer and %e^%e,numer Initial Comment: %e^%e,numer does not evaluate numerically to 15.15... as it should, it simply returns the simplified expression %e^%e. ---------------------------------------------------------------------- >Comment By: Stavros Macrakis (macrakis) Date: 2008-01-27 14:22 Message: Logged In: YES user_id=588346 Originator: YES What is by design is that %e^x,numer does not become 2.718^x (unless %enumer is true). The other cases are because the original coder either didn't care about cases like %e+1 or thought it would be too computationally expensive to handle them differently, since they can't be handled bottom-up. After all, all of %e^2, %e^%pi, %e^(2/3) with ,numer *do* evaluate to floats. If we fix %e+1,numer we should also fix sin(%pi+x),numer. Currently, that gives sin(3.14+x); it should give -sin(x) (that is, the %pi should not simplify to 3.14; the regular simplifier should take over). There is a special hack so that *at the top level*, %e,numer => 2.718. This is really ugly: %e,numer => 2.7 %e+1,numer => %e+1 [%e],numer => [%e] The correct intuition is this: with numer=true, if simplifying a constant (like %e or %pi or for that matter %i and inf) to a float would cause the expression it is contained in (and not just the constant itself) to become a float/complex float, then do it. Otherwise don't. For the purposes of this definition, consider that a top-level constant is "contained in" some sort of expression. This design would give numer:true %e^x => %e^x sin(%pi+x) => -sin(x) inf => <<IEEE positive infinity>> but of course we don't currently handle that %e^2 => 7.4 2^%e => 6.6 atan(1) => .78 atan(inf) => 1.57 sin(2/3*%pi + x) => sin(x+2.1) %e^%i => .5+.8*%i %i^%i => .27 sin(1+%pi) => -0.84 I don't think we can easily fix all these cases, but we should start. The current behavior is incoherent and not very useful. ---------------------------------------------------------------------- Comment By: Robert Dodier (robert_dodier) Date: 2008-01-27 14:01 Message: Logged In: YES user_id=501686 Originator: NO I'm pretty sure we should change the behavior of %e in the presence of numer, whether or not the current behavior is intentional. Reopening this report accordingly. I've been bitten by this inconsistency repeatedly. %e, numer; => 2.718281828459045 %e + 1, numer; => %e + 1 %e^%pi, numer; => 23.14069263277927 %e^%e, numer; => %e^%e Preserving %e in %e^foo, numer when foo is non-numeric is OK by me. I suppose that's the original intent of %enumer but for whatever reason it is not the sole effect. ---------------------------------------------------------------------- Comment By: Dan Gildea (dgildea) Date: 2008-01-27 13:26 Message: Logged In: YES user_id=1797506 Originator: NO This seems to be by design. (%i5) %e^%e,numer,%enumer; (%o5) 15.15426224147926 (%i6) %e^%e,numer; (%o6) %e^%e (%i7) %e+1,numer,%enumer; (%o7) 3.718281828459045 (%i8) %e+1,numer; (%o8) %e+1 ---------------------------------------------------------------------- Comment By: Robert Dodier (robert_dodier) Date: 2006-06-26 14:17 Message: Logged In: YES user_id=501686 Still present in 5.9.3. ---------------------------------------------------------------------- Comment By: Stavros Macrakis (macrakis) Date: 2004-03-23 12:48 Message: Logged In: YES user_id=588346 cf. bug 531466 re float(exp(exp(2))) ---------------------------------------------------------------------- Comment By: Stavros Macrakis (macrakis) Date: 2002-09-18 23:12 Message: Logged In: YES user_id=588346 1+%e,numer also fails These examples work with bfloat, e.g. 1+%e,bfloat; %e^%e,bfloat; ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=104933&aid=609464&group_id=4933 |