acer

32378 Reputation

29 Badges

19 years, 334 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

restart;

m := 1: n := 2:

Zc := m*cos(1/180*x*Pi) + n*cos(1/180*y*Pi);

cos((1/180)*x*Pi)+2*cos((1/180)*y*Pi)

Zs := m*sin(1/180*x*Pi) + n*sin(1/180*y*Pi);

sin((1/180)*x*Pi)+2*sin((1/180)*y*Pi)

Optimization:-Maximize(Zs, {Zc=Zs}, x=0..180, y=0..180);

[2.12132034355964283, [x = HFloat(44.99999999999951), y = HFloat(45.00000000000025)]]

obj := max(extrema(Zs, {Zc=Zs}, {x,y}, 's'));

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

select(u->eval(Zs,u)=obj, s);

{{x = 45, y = 45}}

evalf(obj);

2.121320343

Download opt_examp.mw

Here's one way to get contour plots of the 4th and (Im of) the 7th elements of the expression sequence returned by the doCalc procedure.

A few changes:
  - option remember, to all query for different elements of doCalc's output, while only incurring the cost once for a given grid-resolution.
  - cap lower values (can be very large-negative when first parameter of doCalc is close to 0.0), since otherwise the qualitative features in the -100..0.0 range of output are generally missed by the contours.
  - use plot3d as convernient mechanism to precalculate at desired (shared) grid spacing, where subsequent plot3d/contourplot at the very same grid values will then be very fast.
  - bolster numeric integration, which slows it all down but helps avoid holes in the output data by being more robust.

Naturally, you could invert the order of the legend items.

I didn't bother trying to use the Grid package to parallelize the initial computation of calling doCalc over the shared grid (input) values. I expect that -- with care -- it could be done, instead of these using initial plot3d calls.

I do each (of 4th, and Im of 7th) at first on a coarse grid, and then again on a finer grid.

I used Maple 18.02.  (Later versions allow slightly easier construction of these legend items for a contourplot, or more sophisticated multi-color gradient shading for densityplot.)

restart:

doCalc:= proc(xi, u)  #u is the \bar(H): normalize magnetic field magnitude,
                          # where H = bar(H)*H__a
                 option remember;
                 # Import Packages
                 uses ArrayTools, Student:-Calculus1, LinearAlgebra,
                      ListTools, RootFinding, plots, ListTools:
                 local gamma__1:= .1093,
                       alpha__3:= -0.1104e-2,
                       k__1:= 6*10^(-12),
                       d:= 0.2e-3,
                       theta0:= 0.1e-3,
                       eta__1:= 0.240e-1, chi:= 1.219*10^(-6),
                       alpha:= 1-alpha__3^2/(gamma__1*eta__1),
                       theta_init:= theta0*sin(Pi*z/d),
                       H__a:= Pi*sqrt(k__1/chi)/d,
                       H := u*H__a,     
                       c:=alpha__3*xi*alpha/(eta__1*(4*k__1*q^2/d^2-alpha__3*xi/eta__1 - chi*H^2)),
                       w := chi*H^2*eta__1*alpha/(4*k__1*q^2/d^2-alpha__3*xi/eta__1 - chi*H^2),
                       n:= 20,
                       g, f, b1, b2, qstar, OddAsymptotes, ModifiedOddAsym,
                       qstarTemporary, indexOfqstar2, qstar2, AreThereComplexRoots,
                       soln1, soln2, qcomplex1, qcomplex2, gg, qq, m, pp, j, i,
                       AllAsymptotes, p, Efun, b, aa, F, A, B, Ainv, r, theta_sol, v, Vfun, v_sol,minp,nstar;

                 if not [xi,u]::[numeric,numeric] then
                    return 'procname'(args);
                 end if;

# Assign g for q and plot g, Set q as a complex and Compute the Special Asymptotes

                 g:= q-(1-alpha)*tan(q)- (w*q + c)*tan(q):
                 f:= subs(q = x+I*y, g):
                 b1:= evalc(Re(f)) = 0:
                 b2:= evalc(Im(f)) = 0:
                 qstar:= (fsolve(1/c = 0, q = 0 .. infinity)):
                 OddAsymptotes:= Vector[row]([seq(evalhf(1/2*(2*j + 1)*Pi), j = 0 .. n)]);

# Compute Odd asymptote

                 ModifiedOddAsym:= abs(`-`~(OddAsymptotes, qstar));
                 qstarTemporary:= min(ModifiedOddAsym);
                 indexOfqstar2:= SearchAll(qstarTemporary, ModifiedOddAsym);
                 qstar2:= OddAsymptotes(indexOfqstar2);

# Compute Odd asymptote

                 AreThereComplexRoots:= type(true, 'truefalse');
                 try
                      soln1:= fsolve({b1, b2}, {x = min(qstar2, qstar) .. max(qstar2, qstar), y = 0 .. infinity});
                      soln2:= fsolve({b1, b2}, {x = min(qstar2, qstar) .. max(qstar2, qstar), y = -infinity .. 0});
                      qcomplex1:= subs(soln1, x+I*y);
                      qcomplex2:= subs(soln2, x+I*y);
                 catch:
                       AreThereComplexRoots:= type(FAIL, 'truefalse');
                 end try;

# Compute the rest of the Roots

                 #OddAsymptotes:= Vector[row]([seq(evalhf((1/2)*(2*j+1)*Pi), j = 0 .. n)]);
                 AllAsymptotes:= sort(Vector[row]([OddAsymptotes, qstar]));
                 if   AreThereComplexRoots
                 then
                      gg := [ qcomplex1,
                              qcomplex2,
                              op(Roots(g, q = 0.1e-3 .. AllAsymptotes[n], numeric))
                            ];
                 elif not AreThereComplexRoots
                 then gg:= [ op(Roots(g, q = 0.1e-3 .. AllAsymptotes[n], numeric))
                           ];
                 end if:

# Remove the repeated roots if any & Redefine n

                 qq:= MakeUnique(gg):
                 m:= numelems(qq):

## Compute the `τ_n`time constants

                 for i to m do
                 p[i] := evalf(gamma__1*alpha/(4*k__1*qq[i]^2/d^2 - alpha__3*xi/eta__1- chi*H^2)):
if not p[i]::complex(numeric) then print(p[i], [xi,u], qq[i]); end if;
                 end do:

                Digits := 15;
## Compute θ_n from initial conditions

                for i to m do
                Efun[i] := cos(qq[i]-2*qq[i]*z/d)-cos(qq[i]):
                end do:

## Compute integral coefficients for off-diagonal elements θ_n matrix

                printlevel := 2:
                for i to m do
                    for j from i+1 to m do
                        b[i, j] := evalf(Int(Efun[i]*Efun[j], z = 0 .. d)):
                        if not b[i, j]::complex(numeric) then
                            b[i, j] := evalf[15](Int(Efun[i]*Efun[j], z = 0 .. d,
                                                 digits=15, method=_Dexp, epsilon=1e-12)):
                            if not b[i, j]::complex(numeric) then
                               print("A",[Efun[i]*Efun[j], z = 0 .. d]);
                            end if;
                        end if;
                        b[j, i] := b[i, j]:
                        aa[i, j] := b[i, j]:
                        aa[j, i] := b[j, i]:
                    end do :
                end do:

## Calculate integral coefficients for diagonal elements in theta_n matrix

                for i to m do
                   aa[i, i] := evalf(Int(Efun[i]^2, z = 0 .. d)):
                   if not aa[i, i]::complex(numeric) then
                      aa[i, i] := evalf[15](Int(Efun[i]^2, z = 0 .. d,
                                                digits=15, epsilon=1e-12));
                      if not aa[i, i]::complex(numeric) then
                         print("B",[Efun[i]^2, z = 0 .. d]);
                      end if;
                   end if;
                end do:

## Calculate integrals for RHS vector

               for i to m do
               F[i] := evalf(Int(theta_init*Efun[i], z = 0 .. d));
               if not F[i]::complex(numeric) then
                  F[i] := evalf[15](Int(theta_init*Efun[i], z = 0 .. d,
                                     digits=15, method=_Dexp, epsilon=1e-12));
                  if not F[i]::complex(numeric) then
                     print("C",[theta_init*Efun[i], z = 0 .. d]);
                  end if;
               end if;
               end do:

## Create matrix A and RHS vector B

               A := Matrix([seq([seq(aa[i, j], i = 1 .. m)], j = 1 .. m)]):
               B := Vector([seq(F[i], i = 1 .. m)]):

## Calculate solve A*x=B

              r := LinearSolve(A,B);

## Define Theta(z,t)
             theta_sol := add(r[i]*Efun[i]*exp(-t/p[i]), i = 1 .. m):

## Compute v_n for n times constant

             for i to m do
             v[i] := (-2*k__1*alpha__3*qq[i])*(1/(d^2*eta__1*alpha*gamma__1))+ alpha__3^2*xi/(2*(eta__1)^2*qq[i]*alpha*gamma__1)+xi/(2*eta__1*qq[i]) + alpha__3*chi*H^2/(2*eta__1*qq[i]*gamma__1*alpha):
             end do:

## Compute v(z,t) from initial conditions
             for i to m do
             Vfun[i] := d*sin(qq[i]-2*qq[i]*z/d)+(2*z-d)*sin(qq[i]):
             end do:

## Define v(z,t)
             v_sol := add(v[i]*r[i]*Vfun[i]*exp(-t/p[i]), i = 1 .. m):

##
             minp:=min( seq( Re(p[i]), i=1..m) ):
             member(min(seq( Re(p[i]), i=1..m)),[seq( Re(p[i]), i=1..m)],'nstar'):

## Return all the plots
                 return theta_init, theta_sol, v_sol, minp, eval(p), nstar, p[nstar], g, H, H__a;
                 end proc:

# Run the calculation for supplied value of 'xi'

# Put the returned quantities in a simple list

ans:=CodeTools:-Usage([doCalc(-0.06, 0.001)]):
evalf(ans[9]);
evalf(ans[10]);

memory used=455.22MiB, alloc change=366.71MiB, cpu time=4.48s, real time=4.04s, gc time=650.56ms

0.3484926715e-1

34.84926715

with(plots):

d:= 0.2e-3:

testproc := proc(j, u, k) option remember;
   local calcvals;
   if not [j,u,k]::[numeric,numeric,posint] then
      return 'procname'(args);
   end if;
   calcvals:=doCalc(j,u);
   evalf(calcvals[k]);
end proc:

nconts:=8;

8

(gridji,rngj,rngi):=[3,21],1..3,-2.0..-0.0;
CodeTools:- Usage(plot3d(max(-1e2,testproc(i,j,4)), j=rngj, i=rngi, grid=gridji)):
(minv,maxv):=[min,max](op([1,3],%))[]:
(color1,color2):="Red","Yellow":
conts:=[seq(minv+(i-1)*(maxv-minv)/(nconts+2-1),i=1..nconts+2)][2..nconts+1]:
colorlist:=ColorTools:-Color~(((c1,c2,N)->[seq(c1+(i-1)*(c2-c1)/(N-1),
                                               i=1..N)])([ColorTools:-Color(color2)[]],
                                                         [ColorTools:-Color(color1)[]],
                                                         nops(conts))):
#re-using values computed during plot3d on same grid.
CodeTools:- Usage(contourplot(max(-1e2,testproc(i,j,4)), j=rngj, i=rngi, grid=gridji,
                              contours=conts, thickness=0, coloring=[color1,color2],
                              filledregions, axes=boxed)):
PC:=subsindets(%,specfunc(anything,THICKNESS),u->THICKNESS(0.2)):
display(PC,
        seq(plot(-2.0,1..1,legend=evalf[4](conts[i]),thickness=15,
                 color=colorlist[nops(conts)-i+1],legendstyle=[location=right]),
            i=1..nops(conts)),
        size=[500,400]);

[3, 21], 1 .. 3, -2.0 .. -0.

memory used=28.46GiB, alloc change=128.00MiB, cpu time=5.72m, real time=4.96m, gc time=38.80s
memory used=0.79MiB, alloc change=0 bytes, cpu time=14.00ms, real time=15.00ms, gc time=0ns

(gridji,rngj,rngi):=[3,21],1..3,-2.0..-0.0;
CodeTools:- Usage(plot3d(Im(testproc(i,j,7)), j=rngj, i=rngi, grid=gridji)):
(minv,maxv):=[min,max](op([1,3],%))[]:
(color1,color2):="Red","Yellow":
conts:=[seq(minv+(i-1)*(maxv-minv)/(nconts+2-1),i=1..nconts+2)][2..nconts+1]:
colorlist:=ColorTools:-Color~(((c1,c2,N)->[seq(c1+(i-1)*(c2-c1)/(N-1),
                                               i=1..N)])([ColorTools:-Color(color2)[]],
                                                         [ColorTools:-Color(color1)[]],
                                                         nops(conts))):
#re-using values computed during plot3d on same grid.
CodeTools:- Usage(contourplot(Im(testproc(i,j,7)), j=rngj, i=rngi, grid=gridji,
                              contours=conts, thickness=0, coloring=[color1,color2],
                              filledregions, axes=boxed)):
PC:=subsindets(%,specfunc(anything,THICKNESS),u->THICKNESS(0.2)):
display(PC,
        seq(plot(-2.0,1..1,legend=evalf[4](conts[i]),thickness=15,
                 color=colorlist[nops(conts)-i+1],legendstyle=[location=right]),
            i=1..nops(conts)),
        size=[500,400]);

[3, 21], 1 .. 3, -2.0 .. -0.

memory used=225.37KiB, alloc change=0 bytes, cpu time=6.00ms, real time=7.00ms, gc time=0ns
memory used=0.56MiB, alloc change=0 bytes, cpu time=24.00ms, real time=25.00ms, gc time=0ns

(gridji,rngj,rngi):=[11,31],1..3,-2.0..-0.0;
CodeTools:- Usage(plot3d(max(-1e2,testproc(i,j,4)), j=rngj, i=rngi, grid=gridji)):
(minv,maxv):=[min,max](op([1,3],%))[]:
(color1,color2):="Red","Yellow":
conts:=[seq(minv+(i-1)*(maxv-minv)/(nconts+1-1),i=1..nconts+1)][1..nconts];
colorlist:=ColorTools:-Color~(((c1,c2,N)->[seq(c1+(i-1)*(c2-c1)/(N-1),
                                               i=1..N)])([ColorTools:-Color(color2)[]],
                                                         [ColorTools:-Color(color1)[]],
                                                         nops(conts))):
CodeTools:- Usage(contourplot(max(-1e2,testproc(i,j,4)), j=rngj, i=rngi, grid=gridji,
                              contours=conts, thickness=0, coloring=[color1,color2],
                              filledregions, axes=boxed)):
PC:=subsindets(%,specfunc(anything,THICKNESS),u->THICKNESS(0.2)):
display(PC,
        seq(plot(-2.0,1..1,legend=evalf[4](conts[i]),thickness=15,
                 color=colorlist[nops(conts)-i+1],legendstyle=[location=right]),
            i=1..nops(conts)),
        size=[500,400]);

[11, 31], 1 .. 3, -2.0 .. -0.

memory used=155.38GiB, alloc change=64.00MiB, cpu time=36.43m, real time=31.42m, gc time=7.83m

[-100., -87.84549593, -75.69099186, -63.53648780, -51.38198374, -39.22747968, -27.07297560, -14.91847154]

memory used=1.87MiB, alloc change=0 bytes, cpu time=44.00ms, real time=44.00ms, gc time=0ns

(gridji,rngj,rngi):=[11,31],1..3,-2.0..-0.0;
CodeTools:- Usage(plot3d(Im(testproc(i,j,7)), j=rngj, i=rngi, grid=gridji)):
(minv,maxv):=[min,max](op([1,3],%))[]:
(color1,color2):="Red","Yellow":
conts:=[seq(minv+(i-1)*(maxv-minv)/(nconts+1-1),i=1..nconts+1)][1..nconts];
colorlist:=ColorTools:-Color~(((c1,c2,N)->[seq(c1+(i-1)*(c2-c1)/(N-1),
                                               i=1..N)])([ColorTools:-Color(color2)[]],
                                                         [ColorTools:-Color(color1)[]],
                                                         nops(conts))):
CodeTools:- Usage(contourplot(Im(testproc(i,j,7)), j=rngj, i=rngi, grid=gridji,
                              contours=conts, thickness=0, coloring=[color1,color2],
                              filledregions, axes=boxed)):
PC:=subsindets(%,specfunc(anything,THICKNESS),u->THICKNESS(0.2)):
display(PC,
        seq(plot(-2.0,1..1,legend=evalf[4](conts[i]),thickness=15,
                 color=colorlist[nops(conts)-i+1],legendstyle=[location=right]),
            i=1..nops(conts)),
        size=[500,400]);

[11, 31], 1 .. 3, -2.0 .. -0.

memory used=314.55KiB, alloc change=0 bytes, cpu time=3.00ms, real time=4.00ms, gc time=0ns

[-45.51593608, -39.82644407, -34.13695206, -28.44746006, -22.75796804, -17.06847603, -11.37898402, -5.68949200]

memory used=1.59MiB, alloc change=0 bytes, cpu time=39.00ms, real time=39.00ms, gc time=0ns

 

``

Download Case_3_IjuptilK_300522_ac8.mw

These worked for me in both Maple 2021.2 and 2022.0

restart;

GG:=GroupTheory:-Generators(GroupTheory:-SmallGroup(60,10));

[_m140504181456736, _m140504181470336, _m140504181472384, _m140504181472576]

latex(GG,output=string);

"[(1,2)(3,8)(4,9)(5,10)(6,12)(7,11)(13,23)(14,24)(15,26)(16,25)(17,28)(18,27)(19,30)(20,29)(21,32)(22,31)(33,44)(34,43)(35,46)(36,45)(37,48)(38,47)(39,50)(40,49)(41,52)(42,51)(53,58)(54,57)(55,60)(56,59), (1,3)(2,8)(4,13)(5,14)(6,15)(7,16)(9,23)(10,24)(11,25)(12,26)(17,33)(18,34)(19,35)(20,36)(21,37)(22,38)(27,43)(28,44)(29,45)(30,46)(31,47)(32,48)(39,53)(40,54)(41,55)(42,56)(49,57)(50,58)(51,59)(52,60), (1,4,5)(2,9,10)(3,13,14)(6,17,19)(7,18,20)(8,23,24)(11,27,29)(12,28,30)(15,33,35)(16,34,36)(21,39,41)(22,40,42)(25,43,45)(26,44,46)(31,49,51)(32,50,52)(37,53,55)(38,54,56)(47,57,59)(48,58,60), (1,6,21,22,7)(2,11,31,32,12)(3,15,37,38,16)(4,17,39,40,18)(5,19,41,42,20)(8,25,47,48,26)(9,27,49,50,28)(10,29,51,52,30)(13,33,53,54,34)(14,35,55,56,36)(23,43,57,58,44)(24,45,59,60,46)]"

# I also had no trouble Copy&Pasting this output.
latex(GG);

[
(1,2)(3,8)(4,9)(5,10)(6,12)(7,11)(13,23)(14,24)(15,26)(16,25)(17,28)(18,27)(19,30)(20,29)(21,32)(22,31)(33,44)(34,43)(35,46)(36,45)(37,48)(38,47)(39,50)(40,49)(41,52)(42,51)(53,58)(54,57)(55,60)(56,59)
,
(1,3)(2,8)(4,13)(5,14)(6,15)(7,16)(9,23)(10,24)(11,25)(12,26)(17,33)(18,34)(19,35)(20,36)(21,37)(22,38)(27,43)(28,44)(29,45)(30,46)(31,47)(32,48)(39,53)(40,54)(41,55)(42,56)(49,57)(50,58)(51,59)(52,60)
,
(1,4,5)(2,9,10)(3,13,14)(6,17,19)(7,18,20)(8,23,24)(11,27,29)(12,28,30)(15,33,35)(16,34,36)(21,39,41)(22,40,42)(25,43,45)(26,44,46)(31,49,51)(32,50,52)(37,53,55)(38,54,56)(47,57,59)(48,58,60)
,
(1,6,21,22,7)(2,11,31,32,12)(3,15,37,38,16)(4,17,39,40,18)(5,19,41,42,20)(8,25,47,48,26)(9,27,49,50,28)(10,29,51,52,30)(13,33,53,54,34)(14,35,55,56,36)(23,43,57,58,44)(24,45,59,60,46)
]

Download Perm_ltx.mw

You don't need to nest two calls to collect, in order to obtain your desired result.

restart;

eq_e5_10z := Psi[q0]*Delta*delta = 1/(omega[0])*p*(Delta*Psi[q])
             + Delta*Psi[d]+Psi[d0]*1/(omega[0])*p*(Delta*delta):

eq_e5_10za := Delta*Psi[d] = Psi[q0]*Delta*delta
              - op(1,rhs(eq_e5_10z)) - op(3,rhs(eq_e5_10z)):

eq_e5_10zb := algsubs(p*(Delta*Psi[q])=0,eq_e5_10za):

expr := rhs(eq_e5_10zb);

Psi[q0]*Delta*delta-Psi[d0]*p*Delta*delta/omega[0]

collect(expr,[delta,Delta]);

(Psi[q0]-Psi[d0]*p/omega[0])*Delta*delta

Download collect_d.mw

You're "desired" output contains the name p as standalone multiplicative factor (ie. not as a function call), hence it is clear that in your input you intended multiplication like  p*(Delta*delta)  and  p*(Delta*Psi[q])  and not unevaluated functions calls such as p(Delta*delta)  and  p(Delta*Psi[q]). Hence it seems that you have made a syntax mistake by using function call syntax and mistakenly expected it to denote multiplication.

A simpler example: f(x)  means f applied to x. It doesn't denote f*x.

You could also use eval, or assign on (the assumed) A and B.

restart;

assume(A < B);

S := 2/(B-A);

2/(B-A)

eval(S, [B=10, A=5]);

2/5

assign(B=10, A=5);

S;

2/5

Download assume_assign.mw

This is a frequently asked question.

Your Question's title contains a call to the root command. See the Description in the Help page for the root command for one explanation -- including explanation for this very example. As it mentions, the root command returns the principal root, which may not be a real root.

As alluded to in that page, you might alternatively utilize the surd command:

surd(-8,3);

           -2

You might also get what you want for this example with the RealDomain package (though it is not so robust as some people wish),

restart;
with(RealDomain):

(-8)^(1/3);

           -2

Inside a string (ie. inside a pair of double-quotes) you have to escape inner double-quotes with the backslash character, ie. \"

See also here.

a:=[["{\"test1\",\"test2\"}"],["{test3\",\"test4\"}"]];

[["{"test1","test2"}"], ["{test3","test4"}"]]

lprint(a);

[["{\"test1\",\"test2\"}"], ["{test3\",\"test4\"}"]]

parse(a[1,1]);

{"test1", "test2"}

lprint(%);

{"test1", "test2"}

Download escaped_quotes.mw

Here's an example, done in both 1D and 2D input modes.

I still think you ought to show us how exactly how it's gone wrong for you, with an example in an uploaded attached worksheet.

restart;

kernelopts(version);

`Maple 18.02, X86 64 LINUX, Oct 20 2014, Build ID 991181`

f := proc(x)
  global G;
  local y;
  y := x^2;
  G := y - 2;
  return y;
end proc:

f(3);

9

G;

7

ff := proc (x) local y; global G; y := x^2; G := y-2; return y end proc:

ff(7);

49

G;

47

Download proc_ex.mw

Here is one way, using a legend on the side.

Dynamisches_Modell_Final_filled_conts.mw

Alternatively you could use a seq of implicitplots to get the contours as (ncely rendered) dotted lines, and a corresponding seq of 0-length thick curves and textplots for a faked "legend" inside the main plotting region. It's more effort than I have right now, sorry.

The general approach is to pass implicitplot the relevant inequality and add the filledregions options. However, with all other options at defaults there is not numeric difficulties and ensuing artefacts in the result.

One way around that is to (keep the default Digits=10 working precision and) start the E range from a small poitive number to avoid numeric issues.

plots:-implicitplot(0 <= Vth/E - Vps/E, E = 0.1e-8 .. 1000000, T = 0 .. 15,
                                filledregions, rangeasview);

Dynamisches_Modell_Final_ac1.mw

Another (slower) way is to increase working precision.

Digits:=16:
plots:-implicitplot(0 <= Vth/E - Vps/E, E = 0 .. 1000000, T = 0 .. 15,
                            filledregions, rangeasview);

Dynamisches_Modell_Final_ac.mw

At default Digits=10 the call evalf(Zeta(3)) is computed by the internal procedure `evalhf/Zeta`.

restart; evalf(Zeta(3));

          1.202056903

restart; evalf(evalhf(`evalhf/Zeta`(3)));

          1.202056903

You can see how that approximation is computed by examing the source code:

   showstat(`evalhf/Zeta`);

More generally you can also examine (ie. showstat) additional procedures, eg.
   `evalf/Zeta/real`
   `evalf/Zeta/complex`
and so on.

You can get overwriting in a Task-region that gets embedded right below where output (of an Execution Group or Document Block normally appears).

The DocumentTools:-Tabulate command overwrites that region. This can be done within a loop. This provides a mechanism to show how the loops are progressing, without taking up a large amount of vertically-scrolled space.

You can adjust, to get various formatting effects.

For example, using Threads:-Sleep to get a slight pause (or else the example runs too fast to see the effects...):

for i from 1 to 15 do

res1:='res1';
for j from 1 to 100 do

x:= 5*i*j:
if (j mod 10) =0 then
  res1[j] := j/100;
  DocumentTools:-Tabulate(widthmode=pixels,width=400,
                          <sprintf("i=%a, j=%a",i,j),
                          eval('Typesetting:-Typeset'(convert(res1,list)))>):
  Threads:-Sleep(0.05); # sleep 0.05 seconds
fi;

od:
## clear the printing here ##
if (i mod 5) =0 then
  DocumentTools:-Tabulate(widthmode=pixels,width=200,
                          exterior=all, interior=none,
                          ["outer",sprintf("i=%a",i)]):
  Threads:-Sleep(1.0); # sleep 1.0 seconds
fi;

od:
DocumentTools:-Tabulate(widthmode=pixels,width=200,
                        exterior=all, interior=none,
                        [["finished"]]): # or [[]] to show blank

 

Download Tab_loop.mw

I don't really understand what you intend by differentiating w.r.t a name appearing in the subscript.

As far as getting nicely typeset derivatives, I suspect that in Maple Flow you could try the Expression palette (on left panel), or command-completion templates.

In order to get the command-completion, one can press the Esc key after first typing the start of the word, eg. after typing diff .

You should use add for adding up this particular finite number of terms, and not sum, since it's not an attempt to perform symbolic summation.

restart;

f := (x,y)->1/(2+x*y^2);

proc (x, y) options operator, arrow; 1/(2+x*y^2) end proc

P := (x,y,x0,y0,N) -> sum(1/factorial(n)*sum(binomial(n,k)
                          *D[1$(n-k), 2$k](f)(x0,y0)
                          *(x-x0)^(n-k)*(y-y0)^k, k=0..n),
                          n=0..N):

add(D[1$(3-k),2$k](f)(0,0), k=0..3);

-1/2

Calling the sum command follows usual evaluation rules, in which the arguments are evaluated up front. Here's what the sum command receives for your example:

D[1$(3-k),2$k](f)(0,0);

pochhammer(-3+k, 3-k)*(Sum(0, _k1 = 0 .. k))


In contrast, the add command has special evaluation rules, in which case full evaluation of the first argument is delayed until the index attains actual numeric values.

You could also delay the first argument to sum using a (double, for this example) pair of unevaluation quotes. That's fragile.

sum(''D''[1$(3-k),2$k](f)(0,0), k=0..3);

-1/2

Try either using it like,

   plots:-display (P1,P2);

or, alternatively, first loading the plots package, ie,

   with(plots):
   display(P1,P2);

Don't put a space between the word display and the opening bracket (.

First 67 68 69 70 71 72 73 Last Page 69 of 336