[Date Index]
[Thread Index]
[Author Index]
Zero testing
*To*: mathgroup at smc.vnet.net
*Subject*: [mg53106] Zero testing
*From*: Maxim <ab_def at prontomail.com>
*Date*: Thu, 23 Dec 2004 07:59:42 -0500 (EST)
*Sender*: owner-wri-mathgroup at wolfram.com
By 'zero testing' I mean the problem of deciding whether a given numerical
quantity is exactly equal to zero. Often Mathematica doesn't make
necessary checks at all:
In[1]:=
a = Pi/4; b = I*Log[-(-1)^(3/4)];
Limit[(a - b)/x, x -> 0]
Integrate[1/((x - a)*(x - b)), x]
Integrate[1/(x - b), {x, 0, 1}]
Out[2]=
DirectedInfinity[Pi - (4*I)*Log[-(-1)^(3/4)]]
Out[3]=
(-4*((-2*I)*ArcTan[Log[-(-1)^(3/4)]/x] - 2*Log[Pi - 4*x] + Log[16*(x^2
+ Log[-(-1)^(3/4)]^2)]))/(2*Pi - (8*I)*Log[-(-1)^(3/4)])
Out[4]=
((-I)*Pi - (2*I)*ArcTan[Log[-(-1)^(3/4)]] - Log[Log[-(-1)^(3/4)]^2]
+ Log[1 + Log[-(-1)^(3/4)]^2])/2
The constants a and b are equal to each other. We can see that Out[2] is
incorrect because it is equal to ComplexInfinity and the limit of 0/x is
0; Out[3] is also equal to ComplexInfinity (the denominator is zero) and
therefore wrong as well; finally, Out[4] is incorrect because the integral
doesn't converge.
A variation of the same problem is when we're numerically evaluating a
discontinuous function for an argument close to a discontinuity point. In
those cases Mathematica does perform necessary checks but handles more
complicated cases incorrectly, especially when the branch cuts are
concerned:
In[5]:=
Sign[Im[Sqrt[-1 - 10^-18*I]]]
Out[5]=
1
In[6]:=
((1 + I*(-167594143/78256779 + Pi))^4)^(1/2)
Out[6]=
(1 + I*(-167594143/78256779 + Pi))^2
In fact In[5] is equal to -1 and In[6] is equal to -(1
+ I*(-167594143/78256779 + Pi))^2. In the last case we do not even apply
any functions, the error is in the automatic simplifications. Sometimes
setting a high value for $MinPrecision helps, but here it doesn't have any
effect either.
Maxim Rytin
m.r at inbox.ru
Prev by Date:
**Re: Sequential evaluation of lists**
Next by Date:
**Hypergeometric and MeijerG**
Previous by thread:
**Re: Excel Link Problem**
Next by thread:
**Re: Zero testing**
| |