acer

32333 Reputation

29 Badges

19 years, 323 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

@Carl Love I've submitted a bug report.

@MAXR How's this?

I made a small correction to make the "dummy" curves reside along y=miny the smallest y-data value. By "dummy" curves I mean the seq of plot calls (of zero length) whose purpose is merely to introduce the corresponding legend items.

I used Maple 17.02.

restart;

 

#x:=[0.1, 0.2, 0.3, 0.4, 0.5, 0.1, 0.2, 0.3, 0.4, 0.5,0.1, 0.2, 0.3, 0.4, 0.5,0.1, 0.2, 0.3, 0.4, 0.5,0.1, 0.2, 0.3, 0.4, 0.5]:

#y:=[0.1, 0.1, 0.1, 0.1, 0.1, 0.2, 0.2, 0.2, 0.2, 0.2, 0.3, 0.3, 0.3, 0.3, 0.3, 0.4, 0.4, 0.4, 0.4, 0.4,0.5,0.5,0.5,0.5,0.5]:

z:=[1.971284960, 1.642401616, 1.372353338,1.153620572,0.9762759982,
    1.675502483, 1.411976881, 1.190627373,1.007730234,0.8570007139,
    1.397140245, 1.184230644, 1.003688984,0.852696223,0.7268039317,
    1.144791107, 0.9725020383,0.8257592921,0.7020549659,0.5979974836,                                                        0.9208492326, 0.7816302394, 0.6627749172,0.5620029444,0.4766238930]:

interfunc:=subs(__M=Matrix(Matrix(5,5,z),datatype=float[8]),
                (x,y)->CurveFitting:-ArrayInterpolation([[0.1,0.2,0.3,0.4,.5],
                                                         [0.1,0.2,0.3,0.4,0.5]],
                                                   __M,[[x],[y]],
                                                   method=cubic)[1,1]):

newz:=CurveFitting:-ArrayInterpolation([[0.1,0.2,0.3,0.4,0.5],[0.1,0.2,0.3,0.4,0.5]],
                                       Matrix(5,5,z),
                                       [[seq(0.1+(0.5-0.1)*(i-1)/(50-1),i=1..50)],
                                        [seq(0.1+(0.5-0.1)*(i-1)/(50-1),i=1..50)]],
                                                   method=cubic):

(nminz,nmaxz):=(min,max)(newz):

miny:=0.1:

C:=0.666*(1-ImageTools:-FitIntensity(newz)):

PC:=PLOT(GRID(0.1..0.5,0.1..0.5,newz,COLOR(HUE,C)),STYLE(PATCHNOGRID)):

numcontours:=9:

(P->op(0,P)(op(P),
            ROOT(BOUNDS_X(0),BOUNDS_Y(0),
            BOUNDS_WIDTH(600),BOUNDS_HEIGHT(500))))(plots:-display(PC,
               plots:-contourplot(interfunc,0.1..0.5,0.1..0.5,thickness=0,
                                  contours=[seq(nminz
                                                +(nmaxz-nminz)*(i-1)/(numcontours+2-1),
                                                i=1..numcontours+2)]),
               seq(plot(miny,nminz..nminz,
                        thickness=15,color=COLOR(HUE,0.666*(1-(i)/(numcontours+1))),
                        legend=sprintf(" %.3f",
                                       nminz+(nmaxz-nminz)*(i)/(numcontours+1))),
                   i=numcontours+1..0,-1),
               legendstyle=[location=right,font=[Helvetica,14]],
               font=[Helvetica,16],
               labelfont=[Helvetica,bold,16],
               labels=[eta,"X"],labeldirections=[horizontal,vertical]));

Download MAXRcontourplot_acM17.mw

@Carl Love Have you submitted a bug report against save? If not then I will. I notice the same issue using fprintf with its "%P" format to handle a procedure.

It might be possible to continue to save as plaintext source using a workaround such as,

    Row := proc() local R:=`<|>`; R(args); end proc:

@MAXR Is this the coloring you want for the upper surface? It required only a very simple edit of the green component ("G" in "RGB"), using the previous worksheet's formulas.

If you plot that formula,
   plot3d(F(a,b)/(2-0.5)-0.333, a=0.1 .. 0.5, b=0.1 .. 0.5)
then you would see that it ranges from approximately 0 to 1, vertically. Thus I can easily use it in Red/Green/Blue RGB component formulas to get linear gradients.

restart;

kernelopts(version);

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

(1)

with(plots): with(plottools):

x:=[0.1, 0.2, 0.3, 0.4, 0.5, 0.1, 0.2, 0.3, 0.4, 0.5,
    0.1, 0.2, 0.3, 0.4, 0.5,0.1, 0.2, 0.3, 0.4, 0.5,
    0.1, 0.2, 0.3, 0.4, 0.5]:

y:=[0.1, 0.1, 0.1, 0.1, 0.1, 0.2, 0.2, 0.2, 0.2, 0.2,
    0.3, 0.3, 0.3, 0.3, 0.3, 0.4, 0.4, 0.4, 0.4, 0.4,
    0.5,0.5,0.5,0.5,0.5]:

z:=[1.971284960, 1.642401616, 1.372353338,1.153620572,0.9762759982,

    1.675502483, 1.411976881, 1.190627373,1.007730234,0.8570007139,

    1.397140245, 1.184230644, 1.003688984,0.852696223,0.7268039317,

    1.144791107, 0.9725020383,0.8257592921,0.7020549659,0.5979974836,                                                        0.9208492326, 0.7816302394, 0.6627749172,0.5620029444,0.4766238930]:

M := Matrix(5,5,z)^%T:

xydat := [<[0.1,0.2,0.3,0.4,0.5]>,<[0.1,0.2,0.3,0.4,0.5]>]:

F := proc(a,b) option remember;
   if not [a,b]::list(numeric) then return 'procname'(args); end if;
   CurveFitting:-ArrayInterpolation(xydat, M,
                                    Array(1..1, 1..1, 1..2,
                                          [[[a,b]]]))[1,1];
end proc:

P3 := plot3d(F(a,b), a=0.1 .. 0.5, b=0.1 .. 0.5,
             color=[F(a,b)/(2-0.5)-0.333, 1-F(a,b)/(2-0.5)-0.333, 1]):

P4 := contourplot(F(a,b), a=0.1 .. 0.5, b=0.1 .. 0.5,
                  color="DarkGreen",contours=5):

display(P3,
        transform((a,b,c)->[a,b,1e-2])(P4),
        plot3d(0, a=0.1 .. 0.5, b=0.1 .. 0.5,
               color="yellow",style=surface),
        labels=["x","y","z"], orientation=[30,75,0]);


 

Download MAXR_surfcontdat_pinkblue.mw

Or perhaps you want pink->something else, as it descends.

restart;

kernelopts(version);

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

(1)

with(plots): with(plottools):

x:=[0.1, 0.2, 0.3, 0.4, 0.5, 0.1, 0.2, 0.3, 0.4, 0.5,
    0.1, 0.2, 0.3, 0.4, 0.5,0.1, 0.2, 0.3, 0.4, 0.5,
    0.1, 0.2, 0.3, 0.4, 0.5]:

y:=[0.1, 0.1, 0.1, 0.1, 0.1, 0.2, 0.2, 0.2, 0.2, 0.2,
    0.3, 0.3, 0.3, 0.3, 0.3, 0.4, 0.4, 0.4, 0.4, 0.4,
    0.5,0.5,0.5,0.5,0.5]:

z:=[1.971284960, 1.642401616, 1.372353338,1.153620572,0.9762759982,

    1.675502483, 1.411976881, 1.190627373,1.007730234,0.8570007139,

    1.397140245, 1.184230644, 1.003688984,0.852696223,0.7268039317,

    1.144791107, 0.9725020383,0.8257592921,0.7020549659,0.5979974836,                                                        0.9208492326, 0.7816302394, 0.6627749172,0.5620029444,0.4766238930]:

M := Matrix(5,5,z)^%T:

xydat := [<[0.1,0.2,0.3,0.4,0.5]>,<[0.1,0.2,0.3,0.4,0.5]>]:

F := proc(a,b) option remember;
   if not [a,b]::list(numeric) then return 'procname'(args); end if;
   CurveFitting:-ArrayInterpolation(xydat, M,
                                    Array(1..1, 1..1, 1..2,
                                          [[[a,b]]]))[1,1];
end proc:

P3 := plot3d(F(a,b), a=0.1 .. 0.5, b=0.1 .. 0.5,
             color=[1, 1-0.25*((F(a,b)/(2-0.5)-0.333)), 1-0.2*(1-(F(a,b)/(2-0.5)-0.333))]):

P4 := contourplot(F(a,b), a=0.1 .. 0.5, b=0.1 .. 0.5,
                  color="DarkGreen",contours=5):

display(P3,
        transform((a,b,c)->[a,b,1e-2])(P4),
        plot3d(0, a=0.1 .. 0.5, b=0.1 .. 0.5,
               color="yellow",style=surface),
        labels=["x","y","z"], orientation=[30,75,0]);

 

 

Download MAXR_surfcontdat_pinkwhite.mw

@MAXR You're not being completely clear.

If you mean that you want a coloring that goes from pink to blue in a graded manner (say, as a vertical linear gradient, as the "z"-value changes), then you should state that explicitly.

Is that what you want?

note. A few releases after your Maple 17 there was added a `colorscheme` option to do that easily and flexibly right in the `plot3d' call. But I can adjust the 3-component RGB formulas above to do pink->blue instead of white->blue.

@Ronan Sorry I was not clear.

What I meant to convey was that I think it would be more beneficial longterm if you wrote the procedures directly in plaintext files, instead of writing them in the GUI and exporting as plaintext.

This came up in an earlier Question thread, in which Joe Riel & I listed off some benefits; revision control, syntax highlighting in 3rd party text editors. I could also mention: greater safety from .mw saving corruption, protection from save issues. Some editors also allow escaped system commands while open; I execute scripts that build my .mla's straight from my vim editor, and I suspect Joe does similar from his Maple-mode emacs, and I expect some others do similarly from Eclipse.

@Ronan I think that you should write all these procedures in plaintext 1D Maple Notation, not 2D Input.

If you are using Maple 2022 then the (new) default is adaptive=geometric, which for your example may not produce curves as close to the x-axis near the all the roots.

The result is somewhat better for this example in Maple 2022 if you supply the option,
    adaptive=true
in that plot call.

Try it like this,
   plot(abs(sin(x)/x), x=-2*Pi..10*Pi, adaptive=true, numpoints=400);
if you are using Maple 2022.

@MAXR Please be specific about what coloring you want.

As I mentioned in my answer, one reason that I constructed an interpolating function is so that it could be more easily plotted and colored using just the usual plot3d command.

You can easily see the advanced coloring options for the plot3d command by looking at the Help page with Topic, plot3d,color in your Maple 17 version.

Of course you can also use the basic color and shading options as described on the Help page with topic plot3d,options in your version.

Please do not post duplicate Question threads on this example.

If you make adjustments and fixes to the code, then you could sensibly add your related followup queries here, instead of in a wholly separate Question thread.

@Ronan There is no reason to save in .mws format. Using 1D input doesn't require that. It's related to that warning about the format.

@ecterrab It can still be important to know that the OP was using a Physics update (without the prior lack of knowledge that he might move to, say Maple 2022.2).

One point is that any proposed solution developed by a responder for any stock Maple 2022 point release might conceivably run differently on the OP's system (with its Physics update). Therefore a responder might need to mimic the very same environment, or risk wasting time.

@ecterrab This Question was posted on October 22, 2022, and (at that date) its attachment was last saved in Maple 2022.1.

The update Maple 2022.2 was only released to the public on October 28, 2022.

Using stock Maple 2022.1, without Physics updates separately installed, the attachment does not execute as the OP's sheet shows inlined in the Question.

That is why I asked about whether he had installed a Physics update. It was indeed relevent to what was originally posted.

For example,

restart

kernelopts(version)

`Maple 2022.1, X86 64 LINUX, May 26 2022, Build ID 1619613`

with(Physics)

diff(x(t), `$`(t, 2)) = a(t)

diff(diff(x(t), t), t) = a(t)

dsolve(diff(diff(x(t), t), t) = a(t), arbitraryconstants = subscripted)

Error, (in dsolve) found wrong extra argument(s): arbitraryconstants = subscripted

a(t) = 1.*Unit('m'/'s'^2), c__1 = 2*Unit('m'/'s'), c__2 = 3*Unit('m')

a(t) = 1.*Units:-Unit(m/s^2), c__1 = 2*Units:-Unit(m/s), c__2 = 3*Units:-Unit(m)

subs(a(t) = 1.*Units:-Unit(m/s^2), c__1 = 2*Units:-Unit(m/s), c__2 = 3*Units:-Unit(m))

c__2 = 3*Units:-Unit(m)

value(%)

c__2 = 3*Units:-Unit(m)

NULL

Download Unit_of_t_M2022.1.mw

Using the later Maple 2022.2 updated point-release then I see the same Warning as you showed, and as was in the original Question.

@zenterix Irrespective of your present Question's issues, using savelib and savelibdir is not great methodology -- especially if you are new to all this.

I suggest thar you use LibraryTools commands instead, and always explicitly reference the .mla (including, but not only by, its fully qualified location).

@Carl Love I agree with what you've written here (including what both you and dharr have written about tables).

But I'd like to respond about whattype. I like that wording you used: it is not useful because it doesn't always tell the "complete story".

I can hardly imagine using whattype for serious Maple coding. In some sense it's worse than useless, because it's existence lulls users into poor programming technique alongside the occasional lack of specificity in its return values.

Something can be more than one type, and last name evaluation can hide even that. Also, the type system is not really hierarchical. In consequence of that a Maple program should not ask what type something is, instead of checking explictly whether it is each of some collection of types.

First 92 93 94 95 96 97 98 Last Page 94 of 591