Items tagged with bug

Let us consider 

Statistics:-Mode(Binomial(n, p));
                        floor((1 + n) p)

Up to Wiki, the output is not correct. Simply no words.

There seems to be a bug in determining the folowing integral analytically:

integrate(-(3/2*(exp(-(1/4)*x)*x-sqrt(Pi)*erf((1/2)*sqrt(x))*sqrt(x)))/(sqrt(x)*sqrt(Pi)*erf((1/2)*sqrt(x))), x = 0..1)

Maple gives as a result

3/2

However, numerically integrating it

integrate(-(3/2*(exp(-(1/4)*x)*x-sqrt(Pi)*erf((1/2)*sqrt(x))*sqrt(x)))/(sqrt(x)*sqrt(Pi)*erf((1/2)*sqrt(x))), x=0..1,numeric)

gives

0.1195461293

In fact, integrating it from a to b,

integrate(-(3/2*(exp(-(1/4)*x)*x-sqrt(Pi)*erf((1/2)*sqrt(x))*sqrt(x)))/(sqrt(x)*sqrt(Pi)*erf((1/2)*sqrt(x))), x=a..b)

gives

-3/2 a + 3/2 b

suggesting that Maple thinks the integrand is just 3/2. If one plots it, then it becomes obvious that this is not the case.


 

with(Statistics):````

X := Statistics:-RandomVariable(Normal(0, 1)):

PDF(sin(X), t)

piecewise(t <= -1, 0, t < 1, 2^(1/2)*exp(-(1/2)*arcsin(t)^2)/(Pi^(1/2)*(-t^2+1)^(1/2)), 1 <= t, 0)

(1)

int(%, t = -1 .. 1)

2*erf((1/4)*Pi*2^(1/2))

(2)

evalf(%)

1.767540069

(3)

``


There were recently submitted a dozen Maple bugs by me and others. Maplesoft have brought no responses. They keep strategic silence. True merit is not afraid of criticism.

Download Bug_in_Statistics_PDF.mw


 

I found a strange bug in int.
For some functions f(x), Maple is able to compute the antiderivative (correctly) but refuses to compute the definite integral.
Or, computes the integral over 0..1  and  0..2  but refuses to compute over 1..2.

int(exp(x^3), x);  #ok

-(1/3)*(-1)^(2/3)*((2/3)*x*(-1)^(1/3)*Pi*3^(1/2)/(GAMMA(2/3)*(-x^3)^(1/3))-x*(-1)^(1/3)*GAMMA(1/3, -x^3)/(-x^3)^(1/3))

(1)

int(exp(x^3), x=1..2); #?

int(exp(x^3), x = 1 .. 2)

(2)

int(exp(x^3), x=1..2, method=FTOC); #??

int(exp(x^3), x = 1 .. 2, method = FTOC)

(3)

int(exp(x^3), x=0..2); #?

int(exp(x^3), x = 0 .. 2)

(4)

int(exp(-x^3), x);  #ok

(3/4)*x*exp(-(1/2)*x^3)*WhittakerM(1/6, 2/3, x^3)/(x^3)^(1/6)+exp(-(1/2)*x^3)*WhittakerM(7/6, 2/3, x^3)/(x^2*(x^3)^(1/6))

(5)

int(exp(-x^3), x=0..2);  #ok

(3/4)*2^(1/2)*exp(-4)*WhittakerM(1/6, 2/3, 8)+(1/8)*2^(1/2)*exp(-4)*WhittakerM(7/6, 2/3, 8)

(6)

int(exp(-x^3), x=0..1);  #ok

(3/4)*exp(-1/2)*WhittakerM(1/6, 2/3, 1)+exp(-1/2)*WhittakerM(7/6, 2/3, 1)

(7)

int(exp(-x^3), x=1 .. 2);  #???

int(exp(-x^3), x = 1 .. 2)

(8)


 

Download !strange-bug-int.mw

Let us consider 

restart; J := int(cos(a*x)^2/(x^2-1), x = -infinity .. infinity, CPV);
-(1/4)*Pi*sin(2*a)*csgn(I*a)-(1/4)*Pi*sin(2*a)*csgn(I/a)

This result is not true for a=I:

eval(J, a = I);
                               0

In this case the integral under consideration diverges because of 

cos(I*x)^2;
                                
                            cosh(x) ^2

 

Let us consider 

maximize(int(exp(-x^4), x = k .. 3*k), location);

Error, (in maximize) invalid input: iscont expects its 1st argument, f, to be of type algebraic, but received x = k .. 3*k
whereas the expected output is 

[(2*((1/40)*GAMMA(1/4, (1/80)*ln(3))*5^(1/4)*ln(3)^(3/4)-(1/40)*GAMMA(1/4, (81/80)*ln(3))*5^(1/4)*ln(3)^(3/4)))*5^(3/4)*(1/ln(3))^(3/4), [k = (1/10)*10^(3/4)*ln(3)^(1/4)]]

as Mma 11 produces. The following 

RealDomain:-solve(diff(int(exp(-x^4), x = k .. 3*k), k));
  -(1/10)*5^(3/4)*ln(3)^(1/4), (1/10)*5^(3/4)*ln(3)^(1/4)

is not a workaround because of 

int(exp(-x^4), x = (1/10)*5^(3/4)*ln(3)^(1/4) .. (3/10)*5^(3/4)*ln(3)^(1/4));
  FAIL

 

Let us consider 

MultiSeries:-series(Psi((2*x+1)/(2*x))-Psi((x+1)/(2*x)), x = 0);

x-(1/2)*x^2+(1/4)*x^4-(1/2)*x^6 +O(x^7)

The above result contradicts 

MultiSeries:-limit(diff(Psi((2*x+1)/(2*x))-Psi((x+1)/(2*x)), x), x = 0);
                           undefined
MultiSeries:-limit((Psi((2*x+1)/(2*x))-Psi((x+1)/(2*x)))/x, x = 0, right);
                               1
MultiSeries:-limit((Psi((2*x+1)/(2*x))-Psi((x+1)/(2*x)))/x, x = 0, left);
                           undefined
plot((Psi((2*x+1)/(2*x))-Psi((x+1)/(2*x)))/x, x = -0.1e-1 .. 0.1e-2, discont, y = -5 .. 5);

Correct computatiton for

for reasonable expressions f(x,y), g(x,y) would be very useful in double integrals.

For the moment this is not possible. Too many bugs:

int(Heaviside(1-x^2-y^2), x=-infinity..infinity, y=-infinity..infinity); #should be Pi
                           undefined
int(Heaviside(1-x^2-y^2), x=-1..1, y=-1..1); #should be Pi
                               0
int(Heaviside(y-x^2), x=-1..1, y=-1..1); #should be 4/3
                               -2

int(Heaviside(y-x^2), y=-1..1, x=-1..1); #This one is OK!
                              4/3

 

 

 

 

restart; with(Statistics):
X := RandomVariable(Normal(0, 1)): Y := RandomVariable(Uniform(-2, 2)):
Probability(X*Y < 0);

crashes my comp in approximately 600 s. Mma produces 1/2 on my comp in 0.078125 s.

Let us consider

with(Statistics):
X1 := RandomVariable(Normal(0, 1)):
X2 := RandomVariable(Normal(0, 1)):
X3 := RandomVariable(Uniform(0, 1)): 
X4 := RandomVariable(Uniform(0, 1)):
Z := max(X1, X2, X3, X4); CDF(Z, t);

int((1/2)*(_t0*Heaviside(_t0-1)-_t0*Heaviside(_t0)-Heaviside(1-_t0)*Heaviside(-_t0)+Heaviside(-_t0)+Heaviside(1-_t0)-1)*(1+erf((1/2)*_t0*2^(1/2)))*(2^(1/2)*Heaviside(_t0-1)*exp(-(1/2)*_t0^2)*_t0-2^(1/2)*Heaviside(_t0)*exp(-(1/2)*_t0^2)*_t0-2^(1/2)*Heaviside(-_t0)*Heaviside(1-_t0)*exp(-(1/2)*_t0^2)-Pi^(1/2)*undefined*erf((1/2)*_t0*2^(1/2))*Dirac(_t0)-Pi^(1/2)*undefined*erf((1/2)*_t0*2^(1/2))*Dirac(_t0-1)+2^(1/2)*Heaviside(-_t0)*exp(-(1/2)*_t0^2)+2^(1/2)*Heaviside(1-_t0)*exp(-(1/2)*_t0^2)-Pi^(1/2)*undefined*Dirac(_t0)-Pi^(1/2)*undefined*Dirac(_t0-1)+Pi^(1/2)*Heaviside(_t0-1)*erf((1/2)*_t0*2^(1/2))-Pi^(1/2)*Heaviside(_t0)*erf((1/2)*_t0*2^(1/2))-exp(-(1/2)*_t0^2)*2^(1/2)+Pi^(1/2)*Heaviside(_t0-1)-Pi^(1/2)*Heaviside(_t0))/Pi^(1/2), _t0 = -infinity .. t)

whereas Mma 11 produces the correct piecewise expression (see that here screen15.11.16.docx).

Edit. Mma output.
limit((x^2-1)*sin(1/(x-1)), x = infinity, complex);
infinity-infinity*I
MultiSeries:-limit((x^2-1)*sin(1/(x-1)), x = infinity, complex);
infinity

whereas the same outputs are expected. The help http://www.maplesoft.com/support/help/Maple/view.aspx?path=infinity&term=infinity does not shed light on the problem. Here are few pearls:

  • infinity is used to denote a mathematical infinity, and hence it is usually used as a symbol by itself or as -infinity.
  • The quantities infinity, -infinity, infinity*I, -infinity*I, infinity + y*I, -infinity + y*I, x + infinity*I and x - infinity*I, where x and y are finite, are all considered to be distinct in Maple. However, all 2-component complex numerics in which both components are infinity are considered to be the same (representing the single point at the "north pole" of the Riemann sphere).
  • The type cx_infinity can be used to recognize this "north pole" infinity.

Let us consider 

MmaTranslator:-FromMma(" Table[0,{n=10},{m=2}]");

[seq([seq(0,i=1..(m := 2))],j=1..(n := 10))]

The above result is syntactically incorrect in Maple language. The translation should be 

Matrix(10,2)
#or
[seq([seq(0,i=1.. 2)],j=1..10)]

up to the Mmma's result

Table[0, {n = 10}, {m = 2}]

{{0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0,0}, {0, 0}}

Another bug is as follows.

MmaTranslator:-FromMma("Sinc[x]");

Sinc(x)

whereas the expected result is piecewise(x=0,1,sin(x)/x) up to http://reference.wolfram.com/language/ref/Sinc.html

In general, the MmaTranslator package is outdated. It often returns working Mma's commands as incorrect (Concrete examples are long and need a context. These may be exposed on demand.). The question arises about the quality of other Maple translations. 

The command

plots:-implicitplot(evalc(argument((1+x+I*y)/(1-x-I*y))) <= (1/4)*Pi, x = -5 .. 5, y = -5 .. 5, crossingrefine = 1, gridrefine = 2, rational = true, filled, signchange = true, resolution = 1000);

produces an incorrect result

in view of

evalf(argument((1-4+4*I)/(1+4-4*I)));
                          2.889038378

There is a workaround 

plots:-inequal(evalc(argument((1+x+I*y)/(1-x-I*y))) <= (1/4)*Pi, x = -5 .. 5, y = -5 .. 5);

 

The command 

restart; st := time(): FunctionAdvisor(EllipticE); time()-st;

produces the result on my comp in 805.484 s. Too much time.

The command

J := int(sin(x)/(x*(1-2*a*cos(x)+a^2)), x = 0 .. infinity)assuming a::real,a^2 <>0;

outputs 

(infinity*I)*signum(a^3*(Sum(a^_k1, _k1 = 0 .. infinity))-a^2*(Sum(a^_k1, _k1 = 0 .. infinity))-a*(Sum(a^(-_k1), _k1 = 0 .. infinity))+a^2+Sum(a^(-_k1), _k1 = 0 .. infinity)+a)

which is wrong in view of 

evalf(eval(J, a = 1/2));
                       Float(undefined) I

The correct answer is Pi/(4*a)*(abs((1+a)/(1-a))-1) according to G&R 3.792.6. Numeric calculations confirm it.

1 2 3 4 5 6 7 Last Page 1 of 11