Items tagged with set set Tagged Items Feed

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.

 

Dear all,

Please help in this question.

 

Using   I want to plot in R^3, the set of point u[i,j]^k . This point has as cordinate  (x[i],y[j],t[k]).

x := i -> (1/5)*i;  #  x[i] the x-coordinate
y := j -> (1/5)*j; # y[j] the y-coordinate
t := k -> (1/5)*k;  #  t[k] the t-coordinate

The name of point is u[i,j]^k

How can I  plot all the point.


 with(geom3d):

point(u[i,j]^k, x(i),y(j),t(k));

 

Thank you.

 

 

Is it possible to set maple to fill in a header or footer for every new document I make?

Now i have to do it fot each new file by hand: 

View => Header footer ..=> 

 - select custom  - goto tab cusom headers put in the left textfield "&[File] pag. &[Page]/&[Pages]"

m:=proc(n::list)
local N, S, i:
N:=nops(n);
S:={};
for i from 1 to N do
if n[i]=1 then do
S:=S union {i}; break; od; fi; od;
for i from 1 to N do
if n[i]=0 then do
S:=S union {}; break; od; fi; od;
end proc;

 

the procedure works if the last member of a list is 0, for example 

m(1,0,1,0); 

returns {1,3}

 

but if it ends in 1, nothing gets returned, example: m(1,0,1);

I can also get it to work the other way around, where it'll return the set if the list ends in 1 but not zero. I need it to work for both.

Please look at the following set.

restart; Z := {x1*(h1+h3) = 0, b1*x1+b4*x3 = 0, f2*x2+f3*x1 = 0, g2*x2+g4*x3 = 0, d1*x1+d2*x2+d4*x3 = 0}; for i to numelems(Z) do print(Z[i]) end do; "++++++++++++++++"; h3 := -h1; x3 := x2; g2 := -g4; Z; print("The following loop gives wrong result! The last element d1*x1+d2*x2+d4*x2=0 of set Z have disappeared!"); for i to numelems(Z) do print(Z[i]) end do

{x1*(h1+h3) = 0, b1*x1+b4*x3 = 0, f2*x2+f3*x1 = 0, g2*x2+g4*x3 = 0, d1*x1+d2*x2+d4*x3 = 0}

 

x1*(h1+h3) = 0

 

b1*x1+b4*x3 = 0

 

f2*x2+f3*x1 = 0

 

g2*x2+g4*x3 = 0

 

d1*x1+d2*x2+d4*x3 = 0

 

"++++++++++++++++"

 

{0 = 0, b1*x1+b4*x2 = 0, f2*x2+f3*x1 = 0, d1*x1+d2*x2+d4*x2 = 0}

 

"The following loop gives wrong result! The last element d1*x1+d2*x2+d4*x2=0 of set Z have disappeared!"

 

0 = 0

 

b1*x1+b4*x2 = 0

 

f2*x2+f3*x1 = 0

 

0 = 0

(1)

``

``

Why?

Download Set.mw

Can we define/set a range in Maple. e.g 


I have the following equation:

y = 1.048 + 1.02*x + 6.118*(z-4.041*x^2) + 16.22*(z^2) +6.241* (x*z)

The value of z is within 0.001 - 0.543, y is from 1 - 12 and x is from 0.001 - 0.7

How should I define it in Maple, so while solving equations it read the values within the given range? 


I am trying to solve a set of equations for a Fluid dynamics problem and I cannot get a result...Any ideas why?

rho := 1.184;
nu := 1.562*10^(-5);
ID := .15;
L := 24.5;
Kl := 12.69;
Ho := 50.52;
a := 2.1*10^(-5);
E := 0.1e-2; alpha := 1.05;

sys := {Re = ID*V/nu, hl = (f*L/ID+Kl)*V^2/(2*9.81), Vflow = (1/4)*Pi*ID^2*V, Hrequired = alpha*V^2/(2*9.81)+hl, Hrequired = -a*Vflow^2+Ho, 1/sqrt(f) = -1.8*log[10](6.9/Re+(E/(3.7))^1.11)};

solve(sys*{Re, V, f, hl, Vflow, Hrequired});
%;
Error, (in unknown) invalid input: Utilities:-SetEquations expects its 2nd argument, equations, to be of type set({boolean, algebraic, relation}), but received {{Re = (9603072983/1000000)*V, hl = (5096839959/100000000000)*((1633333333/10000000)*f+1269/100)*V^2, Vflow = (9/1600)*Pi*V, Hrequired = (5351681957/100000000000)*V^2+hl, Hrequired = -(21/1000000)*Vflow^2+1263/25, 1/f^(1/2) = -(9/5)*ln((69/10)/Re+27367561/250000000000)/ln(10)}}

 

Hi there!

Maple has lot's of datatypes which are very related to each other, such as Matrices and Arrays, or sets, lists and vectors.

Most of the time I am not quite sure which type is the "right" one to use for me, and I guess for most of the stuff I have done so far it didn't really matter. However now I am going a bit into numerics, and there things can get big and computationally expensive. Also, recently I got an error message stating that I would assign a large list to a variable, and should rather use an Array instead. So I guess I should start to bother what to use. : )

Obviously the Matrix has some advantages to the Array in the sense that I can perform matrix calculations with it easier using the LinearAlgebra package. So it can be transposed and what not. But is it disadvantegeous to the Array in any way, especially when it comes to large matrices in numerical calculations?

The same would interest me for sets, lists and Vectors.

Cheers!

Gernot

1 2 3 4 Page 1 of 4