acer

32647 Reputation

29 Badges

20 years, 57 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

@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(?).

@Rouben Rostamian  Performing a Help query on the word gamma leads to the Help page for Topic gamma (because that name has various meanings in different contexts).

And that page contains a cross-reference link to the Help page with Topic initialconstants, which mentions that the constant gamma is equivalent to the call gamma(0) (aka Euler's constant, or the Euler-Mascheroni constant) and that gamma(n) is a placeholder for the Stieltjes constants.

Why did you not provide your actual, underlying, motivating question up front?

If you want to feel better about asking for answers to your coursework you could show us (explicitly) what you've been able to accomplish on your own.

@itsme I submit reports on issues I raise myself. But thanks for your interest!

I did not mention the ifactor command because I guessed that he was wanting to use the result (programmatically) for some futher purpose. I might have guessed wrong.

lprint(ifactor(725));
``(5)^2*``(29)

As can be seen, the structure returned by the ifactor command is far more awkward to query and manipulate than is that of the ifactors command. The former is fashioned purely for its display effect, when printed. But perhaps that's all he's aiming for here.

@user-JG 

H:=n->map(op,ifactors(n)[2]):
H(725);
              [5, 2, 29, 1]

H(1125);
               [3, 2, 5, 3]

H(2048);
                 [2, 11]

In modern Maple versions you can save a few keystrokes in the definition of that procedure H by applying op elementwise, rather than using map.

H := n->op~(ifactors(n)[2]):

@greatpet You can set the include path when you start up the Maple interface (GUI or commandline), using the -I option.

Or you can query or set the include path within a Maple session using the kernelopts command (see the item for includepath).

I make the strings in my $include directives be a reference relative to the location of the current file. And I ensure that the include path contains that (parent) location, when I read that file.

Hope that makes sense.

@greatpet Perhaps some of the following might help with organization.

If you're open to using plaintext files, then you can keep each module local procedure's definition in its own text file. You can then use the $include directive to source those from a (now shorter) module definition.

You can even use a directory structure to mimic the code layout, if your modules have submodules, etc.

(If your projects are advanced you can even get busy with the $define and related directives, for source aliasing and conditional source loading and so on. If you're used to such things in C then you might find it convenient.)

It sounds as if this might suited for contacting Maplesoft's Technical Support.

They'll likely want to know your Operating System details, and whether you have a Language setting (other that English), using a Maple language pack, etc.

@anthonyfl Sorry, but I am not sure that I understand why planes are better than lines, for a 3D contour plot to look like a 2D contour plot.

If you have some other orientation or detail in mind then please be specific.

(If desired, the x-axis tickmarks could be specified to lie at exactly the same values for the 2D plots and the 3D plots.)

P1 := plots:-contourplot(sin(x)*y^2, x=-Pi..Pi, y=-1..1,
                         thickness=2,
                         xtickmarks=piticks,
                         coloring=["Orange","Blue"],
                         labels=[``,``], axes=boxed, size=[300,300]):
P2 := plot3d(sin(x)*y^2, x=-Pi..Pi, y=-1..1,
             style=contour,
             thickness=2,
             orientation=[-90,0,0],
             colorscheme=["zgradient",["Orange","Blue"]],
             labels=[``,``,``], axes=boxed):
P3 := plots:-contourplot3d(sin(x)*y^2, x=-Pi..Pi, y=-1..1,
                           thickness=2,
                           orientation=[-90,0,0],
                           colorscheme=["zgradient",["Orange","Blue"]],
                           labels=[``,``,``], axes=boxed):

P1; P2; P3;

P4 := plots:-contourplot(sin(x)*y^2, x=-Pi..Pi, y=-1..1,
                         thickness=1, filled,
                         xtickmarks=piticks,
                         coloring=["Orange","Blue"],
                         labels=[``,``], axes=boxed, size=[300,300]):
P5 := plot3d(sin(x)*y^2, x=-Pi..Pi, y=-1..1,
             style=surfacecontour,
             thickness=3, lightmodel=none,
             orientation=[-90,0,0],
             colorscheme=["zgradient",["Orange","Blue"]],
             labels=[``,``,``], axes=boxed):

P4; P5;

 



contours_2D_3D.mw

@anthonyfl If you plot a 3D surface then the surface can have contour lines. Are you asking how to get level sufaces (planes) instead of (or as well as) contour lines?

You should ask that in a separate Question, I think.

Do you want a re-usable procedure for it?

I can think of a few reasonably straightforward ways to accomplish that (and I'm sure that others can too). I expect you'd get a reasonable answer quickly.

Be sure to specify how much functionality you need. Do you need to be able to specify the degree of transparency, gray/color shading, and style easily for the planes? Does it need to support specifying those separately for each level surface, or can they be all the same? Etc.

@anthonyfl I did not notice earlier for which version your Question might have been tagged.

The support for contourvalue in the legend option is new for Maple 2020. That functionality was not present in Maple 2019.

Here is a link to the "What's New" pages for Maple 2020 which mentions this functionality.

Note that there are no examples such as you showed in the Maple 2019 Help page for Topic contourplot.

Here is that example, working in Maple 2020.1, with the spelling of typeset corrected (which is necessary). I changed from default coloring to make the contours more visually distinguishable to me.

with(plots)

contourplot(4*x^2+9*y^2, x = -10 .. 10, y = -10 .. 10, coloring = ["Orange", "Blue"], legend = typeset("the circle", 4*x^2+9*y^2, "=", contourvalue))

 

Download contourvalue.mw

 

If you really need this kind of functionality in Maple 2019 then you could try the rough code I put in this old Post.

First 161 162 163 164 165 166 167 Last Page 163 of 597