# Items tagged with looploop Tagged Items Feed

### plot multiple for or do loop display...

April 26 2015
0 8

Dear  i want to plot the graphs for different values of R[2,5,6.5]   here is the codes: Either ido loop or array i have to use or other procedure

The graph display should be at R=2, one graph, R=5 another and R=6.5

onemore graph

restart:
with(DEtools):
eta:=1+k*x+epsilon*sin(2*Pi*x):
A1(x):=-exp(-alpha*x)*J^2*R/(2*eta^3+6*xi*J^2*eta^2):

psi0:=A1(x)*y^3:
psi:=delta*psi0:
V:=-diff(psi,x):
delta:=0.1:
epsilon:=0.01:
alpha:=1:
xi:=0.001:
k:=0.1:
As:= [0, 2, 4]:
x:=0.2
plot([seq]([eval(V, J= A), y, y= 0..eval(eta, J= A)], A= As),title=" velocity at R=2.0 ",labels= ["v", "y"],color= [green, red, blue], linestyle= [solid, dash, dot],legend= [seq](J = A, A= As), axes=boxed);

### Do loop problem...

March 16 2015
0 1

Hello

I am trying to do a do loop

X[1] := Statistics:-Sample(Binomial(200, .5), 1);

for i to 10 do X[i+1] := Statistics:-Sample(Binomial(200-X[i], .5), 1) end do;

And it shows error like this

Error, (in rtable/Sum) invalid arguments.

Did I do something wrong in my code?

### Best way to put a big code in a 'external' loop. ...

March 15 2015
0 3

Dear,

I am stuck in this task and wonder if someone could help me with this. I have a big code and, quite generally, receive as a result, say, three quantities, A, B, and C. My aim is create three other lists, list_A, list_B, and, list_C, in a way that each iteration will add to them the respective A[i], B[i], C[i]. My almost complete ignorance with Maple is turning this task a hell, despite in other languages I could do that with relativity ease.

Of course, I thought to put the entire code in a 'for-loop' but as far as I see this is complicated in Maple syntax.

Thank you very much for any kind of help, hint, material for reading, etc.

My best regards,

### Maple nested loop error: unterminated loop...

March 13 2015
1 5

Hi,

I'm, trying to write a nested loop in maple, but I keep getting the Unterminated Loop error. I'm sure the solution is quite simple, but I haven't been able to find it. Any suggestions would be much appreciated. The loop looks like this:

i:=0:
di:=25:
n:=1:

while (n<=nLimit) do
sol1:=fsolve(eq1, y=i..i+di)
if type(sol1, numeric) = true then
lambda(n) :=sol1
i:=i+di
n:=n+1
else  i:=i+di
end if:
end do:

### Amount of Steps...

March 09 2015
1 3

Hello,

I have a question. I have to compare the times and steps taken by an algorithmus (which contents a loop).

So for time there is the time()-function, right? And is there any similar function for the steps taken?

So far i use a variable increasing by 1 each time, but i think there is an more elegant way to do it, which I just don't know.. :D

Thanks for any help!

### Loop With more than one line...

March 07 2015
0 18

Hello

I have some problem with " For loop". If i add more then one expression the, i recieve an error. Could you please help me to solve it? I have attached my file. Thank you.

 Input Section

### Don't get my Error... "Error, (in S4) the modular ...

March 05 2015
1 1

Heyho,

I'm pretty new to Maple (started Monday). And I don't know how to solve (or even why it exists) the following error:

S3() generates two integers, one converted from a random 568-Bit-number "e" and one converted from a random 160-bit number "kp1", satisfying gcd(e,kp1)=1.
That works pretty fine so far.

Now I need two specific numbers, x and y defined by:

And I use the proc S4 to get them:

Sometimes, the error occurs "Error, (in S4) the modular inverse does not exist", and I dont get why,... I tried to fix it, with the "while"-loop, but it didnt work out yet.

Someone knows how to solve this problem?
Thanks!

### Image processing and "Loop"...

March 04 2015
0 4

Hello

1)I need some guides to solve my problem. I have attached my file. Could you please help me to understand what's wrong in my code?

2) Is there any option to pause "Loops" and watching results, something like break point.

THank you.

 Input Section

 Input Section

March 02 2015
0 2

### Set the variable of equation to be a Boolean compo...

March 02 2015
0 5

Hi all,

I have some "boolean variable" constraint equation like this:

a1*x1+a2*x2+...+an*xn>=b1*y1+b2*y2+...+bn*yn

where a1,a2,...,an and b1, b2, ..., bn are 1 or -1

These equations will be used in LPSolve or the other command to find a group of parameters which can fit them.

Now I used for-loop to deal with this kind of question, for example:

But there are more than 10 boolean variables in my case and It's very inefficient. On the other hand, using for-loop to determine the equation we solve in the command will lead to great confusion.

I think there should be some ways able to solve this kind of "boolean variables" question in Maple, such as, through assume command to define the type of "boolean variable".

But I have no idea how to do it.

### procedure that takes integer n and returns an orde...

February 25 2015
0 11

I need to write a procedure that does the following :

Write a procedure quadsum whose input is an integer n and whose output is a list of pairs of solutions [x,y] to the above formula.

Your procedure should implement the following algorithm.

1 Initialization
Set
"mylist = []."

Start at
x = 0
and
y = 0.

2 Phase A
Increment both
x
and
y
until
"x^2+y^2 >=n."

Phase B
Repeat the following until
x^2>n

If you are above the circle
x^2 + y^2 = n
then go down in unit steps until you are on or below the circle.

If you are on the circle, add the point to the list
"mylist. "

If you are on or below the circle
x^2 + y^2 = n
then go one step to the right. My procedure is as follows: but it runs into an infinite loop(most probably because of the while loop defined inside the while loop). What am I doing incorrectly?

I have atta

### How to diff func for k-th times in each k-loop...

February 24 2015
1 2

****** My question *****

for k from 0 to n do    # n is any integer.

func := f(x):             # func is any funciton of x.

D := diff(func, x\$k);   # The maple don't allow to uses k but I want to diff k-th order in each k-loop.

end do;                    # How to diff func for k-th times in each k-loop.

### How to Generate Multiple Loop Automatically ...

February 12 2015
1 13

Hi all,

I want to design a procedure which can generate multiple loop automatically. While I  assign a value to it, it will create a multiple loop with same number of layers.

For example,

P(1):

for i from 1 to n do
...
end do:

p(2):

for i from 1 to n do

for j from 1 to n do
...

end do: end do:

p(3)...

p(4)...

...

I'd appreciate any help on this topic. Thank a lot.

### Simple while loop problem: "Error, can't determine...

February 04 2015
1 1

Hi,

So I have a simple while loop and keep receiving this error and have no idea how to fix it. I don't get why it works for the first few, and then the error starts. Here is my code and output:

Input:

restart;
n:=0:
x:=Pi/3;
m:=0:
total:=0:
while abs(1/2-total) > 10^(-8) do
k:=((-1)^(n/(2))*x^(n))/(n!):
total:= total +k;
evalf(total, 11);
print(%);
n:=+2;
end do:

OUTPUT:
1
- Pi
3
1.
0.45168864437
Error, cannot determine if this expression is true or false: 0 < -50000001/100000000+(1/18)*Pi^2

Why does it think i'm asking if something is greater than 0? Any help??

### Creating two lists from a set with pairs using loo...

January 31 2015
2 9

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.