MathGroup Archive 2005

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

Search the Archive

Re: Re: question about HoldForm

  • To: mathgroup at smc.vnet.net
  • Subject: [mg60858] Re: [mg60792] Re: [mg60777] question about HoldForm
  • From: Andrzej Kozlowski <andrzej at yhc.att.ne.jp>
  • Date: Fri, 30 Sep 2005 03:57:50 -0400 (EDT)
  • References: <200509280541.BAA08384@smc.vnet.net> <C7A03B69-E78A-4C45-9B9C-26AA77EAA489@yhc.att.ne.jp> <200509290940.FAA00982@smc.vnet.net>
  • Reply-to: Andrzej Kozlowski <andrzej at akikoz.net>
  • Sender: owner-wri-mathgroup at wolfram.com

On 29 Sep 2005, at 18:40, Andrzej Kozlowski wrote:

>
> On 28 Sep 2005, at 16:14, Andrzej Kozlowski wrote:
>
>
>>
>> On 28 Sep 2005, at 14:41, Ruth Lazkoz wrote:
>>
>>
>>
>>>
>>> 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
>>>
>>>
>>>
>>>
>>>
>>
>> Do you mean (x+2)^2?
>> Assuming so one possible way is something like this:
>>
>>
>> x = 2; v = HoldForm[x^2 + 4*x + 4];
>>
>>
>> Block[{x}, HoldForm[Evaluate[v /. HoldForm[u_] :> Factor[u]]]]
>>
>>
>> HoldForm[(x + 2)^2]
>>
>> Andrzej Kozlowski
>>
>>
>>
>>
>
>
> This may be slightly simpler, though the idea is the same.
>
>
>
> x = 2; v = HoldForm[x^2 + 4*x + 4];
>
> In[3]:=
> Block[{x}, HoldForm[Evaluate[Factor[ReleaseHold[v]]]]]
>
>
> HoldForm[(x + 2)^2]
>
> Andrzej Kozlowski
>
>


This is even simpler:


x = 2; v = HoldForm[x^2 + 4*x + 4];


Block[{x, HoldForm}, Factor /@ v]


HoldForm[(x + 2)^2]

Andrzej Kozlowski


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