       • To: mathgroup at smc.vnet.net
• Subject: [mg35720] More than one radical
• From: "Julio Vera" <jvera at adinet.com.uy>
• Date: Sat, 27 Jul 2002 06:43:28 -0400 (EDT)
• Sender: owner-wri-mathgroup at wolfram.com

```Hello,

I have a list of expressions. Some of them include radicals. When the
radical exponent is even, and the expression inside the radical is not a
number, the corresponding element will not be defined if the expression
inside the radical is negative. In such cases, I want to replace the
original element by a list of elements which includes the element
itself, and the expressions contained in such radicals.

I found a way to do this for the parcial case in which there is only one
radical of that kind in an element. I tried to do it using ReplaceAll,
but did not succeed. So I used this LONG way.

In[] v1 = {Sqrt*x + 4, 5*x + x^2, 1 + Sqrt[2 + 5*x], (6*x -
1)^(1/5) + 2,

3*x - (2*x - 1)^(1/6), (2 + x^3)^(1/8)}

Out[]  {4 + Sqrt*x, 5*x + x^2, 1 + Sqrt[2 + 5*x], 2 + (-1 +
6*x)^(1/5),

3*x - (-1 + 2*x)^(1/6), (2 + x^3)^(1/8)}

In[] =
p1=Position[v1,Power[a_,Rational[1,b_]]/;EvenQ[b]/;NumberQ[a]==True]

Out[] {{3,2},{5,2,2},{6}}

In[] p1f=p1/.{a_Integer,___}=AEa

Out[] {3,5,6}

In[] vv1[{a__}]:=v1[[a]]

In[] =
new1=Table[{v1[[p1f[[i]]]],vv1[p1[[i]]]},{i,Length[p1]}]/.{a_,Power[b_,
Rational[1,_]]}=AE{a,b}

Out[] {{1 + Sqrt[2 + 5*x], 2 + 5*x}, {3*x - (-1 + 2*x)^(1/6), -1 + 2*x},

{(2 + x^3)^(1/8), 2 + x^3}}

In[] s1=ReplacePart[v1,new1,Split[p1f],Split[Range[Length[p1]]]]

Out[] {4 + Sqrt*x, 5*x + x^2, {1 + Sqrt[2 + 5*x], 2 + 5*x}, 2 + (-1 +
6*x)^(1/5),

{3*x - (-1 + 2*x)^(1/6), -1 + 2*x}, {(2 + x^3)^(1/8), 2 + x^3}}

When more than one of these situation occur in an element, this method
does not work.

In[] v3 = {Sqrt*x + 4, 5*x + x^2, 1 + Sqrt[2 - (x^3 - 3*x -
8)^(1/4) + 5*x],

(6*x - 1)^(1/5) + 2, 3*x - (2*x - 1)^(1/6),

(2*x^(1/4) + x^3*(4*x^2 - 3)^(1/10))^(1/8)}

{4 + Sqrt*x, 5*x + x^2, 1 + Sqrt[2 + 5*x - (-8 - 3*x + x^3)^(1/4)],

2 + (-1 + 6*x)^(1/5), 3*x - (-1 + 2*x)^(1/6),

(2*x^(1/4) + x^3*(-3 + 4*x^2)^(1/10))^(1/8)}

What I want to get is

In[] sol3 = {Sqrt*x + 4, 5*x + x^2, {1 + Sqrt[2 - (x^3 - 3*x -
8)^(1/4) + 5*x],

2 - (x^3 - 3*x - 8)^(1/4) + 5*x, x^3 - 3*x - 8}, (6*x - 1)^(1/5) + 2,

{3*x - (2*x - 1)^(1/6), 2*x - 1}, {(2*x^(1/4) + x^3*(4*x^2 -
3)^(1/10))^(1/8),

2*x^(1/4) + x^3*(4*x^2 - 3)^(1/10), x, 4*x^2 - 3}}

I don=B4t see how I can use ReplacePart in this situation, because the
new elements will have different lengths.

In[] =
p3=Position[v3,Power[a_,Rational[1,b_]]/;EvenQ[b]/;NumberQ[a]==True]

Out[] {{3,2,1,3,2},{3,2},{5,2,2},{6,1,1,2},{6,1,2,2},{6}}

I could do it step by step. But, since I do not know in advance the
number of occurrences, I would have to change the formulas every time
the input changes.