Re: question about HoldForm

• To: mathgroup at smc.vnet.net
• Subject: [mg60808] Re: question about HoldForm
• From: Peter Pein <petsie at dordos.net>
• Date: Thu, 29 Sep 2005 05:41:22 -0400 (EDT)
• References: <dhdbc3\$8eg\$1@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```Ruth Lazkoz schrieb:
> Hi,
>
> I have this expression
>
> x = 2; HoldForm[x^2 + 4x + 4]
>
> Is there a way to operate on HoldForm so that I get (x^2+2)^2? If I cut
> a paste the result and operate on it I obviously get 16.
>
> Thanks,
>
> Ruth
>
>
In[1]:=
x=2;hf=HoldForm[x^2+4x+4];

the obvious:

In[2]:= hf/.HoldForm[x^2+4x+4]->HoldForm[(x^2+2)^2]
Out[2]= (x^2+2)^2

this unfotunately changes the structure (HoldForm "slides down" to x^2):
In[3]:= Factor@ReleaseHold[hf/.HoldPattern[x]->HoldForm[x^2]]
Out[3]= (2+x^2)^2

In[4]:= %//FullForm
Out[4]//FullForm= Power[Plus[2,HoldForm[Power[x,2]]],2]

... but why do you want this unusual mapping (x^2+4x+4 -> (x^2+2)^2)?
;-)

Peter

```

• Prev by Date: Re: Bug in Mathematica ?
• Next by Date: Re: Bug in Mathematica ?
• Previous by thread: Re: question about HoldForm
• Next by thread: Re: question about HoldForm