Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

Hi,

I am trying to curve fit data using NLPSolve. I noticed that the evaluation time for NLPSolve seems really long. Did I mess up in using NLPSolve? 

 

Thanks you for any suggests or comments.
 

restart; kernelopts(version); interface(version); multithread_capability := kernelopts(multithreaded); Number_of_CPUs := kernelopts(numcpus)
NULL

8

(1)

``

``

"#` How` can I decrease the evaluation time of NLPSolve or are there better methods"?"" ""

``

SoS:=proc(E0::float,E00::float,alpha::float,beta:: float)::float;

NULL

NULL

Experimental Data

 

Erealm := Vector[row]([1235.773, 1383.61, 1457.262, 1500.264, 1550.184, 1612.161, 512.7612, 656.6554, 743.6461, 793.375, 855.7937, 939.1199, 79.9523, 128.1375, 167.1459, 193.592, 230.5401, 287.8348, 22.389, 29.41424, 35.91883, 40.86366, 48.79128, 63.4475, 15.34275, 17.10101, 18.63288, 19.77424, 21.5671, 24.84739, 13.8321, 14.52843, 15.07626, 15.47014, 16.07713, 17.16574, 13.13383, 13.63704, 13.95888, 14.16849, 14.46123, 14.93971, 12.76736, 13.2203, 13.50072, 13.673, 13.89852, 14.23242]); LFm := Vector[row]([.156795, .1248161, .1108722, .1032334, 0.9474591e-1, 0.8496174e-1, .361361, .3020133, .2706018, .2546556, .2356126, .2121333, .6883826, .6532309, .6155578, .5906291, .5578895, .5123917, .394458, .5326358, .6095816, .6489291, .6894866, .7232845, .1456468, .2226473, .2826954, .3228541, .3789496, .4632182, 0.6758032e-1, 0.9437384e-1, .1198126, .1387971, .1680719, .2181531, 0.5173809e-1, 0.586771e-1, 0.6591736e-1, 0.7206892e-1, 0.8243504e-1, .1024519, 0.457877e-1, 0.493836e-1, 0.5191291e-1, 0.539114e-1, 0.5708074e-1, 0.6330242e-1])

NULL``

Enter Initial Guesses for HN equation

 

ind0 := min[index](Erealm); ind00 := max[index](Erealm); indLF := max[index](LFm); E0_g := Erealm(ind0); E00_g := 3*Erealm(ind00); `α_g` := 2.0*LFm(indLF)/Pi; `β_g` := `α_g`/(10.0); m := ArrayTools[Dimensions](LFm); maxx := rhs(m[1]); Ecomplex := Vector[row]([seq(Complex(Erealm[k], Erealm[k]*LFm[k]), k = 1 .. maxx)]); `ωτ` := Vector[row]([seq(abs((((E0_g-E00_g)/(Ecomplex[k]-E00_g))^(1/`β_g`)-1)^(1/`α_g`)/(I)), k = 1 .. maxx)]); Erealc := Vector[row]([seq(Re(E00_g+(E0_g-E00_g)/(1+(I*`ωτ`[k])^`α_g`)^`β_g`), k = 1 .. maxx)]); Eimagc := Vector[row]([seq(Im(E00_g+(E0_g-E00_g)/(1+(I*`ωτ`[k])^`α_g`)^`β_g`), k = 1 .. maxx)]); LFc := Vector[row]([seq(Eimagc[k]/Erealc[k], k = 1 .. maxx)]); pltm := plots:-loglogplot(Erealm, LFm, style = point, symbol = solidcircle, gridlines = true, color = red); pltc := plots:-loglogplot(Erealc, LFc, style = point, symbol = diamond, gridlines = true, color = blue); plots:-display(pltm, pltc, title = "Wicket Plot from Guesses       measured - red    calculated - blue"); Sum_of_Squares := SoS(E0_g, E00_g, `α_g`, `β_g`)

.2049941769

(2.1)

``

NULL

NULL

NULL

Run Optimizer

 

lol := .7; hil := 1.3; le0 := lol*E0_g; he0 := hil*E0_g; le00 := lol*E00_g; he00 := hil*E00_g; al := lol*`α_g`; ah := hil*`α_g`; bl := lol*`β_g`; bh := hil*`β_g`; parameterRange := le0 .. he0, le00 .. he00, al .. ah, bl .. bh; soln := Optimization:-NLPSolve(SoS, parameterRange); HN := soln[2]; E0_s := HN[1]; E00_s := HN[2]; `α_s` := HN[3]; `β_s` := HN[4]; `ωτ_s` := Vector[row]([seq(abs((((E0_s-E00_s)/(Ecomplex[k]-E00_s))^(1/`β_s`)-1)^(1/`α_s`)/(I)), k = 1 .. maxx)]); Erealc_s := Vector[row]([seq(Re(E00_s+(E0_s-E00_s)/(1+(I*`ωτ_s`[k])^`α_s`)^`β_s`), k = 1 .. maxx)]); Eimagc_s := Vector[row]([seq(Im(E00_s+(E0_s-E00_s)/(1+(I*`ωτ_s`[k])^`α_s`)^`β_s`), k = 1 .. maxx)]); LFc_s := Vector[row]([seq(Eimagc_s[k]/Erealc_s[k], k = 1 .. maxx)])

[0.648163470800135894e-2, Vector[column](%id = 18446747242105787086)]

(3.1)

NULL

NULL

NULL

Plot Wicket Plot with Optimized HN Parameters

 

pltm_s := plots:-loglogplot(Erealm, LFm, style = point, symbol = solidcircle, gridlines = true, color = red); pltc_s := plots:-loglogplot(Erealc_s, LFc_s, style = point, symbol = diamond, gridlines = true, color = blue); plots:-display(pltm_s, pltc_s, title = "Wicket Plot after Optimization  (measured - red    calculated - blue)"); E0_soln := E0_s; E00_soln := E00_s; `α_soln` := `α_s`; `β_soln` := `β_s`; Sum_of_Squares := soln[1]

0.648163470800135894e-2

(4.1)

NULL


 

Download HN_fit_of_DMA_data_ss_proc_v5a.mw

Hi, 

Recently a few questions concerning the sampling of the Cauchy distribution and the sampling of a truncated Normal distribution have been posted (mainly by  @jalale).
This post is concerned by the sampling of a truncated (standard) Cauchy distribution.

In a first part the efficiency fo two methods is adressed in the case of a non-truncated Cauchy distribution:

  • The "standard" Maple's command Statistics:-Sample(Cauchy(0, 1), N)
  • And a general method a priori very efficient if one knows the ICDF (Inverse Cumulative Function Distribution). It happens that this ICDF is just cot(U*Pi)  where U is a Uniform RV over [0, 1].
     

The second part adresses the sampling of a truncatedCauchy distribution with two methods:

  • The "standard" Maple's command Statistics:-Sample(Cauchy(0, 1), N, method=[envelope, range=...])
  • The method based on the use of the ICDF

 

Results:

Test1 (non-truncated Cauchy distribution) 

  • "Standard" Maples sampling outperforms the ICDF based method in terms of :
    • memory occupation: ICDF is twice more demanding
    • cpu time: ICDF is ten times slower
       

Test2 (truncated Cauchy distribution) 

  • ICDF based method i outperforms "Standard" Maples sampling oin terms of :
    • memory occupation: Maples "envelope sampling" method is twice more demanding
    • cpu time: Maples "envelope sampling" method is two times slower


But, beyond these simple observations, a disturbing problem is: the "envelope sampling" method seems to not return the correct distribution (at least when used this waymethod=[envelope, range=a..b]  with a < b)
This is confirmed by the two last plot where histogram and PDF are uperimposed.

Do you think this problem can be avoided by another parameterization of the "envelope sampling" method or that it reveals some underlying problem with it?

PS: I did not investigate further for other distributions .

 


 

 

Sampling the Cauchy distribution

Maple's default sampling method outperformes the adhoc method

restart

with(Statistics):

C := RandomVariable(Cauchy(0, 1))

_R

(1)

f := unapply(CDF(C, t), t);

proc (t) options operator, arrow; 1/2+arctan(t)/Pi end proc

(2)

finv := unapply(-solve(f(t)=u, t), u)

proc (u) options operator, arrow; cot(u*Pi) end proc

(3)

# "natural" way to proceed

N  := 10^6:

S1 := CodeTools:-Usage(Sample(C, N)):

memory used=7.71MiB, alloc change=39.63MiB, cpu time=69.00ms, real time=69.00ms, gc time=8.72ms

 

# Let's try the sampling strategy based on the inverse of the CDF
# Usually it starts from sampling a Uniform RV on [0, 1] and
# next applies finv to the result.
#
# Smart but inefficient

U  := RandomVariable(Uniform(0., 1)):
S2 := CodeTools:-Usage(finv~(Sample(U, N))):

memory used=145.02MiB, alloc change=7.63MiB, cpu time=4.94s, real time=3.04s, gc time=2.61s

 

# Much more efficient
#
# Given the special form of finv it's simpler to sample a Unirorm RV
# on [0, Pi] and apply "cot" to the result

pi := evalf(Pi):
U  := RandomVariable(Uniform(0., pi)):
S2 := CodeTools:-Usage(cot~(Sample(U, N))):

memory used=15.28MiB, alloc change=0 bytes, cpu time=652.00ms, real time=237.00ms, gc time=577.78ms

 

Sampling a truncated Cauchy distribution

Example 1:
with(Statistics) + method=[envelope, range=-10..10]

The adhoc method outperforms Maple's default sampling method

S1 := CodeTools:-Usage(Sample(C, N, method=[envelope, range=-10..10])):

Histogram(S1);

memory used=8.88MiB, alloc change=-7.63MiB, cpu time=322.00ms, real time=260.00ms, gc time=93.77ms

 

 

p  := Probability(C < -10, numeric);
q  := 1-Probability(C > +10, numeric);
U  := RandomVariable(Uniform(p*pi, q*pi)):
S2 := CodeTools:-Usage(cot~(Sample(U, N))):

Histogram(S2);

HFloat(0.03172551743055352)

 

HFloat(0.9682744825694465)

 

memory used=15.28MiB, alloc change=7.63MiB, cpu time=170.00ms, real time=113.00ms, gc time=92.11ms

 

 

Sampling a truncated Cauchy distribution

Example 2:
with(Statistics) + method=[envelope, range=-1..1]

The adhoc method outperformes Maple's default sampling method

S1 := CodeTools:-Usage(Sample(C, N, method=[envelope, range=-1..1])):


scaling := Probability(C < +1, numeric) - Probability(C < -1, numeric);
plots:-display( Histogram(S1), plot(PDF(C, t)/scaling, t=-1..1, thickness=3, color=red) );

memory used=8.08MiB, alloc change=0 bytes, cpu time=246.00ms, real time=215.00ms, gc time=46.62ms

 

HFloat(0.5)

 

 

p  := Probability(C < -1, numeric);
q  := 1-Probability(C > +1, numeric);
U  := RandomVariable(Uniform(p*pi, q*pi)):
S2 := CodeTools:-Usage(cot~(Sample(U, N))):

plots:-display( Histogram(S2), plot(PDF(C, t)/scaling, t=-1..1, thickness=3, color=red) );

HFloat(0.25)

 

HFloat(0.75)

 

memory used=15.28MiB, alloc change=7.63MiB, cpu time=163.00ms, real time=106.00ms, gc time=85.93ms

 

 

 


 

Download CAUCHY_adhoc-sampling.mw

Hi

Please download the attachment.

 

I try to find a relation between EL and Lap(EL) in polar coordinate for one variable function w(r), where Lap is laplacian and EL is Euler Lagrange equation. Please check the Maple code and help me to do some manipulations to find a general relation (if any relation exists!).

In fact I need the inverse of Euler Lagrange equation to obtain f(r) for an arbitrary function g(r) in equation below

EL(f) = Lap(EL(g))

Or f=inverseEL(Lap(EL(g)))

Thank you for taking your time

 

 

 

restart; s := proc (f) subs(d[0] = w(r), seq(d[n] = diff(w(r), `$`(r, n)), n = 1 .. 10), f) end proc; ss := proc (f) subs(seq(diff(w(r), `$`(r, 11-n)) = d[11-n], n = 1 .. 10), w(r) = d[0], f) end proc; EL := proc (eq) s(diff(ss(eq), d[0]))+add((diff(s(diff(ss(eq), d[n])), `$`(r, n)))*(-1)^n, n = 1 .. 10) end proc

f := (diff(w(r), r, r))^2*r^4+4*r^6*(diff(w(r), r, r, r))^2:

a1 := EL(F):

a2 := VectorCalculus:-Laplacian(EL(f), 'polar[r, t]'):

simplify(a1-a2)

8*r^6*(diff(diff(diff(diff(diff(diff(diff(diff(w(r), r), r), r), r), r), r), r), r))+248*r^5*(diff(diff(diff(diff(diff(diff(diff(w(r), r), r), r), r), r), r), r))+2582*r^4*(diff(diff(diff(diff(diff(diff(w(r), r), r), r), r), r), r))+10910*r^3*(diff(diff(diff(diff(diff(w(r), r), r), r), r), r))+17786*r^2*(diff(diff(diff(diff(w(r), r), r), r), r))+8192*r*(diff(diff(diff(w(r), r), r), r))-92*(diff(diff(w(r), r), r))

(1)

``


 

Download EL.mw

Dear Experts,

I am new user. I need your help!

I have numerical values of omega (w) and a2F(w) (500 rows). I need to do cumulative summation to get lambda(w) using   lambd=2 int (a2F(w)/w  dw). Please help me how can I do it?

Best Wishes,

Enamul Haque

Hello

I am revising the unstable period orbits of the Logistic map, y[n]=4*y[n-1]*(1-y[n]), in Maple.  Although I have implemented the equation and use a loop for the iterations, I wonder whether there is a faster and concise way to code the equation in Maple. 

Here it is what I did:

y[0] := (-sqrt(5)+5)*(1/8);

for n to 10 do y[n] := 4*y[n-1]*(1-y[n-1]) end do;
soly := [seq(simplify(expand(y[n]), radical), n = 0 .. 10)];
dat := [seq([n, Re(evalf(soly[n]))], n = 1 .. 10)]; plot(dat, labels = ["k", "x(k)"], style = pointline,title="Period 2");

Since only few iterations are needed, the solution is symbolic (and then convert to float).  

Many thanks.

Ed

 

 

Hi guys,

This is the first time of solving partial differential equation, can some please help me point out some errows in my code. 
 

restart

ODEs := `<,>`(diff(v(y), y, y)+(diff(v(y), y))/y-(Ha^2/(1-eta)^2+1/y^2)*v(y)-Re*v(y)*(diff(v(y), y)) = 0, diff(theta(y), y, y)+Ec*Pr*(diff(v(y), y)-v(y)/y)^2-Pr*Re*v(y)*(diff(theta(y), y))+Nb*(diff(theta(y), y))*(diff(phi(y), y))+Nt*(diff(theta(y), y))^2 = 0, diff(phi(y), y, y)-Re*Sc*v(y)*(diff(phi(y), y))+Nt*(diff(theta(y), y, y)+(diff(theta(y), y))/y)/Nb = 0)

ODEs := Matrix(3, 1, {(1, 1) = diff(diff(v(y), y), y)+(diff(v(y), y))/y-(Ha^2/(1-eta)^2+1/y^2)*v(y)-Re*v(y)*(diff(v(y), y)) = 0, (2, 1) = diff(diff(theta(y), y), y)+Ec*Pr*(diff(v(y), y)-v(y)/y)^2-Pr*Re*v(y)*(diff(theta(y), y))+Nb*(diff(theta(y), y))*(diff(phi(y), y))+Nt*(diff(theta(y), y))^2 = 0, (3, 1) = diff(diff(phi(y), y), y)-Re*Sc*v(y)*(diff(phi(y), y))+Nt*(diff(diff(theta(y), y), y)+(diff(theta(y), y))/y)/Nb = 0})

(1)

BCs := `<,>`(phi(eta) = 1, v(eta) = 1, theta(eta) = 1, phi(1) = 0, theta(1) = 0, v(1) = 0)

BCs := Matrix(6, 1, {(1, 1) = phi(eta) = 1, (2, 1) = v(eta) = 1, (3, 1) = theta(eta) = 1, (4, 1) = phi(1) = 0, (5, 1) = theta(1) = 0, (6, 1) = v(1) = 0})

(2)

param_names := [eta, Ha, Ec, Nt, Nb, Re, Sc, Pr];

[eta, Ha, Ec, Nt, Nb, Re, Sc, Pr]

(3)

pdSolve := subs(_P = param_names, proc ({ eta::realcons := .5, Ha::realcons := 1, Sc::realcons := .8, Nt::realcons := .1, Nb::realcons := .1, Re::realcons := 2, Ec::realcons := 0.1e-1, Pr::realcons := 10 }) userinfo(1, Solve, `~`[`=`](param_names, _P)); dsolve(eval(`union`(convert(ODEs, set), convert(BCs, set)), `~`[`=`](param_names, _P)), numeric) end proc);

proc ({ Ec::realcons := 0.1e-1, Ha::realcons := 1, Nb::realcons := .1, Nt::realcons := .1, Pr::realcons := 10, Re::realcons := 2, Sc::realcons := .8, eta::realcons := .5 }) userinfo(1, Solve, `~`[`=`](param_names, [eta, Ha, Ec, Nt, Nb, Re, Sc, Pr])); dsolve(eval(`union`(convert(ODEs, set), convert(BCs, set)), `~`[`=`](param_names, [eta, Ha, Ec, Nt, Nb, Re, Sc, Pr])), numeric) end proc

(4)

infolevel[Solve] := 1:

Fig. 3 (changing values of Ha):

P:= Ha:
vals:= [1, 5, 10, 20]:
sols:= [seq(Solve(P= v), v= vals)]:
colors:= [red, green, blue]:
for F in [v,theta,phi](y) do
   print(plots:-display(
      [seq(
         plots:-odeplot(sols[k], [y,F], color= colors[k], legend= [P= vals[k]]),
         k= 1..nops(vals)
      )],
      labeldirections= [horizontal,vertical]
   ))
od:

Error, pdeplot is not a command in the plots package

 

``


 

Download chapter5.mw

 

How can I use Maple to solve a difference quotient problem? How do I enter the basic difference quotient formula and the quadratic equation to be used in the problem?

1.47449729919434*10^10*c[0, 1]*c[0, 2]*c[2, 2]*c[3, 0]+3.38624318440755*10^8*c[0, 1]*c[0, 3]*c[1, 0]*c[2, 1]+1.54309415817260*10^10*c[0, 1]*c[0, 3]*c[1, 3]*c[2, 0]+1.69527735464914*10^14*c[0, 2]*c[0, 3]*c[1, 3]*c[3, 3]+5.64571777979530*10^11*c[0, 1]*c[1, 3]*c[3, 0]*c[3, 1]+5.64571777979530*10^11*c[0, 1]*c[1, 1]*c[3, 0]*c[3, 3]+3.44365358352662*10^11*c[0, 1]*c[1, 1]*c[3, 1]*c[3, 2]+4.56141047477722*10^11*c[0, 1]*c[0, 2]*c[2, 1]*c[3, 3]+1.47449729919434*10^10*c[0, 1]*c[0, 2]*c[2, 0]*c[3, 2]+1.00292015075684*10^10*c[0, 1]*c[0, 2]*c[2, 1]*c[3, 1]+4.96419365552208*10^14*c[1, 1]*c[2, 3]*c[3, 1]*c[3, 2]+2.41547661753786*10^16*c[1, 1]*c[2, 3]*c[3, 2]*c[3, 3]+3.09237360954284*10^11*c[0, 2]*c[1, 1]*c[1, 3]*c[3, 1]+2.07077209298372*10^13*c[0, 2]*c[2, 2]*c[2, 3]*c[3, 0]+2.77395036220550*10^11*c[0, 2]*c[1, 1]*c[1, 2]*c[3, 2]+3.25883571082134*10^15*c[1, 2]*c[2, 3]*c[3, 1]*c[3, 2]+2.77442234357198*10^11*c[0, 2]*c[1, 1]*c[2, 1]*c[2, 3]+7.80736282336175*10^14*c[2, 0]*c[2, 1]*c[3, 2]*c[3, 3]+3.25883571082134*10^15*c[1, 2]*c[2, 2]*c[3, 1]*c[3, 3]+5.35593751087840*10^15*c[1, 2]*c[2, 3]*c[3, 0]*c[3, 3]+3.63255405301248*10^15*c[1, 1]*c[2, 3]*c[3, 1]*c[3, 3]+3.25883571082134*10^15*c[1, 2]*c[2, 1]*c[3, 2]*c[3, 3]+1.48022406855142*10^13*c[1, 0]*c[2, 1]*c[2, 2]*c[3, 3]+5.19766484559825*10^15*c[0, 1]*c[2, 3]*c[3, 2]*c[3, 3]+3.63255405301248*10^15*c[1, 3]*c[2, 1]*c[3, 1]*c[3, 3]+1.03156027712140*10^14*c[0, 3]*c[1, 2]*c[1, 3]*c[2, 3]+6.84418565576730*10^13*c[1, 1]*c[1, 2]*c[1, 3]*c[3, 3]+1.36253689407226*10^13*c[0, 1]*c[1, 2]*c[2, 3]*c[3, 2]+4.50722523384354*10^11*c[0, 1]*c[0, 2]*c[1, 2]*c[3, 3]+4.63272867590191*10^14*c[1, 1]*c[1, 3]*c[2, 3]*c[3, 2]+9.56722337372450*10^9*c[0, 1]*c[0, 2]*c[1, 2]*c[1, 3]+7.56283392524430*10^14*c[0, 3]*c[1, 1]*c[2, 3]*c[3, 3]+1.51879056084535*10^13*c[0, 3]*c[1, 1]*c[2, 3]*c[3, 1]+8.15436050904650*10^14*c[1, 1]*c[2, 3]*c[3, 0]*c[3, 3]+1.51879056084535*10^13*c[0, 1]*c[1, 1]*c[2, 3]*c[3, 3]+3.05712170936082*10^11*c[0, 1]*c[1, 1]*c[1, 3]*c[2, 3]+2.21942429315476*10^9*c[0, 1]*c[0, 2]*c[1, 0]*c[3, 2]+1.50960286458333*10^9*c[0, 1]*c[0, 2]*c[1, 1]*c[3, 1]+6.37602806091310*10^9*c[0, 1]*c[1, 1]*c[1, 2]*c[1, 3]+2.22015380859375*10^7*c[0, 0]*c[1, 0]*c[1, 1]*c[3, 0]+2.24812825520834*10^6*c[0, 0]*c[0, 1]*c[1, 0]*c[2, 1]+2.24812825520834*10^6*c[0, 0]*c[0, 1]*c[1, 1]*c[2, 0]+4.45556640625000*10^5*c[0, 0]*c[0, 1]*c[0, 2]*c[1, 0]+1.80236816406250*10^7*c[0, 0]*c[0, 2]*c[0, 3]*c[1, 0]+9.99813988095240*10^6*c[0, 1]*c[1, 0]*c[1, 1]*c[2, 0]+1.64310515873016*10^7*c[0, 0]*c[0, 1]*c[1, 0]*c[3, 1]+1.09924316406250*10^7*c[0, 0]*c[0, 1]*c[0, 2]*c[1, 2]+1.22578938802084*10^7*c[0, 0]*c[0, 1]*c[0, 3]*c[1, 1]+6.74438476562500*10^5*c[0, 0]*c[0, 1]*c[1, 0]*c[2, 0]+3.27484130859375*10^7*c[0, 0]*c[0, 1]*c[2, 0]*c[3, 0]+4.96419365552208*10^14*c[1, 1]*c[2, 2]*c[3, 1]*c[3, 3]+1.48022406855142*10^13*c[1, 2]*c[2, 0]*c[2, 1]*c[3, 3]+1.48022406855142*10^13*c[1, 2]*c[2, 0]*c[2, 3]*c[3, 1]+7.00457388588595*10^14*c[1, 2]*c[2, 0]*c[2, 3]*c[3, 3]+9.01806926154510*10^12*c[1, 2]*c[2, 1]*c[2, 2]*c[3, 1]+4.26195329427362*10^14*c[1, 1]*c[2, 2]*c[2, 3]*c[3, 2]+8.70017911044035*10^14*c[1, 1]*c[3, 0]*c[3, 2]*c[3, 3]+1.64960358855012*10^13*c[1, 2]*c[1, 3]*c[3, 0]*c[3, 1]+8.70017911044035*10^14*c[1, 3]*c[3, 0]*c[3, 1]*c[3, 2]+4.11701503132284*10^16*c[1, 3]*c[3, 0]*c[3, 2]*c[3, 3]+1.32823657812862*10^13*c[2, 0]*c[2, 1]*c[2, 2]*c[2, 3]+2.49782355477406*10^13*c[0, 1]*c[0, 3]*c[3, 1]*c[3, 3]+1.86077008928572*10^7*c[0, 0]*c[0, 1]*c[0, 2]*c[0, 3]+4.50750425170068*10^11*c[0, 3]*c[1, 2]*c[1, 3]*c[2, 0]+2.41765159606934*10^10*c[0, 0]*c[0, 2]*c[2, 0]*c[3, 3]+1.28155946659681*10^15*c[2, 0]*c[2, 3]*c[3, 0]*c[3, 3]+7.80736282336175*10^14*c[2, 0]*c[2, 3]*c[3, 1]*c[3, 2]+2.95015059452266*10^13*c[2, 0]*c[2, 3]*c[3, 0]*c[3, 1]+1.64424324035644*10^10*c[0, 1]*c[0, 3]*c[2, 0]*c[3, 1]+7.80736282336175*10^14*c[2, 0]*c[2, 2]*c[3, 1]*c[3, 3]+3.38624318440755*10^8*c[0, 1]*c[0, 3]*c[1, 1]*c[2, 0]+6.83811849201320*10^14*c[0, 2]*c[2, 1]*c[2, 3]*c[3, 3]+4.96419365552208*10^14*c[1, 1]*c[2, 1]*c[3, 2]*c[3, 3]+4.50722523384354*10^11*c[0, 1]*c[0, 2]*c[1, 3]*c[3, 2]+2.74640085129511*10^12*c[0, 3]^2*c[1, 3]*c[3, 0]+4.53797990504672*10^10*c[0, 2]^2*c[2, 0]*c[2, 3]+2.76260943995885*10^10*c[0, 2]^2*c[2, 1]*c[2, 2]+5.63905988420760*10^10*c[0, 3]^2*c[1, 0]*c[3, 1]+2.74640085129511*10^12*c[0, 3]^2*c[1, 0]*c[3, 3]+5.63905988420760*10^10*c[0, 3]^2*c[1, 1]*c[3, 0]+1.67039675031390*10^12*c[0, 3]^2*c[1, 1]*c[3, 2]+1.67039675031390*10^12*c[0, 3]^2*c[1, 2]*c[3, 1]

When I try to calculate the derivative of a covariant metric with respect to the corresponding contravariant metric, or vice versa, the result is correct up to the sign, which is wrong:

diff(g_[nu, tau], g_[~mu, ~eta]);

Maple's result: g_[eta, nu] g_[mu, tau]

Correct result: -g_[eta, nu] g_[mu, tau]

diff(g_[~nu, ~tau], g_[mu, eta]);

Maple's result: g_[~eta, ~nu] g_[~mu, ~tau]

Correct result: -g_[~eta, ~nu] g_[~mu, ~tau]

I've loaded DifferentialGeometry, Tensor, Physics. Is this my fault, or Maple's?

Dear friends,

I have attached a document with two commands  in slider0 for plotting the same graph in two plot components.
use DocumentTools in 
a := Do(%Slider0/100);
b := Do(%Slider1/100);

Do(%Plot0 = plot(sin(a*x)+cos(b*x^2),x=0..10,y=-3..3));
SetProperty("Plot1",value,plot(sin(a*x)+cos(b*x^2),x=0..10,y=-3..3));
end use; 

I am just curious to know which one is better and when?

 

``

``

 

``


 

Download DoubtOnLatestCodesinEmbeddedPlot.mw

Thanks for answers.

Ramakrishnan V

restart;
A[0] := 0;
                               0
A[1] := sqrt(2*(k[1]^2-w[1]^2))/n;
                                       (1/2)
                    /      2         2\     
                    \2 k[1]  - 2 w[1] /     
                    ------------------------
                               n            
A[2] := sqrt(2*(k[2]^2-w[2]^2))/n;
                                       (1/2)
                    /      2         2\     
                    \2 k[2]  - 2 w[2] /     
                    ------------------------
                               n            
c[1] := 1;
                               1
c[2] := 1;
                               1
c[3] := 1;
                               1
c[4] := 1;
                               1
c[5] := 1;
                               1
c[6] := 1;
                               1
k[1] := 10.5;
                              10.5
k[2] := 3.5;
                              3.5
w[1] := 5.05;
                              5.05
w[2] := .5;
                              0.5
m := 1.9;
                              1.9
n := 1.75;
                              1.75
xi[1] := -t*w[1]+x*k[1];
                        -5.05 t + 10.5 x
xi[2] := -t*w[2]+x*k[2];
                         -0.5 t + 3.5 x
a := m/sqrt(2*(k[1]^2-w[1]^2));
                          0.1459402733
b := m/sqrt(k[2]^2-w[2]^2);
                          0.5484827558
g := a*(c[2]*exp(a*xi[1])+c[3]*exp(-a*xi[1]));
     0.1459402733 exp(-0.7369983802 t + 1.532372870 x)

        + 0.1459402733 exp(0.7369983802 t - 1.532372870 x)
h := c[1]+c[2]*exp(a*xi[1])+c[3]*exp(-a*xi[1]);
            1 + exp(-0.7369983802 t + 1.532372870 x)

               + exp(0.7369983802 t - 1.532372870 x)
G := b*(c[5]*exp(b*xi[2])+c[6]*exp(-b*xi[2]));
     0.5484827558 exp(-0.2742413779 t + 1.919689645 x)

        + 0.5484827558 exp(0.2742413779 t - 1.919689645 x)
H := c[4]+c[5]*exp(b*xi[2])+c[6]*exp(-b*xi[2]);
            1 + exp(-0.2742413779 t + 1.919689645 x)

               + exp(0.2742413779 t - 1.919689645 x)
u := A[0]+A[1]*[g/h]+A[2]*[G/H];
[(2.799416849 (0.5484827558 exp(-0.2742413779 t + 1.919689645 x)

   + 0.5484827558 exp(0.2742413779 t - 1.919689645 x)))/(1

   + exp(-0.2742413779 t + 1.919689645 x)

   + exp(0.2742413779 t - 1.919689645 x)) + (7.439442594 

  (0.1459402733 exp(-0.7369983802 t + 1.532372870 x)

   + 0.1459402733 exp(0.7369983802 t - 1.532372870 x)))/(1

   + exp(-0.7369983802 t + 1.532372870 x)

   + exp(0.7369983802 t - 1.532372870 x))]
plot3d(u, x = -20 .. .20, t = -20 .. .20);

t := 0;
                               0
plot(u, x = -15 .. 15);


Error, (in plot) found points with fewer or more than 2 components
 

fgure set 1;
Error, missing operation
 Typesetting:-mambiguous(fgure Typesetting:-mambiguous(set 1, 

   Typesetting:-merror("missing operation")))
restart;
l := 4;
                               4
m := 1;
                               1
n := 2;
                               2
k := 1/sqrt(-6*beta*l^2+24*beta*m*n);
                               1        
                        ----------------
                                   (1/2)
                        4 (-3 beta)     
w := alpha/(5*beta*sqrt(l^2-4*m*n));
                                 (1/2)
                          alpha 2     
                          ------------
                            20 beta   

B[0] := -(1/25)*alpha*(5*l^3/(5*sqrt(l^2-4*m*n))-20*l*m*n/(5*sqrt(l^2-4*m*n))-l^2+2*m*n)*sqrt(-6*beta*l^2+24*beta*m*n)*(5*sqrt(l^2-4*m*n))/((l^2-4*m*n)^2*beta);
                 /   (1/2)     \          (1/2)  (1/2)
           alpha \8 2      - 12/ (-3 beta)      2     
         - -------------------------------------------
                             40 beta                  
B[1] := -(12/5)*m*alpha*(5*l/(5*sqrt(l^2-4*m*n))-1)/sqrt(-6*beta*l^2+24*beta*m*n);
                               / (1/2)    \
                       3 alpha \2      - 1/
                     - --------------------
                                    (1/2)  
                         5 (-3 beta)       
B[2] := -12*m^2*alpha/(sqrt(-6*beta*l^2+24*beta*m*n)*(5*sqrt(l^2-4*m*n)));
                                  (1/2)  
                         3 alpha 2       
                      - -----------------
                                    (1/2)
                        20 (-3 beta)     
theta := sqrt(l^2-4*m*n);
                               (1/2)
                            2 2     
xi[0] := 1;
                               1
F := -l/(2*m)-theta*tanh((1/2)*theta*(xi+xi[0]))/(2*m);
                     (1/2)     / (1/2)         \
               -2 - 2      tanh\2      (xi + 1)/
beta := -2;
                               -2
alpha := -3;
                               -3

                               1


xi := k*x-t*w;
                   1   (1/2)     3     (1/2)
                   -- 6      x - -- t 2     
                   24            40         
u := B[0]+B[1]*F+B[2]*F*F;
  3  /   (1/2)     \  (1/2)  (1/2)   3  / (1/2)    \  (1/2) /  
- -- \8 2      - 12/ 6      2      + -- \2      - 1/ 6      |-2
  80                                 10                     \  

      (1/2)     / (1/2) /1   (1/2)     3     (1/2)    \\\   3  
   - 2      tanh|2      |-- 6      x - -- t 2      + 1||| + -- 
                \       \24            40             ///   40 

   (1/2)  (1/2) 
  6      2      

                                                            2
  /      (1/2)     / (1/2) /1   (1/2)     3     (1/2)    \\\ 
  |-2 - 2      tanh|2      |-- 6      x - -- t 2      + 1||| 
  \                \       \24            40             /// 
plot3d(u, x = -30 .. .30, t = -30 .. .30);

t := 0;
                               0
plot([u], x = -30 .. 30);

case2222;
                            case2222
restart;
l := 2;
                               2
m := 1;
                               1
n := 2;
                               2
k := 1/sqrt(-6*beta*l^2+24*beta*m*n);
                              (1/2)   
                             6        
                          ------------
                                 (1/2)
                          12 beta     
w := alpha/(5*beta*sqrt(l^2-4*m*n));
                            1         
                            -- I alpha
                            10        
                          - ----------
                               beta   

B[0] := -(1/25)*alpha*(5*l^3/(5*sqrt(l^2-4*m*n))-20*l*m*n/(5*sqrt(l^2-4*m*n))-l^2+2*m*n)*sqrt(-6*beta*l^2+24*beta*m*n)*(5*sqrt(l^2-4*m*n))/((l^2-4*m*n)^2*beta);
                                 (1/2)
                          alpha 6     
                          ------------
                                (1/2) 
                          5 beta      
B[1] := -(12/5)*m*alpha*(5*l/(5*sqrt(l^2-4*m*n))-1)/sqrt(-6*beta*l^2+24*beta*m*n);
                     /1   1  \        (1/2)
                     |- + - I| alpha 6     
                     \5   5  /             
                     ----------------------
                               (1/2)       
                           beta            
B[2] := -12*m^2*alpha/(sqrt(-6*beta*l^2+24*beta*m*n)*(5*sqrt(l^2-4*m*n)));
                       1           (1/2)
                       -- I alpha 6     
                       10               
                       -----------------
                               (1/2)    
                           beta         
theta := sqrt(l^2-4*m*n);
                              2 I
xi[0] := 1;
                               1
C := -2;
                               -2
F := -l/(2*m)-theta*tanh((1/2)*theta*xi)/(2*m)+sech((1/2)*theta*xi)/(C*cosh((1/2)*theta*xi)-2*m*sinh((1/2)*theta*xi)/theta);
                                   sec(xi)       
              -1 + tan(xi) + --------------------
                             -2 cos(xi) - sin(xi)

beta := -2;
                               -2
alpha := 3;
                               3

xi := k*x-t*w;
                  1   (1/2)     (1/2)     3     
                - -- 6      (-2)      x - -- I t
                  24                      20    
u := B[0]+B[1]*F+B[2]*F*F;
  3   (1/2)     (1/2)   /  3    3   \  (1/2)     (1/2) /  
- -- 6      (-2)      + |- -- - -- I| 6      (-2)      |-1
  10                    \  10   10  /                  \  

        /1   (1/2)     (1/2)     3     \   /   /1   (1/2) 
   - tan|-- 6      (-2)      x + -- I t| + |sec|-- 6      
        \24                      20    /   \   \24        

      (1/2)     3     \\//      /1   (1/2)     (1/2)     3     \
  (-2)      x + -- I t|| |-2 cos|-- 6      (-2)      x + -- I t|
                20    // \      \24                      20    /

        /1   (1/2)     (1/2)     3     \\\   3     (1/2) 
   + sin|-- 6      (-2)      x + -- I t||| - -- I 6      
        \24                      20    ///   20          

      (1/2) /        /1   (1/2)     (1/2)     3     \   /   /1  
  (-2)      |-1 - tan|-- 6      (-2)      x + -- I t| + |sec|-- 
            \        \24                      20    /   \   \24 

   (1/2)     (1/2)     3     \\//
  6      (-2)      x + -- I t|| |
                       20    // \
      /1   (1/2)     (1/2)     3     \
-2 cos|-- 6      (-2)      x + -- I t|
      \24                      20    /

        /1   (1/2)     (1/2)     3     \\\  
   + sin|-- 6      (-2)      x + -- I t|||^2
        \24                      20    ///  
plot3d(Re(u), x = -30 .. .30, t = -30 .. .30);

t := 0;
                               0
plot([Re(u)], x = -30 .. 30);

plot3d(Im(u), x = -10 .. .10, t = -10 .. .10);
Error, (in plot3d) bad range arguments: x = -10 .. .10, 0 = -10 .. .10
t := 0;
                               0
plot([Im(u)], x = -30 .. 30);

fgure set 2;
Error, missing operation
 Typesetting:-mambiguous(fgure Typesetting:-mambiguous(set 2, 

   Typesetting:-merror("missing operation")))
restart;
l := 4;
                               4
m := 1;
                               1
n := 2;
                               2
k := 1/sqrt(6*beta*l^2-24*beta*m*n);
                              (1/2)   
                             3        
                          ------------
                                 (1/2)
                          12 beta     
w := alpha/((5*sqrt(l^2-4*m*n))*beta);
                                 (1/2)
                          alpha 2     
                          ------------
                            20 beta   

B[0] := (1/25)*alpha*(5*l^3/(5*sqrt(l^2-4*m*n))-20*l*m*n/(5*sqrt(l^2-4*m*n))+l^2-6*m*n)*sqrt(6*beta*l^2-24*beta*m*n)*(5*sqrt(l^2-4*m*n))/((l^2-4*m*n)^2*beta);
                     /   (1/2)    \  (1/2)  (1/2)
               alpha \8 2      + 4/ 3      2     
               ----------------------------------
                                 (1/2)           
                          40 beta                
B[1] := -(12/5)*m*alpha*(5*l/(5*sqrt(l^2-4*m*n))-1)/sqrt(6*beta*l^2-24*beta*m*n);
                          / (1/2)    \  (1/2)
                    alpha \2      - 1/ 3     
                  - -------------------------
                                 (1/2)       
                           5 beta            
B[2] := -12*m^2*alpha/(sqrt(6*beta*l^2-24*beta*m*n)*(5*sqrt(l^2-4*m*n)));
                              (1/2)  (1/2)
                       alpha 3      2     
                     - -------------------
                                 (1/2)    
                          20 beta         

                       1           (1/2)
                       -- I alpha 6     
                       10               
                       -----------------
                               (1/2)    
                           beta         
theta := sqrt(l^2-4*m*n);
                               (1/2)
                            2 2     
xi[0] := 1;
                               1
F := -l/(2*m)-theta*tanh((1/2)*theta*(xi+xi[0]))/(2*m);
                     (1/2)     / (1/2)         \
               -2 - 2      tanh\2      (xi + 1)/
beta := -2;
                               -2
alpha := -3;
                               -3

                               1


xi := k*x-t*w;
               1   (1/2)     (1/2)     3     (1/2)
             - -- 3      (-2)      x - -- t 2     
               24                      40         
u := B[0]+B[1]*F+B[2]*F*F;
 3  /   (1/2)    \     (1/2)  (1/2)  (1/2)   3  / (1/2)    \ 
 -- \8 2      + 4/ (-2)      3      2      - -- \2      - 1/ 
 80                                          10              

    (1/2)     (1/2) /  
   3      (-2)      |-2
                    \  

       (1/2)     / (1/2) /  1   (1/2)     (1/2)     3     (1/2)
    - 2      tanh|2      |- -- 3      (-2)      x - -- t 2     
                 \       \  24                      40         

       \\\   3   (1/2)     (1/2)  (1/2) /  
    + 1||| - -- 3      (-2)      2      |-2
       ///   40                         \  

       (1/2)     / (1/2) /  1   (1/2)     (1/2)     3     (1/2)
    - 2      tanh|2      |- -- 3      (-2)      x - -- t 2     
                 \       \  24                      40         

       \\\  
    + 1|||^2
       ///  
plot3d(Re(u), x = -30 .. .30, t = -30 .. .30);
Error, (in plot3d) bad range arguments: x = -30 .. .30, 0 = -30 .. .30
t := 0;
                               0
plot([Re(u)], x = -30 .. 30);

plot3d(Im(u), x = -1 .. 1, t = -1 .. 1);
Error, (in plot3d) bad range arguments: x = -1 .. 1, 0 = -1 .. 1
t := 0;
                               0
plot([Im(u)], x = -30 .. 30);

case2222;
                            case2222
restart;
l := 2;
                               2
m := 1;
                               1
n := 2;
                               2
k := 1/sqrt(-6*beta*l^2+24*beta*m*n);
                              (1/2)   
                             6        
                          ------------
                                 (1/2)
                          12 beta     
w := alpha/(5*beta*sqrt(l^2-4*m*n));
                            1         
                            -- I alpha
                            10        
                          - ----------
                               beta   

B[0] := -(1/25)*alpha*(5*l^3/(5*sqrt(l^2-4*m*n))-20*l*m*n/(5*sqrt(l^2-4*m*n))-l^2+2*m*n)*sqrt(-6*beta*l^2+24*beta*m*n)*(5*sqrt(l^2-4*m*n))/((l^2-4*m*n)^2*beta);
                                 (1/2)
                          alpha 6     
                          ------------
                                (1/2) 
                          5 beta      
B[1] := -(12/5)*m*alpha*(5*l/(5*sqrt(l^2-4*m*n))-1)/sqrt(-6*beta*l^2+24*beta*m*n);
                     /1   1  \        (1/2)
                     |- + - I| alpha 6     
                     \5   5  /             
                     ----------------------
                               (1/2)       
                           beta            
B[2] := -12*m^2*alpha/(sqrt(-6*beta*l^2+24*beta*m*n)*(5*sqrt(l^2-4*m*n)));
                       1           (1/2)
                       -- I alpha 6     
                       10               
                       -----------------
                               (1/2)    
                           beta         
theta := sqrt(l^2-4*m*n);
                              2 I
xi[0] := 1;
                               1
C := -2;
                               -2
F := -l/(2*m)-theta*tanh((1/2)*theta*xi)/(2*m)+sech((1/2)*theta*xi)/(C*cosh((1/2)*theta*xi)-2*m*sinh((1/2)*theta*xi)/theta);
                                   sec(xi)       
              -1 + tan(xi) + --------------------
                             -2 cos(xi) - sin(xi)

beta := -2;
                               -2
alpha := 3;
                               3

xi := k*x-t*w;
                  1   (1/2)     (1/2)     3     
                - -- 6      (-2)      x - -- I t
                  24                      20    
u := B[0]+B[1]*F+B[2]*F*F;
  3   (1/2)     (1/2)   /  3    3   \  (1/2)     (1/2) /  
- -- 6      (-2)      + |- -- - -- I| 6      (-2)      |-1
  10                    \  10   10  /                  \  

        /1   (1/2)     (1/2)     3     \   /   /1   (1/2) 
   - tan|-- 6      (-2)      x + -- I t| + |sec|-- 6      
        \24                      20    /   \   \24        

      (1/2)     3     \\//      /1   (1/2)     (1/2)     3     \
  (-2)      x + -- I t|| |-2 cos|-- 6      (-2)      x + -- I t|
                20    // \      \24                      20    /

        /1   (1/2)     (1/2)     3     \\\   3     (1/2) 
   + sin|-- 6      (-2)      x + -- I t||| - -- I 6      
        \24                      20    ///   20          

      (1/2) /        /1   (1/2)     (1/2)     3     \   /   /1  
  (-2)      |-1 - tan|-- 6      (-2)      x + -- I t| + |sec|-- 
            \        \24                      20    /   \   \24 

   (1/2)     (1/2)     3     \\//
  6      (-2)      x + -- I t|| |
                       20    // \
      /1   (1/2)     (1/2)     3     \
-2 cos|-- 6      (-2)      x + -- I t|
      \24                      20    /

        /1   (1/2)     (1/2)     3     \\\  
   + sin|-- 6      (-2)      x + -- I t|||^2
        \24                      20    ///  
plot3d(Re(u), x = -30 .. .30, t = -30 .. .30);

t := 0;
                               0
plot([Re(u)], x = -30 .. 30);

plot3d(Im(u), x = -10 .. .10, t = -10 .. .10);
Error, (in plot3d) bad range arguments: x = -10 .. .10, 0 = -10 .. .10
t := 0;
                               0
plot([Im(u)], x = -30 .. 30);

Hi,
I face a problem using Tolerances:-NominalValue and Tolerances:-ToleranceValue on a quantity constructed from add.

Example

restart:
with(Tolerances):
x := 10 &+-1:
y := 20 &+- 2:
z := 3*x+2*y;
NominalValue(z);     
# returns 70 as expected
ToleranceValue(z);   # returns 7 as expected


Now I define another quantity Z this way:

Z := add([3, 2] *~ [x, y]);
(or equivalently add(ListOfCoeffs[k]*ListOfVars[k], k=1..K) where ListOfCoeffs and ListOfVars are previously defined adhoc lists)

Both NominalValue(Z) and ToleranceValue(Z) return an error.
PS: already (and this probably explains that) Z does not appear as 70 +/- 7 but as 3*Interval(...)+2*Interval(...) (lprint confirmed)

How can I obtain NominalValue(Z) and ToleranceValue(Z) when Z comes from 'add' constructor?

There have been several posts, over the years, related to visual cues about the values associated with particular 2D contours in a plot.

Some people ask or post about color-bars [1]. Some people ask or post about inlined labelling of the curves [1, 2, 3, 4, 5, 6, 7]. And some post about mouse popup/hover-over functionality [1]., which got added as general new 2D plot annotation functionality in Maple 2017 and is available for the plots:-contourplot command via its contourlabels option.

Another possibility consists of a legend for 2D contour plots, with distinct entries for each contour value. That is not currently available from the plots:-contourplot command as documented. That may be possible, possibly with effort, from contour-plotting approaches based on individual plots:-implicitplot calls for each contour level [eg. Kitonum's procedure, or an undocumented, alternate internal driver for plots:-contourplot].

Since I like the functionality provided by the contourlabels option I thought that I'd highjack that (and the _HOVERCONTENT plotting substructure that plot-annotations now generate) and get a relatively convenient way to get a color-key via the 2D plotting legend.  This is not supposed to be super-efficient.

Here below are some examples. I hope that it illustrates some useful functionality that could be added to the contourplot command. It can also be used to get a color-key for use with densityplot.

restart;

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 nops(clegend)>0 then
    tempP:=:-plots:-contourplot(ee,rng1,rng2,others[],
                                ':-contourlabels'=rhs(clegend[-1]));
    tempP:=subsindets(tempP,'specfunc(:-_HOVERCONTENT)',
                      u->`if`(has(u,"null"),NULL,':-LEGEND'(op(u))));
    if nops(clabels)>0 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 nops(clabels)>0 then
    return plots:-contourplot(ee,rng1,rng2,others[],
                              ':-contourlabels'=rhs(clabels[-1]));
  else
    return plots:-contourplot(ee,rng1,rng2,others[]);
  end if;
end proc:
 

contplot(x^2+y^2, x=-2..2, y=-2..2,
      coloring=["Yellow","Blue"],
      contours = 9,
      size=[500,400],
      legendstyle = [location = right],
      legend=true,
      contourlabels=true,
      view=[-2.1..2.1,-2.1..2.1]
);

contplot(x^2+y^2, x=-2..2, y=-2..2,
      coloring=["Yellow","Blue"],
      contours = 17,
      size=[500,400],
      legendstyle = [location = right],
      legend=['contourvalue',$("null",7),'contourvalue',$("null",7),'contourvalue'],
      contourlabels=true,
      view=[-2.1..2.1,-2.1..2.1]
);

# Apparently legend items must be unique, to persist on document re-open.

contplot(x^2+y^2, x=-2..2, y=-2..2,
      coloring=["Yellow","Blue"],
      contours = 11,
      size=[500,400],
      legendstyle = [location = right],
      legend=['contourvalue',seq(cat($(` `,i)),i=2..5),
              'contourvalue',seq(cat($(` `,i)),i=6..9),
              'contourvalue'],
      contourlabels=true,
      view=[-2.1..2.1,-2.1..2.1]
);

contplot(x^2+y^2, x=-2..2, y=-2..2,
      coloring=["Green","Red"],
      contours = 8,
      size=[400,450],
      legend=true,
      contourlabels=true
);

contplot(x^2+y^2, x=-2..2, y=-2..2,
      coloring=["Yellow","Blue"],
      contours = 13,
      legend=['contourvalue',$("null",5),'contourvalue',$("null",5),'contourvalue'],
      contourlabels=true
);

(low,high,N):=0.1,7.6,23:
conts:=[seq(low..high*1.01, (high-low)/(N-1))]:
contplot(x^2+y^2, x=-2..2, y=-2..2,
      coloring=["Yellow","Blue"],
      contours = conts,
      legend=['contourvalue',$("null",floor((N-3)/2)),'contourvalue',$("null",ceil((N-3)/2)),'contourvalue'],
      contourlabels=true
);

plots:-display(
  subsindets(contplot((x^2+y^2)^(1/2), x=-2..2, y=-2..2,
                      coloring=["Yellow","Blue"],
                      contours = 7,
                      filledregions),
             specfunc(CURVES),u->NULL),
  contplot((x^2+y^2)^(1/2), x=-2..2, y=-2..2,
      coloring=["Yellow","Blue"],
      contours = 7, #grid=[50,50],
      thickness=0,
      legendstyle = [location=right],
      legend=true),
  size=[600,500],
  view=[-2.1..2.1,-2.1..2.1]
);

 

plots:-display(
  contplot(x^2+y^2, x=-2..2, y=-2..2,
      coloring=["Yellow","Blue"],
      contours = 5,
      thickness=0, filledregions),
  contplot(x^2+y^2, x=-2..2, y=-2..2,
      coloring=["Yellow","Blue"],
      contours = 5,
      thickness=3,
      legendstyle = [location=right],
      legend=typeset("<=",contourvalue)),
  size=[700,600],
  view=[-2.1..2.1,-2.1..2.1]
);

N:=11:
plots:-display(
  contplot(sin(x)*y, x=-2*Pi..2*Pi, y=-1..1,
      coloring=["Yellow","Blue"],
      contours = [seq(-1+(i-1)*(1-(-1))/(N-1),i=1..N)],
      thickness=3,
      legendstyle = [location=right],
      legend=true),
   plots:-densityplot(sin(x)*y, x=-2*Pi..2*Pi, y=-1..1,
      colorscheme=["zgradient",["Yellow","Blue"],colorspace="RGB"],
      grid=[100,100],
      style=surface, restricttoranges),
   plottools:-line([-2*Pi,-1],[-2*Pi,1],thickness=3,color=white),
   plottools:-line([2*Pi,-1],[2*Pi,1],thickness=3,color=white),
   plottools:-line([-2*Pi,1],[2*Pi,1],thickness=3,color=white),
   plottools:-line([-2*Pi,-1],[2*Pi,-1],thickness=3,color=white),
   size=[600,500]
);

N:=13:
plots:-display(
  contplot(sin(x)*y, x=-2*Pi..2*Pi, y=-1..1,
      coloring=["Yellow","Blue"],
      contours = [seq(-1+(i-1)*(1-(-1))/(N-1),i=1..N)],
      thickness=6,
      legendstyle = [location=right],
      legend=['contourvalue',seq(cat($(` `,i)),i=2..3),
              'contourvalue',seq(cat($(` `,i)),i=5..6),
              'contourvalue',seq(cat($(` `,i)),i=8..9),
              'contourvalue',seq(cat($(` `,i)),i=11..12),
              'contourvalue']),
   plots:-densityplot(sin(x)*y, x=-2*Pi..2*Pi, y=-1..1,
      colorscheme=["zgradient",["Yellow","Blue"],colorspace="RGB"],
      grid=[100,100],
      style=surface, restricttoranges),
   plottools:-line([-2*Pi,-1],[-2*Pi,1],thickness=6,color=white),
   plottools:-line([2*Pi,-1],[2*Pi,1],thickness=6,color=white),
   plottools:-line([-2*Pi,1],[2*Pi,1],thickness=6,color=white),
   plottools:-line([-2*Pi,-1],[2*Pi,-1],thickness=6,color=white),
  size=[600,500]
);

 

Download contour_legend_post.mw

 

 

 

Hellow

 

I want to create a function that sort an array with a parametric variable alpha[k]. But Maple ignores the sort command, so the array never gets sorted. Please see attached url to creen capture of the problem:

 

https://www.dropbox.com/s/gjy5zbm4gjwmwdv/sort.png?dl=0

Thnaks

2 3 4 5 6 7 8 Last Page 4 of 1511