Stephen Forrest

Mr. Stephen Forrest

451 Reputation

18 years, 120 days
Maplesoft
Software Architect

@Joe Riel: There were performance enhanc...

@Joe Riel: There were performance enhancements achieved in 2018, but the most significant performance improvements have been around since Maple 2016, which used off-the-shelf MiniSAT.  So I suspect that Maple 2016 or 2017 would behave comparably for this example, and users of those versions of Maple should feel free to give Logic:-Satisfy a spin.

It's also worth mentioning that there is (also since 2016) Logic:-Satisfiable, for cases where all you need is to know whether a satisfying instance exists and not what it actually is.

Many of the other routines in Logic including Equivalent, Contradiction, and Tautology all make use of Satisfy/Satisfiable and thus the MapleSAT external SAT solver.

@itsme and @Leo Brewin: thanks...

@itsme and @Leo Brewin: thanks for posting that regex postprocessor.  Do I presume correctly that you would like to see this type of output incorporated in the output of the latex command in general?  We could do so, perhaps controlled by one or more options.

A couple of questions:

1. Do you ever want rationals or rational expressions displayed as a/b, or would you prefer \frac{a}{b} every time?
2. Is there ever a context in which you want whitespace formatting characters (e.g. \, and \!) in output?

Please provide more context...

@chemicaholic I'm afraid this doesn't clear things up. Can you provide an example in which cMo_Coeff_Ndim and cMo_Coeff_Dims are declared and initialized and bounds is declared?

Based on what you posted, there is no way the result of MapleToM_INT(kv, ToMapleInteger(kv, ...)) could be responsible for making this loop infinite, as the loop termination condition depends only on cMo_Coeff_Ndim and i, neither of which can be affected by the MapleToM_INT(...) result.

Use URL rather than HTTP...

The HTTP package has been superseded in versions of Maple past Maple 18 with the URL package.

data := URL:-Get("http://www.fuelsonline.ca/");

The URL package also supports custom outgoing headers, including custom User-Agent settings, which allows you to masquerade as a browser (e.g. Chrome or Firefox) should you need to do so.'

You will still need to parse the resulting HTML, and if the result from the site depends on the browser executing JavaScript then you might be out of luck.

combinat:-firstperm and combinat:-nextpe...

I would echo the points made by Markiyan and Joe, and encourage you to look at and make use of the Iterator package that Joe mentioned.

If however you have an older version of Maple and don't want to download Iterator, it might help to know that even combinat itself offers a way to iterate through all the permutations without building a comprehensive list of them up front, using combinat[firstperm] and combinat[nextperm].

ListTools:-Search is just a frontend to ...

@MathyMaple ListTools:-Search is just a convenient frontend to member to avoid you having to use the third argument, as you can see by inspecting the code with showstat:

> showstat(ListTools:-Search);

ListTools:-Search := proc(pattern, L)
local p;
1 if member(pattern,L,p) then
2     p
else
3     0
end if
end proc

As to your question, I'm a bit surprised by your concern with speed. Using ListTools, it's true you pay a slight cost (once per session) to access the package from the archive, but that is negligible. Either member or ListTools:-Search should be fast even on large lists.

For example in the following example I can build a list with 100,000,001 elements and search it:

L := [0 \$ 10^8, 1]:
time(ListTools:-Search(1,L));


On my computer, this search takes 700 ms.

ExportMatrix or, in Maple 2015, simply E...

@tomleslie You mean the following:

ExportMatrix(filename, maple_matrix, target=Matlab);

For example assuming the current directory is writeable, one might write:

  M := LinearAlgebra:-RandomMatrix(5);
  ExportMatrix("test.mat", M, target=Matlab);

Note that in Maple 2015 you can output to Matlab format just using the multipurpose Export command, and the format will be read implicitly from the file extension. For example the second line above simply becomes

  Export("test.mat", M);

Therefore, a two-step process to plot a sine curve in Maple 2015, extract its points and export them to Matlab format would be:

  data := plottools:-getdata( plot(sin) );
  Export( "plotoutput.mat", data[3] );

Note this above example is particularly simple because of the type of data produced by plot(sin); in general you will need to know what you want to get out of the plot and do some processing on the result of getdata to filter out everything else.

Unlikely to be in passing the list...

I doubt the problem is in passing in the list.

A couple of things to check:

1. Does your procedure f2 take a variable number of arguments or a fixed number? You can execute trace(f2) to watch exactly what values the parameters of f2 are assignment (perhaps this is what you meant when you referred to the program trace).
2. Are you making use of inplace list assignment somewhere? E.g. assigning to list elements via L[1] := 5, etc.

Those used to inplace assignment as found in, for example, C or Java occasionally run into this issue in languages like Maple. For example, consider the following code:

L1 := [1,2,3]
L2 := L1;
L1[1] := 4;


One would correctly expect L1 to have the value [4,2,3], but one might also falsely expect L2 to also be [4,2,3] because you believe it is a reference to the same list. It is not: the last assignment above does a complete copy of the list and points L1 at the new copy. If you need inplace assignment use Arrays.

Count terms...

@Adri van der Meer If you are going to pay the price of expansion, you may as well count the expanded terms.  E.g.

countterms := proc(f) local fe := expand(f); if type(fe, +) then nops(fe) else 1 end if; end proc:

countterms((x+y)^2);

3

@J F Ogilvie Thanks for your commen...

@J F Ogilvie Thanks for your comment. Quoting from the online help, the Classic Interface "provides a basic worksheet environment for older computers with limited memory"; as such, it exists for legacy reasons and has undergone few changes in recent years.

In general, you can assume that descriptions of user interface features which do not explicitly mention the Classic interface apply only to the Standard interface (i.e. the Java interface).

What is the size of the file now?  ...

What is the size of the file now?  Maple produces this question if you try to use it to open a blank file.

Thanks...

I'd like to echo the many thanks to HeiniKlum for this report.

For those interested in the technical details, the issue is with the precedence of the Coercion structure in the intermediate form representation of the input.

The solution suggested by Thomas Richard of using coercetypes=false should work around this issue for all cases for CodeGeneration[Perl] and CodeGeneration[Python].

Batch export via eBookTools:-CreatePDF...

Batch programmatic export of worksheet content is available with the eBookTools:-CreatePDF command, which exports one or more worksheets/documents to PDF.

However, this does completely answer your need, as it does not include the batch execution step.  You can execute worksheets programmatically with DocumentTools:-RunWorksheet, but its output is limited to that which is explicitly returned with a 'return' call.

@Erfan It seems strange that you're...

@Erfan It seems strange that you're getting a Google Chrome error.  I presume you are trying to download the Maple worksheet from someplace on the web?

If so, perhaps you could try right-clicking the link to the worksheet and saving it somewhere on your local computer.  Then open Maple 16 via the Start menu and try to open the worksheet with File -> Open

Example A1 in today's Maple...

Time has marched on since this highly informative post from Will in 2005, and Maple has evolved to be more user friendly.  Commenting specifically on example A1:

As of version 11, when you plot an expression which contains only one unknown, Maple automatically takes that unknown to be the independent variable for plotting.  So now instead of an error asking you to specify the independent variable, we have:

> f := 2-x;
> plot(f);



 1 2 3 4 5 6 7 Page 1 of 7
﻿