[Date Index]
[Thread Index]
[Author Index]
Re: General--Exponential simplifications by default
*To*: mathgroup at smc.vnet.net
*Subject*: [mg69156] Re: General--Exponential simplifications by default
*From*: p-valko at tamu.edu
*Date*: Thu, 31 Aug 2006 04:39:16 -0400 (EDT)
*References*: <2219B7076306D04492C4696EC5C9401C680001@PE-MAIL.pe.tamu.edu> <ed3sle$s89$1@smc.vnet.net>
*Sender*: owner-wri-mathgroup at wolfram.com
You simply neglected my last example and went back to your example (the
value of 2/3).
However, your example is not interesting, because in it the result of
Numerator[] is not contradictory at all.
In my example, the value (in your words) of the input expression
1/Sqrt[2] is still 1/Sqrt[2] but the result of applying Numerator[] to
it gives a strikingly different than anticipated result.
Numerator[] does something else in between and we do not know what she
is doing. If you use Trace, you can see that everything strange is
happening inside the Numerator[] that is
In[2]:=
Map[InputForm,Trace[Numerator[1/Sqrt[2]]]]
Out[2]=
{{{{HoldForm[Sqrt[2]], HoldForm[Sqrt[2]]}, HoldForm[Sqrt[2]^(-1)],
HoldForm[1/Sqrt[2]]}, HoldForm[1/Sqrt[2]],
HoldForm[1/Sqrt[2]]},HoldForm[Numerator[1/Sqrt[2]]],HoldForm[Sqrt[2]]}
The rersult of Numerator[1/Sqrt[2]] is Sqrt[2] and
"all of this is quite not standard staff and cannot be found in every
book on functional languages..."
Andrzej Kozlowski wrote:
> The problem is that you are using the word "evaluate" in a different
> sense than the normal sense used in the context of functional
> programming languages and computer algebra systems. In this normal
> usage all "simplifications" (your words) performed by "the
> Evaluator" are "evaluations" and their results are "values" of the
> input expressions. Simplify is, something quite different - a
> function applied by the user with its own semantics and its own
> evaluation sequence, quite separate from what the "Evaluator" does.
>
> For example, the expression 2/3 when entered into Mathematica has
> FullForm
>
>
> FullForm[Hold[2/3]]
>
> Hold[Times[2,Power[3,-1]]]
>
> but the Evaluator evaluates this to:
>
> FullForm[2/3]
>
> Rational[2,3]
>
> This is normally described by saying that the value of Times[2,Power
> [3,-1]] in Mathematica is Rational[2,3]. There are many such cases in
> Mathematica and what you have come across are just some of them.
> This is completely analogous to what you find in other functional
> languages (like Lisp) where you have to carefully distinguish between
> unevaluated expressions and their "values". (In Lisp you use the
> quote sign to make this distinction). All of this is standard staff
> and can be found in every book on functional languages etc.
>
> Andrzej Kozlowski
>
>
>
>
>
> On 29 Aug 2006, at 18:27, Valko, Peter wrote:
>
> > Andrzej:
> >
> > You tried to convince me that Denominator[] and Numerator[] evaluates
> > its argument in a standard way and then they find the positive and
> > negative powers.
> > I tried to convince you, that Denominator[] and Numerator[] do
> > something
> > more: practically intermitting a Simplify[] operation before really
> > getting to do the real job.
> > Proof:
> >
> > If I write
> > 1/Sqrt[2]
> > or I write
> > Evaluate[1/Sqrt[2]]
> > I still get
> > 1/Sqrt[2] (in input form) or Power[2,Rational[-1,2]] (in full form).
> >
> > However, when I ask for
> > Numerator[1/Sqrt[2]]
> > I get
> > Sqrt[2] (in input form) or Power[2, Rational[1, 2]] (in full form)
> > so "it is pretty clear" that Numerator[] and Denominator[] are doing
> > something secret after evaluating the argument and before really
> > finding
> > the Numerator and Denominator.
> >
> > Your "solution" suggesting to use
> > Numerator[Unevaluated[1/Sqrt[2]]]
> > does something else than just preventing the evaluation of
> > 1/Sqrt[2]
> > (because we already agreed that the evaluation does not do anything to
> > the expression 1/Sqrt[2]).
> > What it really prevents is the simplification of the unevaluated or
> > the
> > evaluated expression, because (I guess) an Unevaluated[expression] is
> > left intact by Simplify[].
> >
> >
> > Or am I missing something?
> >
> >
> >
> >
> > -----Original Message-----
> > From: Andrzej Kozlowski [mailto:akoz at mimuw.edu.pl]
To: mathgroup at smc.vnet.net
> > Subject: [mg69156] Re: Re: General--Exponential simplifications by
> > default
> >
> > Pro* The statement about FullForm you are quoting is "true", at best,
> > only in a "certain sense":
> > FullForm does "not affect" evaluation "inside" FullForm, as in:
> >
> > FullForm[2^2]//InputForm
> >
> > FullForm[4]
> >
> > But of course it does affect evaluation "outside" FullForm, as in:
> >
> >
> > FullForm[2]^2//InputForm
> >
> >
> > FullForm[2]^2
> >
> > This is the reason why you also get:
> >
> >
> > {Numerator[#],Denominator[#]}&@FullForm[2/3]//InputForm
> >
> >
> > {FullForm[2/3], 1}
> >
> > which I think makes pretty clear what happened also in your example.
> >
> > Andrzej Kozlowski
> >
> >
> >
> > On 29 Aug 2006, at 08:26, p-valko at tamu.edu wrote:
> >
> >> Thanks and basically I agree. However, a funny side effect is the
> >> following:
> >>
> >> Denominator[Exp[x] /. x -> -2 ]
> >> gives
> >> E^2
> >>
> >> but
> >>
> >> Denominator[FullForm[Exp[x]] /. x -> -2 ] gives
> >> 1
> >>
> >> In other words, wrapping the FullForm around an expression changes
> >> its
> >
> >> "meaning".
> >> This contradicts the statement that
> >>>> FullForm acts as a "wrapper", which affects printing, but not
> >>>> evaluation.<<
> >> Or am I missing something?
> >>
> >>
> >>
> >> Andrzej Kozlowski wrote:
> >>> I do not consider any of these examples "a contradiction". What
> >>> needs
> >
> >>> to be understood is the difference between certain Mathematica
> >>> expressions before and after they are evaluated. In the case of your
> >>> examples consider:
> >>>
> >>>
> >>> Numerator[Unevaluated[Exp[-x]]]
> >>>
> >>> E^(-x)
> >>>
> >>> vs
> >>>
> >>> Numerator[Exp[-x]]
> >>>
> >>> 1
> >>>
> >>>
> >>> Numerator[Unevaluated[1/Sqrt[2]]]
> >>>
> >>> 1
> >>>
> >>> vs
> >>>
> >>> Numerator[1/Sqrt[2]]
> >>>
> >>> Sqrt[2]
> >>>
> >>> The cause of the apparent problem is that Numerator does not hold
> >>> its
> >
> >>> argument, so whiteout Unevaluated you are getting the numerator of
> >>> the whatever your expression evaluates to, not of your actual input.
> >>> TO get the latter you simply need to use Unevaluated. This is no
> >>> different from:
> >>>
> >>>
> >>> Numerator[3/6]
> >>>
> >>> 1
> >>>
> >>> Numerator[Unevaluated[3/6]]
> >>>
> >>> 3
> >>>
> >>> If this is not a contradiction than neither are the other examples.
> >>> Understanding the process of evaluation is perhaps the most
> >>> important
> >
> >>> thing when using functional languages (not just Mathematica, the
> >>> same
> >
> >>> sort of things occur, perhaps in an even more striking way, in
> >>> languages like Lisp ).
> >>>
> >>> Andrzej Kozlowski
> >>>
> >>>
> >>>
> >>> On 27 Aug 2006, at 07:24, p-valko at tamu.edu wrote:
> >>>
> >>>> Daniel,
> >>>> Could you tell me why the contradiction?:
> >>>>
> >>>> In[14]:=Exp[-x]//InputForm
> >>>> Out[14]//InputForm=E^(-x)
> >>>>
> >>>> In[15]:=Numerator[Exp[-x]]//InputForm
> >>>> Out[15]//InputForm=1
> >>>>
> >>>> Mathematica automatically turns it into Power[E, Times[-1, x]], but
> >>>> the user beleives that the exponent is in the numerator.
> >>>> What you see is not what you get!
> >>>>
> >>>>
> >>>> My favorite contradiction is the following:
> >>>>
> >>>> In[24]:=Numerator[1/Sqrt[2]]//InputForm
> >>>> Out[24]//InputForm=Sqrt[2]
> >>>>
> >>>> In[25]:=Denominator[1/Sqrt[2]]//InputForm
> >>>> Out[25]//InputForm=2
> >>>>
> >>>> I think "Numerator" and "Denominator" should not be allowed to do
> >>>> whatever they want. Too much liberty here...
> >>>>
> >>>> Peter
> >>>>
> >>>>
> >>>> Daniel Lichtblau wrote:
> >>>>> guillaume_evin at yahoo.fr wrote:
> >>>>>> Hi !
> >>>>>>
> >>>>>> I want to avoid simplifications when Mathematica integrates
> >>>>>> expressions with exponential terms. For example, I have :
> >>>>>>
> >>>>>> In[8]= Espcond[y_] = Integrate[x*Densx[x, y], {x, 0,
> >>>>>> Infinity}, Assumptions -> alpha > 0]
> >>>>>> Out[8]= E^(-2eta y)(-theta + E^(eta y)(2+theta))/(2alpha)
> >>>>>>
> >>>>>> I do not want to have a factorization by E^(-2eta y). More
> >>>>>> precisely I would like to have the following result:
> >>>>>> Out[8]= (-theta E^(-2eta y)+ E^(-eta y)(2+theta))/(2alpha)
> >>>>>>
> >>>>>> I guess there is a way to tackle this problem with
> >>>>>> "ComplexityFunction" and "Simplify", but I tried different things
> >>>>>> such as "ComplexityFunction -> (Count[{#1}, Exp_, ∞] &)" in
> >>>>>> the "Simplify" function but no change appears.
> >>>>>>
> >>>>>> Is someone could give me some tricks on how tu use the
> >>>>>> "ComplexityFunction" ?
> >>>>>>
> >>>>>> Thank you in advance.
> >>>>>>
> >>>>>> Guillaume
> >>>>>>
> >>>>>> Link to the forum page for this post:
> >>>>>> http://www.mathematica-users.org/webMathematica/wiki/wiki.jsp?
> >>>>>> pageName=Special:Forum_ViewTopic&pid=12974#p12974
> >>>>>> Posted through http://www.mathematica-users.org [[postId=12974]]
> >>>>>
> >>>>>
> >>>>> Could Collect with respect to powers of the exponential.
> >>>>>
> >>>>> In[59]:= ee = E^(-2eta*y)*(-theta + E^(eta*y)(2+theta))/(2*alpha);
> >>>>>
> >>>>> In[60]:= InputForm[Collect[ee, Exp[eta*y]]] Out[60]//InputForm=
> >>>>> -theta/(2*alpha*E^(2*eta*y)) + (2 + theta)/(2*alpha*E^(eta*y))
> >>>>>
> >>>>> Daniel Lichtblau
> >>>>> Wolfram Research
> >>>>
> >>
> >
Prev by Date:
**RE: "Anti-Comments"?**
Next by Date:
**RE: Can't Remove[] variable "K"? (Really strange behavior . . . )**
Previous by thread:
**Re: Re: General--Exponential simplifications by default**
Next by thread:
**nullspaces**
| |