Product Tips & Techniques

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

What could be done with a module whose ModuleLoad routine redefined itself?

Could such a routine do some action, and then cover its tracks effectively by overwriting itself?

Would there be any way to use march() to examine the .mla archive member, in which that ModuleLoad routine is stored, without accessing the name of the module? Presumably any invocation of the actual module name would result in its being accessed from the library and hence trigger its ModuleLoad routine.

Maple's foldl and foldr procedures provide a convenient means to generate an n-ary function from a binary operator. For example, from another thread, one can use foldl to create an n-ary and procedure from Maple's binary `and` function:

There are some routines in Maple's library which, when called the first time, redefine themselves.

One plausible explanation for this is that the new versions are session dependent (external calls, say) while also more efficient to call (repeatedly).

For example, consider StringTools:-Join which seems typical of that package. First, consider it before it's been called at all.

> restart:
> showstat(StringTools:-Join);
 
StringTools:-Join := proc(...

In Maple we can easily plot a space curve if it is given by a parametric form:

x=x(t), y=y(t), z=z(t) (t=a..b).

However, Maple does not give a easy way to plot a space curve if it is given by the intersection of two surfaces:
F(x,y,z)=0, G(x,y,z)=0.

 So, I wonder if there are easy ways to solve this plotting problem?

For example, I'd like to know how to plot the following space curve In Maple :
x^2+y^2+3*z^2=1, 2*x+3*y+z=0.

Example 1  The region between y=x and y=x^2.

 

with(plots):

f:=x->x: g:=x->x^2:

F:=spacecurve([x,f(x),0],x=-0.2..1.2,color=blue, thickness=3):

G:=spacecurve([x,g(x),0],x=-0.2..1.2,color=red, thickness=3):

region:=plot3d([x,y,0],x=0..1,y=g(x)..f(x),color=grey, style=patchnogrid):

display(region,F,G,axes=normal,orientation=[270,0], scaling=constrained);

 

 

Example 2 The region between y=sin(x) and y=cos(x).

with(plots):

f:=x->sin(x): g:=x->cos(x):

F:=spacecurve([x,f(x),0], x=-0.5..6.5,color=blue,thickness=3):

G:=spacecurve([x,g(x),0], x=-0.5..6.5,color=red,thickness=3):

Region:=plot3d([x,y,0], x=0..6, y=g(x)..f(x), color=green,style=contour):

display(Region, F, G, axes=normal, orientation=[270,0],scaling=constrained);

 

Example 3  The region between x=y^2/2 and x=y^4/4-y^2/2.

with(plots):

f:=y->y^2/2: g:=y->y^4/4-y^2/2:

F:=spacecurve([f(y), y, 0], y=-0.1..2.1, color=blue, thickness=3):

G:=spacecurve([g(y), y, 0], y=-0.2..2.1, color=red, thickness=3):

Region:=plot3d([x, y, 0], y=0..2, x=g(y)..f(y), color=gray, style=patch,grid=[10,10]):

display(Region, F, G, axes=normal, orientation=[270,0], scaling=constrained);

 




Example 4  Bird’s eye view of Example 3 (Just change the orientation.)
with(plots):

f:=y->y^2/2: g:=y->y^4/4-y^2/2:

F:=spacecurve([f(y), y, 0], y=-0.1..2.1, color=blue, thickness=3):

G:=spacecurve([g(y), y, 0], y=-0.2..2.1, color=red, thickness=3):

Region:=plot3d([x, y, 0], y=0..2, x=g(y)..f(y), color=gray, style=patch,grid=[10,10]):

display(Region, F, G, axes=normal, orientation=[300,55], scaling=constrained);

 

 

 

 

 

I use Maple primarily in a Unix text window (TTY or "command-line" Maple), so I am used to seeing common subexpression labeling in the output of my computations. However, in Maple 11, GUI users don't see subexpression labeling by default.  I'll begin by talking about subexpression labeling as it appears in TTY Maple, then I'll talk about it in the GUI.

For starters lets look at an example in which a single subexpression is labeled:

There are a number of facilities in Maple which may be extended. Included amongst those are `type`, `print`, `evalf`, and `latex`. The help-page ?extension_mechanism claims that all the built-in functions allow for extension. It also mentions a few system Library routines such as `verify` (but does not mention `latex`).

There are some descriptions of varying completeness in a few...

The third example on the Plot Tickmarks and Gridlines help page - ?plot,tickmarks(tickmarks) - shows how to put labels at specific locations on a plot axis. But I couldn't find anything in the help pages about altering their font. However by changing the labels to names (enclose in left quotes, instead of double quotes) their font could be set using the axesfont option.

Perhaps something could be added to the example mentioned above. In the longer run though, all the help pages for plots need to be re-written: at present they resemble an untidy scrapbook.

J. Tarr
The command > contourplot(-1,x=0..1,y=0..1,contours=[0],filled=true); is supposed to fill the whole space with red (color for negative values) but it does nothing this is also problem once I need to define a piecewise function which is constant according to some condition, e.g. > f:=(x,y)->piecewise(x>1/2,x*y,-1); > contourplot(f(x,y),x=0..1,y=-1..1,contours=[0],filled=true); this should fill the entire half plane x>1/2 with red, it fills only part of the first quadrant...
The simpliest version of my problem is this: > f:=(x,y)->fsolve(sin(x+y+z)=1,z) > f(5,5); still ok but now: > plot(f(x,5),x=5..10); sais: "Error, (in fsolve) x is in the equation, and is not solved for" it seems as Maple would not first evaluate x:=5 and then solve f(x) :'(

I've made up a worksheet of the Top Ten Maple Errors, containing some of the common mistakes I often see newcomers to Maple commit (especially in the setting of my Introduction to Mathematical Computing class). I hope you will find it useful in trying to avoid those mistakes. Of course this is only a personal list, and not exhaustive. Please feel free to argue the merits of other items that should be included in the list. Here is the link: Download 4541_topten.mw

For the past decade Doug Meade, at the University of South Carolina, has created and maintained a two-page document with essential Maple commands. The first version was created for Maple V, Release 4, in January 1998. n update has been created for each version of Maple (except Maple 10) as it was released. The document has become pretty stable - hence the omission for Maple 10. Here are links to the complete set of documents he has created

Comments, corrections, and suggestions for improvement are welcomed. Please contact the author by e-mail.

Inspired by the blog post Find a point in every region defined by a system of linear equations, I have come up with the following method to find a point inside each bounded region. The assumptions are:
  • No two lines are parallel.
  • No three lines are coincident.
Due to numerical instability, it seems, using floats, the coefficients of the equations of the lines are taken to be integers (they could also have been taken to be fractions, of course). Then the method goes like follows:
I am coloring the xy plane, by using a procedure(x,y) to assign color. The procedure returns a number and color is assigned according to that number. It works fine but I really want some of the points to be colored BLACK. What numerical value do I use for BLACK? WHITE?

I have written a module based Maple expressions to LaTeX converter which can handle the following nested (as given by ToInert) inert types:

_Inert_RATIONAL, _Inert_COMPLEX, _Inert_NAME, _Inert_SUM, _Inert_PROD, _Inert_POWER, _Inert_SET, _Inert_LIST, _Inert_FUNCTION, _Inert_MATRIX, _Inert_VECTOR_COLUMN, _Inert_VECTOR_ROW, _Inert_TABLEREF.

As a somewhat cruel test example consider

expr := Matrix(2,2,(i,j) ->
	-(-x)^(-i/2+c)*sin(x)^(-j)*(a+I*b)^((i-j)/2)
	+f({-i,j})/g([-i,j])
	+m[i,j]
);
newLatex:-Latex(expr);

which yields

First 46 47 48 49 50 51 52 Last Page 48 of 66