MaplePrimes Commons General Technical Discussions

The primary forum for technical discussions.

I congratulate Robert Israel on being the first to attain the Mapleprimes Maple Master badge. It is well deserved.

I was about to post this as a "How-do-I" question, but while composing my question, I stumbled upon the solution.  In case this "discovery" would be useful, I'm posting it here.

For some coursework, I'm developing fitting sinusoids to experimental data (poor-man's Fourier Analysis).  At one point, I do a "brute-force-least-squares" computation, one step of which involves computing the sum of a sine over N equally-spaced intervals around the circle.  This...

As some of you know, I'm hoping to, some day, find a closed form expression for the MRB constant.

 Here is my latest little nugget.

Let x=MRB constant.

(1-604*x)/(28+209*x) = log(x) with an error< ...

(This is a reply to PatrickT, who asked about a certain ArrayTools:-Copy example.)

Suppose that you need to do a computation which requires, in part, a certain subportion of a Vector V. Let's call the routine which does the work as `f`. Let's suppose that `f` is a system command and not something that we write ourselves. One natural way to call `f` and supply the subvector is to call `f` like so:

   f( V[a..b] );

Here the inner range a..b denotes...

Perhaps you have heard the terms "ordering difference" or "session dependent" applied to results of some Maple computation. It used to get heard more often back before Maple 12, when elements of sets in Maple were ordered according to address.

Hello all,

I have encountered a curious bug in the EigenConditionNumbers
procedure. In particular for a pencil pencil (A,B) with B singular,
and precision higher than hardware precision.

The following code for Digits=40 produces a Float(undefined) rather
than a Float(infinity) for the infinite eigenvalue, but an alpha and
beta that will produce an infinite eigenvalue.

Digits:=trunc(evalhf(Digits));
A:=Matrix([[1,0],[0,2]]);
B:=Matrix([[1,0],[0,0]]);

A couple of days ago I found out that gzread from the zlib library can be used for fast reading of binary files in Maple from the disk to memory - about 100 times faster than readbytes - something like in the following simplified example, 

A:=Array(1..2^26,99,datatype=integer[1]):

time(writebytes("A",A));close("A");

                                9.360

B:=Array(1..2^26,1,datatype=integer[1]):
time(readbytes("A",B));close("A");

                                8.065
B[1],B[-1];

                                99, 99

myreadbytes:=proc(f)
local gzopen, gzread, gzclose, n, p, A;
gzopen:=define_external('gzopen',
    'path'::string,
    'mode'::string,
    'RETURN'::integer[4],
    'LIB'="zlibwapi.dll");
gzread:=define_external('gzread',
    'file'::integer[4],
    'buf'::REF(ARRAY(datatype=integer[1])),    
    'len'::integer[4],
    'RETURN'::integer[4],
    'LIB'="zlibwapi.dll");
gzclose:=define_external('gzclose',
    'file'::integer[4],
    'RETURN'::integer[4],
    'LIB'="zlibwapi.dll");
n:=FileTools:-Size(f);
A:=Array(1..n,datatype=integer[1]);
try p:=gzopen(f,"rb");
if gzread(p,A,n)=n
then return A end if
finally gzclose(p)
end try
end proc:
time(assign(C=myreadbytes("A")));

                                0.062

C[1],C[-1];

                                99, 99

'time(myreadbytes("A"))'$5;


                  0.078, 0.062, 0.046, 0.046, 0.046

E:=Array(1..2^26,2,datatype=integer[1]):
time(ArrayTools:-Copy(A,E));

                                0.093

That needs some tweaking, because that works only on uncompressed files. If a file ("A" in this example) was gzipped, then the gzread would ungzip n (uncompressed) bytes in it in this example, instead of copying it into the memory - but it is not a big deal, in general.

Does anybody know about a similar replacement for writebytes? gzwrite doesn't work for copying (it compresses the array.)

I used the zlibwapi.dll library from http://www.winimage.com/zLibDll/index.html, it is a version of zlib 1.2.5 (written by Jean-Loup Gailly and Mark Adler) built by Gilles Vollant. The code is for a 32-bit system (Windows). That should work in 32-bit Linux after replacing that dll with standard libz.so.1, as well as on 64-bit systems after replacing integer[4] with integer[8] in most places.

Click Maple Math, enter x^2/(1+x).   The Preview disappears as soon as I press "/", and the result is not pretty-printed.

x^2/(1+x)

I've been making some use of the Maple Cloud for a while now, and thought that I'd share some comments.

So far, it's been quite useful to me, and I like it. This surprised me a bit. I expected not to find it useful, and to dismiss it with an old-timer's "Bah, humbug... as useless as Maple+twitter!" But, to the contrary, I've found a use for it; a need that isn't otherwise...

Quite often, when plotting an expression in involving trigonometric functions applied to (a rational polynomial of) the main variable, it is desirable to have the major ticks along the x-axis be labeled by multiples of Pi. In particular, it can be much more appealing to have those tickmarks be labeled with short rationals multiplied by the 2D Math symbol π.

In examining ODE models containing parameters I don't like to assign values to these, but use the form

param:={a=2, b=7};
and then
eval(expression, param);

This works well. There are situations, however, where this method can be cumbersome.
This would be the case in a situation like this:

plot(a*sin(x),x=0..b);

You could do

plot(op(eval([a*sin(x),x=0..b],param)));

But maybe an operator having a syntax similar to 'assuming' could be useful.

If I assign a list to a variable named depth it causes invalid object errors in for loops for Maple12

depth:=[1,2,3,4,5,6,7,8]:

for i from 1 to 4 do
  i;
end do;

Error, invalid object: mspace(height = "0.0ex",width = "0.0em",[1, 2, 3, 4, 5, 6, 7, 8] = "0.0ex",linebreak = "newline") and  1 additional error.

 

 

Let's compare the performance of two methods of computing the inverse of a large datatype=float[8] Matrix.


The two methods are that of calling `MatrixInverse`,...

If you want better performance then don't use 2D Math mode to enter procedures which call  `.` (dot).

The following timings are not the result of the order in which the cases are performed. The timings stay roughly the same if the blocks delimited by restarts are executed out of order.

First 16 17 18 19 20 21 22 Last Page 18 of 78