Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2012

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

Search the Archive

Re: Mantaining the same form

  • To: mathgroup at smc.vnet.net
  • Subject: [mg124134] Re: Mantaining the same form
  • From: "Oleksandr Rasputinov" <oleksandr_rasputinov at hmamail.com>
  • Date: Tue, 10 Jan 2012 06:01:02 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <je9624$iqs$1@smc.vnet.net> <jee830$cvo$1@smc.vnet.net>

On Mon, 09 Jan 2012 08:21:52 -0000, Chris Young <cy56 at comcast.net> wrote:

> On 2012-01-07 10:16:36 +0000, Miguel Gil said:
>
>> At a function in which one parameter is an expression "expr",
>> Mathematica 8.0 evaluates or simplifies the value of "expr" when it is
>> introduced.
>> How is that Mathematica keep the same form of the "expr" introduced?.
>>
>> Example:
>>
>> In []: MyFunction [expr_]: = expr;
>> MyFunction [(Sin [2x], Tan [y]) / (x * Sec [y]^2)]
>>
>> Out []: (Cos [y]^2 (Sin [2x], Tan [y]) / x
>>
>> I want to get the same expression (Sin [2x], Tan [y]) / (x * Sec [y]^2)
>>
>> Clearly, the input expression and modified expression are equivalent,
>> but are not equal.
>> For example, if we were to apply the rule of L'Hopital or the theorem
>> Schwarz  the results would be erroneous.
>
> I tried everything I could think of, but couldn't write any function
> that would just pass on the expression unchanged:
>
> In[264]:= exprHeld[e_] := Hold[e]
>
> In[265]:= exprHeld[(Sin[2 x] * Tan[y])/(x * Sec[y]^2)]
> Out[265]= Hold[(Cos[y] Sin[2 x] Sin[y])/x]
>

You forgot your Attributes:

In[1] :=
exprHeld[e_] := Hold[e];
SetAttributes[exprHeld, HoldAll];

In[3]:= exprHeld[(Sin[2 x]*Tan[y])/(x*Sec[y]^2)]
Out[3]= Hold[(Sin[2 x] Tan[y])/(x Sec[y]^2)]

(Note that HoldAll is an Attribute, not a function.)



  • Prev by Date: Memory usage of a Sierpinski triangle algorithm
  • Next by Date: Re: Can't use subscripted variables in function definition?
  • Previous by thread: Re: Mantaining the same form
  • Next by thread: Re: Mantaining the same form