## 1162 Reputation

12 years, 158 days
East Grinstead, United Kingdom

## Selecl Remove from a set...

Maple 2024

How do I get the susset that contains unknowns on the rhs of the elements?

 > restart
 >
 > # I need this subset {a=1/sqrt(2+A), b=6*sqrt(4+N),  d=5*H}
 >
 > C:={a=1/sqrt(2+A),b=6*sqrt(4+N) ,c=sqrt(7),d=5*H,,e=-12,f=-96}
 (1)
 > selectremove(has,indets(rhs~(C)),C)
 (2)
 > selectremove(has,lhs~(C)=indets(rhs~(C)),C)
 (3)

## eval{recurse] Vs simplify with Side rela...

Maple 2024

This question is as much an observation of somthing I accidently stumbled across. I was using eval[recurse] to evaluate expressions reduced with LargeExpressions. I found eval['recurse'](eval['recurse']([Expr1 , Expr2] , [Q=.. Q1=.....])[]) to be better than simplify(eval['recurse']([Expr1 , Expr2] , [Q=.. Q1=.....])[]).

I only realised what was happening  when I put the below together. Then I could see the wood from the trees.

It would be interesting to know why.

 > restart
 >
 > Pt:=[[(sqrt(2*sqrt(Q[2]) + 2*Q[10])*sqrt(Q[6])*(t^2 + 1)/(sqrt(sqrt(Q[2])/(4*a*c - b^2)^2)*sqrt((2*sqrt(Q[2])*a*c^2*e^2 + 2*sqrt(Q[2])*b^2*c^2*f - 8*sqrt(Q[2])*a^3*c*f + 2*sqrt(Q[2])*a^2*b^2*f + 16*sqrt(Q[2])*a^2*c^2*f + 2*sqrt(Q[2])*a^2*c*d^2 - 4*sqrt(Q[2])*a^2*c*e^2 - 8*sqrt(Q[2])*a*c^3*f - 4*sqrt(Q[2])*a*c^2*d^2 + 2*sqrt(Q[2])*a^3*e^2 + 2*sqrt(Q[2])*c^3*d^2 - 2*sqrt(Q[2])*b*c^2*d*e + 4*sqrt(Q[2])*a*b*c*d*e - 2*sqrt(Q[2])*a^2*b*d*e - 4*sqrt(Q[2])*a*b^2*c*f + sqrt(Q[2])*sqrt(2*sqrt(Q[2]) + 2*Q[10])*sqrt(2*sqrt(Q[2]) - 2*Q[10])*Q[7] - 2*Q[11])*signum((sqrt(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2*Q[10])*sqrt(2*sqrt(Q[2]) - 2*Q[10])*Q[7] + 8*(-(a - c)^2*sqrt(Q[2])/4 + Q[5]/4)*Q[8])*Q[4])*Q[4])*(t^2 - 1)) - 2*a*e + b*d)/(4*a*c - b^2)], [Q[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, Q[4] = 1/((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), Q[5] = (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)*(a + c), Q[6] = signum((4*a*c*f - a*e^2 - b^2*f + b*d*e - c*d^2)/(4*a*c - b^2))*(4*a*c*f - a*e^2 - b^2*f + b*d*e - c*d^2)/(4*a*c - b^2), Q[7] = csgn((4*a*c*f - a*e^2 - b^2*f + b*d*e - c*d^2)*(b*I + a - c)*I)*b, Q[8] = 4*a*c*f - a*e^2 - b^2*f + b*d*e - c*d^2, Q[9] = csgn((4*a*c*f - a*e^2 - b^2*f + b*d*e - c*d^2)*(b*I + a - c)*I), Q[10] = (a - c)*(4*a*c*f - a*e^2 - b^2*f + b*d*e - c*d^2), Q[11] = (a + c)*(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]]:
 > length(Pt);  # was >27,000
 (1)
 > valsh:=[a = -9, b = -9, c = 16, d = -10, e = 7, f = -36]
 (2)
 > S1:=eval['recurse'](Pt,valsh)[];
 > length(%)
 >
 (3)
 > simplify(S1);# this is  simplify with side retations length(%)
 (4)
 > simplify(%%); length(%)
 (5)
 >
 > S2:=eval['recurse'](eval['recurse'](Pt,valsh)[]);# I find this interesting length(%)
 (6)
 > simplify(S2); # length(%)
 >
 (7)

## Substituting out Radicals and (a*x........

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)

## DataFrame limit equation length displaye...

Maple

This is a follow on from and earlier question on tabulation. Some procdures returs up tp eight values. So using a Table make it easier to see what is what. Sometimes the equations returned are very long. Is there a way to truncate what is display in the table using something along the lines of term elision? Say the 1st 300 chatacters for example?

Edit: Corrected an error in the worksheet.

 > restart
 > QQFProj := proc(q12::algebraic, q23::algebraic,                 q34::algebraic, q14::algebraic,                   prnt::boolean:=true) #{columns:=[QQFproj,Q13proj,Q24proj]}   description "Projective quadruple quad formula and intermediate 13 and 24 quads. Useful for cyclic quadrilaterals";   local qqf,q13,q24, sub1,sub2,sub3, R,values,DF,lens;   uses   DocumentTools;   sub1:= (q12 + q23 + q34 + q14)^2 - 2*(q12^2 + q23^2 + q34^2 + q14^2) ;   sub2:=-4*(q12*q23*q34+q12*q23*q14+q12*q34*q14+q23*q34*q14)+8*q12*q23*q34*q14;   sub3:=64*q12*q23*q34*q14*(1-q12)*(1-q23)*(1-q34)*(1-q14);   qqf:=((sub1+sub2)^2=sub3);   q13:=((q12-q23)^2-(q34-q14)^2)/(2*(q12+q23-q34-q14-2*q12*q23+2*q34*q14));#check this   q24:=((q23-q34)^2-(q12-q14)^2)/(2*(q23+q34-q12-q14-2*q23*q34+2*q12*q14));#check this   if prnt then       values:=;    DF:=DataFrame(, columns=[`"Values Equations"`],rows=[`#1  QQF`,`#2  Q13`,`#3  Q24`]);    lens := [4 +8* max(op(length~(RowLabels(DF)))),4+ min(max( 10*(length~(values))),1000)];#op(length~(ColumnLabels(DF)0)    Tabulate(DF,width=add(lens),widthmode = pixels,weights = lens);   return qqf,q13,q24   end if;   return qqf,q13,q24 end proc:
 > q12:=1/2:q23:=9/10:q34:=25/26:q41:=9/130:#Cyclic quadrilateral q12:=sqrt(17+a)/2:q23:=expand(r^2+t^2)^2/10:q34:=expand((a+b+c)^4/26):q41:=sqrt(17+b)/130:
 > Q:=QQFProj(q12,q23,q34,q41,true):
 > #Q[1]
 > #(Q[2])
 > #Q[3]
 > length(Q[1])
 (1)
 > length(Q[2])
 (2)
 > length(Q[3])
 (3)

## ReScaliing a projective vector...

Maple 2024

I want to rescale a projective vector. Have been using gcd on the numerators and denominators. This works in simple situations. It doesn;t work well here, admitadely the points have been just made up for the question.  Square roots seem to make it mal-preform. I run into a lot of squate roots in symbolic situations. What would be a better way? I have been wondering if frontend would help?

 > restart
 > Prntmsg::boolean:=true; Normalise_Projective_Point:=1; ReScl::boolean:=true;
 (1)
 >
 > ProjLP:=overload([       proc(A::Vector[row],B::Vector[row],prnt::boolean:=Prntmsg)       description "2 projective points to create a projective line vector";       option overload;       local Vp ,gcdn,gcdd,vp ;       uses LinearAlgebra;               Vp:=CrossProduct(A,B)^%T;#print("2nd ",Vp);       if ReScl then          gcdn := gcd(gcd(numer(Vp[1]),numer(Vp[2])), numer(Vp[3]));          gcdd := gcd(gcd(denom(Vp[1]),denom(Vp[2])), denom(Vp[3]));          Vp:=simplify(Vp*gcdd/gcdn);       end if;       if Prntmsg then          print("Line vector from two projective points. " );       end if;       return Vp       end proc,       proc(A::Vector[column],B::Vector[column],prnt::boolean:=Prntmsg)       description "2 lines to get intersection projective point";       option overload;       uses LinearAlgebra;       local  Vp;            Vp:=CrossProduct(A,B)^%T;                   if Vp[3]<>0 and Normalise_Projective_Point<>0 then            Vp:=Vp/Vp[3];       end if;       if Prntmsg then            print("Meet of two Lines ");       end if;       return Vp    end proc       ]);
 >
 (2)
 > #maplemint(ProjLP)
 > pt1:=: pt2:=: pt3:=: pt4:=:
 >
 > l1:=ProjLP(pt1,pt2)
 (3)
 > l2:=ProjLP(pt3,pt4)
 (4)
 > l3:=ProjLP(pt1,pt4)
 (5)
 > l4:=ProjLP(pt2,pt4)
 (6)
 > pl1l2:=simplify(ProjLP(l1,l2))
 (7)
 > pl2l3:=simplify(ProjLP(l2,l3))
 (8)
 > (ProjLP(pl1l2,pl2l3)); length(%)
 (9)
 > ReScl:=false
 (10)
 > # doing nothing seems to work better here than rescaling
 > (ProjLP(pl1l2,pl2l3)); length(%)
 (11)
 >