acer

32348 Reputation

29 Badges

19 years, 329 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

Your method of generating a sequence of data points, and then interpolating that, and then plotting the interpolant, is very inferior to the direct method shown below.

I have deleted at least one duplicate posting of yours, in which you asked about the same inferior method for a very similar examples.

(You have asked duplicates of some other of your query topics, as well. Stop spamming this site with duplicates.)

@AHSAN It is impolite to expect other people to have to type in your equations for you.

@Carl Love No worries, Carl. I assume that we always have purely constructive discourse!

I had assigned the results from GenerateMatrix to A,b two names, then concatenated before calling Modular:-LineasrSolve. Six of one, half a dozen of the other...

I'm glad you took the high road and showed your answer. Upvote. The OP's use of deprecated lowercase matrix, evalm, etc, made me a little sad.

@Carl Love I wasn't sure what the instructor was up to, on that point.

At first I had code using each of Linsolve(...) mod p, LinearAlgebra:-Modular, and even msolve, but figured that using just solve might give the OP something more to think about.

Your Document was last saved in Maple 18, and not Maple 2018 which is four major releases later. I have adjusted the Question header accordingly.

@Carl Love I had only a sneaking suspicion about the "possibility" of speedup. Yes, I was wondering about simplification (once all the exp and arithmetic had been combined on the real&imag parts, split by evalc, code optimized, etc). I was just wondering... 

More hazily, I wasn't outright sure whether I might also save on arithmetic by avoiding extra care for corner cases (reciprocals, etc). Maybe a poor idea. I was just wondering... 

But nothing concrete.

And I was also trying to recollect details of the platform-specifc complex arithmetic bug(s) I'd seen years earlier -- though I didn't mention it earlier because I was trying to, umm, keep it simple.

@Yiannis Galidakis I wrote that "expmap4.mw" worksheet early in the year 2016, for Maple 2015. I didn't write it for Maple 18 (established by the fact that it uses the newer IterativeMaps package).

Here is an adjustment of the first part (just the plot3d), which runs faster in my Maple 18.02 due to explicit use of evalhf which I have added for you.   expmap4_part1_18.02.mw

@emendes Controls for the animation (including a slider) are available in the top menubar when you put the (mouse pointer) focus on the animation.

They are also available by right-click upon the animation. The popup menu offers control buttons (but no slider) under the "Animation" submenu -- usually at the bottom of the popup.

FYI, you could also do this, which embeds a Slider along with the plot:

restart;
with(DynamicSystems):
num:=10*(s+alpha);
den:=s*(s^2+4*s+8);
Explore(RootLocusPlot(NewSystem(subs(alpha=a,num/den)),
                      view=[-10..3,-15..15]),
        parameters=[a=1..10.0],animate);

@Yiannis Galidakis If you look to this old Question thread started by yourself in 2015, I wrote a Reply in which I mentioned that there are (in that version at least) some specific issues with complex arithmetic under Compiler:-Compile. Those might be MS-Windows-64bit specific. (I had a vague recollection of this when putting together the code above -- but I did not unroll the complex arithmetic operations in your code, as I don't have a MS-Windows machine with Maple 18 at hand right now, on which to test.)

By the way, in that old Question thread there was quite a bit of discussion about using evalhf, etc, for acceleration. (That included the kind of simple edits in my original Answer above.)

As I mentioned above, there is no "general" Escape fractal command in Maple 18. It only has a few specific flavours, hard-coded as the exported commands of the Fractals:-EscapeTime subpackage.

In Maple 2015 the IterativeMaps package was added, and its Escape command can be used in some related ways. (It's not clear how I could use it for your orbit checking -- except by intoducing/storing as many variables/values per x-y entry as your N the orbit Vector dimension, and then post-processing...)

Here is a simple "exponential map" example (from about Feb 2016) which compares computation via plot3d (4.4 sec, even under evalhf) and IterativeMaps:-Escape (0.24 sec).  expmap4.mw

Here is a more involved example also using IterativeMaps:-Escape (from about Nov 2015) which has some bells&whistles for the coloring and stopping criteria, and an Explore (re-using the image/Array container).  tetration_escape0.mw

By the way, the "images" (float[8] Arrays) produced in this and the previous code can not only be inserted/displayed in a Worksheet (ImageTools:-Embed) but can also be saved to file (ImageTools:-Write).

Lastly, if your session crashes or acts funny while running any of this multi-threaded code, you might want to check your Task Manager to see if any orphaned kernels ("mserver" process) are still running after you quit the GUI.

This has been asked a few times in the past weeks.

Perhaps the main ?plot Help page should get such an example, that clearly states the purpose. It seems basic enough to warrant a clear and readily available example.

(There is a less clear polar plot example buried in the ?plot,details Help page.)

@Yiannis Galidakis I suspect a problem with the Compiler.

This is the same but with the use of the Compiler removed. It's 3+ times faster than what was in my answer on my quad-core, due to the multithreading.

parTet2_nocompile.mw

ps. This was very quick to write, as I just had to make relatively minor adjustments to previous escape fractal code that was set up almost identically.

If you're going to link to this page then I might dig out another worksheet I already had, that used the IterativeMaps:-Escape for a tetration fractal. (There are choices, in how to utilize the computed data for coloring...)

@Yiannis Galidakis The source is present in the Worksheet which I attached in my followup (link at bottom of my Reply), within a Code Edit Region that should be eminently visible when you open the sheet in the Maple GUI.

You can either run the code in that portion via right-click on it, or mark it as auto-execute and allow that to run, or expand it and copy the code to elsewhere in the Worksheet.

I used Maple 18.02, since your attachment was last saved in Maple 18.00.

Here is an attachment with the code simply copied to a regular Execution Group. parTet2.mw

@Yiannis Galidakis So, enabling plot3d to use evalhf to compute TF for each x-y point got the (wall-clock) timing for your original example from 412 sec down to 4 sec on my machine in Maple 18.

Below, by multi-threading and compiling the computational portion, as a direct, looped Array (image) computation, the (wall-clock, real) time decreases further to 0.7 sec for the original example on my quad-core machine in Maple 18. You may see further improvement if you try on an 8-core (but doubtful for an "old" 4-physical core, 8-virtual hyperthreaded...).

(It's possible that by manually unrolling the complex arithmetic into real and imaginary components a little more speed-up could be attained. I'm not sure.)

I included the functionality to have it respect the x-y aspect ratio, in terms of horizontal versus vertical pixel density.

I don't know what parameter value that site's author used, for iteration limits, etc.

restart;

kernelopts(version);

`Maple 18.02, X86 64 LINUX, Oct 20 2014, Build ID 991181`

kernelopts(':-numcpus');

4

source for Tetration module

NN := 400: N := 20: eps := 1e-2: ct := 1e6: maxiter := 100:
(a,b,c,d) := -4.0,4.0,-4.0,4.0:

res := CodeTools:-Usage( Tetration( NN, a, b, c, d, N, maxiter, ct, eps ) );

memory used=1.56MiB, alloc change=7.79MiB, cpu time=2.70s, real time=719.00ms, gc time=0ns

res := Vector(4, {(1) = ` 400 x 400 `*Matrix, (2) = `Data Type: `*float[8], (3) = `Storage: `*rectangular, (4) = `Order: `*Fortran_order})

img := Array(1..op([1,1],res),1..op([1,2],res),1..3,1.0,datatype=float[8],order=C_order):
img[..,..,1] := 360*((ImageTools:-FitIntensity(res))):
RGBimg := ImageTools:-HSVtoRGB(img):
ImageTools:-Embed(RGBimg);

 

#PLOT3D(GRID(c..d,a..b,res),
#       SHADING(ZHUE), STYLE(PATCHNOGRID), LIGHTMODEL(NONE), SCALING(CONSTRAINED),
#       ORIENTATION(180., 0., 180.0), AXESLABELS(x, y, iter), AXESSTYLE(BOX)
#       ,ROOT(BOUNDS_X(0), BOUNDS_Y(0), BOUNDS_WIDTH(ceil(1.5*op([1,2],res))),
#             BOUNDS_HEIGHT(ceil(1.5*op([1,1],res))))
#);

#ImageTools:-Preview(RGBimg);

 

NN := 1000; N := 100; eps := 5e-2; ct := 1e6; maxiter := 400;
#(a,b,c,d) := -4.5,3.3,-2.9,2.9;
(a,b,c,d) := -3.5,3.3,-2.9,2.9;

res2 := CodeTools:-Usage( Tetration( NN, a, b, c, d, N, maxiter, ct, eps ) );

NN := 1000

N := 100

eps := 0.5e-1

ct := 1.*10^6

maxiter := 400

a, b, c, d := -3.5, 3.3, -2.9, 2.9

memory used=7.10MiB, alloc change=6.51MiB, cpu time=55.04s, real time=14.34s, gc time=0ns

Matrix(%id = 18446883920994884654)

img := Array(1..op([1,1],res2),1..op([1,2],res2),1..3,1.0,datatype=float[8],order=C_order):
fitres2 := ImageTools:-FitIntensity(res2):
img[..,..,1] := 360*fitres2:
#img[..,..,2] := 1-~(res2):
#img[..,..,3] := (fitres2):
#img[..,..,2] := map[evalhf](x->`if`(x=0.0,0.0,1.0),res2):
img[..,..,3] := map[evalhf](x->`if`(x=0.0,0.0,1.0),res2):
RGBimg := ImageTools:-HSVtoRGB(img):
ImageTools:-Embed(RGBimg);

 

 

``

parTet.mw

note. I have a faster version of HSVtoRGB, if you need it. It's not the bottleneck here.

@AHSAN Here are a few ways. Adjust options to taste.

help2_acc2.mw

@Preben Alsholm Yes, while I mentioned the setting itself I omitted that documented detail. I don't see why students and users new to Maple should be reasonably expected to understand its subtlety, even though they may comprise a significant portion of those include to use the syntax. Perhaps other readers disagree(?).

First 155 156 157 158 159 160 161 Last Page 157 of 592