acer

32313 Reputation

29 Badges

19 years, 315 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

Upload and attach your Maple Document, so that we might see what it actually contains.

@The function Your second function  (-2)^x  is complex-valued.

Ie,

(-2)^1.35;
        -1.157276832 - 2.271283669 I

Re((-2)^1.35);
              -1.157276832

Im((-2)^1.35);
              -2.271283669

In the first plot above the two separate curves represent its real and imaginary components, respectively, versus the independent parameter.

The second plot is by the complexplot command. You could compare that with the following parametric plot, in which the horizontal and vertical coordinates (at each point on the single curve) represent the real and imaginary components.

plot([Re((-2)^t), Im((-2)^t), t=0..10]);

@lekcha You can use colorscheme when calling densityplot (analogously to how I used it in the earlier code above, when using surfdata as part of the substitute for HeatMap in Maple 18).

Note that this is slower and less efficient that the earlier code I showed. The result of densityplot with such a high grid setting can also make the GUI slow and sluggush. The result may be harder to export. And the Maple 18.02 GUI may not be able to save the worksheet with such a high resolution densityplot output. These things get much worse as the grid gets large. All those consderations are a major part of why the method of using images (and the EscapeTime package) instead of plots was invented for such goals.

restart:

newton := proc(x, y)
    local z, m;
    z := evalf(x+y*I);
    for m from 0 to 15 while abs(z^3-1) >= 0.001 do
       z := z - (z^3-1)/(3*z^2)
    od;
    m;
 end:

cm := ["turquoise","cyan","blue", "brown","coral", "maroon",
       "orange", "pink", "magenta", "red", "sienna", "violet",
       "wheat", "yellow", "aquamarine", "black"]:

plots:-densityplot(newton, -2 .. 2, -2 .. 2, grid = [500, 500],
                   colorscheme=["zgradient",cm],
                   axes = none, scaling = constrained,
                   style = patchnogrid, size = [500, 500]);

 

newt_dens_Maple18_colorscheme.mw

Are you asking also about using a .m (dotm) file from within Maple, and not just about putting it as an attachment on a Mapleprimes posting?

Please put your closely related followup queries on this same topic as Replies under this Question thread, instead of posting a separate Question thread. (You've been asked this before.)

Duplicate Question threads will be flagged as such and may be delated.

If you have followup or closely releated queries (possibly because you didn't understand some answer) then please add it as a Reply here, instead of posting a separate Question thread.

Please don't post a duplicate of this query. Duplicate Question threads will get flagged as such and may be deleted.

@mmcdara Your code and commentary for Question 2 seem to indicate that you consider,
   diff(f(x), x) = diff(g(x), x)
to be sufficient for both f and g to attain an extreme point. But that's not true, as that equation doesn't imply that either derivative is zero.

Also, I wonder whether there may have been a transcription or translation error by the OP. If the formulas are right (aside from implicit multiplication) then perhaps the actual question (in Dutch?) is something like: for what value of p do both f and g attain a minimum at the same x value? If so, then...

f := x^2-6*x+p+3:
g := (4*x^2)-(p-8)*x+7:
sol := solve({diff(f,x),diff(g,x)});

       {p = 32, x = 3}

eval([diff(f,x), diff(g,x)], sol);

            [0, 0]

eval([diff(f,x,x), diff(g,x,x)], sol);

            [2, 8]

Your request is missing some important details.

Could your inert expressions contain noninert (but unevaluated) function calls?

What exactly do you mean by "one reduction of inert operations"? Does that entail evaluation? (Presuambly you know about automatic simplification.)

What should happen when multiple operands (at the same call level) are inert calls? Should they be dealt with one step at a time, or together as a single "reduction" step?

Do you want the reductions done first by depth, or by order of operands? 

What is the set of possible inert calls? Is it just arithmetic operators, or can there also be calls to %fsolve, etc.

Do you expect to handle expressions that contain rtables (eg. Matrix, Array) or series, for which the entries do not correspond to individual operands. Ie. structures for which the op command is not going to walk entries.

Better would be to provide an example that contains the most involved kinds of things you want handled, as opposed to the most trivial.

@tomleslie The default for implicitplot is find values where the sign changes, specified by its signchange=true (default) option.

If you supply the option as signchange=false then the result of the above example is an empty plot.

From the Help page,

   The option signchange = true/false (default true), when set to true,
    implicitly plots sign changes of the function. This includes, for
    example, the line y=0 for the input x/y. If this is not desired, and
    only the zeros of the input function are of interest, then signchange
    should be set to false.

Thankfully the OP has since provided his actual example, in which the signchange (and rational) option does not figure prominently. So mmcdara's example is a tangent discussion.

@abdulganiy You are calling implicitplot for first argument M (which implies M=0), and you are calling contourplot on first argument M with option contours=[1] (which implies M=1).

So which are you trying to plot, M=0 or M=1?

ps. I'd marked your Question as Maple 2016, as that is the version in which your attachment was last saved.

@mmcdara For your example implicitplot could be passed the rational=true option.

plots:-implicitplot( 1/sin(x*y),
                       x = -Pi..Pi,
                       y = -Pi..Pi,
                       color=blue,
                       gridlines=false,
                       axes=boxed,
                       rational=true,
                       gridrefine=4  # or higher
                     );

And one way of considering the difference between contourplot and implicitplot is that the latter accepts several additional options (which control its different and more generally sophisticated approach to the computation).

There is a way to get contourplot to use implicitplot to do its work, by passing it the (undocumented) method=alternate option. But I don't know that all the various additional implicitplot options might be easily passed along. So this is not so generally useful. Eg,

plots:-contourplot( 1/sin(x*y),
                      x = -Pi..Pi,
                      y = -Pi..Pi,
                      contours=[0],
                      color=blue,
                      gridlines=false,
                      axes=boxed,
                      method=alternate
                    );

Yet another approach is to use plots:-inequal (though it may be inefficient, with duplicated computations, or more). This may utilize implicitplot for some computation, and its options may be passed along, as is documented. I only mention this because it's on-topic; equations are better directly passed to implicitplot itself, and attempting to pass only the equation 1/sin(x*y)=0 to inequal results in an error message to that effect.

plots:-inequal( [1/sin(x*y)<=0, 1/sin(x*y)>=0],
                       x = -Pi..Pi,
                       y = -Pi..Pi,
                       optionsclosed=[color=blue],
                       gridlines=false,
                       axes=boxed,
                       optionsimplicit=[gridrefine=4]
                     );

 

@lekcha There are somewhat simpler ways to do the following, ie. you could simply construct monochromatic images from the color list/Matrix and concatenate them all together, using ImageTools & ColorTools. It might be tricky to make that very fast, if the dimensions of Matrix m get large.

I'll reuse the earlier approach, at least for now.

If the dimensions of Matrix m get large then I'd recommend keeping it as an Image and using ImageTools:-Embed, instead of using it as background in a plot.

restart;

kernelopts(version);

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

m := Matrix([[1, 2, 3], [4, 5, 6]]):

cm := ["aquamarine","blue","brown",

       "coral","cyan","black"]:

A := ImageTools:-Scale(Array(m, datatype=float[8]),
                       2, method=nearest):

P := plots:-surfdata(A, style=surface, dimension=2,

                     colorscheme=["zgradient", cm]):

img := ImageTools:-Scale(op([2],indets(P,specfunc(COLOR))[1]),
                         1..400, method=nearest):

ImageTools:-Embed(img):

plot([], background=img, axes=none);

 

``

heat_img_Maple18.mw

The initial scaling of m by a factor of 2 is only there to avoid surfdata getting confused by the special case of dimension 2x3 which by default would get interpreted as sparse data. An alternative is to specify the data for surfdata as regular, ie. not sparse format:

m := Matrix([[1, 2, 3], [4, 5, 6]]):
cm := ["aquamarine","blue","brown",
       "coral","cyan","black"]:
A := Array(m, datatype=float[8]):
P := plots:-surfdata(A, style=surface, dimension=2, source=regular,
                     colorscheme=["zgradient", cm]):
img := ImageTools:-Scale(op([2],indets(P,specfunc(COLOR))[1]),
                         1..400, method=nearest):
ImageTools:-Embed(img):

@lekcha Twice I asked you to state exactly what you wanted,  and twice you stated that I'd already shown what you wanted. Perhaps you only meant the custom-coloring aspect.

And now you are asking about a different kind of result, "number of convergence cycles", instead of the (present) escape-time. That's fine, but you should ask it in a new and separate Question thread.

Be sure to explain precisely what you mean by number of convergence cycles. Give an example of a particular complex scalar starting value, and show what output number you expect (...and why).

@lekcha Here is something, done in Maple 18.02.

The constructed image is assigned to img, and can be embedded directly. Or it can be used as the background in a plot with axes, optionally adding symbols at the polynomial's roots.

restart;

kernelopts(version);

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

bl, ur := -6 - 6*I, 6 + 6*I:

f := t^3 - t^2 - 12;

t^3-t^2-12

rts := [fsolve(f, t, complex)]:
rts := evalf[4](rts);;

[-.8379-1.945*I, -.8379+1.945*I, 2.676]

temp := Fractals:-EscapeTime:-Newton(400, bl, ur, f, output=layer1):

cm := ["aquamarine","blue","brown",

       "coral","cyan","black"]:

P := plots:-surfdata(temp, -6..6, -6..6, style=surface, dimension=2,
                     colorscheme=["zgradient", cm]):

img := op([2],indets(P,specfunc(COLOR))[1]):

 

We can embed the image.

 

ImageTools:-Embed(img);

plot([],
     style=point,symbol=diagonalcross,color=red,symbolsize=15,
     background=img,view=[-6..6, -6..6]);

 

With additional red cross symbols at the roots.

 

plot(map(p->[Re,Im](p),rts),
     style=point,symbol=diagonalcross,color=red,symbolsize=15,
     background=img,view=[-6..6, -6..6]);

``

newt_fractal_colorscheme_Maple18.mw

The steps to generate the image should also work in later versions (although in point-release 2021.1 the further use of background images placed into 2D plots has a regression bug related to positioning -- ie. offset&axes).

What's different here is that I used surfdata and a colorscheme (and ripped out the result's color Array) instead of HeatMap, in order to force your custom coloring.

@mmcdara One reason this is "simple" is that it relies on your knowing that the expression contains exactly two function calls, both trig, with mathematically equivalent operands.

First 123 124 125 126 127 128 129 Last Page 125 of 591