MathGroup Archive 2007

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

Search the Archive

Re: Re: Hold and Equal

  • To: mathgroup at smc.vnet.net
  • Subject: [mg73817] [mg73817] Re: Re: Hold and Equal
  • From: albert <awnl at arcor.de>
  • Date: Fri, 2 Mar 2007 06:07:41 -0500 (EST)
  • References: <erufqm$s7j$1@smc.vnet.net> <200702271048.FAA24024@smc.vnet.net> <es3ib9$nus$1@smc.vnet.net>

Murray Eisenberg wrote:

> Aha!  I believe this approach _almost_ allows me to accomplish what I
> was REALLY trying to accomplish.  It certainly works in the example I
> gave.  If I encapsulate this in a function...
> 
>    formEquation[expr_, op_]:= HoldForm[expr=z]/.z\[Rule]op[expr]
> 
> ... then
> 
>    formEquation[(a+b)^2,Identity]
> 
> will produce exactly what I want.
> 
> However, if I try something like the example I was really after (which I
> didn't mention in my original post, since I gave something simpler), it
> works in the direct version...
> 
>    HoldForm[Integrate[x^2,x] = z] /. z\[Rule]Integrate[x^2,x]
> 
> but not with the encapsulating function:
> 
>    formEquation[Integrate[x^2, x], Identity]
> 
> The latter produces the equation
> 
>    x^3/3 = x^3/2

I hope this would be x^3/3 = x^3/3 :-)

> whereas I want the left-hand side to be the unevaluated integral
> expression. 

You need to give formEquation a chance to look at the unevaluated version of
your expression. This would do the trick:

formEquation[Unevaluated[Integrate[x^2,x]],Identity]

Of course it is much nicer if you don't have to always use Unevaluated, so
give formEquation the Attribute HoldFirst, which will make the Unevaluated
unnecessary:

SetAttributes[formEquation,HoldFirst] 

Something else: Using a default value for op will make the function much
nicer to use, in my opinion:

formEquation[expr_, op_:Identity]:= HoldForm[expr=z]/.z\[Rule]op[expr]

now this should work without any extra tricks needed:

formEquation[Integrate[x^2,x]]


hth,

albert




  • Prev by Date: Hilbert Transform problems
  • Next by Date: Re: Numerical integration
  • Previous by thread: Re: Re: Re: Hold and Equal
  • Next by thread: Re: Re: Re: Hold and Equal