Items tagged with list list Tagged Items Feed

I am working on a problem that involves a great deal of combinatorics, and I have broken the problem into several procedures.  I am trying to create a first procedure that creates a list output, a second procedure which takes the list and other input and cycles over combinations of two elements from the list and calls a third procedure to perform the calculus needed for each pair.  A simplified example follows:

f1:=proc(a1, a2, ..., an)
(various if-then statements)

return [b1, b2,...,bn];



f2:=proc(alpha, beta,...,L::list)

for i from 1 to n-1 do
     for j from i+1 to n do
     A:= A+ f2(alpha, beta, ..., L[i], L[j])
     end do;
end do;

return A;



f3:=proc(alpha, beta, ..., bi, bj)

(various mathematical manipulations)
return x;



When I first use f1 to get [b1, b2, ..., bn] and then invoke f2 as f2(alpha, beta, ..., [b1, b2, ..., bn]) everything works fine.

However, f1 needs to be invoked by yet a larger function as follows:

L0:=f1(a1, a2, ..., an):
B:=f2(alpha, beta,...,L0):

When I do this, L0 still gets assigned the correct value according the program trace, yet it fails to invoke f3 correctly.  What could the problem be?

Maybe an easy question, but which command do I have to use to calculate the difference between e and a list of fractions?


I need to be able to find the difference between the ith+1 and the ith element of a sequence and store that difference in another list. My code so far doesn't seem to be able to do that. My code is below. Thank you in advance to anyone taking their time looking at this, any help is greatly appreciated!



Kind regards,

Gambia Man

How can I generate some n-tuple random list of integers s.t. any component is between -30 and 50? For example if n=5 then four random of such 5-tuple are

[-1,2,8,7,9] , [0,-9,2,-3,-5] , [4,5,3,-8,-1] , [12, -5, 0, 6,8]

Let x and y be 4-digit integers such that the last digit of x is 7 and the last digit of y is 1. That is, x = abc7 and y = rst1, where a,b,c,r,s,t all run from 0 to 9. There are 1000 possibilities for x and  1000 for y. What are all possible products x*y? I would like all possible products listed in increasing order. The first element of the list should be 7*1 = 7 (since 0007*0001 = 7). The last should be 9997*9991 = 99880027. Thank you! 

Let B=be a list.

How can I sort B as BB=?


How would you apply a permutation to a list?


So, with permutation [[1,3],[2,4]], given in disjoint cycles,

how would you apply it to [1,2,3,4] to obtain [3,4,1,2]?




H := subs(p=diff(f(q,P,t), q), 1/(2*m)*p^2 + 1/2*m*w^2*q^2) = -diff(f(q,P,t), t);
H:=subs( f(q,P,t) = f1(q) + f2(t), H);
subs(m=1, diff(S,q));
p := (E, theta) -> -(1/2)*sqrt(-q^2*w^2+2*E)+(1/2)*q^2*w^2/sqrt(-q^2*w^2+2*E)-E*(sqrt(w^2)/sqrt(-q^2*w^2+2*E)+sqrt(w^2)*q^2*w^2/(-q^2*w^2+2*E)^(3/2))/(sqrt(w^2)*(1+w^2*q^2/(-q^2*w^2+2*E)));
lst := [seq(p((1/2)*E, theta), E=0..5),seq(-p((1/2)*E, theta), E=0 .. 5)]:
plot(lst, theta = -3*Pi..3*Pi, color = black, numpoints=1000);


i plot it circle in circle, should i substitute a value to q before plot?

i guess q is velocity, is it?

why substitute E with 1/2*E?

subs(q=1, subs(m=1, diff(S,q)));
p := (E, w) -> -(1/2)*sqrt(-w^2+2*E)+(1/2)*w^2/sqrt(-w^2+2*E)-E*(sqrt(w^2)/sqrt(-w^2+2*E)+sqrt(w^2)*w^2/(-w^2+2*E)^(3/2))/(sqrt(w^2)*(1+w^2/(-w^2+2*E)));
lst := [seq(p((1/2)*E, w), E=1..5),seq(-p((1/2)*E, w), E=1 .. 5)]:
plot(lst, w = -3*Pi..3*Pi, color = black, numpoints=1000);

So given a list [ [ [1,2], [2,1] ], [ [3,4], [4,3] ], [ [5] ] ],

I would like to produce a list 

[ [1,2,3,4,5], [1,2,4,3,5], [2,1,3,4,5], [2,1,4,3,5] ]


so it makes a combination of sublist of every lists in the given list

is there a way to do it ?



I'm trying to implement a function that gets list1 and list2 to return a list of permutations that permute list1 to list2. 

Is there any good way to do this? 

Let A and B be two lists of monomials. I want a new list C contained that monomials of A where not divide by any monomial of B. For example if A=[x,y,x^2y,xy^2,y^2] and B=[x^2,y^3] then C=[x,y,xy^2,y^2].

I want to refer to the first element in a list such as x:=[1,2,3] as x[0] not x[1].

How to do it?

Dear friends,


I am trying to do an integration which consists of a list of data; let me explain it more:

I have to do

however, I do not have f(x) in the form of a function. f(x) is a list which is:

also, I have x as

How can I do the integration between 1<x<6 ?





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




So basic problem.


I want to create a list with undetermined size. I have some data, let's say these data objects are numbers for now (they can be expressions of variables, or even equations)


Here is a pseudocode,


for n=1:10

  list(n) = n+1;



So the above for loop will create a list of size 9, with objects being number 2 through 11.


I want the list to be in {} form


Now I awnt to take this further. Let's say my data objects aren't just numbers, but expressions. How would I create a list of expressions and turning them into an equation?




e1 := a^2 + b

e2 := b + a*b


e3:= b*a + a*b^2




for i = 1:3 do

list(i) = ei ~=0;



Output should look like


list = {a^2 + b = 0, b + a*b=0,b*a + a*b^2=0}


Notice the use of curly braces


1 2 3 Page 1 of 3