acer

32343 Reputation

29 Badges

19 years, 327 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

What do you want to accomplish with PDEtools[PDEplot] ?

The plots below render more nicely in the actual Maple GUI.

restart;

PDE := diff(y(x,t), x,x,x,x)+(diff(y(x, t), t,t))=0;  
# Initial/boundary conditions
  BCs:=y(0,t) = 0, y(1,t) = 0,D[1](y)(0,t)=0,D[1](y)(1,t)=0;

  ICs:=y(x,0) =0, D[2](y)(x,0)=1 ;

diff(diff(diff(diff(y(x, t), x), x), x), x)+diff(diff(y(x, t), t), t) = 0

y(0, t) = 0, y(1, t) = 0, (D[1](y))(0, t) = 0, (D[1](y))(1, t) = 0

y(x, 0) = 0, (D[2](y))(x, 0) = 1

num_solution := pdsolve(PDE, {BCs,ICs}, numeric);

_m139650291560768

P3D := num_solution :-plot3d(x=0..1, t=0..1, grid=[49,149]):
P3D;

P2D := num_solution:-plot(x=0.5, t=0..1,
                          numpoints=200);

plots:-display( P3D,
                plottools:-transform((y,z)->[0.5,y,z])(P2D) );

 

Download pdeplot.mw

I have tried to un-muddle the code you supplied.

 restart:

 with(plots):
 with(LinearAlgebra):

 N:=48:
 a:=4:
 b:=5:
 Boundaries:=y(a)=0,y(b)=0;
 P(x):=1;
Q(x):=1;
R(x):=1;
F(x):=cos(Pi*x^2)*x;
NLPart:=-exp(-sin(y(x)))*y(x)^2/(1+y(x));
Equation:=P(x)*diff(y(x),x$2)+Q(x)*diff(y(x),x$1)+R(x)*NLPart=F(x);
NewtonSolution:=dsolve({Equation,Boundaries},y(x),type=numeric,method=bvp);
PlotNewtonSolution:=odeplot(NewtonSolution,a....b);

y(4) = 0, y(5) = 0

1

1

1

cos(Pi*x^2)*x

-exp(-sin(y(x)))*y(x)^2/(1+y(x))

diff(diff(y(x), x), x)+diff(y(x), x)-exp(-sin(y(x)))*y(x)^2/(1+y(x)) = cos(Pi*x^2)*x

proc (x_bvp) local res, data, solnproc, _ndsol, outpoint, i; option `Copyright (c) 2000 by Waterloo Maple Inc. All rights reserved.`; _EnvDSNumericSaveDigits := Digits; Digits := 15; if _EnvInFsolve = true then outpoint := evalf[_EnvDSNumericSaveDigits](x_bvp) else outpoint := evalf(x_bvp) end if; data := Array(1..4, {(1) = proc (outpoint) local X, Y, YP, yout, errproc, L, V, i; option `Copyright (c) 2000 by Waterloo Maple Inc. All rights reserved.`; X := Vector(34, {(1) = 4.0, (2) = 4.030138644973893, (3) = 4.06252075830933, (4) = 4.094888150822047, (5) = 4.1273438613473, (6) = 4.159816989954734, (7) = 4.192221888318701, (8) = 4.224543576874172, (9) = 4.256754500658247, (10) = 4.288740281823471, (11) = 4.320503853783057, (12) = 4.352072016657196, (13) = 4.383425561385851, (14) = 4.414529862821071, (15) = 4.445402267760153, (16) = 4.476096536048872, (17) = 4.506602115915622, (18) = 4.536942920110194, (19) = 4.567166859568994, (20) = 4.597271660548307, (21) = 4.6272042886208125, (22) = 4.656970737760961, (23) = 4.686560865933606, (24) = 4.715944142556049, (25) = 4.745122769711738, (26) = 4.774117826200048, (27) = 4.802932346972274, (28) = 4.831544048877039, (29) = 4.859951837709859, (30) = 4.88818587510624, (31) = 4.916287717622486, (32) = 4.944266740935822, (33) = 4.972160252377423, (34) = 5.0}, datatype = float[8], order = C_order); Y := Matrix(34, 2, {(1, 1) = .0, (1, 2) = -0.11708553875089373e-1, (2, 1) = 0.13700158767917764e-2, (2, 2) = 0.9660362799838607e-1, (3, 1) = 0.5498870360360167e-2, (3, 2) = .1419348442626504, (4, 1) = 0.9428954357184422e-2, (4, 2) = 0.8482319216100598e-1, (5, 1) = 0.10248208012770309e-1, (5, 2) = -0.3939969111538834e-1, (6, 1) = 0.7033593582560118e-2, (6, 2) = -.14868069760447897, (7, 1) = 0.1600320348522399e-2, (7, 2) = -.16808953622046421, (8, 1) = -0.268933454539153e-2, (8, 2) = -0.8270099569678202e-1, (9, 1) = -0.3221761013229303e-2, (9, 2) = 0.50092222673243834e-1, (10, 1) = 0.22956375918981573e-4, (10, 2) = .13857344513822856, (11, 1) = 0.4458505738284509e-2, (11, 2) = .12165303944158753, (12, 1) = 0.6723232053320422e-2, (12, 2) = 0.11140849003640395e-1, (13, 1) = 0.4998774025578387e-2, (13, 2) = -.11597918116164978, (14, 1) = 0.2649537110120204e-3, (14, 2) = -.17100444754563116, (15, 1) = -0.4430341756673352e-2, (15, 2) = -.11562972551238226, (16, 1) = -0.6104139891975028e-2, (16, 2) = 0.12092543179268235e-1, (17, 1) = -0.3874935987353878e-2, (17, 2) = .12366340298254656, (18, 1) = 0.43859249363331924e-3, (18, 2) = .14153191792478992, (19, 1) = 0.35974417547445185e-2, (19, 2) = 0.5291963406316792e-1, (20, 1) = 0.31797732360206703e-2, (20, 2) = -0.8032529122966872e-1, (21, 1) = -0.7029622818499879e-3, (21, 2) = -.16396730152505634, (22, 1) = -0.5492629827069677e-2, (22, 2) = -.13856716126876822, (23, 1) = -0.8008561926513108e-2, (23, 2) = -0.2171776099723813e-1, (24, 1) = -0.6701651609005721e-2, (24, 2) = .10400796028481248, (25, 1) = -0.27284860400601544e-2, (25, 2) = .1499884923488127, (26, 1) = 0.912205309588295e-3, (26, 2) = 0.8407403812966995e-1, (27, 1) = 0.15002731096950745e-2, (27, 2) = -0.4700893187998446e-1, (28, 1) = -0.15002344923093747e-2, (28, 2) = -.15056675043141238, (29, 1) = -0.6098673162178434e-2, (29, 2) = -.15372747280171484, (30, 1) = -0.922048274432461e-2, (30, 2) = -0.5432127608652006e-1, (31, 1) = -0.8851259497357482e-2, (31, 2) = 0.7813403552233018e-1, (32, 1) = -0.5422519739930223e-2, (32, 2) = .1505909374737268, (33, 1) = -0.15020236105948985e-2, (33, 2) = .111689562356771, (34, 1) = .0, (34, 2) = -0.11682217943418692e-1}, datatype = float[8], order = C_order); YP := Matrix(34, 2, {(1, 1) = -0.11708553875089373e-1, (1, 2) = 4.011708553875089, (2, 1) = 0.9660362799838607e-1, (2, 2) = 2.8236981576549516, (3, 1) = .1419348442626504, (3, 2) = -.1939107397989705, (4, 1) = 0.8482319216100598e-1, (4, 2) = -3.140214946215932, (5, 1) = -0.3939969111538834e-1, (5, 2) = -4.06296249155511, (6, 1) = -.14868069760447897, (6, 2) = -2.2530415764364617, (7, 1) = -.16808953622046421, (7, 2) = 1.1432165535554593, (8, 1) = -0.8270099569678202e-1, (8, 2) = 3.827139451569766, (9, 1) = 0.50092222673243834e-1, (9, 2) = 3.907950868344983, (10, 1) = .13857344513822856, (10, 2) = 1.2723607743919638, (11, 1) = .12165303944158753, (11, 2) = -2.2829064857596433, (12, 1) = 0.11140849003640395e-1, (12, 2) = -4.287435146582237, (13, 1) = -.11597918116164978, (13, 2) = -3.3099458846836973, (14, 1) = -.17100444754563116, (14, 2) = 0.5644385583296996e-2, (15, 1) = -.11562972551238226, (15, 2) = 3.3714761127314947, (16, 1) = 0.12092543179268235e-1, (16, 2) = 4.43632684217126, (17, 1) = .12366340298254656, (17, 2) = 2.4157267006515353, (18, 1) = .14153191792478992, (18, 2) = -1.3229052410514246, (19, 1) = 0.5291963406316792e-1, (19, 2) = -4.179354075542915, (20, 1) = -0.8032529122966872e-1, (20, 2) = -4.110187332162933, (21, 1) = -.16396730152505634, (21, 2) = -1.1127422482319964, (22, 1) = -.13856716126876822, (22, 2) = 2.7243688727683266, (23, 1) = -0.2171776099723813e-1, (23, 2) = 4.678157648740803, (24, 1) = .10400796028481248, (24, 2) = 3.332502712593583, (25, 1) = .1499884923488127, (25, 2) = -.39122670466449067, (26, 1) = 0.8407403812966995e-1, (26, 2) = -3.876509041901599, (27, 1) = -0.4700893187998446e-1, (27, 2) = -4.646231873073153, (28, 1) = -.15056675043141238, (28, 2) = -2.126096148715866, (29, 1) = -.15372747280171484, (29, 2) = 1.9305021938308524, (30, 1) = -0.5432127608652006e-1, (30, 2) = 4.675861822052817, (31, 1) = 0.7813403552233018e-1, (31, 2) = 4.154505645313669, (32, 1) = .1505909374737268, (32, 2) = .6876622361674014, (33, 1) = .111689562356771, (33, 2) = -3.3095888773870232, (34, 1) = -0.11682217943418692e-1, (34, 2) = -4.988317782056582}, datatype = float[8], order = C_order); errproc := proc (x_bvp) local outpoint, X, Y, yout, L, V, i; option `Copyright (c) 2000 by Waterloo Maple Inc. All rights reserved.`; Digits := 15; outpoint := evalf(x_bvp); X := Vector(34, {(1) = 4.0, (2) = 4.030138644973893, (3) = 4.06252075830933, (4) = 4.094888150822047, (5) = 4.1273438613473, (6) = 4.159816989954734, (7) = 4.192221888318701, (8) = 4.224543576874172, (9) = 4.256754500658247, (10) = 4.288740281823471, (11) = 4.320503853783057, (12) = 4.352072016657196, (13) = 4.383425561385851, (14) = 4.414529862821071, (15) = 4.445402267760153, (16) = 4.476096536048872, (17) = 4.506602115915622, (18) = 4.536942920110194, (19) = 4.567166859568994, (20) = 4.597271660548307, (21) = 4.6272042886208125, (22) = 4.656970737760961, (23) = 4.686560865933606, (24) = 4.715944142556049, (25) = 4.745122769711738, (26) = 4.774117826200048, (27) = 4.802932346972274, (28) = 4.831544048877039, (29) = 4.859951837709859, (30) = 4.88818587510624, (31) = 4.916287717622486, (32) = 4.944266740935822, (33) = 4.972160252377423, (34) = 5.0}, datatype = float[8], order = C_order); Y := Matrix(34, 2, {(1, 1) = .0, (1, 2) = 0.27327112092203225e-7, (2, 1) = 0.978775060790798e-10, (2, 2) = 0.48529249007737746e-7, (3, 1) = -0.5409380029321304e-8, (3, 2) = 0.7538318387144695e-7, (4, 1) = -0.12045635038481313e-7, (4, 2) = 0.7308674897744689e-7, (5, 1) = -0.14823793655844814e-7, (5, 2) = 0.3852146210517772e-7, (6, 1) = -0.10568187054027944e-7, (6, 2) = -0.8489883548987247e-8, (7, 1) = -0.11128964228786468e-8, (7, 2) = -0.35558307183813596e-7, (8, 1) = 0.7732637048013274e-8, (8, 2) = -0.2210302159189014e-7, (9, 1) = 0.10164440310941924e-7, (9, 2) = 0.24447922129778563e-7, (10, 1) = 0.483962860909516e-8, (10, 2) = 0.7079862076004938e-7, (11, 1) = -0.3969150619899016e-8, (11, 2) = 0.8392038080023722e-7, (12, 1) = -0.9656967240921232e-8, (12, 2) = 0.53832229684224287e-7, (13, 1) = -0.7760495700261479e-8, (13, 2) = 0.8649668118906003e-9, (14, 1) = 0.7144312944825714e-9, (14, 2) = -0.3802894725149483e-7, (15, 1) = 0.10213436390765505e-7, (15, 2) = -0.3636870220284489e-7, (16, 1) = 0.14642824306539772e-7, (16, 2) = 0.4451544095413321e-8, (17, 1) = 0.11315681709129736e-7, (17, 2) = 0.5558209115158183e-7, (18, 1) = 0.29255095886161705e-8, (18, 2) = 0.8078375988497181e-7, (19, 1) = -0.4383642048557253e-8, (19, 2) = 0.6115682507735523e-7, (20, 1) = -0.4993426509629615e-8, (20, 2) = 0.8711261106962578e-8, (21, 1) = 0.1963407280965595e-8, (21, 2) = -0.396438348246792e-7, (22, 1) = 0.11869871997257991e-7, (22, 2) = -0.49592185982409896e-7, (23, 1) = 0.17985978666981787e-7, (23, 2) = -0.1390789173583301e-7, (24, 1) = 0.16324710055000545e-7, (24, 2) = 0.4137831006851972e-7, (25, 1) = 0.8522492508408787e-8, (25, 2) = 0.765805213315824e-7, (26, 1) = 0.421071518722858e-9, (26, 2) = 0.6681647497614776e-7, (27, 1) = -0.20131882330223897e-8, (27, 2) = 0.1892897982999753e-7, (28, 1) = 0.30707192791035046e-8, (28, 2) = -0.33002220069799734e-7, (29, 1) = 0.12148844202097171e-7, (29, 2) = -0.5265154226857148e-7, (30, 1) = 0.1908501428418955e-7, (30, 2) = -0.26871524839094744e-7, (31, 1) = 0.1930670085286513e-7, (31, 2) = 0.26219913369224307e-7, (32, 1) = 0.1283240224899888e-7, (32, 2) = 0.6900543603752283e-7, (33, 1) = 0.4319930491976274e-8, (33, 2) = 0.7049112852700384e-7, (34, 1) = .0, (34, 2) = 0.27547706106614173e-7}, datatype = float[8], order = C_order); if not type(outpoint, 'numeric') then if outpoint = "start" or outpoint = "left" then return X[1] elif outpoint = "right" then return X[34] elif outpoint = "order" then return 6 elif outpoint = "error" then return HFloat(8.392038080023722e-8) elif outpoint = "errorproc" then error "this is already the error procedure" elif outpoint = "rawdata" then return [2, 34, [y(x), diff(y(x), x)], X, Y] else return ('procname')(x_bvp) end if end if; if outpoint < X[1] or X[34] < outpoint then error "solution is only defined in the range %1..%2", X[1], X[34] end if; V := array([1 = 4, 2 = 0]); if Digits <= trunc(evalhf(Digits)) then L := Vector(4, 'datatype' = 'float'[8]); yout := Vector(2, 'datatype' = 'float'[8]); evalhf(`dsolve/numeric/lagrange`(34, 2, X, Y, outpoint, var(yout), var(L), var(V))) else L := Vector(4, 'datatype' = 'sfloat'); yout := Vector(2, 'datatype' = 'sfloat'); `dsolve/numeric/lagrange`(34, 2, X, Y, outpoint, yout, L, V) end if; [x = outpoint, seq('[y(x), diff(y(x), x)]'[i] = yout[i], i = 1 .. 2)] end proc; if not type(outpoint, 'numeric') then if outpoint = "start" or outpoint = "left" then return X[1] elif outpoint = "method" then return "bvp" elif outpoint = "right" then return X[34] elif outpoint = "order" then return 6 elif outpoint = "error" then return HFloat(8.392038080023722e-8) elif outpoint = "errorproc" then return eval(errproc) elif outpoint = "rawdata" then return [2, 34, "depnames", X, Y, YP] else error "non-numeric value" end if end if; if outpoint < X[1] or X[34] < outpoint then error "solution is only defined in the range %1..%2", X[1], X[34] end if; if Digits <= trunc(evalhf(Digits)) and (_EnvInFsolve <> true or _EnvDSNumericSaveDigits <= trunc(evalhf(Digits))) then V := array( 1 .. 6, [( 1 ) = (7), ( 2 ) = (0), ( 3 ) = (false), ( 4 ) = (false), ( 5 ) = (false), ( 6 ) = (false)  ] ); L := Matrix(7, 2, {(1, 1) = .0, (1, 2) = .0, (2, 1) = .0, (2, 2) = .0, (3, 1) = .0, (3, 2) = .0, (4, 1) = .0, (4, 2) = .0, (5, 1) = .0, (5, 2) = .0, (6, 1) = .0, (6, 2) = .0, (7, 1) = .0, (7, 2) = .0}, datatype = float[8], order = C_order); yout := Vector(2, {(1) = .0, (2) = .0}, datatype = float[8]); evalhf(`dsolve/numeric/hermite`(34, 2, X, Y, YP, outpoint, var(yout), var(L), var(V))) else if _EnvInFsolve = true then Digits := _EnvDSNumericSaveDigits end if; V := array( 1 .. 6, [( 1 ) = (7), ( 2 ) = (0), ( 3 ) = (false), ( 4 ) = (false), ( 5 ) = (false), ( 6 ) = (false)  ] ); L := Matrix(7, 2, {(1, 1) = 0., (1, 2) = 0., (2, 1) = 0., (2, 2) = 0., (3, 1) = 0., (3, 2) = 0., (4, 1) = 0., (4, 2) = 0., (5, 1) = 0., (5, 2) = 0., (6, 1) = 0., (6, 2) = 0., (7, 1) = 0., (7, 2) = 0.}, order = C_order); yout := Vector(2, {(1) = 0., (2) = 0.}); `dsolve/numeric/hermite`(34, 2, X, Y, YP, outpoint, yout, L, V) end if; [outpoint, seq(yout[i], i = 1 .. 2)] end proc, (2) = Array(0..0, {}), (3) = [x, y(x), diff(y(x), x)], (4) = 0}); solnproc := data[1]; if not type(outpoint, 'numeric') then if outpoint = "solnprocedure" then return eval(solnproc) elif member(outpoint, ["start", "left", "right", "errorproc", "rawdata", "order", "error"]) then return solnproc(x_bvp) elif outpoint = "sysvars" then return data[3] elif procname <> unknown then return ('procname')(x_bvp) else _ndsol := pointto(data[2][0]); return ('_ndsol')(x_bvp) end if end if; try res := solnproc(outpoint); [x = res[1], seq('[y(x), diff(y(x), x)]'[i] = res[i+1], i = 1 .. 2)] catch: error  end try end proc


delta[0]:=unapply(piecewise(j=k,1,j<>k,0),j,k):
delta[1]:=unapply(piecewise(j=k,0,j<>k,((-1)^(k-j))/(k-j)),j,k):
delta[2]:=unapply(piecewise(j=k,(-Pi^2)/3,j<>k,-2*(-1)^(k-j)/(k-j)^2),j,k):
d:=Pi/2:
h:=2/sqrt(N):
xk:=unapply((a+b*exp(k*h))/(1+exp(k*h)),k):
phi:=unapply(log((x-a)/(b-x)),x);
Dphi:=unapply(simplify(diff(phi(x),x)),x):
D2phi:=unapply(simplify(diff(phi(x),x$2)),x):
w:=unapply(1/Dphi(x),x):
Dw:=unapply(simplify(diff(w(x),x$1)),x):
D2w:=unapply(simplify(diff(w(x),x$2)),x):
MatrixSystem:=[]:
for p from -N to N
do
MatrixSystem:=[op(MatrixSystem),
h*(sum(c[j]*( (1/h^2)*delta[2](p,j)*(Dphi(xk(j))*subs(x=xk(j),P(x)*w(x)))+ (1/h^1)*delta[1](p,j)*(
(D2phi(xk(j))/Dphi(xk(j)))*subs(x=xk(j),P(x)*w(x))+2*subs(x=xk(j),
diff(P(x)*w(x),x))) + (1/h^0)*delta[0](p,j)*((subs(x=xk(j),
diff(P(x)*w(x),x$2))/Dphi(xk(j))))),j=-N..N)
-sum(c[j]*( (1/h^1)*delta[1](p,j)*(subs(x=xk(j),Q(x)*w(x)))+
(1/h^0)*delta[0](p,j)*(subs(x=xk(j),diff(Q(x)*w(x),x))) /Dphi(xk(j))
),j=-N..N)
+subs(y(x)=c[p],NLPart)*subs(x=xk(p),w(x)*R(x))/Dphi(xk(p))
-subs(x=xk(p),w(x)*F(x))/Dphi(xk(p)))=0]:
od:

proc (x) options operator, arrow; ln((x-4)/(5-x)) end proc

CC:=fsolve(evalf(MatrixSystem)):

C:=Vector(2*N+1,(j)->eval(c[j-N-1],CC),datatype=float[8]);

C := Vector(4, {(1) = ` 1 .. 97 `*Vector[column], (2) = `Data Type: `*float[8], (3) = `Storage: `*rectangular, (4) = `Order: `*Fortran_order})

ApproximateSol:=unapply('add(evalf(C[j+N+1]*sin(Pi*(phi(x)-j*h)/h)/(Pi*(phi(x)-
j*h)/h)),j=-N..N)',x,numeric):

ApproximateSol(4.1);

HFloat(0.009832017093837749)

a,b;
plot({ApproximateSol(x)},x=a..b,color=green,style=point,symbol=solidcircle);
`Sinc-GalerkinPlot`:=%:

4, 5

display({`Sinc-GalerkinPlot`, PlotNewtonSolution }, title =
"Sinc-GalerkinApproximation",
labels=["x","y"]);

 

Download sinc_method_example_ac.mw

restart;

C := [0,1/11],[1/11,1/9],[1/9, 1/7],[1/3,1/2],[1/2,1]:

op(map(`[]`@op,[solve(Or(op(map(r->__dum>=r[1] and __dum<=r[2],[C]))))]));

                         [   1]  [1   ]
                         [0, -], [-, 1]
                         [   7]  [3   ]

lprint(%);
  [0, 1/7], [1/3, 1]

restart;

isolve({(x-6)^2+(y+2)^2 = 225, (x+1)^2+(y+3)^2 = 125});

{x = -6, y = 7}, {x = -3, y = -14}

isolve({(x-19)^2+(y-11)^2 = 225, (x+1)^2+(y+3)^2 = 125});

{x = 10, y = -1}

temp := {solve({(x-19)^2+(y-11)^2 = 225, (x+1)^2+(y+3)^2 = 125})};

{{x = 10, y = -1}, {x = 692/149, y = 991/149}}

select(u->eval([x,y],u)::[integer,integer],temp);

{{x = 10, y = -1}}

 

Download solve_integer.mw

We can generate results for each a,b pair via a pair of nested seq calls. And we can accept or reject such candidates according to whether they each pass a conditonal test within the procedure which generates them.

Naturally, you could add whatever else you want to the conditional test (if...then) within procedure G. (note: the restrictions you were originally placing on a,b,x,y don't seem to follow from the problem description you gave. I mean, where you had nops({a, b, x, y}) = 4 and x*y*a*b <> 0)

restart;

G:=proc(a,b)
     local temp;
     temp := {isolve({(x-a)^2+(y-b)^2 = 225, (x+1)^2+(y+3)^2 = 125})};
     if nops(temp)=2 then
       return {[a,b],temp};
     else
       return NULL;
     end if;
end proc:

ans := seq(seq(G(a,b),b=-20..20),a=-20..20):

seq(print(u), u=ans):

{[-15, -5], {{x = -6, y = 7}, {x = -3, y = -14}}}

{[-15, -1], {{x = -6, y = -13}, {x = -3, y = 8}}}

{[-11, -13], {{x = -11, y = 2}, {x = 4, y = -13}}}

{[-11, 7], {{x = -11, y = -8}, {x = 4, y = 7}}}

{[-11, 17], {{x = -11, y = 2}, {x = 1, y = 8}}}

{[-8, -4], {{x = 1, y = 8}, {x = 4, y = -13}}}

{[-8, -2], {{x = 1, y = -14}, {x = 4, y = 7}}}

{[-6, -8], {{x = -6, y = 7}, {x = 9, y = -8}}}

{[-6, 2], {{x = -6, y = -13}, {x = 9, y = 2}}}

{[-5, -5], {{x = 4, y = 7}, {x = 10, y = -5}}}

{[-5, -1], {{x = 4, y = -13}, {x = 10, y = -1}}}

{[-3, -17], {{x = -12, y = -5}, {x = 9, y = -8}}}

{[-3, -7], {{x = -3, y = 8}, {x = 9, y = 2}}}

{[-3, 1], {{x = -3, y = -14}, {x = 9, y = -8}}}

{[-3, 11], {{x = -12, y = -1}, {x = 9, y = 2}}}

{[-2, -10], {{x = -11, y = 2}, {x = 10, y = -1}}}

{[-2, 4], {{x = -11, y = -8}, {x = 10, y = -5}}}

{[0, -10], {{x = -12, y = -1}, {x = 9, y = 2}}}

{[0, 4], {{x = -12, y = -5}, {x = 9, y = -8}}}

{[1, -17], {{x = -11, y = -8}, {x = 10, y = -5}}}

{[1, -7], {{x = -11, y = 2}, {x = 1, y = 8}}}

{[1, 1], {{x = -11, y = -8}, {x = 1, y = -14}}}

{[1, 11], {{x = -11, y = 2}, {x = 10, y = -1}}}

{[3, -5], {{x = -12, y = -5}, {x = -6, y = 7}}}

{[3, -1], {{x = -12, y = -1}, {x = -6, y = -13}}}

{[4, -8], {{x = -11, y = -8}, {x = 4, y = 7}}}

{[4, 2], {{x = -11, y = 2}, {x = 4, y = -13}}}

{[6, -4], {{x = -6, y = -13}, {x = -3, y = 8}}}

{[6, -2], {{x = -6, y = 7}, {x = -3, y = -14}}}

{[9, -13], {{x = -6, y = -13}, {x = 9, y = 2}}}

{[9, 7], {{x = -6, y = 7}, {x = 9, y = -8}}}

{[9, 17], {{x = -3, y = 8}, {x = 9, y = 2}}}

{[13, -5], {{x = 1, y = -14}, {x = 4, y = 7}}}

{[13, -1], {{x = 1, y = 8}, {x = 4, y = -13}}}

{[19, -13], {{x = 4, y = -13}, {x = 10, y = -1}}}

{[19, 7], {{x = 4, y = 7}, {x = 10, y = -5}}}

 

Download solve_integer_2.mw

Here is one way.

student_md_question_ac.mw

You can find several older posts on this topic by searching this site for the word colorbar. Eg, [1], [2], [3] .

The 2+3 becomes 5 due to automatic simplification. That's not something that's going to be able to help you with your second example.

One way to construct a procedure (operator) from a given expression is to use the unapply command.

example2 := unapply( int(1,y), x );

                       example2 := x -> y

example3 := unapply( int(sin(x*y),y), x );

                                     cos(x y)
                  example3 := x -> - --------
                                        x    
example3( 17 );

                           1           
                         - -- cos(17 y)
                           17          

One way is to pull the units out of the the two columns, separately.

You haven't told us what units you want have for the results. Is it foot and day?

restart;

kernelopts(version);

`Maple 2018.1, X86 64 LINUX, Jun 8 2018, Build ID 1321769`

M:=Matrix([[0.,              0.],
           [0.2697*Unit(ft), 0.3613*Unit(ft^2*d/inch^2)],
           [0.3821*Unit(ft), 0.7225*Unit(ft^2*d/inch^2)],
           [0.5352*Unit(ft), 1.4123*Unit(ft^2*d/inch^2)]]);

Matrix(4, 2, {(1, 1) = 0., (1, 2) = 0., (2, 1) = .2697*Units:-Unit(ft), (2, 2) = .3613*Units:-Unit(ft^2*d/`in`^2), (3, 1) = .3821*Units:-Unit(ft), (3, 2) = .7225*Units:-Unit(ft^2*d/`in`^2), (4, 1) = .5352*Units:-Unit(ft), (4, 2) = 1.4123*Units:-Unit(ft^2*d/`in`^2)})

Units:-UseUnit(d):
Units:-UseUnit(ft):

T1 := combine~(M[-1,1],units);
#T1 := M[-1,1];
convert~(T1,unit_free,'u1'):
u1;
M1 := simplify(M[..,1]/u1);

T1 := .5352*Unit('ft')

Unit('ft')

Vector[column](%id = 18446884055612239614)

T2 := combine~(M[-1,2],units);
#T2 := M[-1,2];
convert~(T2,unit_free,'u2'):
u2;
M2 := simplify(M[..,2]/u2);

T2 := 203.3712*Unit('d')

Unit('d')

Vector[column](%id = 18446884055612215654)

plot(M1, M2, labels=[u1,u2]);

 

Download plot_column_units.mw

Which level did you use for the interface setting prettyprint? Was it 0, or 1?

I have been seeing weird behavior with interface(prettyprint=0) for a while now, when using the Standard GUI.

So it you are trying to use writeto from within the Standard GUI (and presuming you are not just using printf calls) then you might want to see if you can get by with the setting interface(prettyprint=1) .

This looks kludgy at best, and perhaps suspect at worst, but for this example...

restart;

eqn := 5*(x*y)^2+x/sqrt(y) = x^2+2*(3*x^3+y^2)^3:

foo := implicitdiff(eqn, x, y);

-(1/2)*(24*y^(13/2)+144*x^3*y^(9/2)+216*x^6*y^(5/2)-20*x^2*y^(5/2)+x)/(54*x^2*y^(11/2)+324*x^5*y^(7/2)+486*x^8*y^(3/2)-10*x*y^(7/2)+2*x*y^(3/2)-y)

eqn2 := subsindets(eqn, `^`(`+`,anything), u->H(op(1,u))^op(2,u));

5*x^2*y^2+x/y^(1/2) = x^2+2*H(3*x^3+y^2)^3

implicitdiff(eqn2 , x, y);

-(1/2)*(24*H(3*x^3+y^2)^2*(D(H))(3*x^3+y^2)*y^(5/2)-20*x^2*y^(5/2)+x)/(54*H(3*x^3+y^2)^2*(D(H))(3*x^3+y^2)*x^2*y^(3/2)-10*x*y^(7/2)+2*x*y^(3/2)-y)

bar := eval(%, H=(u->u));

-(1/2)*(24*(3*x^3+y^2)^2*y^(5/2)-20*x^2*y^(5/2)+x)/(54*(3*x^3+y^2)^2*x^2*y^(3/2)-10*x*y^(7/2)+2*x*y^(3/2)-y)

simplify(foo-bar);

0

 

Download kludge.mw

[edit] I think that I prefer the following form, with radnormal as an intermediate step, since the following form behaves nicer under simplify.

eqn := 5*(x*y)^2+x/sqrt(y) = x^2+2*(3*x^3+y^2)^3:
 

eval(radnormal(implicitdiff(subsindets(eqn, `^`(`+`,anything),
                                       u->H(op(1,u))^op(2,u)),
                            x, y)), H=(u->u));
 

(1/2)*(-24*y^3*(3*x^3+y^2)^2+20*y^3*x^2-y^(1/2)*x)/(y*(54*y*(3*x^3+y^2)^2*x^2-10*y^3*x+2*x*y-y^(1/2)))

 

 

You can use the print command.

You could simply use rand here.

restart;

LetList := [C, E, F, H, K, P, T, W, X, Y]:

gen:=rand(1..nops(LetList)):

gen();
                               7

LetList[gen()];
                               Y

LetList[gen()];
                               P

LetList[['gen()'$5]];
                        [E, H, P, K, C]

It is, of course, trivial to scale the results below by the appropriate 1/2^k , simply by multiplying the generated Matrix by that factor. Or you can scale the two Matrix arguments passed into the procedure Gen.

restart;

interface(rtablesize=100):

with(LinearAlgebra):

M:=3:

F:=Matrix(M,M):
F[1,1] := 2:
F;

Matrix(3, 3, {(1, 1) = 2, (1, 2) = 0, (1, 3) = 0, (2, 1) = 0, (2, 2) = 0, (2, 3) = 0, (3, 1) = 0, (3, 2) = 0, (3, 3) = 0})

L:=Matrix(M,M):
L:=LinearAlgebra[BandMatrix]([
      [seq(-sqrt(2*i-1)/(2*i-1)*sqrt(2*i-3),i=2..M)],
      [1,seq(0*i,i=1..M-1)],
      [seq((sqrt(2*i-3))/((2*i-3)*sqrt(2*i-1)),i=2..M)]]);

Matrix(3, 3, {(1, 1) = 1, (1, 2) = (1/3)*sqrt(3), (1, 3) = 0, (2, 1) = -(1/3)*sqrt(3), (2, 2) = 0, (2, 3) = (1/15)*sqrt(5)*sqrt(3), (3, 1) = 0, (3, 2) = -(1/5)*sqrt(5)*sqrt(3), (3, 3) = 0})

Gen:=proc(K::posint,A,B)
  Matrix(scan=triangular[upper],[seq([A,seq(B,i=j..2^(K-1)-1)],j=1..2^(K-1))]);
end proc:

 

Gen(2, LL, FF);

Matrix(2, 2, {(1, 1) = LL, (1, 2) = FF, (2, 1) = 0, (2, 2) = LL})

Gen(3, LL, FF);

Matrix(4, 4, {(1, 1) = LL, (1, 2) = FF, (1, 3) = FF, (1, 4) = FF, (2, 1) = 0, (2, 2) = LL, (2, 3) = FF, (2, 4) = FF, (3, 1) = 0, (3, 2) = 0, (3, 3) = LL, (3, 4) = FF, (4, 1) = 0, (4, 2) = 0, (4, 3) = 0, (4, 4) = LL})

 

Gen(2, L, F);

Matrix(6, 6, {(1, 1) = 1, (1, 2) = (1/3)*sqrt(3), (1, 3) = 0, (1, 4) = 2, (1, 5) = 0, (1, 6) = 0, (2, 1) = -(1/3)*sqrt(3), (2, 2) = 0, (2, 3) = (1/15)*sqrt(5)*sqrt(3), (2, 4) = 0, (2, 5) = 0, (2, 6) = 0, (3, 1) = 0, (3, 2) = -(1/5)*sqrt(5)*sqrt(3), (3, 3) = 0, (3, 4) = 0, (3, 5) = 0, (3, 6) = 0, (4, 1) = 0, (4, 2) = 0, (4, 3) = 0, (4, 4) = 1, (4, 5) = (1/3)*sqrt(3), (4, 6) = 0, (5, 1) = 0, (5, 2) = 0, (5, 3) = 0, (5, 4) = -(1/3)*sqrt(3), (5, 5) = 0, (5, 6) = (1/15)*sqrt(5)*sqrt(3), (6, 1) = 0, (6, 2) = 0, (6, 3) = 0, (6, 4) = 0, (6, 5) = -(1/5)*sqrt(5)*sqrt(3), (6, 6) = 0})

 

Gen(3, L, F);

Matrix(12, 12, {(1, 1) = 1, (1, 2) = (1/3)*sqrt(3), (1, 3) = 0, (1, 4) = 2, (1, 5) = 0, (1, 6) = 0, (1, 7) = 2, (1, 8) = 0, (1, 9) = 0, (1, 10) = 2, (1, 11) = 0, (1, 12) = 0, (2, 1) = -(1/3)*sqrt(3), (2, 2) = 0, (2, 3) = (1/15)*sqrt(5)*sqrt(3), (2, 4) = 0, (2, 5) = 0, (2, 6) = 0, (2, 7) = 0, (2, 8) = 0, (2, 9) = 0, (2, 10) = 0, (2, 11) = 0, (2, 12) = 0, (3, 1) = 0, (3, 2) = -(1/5)*sqrt(5)*sqrt(3), (3, 3) = 0, (3, 4) = 0, (3, 5) = 0, (3, 6) = 0, (3, 7) = 0, (3, 8) = 0, (3, 9) = 0, (3, 10) = 0, (3, 11) = 0, (3, 12) = 0, (4, 1) = 0, (4, 2) = 0, (4, 3) = 0, (4, 4) = 1, (4, 5) = (1/3)*sqrt(3), (4, 6) = 0, (4, 7) = 2, (4, 8) = 0, (4, 9) = 0, (4, 10) = 2, (4, 11) = 0, (4, 12) = 0, (5, 1) = 0, (5, 2) = 0, (5, 3) = 0, (5, 4) = -(1/3)*sqrt(3), (5, 5) = 0, (5, 6) = (1/15)*sqrt(5)*sqrt(3), (5, 7) = 0, (5, 8) = 0, (5, 9) = 0, (5, 10) = 0, (5, 11) = 0, (5, 12) = 0, (6, 1) = 0, (6, 2) = 0, (6, 3) = 0, (6, 4) = 0, (6, 5) = -(1/5)*sqrt(5)*sqrt(3), (6, 6) = 0, (6, 7) = 0, (6, 8) = 0, (6, 9) = 0, (6, 10) = 0, (6, 11) = 0, (6, 12) = 0, (7, 1) = 0, (7, 2) = 0, (7, 3) = 0, (7, 4) = 0, (7, 5) = 0, (7, 6) = 0, (7, 7) = 1, (7, 8) = (1/3)*sqrt(3), (7, 9) = 0, (7, 10) = 2, (7, 11) = 0, (7, 12) = 0, (8, 1) = 0, (8, 2) = 0, (8, 3) = 0, (8, 4) = 0, (8, 5) = 0, (8, 6) = 0, (8, 7) = -(1/3)*sqrt(3), (8, 8) = 0, (8, 9) = (1/15)*sqrt(5)*sqrt(3), (8, 10) = 0, (8, 11) = 0, (8, 12) = 0, (9, 1) = 0, (9, 2) = 0, (9, 3) = 0, (9, 4) = 0, (9, 5) = 0, (9, 6) = 0, (9, 7) = 0, (9, 8) = -(1/5)*sqrt(5)*sqrt(3), (9, 9) = 0, (9, 10) = 0, (9, 11) = 0, (9, 12) = 0, (10, 1) = 0, (10, 2) = 0, (10, 3) = 0, (10, 4) = 0, (10, 5) = 0, (10, 6) = 0, (10, 7) = 0, (10, 8) = 0, (10, 9) = 0, (10, 10) = 1, (10, 11) = (1/3)*sqrt(3), (10, 12) = 0, (11, 1) = 0, (11, 2) = 0, (11, 3) = 0, (11, 4) = 0, (11, 5) = 0, (11, 6) = 0, (11, 7) = 0, (11, 8) = 0, (11, 9) = 0, (11, 10) = -(1/3)*sqrt(3), (11, 11) = 0, (11, 12) = (1/15)*sqrt(5)*sqrt(3), (12, 1) = 0, (12, 2) = 0, (12, 3) = 0, (12, 4) = 0, (12, 5) = 0, (12, 6) = 0, (12, 7) = 0, (12, 8) = 0, (12, 9) = 0, (12, 10) = 0, (12, 11) = -(1/5)*sqrt(5)*sqrt(3), (12, 12) = 0})

 

Download block_band_matrix.mw

Using Maple 2015.2,

convert(hypergeom([a, b], [c], 1), StandardFunctions);

                   GAMMA(c) GAMMA(c - a - b)
                   -------------------------
                   GAMMA(c - a) GAMMA(c - b)

convert( hypergeom([a, b], [c], 1), GAMMA_related );

                   GAMMA(c) GAMMA(c - a - b)
                   -------------------------
                   GAMMA(c - a) GAMMA(c - b)

Also,

restart;

kernelopts(version);

    Maple 2015.2, X86 64 LINUX, Dec 20 2015, Build ID 1097895

 simplify( hypergeom([a, b], [c], 1) );

              GAMMA(c) GAMMA(c - a - b)
              -------------------------
              GAMMA(c - a) GAMMA(c - b)
restart;

kernelopts(version);

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

simplify( hypergeom([a, b], [c], 1) );

              GAMMA(c) GAMMA(c - a - b)
              -------------------------
              GAMMA(c - a) GAMMA(c - b)

I don't understand why some of your Questions are marked as Maple version 2015, and some with version 18, and some with 2018.

If you expression attains it maximum at the end-point x=100, for each R, then could you not just divide by the value there? I mean, divide the original expression by the expression evaluated at x=100.

Let's pretend that your example would not have that behaviour, and that the maximum value is attained at a different numeric x for each different numeric R.

More generally, you can construct a procedure that admits the value val for the parameter name nm, and then optimizes w.r.t. x=1..100. And this procedure could be made to return unevaluated if its first argument val is not a numeric value. And then you could plot the original expression divided by a call to that maximizing procedure.

The plot3d command would pass in different values for val.

The procedure could attempt to remember the return value for given values of val, since plot3d will pump in the same val several times (as it computes for both different x and different R, say).
 

restart;

Xmax:=proc(val,expr,nm::name)
  option remember, system;
  local res, xvar;
  if not val::numeric then return 'procname'(args); end if;
  xvar:=(indets(expr,name) minus {nm})[1];
  try
    res:=Optimization:-Maximize(eval(expr,nm=val),
                                xvar=1..100,method='branchandbound');
  catch:
  end try;
  if not res[1]::numeric then
    return Float(undefined);
  else
    return res[1];
  end if;
end proc:

 

CARA2 := x^(1-R)/(1-R);
#CARA2 := sqrt(abs(x-90))*x^(1-R)/(1-R);

x^(1-R)/(1-R)

Xmax(0.9,eval(CARA2,[R=Rdummy,x=xdummy]),Rdummy);

HFloat(15.848931924611136)

B := plot3d(CARA2, R = 0 .. .95, x = 1 .. 100):
B;

# If CARA2 always attains its maximum (for each R) at x=100 then
# this is simpler.

plot3d(CARA2/eval(CARA2, x=100),
       R = 0 .. .95, x = 1 .. 100);

Bnew:=plot3d(CARA2/Xmax(R,eval(CARA2,[R=Rdummy,x=xdummy]),Rdummy),
             R = 0 .. .95, x = 1 .. 100):
Bnew;

lnB := plot3d(ln(CARA2), R = 0 .. .95, x = 1 .. 100):
lnB;

lnBnew:=plot3d(ln(CARA2/Xmax(R,eval(CARA2,[R=Rdummy,x=xdummy]),Rdummy)),
               R = 0 .. .95, x = 1 .. 100):
lnBnew;

CARA1 := 1 - exp(-g*x);

1-exp(-g*x)

A := plot3d(CARA1, g = 0 .. 1, x = 1 .. 100):
A;

# Let's do this one just for fun, to illustrate how the use
# of the Xmax command differs from the above example.

Anew:=plot3d(CARA1/Xmax(g,eval(CARA1,[g=gdummy,x=xdummy]),gdummy),
             g = 0 .. 1, x = 1 .. 100):
Anew;

plots:-display(A, Anew, color=[red,blue]);

plots:-display(Anew, Bnew, color=[green, blue]);

 

Download Cara_thing.mw

I'm not really sure what your goal is.

Is it something like this?

restart;

f:=GAMMA(L+2*q-3-k)/(GAMMA(L-k)*k)*((GAMMA(-2*q+L)*GAMMA(L+2*q-3-k)
   -GAMMA(L+2*q-3)*GAMMA(L-2*q-1-k)*(L+2*k-1-(4*k+2)*q))
   /((2*(-1+2*q))*(4*q-3)*GAMMA(L+2*q-3)*GAMMA(L+2*q-3-k)));

(1/2)*(GAMMA(-2*q+L)*GAMMA(L+2*q-3-k)-GAMMA(L+2*q-3)*GAMMA(L-2*q-1-k)*(L+2*k-1-(4*k+2)*q))/(GAMMA(L-k)*k*(-1+2*q)*(4*q-3)*GAMMA(L+2*q-3))

collect(numer(f),[k,GAMMA],u->u/denom(f));

(1/2)*(4*q-2)*GAMMA(L-2*q-1-k)/(GAMMA(L-k)*(-1+2*q)*(4*q-3))+(1/2)*GAMMA(L+2*q-3-k)*GAMMA(-2*q+L)/(GAMMA(L-k)*k*(-1+2*q)*(4*q-3)*GAMMA(L+2*q-3))+(1/2)*(-L+2*q+1)*GAMMA(L-2*q-1-k)/(GAMMA(L-k)*k*(-1+2*q)*(4*q-3))

 

Download collect_numer.mw

If that's right, then it would be slightly more efficient to do it as follows, and thereby call `denom` only once.

temp := denom(f):
collect(numer(f),[k,GAMMA],u->u/temp);
First 167 168 169 170 171 172 173 Last Page 169 of 336