35 Reputation

6 years, 122 days

Doubt about declaring variables in proce...

Maple

If I have 2 procedures,

P1:= proc()

......

end proc;

P2:= proc()

.....

P1();

end proc;

and within P2 I invoke and run P1, do I have to declare P1 as a local/global variable when declaring variables in P2, or it is not necessary?

Problem with BinarySearch sintax...

Maple

Dear,

I have a list, say, L:= [2,3,4,5];

and I need to find the position of several of its elements. However, when a apply the BinarySearch command I get a wrong return. For example, element >= 5:  BinarySearch(L, 5, `>=`);

Maple returns 0

Element = 4: BinarySearch(L, 4, `=`);

Maple returns 0

Element < 3: BinarySearch(L, 3, `<`);

Maple returns 2.

Obviusly, I'm doing something wrong. Could you please tell me what it is?

Problems printing list content with prin...

Maple

Dear,

I have to print something like this:

Days 4,5,6 is closed.

4,5,6 is the content of a list.  I enter:

d:=[4,5,6];

printf("Days %a is closed\n", d[]);

but Maple returns:

Days 4 is closed

Of course, if I enter  printf("Days %a, %a, %a is closed\n", d[]);

I get the correct result: Days 4,5,6 is closed.

However, the numer of elements the list will have vary from case to case and according to the procedure I'm running so I cannot enter the command with the exact number of %a. How could I overcome this problem?

Solving a linear system of equations dif...

Maple

Dear,

If we have to solve in Maple a linear system like A.x =b, we employ the command Linsolve. However, how can I solve a system like x.A=b?

The only method I know is to compute x=b.A-1. Is this an efficient method or there is a better one you recommend?

Creating a table from IF statement...

Dear, I would like to kindly request your help with the following problem I have:

L:= [0, 3,0,7];

for i from 1 to 4 do
if L[i] > 0 then
x[i]:= [L[i]/2]
end if;
end do;

I need to write the elements x[i] as a list, however if I type x[i];  Maple just returns the last value of L[i]/2, namely 7/2. I do not know how to obtain the full list [3/2, 7/2]. What am I doing wrongly?