pchin

Dr. Paulina Chin

1416 Reputation

12 Badges

19 years, 241 days
Maplesoft
Senior Architect
Waterloo, Ontario, Canada

MaplePrimes Activity


These are answers submitted by pchin

Here's another possibility:

Create a bunch of empty polygons having the same colours as those you've defined for the pie chart and include these in your plot.

> colorlist := ["red", "Orange", ...];
> legendlist := ["first entry", "second entry", ...];
> p1 := plots[display](seq(plots[polygonplot]([[0,0],[0,0]], color=colorlist[i], legend=legendlist[i]), i=1..nops(colorlist))):
> plots[display](p1, p2);

where p2 is the pie chart plot.

Paulina

Currently, writedata does not work with rtables. Have you tried using ExportMatrix? ExportMatrix accepts Vectors and Matrices, though not Arrays. Though ExportMatrix doesn't allow the precise formatting offered by writedata, it supports a variety of target output formats. In Maple 14, a number of updates were made to ImportMatrix/ExportMatrix, including support of Matlab binary files.

Paulina

As mentioned by others, Statistics:-NonlinearFit uses the local optimization solvers provided by the Optimization package. Thus, there is no guarantee that the solution you get is an optimal one. A few years ago, I wrote a blog post about the differences between the Optiimization and GlobalOptimization packages. Perhaps you will find this information useful. (As a side note, I noticed to my dismay that all the line-breaks had disappeared from my original post. I've edited the post and added the line-breaks back in, hopefully in the same locations as before!)

Regarding acer's suggestion that GlobalOptimization be called by NonlinearFit ... this has been requested before and is recorded in our database. So it is under consideration and won't be forgotten, but I can't make any promises about when it will show up in Maple. As Robert rightly points out, you don't always want to use GOT even if you have it. For each problem, you need to decide the relative importance of solution quality versus computation cost.

Paulina

If you can produce a text file, then the commands that Robert had suggested are all useful, but I would recommend looking at the ImportMatrix command as well. For example, if your output consists of two columns of numeric data, ImportMatrix will put the data directly into a Matrix, which can then be passed to the plots:-pointplot command.

Paulina

In addition to the plots:-animate command, you can also use:

n := 100:
for i to n do
  p[i] := plots:-pointplot(...);
end do:
plots:-display([seq(p[i], i=1..n)], insequence=true);

This calling sequence will allow you to avoid the bug mentioned by Joe and Preben.

Preben, I've increased the priority of the original bug you'd submitted, and hopefully, we'll get a chance to deal with it soon (It had a modest priority originally because the bug doesn't occur very often and there is a workaround.)

Paulina Chin
Maplesoft

In earlier Maple releases, 'circle' was used in 3-d plotting to mean 'sphere'. We added the 'sphere'  option value in Maple 11, along with several other symbols, but we kept 'circle' for backward compatibility. Because we've not had too many requests for a flat circle symbol, we've not had a reason to change the behaviour. (We generally try to maintain backward compatibility unless there's a compelling reason to do otherwise.) It's possible to draw flat circles in other ways (as you've pointed out in another thread), though it is much less convenient than using the symbol option.

Paulina

Christopher, your guess was right, but I will confirm that it is currently not possible to create custom symbols for use with the 'symbol' option.

Paulina

A while ago, I wrote a blog post about this subject that you may find helpful.

Paulina Chin
Maplesoft

In response to your question, Alec, a number of us here did buy copies of Snow Crash and have been sharing with others. I myself bought an ePub version for my Sony eReader. Some of us also used the local public libraries, which all have copies of this book. I realize the availability might not be so good elsewhere in the world.

Paulina

Regarding this example:

> F:= c -> Int(3*c*x^2 + c^2*x, x = 0 .. 1);
  Optimization:-NLPSolve(F);

Error, (in Optimization:-NLPSolve) complex value encountered

There are a couple of issues here. First, there is a check in NLPSolve for type(..., complex). This is my mistake; the type-check should be for complex(numeric), as F(0.), for example, satisfies type/complex.

The other problem is that, while the Optimization routines apply evalf to the objective function procedure if an initial attempt with evalhf computation fails, they currently don't do this with gradient and Jacobian procedures generated through the codegen automatic differentiation package. The error actually occurs in evaluation of the gradient of F. If you try the above call with method=nonlinearsimplex, a derivative-free method, it will succeed. The suggestion from acer to supply your own gradient will help in this case; it's generally a good idea anyhow, as it often leads to better performance.

I will add these notes to the bug report Robert had submitted, and we'll look at improving the situation in a future release. In the meantime, a workaround is to ensure the procedure representing the objective function always returns a numerical value, as Robert and acer mention above. Indeed, the Optimization help pages say that the objective function, given as a procedure, should accept floating-point arguments and return a floating-point value. The Optimization commands are "forgiving" to some extent, for ease of use, but ensuring numeric input and output leads to the most efficient computation.

Paulina

I think acer's guesses are closest to what's going on here. I didn't write the code used for this algorithm, so I'm also guessing to some extent, but this is what seems to be going on.

First, an interpolating polynomial is used to make an estimate of the Lipschitz constant. In some intervals, the estimated constant is extremely large (a pitfall of using this kind of interpolation) and the bounds are consequently not very accurate. As a result, certain cells that should have been further subdivided are rejected based on the bounds. That is the reason that, for the range -5 to 5, the global maximum is not found.

Some of you have noticed that, if the range is shifted slightly, a better solution is found. That's because, to do the interpolation over a cell, sample points are chosen based on the range provided. The results of these evalutions are examined, and the max/min values are saved if they are better than the currently saved max/min values, even if the cell is subsequently rejected. So different ranges result in different sample points, and in some cases, we're "luckier" than others. That's why -5.1 to 5 gives a better result.

Is there a bug in this situation? I don't think so. If there's a "bug", it's that the algorithm isn't particularly strong. There are improvements that can be made, but to be honest, they are not a high-priority item for us. We added this very basic global univariate solver as a "bonus" to NLPSolve, but the Optimization package is primarily a local optimization package. There is a branch-and-bound solver in the Global Optimization Toolbox (though it is not the default algorithm used) and it is a much stronger one. I'd recommend you use that package if you need a more reliable global optimization solver.

Paulina Chin
Maplesoft

Melykin, the easiest way to generate a 3d plot of points is to use the plots[pointplot3d] command. There are several examples on the help page to get you started. You can change the symbol using the 'symbol' and 'symbolsize' options, and the available values for these options are described on the plot3d/options help page.

Paulina Chin
Maplesoft

Pagan summarized the situation quite well. I'd also written something about this in a blog post a couple of years ago. Pagan writes:

I have  few objections to how it`s been implemented, some of which others have previously mentioned. Firstly, you can`t tell which it is underneath, just by looking at that syntax in 2D Math. Second, whichever choice is made is not stored when the Document or Worksheet is saved.

We're aware of these limitations and understand that they pose a problem for users who exchange worksheets. We're looking at long-term solutions, but in the meantime, you could use the Typesetting[Settings] command, as described in the blog post, to avoid the disambiguation dialog. The advantage of using the Settings command is that it can be included explicitly at the beginning of your worksheet and thus be visible to another user of your worksheet.

Paulina Chin
Maplesoft

The Typesetting:-delayDotProduct command is an internal routine and shouldn't be displayed in this context. The problem arises because the parser has difficulty distinguishing between a pair of inequalities such as "x < 5, ..., 3 > 2" and the Matrix/Vector shortcut notation that uses angle brackets.

We'll investigate this issue, but in the meantime, a workaround is to change "x < -1" to "-1 > x".

Paulina Chin
Maplesoft

The plots[implicitplot] command has several options that may be useful to you. Unfortunately, these options have not been integrated into contourplot yet. If you have an idea of which contour values you'd like to plot, you can give impliciplot a list of expressions representing these values. Try the following, for example:

plots[implicitplot]([seq(-z*(1/(x^2+z^2)^(3/2)-1)=i, i in [-3, -2, -1, 0, 1, 2, 3])],x=-3..3,z=-3..3, gridrefine=2);

Paulina Chin
Maplesoft

 

1 2 3 4 5 6 7 Page 3 of 10