home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky sci.math:10348 sci.math.symbolic:2226 sci.math.num-analysis:2479
- Path: sparky!uunet!gatech!emory!riddle
- From: riddle@mathcs.emory.edu (Larry Riddle)
- Newsgroups: sci.math,sci.math.symbolic,sci.math.num-analysis
- Subject: Re: Some comparison of Mma, Maple and SymbMath (REBUTTAL)
- Keywords: Mathematica, Maple, SymbMath
- Message-ID: <9315@emory.mathcs.emory.edu>
- Date: 18 Aug 92 03:37:38 GMT
- Followup-To: sci.math.symbolic
- Organization: Emory University, Dept of Math and CS
- Lines: 859
-
- 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.
-
- Unfortunately, some aspects of this article were inaccurate and
- misleading. Since I do not use Maple, I will only comment on the
- examples with respect to Mathematica.
-
- 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.
-
- (2) Version 2.1 of Mathematica can solve the 2 differential equations
- examples using the new package Calculus'DSolve'.
-
- (3) SymbMath appears to evaluate improper integrals by evaluating the
- indefinite integral at the endpoints. This correctly gives the Cauchy
- Principal Value in some cases, but is *not* the way that the CPV is
- defined. Simple translations of these "correct" examples produce the
- same incorrect answers as given by Matheamtica. In several examples,
- Huang breaks the integral into two parts at the singularity to get
- SymbMath to give the correct answer, but *does not* do the same thing
- with Mathematica, then claims that SymbMath can do the example but
- Mathematica cannot. When SymbMath is told to compute the integral over
- *one* interval, it gives the same incorrect answer as Matheamtica.
-
- Conclusion: With regard to these 20 examples, there is no difference
- between Mathematica and SymbMath.
-
- Disclaimer: I did not write any part of Mathematica. In fact, I'm a
- rather novice Mathematica user. I think Huang has done an impressive
- job with SymbMath. I just think some misconceptions need to be corrected.
-
- >************************ Example 1 ******************************
- >> int(exp(-a * x^2), x=0..infinity);
-
- > SymbMath :
- > Input:
- >inte(exp(-a*x^2), x from 0 to inf)
- >assume(sqrt(a) > 0)
- >inte(exp(-a*x^2), x from 0 to inf)
- > Output:
- >1/2*a^(-0.5)*sqrt(pi)*erf(inf*sgn(sqrt(a)))
- >assumed
- >1/2*a^(-0.5)*sqrt(pi)
- >
-
- Mathematica 2.0 for SPARC
- Copyright 1988-91 Wolfram Research, Inc.
- -- NeWS graphics initialized --
-
- In[1]:= Integrate[Exp[-a x^2],{x,0,Infinity}]
-
- Sqrt[Pi]
- Out[1]= ---------
- 2 Sqrt[a]
-
- Well, this is really only true if a is positive. But let's take a
- look at SymbMath's answer:
-
- 1/2*a^(-0.5)*sqrt(pi)*erf(inf*sgn(sqrt(a)))
-
- What does sgn(sqrt(a)) mean if a is not positive? Is this answer really
- any better than Mathematica's answer? In fact, if we integrate from 0
- to b, rather than from 0 to Infinity, Mathematica gives
-
- In[2]:= Integrate[Exp[-a x^2],{x,0,b}]
-
- Sqrt[Pi] Erf[Sqrt[a] b]
- Out[2]= -----------------------
- 2 Sqrt[a]
-
- which is exactly SymbMath's answer with b = inf. Thus I see no
- difference between Mathematica and SymbMath here, with slight
- preference to Maple's requirement of demanding to know if a is positive
- before returning an answer.
-
- >************************** Example 2 *********************************
- >> int(x^n, x=0..1);
- >
- > SymbMath :
- > Input:
- >assume(n > -1)
- >inte(x^n, x from 0 to 1)
- > Output:
- >assumed
- >1/(1 + n)
- >
-
- Mathematica:
- In[3]:= Integrate[x^n,{x,0,1}]
-
- 1 + n
- 1 0
- Out[3]= ----- - ------
- 1 + n 1 + n
-
- Ok, this looks a bit strange because Mathematica has left the power of
- 0 unevaluated. That is perhaps not surprising because we have made no
- claims about what type of number n is.
-
- What would SymbMath give if there were no assumptions about n? (Notice
- that Huang made the assumption n > -1 *before* he evaluated the
- integral.)
-
- SymbMath:
- Input:
- inte(x^n, x from 0 to 1)
- Output:
- -0^sgn(1+n)/(1+n) + 1/(1+n)
-
- Why, it looks just like Mathematica's answer!
-
- 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}
-
- In[5]:= Declare[n,Positive]
-
- Now we must tell Mathematica how to evaluate positive powers of 0.
- Again, easy to do.
-
- In[6]:= Unprotect[Power]
-
- Out[6]= {Power}
-
- In[7]:= 0^x_?Positive = 0
-
- Out[7]= 0
-
- In[8]:= Integrate[x^n,{x,0,1}]
-
- 1
- Out[8]= -----
- 1 + n
-
- 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.
-
- >************************** Example 3 *****************************
- >> int(x^n, x=eps..1);
- >
- > (n + 1)
- > 1 eps
- > ----- - ----------
- > n + 1 n + 1
- >
- >> limit(", eps=0, right);
- >
- > SymbMath:
- > Input:
- >assume(n > -1)
- >inte(x^n, x from eps to 1)
- >subs(eps=0 to last)
- > Output:
- >assumed
- >1/(1 + n) - eps^(1 + n)/(1 + n)
- >1/(1 + n)
-
- Mathematica:
- In[9]:=Declare[n,Positive]
-
- In[10]:= Integrate[x^n, {x,eps,1}]
-
- 1 + n
- 1 eps
- Out[10]= ----- - --------
- 1 + n 1 + n
-
- In[11]:= Limit[%,eps->0]
-
- 1
- Out[11]= -----
- 1 + n
-
- 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.
-
- >*************************** Example 4 ***************************
- >> 0^n;
- > 0
- >
- ># Maple flags the error only when 'n' is replaced by the constant 0:
- >
- >> 0^0;
- >Error, 0^0 is undefined
- >
- > SymbMath:
- > Input:
- >assume(n > 0)
- >0^n
- >0^-n
- >0^0
- > Output:
- >assumed
- >0
- >discont
- >undefined
- >
-
- Huang complains about Maple's answer for 0^n when no assumption is made
- about n, but then assumes n > 0 before showing what SymbMath gives for
- 0^n. In fact, with no assumption about n, SymbMath will answer
- 0^sgn(n) for 0^n.
-
- Mathematica gives
- In[12]:= Declare[n, Positive]
-
- In[13]:= 0^n (* Remember we defined a rule to handle this *)
-
- Out[13]= 0
-
- In[14]:= 0^0
-
- 0
- Power::indet: Indeterminate expression 0 encountered.
-
- Out[14]= Indeterminate
-
- 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.
-
- >**************************** Example 5 ******************************
- > Maple:
- >> int(x^k, x);
- >
- > (k + 1)
- > x
- > --------
- > k + 1
- >
- > SymbMath:
- > Input:
- >inte(x^k*d(x))
- >subs(k=-1 to last)
- > Output:
- >constant + x^(1 + k)/(1 + k)
- >discont
-
- I'm not really sure what the point of this example was. What did Maple
- do "wrong" that SymbMath did better? Anyway, here is Mathematica:
-
- In[15]:= Integrate[x^k,x]
-
- 1 + k
- x
- Out[15]= ------
- 1 + k
-
- In[15]:= % /. k -> -1
-
- 1
- Power::infy: Infinite expression - encountered.
- 0
-
- Out[16]= ComplexInfinity
-
- Seems Mathematica can do this example also.
-
- >**************************** Example 6 *****************************
- >> limit(x^k/exp(x), x=infinity);
- >
- > SymbMath:
- > Input:
- >lim(x=inf, x^k/exp(x))
- >lim(x=inf, x^(10^10)/exp(x))
- >lim(x=inf, x^(10^10000)/exp(x))
- > Output:
- >0
- >0
- >0
-
- Mathematica does have trouble doing these limits for k > 3 with the
- built-in Limit command. However, if we load the package Calculus'Limit'
- then Mathematica can do this example also.
-
- In[17]:= <<Limit.m
-
- In[18]:= Limit[x^k/Exp[x],x->Infinity]
-
- Out[18]= 0
-
- In[19]:= Limit[x^(10^10)/Exp[x],x->Infinity]
-
- Out[19]= 0
-
- In[20]:= Limit[x^(10^1000)/Exp[x],x->Infinity]
-
- Out[20]= 0
-
- >****************************** Example 7 ****************************
- > Maple:
- >> int(x^m * exp (-b * x), x=0..infinity);
- >
- > infinity
- > /
- > | m
- > | x exp(- b x) dx
- > |
- > /
- > 0
- >
- >
- ># As expected, the integral remains unevaluated. Now declare the signs
- ># of the symbolic parameters:
- >
- >> signum(b) := 1;
- >
- > signum(b) := 1
- >
- >> signum(m) := 1;
- >
- > signum(m) := 1
- >
- >
- ># Upon attempting to compute the integral a second time...
- >
- >> int(x^m * exp (-b * x), x=0..infinity);
- >
- > infinity
- > /
- > | m
- > | x exp(- b x) dx
- > |
- > /
- > 0
- >
- ># ...THE INTEGRAL CONTINUES TO REMAIN UNEVALUATED, despite the fact that
- ># the signs of the parameters 'b' and 'm' were declared PRIOR to the second
- ># attempt at computation.
- >
- > SymbMath:
- > Input:
- >inte(x^n*exp(-a*x), x from 0 to inf)
- > Output:
- >inte(x^n*exp(-a*x), x, 0, inf)
-
- Huh? It seems SymbMath cannot do this integral either.
- Mathematica:
-
- In[21]:= Integrate[x^m Exp[-b x],{x,0,Infinity}]
-
- -1 - m
- Out[21]= b Gamma[1 + m]
-
- >************************ Example 8 *********************************
- > Mathematica:
- >In[1]:= Integrate[1/x,{x,-1,1}]
- >Out[1]= -Log[-1]
- >
- > Maple:
- >has the same problem.
- >
- > SymbMath:
- > Input:
- >inte(1/x, x from -1 to 1)
- >inte(1/x, x from -1 to 2)
- > Output:
- >0
- >ln(2)
- >
- The problems of Mathematica with improper integrals with an
- internal singularity are well known. But is SymbMath's answer any
- better? The standard definition of the inproper integral of f(x) from a
- to b when f has a singularity at c between a and b is
-
- limit int(f[x],a to c-e1) + limit int(f[x], c+e2 to b) (1)
- e1->0+ e2->0+
-
- and with this definition int(1/x, x from -1 to 1) does not exist, so
- SymbMath's answer is wrong. What SymbMath has computed is actually the
- Cauchy Principal Value, defined by
-
- limit [ int(f[x],a to c-e) + int(f[x],c+e to b} ] (2)
- e->0+
-
- If the limit in (1) exists, then so does the limit in (2), but the
- converse is not true. Which definition to use is, of course, up to the
- user and depends on the reason for computing the integral. However, the
- first definition is certainly the one most often encountered,
- particularly in undergraduate calculus courses. In fact, Watson Fulks
- writes in "Advanced Calculus: An Introduction to Analysis" that with
- the Cauchy Principal Value "we are not dealing with a proper integral
- nor even with an ordinary or garden-variety improper one" (p419).
-
- Mathematica *can* compute Cauchy Principal Values also, but the user
- must supply the exact location of the singularity. Here are the two
- examples that Huang gives:
-
- In[4]:= <<CauchyPrincipalValue.m
-
- In[5]:= CauchyPrincipalValue[1/x,{x,-1,{0},1}]
-
- 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.
-
- Out[5]= 0.
-
- In[6]:= CauchyPrincipalValue[1/x,{x,-1,{0},2}]
-
- 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.
-
- Out[6]= 0.693147
-
- >*************************** Example 9 *******************************
- > Maple:
- >has a problem for int(tan(x), x=0..pi).
- >
- > SymbMath:
- > Input:
- >inte(tan(x), x from 0 to pi)
- > Output:
- >0
-
- Again, SymbMath has computed the Principal Value. Under the first
- definition of an improper integral given above, this integral does not
- exist.
-
- 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.
-
- >**************************** Example 10 ****************************
- > Mathematica:
- >cannot evaluate integral of sgn(x).
- >
- This is incorrect
-
- In[3]:= Integrate[Sign[x],{x,-1,1}]
-
- Out[3]= 0
-
- In[4]:= Integrate[Sign[x],{x,-1,2}]
-
- Out[4]= 1
-
- > SymbMath:
- > Input:
- >inte(sgn(x), x from -1 to 1)
- >inte(sgn(x), x from -1 to 2)
- > Output:
- >0
- >1
- >
- >************************* Example 11 ********************************
- >Implicit diff. gives 1+y'[x](1+1/y[x])==0; y'[x]==-y[x]/(y[x]+1).
- >
- > Mathematica:
- > given this eq. as input to DSolve says that built-in
- > procedure can't solve it.
- >
- DSolve in version 2.0 cannot solve this equation. However, version 2.1
- comes with an additional DSolve package that *can* solve this equation.
- From the Macintosh 2.1 version we get
-
- In[1]:=DSolve[y'[x]==-y[x]/(y[x]+1),y[x],x]
-
- Solve::tdep:
-
- The equations appear to involve trancendental functions
- of the variables in an essentially non-algebraic way.
-
- Out[1]= Solve[-Log[y[x]] - y[x] == x + C[1] , y[x]]
- (Note, what this means is that Mathematica was unable to find an
- *explicit* solution for y[x], but neither could SymbMath. They just
- indicated this in different ways)
-
- >
- > SymbMath:
- >solve the differential equation by integration inte() or by dsolve().
- > Input:
- >d(y)/d(x)*(1+1/y) === -1
- >inte(last*d(x))
- >Expand=On
- >dsolve(d(y)/d(x) === -y/(y+1), y)
- > Output:
- >(1 + 1/y)*d(y)/d(x) === -1
- >y + ln(y*sgn(y)) === constant - x
- >Expand = On
- >-y - ln(y*sgn(y)) === constant + x
- >
- >
- >************************* Example 12 ********************************
- > Mathematica:
- > y'[x] = y[x]^(1/2)
- > y[0] = 0
- >
- >DSolve could not handle it. (It rarely solves anything!!), and the
- >RungeKutta package only gave me the solution
- >
- > y[x]=0
- >
- >Obviously, there is another solution viz.
- >
- > y[x] = (x/2)^2
-
- Again, version 2.1 can solve this equation:
-
- In[2]:= DSolve[{y'[x]==y[x]^(1/2), y[0]==0},y[x],x]
-
- 2
- x
- Out[2]= {{y[x]->--}}
- 4
-
- >
- > SymbMath:
- > Input:
- >dsolve(d(y)/d(x) === sqrt(y), y) [Can SymbMath handle initial conditions?]
- >(last/2)^2
- > Output:
- >2*sqrt(y) === constant + x
- >y === 1/4*(constant + x)^2
- >
- >************************* Example 13 ********************************
- > Mathematica:
- > Sqrt[a^2] evaluates to Sqrt[a^2].
- >
- > SymbMath:
- > Input:
- >sqrt(x^2)
- >assume(a > 0)
- >sqrt(a^2)
- >assume(b <0 )
- >sqrt(b^2)
- > Output:
- >x*sgn(x)
- >assumed
- >a
- >assumed
- >-b
- >
-
- If we tell Mathematica what kind of variables we are working with, it
- has no problem with this example:
-
- In[4]:= <<Declare.m
- {Declare, NewDeclare, NonPositive, RealQ}
-
- In[5]:= Declare[x,Real,a,Positive,b,Negative]
-
- In[6]:= Sqrt[x^2]
-
- Out[6]= Abs[x]
-
- In[7]:= Sqrt[a^2]
-
- Out[7]= a
-
- In[8]:= Sqrt[b^2]
-
- Out[8]= -b
-
- >********************** Example 14 **********************************
- > Maple and Mathematica cannot find the integrals of abs(x).
- >
- > SymbMath:
- > Input:
- >inte(abs(x), x from -1 to 1)
- >inte(abs(x)^5*d(x))
- > Output:
- >1
- >constant + 1/6*abs(x)^6*sgn(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]
-
- 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
-
- In[9]:= Integrate[abs[x]^4,x]
-
- 5
- x
- Out[9]= --
- 5
-
- We had to define our own rules, but Mathematica could do this 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.
- >
- >The comments "INTEGRAL IS DIVERGENT" and "Principal Value" come from
- >Macsyma. Mma gives no indication that anything is amiss.
- >
- >************************ Problem3 *********************************
- > Mathematica:
- >In[4]:= Integrate[1/x^2,{x,-3,1}]
- >
- > 4
- >Out[4]= -(-) (* INTEGRAL IS DIVERGENT *)
- > 3
- >
- > SymbMath:
- > Input:
- >inte(1/x^2, x from -3 to 1)
- > Output:
- >inf
-
- This is impressive. Was SymbMath able to detect the singularity and
- compute the appropriate improper integral? Let's translate the
- function and interval one unit to the right. This should not affect the
- value of the integral
-
- SymbMath:
- Input:
- inte(1/(x-1)^2, x from -2 to 2)
- Output:
- -4/3
-
- Oops. Looks like SymbMath got the same answer as Mathematica.
-
- >
- >************************** Problem12 ***************************
- > Mathemtica:
- >In[6]:= Integrate[x^(-4/3),{x,-1,1}]
- >
- >Out[6]= -6 (* INTEGRAL IS DIVERGENT *)
- >
- > SymbMath:
- > Input:
- >inte(x^(-4/3), x from -1 to 1)
- > Output:
- >inf
- >
- Let's try translating the function and interval again.
-
- SymbMath:
- Input:
- inte((x-1)^(-4/3), x from 0 to 2)
- Output:
- -6
-
- Well, again SymbMath got the same incorrect answer as Mathematica.
- My suspicion is that SymbMath has built-in rules to tell it how to
- integrate x^(-n) from a to b when n > 1 and a < 0 < b. However, when
- SymbMath cannot use one of these rules, as when we translated the
- function, then it simply integrates and evaluates at the endpoints,
- *just as Mathematica does*.
-
- >**************************** Problem15 ************************
- > Mathematica:
- >In[7]:= Integrate[1/x,{x,-1,2}]
- >
- >Out[7]= -Log[-1] + Log[2]
- >
- > Maple:
- >has the same problem.
- >
- > Macsyma:
- > (c7) integrate(1/x,x,-1,2);
- > Principal Value
- > (d7) log(2)
- >
- > SymbMath:
- > Input:
- >inte(1/x, x from -1 to 2)
- > Output:
- >ln(2)
- >
- Here SymbMath has computed the Cauchy Principal Value. The improper
- integral as Swokowski would define it is divergent.
-
- >
- >********************** Problem16 ************************************
- > Mathematica:
- >In[8]:= Integrate[1/(x^2-x-2),{x,0,4}]
- >
- > -Log[-2] Log[2] Log[5]
- >Out[8]= -------- + ------ - ------
- > 3 3 3
- >
- > Macsyma:
- > (c8) integrate(1/(x^2-x-2),x,0,4);
- > Principal Value
- > log(5)
- > (d8) - ------
- > 3
- >
- >
- > SymbMath:
- > Input:
- >inte(1/(x^2-x-2), x from 0 to 4)
- > Output:
- >-1/3*ln(2) + 1/3*ln(2/5)
- >
- Here is an interesting answer. Why would it be of this form? It might
- be interesting to see how SymbMath would do the indefinite integral.
-
- SymbMath:
- Input:
- inte(1/(x^2-x-2)*d(x))
- subs(x=4 to last) - subs(x=0 to last)
- Output:
- constant + 1/3*ln(abs(-4+2*x)/abs(2+2*x))
- -1/3*ln(2) + 1/3*ln(2/5)
-
- It appears that SymbMath evaluated this improper integral by simply
- integrating and evaluating at the endpoints, which is not,
- in general, a valid procedure. It works here because if
-
- int(f(x)*d(x)) = ln(abs(g(x)) where g(x) is continuous
-
- 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
- in this context is that it has been programmed to use
-
- inte(1/x*d(x)) = ln (x * sgn(x))
-
-
- >***************************** Problem23 **********************
- > Mathematica:
- >In[10]:= Integrate[(1/x^2)Cos[1/x],{x,-1,2}]
- >
- > 1
- >Out[10]= Sin[-1] - Sin[-] (* INTEGRAL IS DIVERGENT *)
- > 2
- >
- > SymbMath:
- > Input:
- >y=1/x^2*cos(1/x)
- >inte(y, x from -1 to 0-zero) + inte(y, x from 0+zero to 2)
- > Output:
- >y = x^(-2)*cos(1/x)
- >sin(-1) - sin(1/2) + 2*sin(inf)
- >
- Now wait a minute. Huang makes Mathematica integrate over an interval
- that includes the singularity, but has SymbMath break the integral into
- its two part as the definition of this improper integral requires. That
- doesn't seem quite fair. 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
-
- Now Mathematica tells us that the integral is divergent. It would have
- been interesting to see what answer SymbMath gave if we asked it to
- integrate from -1 to 2, but the shareware version of SymbMath, which I
- was using, does not include the trig functions.
-
- >************************** Problem29 ********************************
- > Mathematica:
- >In[12]:= Integrate[1/(x-4)^2,{x,0,Infinity}]
- >
- > 1
- >Out[12]= -(-) (* INTEGRAL IS DIVERGENT *)
- > 4
- >
- > SymbMath:
- > Input:
- >y=1/(x-4)^2
- >inte(y, x from 0 to 4-zero) + inte(y, x from 4+zero to inf)
- > Output:
- >y = (-4 + x)^(-2)
- >inf
- >
- Here we go again, asking Mathematica to integrate over the singularity
- while letting SymbMath integrate over two intervals. Let's have
- SymbMath do it the same way as Mathematica:
-
- SymbMath:
- Input:
- inte(1/(x-4)^2, x from 0 to inf)
- Output:
- -1/4
-
- The same *wrong* answer as Mathematica. 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.
- --
- Larry Riddle | riddle@mathcs.emory.edu PREFERRED
- Agnes Scott College | {rutgers,gatech}!emory!riddle UUCP
- Dept of Math | riddle@emory.bitnet NON-DOMAIN BITNET
- Decatur, GA 30030 | Phone: Voice 404-371-6222, FAX 404-371-6177
-