Ronan

1451 Reputation

16 Badges

14 years, 148 days
East Grinstead, United Kingdom

MaplePrimes Activity


These are questions asked by Ronan

This the part of a procedure I have for removing common factors from matrices and vectors used in a projective geometry setting.
How can a get it to work so it handles polynomial denominators? Such as 

x__1*y__2 - x__1*y__3 - x__2*y__1 + x__2*y__3 + x__3*y__1 - x__3*y__2

restart

 

ReduceM:= proc(C::{Matrix, :-_ProjM3})
            local i, tgdc, dnm, V1, Ml, SV1, ns, M, r;
            option overload;
            if C::'Matrix' then
                M := LinearAlgebra:-Copy(C);
            elif C::{':-_ProjM3'} then
                M := LinearAlgebra:-Copy(C[1]);
            end if;
            V1 := convert(M, list);
            SV1 := convert(M, set) minus {0};
            ns := nops(SV1);
            dnm := frontend(lcm, [seq(denom(SV1[i]), i = 1 .. ns)]);
            Ml := simplify(dnm *~ M);
            V1 := convert(Ml, list);
            tgdc := SV1[1];
            if tgdc = 0 then
                tgdc := 1;
            end if;
            for i from 2 to ns do
                tgdc := frontend(gcd, [tgdc, SV1[i]]);
            end do;
            r := `if`(C::'Matrix', simplify(factor~(Ml /~ tgdc)),
                <[simplify(factor~(Ml /~ tgdc))]>);
            return r;
        end proc:

 

 

A:=Matrix(3, 3, [[(x__2 - x__1)*(-y__2 + y__3) + (-y__1 + y__2)*(-x__3 + x__2), (x__2 - x__1)*(-y__1 + y__3) + (-y__1 + y__2)*(-x__3 + x__1), (x__2 - x__1)*(-y__1 + y__2) + (-y__1 + y__2)*(-x__2 + x__1)], [(x__3 - x__1)*(-y__2 + y__3) + (-y__1 + y__3)*(-x__3 + x__2), (x__3 - x__1)*(-y__1 + y__3) + (-y__1 + y__3)*(-x__3 + x__1), (x__3 - x__1)*(-y__1 + y__2) + (-y__1 + y__3)*(-x__2 + x__1)], [x__1*(-y__2 + y__3) + y__1*(-x__3 + x__2) - x__2*y__3 + x__3*y__2, (-y__1 + y__3)*x__1 + y__1*(-x__3 + x__1) - x__1*y__3 + x__3*y__1, (-y__1 + y__2)*x__1 + y__1*(-x__2 + x__1) - x__1*y__2 + x__2*y__1]])

Matrix(3, 3, {(1, 1) = (x__2-x__1)*(-y__2+y__3)+(-y__1+y__2)*(-x__3+x__2), (1, 2) = (x__2-x__1)*(-y__1+y__3)+(-y__1+y__2)*(-x__3+x__1), (1, 3) = (x__2-x__1)*(-y__1+y__2)+(-y__1+y__2)*(-x__2+x__1), (2, 1) = (x__3-x__1)*(-y__2+y__3)+(-y__1+y__3)*(-x__3+x__2), (2, 2) = (x__3-x__1)*(-y__1+y__3)+(-y__1+y__3)*(-x__3+x__1), (2, 3) = (x__3-x__1)*(-y__1+y__2)+(-y__1+y__3)*(-x__2+x__1), (3, 1) = x__1*(-y__2+y__3)+y__1*(-x__3+x__2)-x__2*y__3+x__3*y__2, (3, 2) = (-y__1+y__3)*x__1+y__1*(-x__3+x__1)-x__1*y__3+x__3*y__1, (3, 3) = (-y__1+y__2)*x__1+y__1*(-x__2+x__1)-x__1*y__2+x__2*y__1})

(1)

ReduceM(A)

Matrix(3, 3, {(1, 1) = 1, (1, 2) = 1, (1, 3) = 0, (2, 1) = 1, (2, 2) = 0, (2, 3) = -1, (3, 1) = -1, (3, 2) = 0, (3, 3) = 0})

(2)

B:=Matrix(3, 3, [[-(y__1 - y__3)/(x__1*y__2 - x__1*y__3 - x__2*y__1 + x__2*y__3 + x__3*y__1 - x__3*y__2) + (y__1 - y__2)/(x__1*y__2 - x__1*y__3 - x__2*y__1 + x__2*y__3 + x__3*y__1 - x__3*y__2), -(y__1 - y__3)/(x__1*y__2 - x__1*y__3 - x__2*y__1 + x__2*y__3 + x__3*y__1 - x__3*y__2), -(y__1 - y__2)/(x__1*y__2 - x__1*y__3 - x__2*y__1 + x__2*y__3 + x__3*y__1 - x__3*y__2)], [(-x__3 + x__1)/(x__1*y__2 - x__1*y__3 - x__2*y__1 + x__2*y__3 + x__3*y__1 - x__3*y__2) - (-x__2 + x__1)/(x__1*y__2 - x__1*y__3 - x__2*y__1 + x__2*y__3 + x__3*y__1 - x__3*y__2), (-x__3 + x__1)/(x__1*y__2 - x__1*y__3 - x__2*y__1 + x__2*y__3 + x__3*y__1 - x__3*y__2), (-x__2 + x__1)/(x__1*y__2 - x__1*y__3 - x__2*y__1 + x__2*y__3 + x__3*y__1 - x__3*y__2)], [-(x__1*y__3 - x__3*y__1)/(x__1*y__2 - x__1*y__3 - x__2*y__1 + x__2*y__3 + x__3*y__1 - x__3*y__2) + (x__1*y__2 - x__2*y__1)/(x__1*y__2 - x__1*y__3 - x__2*y__1 + x__2*y__3 + x__3*y__1 - x__3*y__2) - 1, -(x__1*y__3 - x__3*y__1)/(x__1*y__2 - x__1*y__3 - x__2*y__1 + x__2*y__3 + x__3*y__1 - x__3*y__2), -(x__1*y__2 - x__2*y__1)/(x__1*y__2 - x__1*y__3 - x__2*y__1 + x__2*y__3 + x__3*y__1 - x__3*y__2)]])

Matrix(3, 3, {(1, 1) = -(y__1-y__3)/(x__1*y__2-x__1*y__3-x__2*y__1+x__2*y__3+x__3*y__1-x__3*y__2)+(y__1-y__2)/(x__1*y__2-x__1*y__3-x__2*y__1+x__2*y__3+x__3*y__1-x__3*y__2), (1, 2) = -(y__1-y__3)/(x__1*y__2-x__1*y__3-x__2*y__1+x__2*y__3+x__3*y__1-x__3*y__2), (1, 3) = -(y__1-y__2)/(x__1*y__2-x__1*y__3-x__2*y__1+x__2*y__3+x__3*y__1-x__3*y__2), (2, 1) = (-x__3+x__1)/(x__1*y__2-x__1*y__3-x__2*y__1+x__2*y__3+x__3*y__1-x__3*y__2)-(-x__2+x__1)/(x__1*y__2-x__1*y__3-x__2*y__1+x__2*y__3+x__3*y__1-x__3*y__2), (2, 2) = (-x__3+x__1)/(x__1*y__2-x__1*y__3-x__2*y__1+x__2*y__3+x__3*y__1-x__3*y__2), (2, 3) = (-x__2+x__1)/(x__1*y__2-x__1*y__3-x__2*y__1+x__2*y__3+x__3*y__1-x__3*y__2), (3, 1) = -(x__1*y__3-x__3*y__1)/(x__1*y__2-x__1*y__3-x__2*y__1+x__2*y__3+x__3*y__1-x__3*y__2)+(x__1*y__2-x__2*y__1)/(x__1*y__2-x__1*y__3-x__2*y__1+x__2*y__3+x__3*y__1-x__3*y__2)-1, (3, 2) = -(x__1*y__3-x__3*y__1)/(x__1*y__2-x__1*y__3-x__2*y__1+x__2*y__3+x__3*y__1-x__3*y__2), (3, 3) = -(x__1*y__2-x__2*y__1)/(x__1*y__2-x__1*y__3-x__2*y__1+x__2*y__3+x__3*y__1-x__3*y__2)})

(3)

ReduceM(B)

Error, (in gcd/Freeze) arguments should be polynomials

 

B*denom(B[1,1])

Matrix(3, 3, {(1, 1) = (x__1*y__2-x__1*y__3-x__2*y__1+x__2*y__3+x__3*y__1-x__3*y__2)*(-(y__1-y__3)/(x__1*y__2-x__1*y__3-x__2*y__1+x__2*y__3+x__3*y__1-x__3*y__2)+(y__1-y__2)/(x__1*y__2-x__1*y__3-x__2*y__1+x__2*y__3+x__3*y__1-x__3*y__2)), (1, 2) = -y__1+y__3, (1, 3) = -y__1+y__2, (2, 1) = (x__1*y__2-x__1*y__3-x__2*y__1+x__2*y__3+x__3*y__1-x__3*y__2)*((-x__3+x__1)/(x__1*y__2-x__1*y__3-x__2*y__1+x__2*y__3+x__3*y__1-x__3*y__2)-(-x__2+x__1)/(x__1*y__2-x__1*y__3-x__2*y__1+x__2*y__3+x__3*y__1-x__3*y__2)), (2, 2) = -x__3+x__1, (2, 3) = -x__2+x__1, (3, 1) = (x__1*y__2-x__1*y__3-x__2*y__1+x__2*y__3+x__3*y__1-x__3*y__2)*(-(x__1*y__3-x__3*y__1)/(x__1*y__2-x__1*y__3-x__2*y__1+x__2*y__3+x__3*y__1-x__3*y__2)+(x__1*y__2-x__2*y__1)/(x__1*y__2-x__1*y__3-x__2*y__1+x__2*y__3+x__3*y__1-x__3*y__2)-1), (3, 2) = -x__1*y__3+x__3*y__1, (3, 3) = -x__1*y__2+x__2*y__1})

(4)

simplify( (4) );

Matrix(3, 3, {(1, 1) = -y__2+y__3, (1, 2) = -y__1+y__3, (1, 3) = -y__1+y__2, (2, 1) = -x__3+x__2, (2, 2) = -x__3+x__1, (2, 3) = -x__2+x__1, (3, 1) = -x__2*y__3+x__3*y__2, (3, 2) = -x__1*y__3+x__3*y__1, (3, 3) = -x__1*y__2+x__2*y__1})

(5)
 

 

Download 2026-08-03_Q_Remove_Common_Factors_from_Matrix.mw

I am trying to follow a series of substitutions used in a paper. I have given some examples of the substitutions. But I am having difficulty getting them to work. I know if all else fails I can manually recreate an expression with the substitution variables and then check backwards using eval(f,vals).
Would appreciate any insight on substitution techniques here.
 

restart

 

sidrels := [a*c - b^2 = Delta, a + c - 2*b = d, a - b = c__bar, a - c = b__bar, c - b = a__bar];

[a*c-b^2 = Delta, a+c-2*b = d, a-b = c__bar, a-c = b__bar, c-b = a__bar]

(1)

vals:='rhs=lhs'~(sidrels)

[Delta = a*c-b^2, d = a+c-2*b, c__bar = a-b, b__bar = a-c, a__bar = c-b]

(2)

t1:=a + c - 2*b;
simplify(t1,sidrels); #this should be d

a+c-2*b

 

d

(3)

t2:=Vector[column](3, [-a + b, c - b, 0]);
simplify(t2,sidrels) ; # This should be <-c__bar,a__bar,0> or <c__bar,-a__bar,0,>r

Vector(3, {(1) = -a+b, (2) = c-b, (3) = 0})

 

Vector[column](%id = 36893490321805397396)

(4)

t3:=normal(1 - b^2/(a*c));

(a*c-b^2)/(a*c)

(5)

simplify((5),sidrels); # This should be Delta/(a*c)

Delta/(b^2+Delta)

(6)

simplify(numer((5)),sidrels,'mindeg')/(denom((5)) ); # This works

 

Delta/(a*c)

(7)

t4:=[(-b^2 + b*c)/(a*c - b^2), (a*b - b^2)/(a*c - b^2)]

[(-b^2+b*c)/(a*c-b^2), (a*b-b^2)/(a*c-b^2)]

(8)

simplify(t4,sidrels,'mindeg');# this should be [(b*a__bar)/Delta, (b*b__bar)/Delta]

[-b*(-c+b)/Delta, b*(a-b)/Delta]

(9)

t5:=simplify(Vector[column](3, [3*b*c__bar - Delta, -3*a__bar*b + Delta, b*(-c__bar + a__bar)]))

Vector(3, {(1) = 3*b*c__bar-Delta, (2) = -3*a__bar*b+Delta, (3) = b*(-c__bar+a__bar)})

(10)

t5[3]:=simplify(t5[3],sidrels)  ;#This should be b*b__bar

 

-a__bar^2+(2*b+d)*a__bar-Delta

(11)

t5

Vector(3, {(1) = 3*b*c__bar-Delta, (2) = -3*a__bar*b+Delta, (3) = -a__bar^2+(2*b+d)*a__bar-Delta})

(12)

subs(sidrels[-2],b*(-c__bar + a__bar))

b*(-c__bar+a__bar)

(13)

algsubs(sidrels[-2],b*(-c__bar + a__bar))

b*(-c__bar+a__bar)

(14)

 


 

Download 2026-07-29_Q_Simplifications_and_Substitutions.mw

Are there any demonstration help videos on creating an eBook? Currently I am struggling with the pages Having a laid out example would really help.  

I would like to do an eBook version of my help pages to send to some people. Hopefully I can use the current help worksheets. The are formatted based on the Maple help structure.

My currrent structure in the help section is:

Rational Trigonometry

      (about 40 help topics)

       RTProjective

       (about 20 help topics)

       UHG

       (about 20 help topics)

     Edit:- I have made a small step of progress using the " Assistant eBook template" but I am getting this error on build. I don't know how to find the cause of the error.

I am trying to select from a default list and a modified list to get a third combined list of the unmodified default elements and the mdfified elements plus extra elements. This is for plot data. I have managed to extract the colour data using something I did a couple of years ago. Though at this stage I don't relly know how that works either but it works.

restart

with(ListTools)

[BinaryPlace, BinarySearch, Categorize, Classify, Collect, Deal, DotProduct, Enumerate, FindMaximalElement, FindMinimalElement, FindRepetitions, Flatten, FlattenOnce, Group, Interleave, InversePermutation, Join, JoinSequence, LengthSplit, MakeUnique, Occurrences, Pad, PartialSums, Reverse, Rotate, Search, SearchAll, SelectFirst, SelectLast, Slice, Sorted, Split, Transpose, Unpermute]

(1)

PlotDefaults:=['colour' = ':-blue', symbol = ':-solidcircle', ':-symbolsize' = 8,thickness=2]; #for points and lines

[colour = blue, symbol = solidcircle, symbolsize = 8, thickness = 2]

(2)

Inputs:=['color'=[red, black, blue],symbol=square,':-linestyle'=dash]; #'color'=[red, black, blue],

 

[color = [red, black, blue], symbol = square, linestyle = dash]

(3)

if has(Inputs,{colour,color}) then
Colourlist:=remove(has,remove(has,Flatten(eval([':-color',':-colour'],Inputs)),':-colour'),':-color')
else
Colourlist:=remove(has,remove(has,Flatten(eval([':-color',':-colour'],PlotDefaults)),':-colour'),':-color');
end if

[red, black, blue]

(4)


Make this list

plotdata:=[symbol=square,':-linestyle'=dash,':-symbolsize' = 8,thickness=2]

[symbol = square, linestyle = dash, symbolsize = 8, thickness = 2]

(5)

mx:=max(nops(PlotDefaults),nops(Inputs))

4

(6)

Plotdata:=[];
for i to mx do

end do

 

 

[]

(7)
 

 

Download 2026-05-18_Q_Select_from_Two_Lists_to_get_New_List.mw

Insetr Table seems to default too test inpul in the cells. I am inserting it from this icon 

I can't figure out how to change the whole table to 1d or 2d math input without individually changing each cell..

What am I misssing here?

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