# Question:Substituting out Radicals and (a*x..........) types

## Question:Substituting out Radicals and (a*x..........) types

Maple 2024

I have some long expressions that would be more readable if common sections were substituted out. There are many sets of radicals often stacked inside each other.  The other one is (a*x..........) I see repeated in some other expressions. indets is good, but is there a way to use it to select  (a*x..........) types
At these eexpressions are returned from procdures would probably put them in an array/table with their substitution components.
I dont need to substitute everything. What I have done below is reasonable for reading and seeing the structure.

What would be a good approact here?

 > restart
 >
 (1)
 > vals:=[a=18,b=21,c=7,d=-29,e=-37,f=-56]
 (2)
 > vars[1]:=x:vars[2]:=y:
 > eqn:= 8*(2*((a^2-2*a*c+b^2+c^2)*(4*a*c*f-a*e^2-b^2*f+b*d*e-c*d^2)^2)^(1                 /2)+(-8*a*f+2*d^2)*c^2+(8*a^2*f-2*a*d^2+2*a*e^2+2*b^2*f-2*b*d*e)*c-2*a^2*e^2-2*                 a*b^2*f+2*a*b*d*e)^(1/2)*(a*c-1/4*b^2)/(4*a*c-b^2)^2*(vars[1]-(1/4*b*e-1/2*c*d)/(a*c-\                 1/4*b^2))-8*csgn((4*a*c*f-a*e^2-b^2*f+b*d*e-c*d^2)*(Complex(1)*a+Complex(-1)*c-                 b))*(a*c-1/4*b^2)*(2*((a^2-2*a*c+b^2+c^2)*(4*a*c*f-a*e^2-b^2*f+b*d*e-c*d^2)^2)^                 (1/2)+(8*a*f-2*d^2)*c^2+(-8*a^2*f+2*a*d^2-2*a*e^2-2*b^2*f+2*b*d*e)*c+2*a^2*e^2+                 2*a*b^2*f-2*a*b*d*e)^(1/2)/(4*a*c-b^2)^2*(vars[2]-(-1/2*a*e+1/4*b*d)/(a*c-1/4*b^2))
 (3)
 > length(eqn)
 (4)
 > simplify(eval(eqn,vals))
 (5)
 > indets(eqn)
 (6)
 > Subs:=[((a^2 - 2*a*c + b^2 + c^2)*(4*a*c*f - a*e^2 - b^2*f + b*d*e - c*d^2)^2)=A^2,          (-8*a*f + 2*d^2)*c^2 + (8*a^2*f - 2*a*d^2 + 2*a*e^2 + 2*b^2*f - 2*b*d*e)*c - 2*a^2*e^2 - 2*a*b^2*f + 2*a*b*d*e=B^2,            f*b^3 - b^2*d*e - (-(-4*c*f + e^2)*a - c*d^2)*b=C]:
 > eqn1:=simplify(eqn,Subs)
 (7)
 > Subsnumeric:=eval(Subs,vals)
 (8)
 > simplify(eval(eqn1,[(rhs=lhs)~(Subsnumeric)[],vals[] ]))
 (9)