acer

32405 Reputation

29 Badges

19 years, 350 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

Is this the kind of thing you want to accomplish?

I did not change the way your formulas work, or which kinds of data structure you use. (Eg. it might be easier to create a as an Array, etc.)

[edit: I figured that you are trying to learn Maple coding, and that a direct movement of your original code into a procedure (which is what you asked) would help in your understanding. Some people learn better by focusing on only a few things at once. So I just put it into a reusable procedure, as is.

Look in particular at how the parameters and the locals of the procedure are all just symbols, and not any indexed names as you attempt had tried.]

restart;

Digits := 15;

15

T5Scheme:=proc(x1,y1,a,L)          
local i,k,nk,N,aa,x,y;
   x[1]:=x1; y[1]:=y1;
   N:=numelems(x[1]):         
   for k from 1 to L do              
     nk := 3^(k - 1)*(N - 6) + 6;         
     for i from 3 to nk - 2 do            
       x[k + 1][3*i - 8] := a[-6]*x[k][i + 2] + a[-3]*x[k][i + 1] + a[0]*x[k][i]
                            + a[3]*x[k][i - 1] + a[6]*x[k][i - 2];
       y[k + 1][3*i - 8] := a[-6]*y[k][i + 2] + a[-3]*y[k][i + 1] + a[0]*y[k][i]
                            + a[3]*y[k][i - 1] + a[6]*y[k][i - 2];
       x[k + 1][3*i - 7] := a[-5]*x[k][i + 2] + a[-2]*x[k][i + 1] + a[1]*x[k][i]
                            + a[4]*x[k][i - 1] + a[7]*x[k][i - 2];
       y[k + 1][3*i - 7] := a[-5]*y[k][i + 2] + a[-2]*y[k][i + 1] + a[1]*y[k][i]
                            + a[4]*y[k][i - 1] + a[7]*y[k][i - 2];
       x[k + 1][3*i - 6] := a[-4]*x[k][i + 2] + a[-1]*x[k][i + 1] + a[2]*x[k][i]
                            + a[5]*x[k][i - 1];
       y[k + 1][3*i - 6] := a[-4]*y[k][i + 2] + a[-1]*y[k][i + 1] + a[2]*y[k][i]
                            + a[5]*y[k][i - 1];
     end do;          
   end do;  
   return evalf(convert(x[L+1],list)), evalf(convert(y[L+1],list));
end proc:

## Initial polygon
x[1] := [-1, 1/2, 1, 0, -sqrt(2)/2, -1, 1/2, 1, 0, -sqrt(2)/2, -1, 1/2, 1, 0, -sqrt(2)/2];

[-1, 1/2, 1, 0, -(1/2)*2^(1/2), -1, 1/2, 1, 0, -(1/2)*2^(1/2), -1, 1/2, 1, 0, -(1/2)*2^(1/2)]

y[1] := [0, sqrt(3)/2, 0, -1, -sqrt(2)/2, 0, sqrt(3)/2, 0, -1, -sqrt(2)/2, 0, sqrt(3)/2, 0, -1, -sqrt(2)/2];

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

s2 := [-1, 1/2, 1, 0, -sqrt(2)/2, -1];

[-1, 1/2, 1, 0, -(1/2)*2^(1/2), -1]

t2 := [0, sqrt(3)/2, 0, -1, -sqrt(2)/2, 0];

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

assign(a[-6] = 13/1296, a[-5] = -11/648, a[-4] = -1/16, a[-3] = -107/1296,
       a[-2] = 179/1296, a[-1] = 9/16, a[0] = 137/144, a[1] = 137/144,
       a[2] = 9/16, a[3] = 179/1296, a[4] = -107/1296, a[5] = -1/16,
       a[6] = -11/648, a[7] = 13/1296);

s1,t1 := T5Scheme(x[1],y[1],a,3):

plot([<<s1> | <t1>>, <<s2> | <t2>>], linestyle = [1, 3], color = [black, red]);

Download zz123_ac.mw

It works for me, in the following sense of referencing a file on my local machine.

In the Hyperlink properties I set the Type to URL and I set the Target to,

    file:///home/acer/mapleprimes/collectexample.html

and clicking on that link in my Maple GUI document makes my web-browser open that local file. (Files with extension .html extension are associated with my web-browser application.)

The key thing above was to use the  file:  protocol in the URL.

It's not entirely clear to me what you want to happen by linking to a geogebra file. Something with your web-browser, or do you expect some 3rd party app to launch it, or...?

Look at the output of your assignment of an operator to the name f.

Clearly something has gone wrong in your 2D Input, since the A*sin(omega*t + varphi)*I term is missing.

I deleted and retyped that term,

omega := 5

5

`&varphi;` := (1/3)*Pi

(1/3)*Pi

A := 4

4

"f(t):=A*cos(omega*t+`&varphi;`)+A*I*sin(omega*t+`&varphi;`)"
 

proc (t) options operator, arrow, function_assign; A*cos(omega*t+varphi)+I*A*sin(omega*t+varphi) end proc

f(0)

2+(2*I)*3^(1/2)

A*exp(I*`&varphi;`)

2+(2*I)*3^(1/2)

NULL

Download Mapleprimes_Book_2_Question_3.6_ac.mw

For the purpose of plotting you may not need high accuracy in the numeric integration.

Also, if you forcibly take only the (significant) real part of calls to N, while also "disabling" overflow exceptions under evalhf and the _d01amc quadrature method, then the float evaluation of calls to J appears to speed up.

(Also, check that might simplified revision of L is correct...)

I didn't experiment with using a finite range of integration. (Maybe that could be faster, while still reasonably accurate? I didn't look...)

Perhaps you could tell us how long your original plot took to compute?

restart;

with(plots):

F:=kappa->kappa;

proc (kappa) options operator, arrow; kappa end proc

f:=(alpha,delta)->exp(-abs(F(kappa))^2*(1+delta^2)/2-abs(F(kappa))*alpha)/abs(F(kappa));

proc (alpha, delta) options operator, arrow; exp(-(1/2)*abs(F(kappa))^2*(1+delta^2)-abs(F(kappa))*alpha)/abs(F(kappa)) end proc

L:=(alpha,delta,Lambda) ->
  (lambda^2*exp(-alpha^2/2)/4)*(2*Int(f(alpha,delta),kappa= -infinity..-Lambda));

proc (alpha, delta, Lambda) options operator, arrow; (1/2)*lambda^2*exp(-(1/2)*alpha^2)*(Int(f(alpha, delta), kappa = -infinity .. -Lambda)) end proc

#0.0008209373770*lambda^2
forget(evalf);
CodeTools:-Usage( evalf(L(4,1,0.001)) );

memory used=1.57MiB, alloc change=0 bytes, cpu time=29.00ms, real time=30.00ms, gc time=0ns

0.8209373770e-3*lambda^2

g:=(beta,delta)->exp(-I*kappa*beta-abs(F(kappa))^2*(1+delta^2)/2)/abs(F(kappa));

proc (beta, delta) options operator, arrow; exp(-I*kappa*beta-(1/2)*abs(F(kappa))^2*(1+delta^2))/abs(F(kappa)) end proc

E:=(omega,gg)->exp(I*omega*gg)*(1-erf((gg+I*omega)/sqrt(2)));

proc (omega, gg) options operator, arrow; exp(I*omega*gg)*(1-erf((gg+I*omega)/sqrt(2))) end proc

MyHandler := proc(operator,operands,default_value)
               NumericStatus( overflow = false );
               return 10^10;
             end proc:
ig1template := proc(kappa)
              NumericEventHandler(overflow = MyHandler);
              evalhf(__dummy); end proc:

igdum:='Re'(simplify(exp(-alpha^2/2)/8*(g(beta,delta)*(E(abs(F(kappa)),gg)+E(abs(F(kappa)),-gg))))):
J := subs(__igdum=igdum, proc(alpha,delta,Lambda,beta,gg) local ig;
  ig := subs(__dummy= __igdum, eval(ig1template));
  evalf(lambda^2*abs(Int(ig,-infinity..-Lambda,epsilon=1e-4,method=_d01amc)
                     +Int(ig,Lambda..infinity,epsilon=1e-4,method=_d01amc)));
end proc):

forget(evalf);
CodeTools:-Usage( J(4,1,0.001,8,3) );

memory used=49.92MiB, alloc change=0 bytes, cpu time=319.00ms, real time=319.00ms, gc time=0ns

0.7304272433e-3*lambda^2

N := (beta,alpha) -> (J(alpha,1,0.001,beta,3)-L(alpha,1,0.001))/lambda^2;

proc (beta, alpha) options operator, arrow; (J(alpha, 1, 0.1e-2, beta, 3)-L(alpha, 1, 0.1e-2))/lambda^2 end proc

forget(evalf);
CodeTools:-Usage(contourplot(N, 0..10, 0..10, grid=[25,25]));

memory used=20.12GiB, alloc change=76.00MiB, cpu time=2.50m, real time=2.32m, gc time=19.72s

 

Download Negativity_v1_acc.mw

It might even be possible to improve the timing even further by parallelizing computation over a 2D Array (over beta and alpha values), and then using listcontplot.

@nm You might try it with a different web browser.

A month ago I was unable to submit postings with Chromium, but Firefox worked. That problem went away after a while, as mysteriously as it arrived.

You could use the parametric calling sequence of the plot command to interchange the roles of the axes.

Below, I don't have to create the first plot (in order to transform ie, say). I include it only for illustration of the effect of the second plot, which is easily and directly constructed with a single command.

restart

NULL

y := 3*x^2-4*x+5

3*x^2-4*x+5

plot(y, x, axes = box, labels = ["x", "y"])

plot([y, x, x = -10 .. 10], axes = box, labels = ["y", "x"]);

 

Download plot_graph_ac.mw

Have you tried uploading your .mw file to the Maple Cloud, and accessing it online (visually) from there? (See also here.)

You should even be able to login to that cloud from your Maple version in which you create such .mw files, and upload directly from that. You can upload to a public area, or make a private group for you and your students.

I do not know whether there is an emulator or similar within the ipad that can alloow it to run the (free) MaplePlayer. That's why I suggested the Maple Cloud, since you can access that from your webbrowser. However the quality of reproduction in the Maple Cloud is not always as good as that in the Maple Player.

The filled-regions version of LineChart is AreaChart.

For example,

restart;

with(Statistics):

A := <1, 2, 3, 4, 2, 3, 1>:
B := <1, 5, 1, 0, 2, 1, 1>:
C := <1, 2, 1, 3, 1, 4, 2>:

AreaChart([A, B, C], format = stacked,
          color=[white,pink,orange], transparency=0.3);

plots:-display(
  AreaChart([A, B, C], format = stacked,
          color=[white,pink,orange], transparency=0.3),
  LineChart([A, B, C], format = stacked));

 

Download AreaChart.mw

Transposing a column Vector seems an awkward way to construct a row Vector.

A:=`<|>`(2,7);

Vector[row](2, {(1) = 2, (2) = 7})

Vector[row]([1,A]);

Vector[row](3, {(1) = 1, (2) = 2, (3) = 7})

Vector[row]([A,1]);

Vector[row](3, {(1) = 2, (2) = 7, (3) = 1})

Download rowV_augment.mw

You could also do it in these alternate ways:

`<|>`(1,seq(A));
`<|>`(seq(A),1);

or,

<1|seq(A)>;
<seq(A)|1>;

I didn't bother to figure out which is most efficient if done millions of times.

If you do it as,

  B := A[1..4, 2..2];

instead of your,

  B := A(1..4, 2);

then you get B as a 4x1 Matrix instead of your 4x1 Column Vector.

restart

A := Matrix(4, 4, {(1, 1) = m[1, 1], (1, 2) = m[1, 2], (1, 3) = m[1, 3], (1, 4) = m[1, 4], (2, 1) = m[2, 1], (2, 2) = m[2, 2], (2, 3) = m[2, 3], (2, 4) = m[2, 4], (3, 1) = m[3, 1], (3, 2) = m[3, 2], (3, 3) = m[3, 3], (3, 4) = m[3, 4], (4, 1) = m[4, 1], (4, 2) = m[4, 2], (4, 3) = m[4, 3], (4, 4) = m[4, 4]})

A := Matrix(4, 4, {(1, 1) = 0, (1, 2) = m[1, 2], (1, 3) = m[1, 3], (1, 4) = m[1, 4], (2, 1) = 0, (2, 2) = m[2, 2], (2, 3) = m[2, 3], (2, 4) = m[2, 4], (3, 1) = 0, (3, 2) = m[3, 2], (3, 3) = m[3, 3], (3, 4) = m[3, 4], (4, 1) = 0, (4, 2) = m[4, 2], (4, 3) = m[4, 3], (4, 4) = m[4, 4]})

A(1 .. 4, 1) := Matrix(4, 1):

A

Matrix([[0, m[1, 2], m[1, 3], m[1, 4]], [0, m[2, 2], m[2, 3], m[2, 4]], [0, m[3, 2], m[3, 3], m[3, 4]], [0, m[4, 2], m[4, 3], m[4, 4]]])

B := A[1 .. 4, 2 .. 2]

B := Matrix(4, 1, {(1, 1) = m[1, 2], (2, 1) = m[2, 2], (3, 1) = m[3, 2], (4, 1) = m[4, 2]})

A.B

4

F := Matrix(4, 1, {(1, 1) = 0.4279668887e-7, (2, 1) = -0.3901148183e-7, (3, 1) = 0.3900685346e-7, (4, 1) = 0.})

A.B-F

Matrix(4, 1, {(1, 1) = m[1, 2]*m[2, 2]+m[1, 3]*m[3, 2]+m[1, 4]*m[4, 2]-0.4279668887e-7, (2, 1) = m[2, 2]^2+m[2, 3]*m[3, 2]+m[2, 4]*m[4, 2]+0.3901148183e-7, (3, 1) = m[3, 2]*m[2, 2]+m[3, 3]*m[3, 2]+m[3, 4]*m[4, 2]-0.3900685346e-7, (4, 1) = m[2, 2]*m[4, 2]+m[3, 2]*m[4, 3]+m[4, 2]*m[4, 4]})

NULL

Download soalzarb_ac.mw

Hopefully I have coded "King's" method as you intend. (You can check that.)

The first worksheet's way is simpler, but more expensive. It uses plots:-densityplot. It colors (hue) the points by the iteration count. But it does not illustrate to which root each input point converges. It's not very fast, even at a relatively small maximal-iteration limit.  King_iter.mw

The second worksheet colors by the root to which the input point converges.
King_vs_Newt_basin.mw

restart;


This is not a fast approach, for modest resolution.

It consists of creating a density plot of the iteration count
to achieve a given forward-error.

The color shading is by iteration count.

__FF := proc(z) option inline; z^3-1 end proc:

 

KingCount := subs(g=3, F=__FF, dF=D(__FF),
  proc(x0,y0) local u,i,v,A;
  u[1] := evalf(x0+y0*I);
  for i from 1 to 25 do
    v[i] := u[i] - F(u[i])/dF(u[i]);
    A[i] := F(u[i])+(g-2)*F(v[i]);
    u[i+1] := v[i] - 1/A[i]*(F(u[i])+g*F(v[i]))*F(v[i])/dF(u[i]);
    if abs(F(u[i+1]))<1e-3 then return i; end if;
  end do:
  return i-1;
end proc):

NewtCount := subs(g=3, F=__FF, dF=D(__FF),
  proc(x0,y0) local u,i,v,A;
  u[1] := evalf(x0+y0*I);
  for i from 1 to 25 do
    u[i+1] := u[i] - F(u[i])/dF(u[i]);
    if abs(F(u[i+1]))<1e-3 then return i; end if;
  end do:
  return i-1;
end proc):

 

PK := CodeTools:-Usage(
        plots:-densityplot(KingCount, -2..2, -2..2, grid=[201,201],
                           title="King's method", size=[300,300],
                           colorstyle=HUE, style=surface) ):

memory used=2.05GiB, alloc change=36.00MiB, cpu time=12.19s, real time=12.19s, gc time=1.48s

PN := CodeTools:-Usage(
        plots:-densityplot(NewtCount, -2..2, -2..2, grid=[201,201],
                           title="Newton's method", size=[300,300],
                           colorstyle=HUE, style=surface) ):

memory used=0.74GiB, alloc change=0 bytes, cpu time=4.74s, real time=4.75s, gc time=615.31ms

plots:-display(Array([PK, PN]));

 

 

 

 

 


An alternative way to get a similar image of the iteration count
(using Newton's method) is as follows. This is much faster.
The hue spread is slightly differently utilized.

M := CodeTools:-Usage(
       Fractals:-EscapeTime:-Newton(300, -2 - 2*I, 2 + 2*I, z^3-1,
                                    iterationlimit=50, tolerance=1e-3) ):
plot(-2..2,-2..2,background=M);

memory used=19.73MiB, alloc change=19.62MiB, cpu time=342.00ms, real time=248.00ms, gc time=25.96ms

 

King_iter.mw

And here is the second:

restart:


The following uses the Escape command from the IterativeMaps package.

It is reasonable fast (even with some relatively ineffient post-processing.

I have chosen to post-process the output data so that the coloring is
made according to the root to which the given x+y*I input point converges.

Optionally we can scale the saturation by the iteration count.

ee := z^3 - 1;

z^3-1

## For ee a polynomial we can compute all the roots.
## This is used to specify the colors, below.
rts:=[fsolve(ee,z,complex)]:
evalf[7](%);

[-.5000000-.8660254*I, -.5000000+.8660254*I, 1.]

#(minr,maxr) := (min,max)(Re~(rts)):
#(mini,maxi) := (min,max)(Im~(rts)):
(minr,maxr) := -1, 1;
(mini,maxi) := -1, 1;

-1, 1

-1, 1

# One iteration of Newton's method
dee := diff(ee, z):
Newt1 := eval( z - ee/dee, z=zr+zi*I);

zr+I*zi-(1/3)*((zr+I*zi)^3-1)/(zr+I*zi)^2

# One iteration of King's method
F := unapply(ee,z): dF:=D(F):
v := u - F(u)/dF(u):
A := F(u)+(g-2)*F(v):
uu := v - 1/A*(F(u)+g*F(v))*F(v)/dF(u):
King1 := eval(uu, [g=3, u=zr+zi*I]);

zr+I*zi-(1/3)*((zr+I*zi)^3-1)/(zr+I*zi)^2-(1/3)*((zr+I*zi)^3-4+3*(zr+I*zi-(1/3)*((zr+I*zi)^3-1)/(zr+I*zi)^2)^3)*((zr+I*zi-(1/3)*((zr+I*zi)^3-1)/(zr+I*zi)^2)^3-1)/(((zr+I*zi)^3-2+(zr+I*zi-(1/3)*((zr+I*zi)^3-1)/(zr+I*zi)^2)^3)*(zr+I*zi)^2)

H := proc(Z,N,maxiter,{scalesaturation::truefalse:=false})
  local final,G,h,w,img,temp,temp2,newt,fzi,fzr;
  uses IterativeMaps, ImageTools;
  fzi := evalc( Im( Z ) );
  fzi := convert(simplify(fzi),horner);
  fzr := evalc( Re( subs(zi=zit, Z) ) );
  fzr := convert(simplify(fzr),horner);
  h,w := N, floor(N*(maxr-minr)/(maxi-mini));
  newt := Escape( height=h, width=w,
                       [zi, zr, zit],
                       [fzi, fzr, zi],
                       [y, x, y], evalc(abs(eval(ee,[z=zr+zit*I])))^2<1e-10,
                       2*minr, 2*maxr, 2*mini, 2*maxi,
                       iterations = maxiter,
                       redexpression = zr, greenexpression = zit, blueexpression=i );
  img:=Array(1..h,1..w,1..3,(i,j,k)->1.0,datatype=float[8]);
  temp:=ln~(map[evalhf](max,copy(newt[..,..,3]),1.0));
  temp2:=Threshold(temp,0.0001,low=1);
  img[..,..,3]:=FitIntensity(zip(`*`,temp,temp2));
  ## Done inefficiently, set the hue by position in the list of
  ## all roots
  G:=Array(zip((a,b)->min[index](map[evalhf](abs,rts-~(a+b*I))),
               newt[..,..,1],newt[..,..,2]),datatype=float[8],order=C_order):
  img[..,..,1]:=240*FitIntensity(G):
  if scalesaturation then
    img[..,..,2]:=1-~img[..,..,3]:
  end if;
  final := HSVtoRGB(img):
end proc:

 

Newtimg := H(Newt1,400,200):

# scale down the saturation by the time to converge
NewtimgS := H(Newt1,400,200,scalesaturation):

ImageTools:-Embed([Newtimg,NewtimgS]);

    

Kingimg := H(King1,400,200):

# scale down the saturation by the time to converge
KingimgS := H(King1,400,200,scalesaturation):

ImageTools:-Embed([Kingimg,KingimgS]);

   

King_vs_Newt_basin.mw

The names Column and Row are also exports of the LinearAlgebra package.

So if you load LinearAlgebra after loading DocumentTools:-Layout then you rebind those two names to LinearAlgebra -- but your code was written earlier to utilize them from DocumentTools:-Layout, and so you've broken your code.

There are many ways to fix up this muddle. Too many for me to show them all.

Here's one way, with minor editing of your attempt: loop_Alger_ac.mw

Personally, I'd rather use procedures (and uses), instead of all those loose top-level with calls to begin your Document. But that might be too much of a change (to your preferred methodology) for you to accept.

You could try something like the following.

This would all be entered into the same Execution Group or Document Block.

P:='P':A:=plot():
for i to 12 do

  # Here could be some long calculation,
  # eg. an expensive plot, or other work.
  # You could simulate that by sleeping 0.5sec, etc.
  Threads:-Sleep(0.5);
  P[i] := plot([i], [i^.5], 'style' = ':-point'):

  A := plots:-display(P[i],A);
  # The following always replaces the content of the
  # sole Task region of this Exec.Group or Doc.Block.
  DocumentTools:-Tabulate([A],'exterior'=':-none');
end do:
DocumentTools:-Tabulate([[]]): # clear the Task region
A;

Is this what you're after?

restart;

kernelopts(version);

`Maple 2021.2, X86 64 LINUX, Nov 23 2021, Build ID 1576349`

A:=-epsilon^(3/2)*a2^3/4 - (5*epsilon^(3/2)*a4^3)/3 - (5*epsilon^(3/2)*a5^3)/3 + a3*sqrt(epsilon) - sqrt(epsilon)*a2/3 - (2*sqrt(epsilon)*a4)/3 - (2*sqrt(epsilon)*a5)/3 - (5*epsilon^(3/2)*a2)/36 + (5*epsilon^(3/2)*a4)/9 + (5*epsilon^(3/2)*a5)/9 + epsilon/12 + (4*epsilon^(3/2)*a2*a4*a5)/3 - (7*epsilon^(3/2)*a2*a3*a4)/12 - (7*epsilon^(3/2)*a2*a3*a5)/12 + 5*epsilon^(3/2)*a3*a4*a5 - (3*epsilon^(3/2)*a2^2*a4)/4 - (3*epsilon^(3/2)*a2^2*a5)/4 + (2*epsilon^(3/2)*a2*a4^2)/3 + (2*epsilon^(3/2)*a2*a5^2)/3 - 5*epsilon^(3/2)*a4^2*a5 - 5*epsilon^(3/2)*a4*a5^2 + epsilon^(3/2)*a2^2*a3/12 + (5*epsilon^(3/2)*a3*a4^2)/2 + (5*epsilon^(3/2)*a3*a5^2)/2;

-(1/4)*epsilon^(3/2)*a2^3-(5/3)*epsilon^(3/2)*a4^3-(5/3)*epsilon^(3/2)*a5^3+a3*epsilon^(1/2)-(1/3)*epsilon^(1/2)*a2-(2/3)*epsilon^(1/2)*a4-(2/3)*epsilon^(1/2)*a5-(5/36)*epsilon^(3/2)*a2+(5/9)*epsilon^(3/2)*a4+(5/9)*epsilon^(3/2)*a5+(1/12)*epsilon+(4/3)*epsilon^(3/2)*a2*a4*a5-(7/12)*epsilon^(3/2)*a2*a3*a4-(7/12)*epsilon^(3/2)*a2*a3*a5+5*epsilon^(3/2)*a3*a4*a5-(3/4)*epsilon^(3/2)*a2^2*a4-(3/4)*epsilon^(3/2)*a2^2*a5+(2/3)*epsilon^(3/2)*a2*a4^2+(2/3)*epsilon^(3/2)*a2*a5^2-5*epsilon^(3/2)*a4^2*a5-5*epsilon^(3/2)*a4*a5^2+(1/12)*epsilon^(3/2)*a2^2*a3+(5/2)*epsilon^(3/2)*a3*a4^2+(5/2)*epsilon^(3/2)*a3*a5^2

sort(collect(A,epsilon),order=plex(epsilon),ascending);

(a3-(1/3)*a2-(2/3)*a4-(2/3)*a5)*epsilon^(1/2)+(1/12)*epsilon+(-(1/4)*a2^3-(5/3)*a4^3-(5/3)*a5^3-(5/36)*a2+(5/9)*a4+(5/9)*a5+(4/3)*a2*a4*a5-(7/12)*a2*a3*a4-(7/12)*a2*a3*a5+5*a3*a4*a5-(3/4)*a2^2*a4-(3/4)*a2^2*a5+(2/3)*a2*a4^2+(2/3)*a2*a5^2-5*a4^2*a5-5*a4*a5^2+(1/12)*a2^2*a3+(5/2)*a3*a4^2+(5/2)*a3*a5^2)*epsilon^(3/2)

 

Download sort_epsilon.mw

Also,

coeff(subs(epsilon^(1/2)=__K,A),__K);

      a3-1/3*a2-2/3*a4-2/3*a5

You could do it like this:

cond1 := 2<phi^2:
expr1 := 1.4<phi:

is(expr1) assuming cond1;

          false

`assuming`([is(expr1)], [cond1]);

          false

is(expr1) assuming cond1, phi>0;

           true

`assuming`([is(expr1)], [cond1, phi>0]);

           true

Above I show two calls to assuming with its infix syntax, as well as their alternate prefix (operator) forms which is sometimes more programmatically useful.

The comma-separated sequence of conditions is treated like a logical conjunction (ie. like a call to And). You may also be able to utilize And(...) , Or(...), etc.

First 63 64 65 66 67 68 69 Last Page 65 of 336