Dr. Paulina Chin

## 1416 Reputation

18 years, 332 days
Maplesoft
Senior Architect

## Samples in logarithmic plot...

This problem has been fixed in Maple 12. However, for earlier versions of Maple, you can use the 'sample' option to specify the sample points.  The loglogplot command will then use your sample points instead of calculating them on its own. Add the adaptive=false option when you use the sample option. You can get information about these options from the plot/options help page.

Paulina Chin
Maplesoft

## Function and procedures...

The problem boils down to the fact that not all smartplot features work with procedures. We'll look into improving this situation. Also, it is true that the terminology in the typesetting dialog box may add to the confusion, and we'll also review that to see if it can be improved. Thanks for your comments.

Paulina

## More on assignment to f(x)...

The questions you asked, elumineX, come up frequently and so I added a blog post with a few more details. I hope this will clear up the confusion.

Paulina

## Smartplots and procedures...

elumineX writes: "It doesn't work with f(x):=2x+2 (Maple doesn't create the smartplot), but with just 2x+2 it does. Whats wrong with plotting a function, Maple should be smart enough to know I want the right-hand side plotted when the only thing on the left if f(x)/y?"

When you choose Plot from the context menu, Maple does plot the right-hand-side of the assignment. The problem with f(x):=2*x+2 is that, in Maple, this does not mean "let f(x) be the function 2*x+2". In 1-d math, it means "create a remember table entry". In 2-d math, you have the option of making it mean, "create a procedure f taking the variable x and returning 2*x+2", i.e. f:=x->2*x+2. This is exactly what you did, and context menu Plot works just fine on this procedure, with the exception that zoom-with-rescaling doesn't work. (That's just a limitation of smartplot with respect to procedures.) So to use that special feature, you have to assign the expression 2*x+2 and not the procedure x->2*x+2, to f instead. Alternatively, you can just enter the expression and use the context menu Plot without actually assigning the expression to anything.

Paulina Chin
Maplesoft

## Did you end up with a procedure?...

As David states, the context menu for f(x)=2*x+2 does not include Plot. Could it be possible that you had entered f(x):=2*x+2, and the typesetting disambiguator turned this into f:=x->2*x+2? I'm guessing that's what you did, as the output you got would be consistent with this situation.

First, f(x):=2*x+2 does not mean what you might think it means in Maple. In 1-d math input, this normally defines f as a procedure with a "remember table".  I won't distract you with the details but you can look at the 'remember' help page if you're curious.

When you enter f(x):=2*x+2 in 2-d math in the worksheet, Maple thinks that you probably meant to write f := x->2*x+2, as use of remember tables is not common, and it asks you via a dialog box whether that's the case. This actually defines a procedure f which then returns the value 6, for example, when you call it by entering f(2).

The plotting commands work on both expressions such as 2*x+2 and procedures such as x->2*x+2. However, the zoom feature which David describes works only when the input is an expression and not when it's a procedure. As a side note, keep in mind that in Maple, f(x):=2*x+2 (an assignment) is not the same as f(x)=2*x+2 (an equation).

Paulina Chin
Maplesoft

## Which interface are you using?...

I am unable to reproduce the labeldirections problem you describe. I tried both Standard and Classic interfaces on Windows and Linux. Also, command-line plots usually don't have labels displayed and there was no change between Maple 11 and Maple 12.

Could you let me know which interface and operating system you're using? Is this plot being displayed in a worksheet or document, or are you producing output for a different device?

Paulina Chin
Maplesoft

## Coords option in contourplot...

Alec, you are right. The coords option does not work in contourplot. I'll add this report to our bugs database and investigate.

Paulina Chin
Maplesoft

## Define colours first...

Did you remember to define the list of colors? In Robert's example, he includes this command right after the ImportMatrix call:
colours:= [red, green, blue, cyan, black];

Paulina Chin
Maplesoft

## Animation example...

Hi Harry,

You might find this thread helpful. Robert Israel gives an example showing how to animate a torus using plottools[rotate] and plottools[torus]. The plottools package has commands for creating an ellipse, as well as commands for translating and scaling an object.

Paulina Chin
Maplesoft

## plottools[torus]...

The plottools[torus] command creates a torus that can be displayed with the plots[display] command. Take a look at the examples on the help page. This command can then be used in combination with the plots[animate] command to create the animation you desire.

Paulina Chin
Maplesoft

## Changing the font of an axis label...

If you are creating your plot interactively in the Standard GUI, then the easiest way to change one of the labels is to right-click on the plot and bring up the context menu. Choose "Axes", followed by "Labels", followed by "Edit horizontal" or "Edit vertical". You can then select the font style and size in the context bar.

If you need to do this task programmatically, then try Robert Israel's suggetions. Alejandro Jakubi's suggestion works too. However, unless you are restricted to use of 1-D input for some reason, it's much easier to just use the palettes to generate an expression than to figure out the internal representation of these objects. For example, to get a Greek letter, open the Greek palette and click on a symbol when you're building your plot command. If you create an expression that does not parse in Maple, use the context menu to create an atomic identifier first. (See this blog post for instructions.)

Paulina Chin
Maplesoft

## Using left quotes for typesetting...

The plot/typesetting page does say you can use left quotes to create a name to be typeset. So in the example of p with superscript *, you should be able to do p^`*`. The problem is that the left quotes show up in the typeset display, so that's why you have to use the Typesetting:-mo("*") workaround. Note that this is a problem particular to just a few symbols that have special meanings in Maple. The limitation with using left quotes in 1-d input is that it creates a name out of the character sequence. So `p^2` gives you exactly that, not p with superscript 2. Again, generating 2-D output from 2-D input should be very straightforward. Generating 2-D expressions from 1-D input is trickier, because the 1-D language doesn't capture (in a simple way) all that's in the 2-D language. For some special cases, you have to resort to some not-so-pretty workarounds. I will submit a bug report asking that the plot/typesetting help page include more details and examples for these situations. Paulina

## Typesetting in textplot...

First, rest assured that we don't really expect users to figure out how to use the internal typesetting representation and generate those ugly strings with msubs and all. You shouldn't have to do this. The easiest approach, if possible, is not to use 1-D input at all. In a 2-D input line, enter textplot([0.75, 0.4, 2-d-expression]). Where I've written 2-d-expression, go to the Layout palette, choose the expression you want and fill in the entries. Then execute and you should get the result you want. If there's a chance that the entry might evaluate or parse incorrectly, then it's best to select the expression and convert into an atomic identifier using the context menu. If you must use 1-D input (e.g. you're writing a procedure that's saved to a text file), you can still do this fairly easily. To get p with subscript g and superscript t, for example, use textplot([0.75, 0.4, typeset(p[g]^t)]). Doing typesetting in 1-D is a lot trickier because the expression must be parsed correctly in 1-D. So if you want t to be the symbol `*`, you must then resort to using something like Typesetting:-mo("*") because * has a particular meaning in 1-D math. Of course, as a developer, I'd prefer that you avoid using the internal undocumented representation unless it's absolutely necessary. You shouldn't have to do this in the majority of cases. Paulina Chin Maplesoft

## Dragging an expression into a plot...

Shannon, dragging an expression into a plot ought to work. For example, if I enter the command plot(sin(x), x=0..2*Pi), a plot is displayed. Then, I can type cos(x) in another input line, select cos(x) from either the input or output line, and drag and drop that into the plot. The curve for cos(x) should appear. Could you provide the example that isn't working for you? Paulina Chin Maplesoft

## NLPSolve and Maximize...

Thanks for your comments, acer. I apologize for my error in saying that branchandbound is used. Yes, the default method is quadratic, not branchandbound. It is true that using Maximize does not lead to the most efficient result. This is a general routine that does a lot of analysis to figure out the problem type and guess at the right method. It is indeed suggested on the help page that if efficiency were an issue, you should use NLPSolve directly. Note that method=quadratic is a local method while method=branchandbound is a global one. Perhaps this makes no difference for this particular application, but in general they may produce different results. Paulina
 5 6 7 8 9 10 Page 7 of 10
﻿