acer

30645 Reputation

29 Badges

18 years, 351 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

@C_R 

[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.

    showstat(`type/satisfies`);

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).

with(IntegrationTools):

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)

lprint(W);

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])

lprint(T);

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

ExpandMultiple(T)

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

lprint(%);

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

Download IT_EM_ex.mw

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.

restart;

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

x+(1/2)*Pi-(1/6)*Pi*3^(1/2)*sin(x)-(1/2)*Pi*cos(x)-2*x*sin((1/2)*x)

 

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)):

with(IntegrationTools):

A:=CollapseNested(Combine(foo));

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

0

Download sursumCorda_int_ac.mw

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).

restart;

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

0

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.

@Carl Love I tried fooling with interface(displayprecision), as well as Numeric Formatting, and also the GUI's Options->Precision. Wasn't able so far to get the reported effect, but who knows those mechanisms can be weird.

@Mathrookie94 

It might be worth checking whether your Gym:-QQplot procedure differs from mine.

What does this look like?

   showstat(Gym:-QQplot);

@Khair Muhammad Saraz In these atatchments you can simply change the N value (posint > 1) and re-execute.

Here are both surfaces, default style=patchcontour by surfdata for the N=7 approximate surface.

DQMSixth_2_accc.mw

And here are both surfaces, with style=surface for the exact surface. (Higher order interpolation to a finer grid is possible for the surface constructed from the approximate data, but perhaps not in the spirit of what you want.)

DQMSixth_2_ac_lininter.mw

It might be fun to wrap all the approximation computation in a procedure, compute & store for several N values, and display as an animation with the exact surface as background.

You are not being clear about how you want the "one 2d plot" to appear.

Construction of the 2D curves has already been show to you in a few attachments. You really ought to be able to put those into a single plot, along with the exact curves. This is your coursework/project, after all.

@Mathrookie94 It works as you expected, for me, without any change to Digits.

Do you have some custom initialization file? I don't know how to test which "version" of Gym I have.

worksheet_-_linear_reg_and_residuals_for_normal_distribution_ac2024.mw

@Mathrookie94 Try something like,

   Digits:=20:

at the start.

(I can't test easily, because you haven't provided the data.)

@Khair Muhammad Saraz You can now just change the N value, without other changes needed.

Check for mistakes.

DQMSixth_2_acc.mw

First 8 9 10 11 12 13 14 Last Page 10 of 561