Product Tips & Techniques

Tips and Tricks on how to get the most about Maple and MapleSim

We are going to show a roundabout but rather effective method of solving some rather complicated (definite) integrals in closed-form via a rather unusual method: a special factorization of linear ODEs.  The example we will use is a 2 week old question that has yet to get an answer.

First, the problem: compute the integral

So, after many years in the making, version 1.0 of wine is released.

Can anyone say, whether it'll run Maple 12?

acer

In the recent discussion about patching, a question about patching a function f including local variables of a module or another function was discussed. For example, let it be defined as

A:=proc() global f,t; local x,y,z;
f:=()->x+y();
y:=()->z;
t:=()->x+z;
x,z:=0,1;
NULL end:
A();

Now,

op(f);
                            () -> x + y()
f();
                                  1

How to change it so that it would return 2 instead of 1, without reassigning it?

Everybody is invited to Maple Wiki .

It is hosted on Maple Advisor, a Maple community site independent of Maplesoft and/or Mapleprimes.

The site has started just a couple of days ago and doesn't have much of a content yet.

This is one sort of Maple inconsistency that interests me. Why should the first example behave like evalf(Int(...)) and call `evalf/int` while the second example does not?

I was looking at the timelimit command in Maple, and wonder about whether it might be improved .

The help-page ?timelimit says that it suspends its checks while within builtin functions. It says that, inside builtins, the time limit is "ignored".

But Maple has a lot of builtins. And significant portions of the work may go on within them. Does this make the timelimit() function not useful, from a practical point of view?

What if timelimit were to make checks whenever garbage collection (gc) ocurred? That's a safe point, no? And gc can happen within some builtins? Or what if time checks were made at the same frequency that interrupt requests were checked? Those can happen within some builtins, at safe points.

Those were my thoughts, until I tried it. The command anames(builtin) shows that rtable() is a builtin. But I have found that timelimit will function within at least some rtable() calls.

I was reminded of this by another thread.

It is faster to add in-place a large size storage=sparse float[8] Matrix into a new empty storage=rectangular float[8] Matrix than it is to convert it that way using the Matrix() or rtable() constructors.

Here's an example. First I'll do it with in-place Matrix addition. And then after that with a call to Matrix(). I measure the time to execute as well as the increase in bytes-allocated and bytes-used.

> with(LinearAlgebra):

> N := 500:
> A := RandomMatrix(N,'density'=0.1,
>                   'outputoptions'=['storage'='sparse',
>                                    'datatype'=float[8]]):

> st,ba,bu := time(),kernelopts(bytesalloc),kernelopts(bytesused):

> B := Matrix(N,'datatype'=float[8]):
> MatrixAdd(B,A,'inplace'=true):

> time()-st,kernelopts(bytesalloc)-ba,kernelopts(bytesused)-bu;
                            0.022, 2489912, 357907

In a recent post, a Maple user misunderstood what an assignment to f(x) meant. Since this is a common source of confusion, I thought it would be worthwhile to say more about this subject.

What is f(x)?
First, f(x) is a "function application" in Maple. It is f applied to the argument x. It is not really the same as what one thinks of as a function in mathematics. Consider a mathematical function such as sin(x+y). In Maple, this can be represented by an expression sin(x+y) or a procedure proc(x, y) sin(x+y) end proc (which can also be written in "operator form" as (x, y)->sin(x+y)). The expression or the procedure can then be assigned to a name such as g. The mathematical function is then represented by g in Maple, and not by g(x, y). Instead, if g is a procedure, then g(x, y) means "the procedure g called with arguments x and y". The "function" help page explains these concepts in more detail.

What is f(x):=x^2 in 1-d math?
Now let's move on to what f(x) := x^2 means. In 1-d math, this means, "Create a remember table entry for procedure f." This stores the expression x^2 so that when you enter f(x), that expression is automatically retrieved, and you avoid the expense of executing the body of the procedure . Similarly, if you enter f(1) := 5, then the value 5 is automatically returned when you enter f(1). Note that if you subsequently enter f(y), you won't get y^2 returned, unless f was already defined to return y^2 with input y. Remember tables are very useful and are heavily used by some Maple library procedures. However, the majority of Maple users do not need to worry about this feature and can do very useful things in Maple without ever knowing about it.

Maple is missing the 'standard' notation for the cumulative normal distribution and uses the error function instead (for historical reasons I guess).

However that would be quite convenient to read and formulae in a common notation.

A recent post asks how to create a Maple permutation iterator, that is, a procedure that, on successive calls, iterates through each permutation of a given input.  I suggested a routine that solved the problem, however, I wasn't satisfied with it.  It was slower than it should be.  Later I suggested an improvement.  Here is another improvement.  It uses the same algorithm (algorithm L, from The Art of Computer Programming, vol. 4, fasicle 2, by Donald E. Knuth) if the input has repeated elements, but uses a different method, algorithm T, ibid., if the input consists of distinct elements.  The sequences of permutations for the two algorithms differ, the second algorithm uses the initial order for the first element and consecutive outputs differ by one transposition.

Some time ago, I confronted the usefullness of the Table element of Maplets, and found out it was something marely to show data that was known on design time, no posibility to dinamicly inject data on it for example on a result table after a process, but in the past days I met MatrixBuilder, on the Student, LinearAlbegra package, and I wonder first if that is a maplet, and second, if that is a table element, I tried to crack on the source code of it, but no info came out.

Someone knows what is this window? or if someone is able to crack the source can show me the table part?

If you're writing an external library to be called from Maple, then you have the following problem. The user wants to interrupt your code. They are valiantly pressing control-C or the stop button in the Maple GUI, as your code grinds their machine to a halt. What do you do ?

Hi everyone,

For my research, I needed a procedure to calculate an interpolant respecting the monotonicity of the given data. The curve fitting package of Maple 11 didn't help.

I'm pasting my code below.  I hope it helps some of you too.

Cheers,

Ozgur

PS: Thanks goes to Joe Riel for his help.

It's been a while since I've updated my blog, but the recent Maple 12 release gives me a good opportunity to talk about some of the features I'd been working on for the past months. A few people on MaplePrimes had asked for more details about Maple 12, so I'll start by saying a bit about the new polar axes. A lot of this work was done by my colleagues in the GUI Group and they may have additional interesting things to say about the feature.

In previous versions of Maple, you could draw polar plots using the plots[polarplot] command or with the coords=polar option, but these were always displayed with Cartesian axes. In Maple 12, polar axes are displayed by default, as seen here.

plots[polarplot](1+cos(theta), theta=0..2*Pi, axis[radial]=[tickmarks=5])

plots[polarplot](1+cos(theta), theta=0..2*Pi, axis[radial]=[tickmarks=5])

 A number of new options were added to the polarplot command so that you can customize the axes.  The most useful ones are the axis[radial] and axis[angular] options. These work like the axis[1], axis[2] and axis[3] options available for general plots, and you can use them to control color, tickmarks and other properties of the radial and angular axes.

Typeset math on plots had been introduced in Maple 11, and now we can take advantage of this with nice axis labels, in multiples of Pi, on the angular axis. These labels appear by default, but of course, they can be customized with the axis options. The plot/typesetting help page provides information on how to add typeset math to plots through the command line. There are also interactive ways to do this, using the context menu.

You can add polar axes to plots created by commands other than plots[polarplot], by using the axiscoordinates=polar option. However, not all the options offered by plots[polarplot] are available generally. Here is an example using plots[implicitplot].

plots[implicitplot]([x^2+2*y^2 = 1, x^2+1.5*y^2 = 1], color = ["Blue", "Green"], x = -1 .. 1, y = -1 .. 1, axiscoordinates = polar);

plots[implicitplot]([x^2+2*y^2 = 1, x^2+1.5*y^2 = 1], color = ["Blue", "Green"], x = -1 .. 1, y = -1 .. 1, axiscoordinates = polar)

It is also possible to get the pre-Maple 12 Cartesian axes back with polar plots, by adding the axiscoordinates=cartesian option.

Hi,

If I have boolean variable x1

And assuming multiplication means "AND" for boolean expressions;

and that addition means "OR"

Then

  x1 = x1^2 = x1^3 = ...=x1^k, k >= 1

 

Since "x1 and x1 and x1 ... and x1" = x1;

it is true if x1 is true and false if x1 is false.

 

How can a boolean expression with variables taken

to various powers be simplified?

 

I can't take credit for this; but Dave Rusin showed

First 43 44 45 46 47 48 49 Last Page 45 of 65