acer

32405 Reputation

29 Badges

19 years, 349 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

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

The unapply command is what you need here.

It has been available in every Maple version for decades.

Below, I use the unapply command to construct a re-usable operator (procedure) from the output expression than was assigned to fin.

restart

with(Statistics)

 

X := [0, 8, 10, 14, 25, 28]

Y := [50, 250, 300, 400, 700, 775]

 

fin := Fit(a*x+b, X, Y, x)

HFloat(26.09176748303333)*x+HFloat(42.86662732369449)

f := unapply(fin, x)

f(25)

HFloat(695.1608143995278)


Note that you don't have to assign to fin, since
you could also act directly on Fit call.

f2 := unapply(Fit(a*x+b, X, Y, x), x)

f2(25)

HFloat(695.1608143995278)


If you do assign the expression to fin, you could
also use the eval command to evaluate the
expression at values of x.

 

eval(fin, x = 25)

HFloat(695.1608143995278)

map(f, X)

[HFloat(42.86662732369449), HFloat(251.60076718796114), HFloat(303.7843021540278), HFloat(408.15137208616113), HFloat(695.1608143995278), HFloat(773.4361168486278)]

[seq(fin, x = X)]

[HFloat(42.86662732369449), HFloat(251.60076718796114), HFloat(303.7843021540278), HFloat(408.15137208616113), HFloat(695.1608143995278), HFloat(773.4361168486278)]

Download unapply_ex.mw

Instead of trying to reset that numbering you should improve your program so that it is robust with respect to the naming of such introduced variables.

Let's suppose that you have an expression assigned to expr, which might be a solution from solve (or a list of set of such, etc). Then you can issue,

    indets(expr, suffixed(_Z,posint))

and get a set of such names present in the expression.

You can then programatically substitute for the introduced name(s) into the expression, without having to hard-code the name.

For example,

expr := solve(cos(x*Pi),x,allsolutions);

        expr := 1/2 + _Z5~

nms := indets(expr, suffixed(_Z,posint));

          nms := {_Z5~}

eval(expr, nms[1]=6);;

              13/2

seq(eval(expr, nms[1]=v), v=1..6);;

      3/2, 5/2, 7/2, 9/2, 11/2, 13/2

Notes:

1.) The need for robust handling of indeterminate names is standard stuff.

2.) Resetting that counter isn't a great idea in general. Different solutions with potentially differently assumed introduced-names should have such names be distinct, regardless of whether the assumptions happen to be. (I'm deliberately going to not mention how to do it.)

Based on your description so far, I'd suggest using a PlotComponent within your document, to get that aspect of interactivity.

If you read the Help page for that embedded component you'll see that the Component Properties (clickx, clicky) can provide you with access to the position of the mouse cursor when you Click (or Click&Drag) on a 2D plot frame. Similarly for the properties endx and endy, when a Drag ends, or hoverx and hovery when the pointer hovers over.

That access is also conveniently programmatic, and fits in well with triggering/working with other interactivity. The x- and y-values can be easily used for other computations, in a manner straightforwardly consistent with other interactive purposes (and documented for such).

The plot `annotation` mechanism is more convenient (IMO) for displaying the x- and y-values in a formatted "hover-over" frame over the plot (though it's possible it might be used programmatically to trigger an embedded component action elsewhere). It has more functionality related to closeness of plotted features in the plotting frame.

I'm not able to tell from your Question and details so far which is closer to your situation and wider goals.

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