Ronan

1207 Reputation

14 Badges

12 years, 217 days
East Grinstead, United Kingdom

MaplePrimes Activity


These are questions asked by Ronan

This problem began about 3 nights ago.

When I load the subpackage UHG to RationalTrigonometry no warning.

When I rerun the worksheet warnings appear. If I put in arestart and reload the packages no warning. The problem only occurs with the sub packageUHG. The RationalTrigonometry package also has a few aliases.

Screen shot of one rerun  then added restart.

I am trying to check if the inputs are a pair of row or column matrices. How should I do that? I have tried type but no success.


 

restart

 

TestDim:=proc(p1::{Matrix(1,3),Matrix(3,1)},p2::{Matrix(1,3),Matrix(3,1)},prnt::boolean:=Prntmsg)
description "Midpoints, Bilines";
uses RationalTrigonometry;
local x1, y1, z1, x2, y2, z2,m1,m2,xpsn , ypsn,zpsn ;

if [Dimension(p1)]=[1,3] and [Dimension(p2)]=[1,3] then  
      m1:= Vector[row](3);
      m2:= Vector[row](3);
      print([1,3]);
  elif [Dimension(p1)]=[3,1]and [Dimension(p2)]=[3,1] then
      m1:= Vector[column](3);
      m2:= Vector[column](3);
       print([3,1]);
 else
      ERROR(p1,p2, `must both be row or column matrices`);
end if;
end proc

proc (p1::{Matrix(1, 3), Matrix(3, 1)}, p2::{Matrix(1, 3), Matrix(3, 1)}, prnt::boolean := Prntmsg) local x1, y1, z1, x2, y2, z2, m1, m2, xpsn, ypsn, zpsn; description "Midpoints, Bilines"; if [Dimension(p1)] = [1, 3] and [Dimension(p2)] = [1, 3] then m1 := Vector[row](3); m2 := Vector[row](3); print([1, 3]) elif [Dimension(p1)] = [3, 1] and [Dimension(p2)] = [3, 1] then m1 := Vector[column](3); m2 := Vector[column](3); print([3, 1]) end if end proc

(1)

f:=<<a|b|c>>;
g:=<<d|e|h>>

f := Matrix(1, 3, {(1, 1) = a, (1, 2) = b, (1, 3) = c})

 

g := Matrix(1, 3, {(1, 1) = d, (1, 2) = e, (1, 3) = h})

(2)

TestDim(f,g)

 


 

Download 2024-08-18_Test_Matrix_Dimension.mw

I need to seperate vectors  from projective geometry vectors in my package. I am experimenting with using row and column matrices for projective points and lines reppresentation. Two approaches are use here. The 1st converts the Matrices to Vectors and back in the procedure. I dont like that way. The 2nd approach, I worked out the equivalent of CrossProduct and DotProduct for the row and column matrices. That I think is better.

1st Question are there any other approaches worth looking at?Is there something in the Physics package that could be of use?

2nd Qusetion could a new data type be made with the properties of a vector that could be displayed differently.?

Say, for a point [ x : y : z ] and a line < x : y : z >, because projecive quantities as basically ratios..


 

restart

with(LinearAlgebra):

 

#

projcross:=overload([

proc(A::Matrix(1,3),B::Matrix(1,3))
option overload;
description "join of points";
local a:=convert(A,Vector[row]),b:=convert(B,Vector[row]);
uses LinearAlgebra;
print("line thro' points");
convert((a &x b)^%T,Matrix);
end proc,

proc(A::Matrix(3,1),B::Matrix(3,1))
option overload;
description "meet of lines";
local a:=convert(A,Vector[column]),b:=convert(B,Vector[column]);
uses LinearAlgebra;
print("intersect point");
convert((a &x b)^%T,Matrix);
end proc,

proc(A::{Matrix(1,3),Matrix(3,1)},B::{Matrix(1,3),Matrix(3,1)})
option overload;
description "incidence of point and line";
uses LinearAlgebra;
local a,b;
if type(A,'Matrix'(1,3))and type(B,'Matrix'(3,1)) or type(A,'Matrix'(3,1))and type(B,'Matrix'(1,3))  then #not working
a:=convert(A,Vector[row]);
b:=convert(B,Vector[row]);
end if;
print("if = 0 coincident");
a.b ;
end proc


]):

projcross(<<1|2|4>>,<<3|-5|7>>)

"line thro' points"

 

Matrix([[34], [5], [-11]])

(1)

projcross(<<1,2,4>>,<<3,-5,7>>)

"intersect point"

 

Matrix([[34, 5, -11]])

(2)

projcross(<<1|2|4>>,<<34,5,-11>>)

"if = 0 coincident"

 

0

(3)

projcross(<<34,5,-11>> ,<<3|-5|7>> )

"if = 0 coincident"

 

0

(4)

#This section is to derive a CrossProduct and DotProduct for row and column matrix inputs

M:=<A[1,1]|A[1,2]|A[1,3]> ; #point

M := Vector[row](3, {(1) = A[1, 1], (2) = A[1, 2], (3) = A[1, 3]})

(5)

N:=<B[1,1]|B[1,2]|B[1,3]> ; #point

N := Vector[row](3, {(1) = B[1, 1], (2) = B[1, 2], (3) = B[1, 3]})

(6)

(M &x N)^%T ; #line thro' points

3

(7)

R:=<A[1,1],A[2,1],A[3,1]> ;# line

R := Vector(3, {(1) = A[1, 1], (2) = A[2, 1], (3) = A[3, 1]})

(8)

S:=<B[1,1],B[2,1],B[3,1]> ;# line

S := Vector(3, {(1) = B[1, 1], (2) = B[2, 1], (3) = B[3, 1]})

(9)

(R &x S)^%T  ;# intersect point

[`?`]

(10)

 

T:=<A[1,1]|A[1,2]|A[1,3]>  ;#point

T := Vector[row](3, {(1) = A[1, 1], (2) = A[1, 2], (3) = A[1, 3]})

(11)

U:=<B[1,1],B[2,1],B[3,1]>  ;# line

U := Vector(3, {(1) = B[1, 1], (2) = B[2, 1], (3) = B[3, 1]})

(12)

DotProduct(T,U,conjugate=false) ; #check coincidence of point and line

A[1, 1]*B[1, 1]+A[1, 2]*B[2, 1]+A[1, 3]*B[3, 1]

(13)

V:=<A[1,1],A[2,1],A[3,1]> ;# line

V := Vector(3, {(1) = A[1, 1], (2) = A[2, 1], (3) = A[3, 1]})

(14)

 

W:=<B[1,1]|B[1,2]|B[1,3]> ;#point

W := Vector[row](3, {(1) = B[1, 1], (2) = B[1, 2], (3) = B[1, 3]})

(15)

DotProduct(V,W,conjugate=false)  ; #check coincidence of line and point

A[1, 1]*B[1, 1]+A[2, 1]*B[1, 2]+A[3, 1]*B[1, 3]

(16)

# CrossProduct and DotProduct procedure for matrix inputs

 

ProjCp:=overload([

proc(a::Matrix(1,3),b::Matrix(1,3))
option overload;
description "join of points";
local A:=a,B:=b;
print("line thro' points");
<<A[1, 2]*B[1, 3] - A[1, 3]*B[1, 2],-A[1, 1]*B[1, 3] + A[1, 3]*B[1, 1],A[1, 1]*B[1, 2] - A[1, 2]*B[1, 1]>>;
end proc,

 

proc(a::Matrix(3,1),b::Matrix(3,1))
option overload;
description "meet of lines";
local A:=a,B:=b;
print("intersect point");
<<A[2, 1]*B[3, 1] - A[3, 1]*B[2, 1] | -A[1, 1]*B[3, 1] + A[3, 1]*B[1, 1] | A[1, 1]*B[2, 1] - A[2, 1]*B[1, 1] >>;
end proc,

proc(A::{Matrix(1,3),Matrix(3,1)},B::{Matrix(1,3),Matrix(3,1)})
option overload;
description "incidence of point and line";
local dp;
uses LinearAlgebra;
if type(A,'Matrix'(1,3))and type(B,'Matrix'(3,1))   then
dp:=A[1, 1]*B[1, 1] + A[1, 2]*B[2, 1] + A[1, 3]*B[3, 1];

elif type(A,'Matrix'(3,1))and type(B,'Matrix'(1,3)) then
dp:=A[1, 1]*B[1, 1] + A[2, 1]*B[1, 2] + A[3, 1]*B[1, 3];

end if;
print("if = 0 coincident");
return dp
end proc,

proc(A::{Matrix(1,3),list})
option overload;
description "convert to/from cartesian";
if type(A,'Matrix'(1,3)) and A[1,3]<>0 then
[A[1,1]/A[1,3],A[1,2]/A[1,3]];
elif A::list then
<<A[1]|A[2]|1>>;
end if;
end proc,

proc(A::{Matrix(3,1)},{vars:=[x,y]})
option overload;
description "convert to expression";

A[1,1]*vars[1]+A[2,1]*vars[2]+A[3,1];

end proc
 

]):

p1:=<<1|2|4>>:p2:=<<3|-5|7>>:p3:=a*p1-b*p2:

L1:=<<5,7,-8>>:L2:=<<-1,4,-6>>:

L3:=ProjCp(p1,p2)

"line thro' points"

 

L3 := Matrix(3, 1, {(1, 1) = 34, (2, 1) = 5, (3, 1) = -11})

(17)

ProjCp(L1,L2)

"intersect point"

 

Matrix([[-10, 38, 27]])

(18)

ProjCp(p1,L3)

"if = 0 coincident"

 

0

(19)

ProjCp(L3,p1)

"if = 0 coincident"

 

0

(20)

ProjCp(ProjCp(p1,p2),p3)

"line thro' points"

 

"if = 0 coincident"

 

0

(21)

Cartlist:=ProjCp~([p1,p2,p3])

[[1/4, 1/2], [3/7, -5/7], [(a-3*b)/(4*a-7*b), (2*a+5*b)/(4*a-7*b)]]

(22)

ProjCp~(Cartlist)

[Matrix(1, 3, {(1, 1) = 1/4, (1, 2) = 1/2, (1, 3) = 1}), Matrix(1, 3, {(1, 1) = 3/7, (1, 2) = -5/7, (1, 3) = 1}), Matrix(1, 3, {(1, 1) = (a-3*b)/(4*a-7*b), (1, 2) = (2*a+5*b)/(4*a-7*b), (1, 3) = 1})]

(23)

ProjCp~([L1,L2,L3])

[5*x+7*y-8, -x+4*y-6, 34*x+5*y-11]

(24)

 

 

 

 

 

 

 


 

Download 2024-08-16_Projective_Vectors_as_Matrices.mw

I use a procedure called Isee  to print to screen procedures from my packages.

However if the procedure is overloaded it Isee doesn't print it. Is there a way around this.
I have inserted screen shots to show the outputs for the package.

restart

Test:=proc(a::{vector})
print(a);
end proc;

proc (a::{vector}) print(a) end proc

(1)

Test1:=overload([ proc(a::{vector})
                  option overload;
                  print(a);
                  end proc,

                  proc(a::{Matrix})
                  option overload;
                  print(a);
                  end proc
                ])

proc () option overload; [proc (a::{vector}) option overload; print(a) end proc, proc (a::{Matrix}) option overload; print(a) end proc] end proc

(2)

Isee := proc(a)
interface(verboseproc = 3);
printf("%P", eval(a));
end proc;

proc (a) interface(verboseproc = 3); printf("%P", eval(a)) end proc

(3)

Isee(Test)

proc(a::{vector})
    print(a);
end proc

 

Isee(Test1)

proc()
    option overload;
    [proc(a::{vector}) option overload; print(a); end proc,
        proc(a::{Matrix}) option overload; print(a); end proc];
end proc

 

#with(Routines);
#

#An non overloaded procedure in a package

Isee(ConicMatrix);
#

 

                                  ConicMatrix

 

#An overloaded procecure in a package

Isee(FactReduce);
#

                                  FactReduce

 
 

 

Download 2024-08-12_print_overloaded_procedure.mw

I know this question has been asked time and time again. Starting of with the expr . That is the end goal I want to achieve.  How would I reduce the expansion to get it into 1-f(x,y,z)/g(x,y,z) format?. I have tried all sorts of approaches.
 

restart

#

expr:=1 - (x__1*x__2 + y__1*y__2 - z__1*z__2)^2/((x__1^2 + y__1^2 - z__1^2)*(x__2^2 + y__2^2 - z__2^2))

1-(x__1*x__2+y__1*y__2-z__1*z__2)^2/((x__1^2+y__1^2-z__1^2)*(x__2^2+y__2^2-z__2^2))

(1)

normal( (1) );

(x__1^2*y__2^2-x__1^2*z__2^2-2*x__1*x__2*y__1*y__2+2*x__1*x__2*z__1*z__2+x__2^2*y__1^2-x__2^2*z__1^2-y__1^2*z__2^2+2*y__1*y__2*z__1*z__2-y__2^2*z__1^2)/((x__1^2+y__1^2-z__1^2)*(x__2^2+y__2^2-z__2^2))

(2)

simplify( (2) );

((y__2^2-z__2^2)*x__1^2-2*x__2*(y__1*y__2-z__1*z__2)*x__1+(y__1^2-z__1^2)*x__2^2-(y__1*z__2-y__2*z__1)^2)/((x__1^2+y__1^2-z__1^2)*(x__2^2+y__2^2-z__2^2))

(3)

radnormal(%)

(x__1^2*y__2^2-x__1^2*z__2^2-2*x__1*x__2*y__1*y__2+2*x__1*x__2*z__1*z__2+x__2^2*y__1^2-x__2^2*z__1^2-y__1^2*z__2^2+2*y__1*y__2*z__1*z__2-y__2^2*z__1^2)/((x__1^2+y__1^2-z__1^2)*(x__2^2+y__2^2-z__2^2))

(4)

Test:=combine(%)

(x__1^2*y__2^2-x__1^2*z__2^2-2*x__1*x__2*y__1*y__2+2*x__1*x__2*z__1*z__2+x__2^2*y__1^2-x__2^2*z__1^2-y__1^2*z__2^2+2*y__1*y__2*z__1*z__2-y__2^2*z__1^2)/((x__1^2+y__1^2-z__1^2)*(x__2^2+y__2^2-z__2^2))

(5)

 

n:={op(numer(Test))}

{x__1^2*y__2^2, x__2^2*y__1^2, -x__1^2*z__2^2, -x__2^2*z__1^2, -y__1^2*z__2^2, -y__2^2*z__1^2, -2*x__1*x__2*y__1*y__2, 2*x__1*x__2*z__1*z__2, 2*y__1*y__2*z__1*z__2}

(6)

d:={op(expand(denom(Test)))}

{x__1^2*x__2^2, x__1^2*y__2^2, x__2^2*y__1^2, y__1^2*y__2^2, z__1^2*z__2^2, -x__1^2*z__2^2, -x__2^2*z__1^2, -y__1^2*z__2^2, -y__2^2*z__1^2}

(7)

d subset n

false

(8)

d intersect n

{x__1^2*y__2^2, x__2^2*y__1^2, -x__1^2*z__2^2, -x__2^2*z__1^2, -y__1^2*z__2^2, -y__2^2*z__1^2}

(9)

add(%[i],i=1..nops(%))

x__1^2*y__2^2-x__1^2*z__2^2+x__2^2*y__1^2-x__2^2*z__1^2-y__1^2*z__2^2-y__2^2*z__1^2

(10)

factor( (10) );

x__1^2*y__2^2-x__1^2*z__2^2+x__2^2*y__1^2-x__2^2*z__1^2-y__1^2*z__2^2-y__2^2*z__1^2

(11)

n minus d

{-2*x__1*x__2*y__1*y__2, 2*x__1*x__2*z__1*z__2, 2*y__1*y__2*z__1*z__2}

(12)

 


 

Download 2024-07-20_Q_Simplify_Reformat.mw

1 2 3 4 5 6 7 Last Page 2 of 32