acer

32385 Reputation

29 Badges

19 years, 336 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

A 3-D simplicial facet is a facet of a 3-D simplex, ie. a triangle.

restart:

A := ArrayTools:-RandomArray(35, 3):

xyz := convert(A,listlist):

ch := ComputationalGeometry:-ConvexHull(xyz);

[[1, 14, 7], [14, 5, 7], [5, 32, 7], [32, 5, 14], [31, 24, 11], [31, 16, 24], [4, 31, 11], [4, 6, 14], [35, 32, 14], [6, 35, 14], [35, 6, 4], [32, 34, 7], [1, 2, 14], [2, 4, 14], [24, 21, 11], [21, 4, 11], [21, 35, 4], [31, 3, 16], [3, 17, 16], [2, 3, 31], [17, 3, 1], [3, 2, 1], [17, 26, 16], [26, 34, 32], [16, 26, 24], [35, 27, 32], [27, 26, 32], [26, 27, 24], [27, 21, 24], [21, 27, 35], [4, 33, 31], [33, 2, 31], [2, 33, 4], [15, 26, 17], [15, 1, 7], [15, 17, 1], [34, 15, 7], [26, 15, 34]]

# Pick off the 7th element of xyz;
xyz[7];

[HFloat(0.011902069501241397), HFloat(0.699076722656686), HFloat(0.6554778901775566)]

# select all members of ch which contain the ordinal
# reference 7
T7 := select(c->member(7,c), ch);

[[1, 14, 7], [14, 5, 7], [5, 32, 7], [32, 34, 7], [15, 1, 7], [34, 15, 7]]

# Notice that xyz[7] is present in each of these
# lists of three 3-dimensional points. Each represents
# a 3-dimensional simplicial facet (ie. a triangle).
map(pt->print(xyz[pt]),T7):

[[HFloat(0.16564872949978093), HFloat(0.25750825412373646), HFloat(0.09713178123584754)], [HFloat(0.05395011866660715), HFloat(0.9597439585160811), HFloat(0.035711678574189554)], [HFloat(0.011902069501241397), HFloat(0.699076722656686), HFloat(0.6554778901775566)]]

[[HFloat(0.05395011866660715), HFloat(0.9597439585160811), HFloat(0.035711678574189554)], [HFloat(0.16218230819324275), HFloat(0.9592914252054443), HFloat(0.7060460880196088)], [HFloat(0.011902069501241397), HFloat(0.699076722656686), HFloat(0.6554778901775566)]]

[[HFloat(0.16218230819324275), HFloat(0.9592914252054443), HFloat(0.7060460880196088)], [HFloat(0.2435249687249893), HFloat(0.9502220488383549), HFloat(0.9133758561390194)], [HFloat(0.011902069501241397), HFloat(0.699076722656686), HFloat(0.6554778901775566)]]

[[HFloat(0.2435249687249893), HFloat(0.9502220488383549), HFloat(0.9133758561390194)], [HFloat(0.25428217897153105), HFloat(0.694828622975817), HFloat(0.9057919370756192)], [HFloat(0.011902069501241397), HFloat(0.699076722656686), HFloat(0.6554778901775566)]]

[[HFloat(0.07585428956306361), HFloat(0.49836405198214295), HFloat(0.6557406991565868)], [HFloat(0.16564872949978093), HFloat(0.25750825412373646), HFloat(0.09713178123584754)], [HFloat(0.011902069501241397), HFloat(0.699076722656686), HFloat(0.6554778901775566)]]

[[HFloat(0.25428217897153105), HFloat(0.694828622975817), HFloat(0.9057919370756192)], [HFloat(0.07585428956306361), HFloat(0.49836405198214295), HFloat(0.6557406991565868)], [HFloat(0.011902069501241397), HFloat(0.699076722656686), HFloat(0.6554778901775566)]]

# Instead of just extracting them, form polygon plotting
# structures from them instead. Again, notice that xyz[7]
# is a vertex of each of these triangles.
map(pt->plottools:-polygon(xyz[pt],transparency=0.5),T7);

[POLYGONS(Matrix(3, 3, {(1, 1) = .16564872949978093, (1, 2) = .25750825412373646, (1, 3) = 0.9713178123584754e-1, (2, 1) = 0.5395011866660715e-1, (2, 2) = .9597439585160811, (2, 3) = 0.35711678574189554e-1, (3, 1) = 0.11902069501241397e-1, (3, 2) = .699076722656686, (3, 3) = .6554778901775566}), TRANSPARENCY(.5)), POLYGONS(Matrix(3, 3, {(1, 1) = 0.5395011866660715e-1, (1, 2) = .9597439585160811, (1, 3) = 0.35711678574189554e-1, (2, 1) = .16218230819324275, (2, 2) = .9592914252054443, (2, 3) = .7060460880196088, (3, 1) = 0.11902069501241397e-1, (3, 2) = .699076722656686, (3, 3) = .6554778901775566}), TRANSPARENCY(.5)), POLYGONS(Matrix(3, 3, {(1, 1) = .16218230819324275, (1, 2) = .9592914252054443, (1, 3) = .7060460880196088, (2, 1) = .2435249687249893, (2, 2) = .9502220488383549, (2, 3) = .9133758561390194, (3, 1) = 0.11902069501241397e-1, (3, 2) = .699076722656686, (3, 3) = .6554778901775566}), TRANSPARENCY(.5)), POLYGONS(Matrix(3, 3, {(1, 1) = .2435249687249893, (1, 2) = .9502220488383549, (1, 3) = .9133758561390194, (2, 1) = .25428217897153105, (2, 2) = .694828622975817, (2, 3) = .9057919370756192, (3, 1) = 0.11902069501241397e-1, (3, 2) = .699076722656686, (3, 3) = .6554778901775566}), TRANSPARENCY(.5)), POLYGONS(Matrix(3, 3, {(1, 1) = 0.7585428956306361e-1, (1, 2) = .49836405198214295, (1, 3) = .6557406991565868, (2, 1) = .16564872949978093, (2, 2) = .25750825412373646, (2, 3) = 0.9713178123584754e-1, (3, 1) = 0.11902069501241397e-1, (3, 2) = .699076722656686, (3, 3) = .6554778901775566}), TRANSPARENCY(.5)), POLYGONS(Matrix(3, 3, {(1, 1) = .25428217897153105, (1, 2) = .694828622975817, (1, 3) = .9057919370756192, (2, 1) = 0.7585428956306361e-1, (2, 2) = .49836405198214295, (2, 3) = .6557406991565868, (3, 1) = 0.11902069501241397e-1, (3, 2) = .699076722656686, (3, 3) = .6554778901775566}), TRANSPARENCY(.5))]

# plot the xyz[7] point, and all the
# triangles that have it as a vertex.
plots:-display(
  plots:-pointplot3d(xyz[7],color=red,symbolsize=20,symbol=solidsphere),
  map(x->plottools:-polygon(xyz[x],transparency=0.5),T7),
  labels=[x,y,z], view=[0..1,0..1,0..1]
);

# plot all the points, and all the triangles (which
# make up the convex hull.
plots:-display(
  plots:-pointplot3d(xyz,color=red,symbolsize=20,symbol=solidsphere),
  plots:-display(map(pt->plottools:-polygon(xyz[pt],transparency=0.5),ch)),
  labels=[x,y,z], view=[0..1,0..1,0..1]
);

 

 

Download hull3D.mw

I suppose that you have already searched the FAQs.

You could contact Maplesoft Technical Support.

Be sure to let them know your Maple version, Operating System and version, and whether you are using any Maple "language packs".

Using concatenated names (which are always global) within procedures is poor programming practice, in my opinion.

Having said that,

restart

x := 3

A || 1 := 3

P := proc () local x; global y, z; x := 'x'; y := fsolve([x+5 = -2], {x}); A || 1 := cat(A, 1); z := fsolve([A || 1+5 = -2], {A || 1}) end proc

P()

{A1 = -7.}

A || 1

A1

 

Download Concatenate_Question_ac.mw

You could also use  cat(':-A',1)  for additional safety.

You can pick off those introduced (free) parameters, evaluate expressions (C, Q, other...) at arbitrary values for them, and so on.

Forcing the stem of the parameter name with the free option makes it easier to pick them off programmtically in the more general case.

Another choice is to use LeastSquares instead of LinearSolve, which will produce a single instance of the solution rather than a parametrized solution.

(I changed the first two entries of B, to make the LeastSquares result more interesting than the zero-Vector.)

restart

A := Matrix(4, 4, {(1, 1) = 1, (1, 2) = 3, (1, 3) = 4.5, (1, 4) = 7, (2, 1) = 0, (2, 2) = 2, (2, 3) = 5, (2, 4) = 9, (3, 1) = 0, (3, 2) = 0, (3, 3) = 0, (3, 4) = 0, (4, 1) = 0, (4, 2) = 0, (4, 3) = 0, (4, 4) = 0}); B := Vector(4, {(1) = 1, (2) = 2, (3) = 0, (4) = 0}); C := LinearAlgebra:-LinearSolve(A, B, free = F)

Vector[column](%id = 18446883819568535062)

params := [indets(C, 'specindex(posint, F)')[]]

[F[1], F[2]]

W1 := C[1]; W2 := C[2]; W3 := C[3]; W4 := C[4]; Q := W1*x^4+W2*x^3+W3*x^2+W1

(-HFloat(2.0)+HFloat(3.0)*F[2]+HFloat(6.5)*F[1])*x^4+(HFloat(1.0)-HFloat(2.5)*F[2]-HFloat(4.5)*F[1])*x^3+F[2]*x^2-HFloat(2.0)+HFloat(3.0)*F[2]+HFloat(6.5)*F[1]

map(`=`, params, 1)

[F[1] = 1, F[2] = 1]

eval(C, map(`=`, params, 1))

Vector[column](%id = 18446883819568524694)

eval(Q, map(`=`, params, 1))

HFloat(7.5)*x^4-HFloat(6.0)*x^3+x^2+HFloat(7.5)

A.C, B

Vector[column](%id = 18446883819568519038), Vector[column](%id = 18446883819672872470)

Alt := LinearAlgebra:-LeastSquares(A, B, method = SVD)

Vector[column](%id = 18446883819568516262)

A.Alt, B

Vector[column](%id = 18446883819568509646), Vector[column](%id = 18446883819672872470)

NULL

Download MultipleTCoefficients_ac.mw

restart;

local gamma: local phi:

sinc:=unapply(piecewise(x=0, 1, (sin(Pi*x))/(Pi*x)),x):
S:=unapply(sinc((x-k*h)/h),k,h,x):

a := -3: b := 4:
f:=unapply(x^2*t^3,x,t);

proc (x, t) options operator, arrow; x^2*t^3 end proc

phi:=unapply(log((x-a)/(b-x)),x):
gamma:=unapply(log(t),t):

teta:=2: Omega:=1:

w:=unapply(simplify(1/(D(phi)(x))^((teta-1)/2)),x):
v:=unapply(simplify((D(gamma)(t))^(Omega/2)),t):

k:=2: l:=1:
#hx:=1.282549830:
ht:=hx:

G:=Int((Int(f(x,t)*S(k,hx,phi(x))*S(l,ht,gamma(t))*w(x)*v(t),x=a..b),t=0..infinity)):

GG:=Int(t^3*S(l,ht,gamma(t))*v(t),t=0..infinity)*Int(x^2*S(k,hx,phi(x))*w(x),x=a..b):

combine(G-GG);

0

op(2,GG);
evalf(eval(%,hx=1.282549830));

Int(x^2*piecewise((-2*hx+ln((x+3)/(4-x)))/hx = 0, 1, sin(Pi*(-2*hx+ln((x+3)/(4-x)))/hx)*hx/(Pi*(-2*hx+ln((x+3)/(4-x)))))*sqrt(7)/(7*sqrt(-1/((x+3)*(-4+x)))), x = -3 .. 4)

5.148697506

#Int(t^3*sin(Pi*(-hx+ln(t))/hx)/Pi/(-hx+ln(t))*hx*(1/t)^(1/2),t = 0 .. infinity);
op(1,GG);
simplify(value(%)) assuming hx::real;

Int(t^3*piecewise((-hx+ln(t))/hx = 0, 1, sin(Pi*(-hx+ln(t))/hx)*hx/(Pi*(-hx+ln(t))))*sqrt(1/t), t = 0 .. infinity)

undefined

 

Download doubleint1.mw

If I understand your goal correctly, the coordinates of the cells are present in the plot structure computed by the VoronoiDiagram command.

They are Matrices, but you could convert them to listlist.

Let us know if you have difficulty converting or manipulating them into some other form. Please be specific in details, though. If you want them merged, without repeats, into one big flat list of points then that could be done -- though if there are very many original data points it computed be computed more efficiently in a more direct manner (via Delaunay triangulation, say), without going through production of the full diagram/plot.

Here is an example, separating then according to the color.

restart;

with(ComputationalGeometry):

m:=LinearAlgebra:-RandomMatrix(7,2,generator=0.0..1.0):

P:=VoronoiDiagram(m,symbol=solidcircle,symbolsize=7,size=[300,300],axes=boxed):
P;

V:=[op(indets(P,specfunc(anything,POLYGONS)))]:

T:=ListTools:-Classify(u->op(2,u),V):

Tinds:=indices(T,nolist);

COLOUR(RGB, .47058824, 0., 0.54901961e-1), COLOUR(RGB, .29019608, .47058824, 0.), COLOUR(RGB, 0., 0.54901961e-1, .47058824)

ColorTools:-Color(Tinds[1]), map[2](op,1,T[Tinds[1]]);

"<RGB : 0.471 0 0.0549>,{[[[0.674755640087579,0.528416189867507],[0.774429137959799,0.760000722399843],[0.565091023500541,1.70390300233302],[0.278700624534252,0.573844297940794]]],[[[0.781700218780773,0.381772909439530],[4.66209503332205,0.337974064337378],[3.70924190390966,-0.608387011801836],[0.716780642385679,0.176311320824582]]]}"

ColorTools:-Color(Tinds[2]), map[2](op,1,T[Tinds[2]]);

"<RGB : 0.29 0.471 0>,{[[[0.278700624534252,0.573844297940794],[-2.20505390543617,-0.708421311778174],[-3.70554867069412,0.505458130569214],[0.564102931719082,4.77510973298241],[0.593861093166918,4.73834981392173],[0.565091023500541,1.70390300233302]]],[[[0.716780642385679,0.176311320824582],[-0.359151757230016,-2.62884825842281],[0.564102931719082,-3.76574686098490],[3.70924190390966,-0.608387011801836]]],[[[0.674755640087579,0.528416189867507],[0.781700218780773,0.381772909439530],[4.66209503332205,0.337974064337378],[4.85550306716113,0.505458130569214],[4.39299635377559,0.933178173190759],[0.774429137959799,0.760000722399843]]]}"

ColorTools:-Color(Tinds[3]), map[2](op,1,T[Tinds[3]]);

"<RGB : 0 0.0549 0.471>,{[[[0.674755640087579,0.528416189867507],[0.781700218780773,0.381772909439530],[0.716780642385679,0.176311320824582],[-0.359151757230016,-2.62884825842281],[-2.20505390543617,-0.708421311778174],[0.278700624534252,0.573844297940794]]],[[[0.774429137959799,0.760000722399843],[4.39299635377559,0.933178173190759],[0.593861093166918,4.73834981392173],[0.565091023500541,1.70390300233302]]]}"

 

Download Voronoi_cells.mw

The result coming out of symbolic int (from the meijerg method) is incorrect.

You can very quickly produce a plot as follows, however, using numeric integration. Note the use of inert (captalized) Int below, instead of active int.

Here I get good speed by forcing a numeric integration method which avoids (here unnecessary) expensive discontinuity checking.

plot(Int(exp(-(x^2-a)^2),x=0..infinity,method=_d01amc),
     a=-2..5);

Other quick approaches here include specifying a decent method other than _d01amc (eg. _Dexp) or utilizing operator form for the integrand within the Int call (slightly tricky since the value of parameter a has to be shoehorned in). These are not quite as quick as the approach given above.

plot(Int(exp(-(x^2-a)^2),x=0..infinity,method=_Dexp),
     a=-2..5);

plot(a->Int(unapply(exp(-(x^2-a)^2),x),0..infinity),
     -2..5);

Using Int (or int with its numeric option) alone for this example is considerably slower slower than the approaches mentioned above. These next approaches will also produce the better plot, but they are not nearly as fast (because of hybrid symbolic-numeric checking), taking about 60sec versus less than 1sec for the first approach above. The slowness is not due to the accuracy tolerance.

plot(Int(exp(-(x^2-a)^2),x=0..infinity),a=-2..5);

plot(a->int(exp(-(x^2-a)^2),x=0..infinity,numeric),-2..5);

I will submit a bug report against the symbolic int command, for the incorrect result coming out of the meijerg method.

If you read the Help page for Topic proc you can see a description of the fact that local variables only get 1-level evaluation.

You code does a rather unusual and roundabout trick of creating expressions with references to y, and then temporarily assigning specific values to y (eg. y=0, y=b), and then unassigning y. It does this while constructing the expressions that get assigned to EQ1,EQ2,EQ3, and EQ4.

When you do all that at the top-level then the expressions assigned to EQ1,etc get fully evaluated, and the references to y are replaced by the values temporarily assigned to y, and no references to y remain.

But when you do that within a procedure (where y, GenFunc, EQHelp, and EQHelp2 are local variables -- whether declared explicitly or not) the references to local y only get 1-level evaluation, and are not resolved to the temporary assigned values.

There are several ways around this:

A) You could wrap in a simple call to eval, each of the four constructions. For example, instead of,
          EQ1 := GenFunc = 0;
you could have,
          EQ1 := eval(GenFunc = 0);
while retaining you temp assignments to y, and unassignments of y (so that the diff calls were still valid). This is workable, but retains what I consider to be a very awkward way of doing something that should be simple. The fact that you have to repeatedly unassign y is a hint that is suboptimal. This is not the best direction in which to move. Test_GetDet_MaplePrimes_assign_eval_unassign.mw

B) You could declare EQHelp, EQHelp2, and GenFunc as a global at the top of the wrapping GetDet procedure, and keep all the other mechanisms as they are. That works, but retains all the awkwardness. It's actually more awkward and convoluted. (For other examples you may get lost trying to figure out what to declare global. Also, unnecessary global declarations are evil and wicked.) This is the wrong direction in which to move. Test_GetDet_MaplePrimes_globaldecl.mw

C) You could get rid of all the need for repeated assigning and unassigning to y, by instead using the so-called 2-argument calling sequence of the eval command to evaluate GenFunc, EQHelp, and EQHelp2 at the specific values of y. This is much more usual and convenient way to utilize a value for a variable without having to unassign it for subsequence symbolic use (the ensuing diff calls). This is the right way to accomplish this part of the task (IMO), regardless of whether inside a wrapping procedure or all done at the top-level. Test_GetDet_MaplePrimes_ac.mw

You keep submitting duplicates of earlier question threads. You spam this site with them. It is inconsiderate and unhelpful. I flag them as duplicates, and then delete them. I have given you messages about this -- as private messages and comments on earlier Questions.

Put your followup queries onto one of your related earlier Questions, instead.

If you have other kinds of example then you should show them.

restart;

expr := 4.22647099771398*exp(-0.0104163888375266*t)
        - 4.22647099771398*exp(-2.00033505979518*t);

4.22647099771398*exp(-0.104163888375266e-1*t)-4.22647099771398*exp(-2.00033505979518*t)

indets(expr,specfunc(anything,exp));

{exp(-2.00033505979518*t), exp(-0.104163888375266e-1*t)}

# note the order of the terms (we don't know
# whether that matters to you.
map(op,indets(expr,specfunc(anything,exp)));

{-2.00033505979518*t, -0.104163888375266e-1*t}

# This preserves the "ordering" of the terms in the original sum.
[seq([op(map(op,indets(term,specfunc(anything,exp))))], term=expr)];

[[-0.104163888375266e-1*t], [-2.00033505979518*t]]

# This preserves the "ordering" of the terms in the original sum.
# Here the operands of the exp calls are not separated, so
# only use this if you know that each term has only one such
# call.
[seq(op(map(op,indets(term,specfunc(anything,exp)))), term=expr)];

[-0.104163888375266e-1*t, -2.00033505979518*t]

 

Download indets_exp.mw

Some instructor has a sense of humour.

(I made no effort for efficiency.)

Guessing at how num2text might work was not difficult.

restart;

num2text := proc(n::posint) local C, i;
  C := convert(n,'base',100);
  cat(seq("abcdefghijklmnopqrstuvwxyz"[C[nops(C)-i+1]],
          i=1..nops(C)));
end proc:

eqs := {z =  4*x + 19*y + 2515211725275120,
        z = 52*x + 27*y + 2515210613496048,
        z = 36*x + 65*y + 2515210981587340,
        z =  6*x + 60*y + 2515211676449260}:

Q := eval([x,y,z], solve(eqs,{x,y,z}));

[23151811, 61518, 2515211819051206]

map(num2text, Q)[];

"work", "for", "yourself"

cat(num2text(Q[1])," ",num2text(Q[2])," ",num2text(Q[3]));
 

"work for yourself"

#cat(num2text(Q[1]), seq([" ",num2text(Q[i])][],i=2..nops(Q)));

 

Download hwQuestion.mw

If you have a set of the form,

   {var1=..., lambda22=..., var2=..., var3=...}

then you can evaluate any formula at that "point" (set of equations of the form name=value).

In particular you can evaluate the simple formula of just lambda22 at that point.

This is especially useful when the equations are in a set, because the mechanism works regardless of the order of the equations in the set.

restart;

with(LinearAlgebra):

kappa:=30:
tensF:=Matrix([[lambda11,0,0],[0,lambda22,0],[0,0,lambda22]]):
tensFbar:=Matrix([[lambda11bar,0,0],[0,1/sqrt(lambda11bar),0],[0,0,1/sqrt(lambda11bar)]]):
tensBbar:=Multiply(tensFbar,Transpose(tensFbar)):

tensPK:=Matrix([[pi,0,0],[0,0,0],[0,0,0]]):
tensPK1:=Multiply(Transpose(MatrixInverse(tensF)),(2/Determinant(tensF))*a*(tensBbar-(1/3)*Trace(tensBbar)*Matrix(3,shape=identity))+kappa*(Determinant(tensF)-1)*Matrix(3,shape=identity)):
eq1:=tensPK[1,1]=tensPK1[1,1]:
eq2:=tensPK[2,2]=tensPK1[2,2]:
sys:={eq1,eq2}:

sol1:=[solve( sys, {lambda11bar,lambda22},explicit)]:
nops(sol1);

6

eval(lambda22,sol1[1]);

(1/30)*10^(1/2)*(lambda11*(pi*lambda11+90))^(1/2)/lambda11

eval(lambda22,sol1[2]);

-(1/30)*10^(1/2)*(lambda11*(pi*lambda11+90))^(1/2)/lambda11

seq([i,eval(lambda22,sol1[i])], i=1..nops(sol1));

[1, (1/30)*10^(1/2)*(lambda11*(pi*lambda11+90))^(1/2)/lambda11], [2, -(1/30)*10^(1/2)*(lambda11*(pi*lambda11+90))^(1/2)/lambda11], [3, (1/30)*10^(1/2)*(lambda11*(pi*lambda11+90))^(1/2)/lambda11], [4, -(1/30)*10^(1/2)*(lambda11*(pi*lambda11+90))^(1/2)/lambda11], [5, (1/30)*10^(1/2)*(lambda11*(pi*lambda11+90))^(1/2)/lambda11], [6, -(1/30)*10^(1/2)*(lambda11*(pi*lambda11+90))^(1/2)/lambda11]

 

A poor alternative is to inspect the set for the location of the one you want, and to pick off the value by using rhs of (here the second entry) entry indexed by position. It is a weak methodology because the set order depends on lexicographic ordering of the set (eg. alphapbetical ordering of the lhs names). If the names were changed the position of the one you wanted could change. So the code would be less robust.

 

rhs(sol1[1][2]);

(1/30)*10^(1/2)*(lambda11*(pi*lambda11+90))^(1/2)/lambda11

rhs(sol1[2][2]);

-(1/30)*10^(1/2)*(lambda11*(pi*lambda11+90))^(1/2)/lambda11

 

Another alternative is to specify the order of the solved variables, in the call to solve, by supplying the solved variables in a list rather than in a set. The effect is that the results will also contain lists, with the same ordering.

 

You can then pick off the values acording to the position of the one you want (in the list of variable names passed to solve).

 

But you still have to remember to re-use the same ordinal position, when picking off the values. Also, the purpose of the lines with rhs,etc may be less obvious to you or someone else at a later date.

 

Hence I prefer the methodology using eval, which involves less bookkeeping and works for both lists and sets of equations name=value.

 

# Notice the second argument passed to `solve` is now a list.
# Also, with this calling sequence `solve` returns a list of
# the solutions, so I didn't wrap the `solve` call in [] brackets.

sol1:=solve( sys, [lambda22,lambda11bar],explicit):

rhs(sol1[1][1]);

(1/30)*10^(1/2)*(lambda11*(pi*lambda11+90))^(1/2)/lambda11

rhs(sol1[2][1]);

-(1/30)*10^(1/2)*(lambda11*(pi*lambda11+90))^(1/2)/lambda11

 

Download solve_eval.mw

There are several ways to accomplish this, so I'll give one of several alternatives.

One of the reasons to split off the "first argument" passed to plots:-animate is to provide a (sometimes easier) mechanism that having to use unevaluation-quotes. The original authors of plots:-animate recognized that avoiding premature evaluation would very often be wanted -- because the animating parameter would not yet have a numeric value -- and hence allowed a syntax that split the command from its arguments.

For your example, that same mechanism can handle it directly, as opposed to also utilizing unevaluation-quotes.

restart;
with(DynamicSystems):
with(plots):

num:=10*(s+alpha);
den:=s*(s^2+4*s+8);

animate(RootLocusPlot@NewSystem,
        [subs(alpha=a,num/den)],
        a=1..10);

f:=unapply(num/den, alpha):
animate(RootLocusPlot@NewSystem,[f(a)],
        a=1..10);

Of course there will be other examples where other flavours are easier.

A subtlety is that you do want f(a) or the subs call to evaluated up-front. It'd be (here, slightly) less efficient to have that be done upon each new value taken by the parameter a. The solutions discussed so far in this thread all do that part well.

The first step is to ensure that your procedure(s) can run under hardware double-precision mode, the simplest mechanism for which is by using the evalhf interpreter.

The plot3d command will attempt to use evalhf mode, but we need to make the TF procedure "evalhf'able". The following takes 4 seconds on my machine, while the original took 412 seconds.

restart

kernelopts(version);

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

eps := 0.1e-1;

0.1e-1

N := 20;

20

maxIter := 100;

100

bail := 0.1e11;

0.1e11

orb := Array(1 .. N, datatype = complex[8]):

TF := proc (x, y, orb, N, eps) local n, p, z, c, lgc; z := 0; c := x+I*y; lgc := ln(c); for n to N do orb[n] := 0 end do; for n to maxIter while abs(z) < bail do z := exp(lgc*z); if maxIter-N < n then orb[n-maxIter+N] := z end if end do; p := 0; for n to N-1 do if abs(orb[N]-orb[N-n]) <= eps then p := n; break end if end do; log(p) end proc:

evalhf(TF(2.1, .3, orb, N, eps));

1.60943791243410028

p := CodeTools:-Usage(plot3d(('TF')(a, b, orb, N, eps), a = -4 .. 4, b = -4 .. 4, grid = [400, 400], lightmodel = none, shading = ZHUE, style = PATCHNOGRID, orientation = [-90, 0], axes = BOX, labels = [x, y, iter])):

memory used=3.12MiB, alloc change=1.22MiB, cpu time=3.96s, real time=3.96s, gc time=0ns

 

NULL

Download tetrationFractal18_ac.mw

The next step is to ditch using plot3d as a mechanism for generating the data values, since we can avoid having to invoke evalhf being called for every x-y point. Instead we could write a single evalhf'able procedure that operates in-place on a predefined 2-dimensional Array (or Matrix).

While re-writing in that way, the coloring scheme could be revamped.

Further improvement would be to make that paralellizable (each thread operating on only a subrange of the x-values, say, but writing to the shared result Matrices), and compile'able under Compiler:-Compile.

note: In more recent Maple versions tetration can be attainted using the IterativeMaps:-Escape command, although that is with a fixed iteration limit (and not so easily with the fancy orbit check). I already had an example of that, but it won't run in Maple 18 since the package was introduced in Maple 2015.

After you assign a value to A the thing assigned to V still contains A.

If you then access individual elements of  V then evaluation occurs, and you'd get what you expect.

If you subsequently assign a different value to A the you could get a different result when accessing the relevant entries of V. (You might want to do this.)

But that evaluation isn't occurring when you print V.

You can map the eval command over V, or apply the rtable_eval command to V, to see the printing display all the elements after evaluation.  Eg,

     map(eval, V);

     rtable_eval(V);

Those both create a new instance of the thing, that contains the value you assigned to A rather than the actual name A. (If you subsequently assign a different value to A then these new instances aren't affected.)

The above describes "how" the behavior happens. Do you also want the (involved) explanation of the design decisions behind rtable evaluation rules?

Here are illustrations of the explanation above (of "how").

restart

with(VectorCalculus)

V := `<,>`(A, B, C)

Vector(3, {(1) = A, (2) = B, (3) = C})

A := 1

1

V

Vector(3, {(1) = A, (2) = B, (3) = C})


We can see what is actually stored in V.

lprint(V)

Vector[column](3,{1 = A, 2 = B, 3 = C},datatype = anything,storage =
rectangular,order = Fortran_order,attributes = [coords = cartesian],shape = [])

 

Accessing the individual elements (entries) gets the evaluated result.

 

V[1]

1


We can force the evaluation of elements (also making a new structure).

W := map(eval, V)

Vector(3, {(1) = 1, (2) = B, (3) = C})

Y := rtable_eval(V)

Vector(3, {(1) = 1, (2) = B, (3) = C})

 

If we now assign a different value to A then we can observe that
doing so affects the evaluated elements of V, but not those of Y (or W).

 

A := 17

17

rtable_eval(V)

Vector(3, {(1) = 17, (2) = B, (3) = C})

rtable_eval(Y)

Vector(3, {(1) = 1, (2) = B, (3) = C})

lprint(Y)

Vector[column](3,{1 = 1, 2 = B, 3 = C},datatype = anything,storage =
rectangular,order = Fortran_order,attributes = [coords = cartesian],shape = [])

 

Download VectorCalculusQuestion_ac.mw

First 108 109 110 111 112 113 114 Last Page 110 of 336