Ronan

1267 Reputation

14 Badges

12 years, 276 days
East Grinstead, United Kingdom

MaplePrimes Activity


These are questions asked by Ronan

What on earth am I doing wrong here? I am trying to check if two vectors are equal for parallelism.Yes, thinking about it I could use CrossProduct but that is the same problem because I would be checking if that new vector =<0,0,0>

l1:=<a,b,c>:l2:=<a,b,c>:
if l1 = l2 then 
print("Equal Vectors");
end if;

I have and input parameter to a procedure called shift:=05. It sets the position of test between to points.

this particular procedure has two potential sets of text one in Q and the other in vec.
Can Q and vec have the own individual values for shift?

I have shown the input to the procedure and what it outputs. The procedure itself to too long and akward to the post.

Also given is the input definiton of the procedure and how I could possibly find a shift in a list.

 

restart

#with( RationalTrigonometry)

P1:=[-1,3]:P2:=[4,5]:

# shift operates as such mp:=P1+shift*(P2-P1). It's default value 0.5 It moves
#   the text along between P1 and P2
# shift and shift are optional inputs to move individual test pieces.
#If Q contains shift then use it else use shift
  qp:=P1+shift*(P2-P1) or qp:=P1+shift*(P2-P1)
#Similarily for vec

Qdim([P1,typeset("P1=",P1),align=[left],colour=red] ,
     [P2,typeset("P2=",P2),align=[right],colour=purple] ,
      Q=[Q_12,align =[below,right],shift=0.6] ,
      point=[symbolsize=12,symbol=solidcircle,colour=blue,shift=0.4] ,
      vec=[typeset("v[12]=",P2-P1),align=[below,right],shift=0.1],
      shift=0.7):  

#The definition input of the procedure is

 

#proc(P1, P2,
#    {Q:=[ NULL,:-align={':-left'}]},
#        {corp::{"cart","proj"}:="cart"},
#        {shift:=0.5},
#        {vec::list:=[]},
#        {scale::{list,integer}:=1},
#        {leader::{-1,0,1}:= 1},
#        {dimoffset::{1/6,1/5,1/4,3/4,2/3,1/2,1/3,1,3/2,2,3,4,5,6}:=1},
#        {point::list:=['color' = ':-blue', symbol = ':-solidcircle', 'symbolsize' = 8]},
#        {line::list:=['thickness'=3]},
#        {plopts::list:=[]})

restart

Q:=[Q_12,shift=0.6,align =[below,right]]  
      
      

 

[Q_12, shift = .6, align = [below, right]]

(1)

nops(Q)

3

(2)

for i to nops(Q) do
 if has([op(Q[i])],`shift`) then
 qp:=rhs(Q[i]);
 print(i,qp);
 break;
end if;
end do;

2, .6

(3)

 


 

Download 2024-09-18_Select_name_and_Value_from_List.mw

I trying to simplify expressions for lines so no higher order terms. factor and op seperate out what I need but how do I select the one with the variables in this case x,y. I cant depent on this always been the last one returned from the op command.

restart

 

vars=[x,y]

vars = [x, y]

(1)

k:=17

17

(2)

expr:=-2*sqrt(118)*(((-4*x + y + 51/32)*sqrt(k) + (k*x)/4 - (51*y)/4 + 153/32)*sqrt(-4012 + 1003*sqrt(k)) + ((x + 4*y)*sqrt(k) - (85*x)/4 - (17*y)/4)*sqrt(4012 + 1003*sqrt(k)))*k^(1/4)/(17051*(-1 + sqrt(k)))

-2*118^(1/2)*(((-4*x+y+51/32)*17^(1/2)+(17/4)*x-(51/4)*y+153/32)*(-4012+1003*17^(1/2))^(1/2)+((x+4*y)*17^(1/2)-(85/4)*x-(17/4)*y)*(4012+1003*17^(1/2))^(1/2))*17^(1/4)/(-17051+17051*17^(1/2))

(3)

indets(expr)

{x, y}

(4)

factor(expr)

(1/64192)*(-4012+1003*17^(1/2))^(1/2)*118^(1/2)*17^(1/4)*(17^(1/2)+5)*(40*x-24*y-3)

(5)

op(factor(expr))

1/64192, (-4012+1003*17^(1/2))^(1/2), 118^(1/2), 17^(1/4), 17^(1/2)+5, 40*x-24*y-3

(6)

select(has,vars, factor(expr))

select(has,vars, op(factor(expr)))

Error, invalid input: has expects 2 arguments, but received 7

 
 

 

Download 2024-09-11_Has_Select_Question.mw

I need to automatically extend or truncate a colour list to suit number of points in plottools:-point plot.
extending the list the colour sequence could be repeated or if the is too awkard just add black.
I can't figure out how to select the list of colours to put into a new list to modify.

This will be inside a plotting procedure.

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)

L:=[[1,2],[3,4],[-5,6],[-3,-2]]

[[1, 2], [3, 4], [-5, 6], [-3, -2]]

(2)

qty:=nops(L)

4

(3)

styles:=[symbol=solidcircle,colour=[red,green,blue,orange],symbolsize=12]

[symbol = solidcircle, colour = [red, green, blue, orange], symbolsize = 12]

(4)

 

plots:-display(plottools:-point(L,styles[]))

 

#Need to extend or truncate the list of colours to match the number of points
#styles can be copied to styles 1,2 etc
#the extended list would be a repeatition of the colour sequence given
#would need to look for color or colour;

has(styles,colour); #how to select colour our into a seperate list?

true

(5)

#too few point for the colours;
L1:=[[1,2],[3,4],[-5,6]]

[[1, 2], [3, 4], [-5, 6]]

(6)

plots:-display(plottools:-point(L1,styles[]))

Error, (in Plot:-Structure:-Points) number of colors must match number of points

 

#too many point for the colours;
L2:=[[1,2],[3,4],[-5,6],[-3,-2],[6-1],[0,1]]

[[1, 2], [3, 4], [-5, 6], [-3, -2], [5], [0, 1]]

(7)

plots:-display(plottools:-point(L2,styles[]))

Error, (in plottools:-point) incorrect arguments for creating points structure, try providing the dimension option

 
 

 

Download 2024-09-06_Q_Extend_or_Truncate_List_of_Colours.mw

If there any way to make text  parallel to a line in textplot3d.

display(line([1,2,3],[4,5,-2],linestyle=longdash),
        point([2.5,3.5,0.5]),
        textplot3d([2.5,3.5,0.5,"not aligned"]))
1 2 3 4 5 6 7 Last Page 2 of 33