30214 Reputation

29 Badges

18 years, 242 days
Ontario, Canada

Social Networks and Content at

MaplePrimes Activity

These are replies submitted by acer

@MaPal93 I don't know that it could be done using the usual substructure generated by the legend item.

Of course, it would also be possible to fake the legend by putting three straight lines in a polygon that is placed carefully in an otherwise blank region of the plots interior. But that kind of ad hoc solution requires effort (locate such a region, make a nice scale, etc.) The up-side is that you can make such lines as long as you'd like within the restrictions of the region.

@Khair Muhammad Saraz To address two more followup queries by you:

For a 2D contour-plot from the Matrix MM you have two choices:
1) Do it directly, using the plots:-listcontplot command.
   (That's easy to do directly, but the axes tickmarks are trickier
    to get to match some arbitrary ranges). Eg,


2) Using Interpolate, and then use plots:-contourplot on that.
  (The first part is trickier, but has also been done before by me on
    this site. There's also an Example worksheet on Interpolation
    and smoothing that illustrates the first part.
    See also,
      Help Topic, ?examples,Interpolation_and_Smoothing
      some old post)

In my Answer's original attachment I already showed you how you could make nice tabulated data from a Matrix like MM.

@nmacsai The baseline for the color-bar doesn't appear to adjust properly w.r.t. the bottom of the title (in the way that the 3D portion does, say).

It seems that enlarging the view of the COLBAR's contents, along with judicious use of size for both parts, can make a suitable vertical adjustment.

Unfortunately not all of that was automatically determined. Automatic determination of the adjustment values might be possible, using font height (if obtainable in pixels, which can be an OS thing) and the view-to-plot-region-size ratio.

ps. Combining by plots:-display may well strip off such size adjustments. That's why I did a substitution for COLBAR's elements only after plots:-display.

@sursumCorda On my machine I need all the following for such "subexpression labeling" to occur,

1) interface(typesetting=standard):  # not default for my Maple 2024.0 on Linux
2) interface(labeling=true):  # default
3) interface(prettyprint=2):  # 3 by default

After that, it works. Unfortunately line-breaking of output is disabled by it, and the Java GUI is as good as the old Classic GUI at figuring out a good split. Manually doing,
is possible but I find that often no single value works as well as I'd hope.

Your code has a couple of instances of,

   else then

but that's not valid syntax.

Perhaps you just intended,


@Carl Love I wonder whether it could be even more visually informative if the orthogonal trajectory lines were shaded by steepness.

That's easier to do with 3D space-curves. For 2D curves it's less directly easy, though of course there are a variety of ways, eg. transform from 3D, manual construction, etc. (I've come across the need for easier 2D curve coloring before... I should collect prior notes and report suggestions.) 


[edit] For this followup snippet of yours one can examine the code and see that, yes, the name unknown is being used as a local.


Perhaps a developer wanted to make a play on the idea that the predicate foo in a type(expr,satisfies(foo)) call is often an anonymous procedure.

I forgot to show in brief form the effect of CollapseNested. So, on the chance that it might not have been crystal clear to all readers:

The two forms print slightly differently.

The key thing is that the collapsed form is just a single int or Int call, which controls the whole process and can utilize assumptions on the inner variables of integration (if it possible for it to infer it from the nested bounds).


W := Int(Int(Int(x1+x2+x3,x1=0..x2),x2=0..x3),x3=0..x);

Int(Int(Int(x1+x2+x3, x1 = 0 .. x2), x2 = 0 .. x3), x3 = 0 .. x)


Int(Int(Int(x1+x2+x3,x1 = 0 .. x2),x2 = 0 .. x3),x3 = 0 .. x)

T := CollapseNested(W);

Int(x1+x2+x3, [x1 = 0 .. x2, x2 = 0 .. x3, x3 = 0 .. x])


Int(x1+x2+x3,[x1 = 0 .. x2, x2 = 0 .. x3, x3 = 0 .. x])


Int(Int(Int(x1+x2+x3, x1 = 0 .. x2), x2 = 0 .. x3), x3 = 0 .. x)


Int(Int(Int(x1+x2+x3,x1 = 0 .. x2),x2 = 0 .. x3),x3 = 0 .. x)


I edited my previous Reply to use,
    x::RealRange(Open(Pi/3), Open(Pi))
instead of,
    RealRange(Open(Pi/3), Open(Pi))
in order to show that the only assumption placed & required there is on x. No manual assumption was placed on the variables of integration. (That was already occurring, as explained a few Replies back. But I wanted to show the aspect.)

@sursumCorda Your first example takes quite a while, and emits Warnings.

As I mentioned, using a "collapsed" form may allow a single int or Int to represent the whole triple-integral and, when computing, to pass the outer integrals' range inferences on to the inner ones. Using that form gets rid of the Warnings for your first example.

Using the collapsed form can sometimes speed things up. And sometimes it resolves an example that otherwise wouldn't succeed.

I asked my oracle and the sibyl responded with a simplification chain than can get the zero for your first example.


expr := (x + Pi/2) - (Pi/(2*sqrt(3))*sin(x) + Pi/2*cos(x) + 2*x*sin(x/2));



foo := 1/4*sin(x)*Int(1/cos(x1/2)**2*Int(cos(x2/2)**2/sin(x2/2)**3*Int(sin(x3/2)/(1 + sin(x3/2))*Int((1 + sin(x4/2))*(2*sin(x4/2) - 1) + x4/2*(cos(x4/2) + sin(x4)), x4 = 0 .. x3), x3 = 0 .. x2), x2 = x1 .. Pi), x1 = Pi/3 .. x) assuming x::RealRange(Open(Pi/3), Open(Pi)):



Int((1/4)*sin(x)*cos((1/2)*x2)^2*sin((1/2)*x3)*((1+sin((1/2)*x4))*(2*sin((1/2)*x4)-1)+(1/2)*x4*(cos((1/2)*x4)+sin(x4)))/(cos((1/2)*x1)^2*sin((1/2)*x2)^3*(1+sin((1/2)*x3))), [x4 = 0 .. x3, x3 = 0 .. x2, x2 = x1 .. Pi, x1 = (1/3)*Pi .. x])

ansAraw := CodeTools:-Usage(value(A))
   assuming x::RealRange(Open(Pi/3), Open(Pi)):

memory used=0.70GiB, alloc change=106.00MiB, cpu time=7.05s, real time=6.45s, gc time=1.03s

CodeTools:-Usage( simplify(combine(evalc(simplify(combine(convert(ansAraw-expr,expln)))))) )
   assuming RealRange(Open(Pi/3), Open(Pi));

memory used=272.79MiB, alloc change=0 bytes, cpu time=2.95s, real time=2.70s, gc time=419.47ms



In contrast here's that original first example. Granted, some timing differences may well be due to different form of the integrand (including combined trig, etc).


expr := (x + Pi/2) - (Pi/(2*sqrt(3))*sin(x) + Pi/2*cos(x) + 2*x*sin(x/2)):

CodeTools:-Usage(simplify(combine(1/4*sin(x)*int(1/cos(x1/2)**2*int(cos(x2/2)**2/sin(x2/2)**3*int(sin(x3/2)/(1 + sin(x3/2))*int((1 + sin(x4/2))*(2*sin(x4/2) - 1) + x4/2*(cos(x4/2) + sin(x4)), x4 = 0 .. x3), x3 = 0 .. x2), x2 = x1 .. Pi), x1 = Pi/3 .. x)) - expr)) assuming RealRange(Open(Pi/3), Open(Pi));

memory used=9.51GiB, alloc change=361.36MiB, cpu time=108.21s, real time=94.16s, gc time=18.61s


I found that direct timing comparisons within the same session were problematic, due to remembered results (and intermediate internal results). I found that example even more prone to such difficulty than usual; I don't know if that's due to the nature of the example or something to do with Maple 2024.

@nm The Physics updates package doesn't get installed by default. One has to choose to install it.

@Khair Muhammad Saraz I made two surfaces in each of my latest 3D plots.

Contrary to your apparent new claim, I did in fact use the approximate data for one of the surfaces, each time.

I stored the approximate data in Matrix MM. I used the plots:-surfdata command to render a surface using the data in Matrix MM. (In Matlab you showed using surf. That's similar to using surfdata in Maple.)

Can you see that my latest worksheets have a red exact surface as well as a blue approximate surface? Earlier you wrote that you wanted both. Can you see that the blue surface is constructed using the computed approximate data from your loop?

If you don't want them both together in the same plot then simply don't bundle them together with last display call. They're even already assigned to names which make it clear, Pexact and Papproximate.

This is my last response on this. You really should study the code and try to understand it and learn to program in Maple on your own. This is not unreasonable stuff. Try to understand properly what each part does.

ps. I think that storing the data in a Matrix (like MM) here is easier than storing it in tables (with that awkward copy each time through the loop). Using a Matrix makes it easier to plot afterwards, and (I expect) more understandable if you were to study it.

@nm Is this something (even for only some x...),

-sqrt(2)*EllipticF(sqrt(2)*sqrt(sin(x)/(1 + sin(x))), sqrt(2)/2)

@nm Multi-line comments have been available in 1D Input since Maple 13 (released, 2009).

It's not available in 2D Input.

ps. tangent: some people set their Maple prompt to (**) so that they can copy&paste to&from other plaintext locations without having to erase the prompt.

@Mathrookie94 You could remove the statement that assigned to Digits, and then restart using either the restart icon on the menubar or the restart command.

It's often useful to begin worksheets with the restart command (before your with calls). That way when you use the !!! icon on the menubar you get a fresh computation, ie. without interference from previous assignments to names.

As I wrote before the original worked for me without changing Digits, so there was already evidence that working precision was not the issue.

I wonder whether it might have something to do with "saved rtable" data, stored due to output.

It might be interesting to know whether it still occurs if you,
1) use the menubar to remove all output.
2) save
3) re-open, then execute

Another (less likely, IMO) possibility might be something related to the new kind of display of rtables (eg.Matrix), with the sliding pan funcitonality.

All this is supposing that it doesn't happen for other worksheets you make yourself, and that your installation is OK.

1 2 3 4 5 6 7 Last Page 1 of 553