another bug...

• To: mathgroup at smc.vnet.net
• Subject: [mg47651] another bug...
• From: Enrique Zeleny <ezeleny at fismat1.fcfm.buap.mx>
• Date: Tue, 20 Apr 2004 03:19:05 -0400 (EDT)
• Sender: owner-wri-mathgroup at wolfram.com

```Hi,

In[1]:= expr = FunctionExpand[Cos[Pi/22]];

The next input doesn't work in 5.0, the expression that I want to replace
by a appears many times in expr

In[2]:= expr /. (1/2)*(-1 + Sqrt[5]) + I*Sqrt[2 - (1/2)*(-1 - Sqrt[5])] -> a

only works doing this

In[3]:= expr //. (1/2)*(-1 + Sqrt[5]) + I*Sqrt[2 - (1/2)*(m_)] -> a

If you look at FullForm

In[4]:= FullForm[(1/2)*(-1 + Sqrt[5]) + I*Sqrt[2 - (1/2)*(-1 - Sqrt[5])]]

Out[4]:= Plus[Times[Rational[1, 2], Plus[-1, Power[5, Rational[1, 2]]]],
Times[Complex[0, 1],
Power[Plus[2, Times[Rational[1, 2], Plus[1, Power[5, Rational[1, 2]]]]],
Rational[1, 2]]]]

but if you copy and paste the result of expr and you use //.
(1/2)*(Sqrt[5] - 1) + I*Sqrt[(1/2)*(Sqrt[5] + 1) + 2] -> a to replace works well!!!

In Version 4.1 only this works well (but not in 5.0), but the expression
that appears many times is written with +'s

In[2]:= expr //. (1/2)*(-1 + Sqrt[5]) + I*Sqrt[2 + (1/2)*(1 + Sqrt[5])] ->
a

If you copy and paste the result of expr and you use only /. instead of
//. to replace (1/2)*(-1 + Sqrt[5]) + I*Sqrt[2 + (1/2)*(1 + Sqrt[5])] ->a
works fine!!!

Clearly the problem is recognizing

- (1/2)*(-1 - Sqrt[5])

Enrique Zeleny