Re: Transforming (x-y)^2 into (x-y)*(x-y) ?
- To: mathgroup at smc.vnet.net
- Subject: [mg22599] Re: Transforming (x-y)^2 into (x-y)*(x-y) ?
- From: Harald Giese <giese at ifm.uni-hamburg.de>
- Date: Mon, 13 Mar 2000 11:03:18 -0500 (EST)
- Organization: Institut fuer Meereskunde, Universitaet Hamburg
- References: <8aek8k$3de@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Axel Kowald wrote: > > I use Mathematica 4 to generate some equations which I export as C code (CForm). > > I would like to force Mathematica to export expressions like (x-y)^2 as > (x-y)*(x-y), but I don't know how to achieve this in Mathematica. I tried > several combinations of Hold (and its variants) and t_^2 -> t*t, but so > far I had no luck. > Hi Axel, You need to insert Hold: In[13]:=(x - y)^2 /. t_^2 -> Hold[t*t] Out[13]=Hold[(x - y) (x - y)] Regards, Harald -- Harald Giese Email: giese at dkrz.de Phone: +49 (0)40 42838 5796; Fax: +49 (0)40 5605724 Institut fuer Meereskunde der Universitaet Hamburg (Institute of Oceanography of the University of Hamburg) Troplowitzstrasse 7, D-22529 Hamburg