Stephen Forrest

Mr. Stephen Forrest

476 Reputation

14 Badges

21 years, 298 days
Software Architect

Social Networks and Content at

Maple Application Center

MaplePrimes Activity

These are answers submitted by Stephen Forrest

Note that Maple 18 introduces the URL package which can perform GET and POST requests using both HTTP and HTTPS (and it also supports FTP).

s := URL:-Get(""):


Merci pour votre question.  Comme Markiyan Hirnyk a montré, on peut utiliser la commande factor.

Alternativement, on peut faire un clic droit sur l'expression originale puis choisir l'option "Factor".

Following on Carl's reply, here is an example where both parts are included in the same context:

N := 10:
t := 5;
S := table([seq(i=1,i=1..N)]):
V := table([seq(i=1,i=1..N)]):
for j from 1 to N do
	if S[j]>99 then
	end if:
end do:

Could be more specific about the nature of your difficulty?

In addition to the resources noted by other users, I would point you to this Quaternion package by Douglas Harder:

Quaternions for Maple:

Thanks for your comment.  There is presently no simple way to create dendrograms.  You can however turn an existing hierarchical classification into a graph representation using the GraphTheory package and display it using the GraphTheory:-DrawNetwork command.

Example: We wish to hierarchically organize a set of strings Strings by common prefix.

Strings := {"aardvark", "aardwolf", "antelope", "anteater", "bumblebee", "buffalo", "zebra"};

First, to generate the hierarchy we extend the set Strings to include all the common prefixes between any pair of strings in our original set:

CP:={seq(seq(StringTools:-Take(x,StringTools:-CommonPrefix(x,y)),x in Strings),y in Strings)}:

Next we build a table P which encodes a parent/child relationship in our hierarchy:

P := table( map( x->x="", Strings )):
for x in CP do for y in CP minus {x} do
    if StringTools:-IsPrefix(y,x) and (assigned(P[x]) implies StringTools:-IsPrefix(P[x],y)) then
        P[x] := y;
    end if;
end do; end do;

Finally, we embed this in a graph G and visualize it.  The resulting graph doesn't have the particular visual characteristics you were looking for in the dendrogram (e.g. right angles at bifurcation points) but does illustrate the hierarchy.

G := GraphTheory:-Digraph( map(x->[op(x)], {indices(P,pairs)} ) ):
GraphTheory:-DrawNetwork( G, horizontal );

result of GraphTheory:-DrawNetwork( G, horizontal )

This is a late reply but hopefully still useful.

I see you're using Maple V Release 3, published in 1994. Please note that many of the inconsistencies you've noted in the handling of indexed names and symbols have since been resolved; in particular, since Maple 7 it has been possible to place assumptions on indexed names.

Also note that in your last line the input y=array(...)  did not actually assign the array to the value y; instead that is an equation whose left hand side is y and who right hand side is an array.  You need to use the assignment operator := (colon equals), as in some other programming languages such as Pascal.

On to your question, here is a way to get the behaviour you desire in your version of Maple, by assigning each indexed expression a[i] with a global name. Note this is the syntax used in Maple V Release 5 and prior versions and will not work in Maple 6 and later, where the dot operator now refers to matrix multiplication and not concatenation of names.

> for i from 1 to 3 do assign(a[i],a.i); assume(a.i>0); od;
> about(a[1]); # observe that the assumption has been placed
Originally a1, renamed a1~:
  is assumed to be: RealRange(Open(0),infinity)

> int(exp(-x^2*a[1]),x=3..infinity);
                                         1/2          1/2          1/2
                                       Pi           Pi    erf(3 a1~   )
                                  1/2 ------ - 1/2 -------------------
                                        1/2                1/2
                                      a1~                a1~

In Maple 7 and later versions you can do this all in a single line directly with the indexed expressions:

> int(exp(-x^2*a[1]),x=3..infinity) assuming seq(a[i] > 0, i=1..3);


To continue on what Joe Riel said, please note that because Maple has three-valued logic, the result of evaluating a boolean expression may be true, false, or FAIL. So if you do want to project this onto {0,1} you'll have to think of what you would want FAIL to map to, or perhaps extend your destination range to {-1,0,1}.

If you prefer to work with integers and not evalhf as in Joe's answer, a slightly simpler implementation of your evalbb procedure which maps false and FAIL to the same place (which may or may not be what you want) is the following:

evalbb := proc(PP) option inline;
end proc:
First off, please be more polite. We certainly aren't obligated to help you, and people who might be helpful are much less inclined to be so when they are confronted with block capitals and exclamation marks demanding their attention. That said, I think we can say a few things about Maple syntax without giving away too much. Let's start simple: a level plain. Here is a Maple procedure that returns the constant 900 for all inputs x, y:
f := proc(x,y) 900 end proc:
Getting a bit more complicated, here is one that varies in elevation between 800 and 900 depending on the value of x and y. Can you see why it does this from the code between "proc(x,y)" and "end proc:"?
f := proc(x,y) 850 + 25 * (cos(x) + cos(y)) end proc:
You can plot either of these functions looks like with the command
plot3d( f(x,y), x = 0..10, y = 0..10 );
(where 0..10 can be replaced by whatever is appropriate.)
It's true that Student supersedes student, but this is terms of functionality. 'Student' is intended to cover the same functionality as 'student', but it does so using different syntax. So syntax lifted from 'student' without changes won't work, but you can probably find a new way to write it using 'Student'. Can you show us the code in question so we can suggest how to rewrite it in terms of the 'Student' package?
Explicitly checking the degree of each term might be a bit expensive. Here is one way using PolynomialTools which avoids this:
SplitPolynomialEvenOdd := proc(p, x)
   local v, n;
   v := PolynomialTools:-CoefficientVector(p, x);
   n := rhs(rtable_dims(v));
   add( v[2*i-1]*x^(2*i-2), i=1..n-iquo(n,2) ),
   add( v[2*i]*x^(2*i-1), i=1..iquo(n,2) );
end proc:
Just out of curiosity, why is this operation useful? I guess it allows you to write the polynomial as f(x^2)+xg(x^2) for f,g polynomials, which I suppose might come in handy. Speaking naively, though, the omission of such functionality from PolynomialTools doesn't seem surprising.
Hello there, Just to make sure, could you tell me what you mean by 'convexity/concavity' in this case? (I know the usual definition, i.e. f is convex on [a,b] if for all t in [a,b], we have f(ta + (1-t)b) ≤ tf(a) + (1-t)f(b).) If this is what you mean, then obviously to handle your function it would be necessary to generalize this to two dimensions, i.e. see whether the plane passing through three points f(x1), f(x2), f(x3) on the curve lies below the curve itself on the convex hull of {x1, x2, x3}. How do you want to define the intervals on which you want to test for convexity? As you say, you could discretize the function and then test each point for convexity with respect to its three closest neighbours. Is this what you'd like to do? I suspect this will give you a lot of noise, especially in very flat regions, but you could probably avoid this by declaring a segment convex or concave only if the distance between the point and the plane was more than some epsilon.
With a bit of help from LEO, the German translates to

  Analyse the following break in the partial fraction.

although bruch could also mean 'fraction' (which is very confusing!).

As before, I updated the post to avoid the < and > tags.
First off, it's often considered rude to post "urgent" requests for others to help with what looks a lot like a homework problem. That said, let's look at your problem. You have a matrix with missing entries. In general, the contents of a matrix can be anything. In order to pinpoint the missing data, you need to know more about your matrix. For example, suppose I have the matrix
    [1   3   9]
M = [         ]
    [?   2   7]
    [         ]
    [9   7   3]
The ? could be anything: -1, 4, or 147. If, however, I know additionally that M has the property of being "symmetric", then I know that the entry in row i and column j has to match up with the one in row j and column i. So, the question mark in row 2 and column 1 has to be equal to 3, which is the value in row 1 and column 2. Now, your particular matrix isn't symmetric, because entries (1,3) and (3,1) don't agree. But there is probably some more information you have about the matrix, some other property, that you haven't mentioned and that you can use to solve this problem.
The string you specify in the catch clause matches the (generic) error template used to generate the error, not the specific error string. One would hope it would work this way; if it needed an exact match, then you'd need to know the runtime exception string, which usually depends on input, when writing the code! (However, after a quick glance at ?try it seems this could be documented better.) You can use 'lasterror' or 'lastexception' to determine what the error template was for the last error that occurred, so you don't have to guess what to put in the catch clause. For example:
> NotAModule:-mem();
Error, `NotAModule` does not evaluate to a module
> lasterror;
               "`%1` does not evaluate to a module"

> lastexception;
        0, "`%1` does not evaluate to a module", NotAModule
So the error template here is "`%1` does not evaluate to a module". So it should suffice to replace `NotAModule` in the string in your catch clause with `%1`, and thankfully it does:
> restart;
> proc()
      catch "`%1` does not evaluate to a module":
          print("it worked")
          print("it failed");
      end try
  end proc();
                         "it worked"
Now, it might be that you want things to be specific to NotAModule, i.e. for some reason, you want to catch the event when the nonexistent module is called "NotAModule", but to let through the event when the nonexistent module is called "AlsoNotAModule". In that case, though, I suppose you can still catch all cases, then check the value of [lastexception][3] and rethrow the exception if it's not the one you want to catch, i.e. NotAModule.
1 2 3 Page 2 of 3