acer

32313 Reputation

29 Badges

19 years, 314 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

@JAMET Please don't create multiple Question threads for this topic.

Please put your followup queries and discussion here, instead of in a new and wholly separate Question thread.

@richinex Here is a shorter version of what I had above, with less exposition but still following the idea of your document.

Y := 1/(R__s+1/(s*C__dl+1/(R__ct+1/(sqrt(s)/sigma+1/R__w))))

padey := `assuming`([collect(eval(numapprox:-pade(Y, x = sqrt(s), [1, 1]), s = ss^2), ss, proc (u) options operator, arrow; simplify(u/(sigma*(R__ct+R__s+R__w))) end proc)], [ss > 0])

num, den := op(padey)

eqs := {seq(a[i] = coeff(num, ss, i), i = 0 .. degree(num, ss)), seq(b[i] = coeff(1/den, ss, i), i = 0 .. degree(1/den, ss))}

[op(simplify(eliminate(eqs, [R__s, C__dl, R__ct, sigma, R__w]))[1])]

[C__dl = -a[2]^2/(a[0]*b[2]-a[2]), R__ct = (-a[1]*b[2]+a[2]*b[1])/(a[1]*a[2]), R__s = b[2]/a[2], R__w = (-a[0]*b[1]+a[1])/(a[1]*a[0]), sigma = (-a[0]*b[1]+a[1])/a[1]^2]

Download maple_attempt_ac3.mw

Replace colon statement terminators with semicolons to see the intermediate results.

Inspired by Axel's clever use of implicit RootOf, I reworked some of the above...

(I have no idea whether the OP wants such an implicit result. But it's fun.)

restart;

expr:=sin(sqrt(3)*t)*cos(sqrt(3)*t)*(sqrt(3)*cos(sqrt(3)*t) - sin(sqrt(3)*t))/3;

(1/3)*sin(3^(1/2)*t)*cos(3^(1/2)*t)*(3^(1/2)*cos(3^(1/2)*t)-sin(3^(1/2)*t))

S:=solve(diff(expr,t),t,allsolutions,explicit=false):
S:=[seq(subsindets(S,RootOf,u->RootOf(op(u),index=i)),i=1..3)]:
v:=indets(S,suffixed(_Z))[1]:

plots:-display(
  plots:-pointplot([seq(Re~(evalf([s,eval(expr,[t=s])])),s=simplify(S,{v=1}))],
                   symbol=solidcircle,symbolsize=15,color=blue),
  plot(expr,t=0..Pi), size=[600,200], xtickmarks=decimalticks)

H:=simplify(S,{v=1}):

HH := sort(H, (a,b)->is(simplify(evalc(eval(expr,t=allvalues(a))))
                        > simplify(evalc(eval(expr,t=allvalues(b)))))):

t_opt := HH[1];
evalf(%);

(1/3)*3^(1/2)*(arctan(RootOf(-2*3^(1/2)*_Z^2+_Z^3+3^(1/2)-2*_Z, index = 3))+Pi)

1.390845871

evalf( eval(expr, t=t_opt) );

HFloat(0.3242632442687191)

expr_opt := combine(expand(eval(expr, t=t_opt)));
evalf(%);

-(1/3)*RootOf(-2*3^(1/2)*_Z^2+_Z^3+3^(1/2)-2*_Z, index = 3)*3^(1/2)/(1+RootOf(-2*3^(1/2)*_Z^2+_Z^3+3^(1/2)-2*_Z, index = 3)^2)^(3/2)+(1/3)*RootOf(-2*3^(1/2)*_Z^2+_Z^3+3^(1/2)-2*_Z, index = 3)^2/(1+RootOf(-2*3^(1/2)*_Z^2+_Z^3+3^(1/2)-2*_Z, index = 3)^2)^(3/2)

HFloat(0.32426324426871905)

sqrt(1+R^2)*(7*R^2-15*R*sqrt(3)-3)/108;
eval(%, R=RootOf(-2*sqrt(3)*_Z^2+_Z^3+sqrt(3)-2*_Z,index=3)):
evalf(%);

(1/108)*(R^2+1)^(1/2)*(7*R^2-15*R*3^(1/2)-3)

HFloat(0.32426324428570724)

Download some_trig_opt_2.mw

Your Question is lacking key details.

For example, you have not shown explicitly how f and fproc were constructed. There is no code in your original Question like, say, a call to any export of the Interpolate package. You mention "an interpolation object, f(x)" but did not show or clearly describe what you did to create that. There are several ways to do such things in Maple, with several different commands from several different packages. You might be using commands from the CurveFitting, Statistics, or ArrayTools packages.

Also, your Question did not originally contain a sentence like, "The name "fproc" is not something I have in my  code, just the name, "f"." You may have edited your Question, and added that, since I first replied.

Quite a bit of what else you've written makes little to no sense without context. Even a clear sentence that stated that you were trying to perform numeric integration using an object returned by command X from the Interpolate package (where X is an actual command name). would have been useful and more clear. The word "object" can be used as a technical Maple term (jargon) or as a general English word, and without your mentioning the Interpolate package it becomes a matter of guessing here.

Why haven't you bothered to upload and attach a worksheet so that we could see what you have actually done, what Maple version you're using, with code to reproduce the problems? (Green up-arrow in the Mapleprimes editor)

@WA573 You can use any valid value that you want for the pointplot3d command's symbol, symbolsize, and color options.

p3dopt2.mw

@Ronan It's slightly bewildering, because I already mentioned using LibraryTools in your previous Question thread.

Saving/exporting your procedures from a worksheet to external files is a methodology that you yourself described, and was not proposed by responders to recent Question threads. It's not necessary.

Personally I think that authoring source in directly plaintext files has benefits, that especially manifest themselves if it's used and re-used over the years. But authoring in the GUI and then saving to external files is a backwards and unnecessary process.

@Ronan In this latest scenario (saving as .m format) there's no reason to even export/save at all.

In that situation you could just as easily use LibraryTools to Save the procedure or module directly to a .mla archive file.

See my earlier Reply above, for various benefits of having/authoring your code in plaintext files. Using the mint Maple syntax checker (at full strength, not the less flexible/weakened maplemint or CodeEdit/Startup facilities in the GUI) is yet another motivation.

I'm not the only person who sees benefits to using plaintext files for packages/procedures that you might utilize into the future; see also here for a comment by someone else in a related and recent discussion thread.

If none of that rationale interests you then you don't need to export/save your procedures/modules to external source files.

@nmacsai It wasn't clear to me from your original Question whether you wanted just the number of base b digits, or the actual conversion as well.

I guessed that it was just the number of base b digits.

@Carl Love I was shooting for speed, especially as n gets very large.

Are the numbers you want to handle only positive integers? Or floats?

How large are the numbers you want to handle?

How many number do you want to handle? How fast do you need it?

@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.

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