Ronan

942 Reputation

14 Badges

11 years, 359 days
East Grinstead, United Kingdom

MaplePrimes Activity


These are questions asked by Ronan

I am trying make atomic variables stand out in the document, I thought they used to automatically change to a purple type colour.

So under Format, styles , I set the style to size 14, Bold, dark green.  The font changed on the existing ones but not the colour.

On new ones no setting occours just default text. I then restored to default settings under styles and they all turned purple including the new ones.

Then I made another one but no adoption of the default style (purple) occured. 

This fiddlyness needs to be improved  

Has anyone any suggestions to make the atomic variables adope their default colour etc?

When will the PDF Maple User Manual be released for Maple 2023. Also I hope the Programming guide is updated too as it is still at 2020.

I am trying to test types inside lists on the input to a procedure. Sometimes I can get this concept to work. 

This is a sample to show the problem. I need to know if the list has [ list[ $3] , Vector[column]($3) ] , or [ Vector[row]($3] , Vector [column]($3) ]

restart

 


        test:=proc(l1::[{[algebraic $ 3],'Vector[row](3, algebraic)'},'Vector[column](3, algebraic)'],l2::[{[algebraic $ 3],'Vector[row](3, algebraic)'},'Vector[column](3,algebraic)'])
        
        print("inputs recognised");

        end proc;

        

proc (l1::[{'Vector[row](3, algebraic)', [`$`(algebraic, 3)]}, 'Vector[column](3, algebraic)'], l2::[{'Vector[row](3, algebraic)', [`$`(algebraic, 3)]}, 'Vector[column](3, algebraic)']) print("inputs recognised") end proc

 

 

#  3d lines

l1:= [<1 | 5 | 7>, <3, 7, 9>]

[Vector[row](3, {(1) = 1, (2) = 5, (3) = 7}), Vector(3, {(1) = 3, (2) = 7, (3) = 9})]

l2:=[<-4 | 2 | 1>, <3, 8, -9>]

[Vector[row](3, {(1) = -4, (2) = 2, (3) = 1}), Vector(3, {(1) = 3, (2) = 8, (3) = -9})]

test(l1,l2)

Error, invalid input: test expects its 1st argument, l1, to be of type [{'Vector[row](3,algebraic)', [algebraic $ 3]}, 'Vector[column](3,algebraic)'], but received [Vector[row](3, [1,5,7]), Vector(3, [3,7,9])]

l3:= [[1 , 5 , 7], <3, 7, 9>]

[[1, 5, 7], Vector(3, {(1) = 3, (2) = 7, (3) = 9})]

l4:=[[-4 , 2 , 1], <3, 2, -9>]

[[-4, 2, 1], Vector(3, {(1) = 3, (2) = 2, (3) = -9})]

test(l3,l4)

Error, invalid input: test expects its 1st argument, l1, to be of type [{'Vector[row](3,algebraic)', [algebraic $ 3]}, 'Vector[column](3,algebraic)'], but received [[1, 5, 7], Vector(3, [3,7,9])]

type(l3[1],[algebraic $ 3])

true

type(l1[1],[algebraic $ 3])  

false

type(l1[1],'Vector[row](3, algebraic)')

true

type(l1[2],'Vector[column](3, algebraic)')

true

 

Download Q_2023-03-06_Proc_types_in_list_inputs.mw

This a more a math question than  a maple programming question. But interesting.

I have a point P=[x,y] on a line y= 2+3x. The point maps to Pn=[f(x, y), g(x, y)]. That represents a conic.

I want to find the equation of the conic. I did it by calculating 5 points and that works fine but only because I know I'm looking for a conic. 

Can the problem by solved without having to get the five points?
I copied and pasted the equations for the lines because they were generated by commands in a pagkage I have.

restart

NULL

NULL

P := [X, Y]

[X, Y]

``

NULL

Pn := [(5*X+12*Y)*(-384+48*X+55*Y)/(225*X^2+225*Y^2-1800*X-602*Y), (2*(12*X-5*Y))*(-384+48*X+55*Y)/(225*X^2+225*Y^2-1800*X-602*Y)]

[(5*X+12*Y)*(-384+48*X+55*Y)/(225*X^2+225*Y^2-1800*X-602*Y), 2*(12*X-5*Y)*(-384+48*X+55*Y)/(225*X^2+225*Y^2-1800*X-602*Y)]

NULL

``

Y := 2+3*Xn

2+3*X

``

for i to 5 do P || i := eval(Pn, X = i) end do

[181139/51416, -19775/25708]

NULL

l12 := 153621*x*(1/68840)+169429*y*(1/27536)-15067/17210

(153621/68840)*x+(169429/27536)*y-15067/17210

NULL

l34 := -5733*x*(1/473062)+258973*y*(1/946124)+244205/946124

-(5733/473062)*x+(258973/946124)*y+244205/946124

c1 := l12*l34

((153621/68840)*x+(169429/27536)*y-15067/17210)*(-(5733/473062)*x+(258973/946124)*y+244205/946124)

NULL

l13 := 5499*x*(1/2360)+6539*y*(1/944)-793/472

(5499/2360)*x+(6539/944)*y-793/472

l24 := 596115*x*(1/6899489)+7228091*y*(1/6899489)+195364/363131

(596115/6899489)*x+(7228091/6899489)*y+195364/363131

plots:-implicitplot([l12, l34, l13, l24])

c2 := l13*l24

((5499/2360)*x+(6539/944)*y-793/472)*((596115/6899489)*x+(7228091/6899489)*y+195364/363131)

c := simplify(c2*lambda+c1)

(655607277/3256558808)*(x+(2515/846)*y-305/423)*(x+(556007/45855)*y+285532/45855)*lambda-(880709193/32565588080)*(x-(19921/882)*y-18785/882)*(x+(65165/23634)*y-4636/11817)

lambda := solve(eval(c, [x = P5[1], y = P5[2]]), lambda)

-1/4

simplify(c)

-(5039454771/65131176160)*x^2+(1/130262352320)*(-29130506847*y+40315638168)*x-(423368829/3256558808)*y^2+(111619143207/130262352320)*y

plt1 := plot(Y, X = -10 .. 10)

NULL

NULL

plt2 := plots:-implicitplot([c])

plots:-display(plt1, plt2, colour = ["Red", "Green"])

NULL

for i in [-7, 13/3, 42*(1/7)] do x := eval(Pn[1], X = i); y := eval(Pn[2], X = i); simplify(c) end do

0

NULL

Download Q_23-03-04_how_to_find_conic_from_mapping.mw

This is part of a package I put together in VScode. Testing it using CMaple.exe worked fine from the code editor. Then I imported it into Maple and saved it as a package, After ra restart  using using with(....) to load it, the special types defined in the package are not recognised. Procedures that don't check for the special types work ok. I have included one of each in the worksheet. 

If I just read in the .mpl file things do work.

What is the cause of this problem?

A secondary question. If I use the same special types in another package. Would that cause a conflict if both are loaded together?

restart

RationalTrigonometry:=module()
    option package;
    
    export
        AcuteObstuseQ,
        AcuteObstuseS,
        AltitudeQ,
        CircleParm,
        CircumCirQ,
        CfstoLeqn,
        CrossLaw,
        LinePrll,
        LinePrpnd,
        LinePts,
        LPproj,
        MedianQ,
        #QPrj,
        Quadrance,
        Quadrea,
        QQF,
        SolidSpread,
        SpreadLawQuadrea,
        SpreadLaw,
        SpreadPoly,
        Spread,
        Spreads123,
        TQF,
        TSF,
        UHG;

local MyModule,RelDPxyz,ppp,xpsn,ypsn,zpsn;

MyModule:= module()
uses TT= TypeTools;
global _T1, _T2L, _T2V, _T2VR, _T3L, _T3V, _T3VC, _T3VR, _T4L, _MyType,GeomClr,Prntmsg, prjpsn;
          GeomClr:="Blue";
          Prntmsg:="y";
          prjpsn:=3;

local
     MyTypes:= {_T1, _T2L, _T2V, _T2VR, _T3L, _T3V, _T3VC, _T3VR, _T4L},
     AllMyTypes:= MyTypes union {_MyType},
     ModuleLoad,
      ModuleUnload:= proc()
     local T;
          for T in AllMyTypes do if TT:-Exists(T) then TT:-RemoveType(T) end if; end do;
          return
     end proc;

     ModuleLoad:= proc()
     local
          g, #iterator over module globals
          e
     ;
          
          ModuleUnload();
          #op([2,6], ...) of a module is its globals.
          for g in op([2,6], thismodule) do
               e:= eval(g);
               #print("e",e);
               if g <> e and e in AllMyTypes then
                    error "The name %1 must be globally available.", g
               end if
          end do;
          TT:-AddType(_T1, algebraic);
          TT:-AddType(_T2V, 'Vector(2, algebraic)');
          TT:-AddType(_T2VR, 'Vector[row](2, algebraic)');
          TT:-AddType(_T2L, [algebraic $ 2]);
          TT:-AddType(_T3V, 'Vector(3, algebraic)');
          TT:-AddType(_T3VC, 'Vector[column](3, algebraic)');
          TT:-AddType(_T3VR, 'Vector[row](3, algebraic)');
          TT:-AddType(_T3L, [algebraic $ 3]);
          TT:-AddType(_T4L, [algebraic $ 4]);
          TT:-AddType(_MyType, MyTypes);
          return
     end proc;
export
     WhichMyType:= proc(X)
     local S:= select(T-> X::T, MyTypes), n:= nops(S);
         printf("%a is ", X);
         if n=0 then printf("not any of the special types.\n")
         else printf("type %a.\n", `if`(n=1, S[], Amd(S[])))
         fi
      end proc;
export    
     Dsp:= proc(msg:=" empty",prnt:=Prntmsg )
          if prnt = "y" then print(msg); end if;
     end proc;

     ModuleLoad()    
     end module;

ppp:=proc(prjpsn)
     description " the position x,y,z or z,x,y in a Vector";   
     if prjpsn=1 then   
        xpsn:=2;
        ypsn:=3;
        zpsn:=1;
      else  
        xpsn:=1;
        ypsn:=2;
        zpsn:=3;  
     end if;
    return xpsn, ypsn, zpsn
end proc;
    






#$include "Rational_Trigonometry\Quadruple Quad Formula.mpl"
#$include "Rational_Trigonometry\Quadrances_Overload_procs.mpl"

Quadrance :=overload([
   
   # 1 Quadrances p0 [x,y]
        proc(p0::{_T2L,_T2V}, clr := GeomClr,$)
                option overload;
                description "Calculates Quadrance of a [x,y] point";
                uses LinearAlgebra;         
                if clr = "b" or clr = "B" or clr = "blue" or clr = "Blue" then
                                MyModule:-Dsp(" Blue");
                                        BilinearForm(p0, p0, conjugate = false) ;
                        elif clr = "r" or clr = "R" or clr = "red" or clr = "Red" then
                                MyModule:-Dsp(" Red");
                                        p0[1]^2 - p0[2]^2 ;
                        elif clr = "g" or clr = "G" or clr = "green" or clr = "Green" then
                                MyModule:-Dsp(" Green");
                                        2*p0[1]*p0[2];
                end if;
        end proc,
# 7 Quadrances Point to Plane and intersection point 3D
        proc(p0::{_T3L,_T3V},pl::{_T4L,`+`,procedure},var::_T3L:=[x,y,z],$)
        option overload;
                local i, dlambda,nlambda,lambda,Q   ,intrP,  Vpn  ,f1  ;
                if pl::_T4L then
                        Vpn:=convert(pl,Vector[row]);
                 elif pl::{`+`,procedure} then
                        f1 := `if`(pl::procedure, pl(vars[]), pl);
                        Vpn:=<coeff(f1,var[1]),coeff(f1,var[2]),coeff(f1,var[3]),coeff(coeff(coeff(f1,var[3],0),var[2],0),var[1],0)>;
                end  if;
                
                nlambda:=(Vpn[1]*p0[1]+Vpn[2]*p0[2]+Vpn[3]*p0[3]+Vpn[4]);
                dlambda:=Vpn[1]^2+Vpn[2]^2+Vpn[3]^2;
                lambda:=nlambda/dlambda;
                intrP:=`<|>`(seq(p0[i]+lambda*Vpn[i],i=1..3));
                Q:=nlambda^2/dlambda;
                MyModule:-WhichMyType(pl);
                MyModule:-Dsp("Quadrance Point to Plane & intersect Point");
                return Q,intrP
                end proc,

        # 2 Quadrances p0 [x,y,z]
        proc(p0::{_T3L,_T3V}, clr := GeomClr,$)
                option overload;
                description "Calculates Quadrance of a [x,y,z] point Blue only";
                uses LinearAlgebra;         
                if clr = "b" or clr = "B" or clr = "blue" or clr = "Blue" then
                         MyModule:-Dsp("Quadrance 3D Point Blue");
                                BilinearForm(p0, p0, conjugate = false);
                        else print("3D Not yet implimented for Red or Green Geometry" );        
                end if;
        end proc,

        # 3 Quadrances P0-P1 [x,y]
         proc(p0::{_T2L,_T2V},p1::{_T2L,_T2V}, clr := GeomClr,$)
                option overload;
                description "Quadrance between two [x,y] points";        
                uses LinearAlgebra;                                
                if clr = "b" or clr = "B" or clr = "blue" or clr = "Blue" then                  
                                MyModule:-Dsp( "Quadrance between two 2D Points Blue") ;
                                 BilinearForm(p0 - p1, p0 - p1, conjugate = false);                        
                        elif clr = "r" or clr = "R" or clr = "red" or clr = "Red" then
                                        MyModule:-Dsp( "Quadrance between two 2D Points Red") ;
                                         (p0[1] - p1[1])^2 - (p0[2] - p1[2])^2;                         
                        elif clr = "g" or clr = "G" or clr = "green" or clr = "Green" then                         
                                        MyModule:-Dsp( "Quadrance between two 2D Points Green") ;
                                         (2*p1[1] - 2*p0[1])*(p1[2] - p0[2]);                        
                end if;
        end proc,

        # 4 Quadrances p0-p1 [x,y,z]
        proc(p0::{_T3L,_T3V},p1::{_T3L,_T3V}, clr::string := GeomClr,$)
                option overload;
                description "Calculates Quadrance of between two points/vectors [x,y,z] Blue only";
                uses LinearAlgebra;         
                if clr = "b" or clr = "B" or clr = "blue" or clr = "Blue" then
                                        MyModule:-Dsp( "Quadrance between two 3D Points Blue") ;
                                        BilinearForm(p0 - p1, p0 - p1, conjugate = false);
                        else print("Not at this point  implimented for Red or Green Geometry" );        
                end if;
        end proc,

        # 5 Quadrances Point to Line and intersection point 2D
        proc(p0::_T2L, l1::{_T3L,`+`,procedure}, vars::_T2L:=[x,y],clr:=GeomClr)
                option overload;
                local f1,P0:=p0,P1;
                if l1::_T3L then
                        P1:=l1;
                 else
                        f1 := `if`(l1::procedure, l1(vars[]), l1);
                        P1:=[coeff(f1,vars[1]),coeff(f1,vars[2]),coeff(coeff(f1,vars[1],0),vars[2],0)];
                end if;
                if  clr = "b" or clr = "B" or clr = "blue" or clr = "Blue"  then
                        MyModule:-Dsp( "Quadrance 2D Point to Line & intersect Point Blue") ;
                        return (P0[1]*P1[1] + P0[2]*P1[2] + P1[3])^2/(P1[1]^2 + P1[2]^2),
                        [((-P0[2]*P1[2] - P1[3])*P1[1] + P0[1]*P1[2]^2)/(P1[1]^2 + P1[2]^2),
                        ((-P0[1]*P1[1] - P1[3])*P1[2] + P0[2]*P1[1]^2)/(P1[1]^2 + P1[2]^2)];
                         
                 elif clr = "r" or clr = "R" or clr = "red" or clr = "Red"  then
                        if P1[1]^2 - P1[2]^2 <> 0 then
                                MyModule:-Dsp( "Quadrance 2D Point to Line & intersect Point Red") ;
                                return (P0[1]*P1[1] + P0[2]*P1[2] + P1[3])^2/(P1[1]^2 - P1[2]^2),
                                [((-P0[2]*P1[2] - P1[3])*P1[1] - P0[1]*P1[2]^2)/(P1[1]^2 - P1[2]^2),
                                ((P0[1]*P1[1] + P1[3])*P1[2] + P0[2]*P1[1]^2)/(P1[1]^2 - P1[2]^2)];
                                
                         else
                                "Null Red"
                        end if;
                 
                        #"Input ERROR "Red"";         
                 elif clr = "g" or clr = "G" or clr = "green" or clr = "Green" then
                        if P1[1]*P1[2] = 0 then
                                "Null Green";
                         else
                                 MyModule:-Dsp( "Quadrance 2D Point to Line & intersect Point Green") ;
                                return 1/2*(P0[1]*P1[1] + P0[2]*P1[2] + P1[3])^2/(P1[1]*P1[2]),
                                [1/2*(P0[1]*P1[1] - P0[2]*P1[2] - P1[3])/P1[1],
                                1/2*(-P0[1]*P1[1] + P0[2]*P1[2] - P1[3])/P1[2]];
                                 
                        end if;
                 else
                        "Input ERROR Green";  
                end if;
        end proc,
        
        # 6 Quadrances Point to Line and intersection point 3D
        proc(p0::{_T3L,_T3V},lP::{_T3L,_T3V},lV::{_T3V},$)
                option overload;
                local lambda , Q ,intrP ;
                lambda:=((p0[1]-lP[1])*lV[1]+(p0[2]-lP[2])*lV[2]+(p0[3]-lP[3])*lV[3])/(lV[1]^2+lV[2]^2+lV[3]^2);
                print(lambda);
                Q:=((p0[1]-lP[1]-lambda*lV[1])^2+(p0[2]-lP[2]-lambda*lV[2])^2+(p0[3]-lP[3]-lambda*lV[3])^2);
                
                intrP:=lP+lambda*lV;
                MyModule:-Dsp("Quadrance Point to 3D Line and Intersect Point");

                return Q,intrP
        end proc

        

        

]):


QQF := proc(Q1, Q2, Q3, Q4)
 ((Q1 + Q2 + Q3 + Q4)^2 - 2*Q1^2 - 2*Q2^2 - 2*Q3^2 - 2*Q4^2)^2 = 64*Q2*Q1*Q3*Q4;
 end proc;

     

end module:

 

RationalTrigonometry:-Quadrance([0,2,3],<3,1,-1>,<2,1,2>);

1/3

"Quadrance Point to 3D Line and Intersect Point"

25, Vector[column](%id = 36893489965928498348)

RationalTrigonometry:-Quadrance([4,-4,3],2*x-2*y+5*z+8,[x,y,z]);

2*x-2*y+5*z+8 is type _T1.

"Quadrance Point to Plane & intersect Point"

507/11, Vector[row](%id = 36893489965928500148)

RationalTrigonometry:-Quadrance([4,-4,3],[2,-2,5,8]);

[2, -2, 5, 8] is type _T4L.

"Quadrance Point to Plane & intersect Point"

507/11, Vector[row](%id = 36893489965928493652)

Qb:=RationalTrigonometry:-Quadrance([a,b],[c,d],"b");

"Quadrance between two 2D Points Blue"

(-c+a)^2+(-d+b)^2

RationalTrigonometry:-QQF(a,b,c,d)

((a+b+c+d)^2-2*a^2-2*b^2-2*c^2-2*d^2)^2 = 64*b*a*c*d

RationalTrigonometry:-QQF(10^2,5^2,2^2,3^2)

5760000 = 5760000

restart

with(RationalTrigonometry)

[AcuteObstuseQ, AcuteObstuseS, AltitudeQ, CfstoLeqn, CircleParm, CircumCirQ, CrossLaw, LPproj, LinePrll, LinePrpnd, LinePts, MedianQ, QQF, Quadrance, Quadrea, SolidSpread, Spread, SpreadLaw, SpreadLawQuadrea, SpreadPoly, Spreads123, TQF, TSF, UHG]

Quadrance([4,-4,3],2*x-2*y+5*z+8,[x,y,z])

Error, type `_T3L` does not exist

QQF(10^2,5^2,2^2,3^2)
                       5760000 = 5760000

 


 

Download Q_2023-01-14_Package_not_Recognising_Types.mw

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