acer

32363 Reputation

29 Badges

19 years, 332 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

I'm guessing that you are asking about the height and width of the plot as rendered on the Worksheet/Document canvas, and not about the ranges that are shown on the horizontal and vertical axes.

There is no way in Maple 13 to programmatically and directly set the width and height of the rendered box in which a plot is displayed as output.

You can, of course, resize the plot by manually adjusting the border with the mouse pointer.

If you really want to be able to insert a rendered plot with specific height and width values (eg, 900x900 pixels) in a Worksheet/Document in the Standard GUI of Maple 13, then you might have a look at this old Post.

Another programmatic methodology consists of using a script -- which could be Maple, via its XMLTools package -- and modifying the height/width fields of the inline-plot items in a saved (XML) .mw file. I recall Preben or someone once saying they'd done that. This requires closing/saving and re-opening the sheet, and so it is not a direct modification of the appearance of plot output. This is quite advanced a technique.

In recent Maple versions up to Maple 2018, there is a size option on the 2D plot command which allows you to specify the height and width easily.

If you are asking about examining or extracting the data structure that holds the computed details of the plot and its features then the commands plottools:-getdata and op can work.

I don't generally recommend using the lprint command for such examination since for many plots that would produce a less legible output.

If instead you are asking about how to get at the original plotting command that produced a given plot, then no that is not stored as part of the plot itself.

See the help page for the command IterativeMaps:-Bifurcation .

 

(Some readers might also find some interesting bits in this old discussion. The first paragraph in my first Comment there contains links to another three earlier threads.)

 

This is quite similar in nature to your previous question.

a := 3;
                      a := 3

f := unapply(a*x, x);

                    f := x -> 3 x

g := subs(dummy=a, x->dummy*x);    

                    g := x -> 3 x

The command unapply handles your example, whether you want the name of the formal parameter to be x or X.

x^2;

                    2
                   x

f := unapply(%, x);

                           2
                f := x -> x

f(t);

                     2
                    t

x^2;
                     2
                    x

f := unapply(subs(x=X,%), X);

                            2
                 f := X -> X

f(t);

                      2
                     t

You *could* construct an operator/procedure that actually uses eval to evaluate the given expression (in x) at x=X where X is the name of the formal parameter. But it would be inefficient to have it do so upon every application of f, and for your example it would be unnecessarily inefficient.

x^2;

                      2
                     x

f := unapply('eval'(%,x=X),X);

                          2|
               f := X -> x |
                           |x = X

lprint(eval(f));
  X -> eval(x^2,x = X)

f(t);

                      2
                     t

I looked at the other responses only after getting the following last night. I am not surprised that the various approaches have elements in common.

ee := abs(z)*(z-4-I)+2*I = (5-I)*z:

ans1:=eval~(z=a+b*I,
            [solve(evalc([Re,Im](subs(z=a+I*b,ee))),explicit)]):

lprint(%);
[z = -1, z = 83/410*(-1/2*(25+2*I*26^(1/2))^(1/3)-9/2/(25+2*I*26^(1/2))^(1/3)+3-1/2*I*3^(1/2)*
((25+2*I*26^(1/2))^(1/3)-9/(25+2*I*26^(1/2))^(1/3)))^2+323/820*(25+2*I*26^(1/2))^(1/3)+2907/
820/(25+2*I*26^(1/2))^(1/3)-1063/410+323/820*I*3^(1/2)*((25+2*I*26^(1/2))^(1/3)-9/(25+2*I*26^(
1/2))^(1/3))+I*(9/410*(-1/2*(25+2*I*26^(1/2))^(1/3)-9/2/(25+2*I*26^(1/2))^(1/3)+3-1/2*I*3^(1/2
)*((25+2*I*26^(1/2))^(1/3)-9/(25+2*I*26^(1/2))^(1/3)))^2+119/820*(25+2*I*26^(1/2))^(1/3)+1071/
820/(25+2*I*26^(1/2))^(1/3)-219/410+119/820*I*3^(1/2)*((25+2*I*26^(1/2))^(1/3)-9/(25+2*I*26^(1
/2))^(1/3))), z = 83/410*((25+2*I*26^(1/2))^(1/3)+9/(25+2*I*26^(1/2))^(1/3)+3)^2-323/410*(25+2
*I*26^(1/2))^(1/3)-2907/410/(25+2*I*26^(1/2))^(1/3)-1063/410+I*(9/410*((25+2*I*26^(1/2))^(1/3)
+9/(25+2*I*26^(1/2))^(1/3)+3)^2-119/410*(25+2*I*26^(1/2))^(1/3)-1071/410/(25+2*I*26^(1/2))^(1/
3)-219/410)]

length(%);
                              1233

ans2:=simplify(evalc(ans1)):

lprint(%);
[z = -1, z = (-747/205-81/205*I)*cos(1/3*arctan(2/25*26^(1/2)))^2+1/410*(-525+195*I-(1494+162*
I)*3^(1/2)*sin(1/3*arctan(2/25*26^(1/2))))*cos(1/3*arctan(2/25*26^(1/2)))+385/82+21/82*I+(105/
82-39/82*I)*3^(1/2)*sin(1/3*arctan(2/25*26^(1/2))), z = -158/205-69/205*I+(1494/205+162/205*I)
*cos(1/3*arctan(2/25*26^(1/2)))^2+(105/41-39/41*I)*cos(1/3*arctan(2/25*26^(1/2)))]

length(%);
                               524

simplify(convert(eval~((rhs-lhs)(ee),ans1),expln));
                             [0, 0, 0]

simplify(convert(eval~((rhs-lhs)(ee),ans2),expln));
                             [0, 0, 0]

Here are a few ways to deal with this issue.

The first is to use formula for one of the domain ranges. This requires joining two surfaces, and a slight seam is visible.

The second and third involve using two variants of cylindrical coordinates. One of these has an quite visible seam. Fortunately the latter (made using an easy stock coordinate known to plot3d) is the nicest looking.

3dplot_domain.mw

Here is an image of the third plot.

Another less satisfying approach is to increase the grid size as an option to the plot3d command. This barely works since manual rotation of the plot slows down as the plot structure gets large, and the jaggedness is only reduced and smaller.

Another (advanced approach) is to write one's own MESH generator that looks for the boundary where the expression becomes non-real, and adjusts adjacent data points to match. I've been working on this (as one of many evening projects) for a while now.

[edit] I forgot that you were trying to make an Explore call. Using Carl's clever idea of sqrt(max(0,...)) then my third variant (usual cylindrical coordinates) could be explored as,

Explore( plot3d([sqrt(max(0,z^2+c))], theta=0..2*Pi, z=-2..2,
                coords=cylindrical,
                style=surface, color=green),
         c=-1.0 .. 1.0 );

The difference being that Carl has used the parametric calling-sequence of plot3d while I've used the expression calling-sequence (while we both used coords=cylindrical). Also, Carl noticed that only one of the two signed pieces is needed in this variant.

And Carl chose a nice fixed view for the plot3d call inside the Explore call. Using that nuance, the above looks even better with the extra option view=[-2..2,-2..2,-sqrt(2)..sqrt(2)] in the plot3d call.

[Wait, where did Carl's fine Answer go?! It seems to have disappeared.]

restart;

ee := RootOf(x^2+1,x):


allvalues(ee);
                             I, -I

If the expressions containing RootOf were the result from solve then you could try passing that command its explicit option.

The answer is that it is an ill-judged and misguided idea to treat an immutable data structure as if it were mutable, since that is relatively bad for performance and needlessly wastes time and memory resources.

It's also a bad idea to have an easy syntax for doing just that, especially if it would obscure the fact that a full copy of the whole structure is being done upon every "update" to an entry.

A set is not a mutable data structure. It would be misguided to treat it as if it were.

A list also is not a mutable data structure. About 20 years ago, or so, the people in charge of Maple development had a serious lapse in judgement and allowed the easy syntax of indexed assignment of a list element, eg, A[i]:=somthing where A is a list. And ever since then people have had an easier task of reducing code performance by inducing full copies of their lists upon each element "update".

 

Do you want a 2D or a 3D contour plot, and if the latter then do you want it separate from the surface plot or together?

Do you want the data interpolated?

surfcont.mw

If you want a 2D contour plot with the data interpolated (to get smoother contour lines) then you could also look at the Interpolation package new to Maple 2018.

[edited] Since you have Maple 2018 here's how you can use the new Interpolation package to obtain a single procedure that can be used to obtain the surface, or the 3D contour plot, or the 2D contour plot -- each smoothed by interpolation if you wish.

Apart from the data Matrix, all you need more are two Vectors to denote the tacit ranges for x and y that the Matrix data represents.

surfcont_Interp.mw

 

[edit] I've removed part of my answer which was relevant or correct because I failed to notice why this change below occurs. [end-of-edit]

It seems to have changed between Maple 16.02 and Maple 17.02. That is, using the CLI,

/usr/local/maple/maple17.02/bin/maple -q -s -c "print(kernelopts(version));" -c "print(evalf(frac(Pi^20)));" -c "quit"

                               Maple 17.02, X86 64 LINUX, Sep 5 2013, Build ID 872941

                                                         23.

/usr/local/maple/maple16.02/bin/maple -q -s -c "print(kernelopts(version));" -c "print(evalf(frac(Pi^20)));" -c "quit"

                               Maple 16.01, X86 64 LINUX, May 6 2012, Build ID 744592

                                                         0.

 

The following computes quickly in my Maple 2018.0 version.

restart;

ee := sqrt(b)*sqrt(1-4*p/b)-2*arctan(sqrt((9*p/b-22201/10000)/(9/4-9*p/b))):

plots:-implicitplot([Re(ee)=0, Im(ee)=0], b=0..5, p=0..5,
                    gridrefine=1, crossingrefine=7);

Your expression is 2*Pi periodic, so we can call minimize or maximize with the restricted range x=0..2*Pi.

Or we can do the general computation, using diff, solve, etc.

restart;

f := (cos(x)+sqrt(3)*sin(x))/(cos(x)+sin(x)+2);

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

(1)

simplify([maximize(f, x=0..2*Pi,'location')]);
evalf(%);

[4*(12+2*3^(1/2))^(1/2)/(3^(1/2)*(12+2*3^(1/2))^(1/2)+(12+2*3^(1/2))^(1/2)+2*3^(1/2)+12), {[{x = arctan((3^(1/2)*(12+2*3^(1/2))^(1/2)-1+3^(1/2))/(3^(1/2)-3+(12+2*3^(1/2))^(1/2)))}, 4*(12+2*3^(1/2))^(1/2)/(3^(1/2)*(12+2*3^(1/2))^(1/2)+(12+2*3^(1/2))^(1/2)+2*3^(1/2)+12)]}]

 

[.6001956932, {[{x = 1.231247593}, .6001956932]}]

(2)

simplify([minimize(f, x=0..2*Pi,'location')]);
evalf(%);

[4*(12+2*3^(1/2))^(1/2)/(3^(1/2)*(12+2*3^(1/2))^(1/2)+(12+2*3^(1/2))^(1/2)-2*3^(1/2)-12), {[{x = arctan((3^(1/2)*(12+2*3^(1/2))^(1/2)+1-3^(1/2))/(-3^(1/2)+3+(12+2*3^(1/2))^(1/2)))+Pi}, 4*(12+2*3^(1/2))^(1/2)/(3^(1/2)*(12+2*3^(1/2))^(1/2)+(12+2*3^(1/2))^(1/2)-2*3^(1/2)-12)]}]

 

[-3.332246505, {[{x = 4.004740164}, -3.332246505]}]

(3)

sols := map(s->simplify(radnormal(s)),
          [solve(diff(f,x), x, allsolutions)]);

[arctan(2+(1/6)*(3-3^(1/2))*(12+2*3^(1/2))^(1/2))+2*Pi*_Z3, arctan(2+(1/6)*(3^(1/2)-3)*(12+2*3^(1/2))^(1/2))+(2*_Z3-1)*Pi]

(4)

maxf := radnormal(expand( eval(f, x=sols[1]) ));
evalf(%);

(3^(1/2)*(12+2*3^(1/2))^(1/2)-(12+2*3^(1/2))^(1/2)+4*3^(1/2)+2)/(3^(1/2)*(12+2*3^(1/2))^(1/2)+4*3^(1/2)+(12+2*3^(1/2))^(1/2)+2)

 

.6001956940

(5)

minf := radnormal(expand( eval(f, x=sols[2]) ));
evalf(%);

(3^(1/2)*(12+2*3^(1/2))^(1/2)-(12+2*3^(1/2))^(1/2)-4*3^(1/2)-2)/(3^(1/2)*(12+2*3^(1/2))^(1/2)-4*3^(1/2)+(12+2*3^(1/2))^(1/2)-2)

 

-3.332246501

(6)

plot(f, x=-10..10, view=-4..1);

 

 


Download max_min_example.mw

 

Here is an example, using Q__outflow and e as parameters (whose earlier assignments I commented out).

I changed Q[outflow] to Q__outflow , although in 2D Input they both appear as the subscripted name.

You could comment out additonal parameters and add them into the Explore call.

382483three_reservoir_prob_ac.mw

 

Try using calls to time[real]() before and after, instead of time() .

(Perhaps also consider CodeTools:-Usage )

First 176 177 178 179 180 181 182 Last Page 178 of 336