acer

32343 Reputation

29 Badges

19 years, 328 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

@mmcdara One possible problem with using subs as you have done is that it replaces all stand-alone instances of L with beta/m.

And sometimes may not be what's wanted. In the following example it may be that standalone L is preferred over beta*m.

expr := 3*L*r/(m*l*s) + L/m + L;

3*L*r/(m*l*s)+L/m+L

expand(algsubs(L/m=beta, expr));

L+3*beta*r/(l*s)+beta

MyRule := beta=L/m:
R := solve(MyRule, {L}):
subs(R, expr);

3*beta*r/(l*s)+beta+beta*m

 

Download algsubs_subs.mw

Of course, no size fits all.

@love-algebra This works for your given (short, toy) example. If it doesn't work for your longer examples then, well, that's what happens when you don't supply them to us up front.

expr := 3*L*r/(m*l*s) + L/m;

3*L*r/(m*l*s)+L/m

algsubs(L/m=beta, expr);

beta*(l*s+3*r)/(l*s)

frontend(expand, [%]);

3*r*beta/(l*s)+beta

map[2](algsubs, L/m=beta, expr);

3*r*beta/(l*s)+beta

 

Download algsubs.mw

It would be easier to demonstrate if you attached your original data. If you use the ExportMatrix command then you can attach it as an (exported) text file. (You could zip it before attaching it. Use the Green up-arrow in the Mapleprimes editor to attach it to a Comment.

If your original data has structure (and I suspect it may) then you can use ArrayInterpolation. But the inputs to that command would not be as you have them. Rather, M1 and M2 would be the two 300-element Vectors of the "common" independent values, and M3 would be the 300x300 Matrix of dependent values.

If it the data is not structured then you could use the Interpolation package to create something from which to attain the interpolated values (utilizing your M4 and M5).

But, again, it's easier to get it right for you the first time if your upload the data. Or you could upload a worksheet that generated the original data, so we could reproduce it via computation.

Have you looked at the examples on the Help page with topic,
   examples/Interpolation_and_Smoothing
That has examples involving interpolation of the kind of structured (regularly spaced in both independent dimensions) data that a plot3d(...,x=a..b,y=c..d) call might generate. It also has examples for irregular independent data.

Your Mapleprimes Post has this link:

   https://www.ias.ac.in/describe/article/reso/024/06/0653-0659

But that seems to have a link to a wrong fulltext article (.pdf file).

Should your link be this instead?

   https://www.ias.ac.in/describe/article/reso/024/06/0661-0679

That links to the fulltext arcticle here.

I agree with Carl's remarks in general.

Naturally, exceptions of evalhf'd code being thread-safe can include procedures that write inplace to rtables, or escaping evalhf mode temporarily via eval.

The Grid package may be beneficial if the individual jobs are not (individually) quick. Using Grid may involve greater overhead per subtask than does using Threads. It might be that a list of parameter values could be passed along in clumps, to mitigate the overhead of firing up separate kernels under Grid.

It might be relevant to know whether the OP is doing symbolic or numeric integration. The former is generally thread-unsafe because it can make significant use of limit (which is quite thread-unsafe).

The fact that the OP's code is reportedly running OK under Threads some of the time is what makes me wonder about the ArrayTools scenario I outlined.

It's often beneficial to make sure that the serial implementation of one's code is well-optimized, before parallelizing. I see many cases where (say) numeric integration is performing suboptimally because of how it's being invoked. For example, successfully enabling evalhf-mode evaluation of the integrand, and avoiding discontinuity checks that might happen to be unnecessary, can sometimes bring about a 20-fold or better timing speedup that is often more significant than parallelization benefits. That's just an example, and I do not know how well optimized the OP's serial code may be.

@Rouben Rostamian  It's interesting that series fails on that example with the RootOf containing those powers of 2*n. It could be tricky to figure out the precise cause (I will submit a bug report). series_oddity.mw

Why would you ask such a question without attaching the code itself?!

Couldn't you coordinate with your fellow student so that you only ask any of your coursework questions onlt once?

See here for the duplicate of this one.

This is not the first time you've both asked the same question.

 

@radaar 

Your problems seem to be more about how to use a Linux commandline terminal for text-driven applications in general, not just Maple. Perhaps you'd be better off learning first how to use commandline Linux, rather than focusing on Maple.

None of this is especially related to data science. That's a pretty big area. Why can't you be more specific?

@radaar If you follow that terminal command with an ampersand then the Linux terminal shell's command prompt should once again be available. So you can run more than one such job in the same terminal.  Eg,

./maple filename1 > output1.txt &

./maple filename2 > output2.txt &

./maple filename3 > output3.txt &

If your calculations involve many internal garbage collections then the output file may contain extra lines like this:

memory used=27.5MB, alloc=107.3MB, time=0.42
memory used=1089.1MB, alloc=208.3MB, time=11.58
memory used=1285.5MB, alloc=216.5MB, time=13.42

If you find those unhelpful then you can suppress that by beginning the input files with the Maple command,

kernelopts(printbytes=false):

Even while the computations are running you can see the output in several ways. Eg, try one of these,

cat output1.txt

tail -20 output1.txt

more output1.txt

You don't have to be in the same directory as the maple script in order to run it. Simply call it using its fullly qualified location (as I suggested in my Answer), wherever that may be.

It's not a good idea to output those files to the same directory in which Maple's executables reside. Better would be to redirect to a file under your home directory. Eg, notice the tilde here,

./maple filename1 > ~/output1.txt &

That would create the output files under your home directory (whose name I do not know, but something like /home/radaar  or what have you).

You should probably read up on the basics on Linux terminal shell commands. You may find top , ps , and kill worth learning.

@radaar Only you can tell us the location of your Maple installation.

@Carl Love Thanks, Carl.

I'm going to try again to push for contourplot and listcontplot to get augmented with most of the useful functionality we've discussed. (I've submitted several requests, and now I may have to send some reminders. Plotting is so important!)

I think that it's important to offer the following bits of functionality, preferably within one single command such as plots:-contourplot. I'd like it if attaining the variants didn't require users' having to strip out CURVES with subsindets or any other fancy techniques.

1) One related thing I've noticed with contourplot is that the filled regions' boundaries can really benefit visually from a boundary curve, so that the edges don't appear jagged. Some people want black or other monochromatic contour curves between shaded regions. But some people might want the boundaries to simply match one neighboring region along the boundary. Both could be readily available.

2) Some people will prefer a smooth gradient, as densityplot supplies. And some might prefer discretely shaded regions such as are shown in the Answer above.

3) The colorscheme option would allow for more control of the variation in the contours and the shaded regions, as shown above.

4) I'd like to see legends on 2D contour plots, with the same flexibility as the hover-over contour labels have. (And why not legends for 3D curves or surfaces that have a single color or style? That could be useful for 3D contour plots.)

I'll leave aside color-bars for now, as constructing them for all manner of custom colorings and shading schemes, for both 3D and 2D, can get quite involved. (There are many relevent posts that could be linked for this. But also, this is relevent to more than just contour plots.)

I'm torn about inlined text labels on contour lines. This post shows that it can look very impressive, and it's a popular request. But I suspect that the ideal solution is to have the contour values be stored (like the hover-over values) in a new substructure on the CURVES. That way the GUI could, dynamically, both place and render them best, as plots are zoomed or magnified. And those aspects can be trickier still if gaps in the curves are desired for spots for the text labels.

And of course there may be things to fix. I've reported the following densityplot flip more than once (it was fixed only for colorscheme, but not for colorstyle).

plots:-densityplot(x,x=0..1,y=0..1,colorstyle=HUE,style=surface);
plots:-densityplot(x,x=0..1,y=0..1,colorstyle=HUE,style=surface,restricttoranges);

And I'm not sure why the following currently shades the same way as "ygradient" (it's shaded by z-value in Maple 18.02),

L:=[seq([i,1,evalf(sin(Pi*i))],i=0.0..1.0,0.05)]:
plots:-pointplot3d(A, symbolsize=20, symbol=solidsphere,
                   colorscheme=["zgradient",["Red","Yellow","Blue"]],
                   labels=[x,y,z], orientation=[-1,90,-1]);

 

@phiost And you're not going to mention which version you're using?!

Also, do you want hue apread such as in a rainbow, or the ability to get exactly that one given colorscheme, or the ability to match any colorscheme, or...?

I edited my Answer to work in versions back to Maple 18.02. (I only tested the latest point-release for each major version. There is some funny business in changes to the color Arrays generated, and your mileage may vary with other point-releases...)

@phiost But you have only mentioned that you want a 2D plot. You have left other important details unspecified.

note: I should add that I submitted a Software Change Request two years ago for the plots:-contourplot command to offer the full colorscheme functionality. (I also submitted a few other suggestions related to coloring and contourplot and listcontplot . They have not yet been implemented.)

You have posted what, now, three or four Questions about either colored contour plots and/or paremetric or implicit plots of a certain system? It is counter-productive and unhelpful to not state what you really want up front.

In this last question you don't even bother to tell us whether you want a 2D or 3D result, what or how many contour values, whether it should allow for `filledregions`, and whether you intend on apply some technique to an explicit expression as above or some other parametric or implicit plot.

I don't necessarily have the spare time to try and produce what you want in many separate steps. If you update this Question with a Comment that contains what you're really after, as the final kind of plotting result, then I may find spare time to provide an answer.

First 212 213 214 215 216 217 218 Last Page 214 of 592