Items tagged with set set Tagged Items Feed

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.

Hello!

I would like to start with the following set of 9 elements,
A = { E11, E12, E21, E22, E11+E12, E11+E21, E12+E22, E21+E22, E11+E12+E21+E22 }.

I need a procedure that takes each of those elements and creates 3 new ones in the following way: Eij becomes Eij1, Eij2, Eij1+Eij2. So for example, E11 will become: E111, E112, and E111+E112. And for example the fifth element in A (i.e. E11+E12) will become the 3 new elements: E111+E121, E112+E122, and E111+E121 + E112+E122.

Since each of the 9 elements gets triplicated, there will be a new set, call it B, with 27 elements.

B = {E111, E112, E111+E112, E121, E122, E121+E122, ... }

Now I want to repeat this process of triplicating again so that, for example, E111 becomes: E1111, E1112, and E1111+E1112. And so on. This new set C will have 81 elements. Now I want to repeat this one last time. The final set, D, will have 243 (3^5) elements. 

Step 2: 

For every pair of elements x and y in D, I want to compute z:=(x+y)mod2. If z already belongs to D, discard it, otherwise, place z in the set D2. Do this until there are no more elements to add together (note that if x+y is computed then I don't want y+x to be computed also--that's inefficient). Maybe the most efficient way is to perform all possibly combinations of x+y mod 2 to create the set D2 and then just go: D2 setminus D.

Step 3: For x in D and y in D2 perform all possible combinations of z:=(x+y)mod2 and place these in D3 then perform set subtraction again: D3 minus D2 minus D.

Repeat this process again: x in D and y in D3 to create new elements in D4. Repeat again until Dm is empty (that is, D(m-1) will be the last set that contains new elements). I'm expecting around 12 sets... 

The issue with this whole algorithm is that I often run out of memory so I need a clever way to do this, since this algorithm is essentially classifying 2^32 elements into disjoint sets. Thank you! 

1 2 3 4 5 Page 1 of 5