Items tagged with set set Tagged Items Feed

I'm currently working on building a Grid Layout for a project, and I'm having trouble coding in the RunWindow and GetFile elements into buttons under the grid layout. I've gone through the overviews and examples for them, but had no luck. I'm using Maple 2016.1 for OS X.

Additionally, the structure of the code is slightly different as to how many of the example worksheets structure their Grid Layout code, since the code originated from a Maplet Builder file. I.e. in the example worksheets they would follow as:

maplet := Maplet('onstartup' = 'Action1', 'reference' = 'Maplet1',
         BoxLayout('background' = "#D6D3CE", 'border' = 'false', 'halign' = 'center', 'inset' = '5', 'reference' = 'BoxLayout1', 'valign' = 'center', 'vertical' = 'false', 'visible' = 'true',
                       BoxColumn( BoxCell('hscroll' = 'never', 'value' = 'Button1', 'vscroll' = 'never'),
         GridLayout('background' = "#D6D3CE", 'border' = 'false','halign'='center','inset'='5', 'reference' = 'GridLayout1', 'valign' = 'center', 'visible' = 'true',
                   GridRow('valign' = 'top', GridCell('height' = '1', 'hscroll' = 'never', 'value' = 'BoxLayout1', 'vscroll' = 'never', 'width' = '1' ))),
         Window('layout'= 'GridLayout1', 'reference' = 'W1', 'resizable' = 'true', 'title' = "Maplet"),
          Action('reference' = 'Action1', RunWindow('window'= 'W1'))

However the structure for the code I am working with has action at the very start of the code, follwed by the the code for the buttons then layouts/window.  E.g. (the code has been shortened)

with (Maplets[Elements]):
maplet :=
Maplet('onstartup'='Action1','reference'='Maplet1',
Action('reference'='clickButton1'),
Action('reference'='clickButton9',
Evaluate('function'='plot3d(x^2*cos(y),x = -1 .. 1,y = -2*Pi .. 2*Pi)','target'='Plotter1','waitforresult'='true')),
Action('reference'='clickButton11'),
Action('reference'='clickButton12'),
Action('reference'='clickButton10'),
Button('background'="#D6D3CE",'caption'="Insert Molecular Geometry",'enabled'='true','foreground'="#000000",'onclick'='clickButton1','reference'='Button1','visible'='true'),

....

BoxLayout('background'="#D6D3CE",'border'='false','halign'='center','inset'='5','reference'='BoxLayout1','valign'='center','vertical'='false','visible'='true',
BoxColumn(
BoxCell('hscroll'='never','value'='Button1','vscroll'='never'),
BoxCell('hscroll'='never','value'='BoxLayout2','vscroll'='never'),
BoxCell('hscroll'='never','value'='BoxLayout3','vscroll'='never'),
BoxCell('hscroll'='never','value'='BoxLayout9','vscroll'='never'),
BoxCell('hscroll'='never','value'='BoxLayout14','vscroll'='never')),
BoxColumn(
BoxCell('hscroll'='never','value'='Label3','vscroll'='never'),
BoxCell('hscroll'='never','value'='Plotter1','vscroll'='never'),
BoxCell('hscroll'='never','value'='Slider1','vscroll'='never'))),
GridLayout('background'="#D6D3CE",'border'='false','halign'='center','inset'='5','reference'='GridLayout1','valign'='center','visible'='true',
GridRow('valign'='top',
GridCell('height'='1','hscroll'='never','value'='BoxLayout1','vscroll'='never','width'='1'))),
Window('layout'='GridLayout1','reference'='Window1','resizable'='true','title'="Maplet"),
Action('reference'='Action1',
RunWindow('window'='Window1'))):

Maplets[Display](maplet);

 

If anyone would be able to provide an example of code or some guidance I could follow that would be greatly appreciated! 

Hello,

 

I tried to rearrange below set of equations to have the equations in term of P[0], P[1], P[2], P[3], P[4], P[5] and P[6]. I used the symbol := for function definition for all Ps except one of them. Thus maple will rearrange that excepted one. However, I got error massage stating "Error, (in P[3]) too many levels of recursion" when I tried to rearranged equations for P[0].

Can I get help to rearranged them. 

P[0](s) = (P[1](s)*mu[1]+P[2](s)*mu[2]+1)/(s+3*lambda+3*sigma)

P[1](s) = (3*P[0](s)*lambda+3*P[3](s)*mu[1]+P[4](s)*mu[2])/(s+mu[1]+2*lambda+2*sigma)

P[2](s) = (3*P[0](s)*sigma+P[4](s)*mu[2]+P[3](s)*mu[1])/(s+mu[2]+2*lambda+2*sigma)

P[3](s) = 2*lambda(P[1](s)+P[2](s))/(s+2*mu[1]+lambda)

P[4](s) = 2*sigma(P[1](s)+P[2](s))/(s+2*mu[2]+sigma)

P[5](s) = lambda(P[3](s)+P[4](s))/s

P[6](s) = sigma(P[3](s)+P[4](s))/s

Thank you for your help

Is there any Maple command for computing the product of two set A and B?

For example if A={a,b,c} and B={x,y} then we have A*B={ax,ay,bx,by,cx,cy}.

though swap can do this,

hope to know a simple way to shift a list or set to the left in cycle in maple

for example

1,2,3

2,3,1

3,1,2

Hi,

 

  Suppose I have an array

A[1]:=a;

A[2]:=b;

A[3]:=c;

 

  I would like to check if an element, e.g. "c", belong to this array. I can contrsuct a "for... end do" command to compare each element and/or construct a subroutine. 

 

  Is there any build-in function in maple can do that? Perferably return true/false

 

Thank you!

I know how we can add a member to a mathematical set ,for example :

C := NULL;

C := C, V, B, X;

print(C)

V, B, X

but, my problem is that how we can subtract a member from the defined set ?

 

 

Thanks,

 

assume x,y is a real number and {x>4,y>4}, how can i get the supplementary set ({x<=4,y<=4}) of x,y in the real domain by maple?

eq:=[Vector[row](4, {(1) = 0., (2) = 0., (3) = 0., (4) = 0.}), Vector[row](4, {(1) = -0.3381778526e-2, (2) = -.3381778526, (3) = -.3185010532, (4) = 0.}), Vector[row](4, {(1) = 0., (2) = 0., (3) = 0., (4) = 0.}), Vector[row](4, {(1) = 0., (2) = 0., (3) = 0., (4) = 0.}), Vector[row](4, {(1) = 0., (2) = 0., (3) = 0., (4) = 0.})]

how i can get a unique results:[Vector[row](4, {(1) = 0., (2) = 0., (3) = 0., (4) = 0.}), Vector[row](4, {(1) = -0.3381778526e-2, (2) = -.3381778526, (3) = -.3185010532, (4) = 0.})]

 

The work contains two procedures called  SetPartition  and  NumbPart .

The first procedure  SetPartition  generates all the partitions of a set  S  into disjoint subsets of specific sizes defined by a list  Q. The third optional parameter is the symbol  `ordered`  or  `nonordered`  (by default) . It determines whether the order of subsets in a partition is significant.

The second procedure  NumbPart  returns the number of all partitions of the sizes indicated by  Q .

 

Codes of these procedures:

SetPartition:=proc(S::set, Q::list(posint), K::symbol:=nonordered)  # Procedure finds all partitions of the set  S  into subsets of the specific size given Q.

local L, P, T, S1, S2, n, i, j, m, k, M;

uses ListTools,combinat;

if `+`(op(Q))<>nops(S) then error "Should be `+`(op(Q))=nops(S)" fi;

L:=convert(Q,set);

T:=[seq([L[i],Occurrences(L[i],Q)], i=1..nops(L))];

P:=`if`(K=ordered,convert(T,list),convert(T,set));

S1:=S;  S2:={`if`(K=ordered,[],{})}; n:=nops(P);

for i to n do

m:=P[i,1]; k:=P[i,2];

for j to k do

S2:={seq(seq(`if`(K=ordered,[op(s),t],{op(s),t}), t=choose(S1 minus `union`(op(s)),m)), s=S2)};

od; od;

if K=ordered then {map(op@permute,S2)[]} else S2 fi;

end proc:

 

NumbPart:=proc(Q::list(posint), K::symbol:=nonordered)  # Procedure finds the number of all partitions of a set into subsets of the specific size given  Q

local L, T, P, n, S, N;

uses ListTools;

L:=convert(Q,set);

T:=[seq([L[i],Occurrences(L[i],Q)], i=1..nops(L))];

P:=`if`(K=ordered,convert(T,list),convert(T,set));

n:=nops(P);  N:=add(P[i,2], i=1..n);

S:=add(P[i,1]*P[i,2],i=1..n)!/mul(P[i,1]!^P[i,2],i=1..n)/mul(P[i,2]!,i=1..n);

if K=nonordered then return S else  S*N! fi;

end proc:

 

Examples of use:

SetPartition({a,b,c,d,e}, [1,1,3]);  nops(%);  # Nonordered partitions and their number

SetPartition({a,b,c,d,e}, [1,1,3], ordered);  nops(%);  # Ordered partitions and their number

 

 

Here's a more interesting example. 5 fruits  {apple, pear, orange, mango, peach}  must be put on three plates so that  on each of two plates there are 2  fruits, and there is one fruit  on one plate. Two variants to solve: 1) plates are indistinguishable and 2) different plates. In how many ways can this be done?

SetPartition({apple,pear,orange,mango,peach}, [1,2,2]);  nops(%);  # plates are indistinguishable

 

NumbPart([1,2,2], ordered);  # Number of ways for  different plates

                                                              90

 

Another example - how many ways can be divided  100 objects into 10 equal parts?

NumbPart([10$10]);

    64954656894649578274066349293466217242333450230560675312538868633528911487364888307200

 

 SetPartition.mws

I paste below a simple code illustrating what I want to create: two lists from a set with pairs. I wonder it is a very simple task but I my lists aren't create in the end. 

 

 

> restart;
>
> lista:=[[1,10],[2,20],[3,30]]:
> x:=[]:
> y:=[]:
>
> for i from 1 to nops(lista) do
>     for j from 1 to 2 do
>
>         if j = 1 then
>             x[i,j]:=op(1,op(i,lista));
>        fi;
>        if j = 2 then
>             y[i,j]:=op(2,op(i,lista));
>       fi;
>    od;
> od;
>
> x;
> y;

 

 

In resume then after the for loop is terminated I want to be left with two lists:

x:= [1,2,3] and y:=[10,20,30]. I'm sure it has a quick fix but I'm stuck and would appreciate any help/advice.  

Thanks in advance!

I tried

nops({x, y, z,1+x, 2+y, -3+z,-2+x, 3+y, -1+z });

and Maple out 9.

If x = 1, y = 2, z = 3, we have

nops({1, 2, 3, 2, 4, 0, -1, 5, 2});

equal to 7.

Edit.

I edited my question. The word "list" into "set".

My question means, there is a triple (x, y, z) = (1, 2, 3) so that the number of element of the set {x, y, z,1+x, 2+y, -3+z,-2+x, 3+y, -1+z } is 7, not 9. Why we can confirm the number of elements of the set {x, y, z, 1+x, 2+y, -3+z,-2+x, 3+y, -1+z } is 9? And, how must select the integer numbers x, y, z (0 < x <10, 0< y <10, 0< z < 10) so that the number of elements of the set {x, y, z, 1+x, 2+y, -3+z,-2+x, 3+y, -1+z } is 9?

I tried

restart:

ListTools[Categorize]:

L:=[]:

for x from -2 to 5  do

for y from -2 to 5  do

for z from -2 to 5  do

a:=[x,y,z]:

b:=[1+x,2+y,-3+z]:

c:=[-2+x,3+y,-1+z]:

if op(1,a)*op(2,a)*op(3,a)*op(1,b)*op(2,b)*op(3,b)*op(1,c)*op(2,c)*op(3,c)<> 0

and op(1,a)<>op(2,a) and  op(1,a)<>op(3,a) and  op(1,a)<>op(2,b) and  op(1,a)<>op(3,b) and  op(1,a)<>op(2,c) and  op(1,a)<>op(3,c) and op(2,a)<>op(3,a) and op(2,a)<>op(1,b) and

op(2,a)<>op(3,b) and

op(2,a)<>op(1,c) and

op(2,a)<>op(3,c) and

op(3,a)<>op(1,b) and

op(3,a)<>op(2,b) and 

op(3,a)<>op(1,c) and

op(3,a)<>op(2,c) and

op(1,b)<>op(2,b) and

op(1,b)<>op(3,b) and

op(1,b)<>op(2,c) and

op(1,b)<>op(3,c) and

op(2,b)<>op(3,b) and

op(2,b)<>op(1,c) and

op(2,b)<>op(3,c) and

op(3,b)<>op(1,c) and

op(3,b)<>op(2,c) and

op(1,c)<>op(2,c) and

op(1,c)<>op(3,c) and op(2,c)<>op(3,c) then L:=[op(L), {a,b,c}] fi; od: od: od:

nops(L); 

L;

 

 

 

 

I experienced strange operation of "union" for sets of vectors.

Mt1:=Matrix(2, 4, [[ 0,1, 0, 0], [ 0,  0,  1, 1]]); Ms := Vector[column](4, [8,4,2,1]); St1 := {}:

St1:= `union`(St1, {Mt1 . Ms});

I am surprised, because each execution of union adds new and the same vector <4 | 3> to set St1:

1

But after copying any set in the clipboard and pasting the set St1 has only one instance of vector <4 | 3>:

2

What does it mean?

properties of operations on sets?

 

Example:

is((A minus B) intersect (A minus C) = A minus (B union C)) assuming A::set, B::set, C::set;

                                                                  FAIL

So if I have a procedure like 

with(GraphTheory)

tneighbors := proc (G::Graph)

local numvertices::integer, i::integer, currentvertex;

numvertices := nops(Vertices(G));

for i to numvertices do

currentvertex := Vertices(G)[i];

if nops(Neighbors(G, currentvertex)) = 2 then print(currentvertex)

end if;

end do;

end proc;

How do I make it so the output gets returned as a set?

For example, if I do  twoneighbors(G); and get
1

7

4

How do I make it so the output is listed as a set like {1,4,7}? Thanks.

1 2 3 4 5 Page 1 of 5