MathGroup Archive 2005

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

Search the Archive

Re: question about HoldForm


Hi,
 
> 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.

This should do what you want:

x = 2;
expr = HoldForm[x^2 + 4x + 4];

Block[{x}, HoldForm @@ {(Factor @@ expr)}]

Anyway it is a good idead to not set symbols you want to use as parameters
in expressions to values in the first place. You an then insert values
whenever needed with ReplaceAll ( /. ):

expr=x^2 + 4x + 4
Factor[expr]
expr /. { x -> 2 }


albert


  • Prev by Date: Re: what is wrong with this plot?
  • Next by Date: Re: what is wrong with this plot?
  • Previous by thread: Re: Re: question about HoldForm
  • Next by thread: Re: question about HoldForm