RE: Simplify
- To: mathgroup at smc.vnet.net
- Subject: [mg14793] RE: [mg14780] Simplify
- From: "Ersek, Ted R" <ErsekTR at navair.navy.mil>
- Date: Wed, 18 Nov 1998 01:28:55 -0500
- Sender: owner-wri-mathgroup at wolfram.com
Jurgen Tischer wrote: > >Could someone tell me please how to simplify the following formula? > >(-7253*2^(1 + 2*n)*5^n - 523*4^n*5^(1 + n) + 17121*20^n + > 130321*20^n*n^4)/130321 > >To my surprise when I changed by hand (with two rules) the powers of 2, >5 and so on to powers of 20, Mathematica changed them back to this >form. > > It seems you have to use HoldForm in the rules as I do below. In[1]:= Clear[n,expr] In[2]:= expr=(-7253*2^(1 + 2*n)*5^n - 523*4^n*5^(1 + n) + 17121*20^n + 130321*20^n*n^4)/130321; In[3]:= expr/.{ c_*4^n*5^(1+n):>5*c*HoldForm[20^n], c_*2^(1+2 n)5^n:>2*c*HoldForm[20^n], 20^n:>HoldForm[20^n]} Out[3]= n^4 20^n You need to use HoldForm because the kernel wants to be clever and undo your rules. Try evaluating the cells below. I would classify this as a bug. In[4]:= 4 20^n Out[4]= 4^(1 + n)*5^n (* Arrrgh! *) In[5]:= 5 20^n Out[5]= 4^n*5^(1 + n) (* Arrrgh! *) Cheers, Ted Ersek