Doug Meade

 

Doug

---------------------------------------------------------------------
Douglas B. Meade <><
Math, USC, Columbia, SC 29208 E-mail: mailto:meade@math.sc.edu
Phone: (803) 777-6183 URL: http://www.math.sc.edu

MaplePrimes Activity


These are replies submitted by Doug Meade

The animate command is really quite useful in situations like this. The syntax is a little strange, at first, but once you use it a couple times it really starts to make sense. There is one extra wrinkle that arises when trying to use animate to plot from a list, but we'll explain this a little later.

Here is how I would approach your problem. First, I have to make up some lists, you'll have your real data to use in this place.

drivingForceList := [1,2,3,4]:
myFunctionList := [ x/6, sin(x), cos(x), exp(-x) ]:

Next, define a procedure to create one frame of your animation:

myPlot := p -> plot( myFunctionList[ trunc(p) ], x = 0 .. 2*Pi );

Note that this procedure has to be written from the point of view that it will be given a floating-point number, which has to be converted to an integer before it's used as an index into a list. (This is the annoying part of this implementation.)

Now, the animate command is:

plots:-animate( myPlot, [ p ], p = 1 .. nops(drivingForceList), frames=nops(drivingForceList) );

It would be nice if animate worked more naturally with a discrete list of plots, but this is not so bad.

We're not done. There is one more option, trace=<number>, that tells Maple to leave <number> images as a sort of cumulative background. You might be able to use this to achieve the spacing effect you mentioned, maybe something like:

nDF := nops(drivingForceList):
plots:-animate( myPlot, [ p ], p = 1 .. nDF, frames=nDF, trace=trunc(nDF/5) );

The examples in the Maple help page for animate show how other effects can be achieved.

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu

No!

While sum works on your example, it's not likely to work for may real problems.  The sum command is intended for general sums for which it is expected (hoped) that there is a closed form expression for the sum; sum does not add the terms together. In contrast, the add command just adds the terms it is given.

Doug

P.S. This comes up so often it really does deserve to be on a FAQ. Also, it would be nice if the MaplePrimes interface included a link to Maple's online help system (which should open in a separate tab or window).

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu

No!

While sum works on your example, it's not likely to work for may real problems.  The sum command is intended for general sums for which it is expected (hoped) that there is a closed form expression for the sum; sum does not add the terms together. In contrast, the add command just adds the terms it is given.

Doug

P.S. This comes up so often it really does deserve to be on a FAQ. Also, it would be nice if the MaplePrimes interface included a link to Maple's online help system (which should open in a separate tab or window).

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu

Look carefully at Maple's output after you first entered the expression. All you see is the difference of two rational expressions in sqrt(a).

What happened to the second term in the product? Look even closer, and you'll see that every occurrence of a in the first term has been replaced by a(1+1/sqrt(a)) (with 1+1/sqrt(a) simplified to (sqrt(a)+1)/sqrt(a)).

Because there is not a space between the parentheses, Maple interprets the two terms in the original input as function evaluation, viz. (f+g)(2) = f(2)+g(2). To get the product, put a space (or *) between the two terms: (f+g) (2) = (f+g)*(2) = 2f+2g

All of this well-documented, but it is still a very common user mistake.

When the input is changed to get the product of two terms, Maple still does not automatically reduce this expression to the desired form. A first problem is that Maple is not going to assume a is positive, so branch cuts come into play during simplification. Even working symbolically, Maple does not simplify this as the OP hopes. But, when we ask Maple to factor the expression over the field extended by sqrt(a), Maple spits out exactly what we want.

q := ((2+sqrt(a))/(a+2*sqrt(a)+1)-(sqrt(a)-2)/(a-1))*(1+1/sqrt(a));
                /        (1/2)       (1/2)    \             
                |   2 + a           a      - 2| /      1   \
                |---------------- - ----------| |1 + ------|
                |       (1/2)         a - 1   | |     (1/2)|
                \a + 2 a      + 1             / \    a     /
simplify( q );
                           /     (1/2)\ / (1/2)    \   
                         2 \a + a     / \a      + 1/   
                      ---------------------------------
                      /       (1/2)    \          (1/2)
                      \a + 2 a      + 1/ (a - 1) a     
simplify( q, symbolic );
                           /     (1/2)\ / (1/2)    \   
                         2 \a + a     / \a      + 1/   
                      ---------------------------------
                      /       (1/2)    \          (1/2)
                      \a + 2 a      + 1/ (a - 1) a     
factor( q );
                           /     (1/2)\ / (1/2)    \   
                         2 \a + a     / \a      + 1/   
                      ---------------------------------
                      /       (1/2)    \          (1/2)
                      \a + 2 a      + 1/ (a - 1) a     
factor( q, sqrt(a) );
                                      2  
                                    -----
                                    a - 1

One final comment. I could not find a way to get this factorization using 2-d input and the context menus.

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu

Very nice, but I'm afraid this is not going to be very robust.

There are many other plot features that cannot be set in display. Unless there is a full complement of "recolor" commands (rethickness, resymbol, ...) the utility of recolor is pretty limited. Also, what about more complicated plots where the color is based on a color function? (Well, I suppose that's an issue only on some 3D plots.)

In most cases it's probably much easier to just recreate the plots. For example,

p1 := plot( sin, color=blue ):
p2 := plot( cos, color=green ):
plots:-display( p1,p2 );

I hope this is helpful,

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu

 

Very nice, but I'm afraid this is not going to be very robust.

There are many other plot features that cannot be set in display. Unless there is a full complement of "recolor" commands (rethickness, resymbol, ...) the utility of recolor is pretty limited. Also, what about more complicated plots where the color is based on a color function? (Well, I suppose that's an issue only on some 3D plots.)

In most cases it's probably much easier to just recreate the plots. For example,

p1 := plot( sin, color=blue ):
p2 := plot( cos, color=green ):
plots:-display( p1,p2 );

I hope this is helpful,

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu

 

The issue of spaces between function names and their arguments is not unique to the plot command. It happens anywhere - builtin commands, user-defined functins, ...

This recommendation would have to be placed on every help page, which is completely inappropriate. The decision, as I see it, is to either improve the parsers to recognize such situations or to do away with implied multiplication. For the former to work, there will have to be some decisions made about exactly when and where a space is, and is not, to be interpreted as multiplication. The latter also requires some changes to the accepted syntax. The decision is not an easy one, and the implementation will be tricky as well.

Might it not be possible to have the best of both worlds? Would it be possible to allow users to turn off implied multiplication? (This should be linked to the Upcoming Development thread.)

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu

The issue of spaces between function names and their arguments is not unique to the plot command. It happens anywhere - builtin commands, user-defined functins, ...

This recommendation would have to be placed on every help page, which is completely inappropriate. The decision, as I see it, is to either improve the parsers to recognize such situations or to do away with implied multiplication. For the former to work, there will have to be some decisions made about exactly when and where a space is, and is not, to be interpreted as multiplication. The latter also requires some changes to the accepted syntax. The decision is not an easy one, and the implementation will be tricky as well.

Might it not be possible to have the best of both worlds? Would it be possible to allow users to turn off implied multiplication? (This should be linked to the Upcoming Development thread.)

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu

The syntax for the plot command:

plot( [ u, v, t=a..b ] );

is for a parametric curve given by x=u, y=v for t from a to b. (Look at the example given elsewhere in this thread; you don't see two curves, just one - and it is not the graph of two exponential functions.)

This is clearly explained in the documentation. I do not see this form listed on the main page for plot (?plot), but I do find the following on the page for ?plot,details:

Using the Parametric Form

  • In the third calling sequence, plot([expr1, expr2, t=c..d]), the function is specified in parametric form.  The first argument is a list having three components: an expression for the x-coordinate, an expression for the y-coordinate, and the parameter range. For example, to plot a circle, use plot([sin(t), cos(t), t=0..2*Pi]).
  • The fourth calling sequence shows the operator-form of a parametric plot. Here, the first argument is a list containing two procedures or operators, specifying the x- and y-coordinates respectively, and a range.  For example, to plot a circle, use plot([sin, cos, 0..2*Pi]).
  • For more information about parametric plots, see the plot[parametric] help page.

I hope this helps to explain what Maple is doing, and why it complains about your initial attempts to use plot.

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu

The syntax for the plot command:

plot( [ u, v, t=a..b ] );

is for a parametric curve given by x=u, y=v for t from a to b. (Look at the example given elsewhere in this thread; you don't see two curves, just one - and it is not the graph of two exponential functions.)

This is clearly explained in the documentation. I do not see this form listed on the main page for plot (?plot), but I do find the following on the page for ?plot,details:

Using the Parametric Form

  • In the third calling sequence, plot([expr1, expr2, t=c..d]), the function is specified in parametric form.  The first argument is a list having three components: an expression for the x-coordinate, an expression for the y-coordinate, and the parameter range. For example, to plot a circle, use plot([sin(t), cos(t), t=0..2*Pi]).
  • The fourth calling sequence shows the operator-form of a parametric plot. Here, the first argument is a list containing two procedures or operators, specifying the x- and y-coordinates respectively, and a range.  For example, to plot a circle, use plot([sin, cos, 0..2*Pi]).
  • For more information about parametric plots, see the plot[parametric] help page.

I hope this helps to explain what Maple is doing, and why it complains about your initial attempts to use plot.

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu

While I do agree with jakubi's suggestion, I think his post provides an opportunity to reiterate one of my previous requests. (At least, I think I wrote about it previously - but that's part of my point as well.)

Inserting hyperlinks in a post is relatively easy. But, if the cross-reference is to another post in MaplePrimes, getting this URL requires opening a second MaplePrimes window. This is not so bad, but I believe many posters do not go to this trouble.

What I would like to see is for MaplePrimes to store partially composed comments.

This would facilitate browsing within MaplePrimes while composing a response. It would also eliminate (or greatly reduce) the frustration of inadvertently refreshing the MaplePrimes window and having a partially composed comment completely disappear. (This happened to me when I tried to check for new posts before submitting my own comment. Now, I just post and don't worry about duplication.)

This would also be a benefit for those times when MaplePrimes is non-responsive when "Post comment" is pressed and  the poster does not  know if MaplePrimes has received the submission. In these cases I have developed the habit of copying the contents of the Comment window in case I have to re-enter it. What's even worse when MaplePrimes response is "database unavailable" - by the time this appears you have lost the Comment window.

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu

What do you know about your matrix?

IIs it positive definite? Invertible? Symmetric? Banded? ???

What do you mean by smallest? In absolute value? Most negative?

If the matrix is positive definite(so all eigenvalues are positive), then the 10 smallest eigenvalues of your matrix are the reciprocals of the 10 largest eigenvalues of the inverse matrix (with the same eignevectors). This could lead you to a quicker computation, but only if you can get the inverse without too much trouble.

What are you going to do with the information, assuming you can find it? Maybe there is another way to this goal?

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu

What do you know about your matrix?

IIs it positive definite? Invertible? Symmetric? Banded? ???

What do you mean by smallest? In absolute value? Most negative?

If the matrix is positive definite(so all eigenvalues are positive), then the 10 smallest eigenvalues of your matrix are the reciprocals of the 10 largest eigenvalues of the inverse matrix (with the same eignevectors). This could lead you to a quicker computation, but only if you can get the inverse without too much trouble.

What are you going to do with the information, assuming you can find it? Maybe there is another way to this goal?

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu

I understand this, but it's not that simple I can copy and paste a matrix directly from Maple to Word. This tells me it should be possible to do the same when copying to MaplePrimes. (The situation with plots is almost identical.)

Some of my requests require some changes in Maple, not just MaplePrimes. I don't see any problems with this. There will be new versions of Maple, and I hope some of my suggestions can help guide the development of these future releases.

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu

There are many times when I wish posts appeared with the most recent post first. I'm not sure I want to force all users to read topics in this form, but I would like (at least) the option of reversing the order.

Only the last 10 comments appear in the Recent Comments list. Sometimes I can see that a post I am following has a new post (because it is on the Active Main Forum Topics) but that comment is already off the Recent Comments list. When I click on the topic, I then have to scroll down, or notice that there are now two (or more) pages of comments.

Multi-page topics are not common (yet) but they are a real nuisance. You don't know they extend to a second page until you get to the bottom and notice the small links to additional pages. These links should appear at the top, and be more prominent in their appearance. And, in connection with the general theme of this post, I would like the option to have the most recent posts (the last page) shown first.

Some of these comments are not new. I know they've been made previously (sometimes by me).

Thanks for listening,

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu
First 20 21 22 23 24 25 26 Last Page 22 of 76