Bug in FullSimplify[] confirmed by Wolfram Research

*To*: mathgroup at smc.vnet.net*Subject*: [mg7747] Bug in FullSimplify[] confirmed by Wolfram Research*From*: "James H. Steiger" <steiger at unixg.ubc.ca>*Date*: Mon, 7 Jul 1997 04:41:20 -0400*Sender*: owner-wri-mathgroup at wolfram.com

Mathematica's FullSimplify[] function has a bug which causes incorrect evaluation of expressions whose simplification path involves the Beta function and its relatives. The existence of the bug was verified by Dave Withoff of Wolfram Research in an email exchange [TS13750]. I discovered the bug while using Mathematica to generate some results in the Binomial Distribution. A portion of my original letter to Wolfram Research, together with the Tech Support response, is shown below. Note that the bug can affect results that have no apparent connection with the Beta function, because such expressions may, upon simplification, reduce to an expression involving the Beta function. This demonstrates that FullSimplify is not reliable, and any results generated with it should be checked carefully. **************** Portions of original correspondence with WRI ***** ************ My Note to Wolfram *********************************** Recently, using Mathematica 3.0, I had an experience which struck me as anomalous. I began by defining the CDF of the Binomial probability distribution in terms of Beta and Gamma functions In[1]:= BinomialCDF[N_, p_, x_] := 1 - Beta[p, x + 1, N - x] Gamma[N + 1]/(Gamma[x + 1] Gamma[N - x]) Then I try a sample calculation: In[2]:= BinomialCDF[26,7/10,17] Out[2]= 1 - 28120950 Beta[7/10, 18, 9] The numerical answer, given below, agrees with the output of all other programs I have tried, including Mathematica. It is correct. In[3]:= N[%] Out[3]= 0.372596 Yet, trying Mathematica's FullSimplify[] function produces a rather surprising result. In[4]:= BinomialCDF[26,7/10,17] Out[4]= 1 - 28120950 Beta[7/10, 18, 9] In[5]:= FullSimplify[%] Out[5]= 1 Mathematica's FullSimplify function "simplifies" Beta[7/10,18,9] to 0, although it clearly is not 0. Can anybody explain this result? I have been puzzling over it. Unless there is some obvious explanation which I cannot grasp (I am not a mathematician) it would seem to indicate a VERY serious bug. Note that, if one substitutes .7 for 7/10, one obtains the correct answer! Note also that if one simply changes the 7/10 to 1/2, one obtains a correct answer, identical to the one obtained with the value .5!! In[29]:=BinomialCDF[26,1/2,17] Out[29]= 1 - 28120950 Beta[1/2, 18, 9] In[30]:=FullSimplify[%] Out[30]=64574877/67108864 In[31]:=N[%] Out[31]=0.962241 *********************** Response from WRI ********************************************* Hello, Thank you for taking the time to report this error. You are correct in observing that there is an error in the transformation of the Beta function in FullSimplify. I was not previously aware of this error, and have forwarded this example to the people in our development group so that this can be investigated. The only currently available workaround is to avoid using FullSimplify for expressions that contain Beta functions. We apologize for any difficulties caused by this error. Dave Withoff Wolfram Research ******************************************** Mr. Withoff's suggestion, though helpful, really will not solve the problem, because the user cannot be expected to know how the expression submitted to "FullSimplify" will simplify! For example, try loading <<Statistics`DiscreteDistributions` then see that FullSimplify[CDF[BinomialDistribution[26,7/10],17]] returns the value 0, instead of the correct answer, which is 9314893730914103398579569 -------------------------- 25000000000000000000000000 or 0.372596 Unless the user is aware of the connection between the CDF of the Binomial Distribution and the Beta function, he/she would not know to avoid using FullSimplify[]. FullSimplify does have an option, ExcludedForms, that can be useful in solving such problems. Of course the question remains, are there other widely used functions that FullSimplify does not handle properly? Professor James H. Steiger Department of Psychology (steiger at unixg.ubc.ca) 2136 West Mall Office: 604-822-2706 University of British Columbia Fax: 604-822-6923 Vancouver, B.C., Canada V6T 1Z4

**Re: How to define an auto-Collect function (fwd)**

**Re: nested * and ** (rules for commutative quantities)**

**Re: How to define an auto-Collect function (fwd)**

**2-D Graphics Options**