MaplePrimes Posts

MaplePrimes Posts are for sharing your experiences, techniques and opinions about Maple, MapleSim and related products, as well as general interests in math and computing.

Latest Post
  • Latest Posts Feed
  • Someone asked me the other week whether a color gradient could be easily applied to a high density point-plot, either vertically or horizontally graded.

    Without thinking, I said, "Sure, easy." But when I got to a computer, and gave it a little thought, I realized that it's not that easy to do it efficiently. And it really ought to be, even for tens of thousands of points.

    There is a help-page plot,color which briefly describes some things that can be done with coloring plots. As of Maple 16, it mentions a "color data structure" which can be created by calls to the new ColorTools package. There is an example on that page for a single color, but not for several colors concurrently. Using Colortools to get a list of colors, for many points, can be done. (And there ought to be such an example.) But for the case of many data points that uses quite a lot of memory, and is slow.

    Also, there is no 2D plotting equivalent to the 3D plotting colorfunc functionality. There ought to be. And just as the 3D colorfunc should be fixed to take three arguments (x,y, & z) any new 2D colorfunc should be made to take two arguments (x & y).

    So, how can we apply a color gradient on a 25000 2D-point-plot, shaded by y-value? One way is to notice that the various 2D and 3D plot data structures can now store an efficient m-by-3 (or m-by-n-by-3) C_order, float[8] Array for the purpose of representing the chosen colors. (That is not documented, but can be learned by observation and inspection of various example plot structures.) We know that such an Array is relatively memory-light, and can be produced very quickly.

    What this task has become is a 2D version of this method of inserting a custom made color sequence into a 3D plot, but more efficient on account of using a float[8] Array.

    To get some decent timings the attached worksheet uses the time[real] command. Timings are computed both immediately after computation (same execution block) as well as after plot rendering (next execution block).

    It takes about 1 sec for the Maple 16.01 64bit Standard GUI on Windows 7 to throw up and render the plot, for both methods.

    It takes 3.4 sec, and a 108 MB increase in allocated memory, to compute the plot data structure result using ColorTools and a list. But it takes only 0.45 sec, and a 20.5 MB increase in allocated memory, to compute an equivalent plot data structure using the float[8] Array. (Timings on an Intel i7-960.)

    [worksheet upload is misbehaving. So inlining the code.]

    restart:
    N:=25000:
    
    xy:=LinearAlgebra:-RandomMatrix(N,2,generator=0.0..1.0,
                                    outputoptions=[datatype=float[8]]):
    
    str:=time[real]():
    
    plots:-pointplot(xy,
                        color=[seq(ColorTools:-Color([xy[i,2],0,0]),i=1..N)],
                        symbolsize=4);
    

    time[real]()-str;
    
                                 3.323
    
    time[real]()-str; # in new execution group
    
                                 4.400
    kernelopts(bytesalloc);
    
                               107646976
    
    
    restart:
    N:=25000:
    
    xy:=LinearAlgebra:-RandomMatrix(N,2,generator=0.0..1.0,
                                    outputoptions=[datatype=float[8]]):
    
    str:=time[real]():
    
    p:=plots:-pointplot(xy,color=red,symbolsize=4):
    
    c:=Array(1..N*3,(i)->`if`(irem(i,3)=1,xy[(i+2)/3,2],0),
             datatype=float[8],order=C_order):
    
    subsindets(p,specfunc(anything,COLOUR),z->'COLOUR'('RGB',c));
    
    
    time[real]()-str;
    
                                 0.483
    
    time[real]()-str; # in new execution group
    
                                 1.357
    kernelopts(bytesalloc);
    
                                20545536
    

    See http://mathematica.stackexchange.com/ and compare with MaplePrimes.

    On a calculus 2 test I was given to review the students were asked to find the derivative of arccosh(x)*sqrt(1-x^2).  Maple gives the answer -arccosh(x)*x/sqrt(1-x^2)+sqrt(1-x^2)/(sqrt(x-1)*sqrt(x+1)).   This is the same answer, in a slightly...

    A better approximation gives more digits of accuracy in the result per digit of precision used in the computation than a good approximation does.  I was wondering if anyone could come up with a better approximation to the MRB constant than 31/165, 

    This is an important topic which is why I have labelled it as a post.  Many users would like to know how to implement a minor fix to versions where fixes have not been applied.

    I will start with one example.

       pdsolve had an issue where the fourth order term was not evaluated in the pdsolve command.  The issue 
       works Maple 16.  To those users of earlier versions where the code didn't work, it was ...

       showstat(pdsolve)

    If anyone was interested Euro 2012 starts tomorrow.  Using the FIFA simulation created by Robert Israel one could enter the new values for the ELO ratings found here http://www.eloratings.net/euro_cup.html to create a similar simlation of Euro 2012.  Just for visual sakes here's the ELO ratings for the teams in the tournament.

    Dear Maple Users

    I have been testing Maple 16 for some time now, and I am overall very pleased with it. There is however one issue, which is really annoying. In previous version of Maple, images inserted into Maple and plots were printed much bigger than they looked like in the Worksheet. Then me and other users have requested to have the printed output look more like it does in the Worksheet on the computerscreen. Maple has adressed those user complaints in the new...

    Way back in Maple 6, the rtable was introduced. You might be more familiar with its three types: Array, Matrix, and Vector. The name rtable is named after "rectangular table", since its entries can be stored contiguously in memory which is important in the case of "hardware" datatypes. This is a key aspect of the external-calling mechanism which allows Maple to use functions from the NAG and CLAPACK external libraries. In essence, the contiguous data portion of a hardware datatype rtable can be passed to a compiled C or Fortran function without any need for copying or preliminary conversion. In such cases, the data structure in Maple is storing its numeric data portion in a format which is also directly accessible within external functions.

    You might have noticed that Matrices and Arrays with hardware datatypes (eg. float[8], integer[4], etc) also have an order. The two orders, Fortran_order and C_order, correspond to column-major and row-major storage respectively. The Wikipedia page row-major  explains it nicely.

    There is even a help-page which illustrates that the method of accessing entries can affect performance. Since Fortran_order means that the individual entries in any column are contiguous in memory then code which accesses those entries in the same order in which they are stored in memory can perform better. This relates to the fact that computers cache data: blocks of nearby data can be moved from slower main memory (RAM) to very fast cache memory, often as a speculative process which often has very real benefits.

    What I'd like to show here is that the relatively small performance improvement (due to matching the entry access to the storage order) when using evalhf can be a more significant improvement when using Maple's Compile command. For procedures which walk all entries of a hardware datatype Matrix or multidimensional Array, to apply a simple operation upon each value, the improvement can involve a significant part of the total computation time.

    What makes this more interesting is that in Maple the default order of a float[8] Matrix is Fortran_order, while the default order of a float[8] Array used with the ImageTools package is C_order. It can sometimes pay off, to write your for-do loops appropriately.

    If you are walking through all entries of a Fortran_order float[8] Matrix, then it can be beneficial to access entries primarily by walking down each column. By this I mean accessing entries M[i,j] by changing i in ther innermost loop and j in the outermost loop. This means walking the data entries, one at a time as they are stored. Here is a worksheet which illustrates a performance difference of about 30-50% in a Compiled procedure (the precise benefit can vary with platform, size, and what else your machine might be doing that interferes with caching).

    Matrixorder.mw

    If you are walking through all entries of an m-by-n-by-3 C_order float[8] Array (which is a common structure for a color "image" used by the ImageTools package) then it can be beneficial to access entries A[i,j,k] by changing k in the innermost loop and i in the outermost loop. This means walking the data entries, one at a time as they are stored. Here is a worksheet which illustrates a performance difference of about 30-50% in a Compiled procedure (the precise benefit can vary with platform, size, and what else your machine might be doing that interferes with caching).

    Arrayorder.mw

    Maple 16 introduced dramatic changes to the postscript export facility of 3d plots. This is great news, but some bugs remain. Let me report here about my experience. (Note: Maple 15's 3d ps export was something like an encapsulated bmp, while Maple 16 is a genuine level3 postscript export tool)

    The initial release in Maple 16.00 was buggy. In my experience, the export would hang most of the time. An improved release came with Maple 16.01. I have not experienced any...

    Maplesoft has these interesting bits of Math on their website.  For example this one here

    http://www.maplesoft.com/mathmatters/airplanes.aspx

    It is all nice and all but I would like to see some reference examples to maple for each one, a cool application worksheet that portrays each one nicely. 

    Using the example link above I searched maplesoft application center for navier stokes...

    Not really a review but I think Maple has so much cool stuff one can do with it, that we get sidetracked from one project to the next.   Before you know it, a new release is out and you've put your project on hold to try out and play with the new features - and not really forging ahead on any projects.  One year between new releases isn't enough time to have customers really, and I mean really, dive into Maple.

    Here is what a reviewer at computing world said about Maple16

    This does not make any sense to me :-)

    restart:
    A := Matrix([[seq(i, i = 1 .. 10)], [seq(i, i = 11 .. 20)], [seq(i, i = 21 .. 30)]]):
    A[.. -1,..] ;
    A[.. -2,..] ;



    You would assume that A[..-1,..] would remove the last row but that is not the case!
    Instead you have to do A[..-2,..] he he it seems a bit odd!

    This is a problem I've had with the new mapleprimes. Contributions listed as "answers" to a question are listed according to the number of votes they receive. This is a system used on forums like mathoverflow, for instance, websites designed to provide answers to specific questions, websites where "discussions" are discouraged. But, in my opinion, mapleprimes is both a discussion and question/answer forum and the "rank by vote" is not suited to it.

    In the example I...

    The MRB constant Z will probably have several parts.

    The following example is from the Maple help pages
    > with(GraphTheory);
    > with(SpecialGraphs);
    > H := HypercubeGraph(3);
    DrawGraph(H)
     
     


    What I would like to do in the MRB constant z,  MRB constant z part2, and etc. is to draw a series of graphs that show the some of the geometry of the MRB constant.

    See http://math-blog.com/2010/11/21/the-geometry-of-the-mrb-constant/. I would like to draw a tesseract of 4 units^4, a penteract of 5 units^5, etc and take an edge from each and line the edges up as in Diagram 3:

    `` 

     

     

     

    As usual I'm asking for your help.

    ``

    ``

     

    Download May262012.mw

     

    First 108 109 110 111 112 113 114 Last Page 110 of 306