Ronan

1311 Reputation

14 Badges

12 years, 315 days
East Grinstead, United Kingdom

MaplePrimes Activity


These are questions asked by Ronan

I am trying to tidy up cases where a proc returns multiple values. Have being trying Tabulate. I can get it to work when called after the results are returned. I would the procedure to do this but  keep acces to the name(s) assigned to the returned values.

A,B,C:= proc(...)  .....  return a, b, c    end proc. 

So basically display a tabulated of a, b, c.
 

restart

 

QQFProj := proc(q12::algebraic, q23::algebraic, q34::algebraic, q14::algebraic,{columns:=[QQFproj,Q13proj,Q24proj]},prnt::boolean:=true)
description "Projective quadruple quad formula and intermediate 13 and 24 quads. Useful for cyclic quadrilaterals";
local qqf,q13,q24, sub1,sub2,sub3, R;
#uses  DT = 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
#return [columns,[qqf,q13,q24]];


if prnt then
print(cat(" ",columns[1],"    ",columns[2],"     ",columns[3])) ;
end if;
return qqf ,q13,q24


 end proc:

q12:=1/2:q23:=9/10:q34:=25/26:q41:=9/130: #Cyclic quadrilateral
 AA:=QQFProj(q12,q23,q34,q41,true);


AA[1];
AA[2];
AA[3]

" QQFproj    Q13proj     Q24proj"

 

9801/2856100 = 9801/2856100, 4/5, 16/65

 

9801/2856100 = 9801/2856100

 

4/5

 

16/65

(1)

# Can the below be built into the proc to nicely didplay the results but maintain access to the results as shown when prnt=true.

columns:=[QQFproj,Q13proj,Q24proj]:
BB:=QQFProj(q12,q23,q34,q41,false):
DocumentTools:-Tabulate([columns,[BB]],width=55):#could do with a variable width depending on length of output epression.

BB[1];
BB[2];
BB[3]

9801/2856100 = 9801/2856100

 

4/5

 

16/65

(2)

dspformat:=(BB,columns)->DocumentTools:-Tabulate([columns,[BB]],width=75);

proc (BB, columns) options operator, arrow; DocumentTools:-Tabulate([columns, [BB]], width = 75) end proc

(3)

CC:=dspformat(BB,columns):#layout not as expected

CC[1] ; #  just gives  letters from Tabulate

"T"

(4)

 


 

Download 2024-03-18_Q_Format_Returned_Results_into_a_Table..mw

 I am writing help pages for a package. The inital Overview should be at the top of the listing like in other Maple help directories. 

How to I do this? Mine is listing purely alphabetically.
 

NULL

with(HelpTools)

[Database, TableOfContents, Worksheet]

(1)

currentdir()

"D:\User Account Ronan\Documents\MAPLE\Rational Trigonometry"

(2)

 

NULL

NULL

HelpTools[Database][Create]("C:/Users/Ronan/Maple/toolbox/personal/lib/RationalTrigonometry.help")

"C:/Users/Ronan/Maple/toolbox/personal/lib/RationalTrigonometry.help"

(3)

HelpTools[Database][Add]("C:/Users/Ronan/Maple/toolbox/personal/lib/RationalTrigonometry.help")

["C:\Program Files\Maple 2024\lib\maple.help", "C:\Program Files\Maple 2024\lib\maple_ja.help", "C:\Users\Ronan\maple\toolbox\CodeBuilder\lib\CodeBuilder.help", "C:\Users\Ronan\maple\toolbox\DirectSearch\lib\DirectSearch.help", "C:\Users\Ronan\maple\toolbox\OEIS\lib\OEIS.help", "C:\Users\Ronan\maple\toolbox\UTF8\lib\UTF8.help"]

(4)

HelpTools[Database][GetActive]()

["C:/Users/Ronan/Maple/toolbox/personal/lib/RationalTrigonometry.help", "C:\Program Files\Maple 2024\lib\maple.help", "C:\Program Files\Maple 2024\lib\maple_ja.help", "C:\Users\Ronan\maple\toolbox\CodeBuilder\lib\CodeBuilder.help", "C:\Users\Ronan\maple\toolbox\DirectSearch\lib\DirectSearch.help", "C:\Users\Ronan\maple\toolbox\OEIS\lib\OEIS.help", "C:\Users\Ronan\maple\toolbox\UTF8\lib\UTF8.help", "C:\Users\Ronan\maple\toolbox\personal\lib\RationalTrigonometry.help"]

(5)

NULL

makehelp("RationalTrigonometry", "Rational Trigonometry Overiew Help.mw", "C:/Users/Ronan/Maple/toolbox/personal/lib/RationalTrigonometry.help", aliases = ["RatTrig", "Rat Trig", "RT", "R T"], browser = ["Rational Trigonometry", " Overview"])

["C:/Users/Ronan/Maple/toolbox/personal/lib/RationalTrigonometry.help", "C:\Program Files\Maple 2024\lib\maple.help", "C:\Program Files\Maple 2024\lib\maple_ja.help", "C:\Users\Ronan\maple\toolbox\CodeBuilder\lib\CodeBuilder.help", "C:\Users\Ronan\maple\toolbox\DirectSearch\lib\DirectSearch.help", "C:\Users\Ronan\maple\toolbox\OEIS\lib\OEIS.help", "C:\Users\Ronan\maple\toolbox\UTF8\lib\UTF8.help", "C:\Users\Ronan\maple\toolbox\personal\lib\RationalTrigonometry.help"]

(6)

makehelp("RationalTrigonometry,Quadrance", "Help Quadrance.mw", "C:/Users/Ronan/Maple/toolbox/personal/lib/RationalTrigonometry.help", browser = ["Rational Trigonometry", "Quadrance"])

makehelp("RationalTrigonometry,Cross Law", "Help Cross Law.mw", "C:/Users/Ronan/Maple/toolbox/personal/lib/RationalTrigonometry.help", browser = ["Rational Trigonometry", "CrossLaw"])

makehelp("RationalTrigonometry,Spread", "Help Spread.mw", "C:/Users/Ronan/Maple/toolbox/personal/lib/RationalTrigonometry.help", aliases = ["RT Spread", "R T Spread"], browser = ["Rational Trigonometry", "Spread"])

makehelp("RationalTrigonometry,Spread Law", "Help Spread Law.mw", "C:/Users/Ronan/Maple/toolbox/personal/lib/RationalTrigonometry.help", aliases = ["RT Spread Law", "Spread Law Quadrea"], browser = ["Rational Trigonometry", "Spread Law"])

makehelp("RationalTrigonometry,TQF", "Help Triple Quad Formula.mw", "C:/Users/Ronan/Maple/toolbox/personal/lib/RationalTrigonometry.help", aliases = ["Triple Quad Formula", "TQF"], browser = ["Rational Trigonometry", "Triple Quad Formula"])

makehelp("RationalTrigonometry,TSF", "Help Triple Spread Formula.mw", "C:/Users/Ronan/Maple/toolbox/personal/lib/RationalTrigonometry.help", aliases = ["Triple Spread Formula", "TSF"], browser = ["Rational Trigonometry", "Triple Spread Formula"])

makehelp("RationalTrigonometry,QQF", "Help Quadruple Quad Formula.mw", "C:/Users/Ronan/Maple/toolbox/personal/lib/RationalTrigonometry.help", aliases = ["Quadruple Quad Formula", "QQF"], browser = ["Rational Trigonometry", "Quadruple Quad Formula"])

makehelp("RationalTrigonometry,QSF", "Help Quadruple Spread Formula.mw", "C:/Users/Ronan/Maple/toolbox/personal/lib/RationalTrigonometry.help", aliases = ["Quadruple Spread Formula", "QSF"], browser = ["Rational Trigonometry", "Quadruple Spread Formula"])

makehelp("RationalTrigonometry,Quadrea", "Help Quadrea Triangle.mw", "C:/Users/Ronan/Maple/toolbox/personal/lib/RationalTrigonometry.help", browser = ["Rational Trigonometry", "Quadrea"])

NULL

NULL

NULL       

NULL


 

Download Help_Edit_to_Database_2023.mw

I have a repetative set of parameter names used in procedures in a package. I settled on making all optional inputs in the format {name::type:=something}. Originally I wanted to use non capitalised names for the optional inputs. But the names clash with Maple commands. I have all sorts of quicky abbreviations like prnt etc. These are both messy and tacky. For many of my choices I would seem to have to use capitalised naming to give a meaningful name. The problem here is these names are used in other Maple packages. So sooner or later there is going to be a clash.

Is there a way a of handling this? Like can I defiine package parameter names? Or should I just stick with my abbreviations?

I read somewhere about this problem in the help years ago. I think Basis was the example used in different packages GroebinerBasis and Polynomial package and using PackageName:-Basis to avoid the clash with both loaded. But that is more a command level handling.

restart

 

illegal:=proc(x,y,{Point:=[symbol=solidcircle,colour=purple]},{Line:=[colour=green,thickness=2]},{Colour:="Blue"},{Scale:=5},{Print:="y"})

print("1 Point= ",Point);  #I currently use points
print("2 Line= ",Line);   #                 linetype
print("3 Colour=  ",Colour); #              clr     this has nothing to do with plotting colour
print("4 Scale= ",Scale);   #               scl   
print("5 Print= ",Print);   #               prnt
Scale*x/y
end proc

 

proc (x, y, { Colour := "Blue", Line := [colour = green, thickness = 2], Point := [symbol = solidcircle, colour = purple], Print := "y", Scale := 5 }) print("1 Point= ", Point); print("2 Line= ", Line); print("3 Colour=  ", Colour); print("4 Scale= ", Scale); print("5 Print= ", Print); Scale*x/y end proc

(1)

illegal(3,7)

"1 Point= ", [symbol = solidcircle, colour = purple]

 

"2 Line= ", [colour = green, thickness = 2]

 

"3 Colour=  ", "Blue"

 

"4 Scale= ", 5

 

"5 Print= ", "y"

 

15/7

(2)

illegal(3,7,line=[linestyle=dash,colour=black,thickness=4])

"1 Point= ", [symbol = solidcircle, colour = purple]

 

"2 Line= ", [colour = green, thickness = 2]

 

"3 Colour=  ", "Blue"

 

"4 Scale= ", 5

 

"5 Print= ", "y"

 

15/7

(3)
 

 

Download 2024-03-09_Illegal_or_Not.mw

Was experimenting with methods to handle the representation of 3D lines and plotting them. Where I normally use a point and a direction vector to dascribe the line.

With a bit of experimenting I see the element wise operation `+`~  or  `-`~  using prefix notation saves a lot of time converting vector to lists and vice a versa.  Would be interested to know if there are better techniques.

On the plotting side using plot3d Can the colour of the lines be changed individually? Or should I use a different plotting command?

restart

with(plottools):

l:=([2,-3,1],<3,7/9,6>);   # 3d line point + vector

P:=[7,-8,9]

l := [2, `&ndash;`(3), 1], Vector(3, {(1) = 3, (2) = 7/9, (3) = 6})

 

[7, -8, 9]

(1)

pl:=`+`~(lambda*l[2],l[1]); #3d line as vector eqn

 

Vector(3, {(1) = 3*lambda+2, (2) = (7/9)*lambda-3, (3) = 6*lambda+1})

(2)

vnl:=`-`~(pl,P) ; #vector from Point P to 3D line

 

Vector(3, {(1) = 3*lambda-5, (2) = (7/9)*lambda+5, (3) = 6*lambda-8})

(3)

vnl.l[2] assuming `real` ; #dot product of vectors= 0 when perpendicular

 

(3694/81)*lambda-532/9

(4)

sol:=solve( { (4) }, [lambda] )[];

[lambda = 2394/1847]

(5)

intP:=eval(pl,sol)  #intersection point

Vector(3, {(1) = 10876/1847, (2) = -3679/1847, (3) = 16211/1847})

(6)

l2:=P,eval(vnl,sol) ;  #perpendicular 3D line through P

l2 := [7, `&ndash;`(8), 9], Vector(3, {(1) = -2053/1847, (2) = 11097/1847, (3) = -412/1847})

(7)

pl2:=`+`~(lambda*l2[2],l2[1]); #3D line as vector eqn

Vector(3, {(1) = -(2053/1847)*lambda+7, (2) = (11097/1847)*lambda-8, (3) = -(412/1847)*lambda+9})

(8)

plots:-display(plot3d([pl,pl2],lambda=-.5..1.8,thickness=0,colour=[orange,purple],axes=normal,scaling=constrained),
                point(P,colour=blue ,symbolsize=15,symbol=solidsphere),
                point(l[1],colour=green ,symbolsize=15,symbol=solidsphere),
                point(eval(pl,sol),colour=red ,symbolsize=15,symbol=solidsphere),
                arrow(l,0.2, 0.4, 0.1,colour=green),
                arrow(l2,0.2, 0.4, 0.1,colour=blue));

 

  

 


 

Download Perpendicular_3D_lines.mw

I am trying to replace thickness = 0 with thickness = 3 in a list, under the condition leader = 0 

The order of entries in the list is not fixed so it is more akin to a set.

leader:=1;

parms:=[colour=red,thickness=0,linestyle =dash];
 if leader=0 then selectremove(thickness=0,parms);end if;
[op(parms),thickness=3];
display(plottools:-line([1,2], [3,4]),op(parms));
First 8 9 10 11 12 13 14 Last Page 10 of 35