acer

32303 Reputation

29 Badges

19 years, 309 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

restart;

kernelopts(version);

`Maple 2023.2, X86 64 LINUX, Nov 24 2023, Build ID 1762575`

kernelopts(ASSERT=true):
kernelopts(assertlevel=2):

foo:= overload(  
        [
        proc(A::integer,B::integer)::integer; option overload;
            B/5;
        end proc,

        proc(A::integer)::integer; option overload;
            A/3;   
        end proc      
       ]):

foo(1);

Error, (in foo) assertion failed, foo expects its return value to be of type integer, but computed 1/3

foo(12);

4

foo(1,2);

Error, (in foo) assertion failed, foo expects its return value to be of type integer, but computed 2/5

foo(1,10);

2

Download overload_return_type.mw

notes:
1) That syntax is consistent with that for non-overloaded procedures, ie. the return-type comes right after each proc's parameter specs.
2) The individual procs get separate return-types, because... they should. They could be altogether different.
3) I changed the order of the two procs appearance in the overload definition. (Otherwise I don't fully understand how/when you intended to be able to get to the second proc.)

In your worksheet you strip off the method=_d01ajc when you call,
    unapply(int(op(1 .. 2, original_Int)), y)
because you only use operands 1..2. With an expression-form integrand, and without that method, the hybrid numeric-symbolic analysis of the integrand makes it slow.

If that method were retained then you could get good speed throughout, using the original expression Int. For example,

orig := Int(22.89730452*exp(-3.373250126*10^6*x^2)*sqrt(2)*(erf(1298.701299*sqrt(2)*(sqrt(2.500000000*10^(-7) - x^2) + 1/40*y - 0.001540000000)) + erf(1298.701299*sqrt(2)*(sqrt(2.500000000*10^(-7) - x^2) - 1/40*y + 0.001540000000))), x = -0.0005000000000 .. 0.0005000000000, method = _d01ajc):

CodeTools:-Usage(plot(orig, y = 0 .. 0.25, size = [400, 200]))

memory used=8.30MiB, alloc change=0 bytes, cpu time=151.00ms, real time=152.00ms, gc time=0ns

CodeTools:-Usage(Optimization:-Maximize(orig, y = 0 .. 0.15, variables = [y]))

memory used=0.56MiB, alloc change=0 bytes, cpu time=12.00ms, real time=12.00ms, gc time=0ns

[HFloat(0.0356073228322899), [y = HFloat(0.06159999993348495)]]

CodeTools:-Usage(fsolve(orig - 0.005, y = 0 .. 0.15, maxsols = 2))

memory used=20.87MiB, alloc change=0 bytes, cpu time=334.00ms, real time=334.00ms, gc time=0ns

Download slow_maximize_and_fsolve_nostrip.mw

Comparably good speed of the numeric integration can also be achieved by making the integrand an operator. Then the _d01ajc method is not necessary.

This new, constructed F can also be used to achieve the plot quickly.

When called, this procedure F substitutes its argument Y for y in the integrand, then uses unapply to get a fresh operator form for that.

restart;

ig := Int(22.89730452*exp(-3.373250126*10^6*x^2)*sqrt(2)*(erf(1298.701299*sqrt(2)*(sqrt(2.500000000*10^(-7) - x^2) + 1/40*y - 0.001540000000)) + erf(1298.701299*sqrt(2)*(sqrt(2.500000000*10^(-7) - x^2) - 1/40*y + 0.001540000000))), x = -0.0005 .. 0.0005):

F := Y->evalf(Int(unapply(eval(op(1,ig),y=Y),x),
                  rhs(op(2,ig)))):

CodeTools:-Usage(plot(F, 0 .. 0.25, size = [400, 300]));

memory used=16.97MiB, alloc change=35.01MiB, cpu time=231.00ms, real time=232.00ms, gc time=0ns

CodeTools:-Usage(Optimization:-Maximize(F, 0 .. 0.15));

memory used=1.10MiB, alloc change=0 bytes, cpu time=17.00ms, real time=17.00ms, gc time=0ns

[0.356073228322897e-1, Vector(1, {(1) = 0.615999999351895e-1})]

CodeTools:-Usage(fsolve(F - 0.005, 0 .. 0.15, maxsols = 2))

memory used=75.71MiB, alloc change=38.00MiB, cpu time=665.00ms, real time=581.00ms, gc time=172.77ms

0.2456248637e-1, 0.9863751363e-1

Download slow_maximize_and_fsolve_acc.mw

See also point 1) in this Reply to another recent Question by you. There's more than one way to get a similar effect.
A) What I did in the earlier Question thread: on the fly substitute (using subs) into an Int call that already contains a template operator.
B) What I did here: on the fly make Int calls with fresh operators from (using unapply on) each substitution into the integrand expression.
By "on the fly" I mean at each distinct evaluation by Maximize, fsolve, or plot.

[edit] I actually don't know yet why fsolve fails (quickly) in the following variant. Some sort of accuracy&convergence thing, I suspect. It would work -- and faster that the OP's original but not as fast as those other approaches above -- if method=_Dexp were used instead.
slow_maximize_and_fsolve_hmm.mw

You could add the following to the command which launches the Maple GUI.

   -standalone

On Linux I simply use that option when I launch the Maple GUI from the commandline terminal.

On Windows I add it to the command property in the desktop icon.

The effect is that I can launch wholly separate instances of the GUI. Each could have its own debugger popup, or its own Help window, or even its own instance of opening the same worksheet.

Each also runs in its own JVM instance, and a GUI crash in either does not affect the other.

Note that such distinct GUI sessions aren't able to share a single Maple kernel with each other, although multiple worksheets opened in the same GUI instance can still share a kernel.

This change to the desktop icon is the first thing I do after installing Maple in my Windows 7. I suppose you could also have another icon, without the change, in case you wanted to be able to share a Maple kernel instance between worksheets by merely dropping the file onto the same desktop icon.

There are several possible variants on an approach using an inert operator for the special construction, a corresponding custom print-extension for it (to get the pretty-printing effect on output), and the simple value command as an easy mechanism to undo it.

For example,

N := x->x: `print/N`:=Typesetting:-Typeset:

 

mass := %N(1) * Unit(m);

%N(1)*Units:-Unit(m)

value(mass);

Units:-Unit(m)

 

mass2 := %N(1) * Unit(cm);

%N(1)*Units:-Unit(cm)

mass + mass2;

%N(1)*Units:-Unit(m)+%N(1)*Units:-Unit(cm)

simplify(value(%));

(101/100)*Units:-Unit(m)

Download unit_fun.mw

To a certain extent you can enlarge a Slider's length, and accompany that by forced larger dimensions for the exploration. Personally, I find that it's easier to utilize the Slider's (albeit, limited) precision if it is longer.

For example, with adjustment to borders only for understanding,

Explore( plot(a*x),
         width=700, tablealignment=left,
         tableborders=false, showhiddenborders=always,
         parameters=[ [a=1.0..2.0, width=500]] );

There's a limit to this, however, since there's some internal Explore code that automatically gives a portion of the overall width to the parameter/value labels on each side. Getting a much wider Slider might currently necessitate specifying the whole exploration to be wider than the GUI, or fiddling with Table properties manually, post-insertion. (That functionality might be improved in the future, perhaps by smarter weighting.)

But IIRC the limit of granularity of sampling of a Slider with a floating-point range is GUI side, and cannot be adjusted arbitrarily -- though minor tickmarks can give a little relief. The same goes for the numeric formatting of the labelling on the Slider itself.

The displayed value beside the Slider (in a separate Label) might also be improved, if Explore were to allow specified numeric formatting for such, within the parameters option. That might be quite useful.

ps. By manual adjustment I mean manually using the mouse to turn on all interior Table's borders, adjust Properties, and adjust Slider length property. This sounds unpleasant, since I don't know if all weighting aspects could be so altered adequately.

pps. Really fine granularity might be accomplished by scaling, eg. replace the instance of the parameter in the plotting expression by constant+newname, etc. You've probably already considerd that kludge. You could even "split" a parameter into a sum , each providing a carefully rounded value on two distinct scales (ie. 2-3 base 10 digits places, each).

restart;

kernelopts(version);

`Maple 2023.1, X86 64 LINUX, Jul 07 2023, Build ID 1723669`

y := -cos(sqrt(x))*x^3/(-x^2 + 24*cos(sqrt(x)) + 12*x - 24);

-cos(x^(1/2))*x^3/(-x^2+24*cos(x^(1/2))+12*x-24)

plot(y, x=0..1, adaptive=true);

Download cannot_plot_ac.mw

I'll file a bug report.

Your phi[1] and phi[2] might agree at x=0, but not for other mirrored x values. And their respective max and min might also not agree everywhere else, over the given ranges.

So when you pass just contours=25 then contourplot will automatically choose a different selection of 25 contour values for phi[1] than it does for phi[2]. And if the choice of contour values are not the same for both plots then there's no match-up along x=0, ie. the y-axis.

But if instead you specifiy the particular contour values -- the same for both phi[1] and phi[2] -- then the matching at x=0 can be made apparent.

By the way, in Maple 2023 there's no need for using that contplot procedure, since its only purpose is to allow a legend that mimics a color-bar. In Maple 2023 that color-bar is available (by default) from the actual plots:-contourplot command. I haven't changed that aspect.

Below I use Maple 2023, and in older versions you'd need to remove the colorbar option.

restart

Digits := 50

50

beta := 1; lambda := .9; b := 4; a := 6; alpha := 0; y[1] := 1.3; y[2] := 1.3; x[1] := -1.5; x[2] := 1.5; Q[1] := 40; Q[2] := 35; T[1] := 5; T[2] := 4.5

v := n*Pi/b

Delta := exp(2*v*a)*(alpha*v+beta)*(1+lambda)-(1-lambda)*(alpha*v-beta)

omega := Pi/(2*b)

P[1] := (-(1+lambda)*exp(-v*abs(x-xi))-(1-lambda)*exp(v*(x+xi)))*exp(2*v*a)-(1+lambda)*exp(-v*(x+xi))-(1-lambda)*exp(v*abs(x-xi))

P[2] := (-(1+lambda)*exp(-v*abs(x-xi))-(1-lambda)*exp(v*(x+xi)))*exp(2*v*a)+((1+lambda)*exp(-v*(x+xi))+(1-lambda)*exp(v*abs(x-xi)))

P[3] := P[1]*(-alpha^2*v-alpha*beta+alpha*v)+beta*P[2]

G[11] := (sum((alpha*P[1]*(1-lambda)*(alpha*v-beta)*exp(-2*v*a)+(1+lambda)*P[3])*(cos(v*(y-eta))-cos(v*(y+eta)))/(v*(exp(2*v*a)*(alpha*v+beta)*(1+lambda)-(1-lambda)*(alpha*v-beta))), n = 1 .. 40))/(2*b*(1+lambda))-(2*(1+lambda)*alpha*b/Pi*.25)*ln((1+2*exp(-omega*abs(x-xi))*cos(omega*(y-eta))+exp(-2*omega*abs(x-xi)))*(1-2*exp(-omega*abs(x-xi))*cos(omega*(y+eta))+exp(-2*omega*abs(x-xi)))*(1+2*exp(-omega*(2*a+x+xi))*cos(omega*(y-eta))+exp(-2*omega*(2*a+x+xi)))*(1-2*exp(-omega*(2*a+x+xi))*cos(omega*(y+eta))+exp(-2*omega*(2*a+x+xi)))/((1-2*exp(-omega*abs(x-xi))*cos(omega*(y-eta))+exp(-2*omega*abs(x-xi)))*(1+2*exp(-omega*abs(x-xi))*cos(omega*(y+eta))+exp(-2*omega*abs(x-xi)))*(1-2*exp(-omega*(2*a+x+xi))*cos(omega*(y-eta))+exp(-2*omega*(2*a+x+xi)))*(1+2*exp(-omega*(2*a+x+xi))*cos(omega*(y+eta))+exp(-2*omega*(2*a+x+xi)))))/(2*b*(1+lambda))-(2*(1-lambda)*alpha*b/Pi*.25)*ln((1+2*exp(omega*(x+xi))*cos(omega*(y-eta))+exp(2*omega*(x+xi)))*(1-2*exp(omega*(x+xi))*cos(omega*(y+eta))+exp(2*omega*(x+xi)))*(1+2*exp(-omega*(2*a-abs(x-xi)))*cos(omega*(y-eta))+exp(-2*omega*(2*a-abs(x-xi))))*(1-2*exp(-omega*(2*a-abs(x-xi)))*cos(omega*(y+eta))+exp(-2*omega*(2*a-abs(x-xi))))/((1-2*exp(omega*(x+xi))*cos(omega*(y-eta))+exp(2*omega*(x+xi)))*(1+2*exp(omega*(x+xi))*cos(omega*(y+eta))+exp(2*omega*(x+xi)))*(1-2*exp(-omega*(2*a-abs(x-xi)))*cos(omega*(y-eta))+exp(-2*omega*(2*a-abs(x-xi))))*(1+2*exp(-omega*(2*a-abs(x-xi)))*cos(omega*(y+eta))+exp(-2*omega*(2*a-abs(x-xi))))))/(2*b*(1+lambda))

g[12] := lambda*(-(alpha*v+beta)*exp(v*(2*a+x))-(alpha*v-beta)*exp(-v*x))*exp(-v*xi)/(v*Delta)

G[12] := (sum(g[12]*(cos(v*(y-eta))-cos(v*(y+eta))), n = 1 .. 40))/b

phi[1] := int(int(G[11]*Q[1]*Dirac(xi-x[1])*Dirac(eta-y[1]), xi = -a .. 0), eta = 0 .. b)+int(int(G[12]*Q[2]*Dirac(xi-x[2])*Dirac(eta-y[2]), xi = 0 .. infinity), eta = 0 .. b)

N[1] := (-(1+lambda)*exp(-v*abs(x-xi))-(-1+lambda)*exp(-v*(x+xi)))*exp(2*v*a)-(1+lambda)*exp(-v*(x+xi))-(-1+lambda)*exp(-v*abs(x-xi))

N[2] := (-(1+lambda)*exp(-v*abs(x-xi))-(-1+lambda)*exp(-v*(x+xi)))*exp(2*v*a)+((1+lambda)*exp(-v*(x+xi))+(-1+lambda)*exp(-v*abs(x-xi)))

N[3] := N[1]*(-alpha^2*v-alpha*beta+alpha*v)+beta*N[2]

G[22] := (sum((alpha*N[1]*(1-lambda)*(alpha*v-beta)*exp(-2*v*a)+(1+lambda)*N[3])*(cos(v*(y-eta))-cos(v*(y+eta)))/(v*(exp(2*v*a)*(alpha*v+beta)*(1+lambda)-(1-lambda)*(alpha*v-beta))), n = 1 .. 40))/(2*b*(1+lambda))-(2*(1+lambda)*alpha*b/Pi*.25)*ln((1+2*exp(-omega*abs(x-xi))*cos(omega*(y-eta))+exp(-2*omega*abs(x-xi)))*(1-2*exp(-omega*abs(x-xi))*cos(omega*(y+eta))+exp(-2*omega*abs(x-xi)))*(1+2*exp(-omega*(2*a+x+xi))*cos(omega*(y-eta))+exp(-2*omega*(2*a+x+xi)))*(1-2*exp(-omega*(2*a+x+xi))*cos(omega*(y+eta))+exp(-2*omega*(2*a+x+xi)))/((1-2*exp(-omega*abs(x-xi))*cos(omega*(y-eta))+exp(-2*omega*abs(x-xi)))*(1+2*exp(-omega*abs(x-xi))*cos(omega*(y+eta))+exp(-2*omega*abs(x-xi)))*(1-2*exp(-omega*(2*a+x+xi))*cos(omega*(y-eta))+exp(-2*omega*(2*a+x+xi)))*(1+2*exp(-omega*(2*a+x+xi))*cos(omega*(y+eta))+exp(-2*omega*(2*a+x+xi)))))/(2*b*(1+lambda))-(2*(-1+lambda)*alpha*b/Pi*.25)*ln((1+2*exp(-omega*(x+xi))*cos(omega*(y-eta))+exp(-2*omega*(x+xi)))*(1-2*exp(-omega*(x+xi))*cos(omega*(y+eta))+exp(-2*omega*(x+xi)))*(1+2*exp(-omega*(2*a+abs(x-xi)))*cos(omega*(y-eta))+exp(-2*omega*(2*a+abs(x-xi))))*(1-2*exp(-omega*(2*a+abs(x-xi)))*cos(omega*(y+eta))+exp(-2*omega*(2*a+abs(x-xi))))/((1-2*exp(-omega*(x+xi))*cos(omega*(y-eta))+exp(-2*omega*(x+xi)))*(1+2*exp(-omega*(x+xi))*cos(omega*(y+eta))+exp(-2*omega*(x+xi)))*(1-2*exp(-omega*(2*a+abs(x-xi)))*cos(omega*(y-eta))+exp(-2*omega*(2*a+abs(x-xi))))*(1+2*exp(-omega*(2*a+abs(x-xi)))*cos(omega*(y+eta))+exp(-2*omega*(2*a+abs(x-xi))))))/(2*b*(1+lambda))

g[21] := (-(alpha*v+beta)*exp(v*(2*a+xi))-(alpha*v-beta)*exp(-v*xi))*exp(-v*x)/(v*Delta)

G[21] := (sum(g[21]*(cos(v*(y-eta))-cos(v*(y+eta))), n = 1 .. 40))/b

phi[2] := int(int(G[21]*Q[1]*Dirac(xi-x[1])*Dirac(eta-y[1]), xi = -a .. 0), eta = 0 .. b)+int(int(G[22]*Q[2]*Dirac(xi-x[2])*Dirac(eta-y[2]), xi = 0 .. infinity), eta = 0 .. b)

f1 := subs(y = 1.2, x = 0, phi[1])

f2 := subs(y = 1.2, x = 0, phi[2])

evalf(f1-f2)

-0.6e-48

contplot := proc (ee, rng1, rng2) local clabels, clegend, i, ncrvs, newP, otherdat, others, tcrvs, tempP; clegend, others := selectremove(type, [_rest], identical(:-legend) = anything); clabels, others := selectremove(type, others, identical(:-contourlabels) = anything); if 0 < nops(clegend) then tempP := :-plots:-contourplot(ee, rng1, rng2, others[], ':-contourlabels' = rhs(clegend[-1])); tempP := subsindets(tempP, 'specfunc(:-_HOVERCONTENT)', proc (u) options operator, arrow; `if`(has(u, "null"), NULL, (':-LEGEND')(op(u))) end proc); if 0 < nops(clabels) then newP := plots:-contourplot(ee, rng1, rng2, others[], ':-contourlabels' = rhs(clabels[-1])); tcrvs := select(type, [op(tempP)], 'specfunc(CURVES)'); ncrvs, otherdat := selectremove(type, [op(newP)], 'specfunc(CURVES)'); return (':-PLOT')(seq((':-CURVES')(op(ncrvs[i]), op(indets(tcrvs[i], 'specfunc(:-LEGEND)'))), i = 1 .. nops(ncrvs)), op(otherdat)) else return tempP end if elif 0 < nops(clabels) then return plots:-contourplot(ee, rng1, rng2, others[], ':-contourlabels' = rhs(clabels[-1])) else return plots:-contourplot(ee, rng1, rng2, others[]) end if end proc

eval(phi[1], [x = -2, y = 1.5]); eval(phi[2], [x = 2, y = 1.5])

-9.8412713172730248458596904204018436823701850499209

-8.7773504289855657587933228948787812084275286238075

plots:-display(contplot(phi[1], x = -5 .. 0, y = 0 .. b, coloring = ["Red", "Blue"], contours = [seq(-25 .. -1)], legend = false, contourlabels = true, colorbar = false, thickness = 0, filledregions = false), contplot(phi[2], x = 0 .. 5, y = 0 .. b, coloring = ["Green", "Magenta"], contours = [seq(-25 .. -1)], legend = false, contourlabels = true, colorbar = false, thickness = 0, filledregions = false), size = [400, 400], view = [-5 .. 6, 0 .. b])

 

Download h-x_nemodar-e_ac.mw

restart

kernelopts(version)

`Maple 2023.1, X86 64 LINUX, Jul 07 2023, Build ID 1723669`

NULLX := Vector(3, {(1) = 3*Unit('m'), (2) = 9*Unit('m'), (3) = 25*Unit('m')})

Y := Vector(3, {(1) = 1, (2) = .56, (3) = .12})

NULL


With the following calling sequence, pointplot shows the units
as axis labels without my having to supply the useunits option.

plots:-pointplot(`<|>`(X, Y), symbolsize = 15, symbol = solidcircle)

plots:-pointplot(`<|>`(X, Y), style = line, color = "Niagara 1")

NULL

Download PlotUnit_ac.mw

I've tried to adjust the methodology to get better performance from the numerical integration computations of eq7 & eq8 after the substitutions.

Getting that fast (for individual values of alpha and beta) is, naturally, key to figuring out efficiently from purely numerical computations where the inequality might hold.

I'm pretty sure that the following adjustments to calling evalf/Int, etc, gets a faster computation than merely removing the unapply, as CW suggested in his Answer.

More importantly, your original pointplot approach would compute something like 26*900 times, for alpha and beta sampled in a evenly spaced grid. A fine grid sampling is often an unnecessarily expensive way, and gets only a coarse visual of an inequality.

Let me know if this below is helpful. (You were originally sampling 10^(-9) to 1=10^0, etc. I've changed the ranges a bit.)

restart;

eq1:=diff(a(t),t)/a(t)=alpha*t-beta*t^3:

eq2:=dsolve({eq1,a(0)=1}):

eq3:=diff(lambda(t),t)=rhs(eq2):

eq4:=dsolve({eq3,lambda(0)=0}):

sm:=exp(-lambda^2/(2*tau^2))*1/(sqrt(2*Pi)*tau):

eq5:=sm*diff(rhs(eq1),t)/rhs(eq2):

eq6:=combine(eval(eq5,[lambda=rhs(eq4),tau=eval(rhs(eq4),t=1)])):

eq7:=subs(Int(exp(-_z1^2*(_z1^2*beta - 2*alpha)/4), _z1 = 0 .. 1)=L,eq6):
eq7 := subsindets(eq6, specfunc(Int),
                  u->op(0,u)(op(u), digits=15, epsilon=1e-11, method=_d01ajc));

(1/2)*2^(1/2)*(-3*beta*t^2+alpha)*exp(-(1/2)*(Int(exp(-(1/4)*_z1^2*(_z1^2*beta-2*alpha)), _z1 = 0 .. t, digits = 15, epsilon = 0.1e-10, method = _d01ajc))^2/(Int(exp(-(1/4)*_z1^2*(_z1^2*beta-2*alpha)), _z1 = 0 .. 1, digits = 15, epsilon = 0.1e-10, method = _d01ajc))^2+(1/4)*t^2*(beta*t^2-2*alpha))/(Pi^(1/2)*(Int(exp(-(1/4)*_z1^2*(_z1^2*beta-2*alpha)), _z1 = 0 .. 1, digits = 15, epsilon = 0.1e-10, method = _d01ajc)))

GG:=Int(exp(-_z1^2*(_z1^2*beta - 2*alpha)/4), _z1 = 0 .. 1, digits=15, epsilon=1e-11, method=_d01ajc);

Int(exp(-(1/4)*_z1^2*(_z1^2*beta-2*alpha)), _z1 = 0 .. 1, digits = 15, epsilon = 0.1e-10, method = _d01ajc)

eq8:=1/(8*L^2);

(1/8)/L^2

HH := proc(a,b) option remember; local res;
  if not [a,b]::list(numeric) then return 'procname'(args); end if;
  res := evalf(eval(Int(eval(eval(eq7,L=GG),[:-alpha=a,:-beta=b]), t=-25..25,
                        epsilon=1e-5, method=_Dexp))
               - eval(GG,[:-alpha=a,:-beta=b]));
  if res::numeric then evalf[5](res); else undefined; end if;
end proc:

 

CodeTools:-Usage(
  plots:-inequal(HH(alpha,beta)>=0
         , alpha=-1.5..0, beta=-2..0
         , optionsimplicit=[gridrefine=1]
         )
);

memory used=14.96GiB, alloc change=148.53MiB, cpu time=3.44m, real time=3.09m, gc time=29.88s

 

Download NestedError_accc.mw

ps. Your original approach was also flawed in how it generated the pointplot data pairs. The table M was converted to a list, but the i values (indices) were being dropped, that way. If the inequality didn't hold (or the integration failed) then there'd be no value stored in M. So not all i values are even implicit in the M data. The generation of the pointplot pairs was thus all muddled up, using the wrong i values for the stored j values in M.

Purely numeric integration can be quicker, here. (The later plot done in 22ms.)

Is this result as expected?

Gaussian_integration_ac.mw

Is this the kind of thing that you're trying to accomplish?

restart;

P := expand((cosh(k*eta) + alpha*m*sinh(k*eta)/eta)^3);

cosh(k*eta)^3+3*cosh(k*eta)^2*alpha*m*sinh(k*eta)/eta+3*cosh(k*eta)*alpha^2*m^2*sinh(k*eta)^2/eta^2+alpha^3*m^3*sinh(k*eta)^3/eta^3

P := convert(P, exp);

((1/2)*exp(k*eta)+(1/2)*exp(-k*eta))^3+3*((1/2)*exp(k*eta)+(1/2)*exp(-k*eta))^2*alpha*m*((1/2)*exp(k*eta)-(1/2)*exp(-k*eta))/eta+3*((1/2)*exp(k*eta)+(1/2)*exp(-k*eta))*alpha^2*m^2*((1/2)*exp(k*eta)-(1/2)*exp(-k*eta))^2/eta^2+alpha^3*m^3*((1/2)*exp(k*eta)-(1/2)*exp(-k*eta))^3/eta^3

frontend(coeff,[P, eta, 0]);

((1/2)*exp(k*eta)+(1/2)*exp(-k*eta))^3

frontend(coeff,[P, eta, -1]);

3*((1/2)*exp(k*eta)+(1/2)*exp(-k*eta))^2*alpha*m*((1/2)*exp(k*eta)-(1/2)*exp(-k*eta))

frontend(coeff,[P, eta, -2]);

3*((1/2)*exp(k*eta)+(1/2)*exp(-k*eta))*alpha^2*m^2*((1/2)*exp(k*eta)-(1/2)*exp(-k*eta))^2

frontend(coeff,[P, eta, -3]);

alpha^3*m^3*((1/2)*exp(k*eta)-(1/2)*exp(-k*eta))^3

combine(expand(frontend(coeff,[P, eta, -3])));

(1/8)*alpha^3*m^3*exp(3*k*eta)-(3/8)*alpha^3*m^3*exp(k*eta)+(3/8)*alpha^3*m^3*exp(-k*eta)-(1/8)*alpha^3*m^3*exp(-3*k*eta)

Q := combine(collect(expand(P),eta));

(1/8)*exp(3*k*eta)+(3/8)*exp(k*eta)+(3/8)*exp(-k*eta)+(1/8)*exp(-3*k*eta)+((3/8)*alpha*m*exp(3*k*eta)+(3/8)*alpha*m*exp(k*eta)-(3/8)*alpha*m*exp(-k*eta)-(3/8)*alpha*m*exp(-3*k*eta))/eta+((3/8)*alpha^2*m^2*exp(3*k*eta)-(3/8)*alpha^2*m^2*exp(k*eta)-(3/8)*alpha^2*m^2*exp(-k*eta)+(3/8)*alpha^2*m^2*exp(-3*k*eta))/eta^2+((1/8)*alpha^3*m^3*exp(3*k*eta)-(3/8)*alpha^3*m^3*exp(k*eta)+(3/8)*alpha^3*m^3*exp(-k*eta)-(1/8)*alpha^3*m^3*exp(-3*k*eta))/eta^3

frontend(coeff,[Q, eta, -3]);

(1/8)*alpha^3*m^3*exp(3*k*eta)-(3/8)*alpha^3*m^3*exp(k*eta)+(3/8)*alpha^3*m^3*exp(-k*eta)-(1/8)*alpha^3*m^3*exp(-3*k*eta)

Download coeff_ex.mw

I'm not sure what collect has to do with this.

ps. The name eta also appears in the trigh/exp calls, eg. sinh(k*eta). Is it possible that you might want/need some kind of (truncated) series in eta?

Using active product instead of inert Product, the following can be done.

I think that it needs Maple 2018 or later, though, and not the Maple 2015 you used.

restart;

f := Product(x[i]^a*(1-x[i])^b, i);

Product(x[i]^a*(1-x[i])^b, i)

Lf := ln(f);

ln(Product(x[i]^a*(1-x[i])^b, i))

expand(simplify(expand(value(Lf))))
  assuming x[i] > 0, x[i] < 1, a > 0, b > 0;

a*(sum(ln(x[i]), i))+b*(sum(ln(1-x[i]), i))

Download From2to7_ac.mw

Is this the kind of thing that you want to accomplish?

restart

V := Vector(2, [25.0*Pi*r/(r^2+z^2), 25.0*Pi*z/(r^2+z^2)])

Vector[column](%id = 36893628704703683148)

LinearAlgebra:-Norm(V, 2)

(6168.502752*abs(r/(r^2+z^2))^2+6168.502752*abs(z/(r^2+z^2))^2)^(1/2)

 

I got the next 2D Input by using the double-bar entry
in the Common Symbols palette, and then Ctl-Shift-underscore 2
to get the subscript for the 2-norm.

 

LinearAlgebra[Norm](V, 2)

(6168.502752*abs(r/(r^2+z^2))^2+6168.502752*abs(z/(r^2+z^2))^2)^(1/2)


I got the next 2D Input by typing Norm in 2D Input mode, and

then the Esc key to get the command-completion templates
for that. I chose the second item in the ensuing popup, for the
2-norm.

LinearAlgebra[Norm](V, 2)

(6168.502752*abs(r/(r^2+z^2))^2+6168.502752*abs(z/(r^2+z^2))^2)^(1/2)

Download 2nrm.mw

ps. If you've loaded the LinearAlgebra package then you could simply call Norm(V,2) .

The plots:-display command can also handle a sequence of plots.

And the seq command can turn your Vector of plots into a sequence of plots.

restart

with(Physics); with(LinearAlgebra); with(VectorCalculus); with(Optimization); with(Statistics); with(ArrayTools); with(plots); with(plottools); with(Threads); with(MmaTranslator[Mma]), with(StringTools); with(CodeGeneration); with(ImageTools); with(ImageTools:-Draw); VectorCalculus:-`*`(Setup(mathematicalnotation = true), Setup(coordinatesystems = cartesian))

`Default differentiation variables for d_, D_ and dAlembertian are:`*{X = (x, y, z, t)}

`Systems of spacetime Coordinates are:`*{X = (x, y, z, t)}

radius := 1.0

alpha := sin((1/4)*Pi)

step := .2

radius := 100.0

l1 := line([0, 0], [100, 100])

loAng := 0.

hiAng := (1/2)*Pi

c1 := arc([0, 0.], radius, loAng .. Pi, color = "red")

c2 := arc([step, 0.], -alpha*step+radius, loAng .. hiAng, color = "blue")

c3 := arc([2*step, 0.], -2*alpha*step+radius, loAng .. Pi, color = "purple")

c4 := arc([3*step, 0.], -3*alpha*step+radius, loAng .. Pi, color = "black")

`cir&Assign;arc`([x, 0.], radius-step, loAng .. hiAng, i, color = "red")

xLimitWall := 500.0; nScatter := 20; step := xLimitWall/(nScatter+1); x := 0.; for i from 0 to nScatter do x := x+step; cir := arc([x, 0.], radius-step, 0 .. Pi, color = "red"); if i = 0 then lc := Vector([cir]) else i; cir; Append(lc, cir) end if end do

plots:-display(seq(lc))

Download JFKWEdgeDifractionDirection_ac.mw

You could also turn your Vector into a list and pass that instead, eg. you could do one of these:
    plots:-display([seq(lc)]);
or,
    plots:-display(convert(lc,list));

(While repeatedly appending to a Vector is not the most efficient way to construct your Vector of plots, I didn't change that aspect.)

ps. Your attached worksheet was last saved in Maple 2018, and not Maple 18 (released: year 2014).

Is this the kind of thing you're trying to accomplish?

fcn1 := sum(N[i]*z[i]^2, i);

sum(N[i]*z[i]^2, i)


The terms N__i and z__i (typed with double-underscore) are just whole
names, and don't depend on i.

They're not what you want, since they are unrelated to the sum index i.

fcn2 := sum(N__i*z__i, i);

N__i*z__i*i


Is this the kind of thing you want to accomplish?

diff(fcn1, N[i]);

sum(z[i]^2, i)


In 2D Input mode, you can enter N[i] by using the keystrokes
    N Ctl-Shift-underscore i

diff(fcn1, N[i])

sum(z[i]^2, i)

Download subsc_diff_ex.mw

First 31 32 33 34 35 36 37 Last Page 33 of 336