Comment #5 on issue 3052 by [email protected]: evaluating Abs should result
in a positive number
http://code.google.com/p/sympy/issues/detail?id=3052
I don't know why I didn't receive your comments about this, Aaron. I have
the issue starred. I thought I have settings set so starred comments get
sent to me....
Anyway, regarding numerical_zero. I pulled it out of 1036 because I can see
that it needs more thought. Something like Heaviside would be rejected as
answerable by the algorithm because a complex number doesn't allow it to be
evaluated:
Heaviside(1+I).n()
Heaviside(1 + I)
But the problem that I see is this: for a given precision, an insignificant
result might be obtained indicating that more precision is needed. A
symbolic zero will *never* obtain enough precision and with any other
expression, depending on how small the result is (assuming it's not zero),
at some point you will attain enough precision -- but how far that is, is
the unknown, so I think the method is doomed. Consider:
one=cos(x)**2+sin(x)**2
big=pi**1000
e=big-big*one+1/sqrt(big)**3
for i in range(10,450,50):
... print i, e.n(i,subs=dict(x=1))
...
10 0.e+344
60 0.e+307
110 0.e+269
160 -0.e+170
210 -0.e+69
260 0.e-746
310 -0.e-131
360 -0.e-230
410 0.e-746
If we just look for the precisions needed to get a significant digit (prec
1) we get that starting at prec=411:
for i in range(1,500):
... if e.n(i,subs=dict(x=1))._prec>1: print i
...
411
413
415
418
421
423
427
430
etc...
But until we get there, I don't know how to detect that we might get there.
So numerical methods will fail...but simplification of an expression can
make it very obvious:
e.equals(0) # in branch 1036 (master gives None)
False
e.simplify()
pi**(-1500)
This work was rekindled by getting failures for testing really simple
things that should be equal while working through an intermediate algebra
text that I am teaching, especially things involving surds. So initially I
added surd-detection but abandoned that in favor of positive numerical
tests (not inconclusive ones as shown above). So now simple things like
(sqrt(3)- sqrt(5)).equals(0) give False rather than None (as in master).
So nothing heroic in #1036 -- just a series of steps to try test an
arbitrary expressions equivalence to zero to be used when you want
something a little more sophisticated than "expr is S.Zero".
--
You received this message because you are subscribed to the Google Groups
"sympy-issues" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sympy-issues?hl=en.