tomleslie

13876 Reputation

20 Badges

15 years, 175 days

MaplePrimes Activity


These are answers submitted by tomleslie

Avoid using floating-point arithmetic until/unless you absolutely have to!!!

Maple can solve your problem exactly.

In the attached, I have

  1. removed the Digits setting: since the computation is being done exactly this isn't relevant (but see item 4 below)
  2. removed all intermediate evalf() commands
  3. converted some floating-point input parameters to their rational form. If you start with floating point parameters, then you are 'forcing' Maple to use floating point arithmetic whenever these parameters occur. The floating point arithemtic will rapidly "propagate" through the whole calculation. If memory serves, this just involved converting values like 0.1 to 1/10 in a few places
  4. evaluated the last four expressions using a few different settings of Digits, by using the evalf[n](), with different values of 'n'

The output of the last four execution groups with four different settings of 'n' in evalf[n]() is now consistent

Repeated execution of the worksheet gives *more-or-less-the-same* output.  For each setting of 'n' in the 'evalf[n]' commands the final two or three digits *might* change, but the leading 'n-3' digits do not change.

If desired, you can even circumevert this minor inconsistency by "rounding" the output data. The final execution group in the attached computes the desired answers to 10, 15, 20, 25 digits, and then "rounds" these to the number of digits set by the parameter "accuracy" - I have used accuracy=10. With this approach

  1. computing to [15, 20, 25] digits followed by rounding to 10 digits, always agree, and gives the same answers on repreated execution
  2. computing to 10-digit accuracy followed by rounding to 10 digits, gives a (slightly) different answer from computing to [15, 20, 25] digits, and the answer differs (slightly) on repeated execution.


 

restart:

with(student):

nup:=1:nlp:=1:np:=2:

L:=10:

E:=200000:Eup:=E:Elp:=E:Ep1:=E:Ep2:=E:Ep3:=E:

tup:=1/10:rho[up]:=0:hup:=1:

tlp:=1/10:rho[lp]:=0:hlp:=1:

for i from 1 to np do

  tp||i:=1/10:hp||i:=6:

end:

rho[p][1]:=90*Pi/180:rho[p][2]:=90*Pi/180:

rho[1]:=rho[p][1]-rho[up]:rho[2]:=rho[p][2]-rho[up]:

qup:=1:qlp:=0:

for i from 1 to np do

  qp||i:=0:

end:

for i from 1 to nup do

  hup||i:=hup:
  yup||i||b:=hup/2:yup||i||t:=-hup/2:
  Aup||i:=tup*hup:
  Ixxup||i:=tup*hup^3/12:

  Iyyup||i:=tup^3/12:

  qzzup||i:=qup*(cos(rho[up]))^2:
  qyyup||i:=abs(qup*cos(rho[up])*sin(rho[up])):

end:

#qyysu:=abs(sum('qsu||i','i'=1..nsu)*cos(rho[su])*sin(rho[su])):

#qyyup:=abs(qup*nup*cos(rho[up])*sin(rho[up])):

for i from 1 to nlp do

  hlp||i:=hlp:
  ylp||i||b:=hlp||i/2:ylp||i||t:=-hlp||i/2:
  Alp||i:=tlp*hlp:
  Ixxlp||i:=tlp*hlp^3/12:

  Iyylp||i:=tlp^3/12:

  qzzlp||i:=qlp*(cos(rho[lp]))^2:
  qyylp||i:=abs(qlp*cos(rho[lp])*sin(rho[lp])):  

end:

#qyysl:=abs(sum('qsl||i','i'=1..nsl)*cos(rho[sl])*sin(rho[sl])):

#qyylp:=abs(qlp*nlp*cos(rho[lp])*sin(rho[lp])):

for i from 1 to np do

  yp||i||b:=hp||i/2:yp||i||t:=-hp||i/2:

  Iyyp||i:=tp||i^3/12:

  Ap||i:=tp||i*hp||i:

  Ixxp||i:=tp||i*hp||i^3/12:

  qzzp||i:=qp||i*(cos(rho[p][i]))^2:

  qyyp||i:=abs(qp||i*cos(rho[p][i])*sin(rho[p][i])):

end:

``

     Transverse Behaviour:

for i from 1 to nup do

  deq||i:=Eup*Iyyup||i*diff(Wup||i(y),y$4)=qzzup||i:

  sol||i:=dsolve(deq||i,Wup||i(y)):assign(sol||i):

  Wup||i(y):=subs(_C1=c||((i-1)*4+1),_C2=c||((i-1)*4+2),_C3=c||((i-1)*4+3),_C4=c||((i-1)*4+4),Wup||i(y)):

  phiup||i(y):=diff(Wup||i(y),y):

  Myyup||i(y):=-Eup*Iyyup||i*diff(phiup||i(y),y):

  Syyup||i(y):=diff(Myyup||i(y),y):

end:

 

for i from 1 to np do

  deq||i:=Ep||i*Iyyp||i*diff(Wp||i(y),y$4)=qzzp||i:

  sol||i:=dsolve(deq||i,Wp||i(y)):assign(sol||i):

  Wp||i(y):=subs(_C1=c||((i-1+nup)*4+1),_C2=c||((i-1+nup)*4+2),_C3=c||((i-1+nup)*4+3),_C4=c||((i-1+nup)*4+4),Wp||i(y)):

  phip||i(y):=diff(Wp||i(y),y):

  Myyp||i(y):=-Ep||i*Iyyp||i*diff(phip||i(y),y):

  Syyp||i(y):=diff(Myyp||i(y),y):

end:

 

for i from 1 to nlp do

  deq||i:=Elp*Iyylp||i*diff(Wlp||i(y),y$4)=qzzlp||i:

  sol||i:=dsolve(deq||i,Wlp||i(y)):assign(sol||i):

  Wlp||i(y):=subs(_C1=c||((i-1+nup+np)*4+1),_C2=c||((i-1+nup+np)*4+2),_C3=c||((i-1+nup+np)*4+3),_C4=c||((i-1+nup+np)*4+4),Wlp||i(y)):

  philp||i(y):=diff(Wlp||i(y),y):

  Myylp||i(y):=-Elp*Iyylp||i*diff(philp||i(y),y):

  Syylp||i(y):=diff(Myylp||i(y),y):

end:

 

eq1:=subs(y=yp1t,Myyp1(y))=subs(y=yup1b,Myyup1(y)):

eq2:=subs(y=yp1t,phip1(y))=subs(y=yup1b,phiup1(y)):

eq3:=subs(y=yp1t,Wp1(y))=Vp1(x)*cot(rho[1])-Vup1(x)/sin(rho[1]):

eq4:=subs(y=yup1b,Wup1(y))=Vp1(x)/sin(rho[1])-Vup1(x)*cot(rho[1]):

eq5:=subs(y=yp2t,Myyp2(y))=-subs(y=yup1t,Myyup1(y)):

eq6:=subs(y=yp2t,phip2(y))=subs(y=yup1t,phiup1(y)):

eq7:=subs(y=yp2t,Wp2(y))=Vp2(x)*cot(rho[2])-Vup1(x)/sin(rho[2]):

eq8:=subs(y=yup1t,Wup1(y))=Vp2(x)/sin(rho[2])-Vup1(x)*cot(rho[2]):

eq9:=subs(y=yp1b,Myyp1(y))=subs(y=ylp1t,Myylp1(y)):

eq10:=subs(y=yp1b,phip1(y))=subs(y=ylp1t,philp1(y)):

eq11:=subs(y=yp1b,Wp1(y))=Vp1(x)*cot(rho[1])-Vlp1(x)/sin(rho[1]):

eq12:=subs(y=ylp1t,Wlp1(y))=Vp1(x)/sin(rho[1])-Vlp1(x)*cot(rho[1]):

#eq13:=subs(y=yp2b,Myyp2(y))=-subs(y=ylp2b,Myylp2(y)):

#eq14:=subs(y=yp2b,phip2(y))=subs(y=ylp2b,philp2(y)):

#eq15:=subs(y=yp2b,Wp2(y))=Vp2(x)*cot(rho[2])-Vlp2(x)/sin(rho[2]):

#eq16:=subs(y=ylp2b,Wlp2(y))=Vp2(x)/sin(rho[2])-Vlp2(x)*cot(rho[2]):

eq13:=subs(y=ylp1b,Myylp1(y))=0:

eq14:=subs(y=ylp1b,Syylp1(y))=0:

eq15:=subs(y=yp2b,Myyp2(y))=0:

eq16:=subs(y=yp2b,Syyp2(y))=0:

sol_c:=solve({eq||(1..16)},{c||(1..16)}):

for i from 1 to nup do

  Wup||i(y):=subs(sol_c,Wup||i(y)):

  phiup||i(y):=subs(sol_c,phiup||i(y)):

  Myyup||i(y):=subs(sol_c,Myyup||i(y)):

  Syyup||i(y):=subs(sol_c,Syyup||i(y)):

end:

for i from 1 to nlp do

  Wlp||i(y):=subs(sol_c,Wlp||i(y)):

  philp||i(y):=subs(sol_c,philp||i(y)):

  Myylp||i(y):=subs(sol_c,Myylp||i(y)):

  Syylp||i(y):=subs(sol_c,Syylp||i(y)):

end:

for i from 1 to np do

  Wp||i(y):=subs(sol_c,Wp||i(y)):

  phip||i(y):=subs(sol_c,phip||i(y)):

  Myyp||i(y):=subs(sol_c,Myyp||i(y)):

  Syyp||i(y):=subs(sol_c,Syyp||i(y)):

end:

    Longitudinal Behaviour:

Np1(x):=Ep1*Ap1*(Nup1(x)/Eup/Aup1-yup1b*diff(Vup1(x),x$2)+yp1t*diff(Vp1(x),x$2)):

Np2(x):=Ep2*Ap2*(Nup1(x)/Eup/Aup1-yup1t*diff(Vup1(x),x$2)+yp2t*diff(Vp2(x),x$2)):

Nlp1(x):=Elp*Alp1*(Nup1(x)/Eup/Aup1+(-yp1b+yp1t)*diff(Vp1(x),x$2)+ylp1t*diff(Vlp1(x),x$2)-yup1b*diff(Vup1(x),x$2)):

#Nlp2(x):=Elp*Alp2*(Nup1(x)/Eup/Aup1+(-yp2b+yp2t)*diff(Vp2(x),x$2)+ylp2b*diff(Vlp2(x),x$2)-yup1t*diff(Vup1(x),x$2)):

deq1:=-diff(Nup1(x),x)-diff(Np1(x),x)-diff(Np2(x),x)-diff(Nlp1(x),x)=0:

deq1A:=diff(Nup1(x),x)=solve(deq1,diff(Nup1(x),x)):

deq2:=simplify(subs(deq1A,Eup*Ixxup1*diff(Vup1(x),x$4)-yup1b*diff(Np1(x),x$2)-yup1t*diff(Np2(x),x$2)-yup1b*diff(Nlp1(x),x$2)+subs(y=yp1t,Syyp1(y))/sin(rho[1])+subs(y=yp2t,Syyp2(y))/sin(rho[2])-subs(y=yup1b,Syyup1(y))*cot(rho[1])+subs(y=yup1t,Syyup1(y)*cot(rho[2]))-qyyup1=0)):

deq3:=simplify(subs(deq1A,Ep1*Ixxp1*diff(Vp1(x),x$4)+yp1t*diff(Np1(x),x$2)+(-yp1b+yp1t)*diff(Nlp1(x),x$2)-subs(y=yp1t,Syyp1(y))*cot(rho[1])+subs(y=yup1b,Syyup1(y))/sin(rho[1])+subs(y=yp1b,Syyp1(y))*cot(rho[1])-subs(y=ylp1t,Syylp1(y))/sin(rho[1])-qyyp1)=0):

deq4:=simplify(subs(deq1A,Ep2*Ixxp2*diff(Vp2(x),x$4)+yp2t*diff(Np2(x),x$2)-subs(y=yp2t,Syyp2(y))*cot(rho[2])-subs(y=yup1t,Syyup1(y))/sin(rho[2])-qyyp2)=0):

deq5:=simplify(subs(deq1A,Elp*Ixxlp1*diff(Vlp1(x),x$4)+ylp1t*diff(Nlp1(x),x$2)-subs(y=yp1b,Syyp1(y)/sin(rho[1]))+subs(y=ylp1t,Syylp1(y)*cot(rho[1]))-qyylp1)=0):

#deq6:=simplify(subs(deq1A,Elp*Ixxlp2*diff(Vlp2(x),x$4)+ylp2b*diff(Nlp2(x),x$2)-subs(y=yp2b,Syyp2(y)/sin(rho[2]))-subs(y=ylp2b,Syylp2(y)*cot(rho[2]))-qyylp2)=0):

sol_L:=value(dsolve({deq||(2..5)},{Vup1(x),Vp1(x),Vp2(x),Vlp1(x)})):

sol_V:=subs(_C1=c1,_C2=c2,_C3=c3,_C4=c4,_C5=c5,_C6=c6,_C7=c7,_C8=c8,_C9=c9,_C10=c10,_C11=c11,_C12=c12,_C13=c13,_C14=c14,_C15=c15,_C16=c16,sol_L):

deq1:=subs(sol_V,deq1):

sol_N:=value(dsolve(deq1,Nup1(x))):

sol_N:=subs(_C1=c17,sol_N):

for i from 1 to nup do

  Wup||i(x,y):=subs(sol_V,sol_N,Wup||i(y)):

  Myyup||i(x,y):=subs(sol_V,sol_N,Myyup||i(y)):

end:

for i from 1 to nlp do

  Wlp||i(x,y):=subs(sol_V,sol_N,Wlp||i(y)):

  Myylp||i(x,y):=subs(sol_V,sol_N,Myylp||i(y)):

Nlp||i(x):=simplify(subs(sol_V,sol_N,Nlp||i(x))):

end:

for i from 1 to np do

  Wp||i(x,y):=subs(sol_V,sol_N,Wp||i(y)):

  Myyp||i(x,y):=subs(sol_V,sol_N,Myyp||i(y)):

  Np||i(x):=simplify(subs(sol_V,sol_N,Np||i(x))):

end:

assign(sol_V):assign(sol_N):

eq1:=subs(x=0,Nup1(x)+Np1(x)+Np2(x)+Nlp1(x)=0):

eq2:=subs(x=0,Eup*Ixxup1*(diff(Vup1(x),x$2))-Np1(x)*yup1b-Np2(x)*yup1t-Nlp1(x)*yup1b)=0:

eq3:=subs(x=0,Vup1(x))=0:

eq4:=subs(x=L,Eup*Ixxup1*(diff(Vup1(x),x$2))-Np1(x)*yup1b-Np2(x)*yup1t-Nlp1(x)*yup1b)=0:

eq5:=subs(x=L,Vup1(x))=0:

eq6:=subs(x=0,Ep1*Ixxp1*diff(Vp1(x),x$2)+Np1(x)*yp1t+Nlp1(x)*(-yp1b+yp1t))=0:

eq7:=subs(x=0,Vp1(x))=0:

eq8:=subs(x=L,Ep1*Ixxp1*diff(Vp1(x),x$2)+Np1(x)*yp1t+Nlp1(x)*(-yp1b+yp1t))=0:

eq9:=subs(x=L,Vp1(x))=0:

eq10:=subs(x=0,Ep2*Ixxp2*diff(Vp2(x),x$2)+Np2(x)*yp2t)=0:

eq11:=subs(x=0,Vp2(x))=0:

eq12:=subs(x=L,Ep2*Ixxp2*diff(Vp2(x),x$2)+Np2(x)*yp2t)=0:

eq13:=subs(x=L,Vp2(x))=0:

eq14:=subs(x=0,Elp*Ixxlp1*diff(Vlp1(x),x$2)+Nlp1(x)*ylp1t)=0:

eq15:=subs(x=0,Vlp1(x))=0:

eq16:=subs(x=L,Elp*Ixxlp1*diff(Vlp1(x),x$2)+Nlp1(x)*ylp1t)=0:

eq17:=subs(x=L,Vlp1(x))=0:

#eq18:=evalf(subs(x=0,Elp*Ixxlp2*diff(Vlp2(x),x$2)+Nlp2(x)*ylp2b)=0):

#eq19:=evalf(subs(x=0,Vlp2(x))=0):

#eq20:=evalf(subs(x=L,Elp*Ixxlp1*diff(Vlp2(x),x$2)+Nlp2(x)*ylp2b)=0):

#eq21:=evalf(subs(x=L,Vlp2(x))=0):

sol_cL:=solve({eq||(1..17)},{c||(1..17)}):

 

for i from 1 to nup do

  Wup||i(x,y):=subs(sol_cL,Wup||i(x,y)):

  Myyup||i(x,y):=subs(sol_cL,Myyup||i(x,y)):

  Vup||i(x):=subs(sol_cL,Vup||i(x)):

  Mxxup||i(x):=-Eup*Ixxup||i*diff(Vup||i(x),x$2):

  Nup||i(x):=subs(sol_cL,Nup||i(x)):

end:

for i from 1 to nlp do

  Wlp||i(x,y):=subs(sol_cL,Wlp||i(x,y)):

  Myylp||i(x,y):=subs(sol_cL,Myylp||i(x,y)):

  Vlp||i(x):=subs(sol_cL,Vlp||i(x)):

  Mxxlp||i(x):=-Eup*Ixxup||i*diff(Vlp||i(x),x$2):

  Nlp||i(x):=subs(sol_cL,Nlp||i(x)):

end:

for i from 1 to np do

  Wp||i(x,y):=subs(sol_cL,Wp||i(x,y)):

  Myyp||i(x,y):=subs(sol_cL,Myyp||i(x,y)):

  Vp||i(x):=subs(sol_cL,Vp||i(x)):

  Mxxp||i(x):=-Ep||i*Ixxp||i*diff(Vp||i(x),x$2):

  Np||i(x):=subs(sol_cL,Np||i(x)):

end:

#
# Compute desired outputs at various accuracy
# settings, by using evalf[n]() for various
# values of 'n'
#
  f:= x-> [seq( evalf[j](x), j=10..25,5)]:
  f(subs(x=L/2,Vp1(x)));
  f(subs(x=L/2,Vp2(x)));
  f(subs(x=L/2,y=0,Wup1(x,y)));
  f(subs(x=L/2,y=0,Wlp1(x,y)));
 

[0.1357685133e-3, 0.135768513215361e-3, 0.13576851321537748786e-3, 0.1357685132153774877315145e-3]

 

[0.1386283175e-3, 0.138628320356835e-3, 0.13862832035679494736e-3, 0.1386283203567949475373214e-3]

 

[0.8489872229e-3, 0.848987223467273e-3, 0.84898722346726016804e-3, 0.8489872234672601681278974e-3]

 

[0.7366371047e-3, 0.736637098146683e-3, 0.73663709814669674524e-3, 0.7366370981466967446691314e-3]

(1)

#
# As above, but this time 'round' the results
# to a number of digits set by the parameter
# 'accuracy'
#
# Note that within each output "row", only the
# first differs from the other three, in the
# final 2 or 3 decimal places
#
  g:= (x, acc)-> evalf[acc]~([seq( evalf[j](x), j=10..25,5)]):
  accuracy:=10:
  g(subs(x=L/2,Vp1(x)), accuracy);
  g(subs(x=L/2,Vp2(x)), accuracy);
  g(subs(x=L/2,y=0,Wup1(x,y)), accuracy);
  g(subs(x=L/2,y=0,Wlp1(x,y)),accuracy);

[0.1357685144e-3, 0.1357685132e-3, 0.1357685132e-3, 0.1357685132e-3]

 

[0.1386283175e-3, 0.1386283204e-3, 0.1386283204e-3, 0.1386283204e-3]

 

[0.8489872229e-3, 0.8489872235e-3, 0.8489872235e-3, 0.8489872235e-3]

 

[0.7366371047e-3, 0.7366370981e-3, 0.7366370981e-3, 0.7366370981e-3]

(2)

 


 

Download consistency.mw

 

Consider the toy example, which for some reason wont display inline here?!)

listPlot.mw

Maybe as a CNC machining problem some solutions are "excluded", but as a straightforward problem in geometry - ie a circle tangent to a line and another circle, then shouldn't there be four solutions, as in the attached

  restart:
  with(geometry):
  _EnvHorizontalName:=x:
  _EnvVerticalName:=y:
  x0 := (3+1/2)/2:
  x1 := x0: y1 := x0 + (1+1/4):
  point(P1, x1, y1):
  circle(C2, [P1, x0]):
  x3 := (3+1/2)/2-(3/4+20/1000)/2-1/2:
  y3 := 1+1/4: evalf([x3, y3]):
  point(P2, x3, 0):
  point(P3, x3, y3):
  line(L1, [P2, P3]):
  intersection(I1, L1, C2, [IP1, IP2]):
  tr := 1/8:
  x4 := x3 - tr:
  point(P4, x4, y4):
#
# Calculate all four possible solution circles
#
  circle(C4a, [point(P4a, x4, eval(y4, solve({distance(P4, P1)=tr+x1, y4<y1}))), tr]):
  circle(C4b, [point(P4b, x4, eval(y4, solve({distance(P4, P1)=x1-tr, y4<y1}))), tr]):
  circle(C4c, [point(P4c, x4, eval(y4, solve({distance(P4, P1)=tr+x1, y4>y1}))), tr]):
  circle(C4d, [point(P4d, x4, eval(y4, solve({distance(P4, P1)=x1-tr, y4>y1}))), tr]):
#
# Plot of all solutions
#
  draw([L1(color=blue), C2(color=green), C4a(color=red), C4b(color=red), C4c(color=red), C4d(color=red)]);
#
# Details of "lower" two solution circles
#
  draw([L1(color=blue), C2(color=green), C4a(color=red), C4b(color=red)], view=[0..1,1..2]);
  detail(C4a);
  detail(C4b);
#
# Details of "upper" two solution circles
#
  draw([L1(color=blue), C2(color=green), C4c(color=red), C4d(color=red)], view=[0..1,4..5]);
  detail(C4c);
  detail(C4d);

 

 

GeometryDetail(["name of the object", C4a], ["form of the object", circle2d], ["name of the center", P4a], ["coordinates of the center", [37/50, 3-(1/200)*sqrt(99821)]], ["radius of the circle", 1/8], ["equation of the circle", x^2+y^2-(37/25)*x+y*(-6+(1/100)*sqrt(99821))+21279/40000+(3-(1/200)*sqrt(99821))^2 = 0])

 

GeometryDetail(["name of the object", C4b], ["form of the object", circle2d], ["name of the center", P4b], ["coordinates of the center", [37/50, 3-(1/200)*sqrt(64821)]], ["radius of the circle", 1/8], ["equation of the circle", x^2+y^2-(37/25)*x+y*(-6+(1/100)*sqrt(64821))+21279/40000+(3-(1/200)*sqrt(64821))^2 = 0])

 

 

GeometryDetail(["name of the object", C4c], ["form of the object", circle2d], ["name of the center", P4c], ["coordinates of the center", [37/50, 3+(1/200)*sqrt(99821)]], ["radius of the circle", 1/8], ["equation of the circle", x^2+y^2-(37/25)*x+y*(-6-(1/100)*sqrt(99821))+21279/40000+(3+(1/200)*sqrt(99821))^2 = 0])

 

GeometryDetail(["name of the object", C4d], ["form of the object", circle2d], ["name of the center", P4d], ["coordinates of the center", [37/50, 3+(1/200)*64821^(1/2)]], ["radius of the circle", 1/8], ["equation of the circle", x^2+y^2-(37/25)*x+y*(-6-(1/100)*64821^(1/2))+21279/40000+(3+(1/200)*64821^(1/2))^2 = 0])

(1)

 

 

  

 

Download circGeom.mw

If you have 'Y' as an Array whose dimensions are (say for example) 1..10.

The you have to be careful with expressions such as Y[ i + 1 ] - Y[ i - 1 ], because if you try to compute them over the range i=1..10, then rather obviously, this would require accessing both Y[11] and Y[0], neither of which exist. This is the most common way to get the problem  "Error, bad index into Array".

It would be much simpler to give you a detailed diagnosis if you uploaded the offending worksheet using the big green up-arrow in the MaplePrimes toolbar - but for now you should just heed the error message - you are trying to access an entry in the Array which simply does not exist

 

using 'true', 'false' values and built 'xor' command (NB thats xor, not Logic:-&xor)

  restart;
#
# Define three signals as simple lists
#
  A:=[seq( [false$4, true$4][], j=1..4)]:
  B:=[seq( [false$2, true$2][], j=1..8)]:
  C:=[seq( [false$1, true$1][], j=1..16)]:
  myXOR:= (U,V)-> zip( `xor`, U ,V):
  toPW:=M->piecewise(seq( [t<j, `if`(M[j],1,0)][], j=1..numelems(M))):
#
# Plot relevant waveforms, offset in the y-direction
# by 2, and adjust the y-axis tickmarks
#
  plot( [ toPW(myXOR( myXOR(A, B), C) ),
          toPW(A)+2,
          toPW(B)+4,
          toPW(C)+6
        ],
        t=0..16,
        tickmarks=[ default,
                    [seq( j=j mod 2, j=0..7)]
                  ]
    );

 

 

Download logDiag2.mw

It's on the 'File' menu, just below the 'Print' command - see screen snip from my installation (on 64-bit Win 7) below.

Can't imagine it would be anywhere else on a Mac!

 - and there are (probably) many others!

NB graphic "renders" better in a Mple worksheet than it does here

  restart;
#
# Define three signals as simple lists
#
  A:=[seq( [0$4, 1$4][], j=1..4)]:
  B:=[seq( [0$2, 1$2][], j=1..8)]:
  C:=[seq( [0$1, 1$1][], j=1..16)]:
#
# Define a function which performs 'xor'
# on the elements of 2 lists
#
  myXOR:= (V,U) -> zip((i,j)-> (i+j) mod 2, V, U):
#
# Define a function which converts a
# list to a piecewise "waveform"
#
  toPW:=M->piecewise(seq( [t<j, M[j]][], j=1..numelems(M))):
#
# Plot relevant waveforms, offset in the y-direction
# by 2, and adjust the y-axis tickmarks
#
  plot( [ toPW(myXOR( myXOR(A, B), C) ),
          toPW(A)+2,
          toPW(B)+4,
          toPW(C)+6
        ],
        t=0..16,
        tickmarks=[ default,
                    [seq( j=j mod 2, j=0..7)]
                  ]
    );
 

 

 

Download logDiag.mw

It is not particularly difficult to define three vectors (u,p,q) in such a way that the integrand is defined.

The first issue is that presumably these vectors are not constant - otherwise the integrand would be a constant, and integrating a constant along a path defined a vector (even once) is probably(?) not going to be interesting, so I assume that in some sense these vectors are actually "variable". The comventional approach to this situations is to parameterize the vectors - ie the coefficients multiplying each of the basis vectors depend on some other variable - say 't', so for example u could be written something like u1(t)*i+u2(t)*j+u3(t)*k. This also is pretty trivial to do (see the attached)

The integrand still is pretty easy to define in terms of these variable vectors, provided that one remembers that one cannot "square" vectors, the dot product is mandatory. The net result of this is that the integrand is a scalar function of the parameterisation variable 't'. This scalar function can be integrate wrt a vector (technically it is a "path integral") and this too, is simple to define in Maple (see the attached). Whether or not it can be solved, (numerically or otherwise) is an entirely different matter - almost certainly dependent on the vector parameterisations.

The thing I really don't get is that you appear(?) to want three nested path integrals - hiowever the result of performing the "innermost" integration will be a constant, sice the integran is now a function of a single variable, and you are integrating along a 'path' which is a function of that variable. So what happens with the "outer" two integrals, where you integrate a scalar quantity along an infinite path. Doesn't seem like a good idea!!

Anyway for what it is worth, see thet attached whihc shows how to set up the parameterized vectors and the "innermost" path integral. I have done thi using cartesian coordinates, although it would be trivial to convert to spherical polars. Choice of coordinate system, does not overcome the problem that the result of the "innermost" path integral is still going to be a scalar, and integrating along two further infinite paths (in whatever coordinate system) just doesn't seem sensible.

I suppose the alternative is that I just don't really understand your problem or what you are trying to achieve:-(

restart;
with(VectorCalculus):
#
# Define three parameterized vectors in
# Cartesian coordinates (the default)
#
  p:=Vector(3, [ p__1(t), p__2(t), p__3(t) ]);
  q:=Vector(3, [ q__1(t), q__2(t), q__3(t) ]);
  w:=Vector(3, [ w__1(t), w__2(t), w__3(t) ]);
#
# Construct the integrand. NB this results in
# a scalar quantity
#
  IG:=(w.w +m^2)^(1/4)*(p.p+mu*2)^(1/4)/((w.w+a^2)^2*(p.p+a^2)*(q.q+b__2^2)^2*((p-q+w).(p-q+w)+b__1^2) );
#
# Set up the path integral along the vector 'p'
# OP seems to want to integrate along the vector
# from -Infinity to Infinity, so that the range
# of the parameterisation variable will have
# to ensure this - the following just uses
#
#            t=-Infinity..Infinity
#
# more or less as a placehoder
#
  PathInt(IG, [x,y,z]=Path(p, t=-Infinity..Infinity), 'inert');
#
# There appears to be no reason why these path
# integrals could not be nested
#

Vector(3, {(1) = `#msub(mi("p"),mi("1"))`(t), (2) = `#msub(mi("p"),mi("2"))`(t), (3) = `#msub(mi("p"),mi("3"))`(t)})

 

Vector(3, {(1) = `#msub(mi("q"),mi("1"))`(t), (2) = `#msub(mi("q"),mi("2"))`(t), (3) = `#msub(mi("q"),mi("3"))`(t)})

 

Vector(3, {(1) = `#msub(mi("w"),mi("1"))`(t), (2) = `#msub(mi("w"),mi("2"))`(t), (3) = `#msub(mi("w"),mi("3"))`(t)})

 

(w__1(t)^2+w__2(t)^2+w__3(t)^2+m^2)^(1/4)*(p__1(t)^2+p__2(t)^2+p__3(t)^2+2*mu)^(1/4)/((w__1(t)^2+w__2(t)^2+w__3(t)^2+a^2)^2*(p__1(t)^2+p__2(t)^2+p__3(t)^2+a^2)*(q__1(t)^2+q__2(t)^2+q__3(t)^2+b__2^2)^2*((p__1(t)-q__1(t)+w__1(t))^2+(p__2(t)-q__2(t)+w__2(t))^2+(p__3(t)-q__3(t)+w__3(t))^2+b__1^2))

 

Int((w__1(t)^2+w__2(t)^2+w__3(t)^2+m^2)^(1/4)*(p__1(t)^2+p__2(t)^2+p__3(t)^2+2*mu)^(1/4)*((diff(p__1(t), t))^2+(diff(p__2(t), t))^2+(diff(p__3(t), t))^2)^(1/2)/((w__1(t)^2+w__2(t)^2+w__3(t)^2+a^2)^2*(p__1(t)^2+p__2(t)^2+p__3(t)^2+a^2)*(q__1(t)^2+q__2(t)^2+q__3(t)^2+b__2^2)^2*((p__1(t)-q__1(t)+w__1(t))^2+(p__2(t)-q__2(t)+w__2(t))^2+(p__3(t)-q__3(t)+w__3(t))^2+b__1^2)), t = -Infinity .. Infinity)

(1)

 


 

Download pathInt.mw

 

as in

isolate( F*R=(1/2*M*R^2)*(a/R), F);

 

I assume that this question is related to the earlier one at

https://www.mapleprimes.com/questions/225366-How-To-Make-A-Two-Dimensional-Ising-Model

(I recognised the code snippet)

I had a spare hour yesterday evening, so this response is actually my attempt at answering your earlier question - bearing in mind that I don't really know what an "Ising model" is! So what does this code do

  1. Generates an nxn matrix with elements randomly chosen from [-1,1]
  2. Defines an "energy function" for this matrix, based on
    1. imposing "periodic boundary conditions" on the random matrix
    2. nearest-neighbour interaction
    3. a really simple definition of "energy" - neghbours have the same spin, then energy=1: if they have opposite spin then energy=-1. With four nearest neighbours, the resulting energy-per-element must be in the range -4..4
    4. adds all the energy-per-element values to get a total "energy" for the matrix
    5. Note that this means that the "lowest energy" configuration is a "checkerboard", ie the matrix has alternating +1, -1 entries
    6. Note also that with periodic boundary conditions the 'lowest energy configuration can only be obtained if the matrix has even dimensions. The code works if the matrix has odd dimension, but since there are actually multiple configurations with the same "lowest energy", then one will just cycle around these without really getting anywhere!
  3. Randomly change a single element in the matrix, and recompute the energy. If the new "energy" is <= the old "energy" then accept the new matrix as valid
  4. Repeat (3) above until either
    1. No lower energy configuration can be found (at least by this random process): the code will only attempt a maximum of 1000 random single-element changes before it bails out. Obviously you can change this, but be careful, otherwise run times will start to climb
    2. The total number of new (lower "energy") matrices is restricted to 200. This may (or may not) result in the lowest  possible enrgy configuration being obtained: again it can be increased at the expense of run times. As a result of 2.6 above, if the matrix has an odd dimension, then this limit will stop the code runniing for ever
    3. Up to 10*10 matrices, I was always able to achieve the "checkerboard" lowest state within 200 iterations - above this I wasn't! Increasing this iteration limit *may* allow the ultimate "checkerboard" to be obtained, but I'd be careful because I suspect that run times might really *explode*
  5. Produce an animation on the resulting matrices, using two colours to represent the values +1, -1: so if the minimum energy configuration has been obtained, then this *ought* to be a checkerboard
  6. Produce a plot of the "total energy" which will be a decreasing function, but may not reach zero. For matrices with one or more odd dimensions, this energy curve will flatten out at some non-zero value

This code could probably be made more efficient/faster, but I am reluctant to do this because

  1. It may not even be simulating the behaiour you want - so any improvement would be in the category "lipstick on a pig"
  2. I don't really have the time

So with all of the above caveats, you may (or may not!) want to play with the attached code - the animation is easier to follow in a Maple worksheet rather than on this site, where the start/stop points (ie final checkerboard) are not obvious!

  restart;
  with(LinearAlgebra):
  with(plots):
  with(plottools):
#
# Set up matrix size and random number
# generators. Things start to slow down
# down a bit with more than 10*10 matrices,
# so be careful what you ask for!
#
  nR:=10:
  nC:=10:
  rv:=rand(0..1):
  s:=()->(-1)^rv():
  C:=RandomMatrix(nR, nC, generator=s):
  rR:=rand(1..nR):
  rC:=rand(1..nC):
#
# Define the procedure which changes a matrix
# entry, looking for a "lower energy"
# configuration
#
  doIter:=proc( mat::Matrix, rv1::procedure, rv2:=procedure)
                local augment, getE, oldE, newE,
                      matC:=mat, roll1, roll2,
                      count:=0:
              #
              # Define a procedure which "augments" the input
              # matrix so as to mimic periodic boundary conditions
              #
                augment:=proc( M::Matrix )
                               local augM;
                               augM:=Matrix( op([1,1],M)+2,
                                             op([1,2],M)+2,
                                             fill=0
                                           );
                               augM[2..op([1,1],M)+1, 2..op([1,2],M)+1]:=M;
                               augM[1, 2..op([1,2],M)+1]:= M[op([1,1],M),..]:
                               augM[op([1,1],M)+2, 2..op([1,2],M)+1]:= M[1,..]:
                               augM[2..op([1,1],M)+1,1]:=M[..,op([1,2],M)]:
                               augM[2..op([1,1],M)+1, op([1,2],M)+2]:=M[..,1]:
                               return augM
                        end proc;
              #
              # Define a simple energy function for the
              # augmented matrix
              #
                getE:= proc( M::Matrix)
                             add
                             ( add
                               ( (M[i-1,j]+M[i+1,j]+M[i,j-1]+M[i,j+1])*M[i,j],
                                 i=2..op([1,1],M)-1
                               ),
                               j=2..op([1,2],M)-1
                             )
                             +
                             4*(op([1,1],M)-2)*(op([1,2],M)-2);
                       end proc:
              #
              # Compute the "energy" of input matrix
              #
                oldE:=getE(augment(matC));
              #
              # Randomly change one entry in the input matrix
              # and check the new "energy". If it is <= to
              # the old "energy", then accept this new matrix
              # and exit.
              #
              # Restrict the number of attempts to 1000, just
              # to stop this getting stuck *permanently*
              #
                while true do
                      roll1:=rv1():
                      roll2:=rv2():
                      matC[roll1, roll2]:=-1*matC[roll1, roll2]:
                      newE:=getE(augment(matC)):
                      if   newE <= oldE
                      then return [newE, matC]
                      else matC[roll1, roll2]:=-1*matC[roll1, roll2]:
                      fi:
                      count:=count+1:
                      if count=1000
                      then return "ERROR"
                      fi:
              od:
       end proc:
#
# Define a plotting function, which I wouldn't have to
# do if the HeatMap() command could be used in animation,
# (and I still have no idea why it can't
#
  colors:=[red,blue]:
  gP:= M-> display
           ( [ seq
               ( seq
                 ( rectangle
                   ( [i-1,j-1],[i,j],
                     color=colors[(M[i,j]+3)/2]
                   ),
                   i=1..op([1,1],M)
                 ),
                 j=1..op([1,2],M)
               )
             ],
             scaling=constrained
           ):
#
# Initialise the loop and produce the starting
# plot
#
  p[1]:=C:
  q[1]:=gP(p[1]):
#
# Perform iterations. If doIter() is successful
# (ie produces a matrix) then generate a plot.
# If it is unsuccessful, then it will return a
# string, at which point this loop will terminate
#
# For a starting 10*10 Matrix, it takes ~150
# iterations through this loop to reach the
# ultimate "minimum energy" state, although
# it is not obvius to me that the final
# checkerboard (minimum energy) state would
# ever (necessarily) be obtained by the random
# process - getting stuck in some kind of
# cycle must (surely?) be a possibility
#
# So the upper limit on this loop is just to
# avoid excessive run times - you can raise
# it, but do so carefully
#
  for k from 2 by 1 to 200 do
      ans:= doIter(copy(p[k-1],deep), rR, rC);
      if   type( ans[2], Matrix )
      then p[k]:= ans[2]:
           E[k]:= ans[1]:
           q[k]:=gP(p[k]):
      else break
      fi
  od:
  printf("Actually did %d iterations\n",k-1):

Actually did 149 iterations

 

#
# Show the total "energy". This ought to be a
# decreasing function, but may or may not reach
# zero, depending on whether the lowext enrgy state
# has been achieved
#
  listplot( convert(E, list) );
#
# Animate the results which have been obtained.
# This can be a bit slow, depending on the size
# of the matrix, and the number of iteration
# steps which have been used. For 10*10 matrices
# and ~200 iterations, I would call it acceptable
# (ie ~30secs)
#
  display( convert(q, list), insequence=true);

 

 

 

 


 

Download ising.mw

whihc is basically just a different way to select the first column

restart;
with(LinearAlgebra):
A := Matrix(3, 3, [[-3, 32/5, 4], [4, 24/5, 3], [5, 6*sqrt(2), 5*sqrt(2)]]);
GivensRotationMatrix(A[..,1],1,2);

For future reference, the "simplest" way to upload code here is just to use the big green up-arrow in the toolbar to upload your Maple worksheet

assume(phi, real);
eq1:=exp(I*phi);
simplify(conjugate(eq1)*eq1);

which returns '1'

The attached returns a list of lists: in each sublist, the first entry is the valueof a matrix element; subsequent enties in the sublist are the indices where this matrix entry occurs. It would (probably) be fairly trivial to reorganise this data in alterntive formats - if I knew what format you actually wanted

restart;
with(ListTools):
M:=Matrix(4, 4, [ [ 1, 2, 3, 4 ],
                  [ 2, 3, 4, 5 ],
                  [ 3, 4, 5, 6 ],
                  [ 4, 5, 6, 7 ]
                ]
         ):
Ent:=[entries(M, nolist)]:
Ind:=[indices(M)]:
[{seq( [{j, seq( Ind[k], k in SearchAll(j, Ent))}[]], j in Ent)}[]];

[[1, [1, 1]], [7, [4, 4]], [2, [1, 2], [2, 1]], [6, [3, 4], [4, 3]], [3, [1, 3], [2, 2], [3, 1]], [5, [2, 4], [3, 3], [4, 2]], [4, [1, 4], [2, 3], [3, 2], [4, 1]]]

(1)

 

Download matEntry.mw

You have many choices, amongst which are

  1. a list of matrices
  2. a set of matrices
  3. a table of matrices
  4. an array of matrices
  5. a row vector of matrices
  6. a column vector of matrices
  7. a matrix, each of whose diagonal entries is the required 2x2 matrix

The choice depends on how you feel about potential duplicate entries, and how you subsequently want to access, change, add to, or delete entries from the defined data structure. Depending on what you want to do with this information, one of these structures *may* be more convenient than others - only you can determine this.

The attached illustrates all of the above possibilities (and there are others!!!)

  restart;
  interface(rtablesize=20):

#
# Generate a *list* each of whose entries is
# a 2x2 matrix
#
  A:= [ seq
        ( Matrix
          ( [ [ k,   k^2],
              [ 2*k, 2*k^2]
            ]
          ),
          k=1..10
        )
      ];
  whattype(A);

[Matrix(2, 2, {(1, 1) = 1, (1, 2) = 1, (2, 1) = 2, (2, 2) = 2}), Matrix(2, 2, {(1, 1) = 2, (1, 2) = 4, (2, 1) = 4, (2, 2) = 8}), Matrix(2, 2, {(1, 1) = 3, (1, 2) = 9, (2, 1) = 6, (2, 2) = 18}), Matrix(2, 2, {(1, 1) = 4, (1, 2) = 16, (2, 1) = 8, (2, 2) = 32}), Matrix(2, 2, {(1, 1) = 5, (1, 2) = 25, (2, 1) = 10, (2, 2) = 50}), Matrix(2, 2, {(1, 1) = 6, (1, 2) = 36, (2, 1) = 12, (2, 2) = 72}), Matrix(2, 2, {(1, 1) = 7, (1, 2) = 49, (2, 1) = 14, (2, 2) = 98}), Matrix(2, 2, {(1, 1) = 8, (1, 2) = 64, (2, 1) = 16, (2, 2) = 128}), Matrix(2, 2, {(1, 1) = 9, (1, 2) = 81, (2, 1) = 18, (2, 2) = 162}), Matrix(2, 2, {(1, 1) = 10, (1, 2) = 100, (2, 1) = 20, (2, 2) = 200})]

 

list

(1)

#
# Generate a *set* each of whose entries is
# a 2x2 matrix
#
  A:= { seq
        ( Matrix
          ( [ [ k,   k^2],
              [ 2*k, 2*k^2]
            ]
          ),
          k=1..10
        )
      };
  whattype(A);

{Matrix(2, 2, {(1, 1) = 2, (1, 2) = 4, (2, 1) = 4, (2, 2) = 8}), Matrix(2, 2, {(1, 1) = 3, (1, 2) = 9, (2, 1) = 6, (2, 2) = 18}), Matrix(2, 2, {(1, 1) = 4, (1, 2) = 16, (2, 1) = 8, (2, 2) = 32}), Matrix(2, 2, {(1, 1) = 5, (1, 2) = 25, (2, 1) = 10, (2, 2) = 50}), Matrix(2, 2, {(1, 1) = 6, (1, 2) = 36, (2, 1) = 12, (2, 2) = 72}), Matrix(2, 2, {(1, 1) = 7, (1, 2) = 49, (2, 1) = 14, (2, 2) = 98}), Matrix(2, 2, {(1, 1) = 8, (1, 2) = 64, (2, 1) = 16, (2, 2) = 128}), Matrix(2, 2, {(1, 1) = 9, (1, 2) = 81, (2, 1) = 18, (2, 2) = 162}), Matrix(2, 2, {(1, 1) = 10, (1, 2) = 100, (2, 1) = 20, (2, 2) = 200}), Matrix(2, 2, {(1, 1) = 1, (1, 2) = 1, (2, 1) = 2, (2, 2) = 2})}

 

set

(2)

#
# Generate a *table* each of whose entries is
# a 2x2 matrix
#
  A:= table
      ( [ seq
          ( Matrix
            ( [ [ k,   k^2],
                [ 2*k, 2*k^2]
              ]
            ),
            k=1..10
          )
        ]
      );
  whattype(op(A));

table(%id = 18446744074361283486)

 

table

(3)

#
# Generate an *Array*, each of whose entries is
# a 2x2 Matrix
#
  A:= Array
      ( 1..10,
        k->Matrix( [ [ k,   k^2],
                     [ 2*k, 2*k^2]
                   ]
                 )
      );
  whattype(A);

Vector[row](10, {(1) = Matrix(2, 2, {(1, 1) = 1, (1, 2) = 1, (2, 1) = 2, (2, 2) = 2}), (2) = Matrix(2, 2, {(1, 1) = 1, (1, 2) = 1, (2, 1) = 2, (2, 2) = 2}), (3) = Matrix(2, 2, {(1, 1) = 1, (1, 2) = 1, (2, 1) = 2, (2, 2) = 2}), (4) = Matrix(2, 2, {(1, 1) = 1, (1, 2) = 1, (2, 1) = 2, (2, 2) = 2}), (5) = Matrix(2, 2, {(1, 1) = 1, (1, 2) = 1, (2, 1) = 2, (2, 2) = 2}), (6) = Matrix(2, 2, {(1, 1) = 1, (1, 2) = 1, (2, 1) = 2, (2, 2) = 2}), (7) = Matrix(2, 2, {(1, 1) = 1, (1, 2) = 1, (2, 1) = 2, (2, 2) = 2}), (8) = Matrix(2, 2, {(1, 1) = 1, (1, 2) = 1, (2, 1) = 2, (2, 2) = 2}), (9) = Matrix(2, 2, {(1, 1) = 1, (1, 2) = 1, (2, 1) = 2, (2, 2) = 2}), (10) = Matrix(2, 2, {(1, 1) = 1, (1, 2) = 1, (2, 1) = 2, (2, 2) = 2})})

 

Array

(4)

#
# Generate a column Vector, each of whose entries
# is a 2x2 Matrix
#
  A:= Vector[column]
      ( 10,
        k->Matrix( [ [ k,   k^2],
                     [ 2*k, 2*k^2]
                   ]
                 )
      );
  whattype(A);

Vector(10, {(1) = Matrix(2, 2, {(1, 1) = 1, (1, 2) = 1, (2, 1) = 2, (2, 2) = 2}), (2) = Matrix(2, 2, {(1, 1) = 2, (1, 2) = 4, (2, 1) = 4, (2, 2) = 8}), (3) = Matrix(2, 2, {(1, 1) = 3, (1, 2) = 9, (2, 1) = 6, (2, 2) = 18}), (4) = Matrix(2, 2, {(1, 1) = 4, (1, 2) = 16, (2, 1) = 8, (2, 2) = 32}), (5) = Matrix(2, 2, {(1, 1) = 5, (1, 2) = 25, (2, 1) = 10, (2, 2) = 50}), (6) = Matrix(2, 2, {(1, 1) = 6, (1, 2) = 36, (2, 1) = 12, (2, 2) = 72}), (7) = Matrix(2, 2, {(1, 1) = 7, (1, 2) = 49, (2, 1) = 14, (2, 2) = 98}), (8) = Matrix(2, 2, {(1, 1) = 8, (1, 2) = 64, (2, 1) = 16, (2, 2) = 128}), (9) = Matrix(2, 2, {(1, 1) = 9, (1, 2) = 81, (2, 1) = 18, (2, 2) = 162}), (10) = Matrix(2, 2, {(1, 1) = 10, (1, 2) = 100, (2, 1) = 20, (2, 2) = 200})})

 

Vector[column]

(5)

#
# Generate a row Vector, each of whose entries
# is a 2x2 Matrix
#
  A:= Vector[row]
      ( 10,
        k->Matrix( [ [ k,   k^2],
                     [ 2*k, 2*k^2]
                   ]
                 )
      );
  whattype(A);

Vector[row](10, {(1) = Matrix(2, 2, {(1, 1) = 1, (1, 2) = 1, (2, 1) = 2, (2, 2) = 2}), (2) = Matrix(2, 2, {(1, 1) = 2, (1, 2) = 4, (2, 1) = 4, (2, 2) = 8}), (3) = Matrix(2, 2, {(1, 1) = 3, (1, 2) = 9, (2, 1) = 6, (2, 2) = 18}), (4) = Matrix(2, 2, {(1, 1) = 4, (1, 2) = 16, (2, 1) = 8, (2, 2) = 32}), (5) = Matrix(2, 2, {(1, 1) = 5, (1, 2) = 25, (2, 1) = 10, (2, 2) = 50}), (6) = Matrix(2, 2, {(1, 1) = 6, (1, 2) = 36, (2, 1) = 12, (2, 2) = 72}), (7) = Matrix(2, 2, {(1, 1) = 7, (1, 2) = 49, (2, 1) = 14, (2, 2) = 98}), (8) = Matrix(2, 2, {(1, 1) = 8, (1, 2) = 64, (2, 1) = 16, (2, 2) = 128}), (9) = Matrix(2, 2, {(1, 1) = 9, (1, 2) = 81, (2, 1) = 18, (2, 2) = 162}), (10) = Matrix(2, 2, {(1, 1) = 10, (1, 2) = 100, (2, 1) = 20, (2, 2) = 200})})

 

Vector[row]

(6)

#
# Generate a matrix, whose diagonal entries
# are the required 2x2 Matrices
#
  A:= Matrix( 10,
              10,
              (i,j)->`if`( i=j,
                           Matrix( [ [ i,   i^2],
                                    [ 2*i, 2*i^2]
                                   ]
                                 ),
                           0
                         )
            );
  whattype(A);

Matrix(10, 10, {(1, 1) = Matrix(2, 2, {(1, 1) = 1, (1, 2) = 1, (2, 1) = 2, (2, 2) = 2}), (1, 2) = 0, (1, 3) = 0, (1, 4) = 0, (1, 5) = 0, (1, 6) = 0, (1, 7) = 0, (1, 8) = 0, (1, 9) = 0, (1, 10) = 0, (2, 1) = 0, (2, 2) = Matrix(2, 2, {(1, 1) = 2, (1, 2) = 4, (2, 1) = 4, (2, 2) = 8}), (2, 3) = 0, (2, 4) = 0, (2, 5) = 0, (2, 6) = 0, (2, 7) = 0, (2, 8) = 0, (2, 9) = 0, (2, 10) = 0, (3, 1) = 0, (3, 2) = 0, (3, 3) = Matrix(2, 2, {(1, 1) = 3, (1, 2) = 9, (2, 1) = 6, (2, 2) = 18}), (3, 4) = 0, (3, 5) = 0, (3, 6) = 0, (3, 7) = 0, (3, 8) = 0, (3, 9) = 0, (3, 10) = 0, (4, 1) = 0, (4, 2) = 0, (4, 3) = 0, (4, 4) = Matrix(2, 2, {(1, 1) = 4, (1, 2) = 16, (2, 1) = 8, (2, 2) = 32}), (4, 5) = 0, (4, 6) = 0, (4, 7) = 0, (4, 8) = 0, (4, 9) = 0, (4, 10) = 0, (5, 1) = 0, (5, 2) = 0, (5, 3) = 0, (5, 4) = 0, (5, 5) = Matrix(2, 2, {(1, 1) = 5, (1, 2) = 25, (2, 1) = 10, (2, 2) = 50}), (5, 6) = 0, (5, 7) = 0, (5, 8) = 0, (5, 9) = 0, (5, 10) = 0, (6, 1) = 0, (6, 2) = 0, (6, 3) = 0, (6, 4) = 0, (6, 5) = 0, (6, 6) = Matrix(2, 2, {(1, 1) = 6, (1, 2) = 36, (2, 1) = 12, (2, 2) = 72}), (6, 7) = 0, (6, 8) = 0, (6, 9) = 0, (6, 10) = 0, (7, 1) = 0, (7, 2) = 0, (7, 3) = 0, (7, 4) = 0, (7, 5) = 0, (7, 6) = 0, (7, 7) = Matrix(2, 2, {(1, 1) = 7, (1, 2) = 49, (2, 1) = 14, (2, 2) = 98}), (7, 8) = 0, (7, 9) = 0, (7, 10) = 0, (8, 1) = 0, (8, 2) = 0, (8, 3) = 0, (8, 4) = 0, (8, 5) = 0, (8, 6) = 0, (8, 7) = 0, (8, 8) = Matrix(2, 2, {(1, 1) = 8, (1, 2) = 64, (2, 1) = 16, (2, 2) = 128}), (8, 9) = 0, (8, 10) = 0, (9, 1) = 0, (9, 2) = 0, (9, 3) = 0, (9, 4) = 0, (9, 5) = 0, (9, 6) = 0, (9, 7) = 0, (9, 8) = 0, (9, 9) = Matrix(2, 2, {(1, 1) = 9, (1, 2) = 81, (2, 1) = 18, (2, 2) = 162}), (9, 10) = 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) = Matrix(2, 2, {(1, 1) = 10, (1, 2) = 100, (2, 1) = 20, (2, 2) = 200})})

 

Matrix

(7)

 

Download storeMat.mw

and has only been available since Maple 16 (that's Maple 16, not Maple 2016!).

The process is explained on the following help pages

?Snippets Palettes in Maple 16
?DocumentTools, AddPalette
?DocumentTools,AddPaletteEntry

First 125 126 127 128 129 130 131 Last Page 127 of 207