Joe Riel

7742 Reputation

22 Badges

14 years, 178 days

MaplePrimes Activity


These are answers submitted by Joe Riel

The predicate (first argument) to select must be a procedure that returns a boolean. Use the following

select(p->findOrderOf(2,p)=p-1 and findOrderOf(3,p)=p-1,primes);

What do you expect as the output?  The usual way to run Maple from a command line is to run maple scripts (typically .mpl files); they contain standard Maple commands. I do this regularly, though from Linux, not Windows. You can convert a .mw file to a .mpl file by exporting it as such (File > Export As, then select Maple Input (.mpl). To execute the script, you pass it to tty maple, which on Windows is named cmaple and is in the bin subdirectory of the Maple installation.

Followup

On Windows the executable is in bin.X86_64_WINDOWS, at least on a 64 bit install. Ideally you would set %PATH% to access the directory, but without that you can do, at a DOS prompt

> "c:\Program Files\Maple 2017\bin.X86_64_WINDOWS\cmaple.exe" myfile.mpl

where myfile.mpl is the Maple script file you want to run.

If you double-click the Probe Plots selection in the bottom left pane of the Simultion Results window, the plot will appear. I'm not sure why it isn't appearing automatically.

Further 

It appears as though the visibility of that plot is initially off.  Maybe it was accidentally toggled before the file was saved. Double-clicking toggles the visibility; you can also right-click to bring up a context menu.

You have a space or something between the first ::.  The following works

patt := x::symbol^n::symbol /  y::symbol^n::symbol: # verify this is parsed correctly
patmatch(x^n/y^n, patt, 'eqs');
                                true
eqs;
       [n = n, x = x, y = y]

The result is, uhh, correct.  The condition a > b evaluates to 1 > 3 which is false, so the else clause is executed.

It seems to work here; moving the sliders updates the corresponding figure and adds data to the tables. 

A few comments.  There is no good reason to use with(DocumentTools) inside a use DocumentTools in ... end use; structure (that is done in the code for DataTable0). Putting a restart in embedded code has no effect; a restart is only available at the top level (that also exists in the code for DataTable0).

Further The code for the first slider is updating DataTable1, not DataTable0, which is the data table that is adjacent to it. So maybe that's your problem.

P operates on lists. To use it with map, the mapped structure should be a list of lists. So

map(P, [[A1, A2, A3, A4]], [B1, B2, B3, B4]);

frontend can be used here

y := -sin(alpha)*(sin(theta1)*cos(theta)-cos(theta1)*sin(theta)):
frontend(combine, [y], [{`+`,`*`},{theta,theta1}]); 
                        sin(alpha) sin(-theta1 + theta)

A better choice is to use add rather than sum.  Even better is to cache the results.  Consider

f1 := n->piecewise(n=0,1,n>=1,add(thisproc(k),k=0..n-1)):
f2 := proc( n :: nonnegint)
option cache;
local k;
    add(thisproc(k), k = 0..n-1);
end proc:
f2(0) := 1:  # Directly assign the value for n=1

n := 20:
CodeTools:-Usage(f1(n));
memory used=0.53GiB, alloc change=32.00MiB, cpu time=9.94s, real time=9.94s, gc time=196.00ms
                                                                                524288
CodeTools:-Usage(f2(n));
memory used=6.08KiB, alloc change=0 bytes, cpu time=0ns, real time=0ns, gc time=0ns
                                                                                524288

The second version runs much faster.

Apologies for the belated reply.  The basic problem is that there are bugs in that version of CodeBuilder.  I've uploaded a new version to the MapleCloud (but not to the Maple Application Center).  With Maple 2017 you should be able to download it from the MapleCloud palette.  Alternatively, you can do execute the following statement, which should install it.

PackageTools:-Install(5723849212559360,'overwrite');

It's hard to be sure without knowing what the code is doing, but you can use a conditional to check for an empty solution from solve and then skip the rest of the loop.

for ... do
   ...
   sol := solve(...);
   if sol = NULL then
      next;
   end if;
   ...
end do;

You may have to modify the conditional (sol = NULL) to something appropriate for your usage of solve.

Your call expands to

map(`*`, 1/x, y, z);

which maps `*`, with additional arguments y and z, onto 1/x, which is equivalent to x^(-1). To better understand what happens, do

map(f, 1/x, a, b);
               f(x,a,b)^f(-1,a,b)

With current Maple you could just do

mul([1/x,y,z]);
assign(op(op(Sol))): # this assigns a table to u.
U := Matrix(25, u):
plot([seq([i,U[i,20]], i=1..25)]);

No, that statement is generally true. When using a seq, add, or mul in a procedure, one should always declare the index as local to the procedure. Normally the value is not retained, however, because you are using an indexed name (which becomes a table reference when assigned to by the seq) values are being assigned to the table i. I'd avoid using an indexed name as the index variable.

Followup 

To see that index in a seq is not local to the seq, do

protect(i);
seq(i, i=1..3);
Error, attempting to assign to `i` which is protected.  Try declaring `local i`; see ?protect for
details.
collect(expression,x,factor);

does what you want.

5 6 7 8 9 10 11 Last Page 7 of 101