MathGroup Archive 1992

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Suppressing the use of special functions

  • To: mathgroup at yoda.physics.unc.edu
  • Subject: Re: Suppressing the use of special functions
  • From: withoff
  • Date: Sat, 24 Oct 92 14:56:15 CDT

> From: BEEZER at ups.edu (Rob Beezer)
> Subject: Suppressing the use of special functions
> 
> I would like to have Mathematica demonstrate the result of integrating
> expressions like x^n E^(-x) as part of a calculus lesson on integration
> by parts.  Unfortunately, I get
> 
> Integrate[x^2 E^(-x), x] = -Gamma[3, x]
> 
> when I would prefer to get
> 
> Integrate[x^2 E^(-x), x] = (2 + 2x + x^2) E^(-x).
> 
> Can anyone tell me how to suppress the use of the gamma function for
> problems like this?
> 
> Thanks in advance,
> 
> Robert Beezer
> University of Puget Sound
> beezer at ups.edu 

There are roughly two ways to do this: add a rule to rewrite Gamma[3, x]
in the form you want, or change Integrate to produce that form in the
first place.  I will describe the second way, which is the way I would
recommend.

The integral Integrate[x^2 E^(-x), x] is fairly easy and can be evaluated
using several methods.  The method used in Version 2.1 is to simply
look the integral up in a table.  If this method is disabled, the integral
will go on to another method (the Risch algorithm) which will give the
answer you want:

In[1]:= Integrate[Exp[-x] x^2, x]

Out[1]= -Gamma[3, x]

In[2]:= Block[{Integrate`TableMatch},
            Integrate[Exp[-x] x^2, x] ]

                    2
        -2 - 2 x - x
Out[2]= -------------
              x
             E

Using Block[{Integrate`TableMatch}, ...] is one way to temporarily
disable the lookup table.  A better way is to change the table.

The table is defined in a startup package called table.m in the Integrate
directory.  Near the bottom of that table you should find a rule that
looks like this:

TableMatch[E^(-X)*X^$a_]:=
  Condition[
    -Gamma[$a+1,X],
    FreeQ[$a,X]]

This is the rule that is used to evaluate this integral.  If you remove
this rule from table.m and reload the startup packages, you will get
the result you want.  Unfortunately, doing so also prevents Mathematica
from being able to compute Integrate[x^n  E^(-x), x], so a better method
would be to replace this rule with:

TableMatch[E^(-X)*X^$a_]:=
  Condition[
    -Gamma[$a+1,X],
    FreeQ[$a,X] && !IntegerQ[2 $a]]

This is probably the best thing to do if you have a whole classroom full
of computers and you want all of them to behave this way whenever they
start up.

Yet another thing to do, which does not require reloading the initialization
packages, is to replace the offending rule.  If EditDefinition is implemented
on your computer, you can enter EditDefinition[Integrate`TableMatch], find
the rule (I think it will be the 49th rule out of 52), and change it.

Or, if you want to really mess with the nitty gritty of things you
can change the DownValues list for Integrate`TableMatch:

In[14]:= Begin["Integrate`"]

In[17]:= DownValues[TableMatch][[49]] //InputForm

Out[17]//InputForm= 
  Literal[TableMatch[X^($a_)/E^X]] :> -Gamma[$a + 1, X] /; FreeQ[$a, X]

In[18]:= DownValues[TableMatch] = ReplacePart[DownValues[TableMatch],
             Literal[TableMatch[X^($a_)/E^X]] :> -Gamma[$a + 1, X] /;
                 FreeQ[$a, X] && !IntegerQ[2 $a], 49] ;

In[19]:= End[]

If none of them seem appropriate for your purpose, your could try
contacting Wolfram Research Technical Support (support at wri.com).

Dave Withoff
withoff at wri.com





  • Prev by Date: vectors with mma
  • Next by Date: ParametricPlot3D
  • Previous by thread: Suppressing the use of special functions
  • Next by thread: Plotting propability distributions