Ronan

1376 Reputation

16 Badges

13 years, 270 days
East Grinstead, United Kingdom

MaplePrimes Activity


These are replies submitted by Ronan

@acer Out of interest how did you discover/find the hidden character?

@mmcdara true/false is a valid answer for me. I was only solving for alpha as I couldn't think of any other way to derermine an asnwer.

@dharr  I see I tried it the wrong way around.

@acer  Thank you for pointing that out. I should try in future.

 Could you provide a sketch showing exactly what you mean. Say from Geogebra.

Is O the Origin?

Does it happen with rational numbers aswell

(123/100)/(n^(165/100)). 

I am not at my home pc to try.

@Kitonum Thank you. So it is sort of a little bug. I think I will keep the Tabulate and live with it.

@Kitonum Ok. But what I am looking for is needed in terms of varp. I can't get it to work.

varp:=alpha     but could be beta, lambda,  t etc.

`#3  Q24` (`&varp;`);  # not working

to give 

@acer Oh that is not a problem. You a busier than I and you find time to help a lot.

@acer That works perfectly. I would not have worked out the AddType for a long time. I did however manage to figure out the spellchecking by looking inside the Maple routine for Vector. But not as efficient as yours.
 

ProjVector := proc(a, b, c) 
      local cfs, vectr; 
      description " A Projective Line or Row Vector in Reduced format";
      if type(procname, 'indexed') then
         if procname::anyindex(identical(':-row')) then
            cfs := sign(c)*FactReduce([a, b, c]); 
            vectr := <[<cfs>^%T]>^%T;
            return vectr,type(vectr,ProjVR);
          elif procname::anyindex(identical(':-column')) then
            cfs := FactReduce([a, b, c]); 
            vectr := <[<cfs>]>;
            return vectr,type(vectr,ProjVC);
          else 
            error "either row or column is spelt incorrectly"; 
         end if;
       else
         cfs := FactReduce([a, b, c]); 
         vectr := <[<cfs>]>;
         return vectr,type(vectr,ProjVC);
      end if;
      end proc:

 

@acer I have just edited the question and put a link in.

@acer Thank you and the NSHO shall be heeded. I tried altering the procedure so it would catch typos for "row" and not default to the column option. Can't get it working properly. 

Secondly using the module from my prior question How to setup special type check in a procedure? - MaplePrimes I was trying to AddType for the vector construction of <[<a,b,c>]>  but can't get that to work either. 
Just to explain. I have to have a way of differentiating between standard vectors and projective vectors in the package. Using matrices were causing other problems. This is why I am trying this vector stucture. I doubt it is commonly used.

restart;

FactReduce:=overload([
     proc(v::{list,Vector})
          option overload;
          description " removes linear factor from",
                      " a list, vector, matrix or expression";
          uses LinearAlgebra;
          local i, num,tgdc,dnm, V1;
          num:=`ifelse`(type(v,Vector),numelems(v),nops(v));
          dnm:=frontend(lcm, [seq(denom(v[i]),i=1..num)]);
          V1:=radnormal(v*~dnm);
          tgdc:=V1[1];

          for i from 2 to num do
               tgdc:=frontend(gcd, [tgdc, V1[i]]);
          end do;

          return  simplify(V1/~tgdc);
     end proc,

     proc(M::{Matrix})
          option overload;
          uses LinearAlgebra;
          local i, num,r,c, tgdc,dnm, V1, Ml;
          r,c:=Dimension(M);
          num:=r*c;
          V1:=convert(M,list);
          dnm:=frontend(lcm, [seq(denom(V1[i]),i=1..num)]);
          Ml:=radnormal(dnm*~M);
          V1:=convert(Ml,list);#print((dnm,V1));
          tgdc:=V1[1];#print("xx")

          for i from 2 to num do
               tgdc:=frontend(gcd, [tgdc, V1[i]])
          end do;

          return  simplify(Ml/~tgdc);   
     end proc,

     proc(l::{`+`,`*`,`=`, `symbol`,procedure},  {vars::list:=[:-x,:-y]})
          option overload;
          uses LinearAlgebra;
          local i, num,f1,f1a,lv,lr, tgdc,dnm, V1,Vs;
          f1 := `if`(l::procedure, l(vars[]), l);
               f1a:=`if`(f1::`=`,lhs(f1)-rhs(f1),f1)  ; # Remequal(f1);
          lr:=primpart(f1a,vars);
          return lr
end proc

]):

 

#ProjVector := proc(a, b, c)
#local cfs, vectr;
#description " A Projective (Line) Vector in Reduced format";
#if procname::anyindex(identical(':-row')) then
#  cfs := sign(c)*FactReduce([a, b, c]);
#  vectr := <[<cfs>^%T]>^%T;
#else
 # cfs := FactReduce([a, b, c]);
 # vectr := <[<cfs>]>;
#end if;
#vectr;
#end proc:

 

NULL

M:= module()
local
    AddType:= proc(T::name, H::{type, procedure})
    uses TT= TypeTools;
        if TT:-Exists(T) then TT:-RemoveType(T) fi;
        TT:-AddType(T,H)
    end proc,

    ModuleLoad:= proc()
        AddType(Point, (e, n::{2,3})-> type(e, [algebraic$n]));
        AddType(Line, (e, n::{2,3})-> type(e, [Point(n)$2]));
        AddType(ProjVC,'Vector(1,'[Vector(3)]')');
        AddType(ProjVR,'Vector[':-row'](1,'[Vector[':-row'](3)]')');
    end proc
;
export
    CreateLine:= overload([
        proc(Pts::Line(2), $) option overload; "2D line" end proc,
        proc(Pts::Line(3), $) option overload; "3D line" end proc,
        ()-> "Unrecognized input format"
    ])
;
export
     ProjVector := proc(a, b, c)
      local cfs, vectr;
      description " A Projective Line or Row Vector in Reduced format";
      if procname::anyindex(identical(':-row')) then
         cfs := sign(c)*FactReduce([a, b, c]);
         vectr := <[<cfs>^%T]>^%T;
         return vectr,type(vectr,ProjVR);
       elif procname::anyindex(identical(':-column'))or procname::name then
         cfs := FactReduce([a, b, c]);
         vectr := <[<cfs>]>;
         return vectr,type(vectr,ProjVC);
       else Error;
      end if;
      vectr;
      end proc:

    ModuleLoad()
end module
:
M:-CreateLine([[1,2,3],[4,5,6]]);
                          

M:-CreateLine([[1,2],[4,5]]);

"3D line"

 

"2D line"

(1)

M:-ProjVector(a,b,c);

 

Vector[column](%id = 36893489844854842300), false

(2)

M:-ProjVector[':-row'](a,b,c)

Vector[row](%id = 36893489844854845180), false

(3)

M:-ProjVector[':-column'](a,b,c)

Vector[column](%id = 36893489844854839524), false

(4)

M:-ProjVector[':-raw'](a,b,c); #need to catch typos

 

Vector[column](%id = 36893489844854830012), false

(5)
 

 

Download 2024-11-22_Q_Projective_Vector_Format_ac_Rc.mw

Try changing the hours "Night Light" come on in windows.  I know it's not a very good solution.

@Carl Love Thank you. Is it possible to have a variants in the AddType? In this case  two points or a point and a vector.

I tried this but it didnt work. It still recognises two points though.  I also tried  adding another type  LineLV but haven't made that work either.

AddType(Line, (e, n::{2,3})-> type(e, {[Point(n)$2], [Point(n)$1,Vector(n)$1] }));
M:= module()
local
    AddType:= proc(T::name, H::{type, procedure})
    uses TT= TypeTools;
        if TT:-Exists(T) then TT:-RemoveType(T) fi;
        TT:-AddType(T,H)
    end proc,

    ModuleLoad:= proc()
        AddType(Point, (e, n::{2,3})-> type(e, [algebraic$n]));
        AddType(Line, (e, n::{2,3})-> type(e, [Point(n)$2]));
        AddType(LineLV, (e, n::{2,3})-> type(e, [Point(n)$1,Vector(n)$1]));
    end proc
;
export
    CreateLine:= overload([
        proc(Pts::Line(2), $) option overload; "2D line" end proc,
        proc(Pts::Line(3), $) option overload; "3D line" end proc,
         proc(Pts::LineLV(2), $) option overload; "2D line point and vector" end proc,
         proc(Pts::LineLV(3), $) option overload; "3D line point and vector" end proc,
        ()-> "Unrecognized input format"
    ])
;
    ModuleLoad()
end module
:
M:-CreateLine([[1,2,3],[4,5,6]]);
                           

M:-CreateLine([[1,2],[4,5]]);

M:-CreateLine([[1,2,3],<4,5,6>]);

M:-CreateLine([[1,2],<4,5>]);              
                           "3D line"

                           "2D line"

                  "Unrecognized input format"

                  "Unrecognized input format"

What is the Maple Beta Forum?

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