Items tagged with list list Tagged Items Feed


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


Hi, i got a litlle problem with fromats, i m realy bad at this.
i got procedure 'getone(z::list)' i was execute it like this  
>getone([seq(lineP[i], i = 1 .. pm)]::list)
where lineP is 

>pm := 3;
>rollx := rand(98.0 .. 102.0); rolly := rand(-1.0 .. 5);
>rolll := rand(.5 .. 1.0); rollf := rand(0. .. evalf(2*Pi));
>rollm := rand(0. .. 20.0);

>for i to pm do lineP[i] := [rollx(), rolly(), rolll(), rollf(), rollm()] end do;

it's pm times of z:=[rollx(), rolly(), rolll(), rollf(), rollm()] ::list

and i need make optimization work for any pm=1..100; with rabdomly generated iteration point as above.

The main queston is how make minimize as below
Minimize(z,variables=[z],   initialpoint={z=[seq(lineP[i], i = 1 .. pm)]},iterationlimit=1000,optimalitytolerance=0.01)

work with z::list kind of 

[[100.7798614, 1.109653266, 0.9840371500, 4.257816686, 9.737110573][100.0135459, 0.887539481, 0.9144164697, 3.980093624, 7.343851161][100.0661308, 3.724268229, 0.5020544909, 2.052134822, 14.37408543]]

The member function can provide the position of x in table/list s for the first variable




will provide p=1


If I would like to know the position of all a, [1,4,5], is there any simple way to obtain them? I can do something like



for i from 1 to 5 do

 if f[i]='a' then



 end if;

end do;


something like that

Thank you very much

1 2 3 Page 1 of 3