[56] in mathematical software users group

home help back first fref pref prev next nref lref last post

RE: some comparison of Mathematica, Maple and SymbMath

daemon@ATHENA.MIT.EDU (Weiguang Huang)
Tue Sep 15 00:49:13 1992

Date: Tue, 15 Sep 1992 14:45:51 +1000
From: Weiguang Huang <huang@deakin.OZ.AU>
To: allusers@cauchy.stanford.edu, everybody@netserver.stanford.edu,

In article <9315@emory.mathcs.emory.edu> riddle@mathcs.emory.edu (Larry Riddle) writes:
>In a previous article, Weiguang Huang writes:
>>	Here are some problems that Maple and Mathematica cannot 
>>solve, but SymbMath can do. 
>>	The following examples came from news on the sci.math.symbolic 
>>newsgroup in 1991, and were run in Maple V, Mathematica 2.0, or  
>>SymbMath 2.1. 

>Summary of comments:
>(1) Of the 10 examples that do not involve improper integrals or
>differential equations, Mathematica can do every example once we define
>some simple rules or load some standard packages.

If you have to load external packages and/or programming, that is different
story. YOU, instead of the system, solve the examples while you define rules.

>(3) SymbMath appears to evaluate improper integrals by evaluating the
>indefinite integral at the endpoints. This correctly gives the Cauchy

SymbMath evaluates improper integrals by first detecting the improper point.
It is able to detect some improper points.


Principal Value in some cases, but is *not* the way that the CPV is
>defined. Simple translations of these "correct" examples produce the

The examples you have translated are different examples.

same incorrect answers as given by Matheamtica. 

>Conclusion: With regard to these 20 examples, there is no difference
>between Mathematica and SymbMath.

"no difference" ?
 Why do you have to be helped with external packages and/or
programming in Mma while you just solve examples one step in SymbMath ?
Why does Mma cannot detect any improper point in improper integrals at all
while SymbMath has the ability to detect some ?


>>************************** Example 2 *********************************
>>> int(x^n, x=0..1);
>
>This is easy to take care of in Matheamtica.
>First we load the package Declare.m written by Pekka
>Jahunnen that will allow us to declare n to be positive.
>
>In[4]:= <<Declare.m
>{Declare, NewDeclare, NonPositive, RealQ}

help with external package.

>In[5]:= Declare[n,Positive]
>Now we must tell Mathematica how to evaluate positive powers of 0.

YOU, instead of software, evaluate positive powers of 0.

Again, easy to do.
>In[6]:= Unprotect[Power]
>
>Out[6]= {Power}
>
>In[7]:= 0^x_?Positive = 0

YOU give the result 0 for 0^x, not the software does. 

>The same answer as SymbMath which also had to declare n > -1. The only
>extra we really had to add in Mathematica was that 0^n = 0 when n is
>positive, which was trivial to do.

Users must do these two  trivial things: both loading the specific external
package and programming how to evaluate 0^n.

>>************************** Example 3 *****************************
>>> int(x^n, x=eps..1);
>>
>Mathematica:
>In[9]:=Declare[n,Positive]
>
>Again, the exact same answers as given by SymbMath. We are still using
>the rules defined for powers of 0 and that n is positive, but didn't
>have to do anything special for this example once those rules were made.

You had loaded the special external package and programed.

>>*************************** Example 4 ***************************

With no assumption about n, Mma gives 0 for 0^n.

>Mathematica gives
>In[12]:= Declare[n, Positive]
>In[13]:= 0^n  (* Remember we defined a rule to handle this *)

If the user had already known the rule to handle 0^n (0^x_Positive = 0),
why does he need  the software to solve the "problem" that he had already
known the result for.

>No difference between Mathematica and SymbMath here. I could easily
>have defined the rule 0^x_?Negative = Infinity and then Mathematica
>would have also returned 0^(-n) = Infinity.

If you had already known the result Infinity for 0^x_?Negative, you do not
need any software to evalute 0^x.


>>**************************** Example 6 *****************************

if we load the package Calculus'Limit'
>then Mathematica can do this example also.

>In[17]:= <<Limit.m

have to help with the special external package.


>>************************ Example 8 *********************************
>>	Mathematica:
>>In[1]:= Integrate[1/x,{x,-1,1}]
>>Out[1]= -Log[-1]

>The problems of Mathematica with improper integrals with an
>internal singularity are well known. But is SymbMath's answer any

 Are the bugs in Mma well-known ?

better? 
What SymbMath has computed is actually the
>Cauchy Principal Value, 

>Mathematica *can* compute Cauchy Principal Values also, but the user
>must supply the exact location of the singularity. Here are the two

If the user does not supply the exact location of the singularity,
what is the result ?

examples that Huang gives:
>In[4]:= <<CauchyPrincipalValue.m
>In[5]:= CauchyPrincipalValue[1/x,{x,-1,{0},1}]

You said it is not fair to apply different techniques into Mma and SymbMath.
Why did you split the interval here ? Why did you use numerical integration
instead of symbolic integration ?

>NIntegrate::ploss:
>   Numerical integration stopping due to loss of precision. Achieved neither
>     the requested PrecisionGoal nor AccuracyGoal; suspect one of the
>     following: highly oscillatory integrand or the true value of the integral
>     is 0.

This means numerical integration fails and the result is not liable ?


>>*************************** Example 9 *******************************
>In Mathematica:
>In[2]:= CauchyPrincipalValue[Tan[x],{x,0,{Pi/2},Pi}]
>
>NIntegrate::ploss:
>   Numerical integration stopping due to loss of precision. Achieved neither
>     the requested PrecisionGoal nor AccuracyGoal; suspect one of the
>     following: highly oscillatory integrand or the true value of the integral
>     is 0.
>
>                   -16
>Out[2]= -1.11022 10   

>Well, this looks close enough to 0 for me.

How did you know the result is 0 ? -1.11022 10^-16 = 0 ?


>>************************* Example 13 ********************************
>>	Mathematica:
>> Sqrt[a^2] evaluates to Sqrt[a^2].


>If we tell Mathematica what kind of variables we are working with, it
>has no problem with this example:

no problem without help with the special external package ?

>In[4]:= <<Declare.m


>>********************** Example 14 **********************************
>>	Maple and Mathematica cannot find the integrals of abs(x).
>Huang is correct. But it's not hard to fix this. Let's define our
>own version of abs by abs[x] = x Sign[x] 
>
>In[1]:= abs[x_] := x Sign[x]
>
>General::spell1:
>   Possible spelling error: new symbol name "abs"
>     is similar to existing symbol "Abs".
>
>In[2]:= Integrate[abs[x],{x,-1,1}]
>
>Out[2]= 1   (* Same answer as SymbMath *)
>
>In[3]:= Integrate[abs[x]^5,x]
>
>                   5        5
>Out[3]= Integrate[x  Sign[x] , x]   (* Integration failed *)
>
>In[4]:= Unprotect[Power,Integrate]
>
>Out[4]= {Power, Integrate}
>
>In[5]:= Sign[x_]^n_?EvenQ = 1    (* Give rules for powers of Sign[x] *)
>
>Out[5]= 1
>
>In[6]:= Sign[x_]^n_?OddQ = Sign[x]
>
>Out[6]= Sign[x]
>
>In[7]:= Integrate[x_^n_?OddQ Sign[x_], x_] = x^(n+1)/(n+1) Sign[x]

If the user had already known the result x^(n+1)/(n+1) Sign(x) for
Integrate[x_^n_?OddQ Sign[x_], x_], he does not need any software to evaluate
Integrate[x^5 Sign[x], x] that he had already know the result for.

>         1 + n
>        x      Sign[x]
>Out[7]= --------------   (* Give rule for integration of odd power *)
>            1 + n
>
>In[8]:= Integrate[abs[x]^5,x]
>
>         6
>        x  Sign[x]
>Out[8]= ----------  (* Same answer as SymbMath *)
>            6
>
>We had to define our own rules, but Mathematica could do this example.

Yes, we had to define our own rules, had to write a long program ( 7 lines
of code, or 7 rules) to do this simple example.

Of course, I suspect that SymbMath has similar rules built-in.

>>---------------------------------------------------------------------


>>	The following problems are taken from Swokowski's Calculus 
>>book.  They cause Mathematica to fail because of a singularity in 
>>the interior of the interval of integration:
>>
>>        Section 10.4 Problems 3, 12, 15, 16, 23, 29.

>>************************ Problem3 *********************************
>>	Mathematica:
>>In[4]:= Integrate[1/x^2,{x,-3,1}]
>>
>>          4
>>Out[4]= -(-)                            (* INTEGRAL IS DIVERGENT *)
>>          3

Let's translate the
>function and interval one unit to the right. This should not affect the
>value of the integral

The function you had translated is different function. "This should not
affect the value of the integral", but affect the integral and affect
integral technique.

>  SymbMath:
>  Input:
>inte(1/(x-1)^2, x from -2 to 2)

integral of 1/(x-1)^2 is different from integral of 1/x^2.

>>************************** Problem12 ***************************
>>	Mathemtica:
>>In[6]:= Integrate[x^(-4/3),{x,-1,1}]
>>
>>Out[6]= -6                              (* INTEGRAL IS DIVERGENT *)

>Let's try translating the function and interval again. 
>
>  SymbMath:
>  Input:
>inte((x-1)^(-4/3), x from 0 to 2)

The integral of (x-1)^(-4/3) is different from the integral of x^(-4/3).

No package of software can do any integral. Mma cannot do these integrals
at all while Symbmath can do some types of integrals.


>>********************** Problem16 ************************************

>then the Cauchy Principal Value between a and b will equal
>ln|g(b)| - ln|g(a)|. So the one advantage SymbMath has over Mathematica

While you say "the one advantage SymbMath has over Mathematica", 
why do you write
"no difference between Mathematica and SymbMath" in your conclusion ?

>in this context is that it has been programmed to use
>
>inte(1/x*d(x)) = ln (x * sgn(x))


>>***************************** Problem23 **********************
Let's have Mathematica do the integral the
>same way that SymbMath does:
>In[1]:= Integrate[1/x^2 Cos[1/x],{x,-1,0}] + Integrate[1/x^2 Cos[1/x],{x,0,Infinity}]
>
>                                 1
>Power::infy: Infinite expression - encountered.
>                                 0
>
>Out[1]= Infinity

1/0 <> Infinity.

The value Infinity is different from sin(inf). The former value indicates that
the integration diverges by infinity while the latter value indicates that the
integration diverges by oscillation. They are different types of improper
integrals.          
   
>>************************** Problem29 ********************************
Now let's have Mathematica do
>the integral over two intervals:
>
>In[2]:= Integrate[1/(x-4)^2,{x,0,4}] + Integrate[1/(x-4)^2,{x,4,Infinity}]
>
>Infinity::indet: Indeterminate expression -Infinity + Infinity encountered.
>
>Out[2]= Indeterminate
>
>Mathematica now correctly determines that the integral is divergent.

No.
This indicates Mma fails to evaluate the integral, does not means the integral
is divergent.

Indeterminate <> inf.


































































home help back first fref pref prev next nref lref last post