Scott03

784 Reputation

10 Badges

19 years, 257 days

MaplePrimes Activity


These are replies submitted by Scott03

The information for %a can be found on the printf help page.  From that help page you will find that both %a are placeholders of Maple objects.  The objects that printf will use are the objects found right after the string.  Therefore, the first object P[i-2]/Q[i-2] will be placed where the first %a is located and the rlast value will be placed in the second %a location.  rlast is another change I had made to your code because the remainder value you want to use is the value that r was just before F[i] < epsilon.  You don't need to use the printf statement, you could return the values, I just had the printf statement so that you understand what each of the parameters are for.

Scott
Application Developer
Maplesoft

Try adding a check of nops(p) into the code.  See the ?nops help page for more information on the command.

Scott
Application Developer
Maplesoft

Try adding a check of nops(p) into the code.  See the ?nops help page for more information on the command.

Scott
Application Developer
Maplesoft

Hi PatrickT,

I have jsut tried the worksheet on Maple 13.02 (standart on WinXP) and the animation does come up with no changes to Giogios's worksheet.  Could you try updating Maple 13 and check to see if the problem goes away?

Scott
Application Developer
Maplesoft

Here is your proc with some small alterations

FracProc:=proc(x,epsilon,Kmax)
  local F,i,P,Q, r, y, a, rlast:
   P:=Array(-1..Kmax):
   P[0]:=floor(x):
   P[-1]:=1:
   Q:=Array(-1..Kmax):
   Q[-1]:=0:
   Q[0]:=1:
   F:=Array(0..Kmax):
   a:=floor(x):
   r:=x-a:
   y:=1/r:
   F[0]:= abs(x-P[0]);
        for i from 1 to Kmax while F[i-1]>=epsilon do
        rlast:=r:
        a:=floor(y):
        r:=y-a:
        y:=1/r:
        P[i]:=a*P[i-1]+P[i-2]:
        Q[i]:=a*Q[i-1]+Q[i-2]:
        F[i]:=abs(P[i]/Q[i]-P[i-1]/Q[i-1]):
  end do:
return printf("The remainder is %a with a remainder of %a", P[i-2]/Q[i-2], rlast);
end proc:

The main changes were that the name of the procedure can't be frac since that is a function that is already defined.  You also need to change your while loop to a for and while loop, you needed to define F[0] before the loop started and you had a couple = instead of := in your code.

Scott
Application Developer
Maplesoft

Here is your proc with some small alterations

FracProc:=proc(x,epsilon,Kmax)
  local F,i,P,Q, r, y, a, rlast:
   P:=Array(-1..Kmax):
   P[0]:=floor(x):
   P[-1]:=1:
   Q:=Array(-1..Kmax):
   Q[-1]:=0:
   Q[0]:=1:
   F:=Array(0..Kmax):
   a:=floor(x):
   r:=x-a:
   y:=1/r:
   F[0]:= abs(x-P[0]);
        for i from 1 to Kmax while F[i-1]>=epsilon do
        rlast:=r:
        a:=floor(y):
        r:=y-a:
        y:=1/r:
        P[i]:=a*P[i-1]+P[i-2]:
        Q[i]:=a*Q[i-1]+Q[i-2]:
        F[i]:=abs(P[i]/Q[i]-P[i-1]/Q[i-1]):
  end do:
return printf("The remainder is %a with a remainder of %a", P[i-2]/Q[i-2], rlast);
end proc:

The main changes were that the name of the procedure can't be frac since that is a function that is already defined.  You also need to change your while loop to a for and while loop, you needed to define F[0] before the loop started and you had a couple = instead of := in your code.

Scott
Application Developer
Maplesoft

Could you either let us know what this list of solutions look like or upload the code so that we can see the what you are getting when you try to add the solutions.

Scott
Application Developer
Maplesoft

Could you either let us know what this list of solutions look like or upload the code so that we can see the what you are getting when you try to add the solutions.

Scott
Application Developer
Maplesoft

Why do you want to do this in a do statement?

If you really want this in a do loop, you can do the following for #1

MyData := [1, 5, 10, 15, 20]:
MyA := Array(1 .. 5):
for i to 5 do
MyA[i] := MyData[i]:
end do;
MyA;

If you just want to place the data into the array and you don't need to have the do loop the following would be a lot quicker and produce the same result

MyA:=Array([1, 5, 10, 15, 20]);

For you second question, you can either use a nested for loop or pass a listlist into the Array constructor.

 

Scott
Application Developer
Maplesoft

Why do you want to do this in a do statement?

If you really want this in a do loop, you can do the following for #1

MyData := [1, 5, 10, 15, 20]:
MyA := Array(1 .. 5):
for i to 5 do
MyA[i] := MyData[i]:
end do;
MyA;

If you just want to place the data into the array and you don't need to have the do loop the following would be a lot quicker and produce the same result

MyA:=Array([1, 5, 10, 15, 20]);

For you second question, you can either use a nested for loop or pass a listlist into the Array constructor.

 

Scott
Application Developer
Maplesoft

If you want to convert the table 'a' into an array you can pass 'a' in the Array constructor like the following

Array(1..4,1..3,a);

In this case the spots that don't contain a number in the table gets set to 0.  If you know what the size of the Array is before hand, why not just create an array for 'a' before assigning the values.

Scott
Application Developer
Maplesoft

If you want to convert the table 'a' into an array you can pass 'a' in the Array constructor like the following

Array(1..4,1..3,a);

In this case the spots that don't contain a number in the table gets set to 0.  If you know what the size of the Array is before hand, why not just create an array for 'a' before assigning the values.

Scott
Application Developer
Maplesoft

I have noticed that MaplePrimes had hiddent some of the above code that the user had entered (due to some of the code being interpreted as html).  This will hopefully make the question more clear.

Scott
Applicaiton Developer
Maplesoft

I have noticed that MaplePrimes had hiddent some of the above code that the user had entered (due to some of the code being interpreted as html).  This will hopefully make the question more clear.

Scott
Applicaiton Developer
Maplesoft

If you try the following

solve(-ln(1-x)/x-x+2 = 0,x, AllSolutions);
                          /  1                                                    \   
                  -exp|- - LambertW(_Z2, 2 exp(2)) + 1| + 1
                          \  2                                                   /   

In the above solution the _Z2 is assumed to be an integer.

 

Scott
Application Developer
Maplesoft

2 3 4 5 6 7 8 Last Page 4 of 20