Re: question about Protect
- To: mathgroup at smc.vnet.net
- Subject: [mg75149] Re: question about Protect
- From: dimitris <dimmechan at yahoo.com>
- Date: Wed, 18 Apr 2007 05:09:02 -0400 (EDT)
- References: <f013jm$8f5$1@smc.vnet.net>
Hello. What version do you use? On mine I get In[1]:= Unprotect[Limit]; In[2]:= Attributes[Limit] Out[2]= {Listable} In[3]:= Integrate[Exp[-x], {x, 1, Infinity}] Out[3]= 1/E In[4]:= Attributes[Limit] Out[4]= {Listable, Protected} Note that Limit MISSES the attribute ReadProtected from the attributes list appeared on your post. (As long as I remember you use 5.2 for Mac; If so, does it seems logical this difference between the two versions?) In[5]:= Unprotect[Limit]; In[6]:= Attributes[Limit] Out[6]= {Listable} In[7]:= Integrate[Exp[-x], {x, 1, 2}] Out[7]= (-1 + E)/E^2 In[8]:= Attributes[Limit] Out[8]= {Listable} >It seems that built-in functions, when they call on another built in >function will sometimes Protect if it had previously been Unprotected. Your statement seems to have a basement, but your examples are quite contradictory. I mean, in the first example it seems that after Integrate obtained the antiderivative and search for convergence (where Limit is first called) it then (re)calls Limit in order to apply the Nweton-Leibniz formula. That is, I think something like the following take place In[24]:= (Limit[Exp[-x], x -> #1] & ) /@ {1, Infinity} ant = Integrate[Exp[-x], x] (Limit[ant, x -> #1] & ) /@ {1, Infinity} (Plus[#2 - #1] & ) @@ % Out[24]= {1/E, 0} Out[25]= -E^(-x) Out[26]= {-(1/E), 0} Out[27]= 1/E And in the end Limit was Protect(ed). In the second example (since Limit was not protected and based on your argument) it seems that Limit was not called at all. But then how Integrate checked for convergence and moreover how the Newton-Leibniz formula was applied? I mean by hand we can write down In[32]:= Simplify[(ant /. x -> 2) - (ant /. x -> 1)] Out[32]= (-1 + E)/E^2 but as far as know even for simple cases like these (that is no indeterminate forms that required limits or improper integrals and the staf) Mathematica evaluates the antiderivative at the end-points with something like In[34]:= Simplify[Limit[ant, x -> 2] - Limit[ant, x -> 1]] Out[34]= (-1 + E)/E^2 I was puzzled. But now I got more confused! >I have not investigated this sufficiently to be able to describe the >exact circumstancs under which this happens... I hope you will find the time to do so. With your mathematical and Mathematica knowledge I am quite sure you will succeed in finding what is going on and then... share your conclusion with us if you don't mind! >I speculate that a Mathematica function that calls on another Mathematica = function >sometimes (or often or always (?)) Unprotects it and when it finished >its job Protects it again. If this is correct than a function that >had been earlier Unprotected by a user would end up automatically >Protected. Probably a better approach would be to simply save and >restore the attributes the function had when it was called; so this >might be a minor bug? Bug or not a bug it deserves a thorough explanation by someone from WRI. Until then above explanation (or should I say guessing?) of you is what we just have on our hands! Kind Regards Dimitris =CF/=C7 dimitris =DD=E3=F1=E1=F8=E5: > Hello. > > The following code add a rule for the Limit command > > In[1]:= > Off[General::spell1] > Unprotect[Limit]; > Limit[a___] := Null /; (Print[InputForm[limit[a]]]; False) > > For example > > In[7]:= > Integrate[1/Sqrt[Abs[x]], {x, -1, 2}] > > >From In[7]:= > InputForm[limit[1 + (1 + x)/2 + (3*(1 + x)^2)/8, x -> -1, Direction -> > -1, Assumptions -> True]] > >From In[7]:= > InputForm[limit[(-I)/Sqrt[x], x -> 0, Direction -> 1, Assumptions -> > True]] > >From In[7]:= > InputForm[limit[I/Sqrt[x], x -> 0, Assumptions -> True]] > >From In[7]:= > InputForm[limit[2*Sqrt[x], x -> 1, Direction -> 1, Assumptions -> > True]] > >From In[7]:= > InputForm[limit[2*Sqrt[x], x -> 0, Direction -> -1, Assumptions -> > True]] > >From In[7]:= > InputForm[limit[1/Sqrt[x], x -> 0, Direction -> -1, Assumptions -> > True]] > >From In[7]:= > InputForm[limit[1/Sqrt[x], x -> 0, Assumptions -> True]] > >From In[7]:= > InputForm[limit[1/Sqrt[2] - (-2 + x)/(4*Sqrt[2]) + (3*(-2 + x)^2)/ > (32*Sqrt[2]), x -> 2, Direction -> 1, Assumptions -> True]] > >From In[7]:= > InputForm[limit[2*Sqrt[x], x -> 2, Direction -> 1, Assumptions -> > True]] > >From In[7]:= > InputForm[limit[2*Sqrt[x], x -> 0, Direction -> -1, Assumptions -> > True]] > > Out[7]= > 2*(1 + Sqrt[2]) > > Note that I have NOT protect the Limit command. Nevertheless, > > In[8]:= > Clear[Limit] > Clear::wrsym: Symbol Limit is Protected. > > > Why do we get this message? How Limit was protected WITHOUT telling > so? > > In[12]:= > Information["Limit", LongForm -> True] > > "Limit[expr, x->x0] finds the limiting value of expr when x approaches > x0."*Button[More..., ButtonData :> "Limit", > Active -> True, ButtonStyle -> "RefGuideLink"] > Attributes[Limit] = {Listable, Protected} > Limit[a___] := Null /; (Print[InputForm[limit[a]]]; False) > Options[Limit] = {Analytic -> False, Assumptions :> $Assumptions, > Direction -> Automatic} > > Of course > > In[19]:= > Unprotect[Limit]; > Clear[Limit]; > Protect[Limit]; > > In[22]:= > Information["Limit", LongForm -> True] > > "Limit[expr, x->x0] finds the limiting value of expr when x approaches > x0."*Button[More..., ButtonData :> "Limit", > Active -> True, ButtonStyle -> "RefGuideLink"] > Attributes[Limit] = {Listable, Protected} > Options[Limit] = {Analytic -> False, Assumptions :> $Assumptions, > Direction -> Automatic} > > but the question still remains!
- Follow-Ups:
- Re: Re: question about Protect
- From: Andrzej Kozlowski <akoz@mimuw.edu.pl>
- Re: Re: question about Protect