Items tagged with set set Tagged Items Feed

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! 

I have a large system of non-linear equations. Is there any way to get Maple to remove the duplicate equations in the system? For example Maple doesn't recognise that x-y =0 is equal to y-x=0. 

I have a set, R consisting of 9 elements:

R = {A_1, A_2, A_3, A_4, B_1, B_2, B_3, B_4, C_1}

where
B_1 = A_1 + A_2,
B_2 = A_1 + A_3,
B_3 = A_3 + A_4,
B_4 = A_2 + A_4,
C_1 = A_1 + A_2 + A_3 + A_4.

I want to know how to do 2 things:
1) For each element x in R I want x to become x_1, x_2, and x_3 (where x_3 = x_2 + x_1). So for example:
A_1 will become A_11, A_12, A_13 (where A_13 = A_11 + A_12). This should create a total of 27 elements (since each of the 9 elements splits into 3). I want all 27 elements to go into a new set called S_1.
2) The second thing I want is a procedure that takes x in S_1 and y in S_1 and computes z=(x+y)mod2. If z is not already an element of S_1 then put it into a new set S_2. This procedure should terminate when all the possible additions of x and y have been computed. I know that S_2 will contain 162 elements (all of which are different from the 27 elements in S_1). Then I want the procedure to take x in S_1 and y in S_2 and do the same thing: z=(x+y)mod2, where new elements not in S_1 or S_2 will be placed in S_3. Then again repeat this: x in S_1 and y in S_r until no new sets S_{r+1} can be created (i.e. S_{r+1} is empty because no new possible elements exist).

******************************************where d1 to d45 -kappa and chi are constant**********

dsys4 := {d1*h1(theta)+d2*(diff(h1(theta), theta, theta))+d3*(diff(h2(theta), theta))+d4*(diff(h2(theta), theta, theta, theta))+d5*h3(theta)+d6*(diff(h3(theta), theta, theta))+d7*(diff(h1(theta), theta, theta, theta, theta)) = 0, d8*h2(theta)+d9*(diff(h2(theta), theta, theta, theta, theta))+d10*(diff(h2(theta), theta, theta))+d11*(diff(h1(theta), theta))+d12*(diff(h1(theta), theta, theta, theta))+d13*(diff(h3(theta), theta))+d14*(diff(h3(theta), theta, theta, theta)) = 0, h3(theta)^5*(d16+ln(h3(theta))^2*d15+2*ln(h3(theta))*d17)+(diff(h3(theta), theta, theta))*h3(theta)^4*(d19+ln(h3(theta))^2*d18+2*ln(h3(theta))*d20)+(diff(h3(theta), theta, theta, theta, theta))*h3(theta)^4*(d22+ln(h3(theta))^2*d21+2*ln(h3(theta))*d23)+h1(theta)*h3(theta)^4*(d25+ln(h3(theta))^2*d24+2*ln(h3(theta))*d26)+(diff(h1(theta), theta, theta))*h3(theta)^4*(d28+ln(h3(theta))^2*d27+2*ln(h3(theta))*d29)+(diff(h2(theta), theta))*h3(theta)^4*(d31+ln(h3(theta))^2*d30+2*ln(h3(theta))*d32)+(diff(h2(theta), theta, theta, theta))*h3(theta)^4*(d34+ln(h3(theta))^2*d33+2*ln(h3(theta))*d35)+h3(theta)^4*(d37+ln(h3(theta))^2*d36+2*ln(h3(theta))*d38)+h3(theta)^4*(diff(h2(theta), theta, theta, theta, theta, theta, theta))*(d40+ln(h3(theta))^2*d39+2*ln(h3(theta))*d41)-beta*h3(theta)^3*d42-chi*ln(h3(theta))^2*d43/kappa-chi*d45/kappa-2*chi*ln(h3(theta))*d44/kappa = 0, h1(0) = 0, h1(1) = 0, h2(0) = 0, h2(1) = 0, h3(0) = 1, h3(1) = 1, ((D@@1)(h1))(0) = 0, ((D@@1)(h1))(1) = 0, ((D@@1)(h2))(0) = 0, ((D@@1)(h2))(1) = 0, ((D@@1)(h3))(0) = 0, ((D@@1)(h3))(1) = 0, ((D@@2)(h3))(0) = 0, ((D@@2)(h3))(1) = 0}; dsol6 := dsolve(dsys4, 'maxmesh' = 600, numeric, output = listprocedure)

 

hi.i encountered this erroe  [Error, (in dsolve/numeric/bvp/convertsys) unable to convert to an explicit first-order system] with solving set of differential equation.please help me.thanks a lot  

dsys3 := {`1`*h1(theta)+`1`*(diff(h1(theta), theta, theta))+`1`*(diff(h2(theta), theta))+`1`*(diff(h2(theta), theta, theta, theta))+`1`*h3(theta)+`1`*(diff(h3(theta), theta, theta))+`1`*(diff(h1(theta), theta, theta, theta, theta)) = 0, `1`*h2(theta)+`1`*(diff(h2(theta), theta, theta, theta, theta))+`1`*(diff(h2(theta), theta, theta))+`1`*(diff(h1(theta), theta))+`1`*(diff(h1(theta), theta, theta, theta))+`1`*(diff(h3(theta), theta))+`1`*(diff(h3(theta), theta, theta, theta)) = 0, h3(theta)^5*(`1`+ln(h3(theta))^2*`1`+2*ln(h3(theta))*`1`)+(diff(h3(theta), theta, theta))*h3(theta)^4*(`1`+ln(h3(theta))^2*`1`+2*ln(h3(theta))*`1`)+(diff(h3(theta), theta, theta, theta, theta))*h3(theta)^4*(`1`+ln(h3(theta))^2*`1`+2*ln(h3(theta))*`1`)+h1(theta)*h3(theta)^4*(`1`+ln(h3(theta))^2*`1`+2*ln(h3(theta))*`1`)+(diff(h1(theta), theta, theta))*h3(theta)^4*(`1`+ln(h3(theta))^2*`1`+2*ln(h3(theta))*`1`)+(diff(h2(theta), theta))*h3(theta)^4*(`1`+ln(h3(theta))^2*`1`+2*ln(h3(theta))*`1`)+(diff(h2(theta), theta, theta, theta))*h3(theta)^4*(`1`+ln(h3(theta))^2*`1`+2*ln(h3(theta))*`1`)+h3(theta)^4*(`1`+ln(h3(theta))^2*`1`+2*ln(h3(theta))*`1`)+h3(theta)^4*(diff(h2(theta), theta, theta, theta, theta, theta, theta))*(`1`+ln(h3(theta))^2*`1`+2*ln(h3(theta))*`1`)-beta*h3(theta)^3*`1`-chi*ln(h3(theta))^2*`1`/kappa-chi*`1`/kappa-2*chi*ln(h3(theta))*`1`/kappa = 0, h1(0) = 0, h1(1) = 0, h2(0) = 0, h2(1) = 0, h3(0) = 1, h3(1) = 1, ((D@@1)(h1))(0) = 0, ((D@@1)(h1))(1) = 0, ((D@@1)(h2))(0) = 0, ((D@@1)(h2))(1) = 0, ((D@@1)(h3))(0) = 0, ((D@@1)(h3))(1) = 0, ((D@@2)(h3))(0) = 0, ((D@@2)(h3))(1) = 0}; dsol5 := dsolve(dsys3, 'maxmesh' = 600, numeric, output = listprocedure);
%;
Error, (in dsolve/numeric/bvp/convertsys) unable to convert to an explicit first-order system

 

We know that the set f:={(1,2),(2,a),(3,b)} can introduce a function from {1,2,3} to {2,a,b}. I want Maple to know f as a function. Is this job possible at Maple? I thought to find the Cartesian product of above latter sets and then try to select "f" as one of its subset but this did not help me to force Maple to take "f" as a function. Indeed, I want to work with this kind of function (like plotting and doing f+g, f-g, fog for two functions for example).

Thanks for your time and help.

 

1 2 3 4 Page 1 of 4