Items tagged with union

Feed App Center

I want to use union, intersection and minus to find. Help me

При использовании «объединения» нумерация не сохраняется. Непонятно, по каким алгоритмам «объединение» применяется к тому или иному месту. Почему sistema [1] не равно GRAN [1]? Как я могу это исправить?

PS Прошу прощения за грамматические ошибки, английский плохо знаю

1. mws
 

рестарт;

 

 

B:=matrix([[1,        0,        1,        0,        0,        0,        0,        0,        0,        0,        0,        0,        0,        0,        0,        0],
[-1,        -1,        0,        0,        0,        0,        0,        0,        0,        0,        0,        0,        0,        0,        0,        0],
[0,        0,        -1,        0,        -1,        0,        0,        0,        0,        0,        0,        0,        0,        0,        0,        0],
[0,        1,        0,        1,        0,        0,        0,        0,        0,        0,        0,        0,        0,        0,        0,        0],
[0,        0,        0,        0,        1,        1,        0,        1,        0,        0,        0,        0,        0,        0,        0,        0],
[0,        0,        0,        -1,        0,        -1,        -1,        0,        0,        0,        0,        0,        0,        0,        0,        0],
[0,        0,        0,        0,        0,        0,        1,        0,        1,        0,        0,        0,        0,        0,        0,        0],
[0,        0,        0,        0,        0,        0,        0,        -1,        0,        -1,        0,        0,        0,        0,        0,        0],
[0,        0,        0,        0,        0,        0,        0,        0,        -1,        0,        -1,        -1,        0,        0,        0,        0],
[0,        0,        0,        0,        0,        0,        0,        0,        0,        1,        1,        0,        1,        0,        0,        0],
[0,        0,        0,        0,        0,        0,        0,        0,        0,        0,        0,        1,        0,        1,        0,        0],
[0,        0,        0,        0,        0,        0,        0,        0,        0,        0,        0,        0,        -1,        0,        -1,        0],
[0,        0,        0,        0,        0,        0,        0,        0,        0,        0,        0,        0,        0,        -1,        0,        -1],
[0,        0,        0,        0,        0,        0,        0,        0,        0,        0,        0,        0,        0,        0,        1,        1]
]):

E:=16:V:=14;

V: = 14

(1)

G:=2*E; êîëè÷åñòâî ãðàíè÷íûõ óñëîâèé

G: = 32

(2)

l:=[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]:

 

for i to E do
De[i]:=-diff(phi[i](s[i]),s[i]$2)=He*phi[i](s[i]):  Äó âèäà -(diff(phi[i](s[i]), `$`(s[i], 2))) = H[e]*phi[i](s[i])
od:

for i to E do
FSR[i]:=subs(s[i]=x,dsolve(De[i],phi[i](s[i]),output=basis)):  Îáùèå ðåøåíèÿ
od:

for i to E do
OBCHEE_RECHIE[i]:=unapply(C[i+i-1]*FSR[i][2]+C[i+i]*FSR[i][1],x): od:

 

for i to E do
PROIZ:=diff(OBCHEE_RECHIE[i](x),x):
PROIZ_OB_RECH[i]:=unapply(PROIZ,x):od:

 

×òåíèå ìàòðèöû èíöèäåíòíîñòè

i0:=1:i1:=1:z:=1:y:=1:

for i from 1 to V do
 y:=1: z:=1:
  for j from 1 to E do
   if B[i,j]=1 then
    x[z]:=j: z:=z+1:
   fi:

   if B[i,j]=-1 then
    x[y]:=j:
    y:=y+1:
   fi:

  od;

  if z>=2 then
   v0[i0]:=[seq(x[s],s=1..z-1)]:
   i0:=i0+1:
  fi:

  if y>=2 then
   v1[i1]:=[seq(x[s],s=1..y-1)]:
   i1:=i1+1:
  fi:
od:

v0:=convert(v0,list):

v1:=convert(v1,list):

 

Ïîäñ÷åò êîëè÷åñòâà ãðàíè÷íûõ óñëîâèé òèïà f(0)

number0:=0:

for i to i0-1 do
if nops(v0[i])=2 then number0:=number0+2; fi:
if nops(v0[i])=3 then number0:=number0+4; fi:
od:

number0:=number0/2; #êîëè÷åñòâî ãðàíè÷íûõ óñëîâèé òèïà f(0)

number0 := 9

(3)

 

Ïîäñ÷åò êîëè÷åñòâà ãðàíè÷íûõ óñëîâèé òèïà f(1)

number1:=0:

for i to i1-1 do
if nops(v1[i])=2 then number1:=number1+2; fi:
if nops(v1[i])=3 then number1:=number1+4; fi:
od:

number1:=number1/2; #êîëè÷åñòâî ãðàíè÷íûõ óñëîâèé òèïà f(1)

number1 := 9

(4)

 

Êîëè÷åñòâî ãðàíè÷íûõ óñëîâèé ñ ïðîèçâîäíûìè

GP:=i0-1+i1-1;

GP := 14

(5)

 

ÍÓËÅÂÛÅ ÓÑËÎÂÈß

i:=1:

while i<number0+1 do
for j to i0-1 do
if nops(v0[j])=2 then
GRAN[i]:=OBCHEE_RECHIE[v0[j,1]](0)-OBCHEE_RECHIE[v0[j,2]](0)=0;
i:=i+1;
fi;
if nops(v0[j])=3 then
GRAN[i]:=OBCHEE_RECHIE[v0[j,1]](0)-OBCHEE_RECHIE[v0[j,2]](0)=0;
GRAN[i+1]:=OBCHEE_RECHIE[v0[j,2]](0)-OBCHEE_RECHIE[v0[j,3]](0)=0;
i:=i+2;
fi;
od; od;

 

ÅÄÈÍÈ×ÍÛÅ ÓÑËÎÂÈß (ÈËÈ îò l)

i:=number0+1:

while i<number0+number1+1 do
for j to i1-1 do
if nops(v1[j])=2 then
GRAN[i]:=OBCHEE_RECHIE[v1[j,1]](l[v1[j,1]])-OBCHEE_RECHIE[v1[j,2]](l[v1[j,2]])=0;
i:=i+1;
fi;
if nops(v1[j])=3 then
GRAN[i]:=OBCHEE_RECHIE[v1[j,1]](l[v1[j,1]])-OBCHEE_RECHIE[v1[j,2]](l[v1[j,2]])=0;
GRAN[i+1]:=OBCHEE_RECHIE[v1[j,2]](l[v1[j,2]])-OBCHEE_RECHIE[v1[j,3]](l[v1[j,3]])=0;
i:=i+2;
fi;
od; od;

 

ÍÓËÅÂÛÅ ÏÐÎÈÇÂÎÄÍÛÅ

i:=number0+number1+1:

while i<number0+number1+nops(v0) do
 for j to nops(v0) do
  for y from 1 to nops(v0[j]) do
   x[y]:=PROIZ_OB_RECH[v0[j,y]](0);
  od;
  m:='m';
  GRAN[i]:=sum(x[m],m=1..nops(v0[j]));
  i:=i+1;
 od;
od;

 

ÍÅÍÓËÅÂÛÅ ÏÐÎÈÇÂÎÄÍÛÅ

i: = число0 + число1 + nops (v0) +1:

в то время как i <G + 1 сделать
 для j до nops (v1) сделать
  для y от 1 до nops (v1 [j]) сделать
   x [y]: = PROIZ_OB_RECH [v1 [j, y]] (l [v1 [j, y]]);
  od;
  m: = 'm';
  ГРАН [i]: = сумма (x [m], m = 1..nops (v1 [j]));
  я: = я + 1;
 od;
od;

 

 

 

новогодний

sistema: = {}:

новенькие

время: = {}:

 

для я от 2 до G делаю

  sistema: = sistema union {GRAN [i]}:

od:

для я от 2 до G делаю

  peremenie: = peremenie union {C [i]}:

od:

 

коэфф: = решить (система, изменение):

коэфф:

 

система [1];

C[2]*He^(1/2)+C[6]*He^(1/2)

(6)

ГРАН [1];

C[1]-C[5] = 0

(7)

 

urav: = subs (koeff, GRAN [1]):

uravnenie: = collect (numer (lhs (normal (urav))), {He, C [1]}):

uravn: = remove (has,%, C [1]):

uravnenie_sobs_chisla: = evalf (algsubs (He = x, uravn)):

ВЕСЕЛЫЕ: = неприменить (uravnenie_sobs_chisla, x):

 

 

 

 

 

 

 

 

 

 

 

 


 

Скачать 1.mws

 

 

 

Hi, for each region shown in the figure, there is a single point. I want to define the location constraints of the point in each region

e.g. for region 1 and 5, it is easy to define:

R1 := {p_B <= y_1 <= 1, p_l <= x_1 <= epsilon}

R5:={y_5 <= x_5, p_l <= x_5<= epsilon, p_l <= y_5 <= epsilon}

but what about region 2? it seems wrong if I define like this in maple:

R2 := {epsilon <= x_2 <= p_B, p_B <= y_2 <= 1} union {x_2 <= y_2, p_B <= x_2  <= 1, p_B <= y_2 <= 1}

Or it is actually right....

Is there another way in maple to code `union`. I am not confident using this function and was wondering if there was a perhaps longer/different way to do the same thing?

 

Thanks!

Hello,

 

Assume we have the following "intervals" (I am not sure what is its formal name in Maple)

 

C :=[0,1/11],[1/11,1/9],[1/9, 1/7],[1/3,1/2],[1/2,1]

 

How can we get the "union" of these intervals? That is to say, obtain  [0,1/7],[1/3,1] 

 

Many thanks in advance for your comments and suggestions.

 

 

As I work a lot with lists (need to merge them frequently), I would like to redefine the `union` operator in such a way that it will merge two lists together. It would makes thing more efficient than writing 

list1 := [a,b,c];
list2 := [d,e,f];

newlist = [op(list1), op(list2)];

I've already tried

`&union` := proc(list1, list2)
  [op(list1), op(list2)];
end proc:

[a,b,c] &union [d,e,f]

but it's not what I'm looking for. In fact I could have used any name after the `&`... and really don't like having to type the & at the beginning (is there a way to define an infix operator without having to use the `&`?)

Maybe creating a module to override  the original definition?

my_module := module()
  export `union`:

  `union` := proc(foo,bar)
      if some_trigger then
         # return something
      else
         # use global `union` definition
      end if
   end proc:

end module;

Any suggestion?

P.S.

- I generally don't use the original set union operator, so redefining it is not an issue;

- I have to use lists 

most effective built in operator code award goes to ppl that wrote the code for the union and intercect set operations for maple. Very important simple example below of  one of its applications.

 

When i work with algorithms, probably one of my most primary ports of enquiry (figuratively jeez skynet)  is to set up and if statement triggered to terminate the loop once the operations performed for any further cycles is INDEMPOTENT. this doesnt always mean your output is convergent in every case but it allows you to minimize the amount of time the cpu needs to collect data( ie the point at which it would produce that same set as it did in the last most loop)

 

 

Y := proc (X) local N, S1, `&Sopf;`; if X <> `union`(X, S1[N]) then N := (rand(1 .. NrANGE))(); S1[N] := {K[1](4+N), K[1](5+N), K[1](6+N), K[1](7+N), K[1](8+N), K[1](9+N), K[1](10+N), K[1](11+N), K[1](12+N), K[1](13+N), K[1](14+N), K[1](15+N)}; `&Sopf;` := `union`(X, S1[N]) else  end if end proc

proc (X) local N, S1, `&Sopf;`; if X <> `union`(X, S1[N]) then N := (rand(1 .. NrANGE))(); S1[N] := {K[1](4+N), K[1](5+N), K[1](6+N), K[1](7+N), K[1](8+N), K[1](9+N), K[1](10+N), K[1](11+N), K[1](12+N), K[1](13+N), K[1](14+N), K[1](15+N)}; `&Sopf;` := `union`(X, S1[N]) else  end if end proc

(1)

``

 

Download idempotency.mwidempotency.mw

 

 

I have a user defined type named FST which is like [list of numbers between 0 and 1 inclusive,list of names]. I now want to change union of two objects of type FST to be as maximum of evry pair of corresponding elemnts of first sublists. For example suppose A:=[[.3,.4,.2],[a,b,c]]; B:=[[.7,0,.2],[a,b,c]]; Then writing >A union B; should give [[.7,.4,.2],[a,b,c]] Thanking in anticipation.
Page 1 of 1