Ronan

1311 Reputation

14 Badges

12 years, 316 days
East Grinstead, United Kingdom

MaplePrimes Activity


These are questions asked by Ronan

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}

{a = 1/(2+A)^(1/2), b = 6*(4+N)^(1/2), c = 7^(1/2), d = 5*H, e = -12, f = -96}

(1)

selectremove(has,indets(rhs~(C)),C)

{}, {A, H, K, N, 1/(2+A)^(1/2), (4+N)^(1/2)}

(2)

selectremove(has,lhs~(C)=indets(rhs~(C)),C)

() = (), {a, b, c, d, e} = {H, K, N, (4+N)^(1/2)}

(3)
 

 

Download 2024-06-05_Q_Select_Remove_indet_elements.mw

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*s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rt(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(Q[2])*sqrt(2*sqrt(Q[2]) + 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

5002

(1)

valsh:=[a = -9, b = -9, c = 16, d = -10, e = 7, f = -36]

[a = -9, b = -9, c = 16, d = -10, e = 7, f = -36]

(2)

S1:=eval['recurse'](Pt,valsh)[];

length(%)

 

[-(1/657)*(2*Q[2]^(1/2)+2*Q[10])^(1/2)*Q[6]^(1/2)*(t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(1/2)*(2*Q[2]^(1/2)+2*Q[10])^(1/2)*(2*Q[2]^(1/2)-2*Q[10])^(1/2)*Q[7]+2*Q[11])*signum((Q[2]^(1/2)*(2*Q[2]^(1/2)+2*Q[10])^(1/2)*(2*Q[2]^(1/2)-2*Q[10])^(1/2)*Q[7]+8*(-(625/4)*Q[2]^(1/2)+(1/4)*Q[5])*Q[8])*Q[4])*Q[4])^(1/2)*(t^2-1))-24/73], [Q[2] = 377479229074, Q[4] = 1/377479229074, Q[5] = 114273866, Q[6] = 23123/657, Q[7] = -9, Q[8] = 23123, Q[9] = 1, Q[10] = -578075, Q[11] = 2642354603518]

 

2074

(3)

simplify(S1);# this is  simplify with side retations
length(%)

[-(257/248003853501618)*377479229074^(3/4)*((377479229074^(1/4)*(t^2-1)*((9/377479229074)*377479229074^(1/2)*(2*377479229074^(1/2)-1156150)^(1/2)*(2*377479229074^(1/2)+1156150)^(1/2)+(625/8162419)*377479229074^(1/2)+14)^(1/2)+(1/168849)*657^(1/2)*23123^(1/2)*431649^(1/2)*(2*377479229074^(1/2)-1156150)^(1/2)*(t^2+1))*((9/377479229074)*377479229074^(1/2)*(2*377479229074^(1/2)-1156150)^(1/2)*(2*377479229074^(1/2)+1156150)^(1/2)+(625/8162419)*377479229074^(1/2)-14)^(1/2)+(2/168849)*23123^(1/2)*657^(1/2)*431649^(1/2)*((9/377479229074)*377479229074^(1/2)*(2*377479229074^(1/2)-1156150)^(1/2)*(2*377479229074^(1/2)+1156150)^(1/2)+(625/8162419)*377479229074^(1/2)+14)^(1/2)*(2*377479229074^(1/2)+1156150)^(1/2)*t)/(((9/377479229074)*377479229074^(1/2)*(2*377479229074^(1/2)-1156150)^(1/2)*(2*377479229074^(1/2)+1156150)^(1/2)+(625/8162419)*377479229074^(1/2)-14)^(1/2)*((9/377479229074)*377479229074^(1/2)*(2*377479229074^(1/2)-1156150)^(1/2)*(2*377479229074^(1/2)+1156150)^(1/2)+(625/8162419)*377479229074^(1/2)+14)^(1/2)*(t-1)*(t+1)), -(12/13777991861201)*377479229074^(3/4)*((377479229074^(1/4)*(t^2-1)*((9/377479229074)*377479229074^(1/2)*(2*377479229074^(1/2)-1156150)^(1/2)*(2*377479229074^(1/2)+1156150)^(1/2)+(625/8162419)*377479229074^(1/2)+14)^(1/2)-(1/141912)*657^(1/2)*23123^(1/2)*431649^(1/2)*(2*377479229074^(1/2)+1156150)^(1/2)*(t^2+1))*((9/377479229074)*377479229074^(1/2)*(2*377479229074^(1/2)-1156150)^(1/2)*(2*377479229074^(1/2)+1156150)^(1/2)+(625/8162419)*377479229074^(1/2)-14)^(1/2)+(1/70956)*(2*377479229074^(1/2)-1156150)^(1/2)*t*23123^(1/2)*657^(1/2)*431649^(1/2)*((9/377479229074)*377479229074^(1/2)*(2*377479229074^(1/2)-1156150)^(1/2)*(2*377479229074^(1/2)+1156150)^(1/2)+(625/8162419)*377479229074^(1/2)+14)^(1/2))/(((9/377479229074)*377479229074^(1/2)*(2*377479229074^(1/2)-1156150)^(1/2)*(2*377479229074^(1/2)+1156150)^(1/2)+(625/8162419)*377479229074^(1/2)-14)^(1/2)*((9/377479229074)*377479229074^(1/2)*(2*377479229074^(1/2)-1156150)^(1/2)*(2*377479229074^(1/2)+1156150)^(1/2)+(625/8162419)*377479229074^(1/2)+14)^(1/2)*(t-1)*(t+1))]

 

2316

(4)

simplify(%%);
length(%)

[-(1/71716466988)*(-2471*706^(1/2)+249218)^(1/2)*(2471*706^(1/2)+249218)^(1/2)*((73^(1/2)*(t^2+1)*(46246*706^(1/2)-1156150)^(1/2)+(257/3)*706^(1/4)*(14+2*706^(1/2))^(1/2)*t^2)*(-14+2*706^(1/2))^(1/2)+2*73^(1/2)*(t*(46246*706^(1/2)+1156150)^(1/2)*(14+2*706^(1/2))^(1/2)-257*706^(1/4)))*706^(1/4)/(t^2-1), (1/71716466988)*(-2471*706^(1/2)+249218)^(1/2)*((73^(1/2)*(t^2+1)*(46246*706^(1/2)+1156150)^(1/2)-72*706^(1/4)*(14+2*706^(1/2))^(1/2)*t^2)*(-14+2*706^(1/2))^(1/2)-2*73^(1/2)*((14+2*706^(1/2))^(1/2)*(46246*706^(1/2)-1156150)^(1/2)*t-216*706^(1/4)))*(2471*706^(1/2)+249218)^(1/2)*706^(1/4)/(t^2-1)]

 

744

(5)

 

S2:=eval['recurse'](eval['recurse'](Pt,valsh)[]);# I find this interesting
length(%)

[-(1/162938531750563026)*(2*377479229074^(1/2)-1156150)^(1/2)*23123^(1/2)*657^(1/2)*(t^2+1)*431649^(1/2)*377479229074^(3/4)/(((9/377479229074)*377479229074^(1/2)*(2*377479229074^(1/2)-1156150)^(1/2)*(2*377479229074^(1/2)+1156150)^(1/2)+(625/8162419)*377479229074^(1/2)+14)^(1/2)*(t^2-1))-(1/81469265875281513)*(2*377479229074^(1/2)+1156150)^(1/2)*t*23123^(1/2)*657^(1/2)*431649^(1/2)*377479229074^(3/4)/(((9/377479229074)*377479229074^(1/2)*(2*377479229074^(1/2)-1156150)^(1/2)*(2*377479229074^(1/2)+1156150)^(1/2)+(625/8162419)*377479229074^(1/2)-14)^(1/2)*(t^2-1))-257/657, (1/162938531750563026)*(2*377479229074^(1/2)+1156150)^(1/2)*23123^(1/2)*657^(1/2)*(t^2+1)*431649^(1/2)*377479229074^(3/4)/(((9/377479229074)*377479229074^(1/2)*(2*377479229074^(1/2)-1156150)^(1/2)*(2*377479229074^(1/2)+1156150)^(1/2)+(625/8162419)*377479229074^(1/2)+14)^(1/2)*(t^2-1))-(1/81469265875281513)*(2*377479229074^(1/2)-1156150)^(1/2)*t*23123^(1/2)*657^(1/2)*431649^(1/2)*377479229074^(3/4)/(((9/377479229074)*377479229074^(1/2)*(2*377479229074^(1/2)-1156150)^(1/2)*(2*377479229074^(1/2)+1156150)^(1/2)+(625/8162419)*377479229074^(1/2)-14)^(1/2)*(t^2-1))-24/73]

 

1283

(6)

simplify(S2); #
length(%)

 

[-(1/406325592)*(14+2*706^(1/2))^(1/2)*(((181442/3)*(14+2*706^(1/2))^(1/2)*t^2+706^(3/4)*73^(1/2)*(46246*706^(1/2)-1156150)^(1/2)*(t^2+1))*(-14+2*706^(1/2))^(1/2)+2*(46246*706^(1/2)+1156150)^(1/2)*73^(1/2)*706^(3/4)*(14+2*706^(1/2))^(1/2)*t-362884*73^(1/2))*(-14+2*706^(1/2))^(1/2)/(t^2-1), (14+2*706^(1/2))^(1/2)*((-2*706^(3/4)*73^(1/2)*(46246*706^(1/2)-1156150)^(1/2)*t-50832*(-14+2*706^(1/2))^(1/2)*t^2)*(14+2*706^(1/2))^(1/2)+(304992+(t^2+1)*(46246*706^(1/2)+1156150)^(1/2)*706^(3/4)*(-14+2*706^(1/2))^(1/2))*73^(1/2))*(-14+2*706^(1/2))^(1/2)/(406325592*t^2-406325592)]

 

705

(7)
 

 

Download 2024-05-31_Eval_Recurse_vs_Simplify_Side_Rels.mw

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

 

18*x^2+21*x*y+7*y^2-29*x-37*y-56

(1)

vals:=[a=18,b=21,c=7,d=-29,e=-37,f=-56]

[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))

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)*(x-((1/4)*b*e-(1/2)*c*d)/(a*c-(1/4)*b^2))/(4*a*c-b^2)^2-8*csgn((4*a*c*f-a*e^2-b^2*f+b*d*e-c*d^2)*(I*a-I*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)*(y-(-(1/2)*a*e+(1/4)*b*d)/(a*c-(1/4)*b^2))/(4*a*c-b^2)^2

(3)

length(eqn)

962

(4)

simplify(eval(eqn,vals))

(4/567)*(9*x+53)*(-63382+5762*562^(1/2))^(1/2)+(4/1323)*(-21*y+241)*(63382+5762*562^(1/2))^(1/2)

(5)

indets(eqn)

{a, b, c, d, e, f, x, y, ((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), (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), (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), csgn((4*a*c*f-a*e^2-b^2*f+b*d*e-c*d^2)*(I*a-I*c-b))}

(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)

(-8*csgn(C+((1/2)*I)*B^2)*(-(1/4)*y*b^2-(1/4)*b*d+a*(y*c+(1/2)*e))*(-B^2+2*(A^2)^(1/2))^(1/2)+8*(B^2+2*(A^2)^(1/2))^(1/2)*(-(1/4)*b^2*x-(1/4)*b*e+c*(a*x+(1/2)*d)))/(4*a*c-b^2)^2

(7)

Subsnumeric:=eval(Subs,vals)

[74635047712 = A^2, -253528 = B^2, 242004 = C]

(8)

simplify(eval(eqn1,[(rhs=lhs)~(Subsnumeric)[],vals[] ]))

(4/567)*(9*x+53)*(-63382+5762*562^(1/2))^(1/2)+(4/1323)*(241-21*y)*(63382+5762*562^(1/2))^(1/2)

(9)
 

 

Download 2024-05-27_Q_Pick_Apart_an_Expression.mw

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:=<qqf,q13,q24>;
   DF:=DataFrame(<values>, 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])

2669

(1)

length(Q[2])

1024

(2)

length(Q[3])

1024

(3)
 

 

Download 2024-05-14_Q_Data_Table_Limit_Equation_lentgh.mw

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;

true

 

1

 

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
     
]);

 

proc () option overload; [proc (A::(Vector[row]), B::(Vector[row]), prnt::boolean := Prntmsg) local Vp, gcdn, gcdd, vp; option overload; description "2 projective points to create a projective line vector"; Vp := LinearAlgebra:-CrossProduct(A, B)^%T; 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) local Vp; option overload; description "2 lines to get intersection projective point"; Vp := LinearAlgebra:-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] end proc

(2)

#maplemint(ProjLP)

pt1:=<a|sqrt(b^2+c^2)|1>:
pt2:=<c|sqrt(b^2+a^2)|1>:
pt3:=<f^2/sqrt(a^2+b^2)|f^2/sqrt(c^2+b^2)+sqrt(a^2+b^2)|1>:
pt4:=<b^2/sqrt(a^2+b^2)|f^2/sqrt(c^2+b^2)-sqrt(a^2+b^2)|1>:

 

l1:=ProjLP(pt1,pt2)

"Line vector from two projective points. "

 

Vector[column](%id = 36893490491002736020)

(3)

l2:=ProjLP(pt3,pt4)

"Line vector from two projective points. "

 

Vector[column](%id = 36893490491002712420)

(4)

l3:=ProjLP(pt1,pt4)

"Line vector from two projective points. "

 

Vector[column](%id = 36893490491064062908)

(5)

l4:=ProjLP(pt2,pt4)

"Line vector from two projective points. "

 

Vector[column](%id = 36893490491064037372)

(6)

pl1l2:=simplify(ProjLP(l1,l2))

"Meet of two Lines "

 

Vector[row](%id = 36893490491002741932)

(7)

pl2l3:=simplify(ProjLP(l2,l3))

"Meet of two Lines "

 

Vector[row](%id = 36893490491113907252)

(8)

(ProjLP(pl1l2,pl2l3));
length(%)

"Line vector from two projective points. "

 

Vector[column](%id = 36893490491113907972)

 

6223

(9)

ReScl:=false

false

(10)

# doing nothing seems to work better here than rescaling

(ProjLP(pl1l2,pl2l3));
length(%)

"Line vector from two projective points. "

 

Vector[column](%id = 36893490491125667468)

 

2796

(11)

 


 

Download 2024-05-09_Q_Rescale_projective_vector.mw

5 6 7 8 9 10 11 Last Page 7 of 35