Joe Riel

9660 Reputation

23 Badges

20 years, 2 days

MaplePrimes Activity


These are answers submitted by Joe Riel

Try Optimization:-Maximize, it quickly finds the local maximum in the region.

For this particular case you might be able to use LinearAlgebra:-IdentityMatrix(5). That won't work if you plan to later modify the Matrix.

That's a really old maplev version.  The current latest is, as John says, available at my GitHub site. A newer version will be uploaded in the near future. Note that I'm still using GNU Emacs 24.4.1, not 25. If you do have issues, please contact me directly. Thanks. 

Using the Iterator package one can do

# 2 0's and 3 1's
iter := Iterator:-Chase(2,3):
seq(p[], p=iter);
   [0, 0, 1, 1, 1], [1, 0, 0, 1, 1], [0, 1, 0, 1, 1], [0, 1, 1, 0, 1], 
   [1, 0, 1, 0, 1], [1, 1, 0, 0, 1], [1, 1, 1, 0, 0], [1, 1, 0, 1, 0], 
   [1, 0, 1, 1, 0], [0, 1, 1, 1, 0]
  
n := 8650368:
P := sort(map2(op,1,ifactors(n)[2]));
                 [2, 3, 2503]
sort(ifactor(n), ``~(P));
                 ``(2)^7*``(3)^3*``(2503)

Here's why

 eval((1/s^2)^N = s^(-2*N), [s=-1,N=1/2]);  
                                           1 = -1

The short answer is no.  For the most part there is no practical way to do so.  However, if you drop the requirement that the change be stored in the mla, it is possible to temporarily modify a procedure.  The Emacs Maple Debugger provides a particularly nice way to do so.  For example, to temporarily modify the simplify procedure I would

  1. Set a breakpoint in simplify and then execute simplify.  I do both in one call with mdc(simplify)(x);
  2. Once in the debugger and in the procedure of interest, type "P" which invokes a patch utility that copies the interpreted source to a buffer (editor window).
  3. In the buffer edit the procedure accordingly.  When finished type C-c C-p to install the patch.
  4. Exit the debugger and rerun simplify.  The new code will be executed.
  5. The modified simplify will remain until a restart.

Use LinearAlgebra:-SmithForm to convert a Matrix to Smith normal form.  

The following code compares three ways to do this

A := Matrix(100):

isRowZero1 := proc(A,i)
    andmap(Testzero, A[i,..]);
end proc:

isRowZero2 := proc(A,i)
local j;
    for j to upperbound(A,2) do
        if A[i,j] <> 0 then
            return false;
        end if;
    end do;
    return true;
end proc:

isRowZero3 := proc(A,i)
    not rtable_scanblock(A,[i, 1..upperbound(A,2)],'HasNonZero');
end proc:


CodeTools:-Usage(isRowZero1(A,1),'iterations'=10\000);
memory used=10.45KiB, alloc change=32.00MiB, cpu time=88.00us, real time=88.00us, gc time=3.20us

CodeTools:-Usage(isRowZero2(A,1),'iterations'=10\000);
memory used=2.47KiB, alloc change=0 bytes, cpu time=36.00us, real time=35.80us, gc time=0ns

CodeTools:-Usage(isRowZero3(A,1),'iterations'=10\000);
memory used=200 bytes, alloc change=0 bytes, cpu time=2.80us, real time=3.00us, gc time=0ns

Using rtable_scanblock appears to be the way to go. Note that method 2 is more efficient than method 1 because it doesn't allocate memory to extract the row. That's why, in a different thread, I wished Maple had an andseq builtin. Method 3 is essentially method 2, but using rtable_scanblock with its builtin procedure HasNonZero to get some speed. When dealing with rtables (Arrays, Matrices, Vectors) rtable_scanblock works but given its more complicated interface is not something I immediately try. 

applyop(`^`,1,A,2);

This is a rather low level approach and works for the simple case when when A is number with a unit. It won't work for the more general case of an algebraic expression with a unit. If you have to deal with such expressions you would be better off writing a small procedure that operates on the non-Unit part of the expression. Let me know if you need help doing that.

Set Digits := 10 before calling Histogram.

A simple method is

subs(beta-1 = 1, e44_6);

You can then multiply by the factor if desired.

Similarly

map(`/`, e44_6, beta-1)

If R is a list, then you could do 

if member(R[i], R[1..i-1]) then
It would be nice if Maple provided an orseq builtin, then one could do
if orseq(R[i]=R[k], k=1..i-1) then

The small advantage of that hypothetical solution is that it wouldn't allocate extra memory for a sublist that is not otherwise required.

Write directly to the file.  Something like (I haven't tested this, so assume it has bugs):

for i to 5000 do
   file := sprintf("SIM_%d.mpl", i);
   fprintf(file, "Threads:-Map(SIM, 5000, %d);\n", i);
   fclose(file);
end do:

Try

Arg := z -> Pi+argument(-z);
First 20 21 22 23 24 25 26 Last Page 22 of 114