acer

32333 Reputation

29 Badges

19 years, 322 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

My results agree approximately with that of mmcdara.

If you do symbolic integration then the symbolic result require high (Digits possibly as high as 150, but I didn't find a tight bound) working precision in order to avoid numeric roundoff error.

But if you set it up with purely numeric integration then a siimilar result can be obtained with much lower working precision in just a few seconds.

XZ_for_MPac.mw

The Statistics:-BoxPlot command already offers options to control the offset and width of the box. I deliberately do a translation (transformation) instead of using those. And I stick in a point at the origin, as one easy way to force the axes to be displayed at the origin.

(There are several other ways to get all these effects. It's a matter of taste, mostly. They all require a little bookkeeping or fiddling, IMO. How much fiddling depends on whether you want to be able to get the a-axis above just as easily, or whether you also want easy control over the box width, etc. Again, note that your code forced the size option, which I kept.)

I didn't find your description and question very clear, so I may not have guessed correctly about what details you're after.

restart;

BoxP:=proc(xd::list, {yshift::realcons:=0})
        local P,s;
        uses Statistics:
        s := evalf(yshift);
        if s<0 then s:=s-1; end if;
        P:=BoxPlot(xd,':-deciles'=false,':-orientation'=':-horizontal');
        P:=plottools:-transform((x,y)->[x,y+s])(P);
        return plots:-display(P,plot([[0,0]]),':-size'=[400,200],
                              ':-axis'[2]=[':-color'="white",':-tickmarks'=[]],
                              ':-axes'=':-normal');
    end proc:

f:=rand(1..100):
L:=[seq(f(),i=1..100)]:

 

Here's the basic idea.

 

\BoxP(L, yshift=0.5);

 

If you shift farther away, with the fixed `size` and normal `axes,
then you get more vertical scaling (compression).

 

BoxP(L, yshift=1.0);

 

If you want the x-axis on top (...there are other ways to get this).

 

BoxP(L, yshift=-0.5);

 

Again, you can shift farther away.

 

BoxP(L, yshift=-1.0);

 

Download boxp_idea.mw

Once again, let me point out that you can control all this and more by using the offset, width, and distance options of the BoxPlot command. But even then you may prefer to omit the size option, or allow an unconstrained scaling, or still need to include a fixed reference such as the origin point. It's a bit of a trade-off: easy control for just your particular case, or slightly more awkward control for a wider set of cases.

 

Here are some ideas that might help you get started with the surface defined by your formula.

I've constructed an explicit solution for m__yy as a function of m__zz and n. This is used to plot a surface quickly, that looks smoother and responds better in the GUI than a 3D implicit plot. And you may find use for the explict formula.

I've laid some 3D contours lines on that surface. I've also shown how the equivalent 2D contour plots can be obtained. Let me know if you want a 2D version more like a fully-shaded densityplot (or both, overlaid).

(The original can also be solved for m__zz explicitly, but getting a sharp and full plot boundary is a little more effort.)

I don't know how you are currently dealing with your irregularly spaced 3D data. Are you generating an interpolating procedure? Please post the actual data. 

restart;

a := 45/100;
#a := 2/3:

9/20

UC := proc(n, m__yy, m__zz)
  piecewise(1/5 < n, m__yy^2/min(1,(1-n)/(1-1/2*aa))^2
                     +(m__zz/piecewise(n <= aa, 1, 1-(n-aa)^2/(1-aa)^2))^(5*n),
                     m__yy^2/min(1,(1-n)/(1-1/2*aa))^2
                     +m__zz/piecewise(n <= aa, 1, 1-(n-aa)^2/(1-aa)^2));
end proc:

eval(UC(n, m__yy, m__zz), aa = a):

KK := simplify(%);

KK := piecewise(n <= 1/5, m__yy^2+m__zz, n <= 9/40, m__yy^2+m__zz^(5*n), n <= 9/20, 961*m__yy^2/(1600*(n-1)^2)+m__zz^(5*n), 9/20 < n, 961*m__yy^2/(1600*(n-1)^2)+(-121*m__zz/(400*n^2-360*n-40))^(5*n))

RR := solve({KK = 1, 0 < m__zz, 0 < n, m__zz < 1, n < 1}, {m__yy}):
RRR := (simplify(RR) assuming (0 < n, n < 1, 0 < m__zz, m__zz < 1)):
RRRR := subsindets(RRR, list, uu -> eval(m__yy, uu[1]));

RRRR := piecewise(n <= 1/5, sqrt(1-m__zz), n <= 9/40, sqrt(1-m__zz^(5*n)), n <= 9/20, -40*sqrt(1-m__zz^(5*n))*(n-1)*(1/31), 9/20 < n, -40*sqrt(1-m__zz^(5*n)*(-25937424601/(102400000*(10*n^2-9*n-1)^5))^n)*(n-1)*(1/31))

FF := [solve({RRRR = 0}, {m__zz})];
FFF := (eval(m__zz, simplify(%[1])[1]) assuming (a < n));
evalf(eval(FFF, n = 0.7));

FF := [piecewise(n <= 9/20, [{m__zz = 1}], 9/20 < n, [{m__zz = 40/(121*(-1/(10*n^2-9*n-1)^5)^(1/5))}])]

(40/121)/(-1/(10*n^2-9*n-1)^5)^(1/5)

.7933884298

P1s := plot3d([RRRR, m__zz, n],
               m__zz = 0 .. piecewise(n <= a, 1, FFF) - 0.1*10^(-8),
               n = 0 .. 1, labels = [m__yy, m__zz, n],
               view = [0 .. 1, 0 .. 1, 0 .. 1], style = surface):
P1s;

P1c := plot3d([RRRR, m__zz, n],
              m__zz = 0 .. piecewise(n <= a, 1, FFF) - 0.1*10^(-8),
              n = 0 .. 1, labels = [m__yy, m__zz, n],
              view = [0 .. 1, 0 .. 1, 0 .. 1],
              colorscheme = ["zgradient", ["LightGreen", "Blue"]],
              style = contour, contours = [1/5, a/2, a, 0.7], thickness = 3):
P1c;

P2c2D := plots:-contourplot(RRRR, m__zz = 0 .. piecewise(n <= a, 1, FFF) - 0.1*10^(-8),
                            n = 0 .. 1, labels = [m__zz, n], view = [0 .. 1, 0 .. 1],
                            thickness = 3, contours = [0.2, 0.4, 0.6, 0.9],
                            coloring = [red, yellow]):
P2c2D;

P2c := plots:-display(plottools:-transform((a, b, c) -> [eval(RRRR, [n = b, m__zz = a]), a, b])(P2c2D)):

plots:-display(P1s, P1c, P2c);

P1c2D := plots:-contourplot([RRRR, m__zz, n],
                            m__zz = 0 .. piecewise(n <= a, 1, FFF) - 0.1*10^(-8),
                            n = 0 .. 1 - 0.1*10^(-8), labels = [m__yy, m__zz],
                            view = [0 .. 1, 0 .. 1], coloring = ["LightGreen", "Blue"],
                            contours = [1/5, a/2, a, 0.7], thickness = 3):
P1c2D;

 

Download testd3.mw

You might give this a whirl.

restart;

kernelopts(version);

`Maple 2016.2, X86 64 LINUX, Jan 13 2017, Build ID 1194701`

fsolve({c*exp(-8*a)+18 = 36, c*exp(-2*a)+18 = 55},{a, c});

fsolve({c*exp(-8*a)+18 = 36, c*exp(-2*a)+18 = 55}, {a, c})

fsolve([c*exp(-8*a)+18 = 36, c*exp(-2*a)+18 = 55],{a, c});

fsolve([c*exp(-8*a)+18 = 36, c*exp(-2*a)+18 = 55], {a, c})

fsolve([c*exp(-2*a)+18 = 55, c*exp(-8*a)+18 = 36],{a, c});

{a = .1200910258, c = 47.04478236}

 

A "hot fix", to correct line 52 (from return FAIL to break) of either `fsolve/sysnewton`
or fsolve:-sysnewton, in relevant versions.

If it works for you then you could try it in an initialization file.

 

proc()
  local str,pp,KK,uu,oldop;
  oldop:=kernelopts(':-opaquemodules'=false);
  try
    str:=sprintf("%a",kernelopts(':-version'))[8..13];
    if str="2015.2" then
      pp:=:-`fsolve/sysnewton`;
    elif
      parse(str)>=2016 and parse(str)<2020 then
      pp:=:-fsolve:-sysnewton;
    else;
      error "targeted version not detected";
    end if;
    KK:=ToInert(eval(pp)):
    if op([5,14,6,10,6,4,1,2,1,1,2],KK)
       = _Inert_STATSEQ(_Inert_RETURN(_Inert_NAME("FAIL",
           _Inert_ATTRIBUTE(_Inert_NAME("protected",
             _Inert_ATTRIBUTE(_Inert_NAME("protected"))))))) then
      unprotect(pp);
      uu:=true;
      assign(pp,FromInert(subsop([5,14,6,10,6,4,1,2,1,1,2]
                            =_Inert_STATSEQ(_Inert_BREAK()),KK)));
    end if:
  catch:
  finally
    kernelopts(':-opaquemodules'=oldop);
    if uu=true then
      protect(pp);
    end if;
  end try;
  NULL;
end proc();

 

fsolve({c*exp(-8*a)+18 = 36, c*exp(-2*a)+18 = 55},{a, c});

{a = .1200910258, c = 47.04478236}

fsolve([c*exp(-8*a)+18 = 36, c*exp(-2*a)+18 = 55],{a, c});

{a = .1200910258, c = 47.04478236}

fsolve([c*exp(-2*a)+18 = 55, c*exp(-8*a)+18 = 36],{a, c});

{a = .1200910258, c = 47.04478236}

 

Download sysnewtonhotfix.mw

Consider line 52 of fsolve:-sysnewton (it was `fsolve/sysnewton` in Maple 2015 and earlier) under showstat. The purpose of that line seems to be to bail out early on a iteration it considers futile. In Maple 18 it followed a conditional test that could never work (it compared a vector directly against a list). In Maple 2015 that was amended with a test that could work (and probably fixed some other example). But at that point it bails out by a hard return from the whole procedure (when the rare condition happens to get triggered), which seems like a coding mistake. A better way might be merely to break out of the current do-loop and allow the outer loop to proceed normally and produce further initial-point guesses and iteration attempts -- and so that's an idea for amending the procedure.

I don't advise pasting the code in as 2D Input.

You also mentioned solve. Using Maple 2016.2 you can also obtain an explicit, exact real solution.

Carl mentioned that you can use the evalf command on the result containing implicit RootOfs, obtained from the simple call to solve (without the extra explicit option). You could also apply the allvalues command to that result, to resolve those particular RootOfs exactly.

Here are a few ways to get an exact root in terms of exact radicals, including supplying the explicit option to solve directly.

restart;

kernelopts(version);

`Maple 2016.2, X86 64 LINUX, Jan 13 2017, Build ID 1194701`

S:=t->c*exp(-a*t)+18;

proc (t) options operator, arrow; c*exp(-a*t)+18 end proc

sys:={S(2)=55,S(8)=36};

{c*exp(-8*a)+18 = 36, c*exp(-2*a)+18 = 55}

 

In one step, using solve:

 

[solve(sys,real,explicit)];
combine(simplify(%));
evalf(%);

[{a = -(1/2)*ln((1/37)*24642^(1/3)), c = (1/18)*24642^(2/3)}]

[{a = (1/3)*ln((1/6)*74^(1/2)), c = (1/18)*24642^(2/3)}]

[{a = .1200910258, c = 47.04478236}]


Also using solve, then sieving out the real solution:

 

exactsols:=evalc([solve(sys,explicit)]):

map(print,exactsols):

{a = -(1/2)*ln((1/74)*444^(2/3)), c = (37/6)*444^(1/3)}

{a = -(1/4)*ln((3/37)*444^(1/3))+((1/3)*I)*Pi, c = -(37/12)*444^(1/3)+((37/12)*I)*3^(1/2)*444^(1/3)}

{a = -(1/4)*ln((3/37)*444^(1/3))-((1/3)*I)*Pi, c = -(37/12)*444^(1/3)-((37/12)*I)*3^(1/2)*444^(1/3)}

map(print,evalf(exactsols)):

{a = .1200910259, c = 47.04478236}

{a = .1200910258+1.047197551*I, c = -23.52239118+40.74197665*I}

{a = .1200910258-1.047197551*I, c = -23.52239118-40.74197665*I}

select(s->andmap(is,map(rhs,s),real),exactsols);
evalf(%);

[{a = -(1/2)*ln((1/74)*444^(2/3)), c = (37/6)*444^(1/3)}]

[{a = .1200910259, c = 47.04478236}]

 

Using allvalues on the solution from solve that contains the implicit RootOfs.

From here you could select only the real root, as done above.

 

solve(sys);
combine([allvalues(%)]):
map(print,%):

{a = -(1/2)*ln((18/37)*RootOf(18*_Z^3-37)^2), c = 37*RootOf(18*_Z^3-37)}

{a = -(1/2)*ln((1/74)*444^(2/3)), c = (37/6)*444^(1/3)}

{a = -(1/2)*ln((1/296)*444^(2/3)*(I*3^(1/2)-1)^2), c = -(37/12)*444^(1/3)+((37/12)*I)*3^(1/2)*444^(1/3)}

{a = -(1/2)*ln((1/296)*444^(2/3)*(I*3^(1/2)+1)^2), c = -(37/12)*444^(1/3)-((37/12)*I)*3^(1/2)*444^(1/3)}

 

In several steps, isolating exactly, and re-substituting:

 

S1:=isolate(sys[1],a);

a = -(1/8)*ln(18/c)

S2:=eval(sys[2],S1);

c*3^(1/2)*(2^(1/2)*(1/c)^(1/2))^(1/2)+18 = 55

isolate(S2,c);
Csol:=combine(%);

c = (37/6)*2^(2/3)*111^(1/3)

c = (37/6)*444^(1/3)

Asol:=eval(S1,Csol);

a = -(1/8)*ln((9/1369)*444^(2/3))

evalf([Asol,Csol]);

[a = .1200910258, c = 47.04478236]

 

Download exactexplicit.mw

It's unclear to me what you're asking. The example you've given seems trivial, to the point that I wonder whether I've misunderstood. Perhaps one of these will do for you.

I am guessing that perhaps it may be the second idea below (using F1) that you're after: as a looped operation, storing produced values in table references, so as to be able to convert at the end to a sequence or list. I am guessing that you already have some other procedure or process generating values in a more complicated loop, and you want to know how to store them so that you can convert afterwards to a sequence or list.

restart

F0 := proc () [seq(i^2, i = 1 .. 5)] end proc

F0()

[1, 4, 9, 16, 25]

F1 := proc () local i, T; for i to 5 do T[i] := i^2 end do; convert(T, list) end proc

F1()

[1, 4, 9, 16, 25]

F2 := proc (f::appliable, rng::(range(integer))) local i; [seq(f(i), i = rng)] end proc

F2(proc (i) options operator, arrow; i^2 end proc, 1 .. 5)

[1, 4, 9, 16, 25]

F3 := proc (f, var, rng::(range(integer))) local i; [seq(eval(f, var = i), i = rng)] end proc

F3(x^2, x, 1 .. 5)

[1, 4, 9, 16, 25]

``

Download MaplePrimes_Example_ac.mw

Do you need to be shown how to read in the contents of a text file as a string?

restart;

str := "How to remove all punctuation marks in a string read from a text file

and then store in a list of words according to the ordering of the original text?":

StringTools:-Words(str);

["How", "to", "remove", "all", "punctuation", "marks", "in", "a", "string", "read", "from", "a", "text", "file", "and", "then", "store", "in", "a", "list", "of", "words", "according", "to", "the", "ordering", "of", "the", "original", "text"]

 

Download words.mw

This is a good one to report.

There are several workarounds for fsolve here (you don't even have to resort to using other commands).

My favorite is the first one, where it works simply by renaming the variables (but with reverse lexicographic order).

restart;

kernelopts(version);

`Maple 2016.2, X86 64 LINUX, Jan 13 2017, Build ID 1194701`

sys := {c*exp(-8*a)+18 = 36, c*exp(-2*a)+18 = 55};

{c*exp(-8*a)+18 = 36, c*exp(-2*a)+18 = 55}

new0 := eval(sys,[a=C,c=A]);

{A*exp(-8*C)+18 = 36, A*exp(-2*C)+18 = 55}

fsolve(new0,{C,A});

{A = 47.04478236, C = .1200910258}

new1 := map(isolate,sys,a);
fsolve(new1);

{a = -(1/8)*ln(18/c), a = -(1/2)*ln(37/c)}

{a = .1200910258, c = 47.04478236}

new2 := map(isolate,sys,c);
fsolve(new2);

{c = 18/exp(-8*a), c = 37/exp(-2*a)}

{a = .1200910258, c = 47.04478236}

map(`/`,sys,c);
fsolve(%);

{(c*exp(-8*a)+18)/c = 36/c, (c*exp(-2*a)+18)/c = 55/c}

{a = .1200910258, c = 47.04478236}

fsolve(sys,{a,c},{a=-5..80});

{a = .1200910258, c = 47.04478236}

fsolve(sys,{a,c},{c=0..infinity});

{a = .1200910258, c = 47.04478236}

 

Download fsysolve_sys.mw

You could get the convenience of loading all of the package, and then selectively unload just the export whose name you wished to utilize.

That allows you to use the remaining exports as their short-form names. And the export corresponding to the special name could still be accessed using its long-form.

For example,

restart;

with(NumberTheory):

unwith(NumberTheory,lambda):

lambda:=5;

5

lambda;

5

NumberTheory:-lambda(222);

36

Divisors(28);

{1, 2, 4, 7, 14, 28}

lambda := n -> (-1)^Omega(n);

proc (n) options operator, arrow; (-1)^NumberTheory:-Omega(n) end proc

lambda(667);

1

NumberTheory:-lambda(667);

308

 

Download unwith_example.mw

Alternatively (as Tom mentioned) you could utilize the global reference :-lambda. In that fashion you could still load the whole package, and get a similar effect.

restart;

with(NumberTheory):

:-lambda:=5;

5

:-lambda;

5

NumberTheory:-lambda(222);

36

Divisors(28);

{1, 2, 4, 7, 14, 28}

:-lambda := n -> (-1)^Omega(n);

proc (n) options operator, arrow; (-1)^NumberTheory:-Omega(n) end proc

:-lambda(667);

1

NumberTheory:-lambda(667);

308

 

Download globalname.mw

Applying unprotect on the special name, after loading the whole package, and then assigning to that name, is not good since it prevents any further access to the package export of that name. It would also break any functionality that depended on the original definition of that export. It actually clobbers that export.

 

A:= [ [4,2], [9,1], [6,8] ]:

map[2](op,1,A);                                                                              

             [4, 9, 6]

map[2](op,2,A);

             [2, 1, 8]

Alternatively,

op~(1,A);
                                                                                
             [4, 9, 6]

op~(2,A);

             [2, 1, 8]

map(`?[]`,A,[1]);

             [4, 9, 6]

map(`?[]`,A,[2]);

             [2, 1, 8]

map(u->u[1],A);

             [4, 9, 6]

map(u->u[2],A);

             [2, 1, 8]

(u->u[1])~(A);

             [4, 9, 6]

(u->u[2])~(A);

             [2, 1, 8]

I'm not claiming that this is a general solution, in part because you haven't indicated the general kind of example. But you might get some ideas from it, for your exercise.

(It isn't clear whether you can use expand, as done below. But even that effect could be implemented manually.)

If your expression has a term with (1-y) in its denominator and another term with (1-y)^2 in its own denominator then G may be generated here as (1-y)^3. If that's not what you want to happen then you could correct the code to manage that. That's what I mean when I say that this is just to give you some ideas.

And I don't know whether this code will seem simplistic or complicated to you, as I don't know what Maple familiarity you have.

restart;

ee := -1/(y-1)-y/(y-1)-y^2-2*y-1+y^3/(y-1)+y^2/(y-1);

-1/(y-1)-y/(y-1)-y^2-2*y-1+y^3/(y-1)+y^2/(y-1)

L:=[op(ee)];

[-1/(y-1), -y/(y-1), -y^2, -2*y, -1, y^3/(y-1), y^2/(y-1)]

getdenom:=proc(u)
  local T,TT;
  if u::`*` then
    T:=[op(u)];
    TT:=select(type,T,And(`^`,satisfies(p->op(2,p)::numeric and op(2,p)<0)));
    TT:={op(map(p->op(1,p)^(-op(2,p)),TT))};
  else
    return {1};
  end if;
end proc:

getdenom(L[1]);

{y-1}

`union`(op(map(getdenom,L)));
G:=`*`(op(%));

{1, y-1}

y-1

map(expand@`*`,L,G);
`+`(op(%));

[-1, -y, -y^3+y^2, -2*y^2+2*y, -y+1, y^3, y^2]

0

expr:=2+3*x+3*x^3*y+3*x*y-x^4*y^3-x^3*y^4-x^2*y^5-x*y^6-3*x^4*y^2-2*x^3*y^2-2*x^2*y^3-2*x*y^4+2*y-3*x^4*y+y^6/(y-1)-x^5/(y-1)-x^4/(y-1)-x^3/(y-1)-x^2/(y-1)-x/(y-1)-1/(y-1)+x^3*y^3/(y-1)-x^5*y/(y-1)+x^2*y^4/(y-1)+x*y^5/(y-1)-2*y^5-x^4-y^2/(y-1)-2*y/(y-1)-x^5*y^2+3*x^2*y+y^8/(y-1)+2*y^7/(y-1)-3*x^3*y^3-3*x^2*y^4-3*x*y^5-2*x^5*y+x^5*y^3/(y-1)+x^4*y^4/(y-1)+x^3*y^5/(y-1)+x^2*y^6/(y-1)+x*y^7/(y-1)+x^5*y^2/(y-1)+2*x^4*y^3/(y-1)+2*x^3*y^4/(y-1)+2*x^2*y^5/(y-1)+2*x*y^6/(y-1)-2*x^4*y/(y-1)-x^3*y^2/(y-1)-2*x^3*y/(y-1)-x^2*y^2/(y-1)-2*x^2*y/(y-1)-x*y^2/(y-1)-2*x*y/(y-1)-x^5-2*y^6+3*x^3+3*x^2:

LL:=[op(expr)];

[2, x^5*y^3/(y-1), x^4*y^4/(y-1), x^3*y^5/(y-1), x^2*y^6/(y-1), x*y^7/(y-1), x^5*y^2/(y-1), -x^3*y^2/(y-1), -x^2*y^2/(y-1), -x*y^2/(y-1), x^3*y^3/(y-1), -x^5*y/(y-1), x^2*y^4/(y-1), x*y^5/(y-1), 3*x^3, -2*y^6, -2*y^5, -x^4, 3*x^2, -x^5, 2*y, -1/(y-1), -2*y/(y-1), -y^2/(y-1), 3*x, 2*x^2*y^5/(y-1), -2*x^4*y/(y-1), 2*x^4*y^3/(y-1), 2*x^3*y^4/(y-1), -2*x^2*y/(y-1), -2*x*y/(y-1), 2*x*y^6/(y-1), -2*x^3*y/(y-1), -x^4*y^3, -x^3*y^4, -x^2*y^5, -x*y^6, y^6/(y-1), -x^5/(y-1), -x^4/(y-1), -x^3/(y-1), -x^2/(y-1), -x/(y-1), -x^5*y^2, y^8/(y-1), 3*x^3*y, 3*x*y, -3*x^4*y^2, -2*x^3*y^2, -2*x^2*y^3, -2*x*y^4, -3*x^4*y, 3*x^2*y, 2*y^7/(y-1), -3*x^3*y^3, -3*x^2*y^4, -3*x*y^5, -2*x^5*y]

`union`(op(map(getdenom,LL)));
GG:=`*`(op(%));

{1, y-1}

y-1

RR:=map(expand@`*`,LL,GG);

[2*y-2, x^5*y^3, x^4*y^4, x^3*y^5, x^2*y^6, x*y^7, x^5*y^2, -x^3*y^2, -x^2*y^2, -x*y^2, x^3*y^3, -x^5*y, x^2*y^4, x*y^5, 3*x^3*y-3*x^3, -2*y^7+2*y^6, -2*y^6+2*y^5, -x^4*y+x^4, 3*x^2*y-3*x^2, -x^5*y+x^5, 2*y^2-2*y, -1, -2*y, -y^2, 3*x*y-3*x, 2*x^2*y^5, -2*x^4*y, 2*x^4*y^3, 2*x^3*y^4, -2*x^2*y, -2*x*y, 2*x*y^6, -2*x^3*y, -x^4*y^4+x^4*y^3, -x^3*y^5+x^3*y^4, -x^2*y^6+x^2*y^5, -x*y^7+x*y^6, y^6, -x^5, -x^4, -x^3, -x^2, -x, -x^5*y^3+x^5*y^2, y^8, 3*x^3*y^2-3*x^3*y, 3*x*y^2-3*x*y, -3*x^4*y^3+3*x^4*y^2, -2*x^3*y^3+2*x^3*y^2, -2*x^2*y^4+2*x^2*y^3, -2*x*y^5+2*x*y^4, -3*x^4*y^2+3*x^4*y, 3*x^2*y^2-3*x^2*y, 2*y^7, -3*x^3*y^4+3*x^3*y^3, -3*x^2*y^5+3*x^2*y^4, -3*x*y^6+3*x*y^5, -2*x^5*y^2+2*x^5*y]

ans:=map(`/`,`+`(op(RR)),GG);

y^8/(y-1)+2*x^3*y^3/(y-1)+2*x^2*y^4/(y-1)+2*x*y^5/(y-1)+y^6/(y-1)+4*x^3*y^2/(y-1)+2*x^2*y^3/(y-1)+2*x*y^4/(y-1)+2*y^5/(y-1)-2*x^3*y/(y-1)+2*x^2*y^2/(y-1)-4*x^3/(y-1)-2*x^2*y/(y-1)+2*x*y^2/(y-1)-4*x^2/(y-1)-2*x*y/(y-1)+y^2/(y-1)-4*x/(y-1)-2*y/(y-1)-3/(y-1)

targ:=y^6/(y-1)-4*x^3/(y-1)-4*x^2/(y-1)-4*x/(y-1)-3/(y-1)+2*x^3*y^3/(y-1)+2*x^2*y^4/(y-1)+2*x*y^5/(y-1)+y^8/(y-1)+2*y^5/(y-1)+4*x^3*y^2/(y-1)+2*x^2*y^3/(y-1)+2*x*y^4/(y-1)+2*y^2*x^2/(y-1)+2*y^2*x/(y-1)-2*y/(y-1)-2*y*x^3/(y-1)+y^2/(y-1)-2*x*y/(y-1)-2*y*x^2/(y-1);

y^8/(y-1)+2*x^3*y^3/(y-1)+2*x^2*y^4/(y-1)+2*x*y^5/(y-1)+y^6/(y-1)+4*x^3*y^2/(y-1)+2*x^2*y^3/(y-1)+2*x*y^4/(y-1)+2*y^5/(y-1)-2*x^3*y/(y-1)+2*x^2*y^2/(y-1)-4*x^3/(y-1)-2*x^2*y/(y-1)+2*x*y^2/(y-1)-4*x^2/(y-1)-2*x*y/(y-1)+y^2/(y-1)-4*x/(y-1)-2*y/(y-1)-3/(y-1)

ans-targ;

0

 

Download ideas.mw

You might also consider using coeff, if allowed.

I'm not sure why you say "order". It seems more like mapped evaluation-at.

restart;

ST := [`162` = Record(mu = 475, sigma = 41), `70` = Record(mu = 480, sigma = 42),
       `168` = Record(mu = 448, sigma = 103)];

[`162` = Record(mu = 475, sigma = 41), `70` = Record(mu = 480, sigma = 42), `168` = Record(mu = 448, sigma = 103)]

Games:=[[`162`, `70`], [`70`, `168`], [`168`, `162`]];

[[`162`, `70`], [`70`, `168`], [`168`, `162`]]

STO:=[`162` = Record(mu = 475, sigma = 41),`70` = Record(mu = 480, sigma = 42),
       `70` = Record(mu = 480, sigma = 42),`168` = Record(mu = 448, sigma = 103),
     `168` = Record(mu = 448, sigma = 103),`162` = Record(mu = 475, sigma = 41)];

`Non-fatal error while reading data from kernel.`

map(L->map(LL->LL=eval(LL,ST),L)[], Games);

`Non-fatal error while reading data from kernel.`

 

Download ORDERED_ac.mw

Alternatively (but not only),

map(L->L=eval(L,ST),map(op,Games));

(G->G=eval(G,ST))~(op~(Games));

Is this what you mean?

Since your request is to scale the distance between adjacent points, then that works with a simple rescaling of the increment (3rd argument) passed to the seq command.

(You could even scale x and y distances differently from each other. I kept them the same.)

restart

with(plots)

x_min := 1; x_max := 4; y_min := 1; y_max := 3

1

4

1

3

x_range := x_max-x_min; y_range := y_max-y_min

3

2

n[0] := 1

1

Blocks := x_range*y_range*n[0]^2

6

Points1 := [seq(seq([X, Y], X = x_min .. x_max), Y = y_min .. y_max)]; nops(%); (x_max-x_min)*n[0]+1, (y_max-y_min)*n[0]+1; (x_max-x_min)*n[0], (y_max-y_min)*n[0]; (x_max-x_min)*n[0]*((y_max-y_min)*n[0])

[[1, 1], [2, 1], [3, 1], [4, 1], [1, 2], [2, 2], [3, 2], [4, 2], [1, 3], [2, 3], [3, 3], [4, 3]]

12

4, 3

3, 2

6

plot(Points1, style = point, color = red, symbol = solidcircle, symbolsize = 20)

n[1] := 3

3

x_range*y_range*n[1]^2

54

Points2 := [seq(seq([X, Y], X = x_min .. x_max, 1/n[1]), Y = y_min .. y_max, 1/n[1])]; nops(%); (x_max-x_min)*n[1]+1, (y_max-y_min)*n[1]+1; (x_max-x_min)*n[1], (y_max-y_min)*n[1]; (x_max-x_min)*n[1]*((y_max-y_min)*n[1])

70

10, 7

9, 6

54

pointplot(Points2, color = red, symbol = solidcircle, symbolsize = 15)

n[2] := 4

4

x_range*y_range*n[2]^2

96

Points3 := [seq(seq([X, Y], X = x_min .. x_max, 1/n[2]), Y = y_min .. y_max, 1/n[2])]; nops(%); (x_max-x_min)*n[2]+1, (y_max-y_min)*n[2]+1; (x_max-x_min)*n[2], (y_max-y_min)*n[2]; (x_max-x_min)*n[2]*((y_max-y_min)*n[2])

117

13, 9

12, 8

96

pointplot(Points2, color = red, symbol = solidcircle, symbolsize = 15)

 

NULL

Download Grid_Example_ac.mw

If you execute the following then the .mla should be created in a special toolbox location.

You should then be able to execute only the command with(MyMat); in any future session, without having for first augment libname.

(You won't be able to simply test by doing only a restart in that same GUI window/tab. The GUI only scans for such special locations once, and it's already been done for the window/tab in which you execute this code.)

LibFolder:=cat(kernelopts(':-homedir'),"/maple/toolbox/MyMat/lib");
FileTools:-MakeDirectory(LibFolder, ':-recurse');
LibLocation:=cat(LibFolder,"/MyMat.mla");
if FileTools:-Exists(LibLocation) then
  FileTools:-Remove(LibLocation)
end if;
LibraryTools:-Create(LibLocation);
LibraryTools:-Save(MyMat, LibLocation);

If you subsequently ever want that package not to be found then you'd have to either delete (or move aside) that .mla file, or remove its location from libname in the session, or launch with a specifically restricted libname.

The functionality provided by x^n (for x,n integers) is not implemented as merely mul(x, i=1..n).

Your previous comments indicate that you were originally under that mistaken impression.

First 140 141 142 143 144 145 146 Last Page 142 of 336