Items tagged with while


I'm trying to program a procedure that will return me a list of positions defining equally spaced points (planets) around a circumference, for example:
PSI := [0, Pi]; # Location of 2 planets
PSI := [0, ((2/3)*Pi) , ((4/3)*Pi) ]; # For 3 Planets
I'm new to maple so most commands are new to me, I tried building the size of the list with [0 $ n] because I want the first position to always be at 0 degrees. The first problem is that I get this error:

Error, reserved word `for` unexpected


nplanets := 2;



make_PSI :=
local n,psin,i,PSI:
n = nplanets;
psin  :=(pi*2)/n;
PSI := [0 $ n];
for i from 1 to n do
 angle :=(psin*i);
 op(i,PSI) := angle;
end do;



Error, reserved word `for` unexpected


Any advice would be appreciated!


I want to use while in proc but Maple shows an error saying


"Error, (in exa) illegal use of a formal parameter"


When I click on it, as usual it says "There is no help page available for this error". I tried a very simple example of while which you can see it below and it again shows same error. The while works well but when I put it inside of a procedure it makes an error. Note: the following example is just an example, this is not what I'm doing so please don't reply this while proc is not giving anything. My question is how can I use a while in procedure without encountering the above error.


i := 10;
while i > 1 do
if i mod 2 = 0 then i := i/2; else i := i+1; end if;
end do;


Now with proc


exa := proc (i::integer)::integer;
while 1 < i do
if i mod 2 = 0 then i :=i/2; else i := i+1; end if
end do; 
end proc;


"Error, (in exa) illegal use of a formal parameter"

Hi, all. I need to built a user interface for my program. First, I create two label and two text area for both the value of x and y. After that I assign a button to random generate the value for x and y within the range with x <y. I write the code below into click action of the button.

use DocumentTools in



while %x>= %y do



end do;

end use;

This code can generate two random number and insert inside the boxes created. When the button is clicked, two random number generated but the error dialog box shown on the screen with message : Error in component button with caption "generate" cannot determine if this expression is true or false: %y=%x. What I want is only the true value of x<y will be inserted to the text boxes. 

Any suggestion? Any help will be highly appreciated. Thank you.


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
"mylist = []."

Start at
x = 0
y = 0.

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

Phase B
Repeat the following until

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


Or I didn't get something right? This is with Maple 16.02 on a Mac:

maple worksheet snapshot


> for i from 1 to 10 while i<=5 do print(i) end do; #works all right
> for i from 1 to 10 while i>=5 do print(i) end do; #nothing shows up?

I am trying to work with a for do loop with a while component. I have the error but I am not sure what the desired error should be. I know it has to be small but how small?



here is my maple procedure. I have to make the iteration works until I have met the initial condition it will stop. the initial conditions here is z:=ic.

Say I wanted to print out all values from 1 to 8 but excluding 3, how would I do that using a for loop?

For example, this just stops after 2:

for i to 8 while i <> 3 do
end do ;

whereas I want it to skip 3 so going 1,2,4,5,6,7,8.

For what I'm actually doing, I need i to run over a range but excluding one value.






I only want to display 'position' in animation while tend <= 12:
This is the trial:

for tend from 0 to 50
while (tend <= 12) do
pos:=animate(textplot3d,[[-1.8,0,alpha*tend, 'position']], tend=0..50,frames=150);

I receive error messages:
error, (in plots/animate) 0=0..50 is an invalid animation range


Then I try:

while (tend <= 12) do

Hi I've been searching for an example of a while loop (no recursion) with 2 parts to it, but I have not been able to find one.  Does anyone know of any or can make one up for me?  Thanks!!!

Page 1 of 1