## 1162 Reputation

12 years, 158 days

## Proc. Tabulate return results but keep a...

Maple 2024

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]
 (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]
 (2)
 > dspformat:=(BB,columns)->DocumentTools:-Tabulate([columns,[BB]],width=75);
 (3)
 > CC:=dspformat(BB,columns):#layout not as expected
 > CC[1] ; #  just gives  letters from Tabulate
 (4)
 >

## How to get Help Overview to top of listi...

Maple 2024

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.

 (1)

 (2)

 (3)

 (4)

 (5)

 (6)

## Optional parameter naming...

Maple 2023

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
 >
 (1)
 > illegal(3,7)
 (2)
 > illegal(3,7,line=[linestyle=dash,colour=black,thickness=4])
 (3)

## Handling lists and vectors for 3D lines....

Maple 2023

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]
 (1)
 > pl:=`+`~(lambda*l[2],l[1]); #3d line as vector eqn
 >
 (2)
 > vnl:=`-`~(pl,P) ; #vector from Point P to 3D line
 >
 (3)
 > vnl.l[2] assuming `real` ; #dot product of vectors= 0 when perpendicular
 >
 (4)
 > sol:=solve( { (4) }, [lambda] )[];
 (5)
 > intP:=eval(pl,sol)  #intersection point
 (6)
 > l2:=P,eval(vnl,sol) ;  #perpendicular 3D line through P
 (7)
 > pl2:=`+`~(lambda*l2[2],l2[1]); #3D line as vector eqn
 (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));
 >
 >

## How to replace a specific list/set entry...

Maple 2023

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];