Re: An open letter
- To: mathgroup at smc.vnet.net
- Subject: [mg16596] Re: [mg16540] An open letter
- From: Daniel Lichtblau <danl>
- Date: Wed, 17 Mar 1999 23:55:04 -0500
- References: <199903160900.EAA09473@smc.vnet.net.>
- Sender: owner-wri-mathgroup at wolfram.com
Jack Goldberg wrote: > > Hi Group, > > I am a Mathematica enthusiast who has dabbled in programming > Mathematica for enough years that I feel free to complain. Here's > my gripe: > > My main purpose in using Mathematica is help students learn mathematics. > So for my purposes the fact that Mathematica evaluates everything in sight > is a major drawback. Let me be explicit. I want to illustrate > "Integration by Parts". So I try to define > > ByParts[Integrate[f_*g_,x_],g_] := ???? > > What I would like as an output of ByParts is this > > Integrate[f*g,x] == f*Integrate[g,x] - > Integrate[D[f,x]*Integrate[g,x],x] > > where the integration on the left IS NOT performed, the integration of > g in the two integrals on the right is performed but the last integral > on the right is unevaluated. Put in other words, I would like Mathematica to > display the kind of formula the student would get using integration by > parts. I have found this surprisingly difficult to do. I have used > various combinations of Evaluate, Hold, HoldFirst and HoldForm with > only partial success. I have gotten to the point where I don't even > understand why my last effort failed! Perhaps someone could explain why > the following does not work. > > ByParts[ f_*g_,x_,g_] := Module[ {int, dif, li1}, > int = Integrate[g,x]; > dif = D[f,x]; > li1 = int*dif; > HoldForm[Integrate[f*g,x]] == f*int- > HoldForm[Integrate[li1,x]] > ] > > (I hope I have the right number of left and right brackets!) > The problem is that the very last HoldForm seems to prevent > li1 from providing int*dif as the integrand. What's going on? > This might be something useful for your purposes. I use a "dummy" head and format it appropriately. ByParts[ f_*g_,x_,g_] := Module[{int, dif, li1}, int = Integrate[g,x]; dif = D[f,x]; li1 = int*dif; HoldForm[Integrate[f*g,x]] == f*int - integrate[li1,x] ] Format[integrate[a___]] := "Integrate"[a] In[3]:= ByParts[x*Log[x],x,x] 2 x x Log[x] Out[3]= Integrate[Log[x] x, x] == -Integrate[-, x] + --------- 2 2 > Now back to my open letter. This example is only one of three or > four that I have fell prey to. All of them are based on Mathematica's propensity > to evaluate. I offer only one more example and I will be brief > in my description. > > I want to explain why e^x*e^x = e^(2x) by using > the power series expansion of e^x. I > define the Cauchy product of series for the students and would like > Mathematica to exhibit the nth coefficient of the product as a finite sum. > > Sum[ x^n/n!, {n,0,Infinity} ]*Sum[ x^n/n!, {n,0,Infinity} ] == > Sum[ Sum[ 1/(k!(n-k)!, {k,0,n}] x^n, {n,0,Infinity} ] > > There is not a single term in this expression that Mathematica will leave > unevaluated! I could trick Mathematica by inserting spurious factors that > would stop the evaluation process, but I don't want to have to figure > out some clever way to do this or to introduce holds etc. Here is a possibility. Use RSolve`SeriesTerm to see the nth term of the product, and a single sum to get at individual coefficients from the rhs. <<DiscreteMath`RSolve` In[8]:= SeriesTerm[Sum[x^n/n!,{n,0,Infinity}] * Sum[ x^n/n!,{n,0,Infinity}], {x,0,n}] n 2 Out[8]= -- n! In[9]:= Sum[ 1/(k!(n-k)!), {k,0,n}] n 2 Out[9]= ------------ Gamma[1 + n] > ... Daniel Lichtblau Wolfram Research
- References:
- An open letter
- From: Jack Goldberg <jackgold@math.lsa.umich.edu>
- An open letter