MathGroup Archive 2007

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

Search the Archive

Re: Re: Hold and Equal

  • To: mathgroup at smc.vnet.net
  • Subject: [mg73863] Re: Re: Hold and Equal
  • From: albert <awnl at arcor.de>
  • Date: Fri, 2 Mar 2007 06:32:36 -0500 (EST)
  • References: <erufqm$s7j$1@smc.vnet.net> <200702280929.EAA24225@smc.vnet.net> <acbec1a40702280457r5cd8708at59e67331d62326f5@mail.gmail.com> <es6bt0$r9q$1@smc.vnet.net>

Hi,

>    Attributes@formEquation=List@HoldFirst
>    formEquation[expr_,op_]:=With[{result=op@expr},HoldForm[expr=result]]
> 
>    Table[formEquation[Integrate[x^n, x], Identity], {n, 1, 2}]//InputForm
> {HoldForm[Integrate[x^n, x] = x^2/2], HoldForm[Integrate[x^n, x] = x^3/3]}
> 
> I used InputForm there so could copy as plain text from Mathematica to
> here.  The problem is that both entries in the list have x^n on the left
> side of the equations now.

I think now you are asking for quite much: You want the expression to be
evaluated partially, that is n should be evaluated but not Integrate. I
think the only way to achieve this is to tell mathematica which parts you
want to be evaluated, the following should work:

Table[formEquation[Integrate[x^nn,x],Identity]/.nn->n,{n,1,2}]

or:

Table[With[{n=n},formEquation[Integrate[x^n,x],Identity]],{n,1,2}]

Of course one could argue that Table should be implemented in such a way,
that n will always be inserted in the "evaluted" form since the unevaluated
n doesn't look very usefull. This would be possible, and as an exercise to
learn the details about evaluation you might want to write a myTable that
behaves like that, but probably there were good reasons why Table behaves
as it does.

Using different constructs than Table, you could achieve the same results
without having even more trouble with evaluation, e.g.:

Map[formEquation[Integrate[x^#,x],Identity]&,Range[2]]


hth, 

albert



  • Prev by Date: Re: Beginner--Problem with FilledPlot
  • Next by Date: Re: Regression
  • Previous by thread: Re: Hold and Equal
  • Next by thread: Re: Re: Re: Hold and Equal