Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

can you do groupwork on a single documet 

Can anyone assist with the error please?
 

#Clear memory.
restart;

#Initialise variables and arrays.
h:=0.1;
n:=10;
k:=0.1;  
m:=10;
t:=Array(0..m):
x:=Array(0..n):
u:=Array(0..n,0..m):

#Initialise the x array and the initial u(x,0) boundary.
for i from 0 to n do
    x[i]:=i*h;
    u[i,0]:=exp(x[i]);
end do:

#Initialise the t array and the u(x,t) side boundaries.
for j from 0 to m do
   t[j]:=j*k;
   u[0,j]:=0;
   u[n,j]:=t[j];
end do:

#Use the 2D CTCS explicit wave method.
for i from 1 to n-1 do
   u[i,1]:=(9*u[i-1,0]+14*u[i,0]+9*u[i+1,0])/32+[i]/10;
end do:
 
for j from 1 to m-1 do
  for i from 0 to n-1 do
   u[i,j+1]:=(9*u[i-1,j]+14**u[i,j]+9*u[i+1,j])/16-u[i,j-1];
  end do;
end do:

#Display the u(x,t)values.
printf("2D CTCS Explicit Wave Method\n");
printf("----------------------------\n");
printf("x\t\t t\t\t u\n");
for i from 0 to n do
   printf("% f\t% f\t% f\n",x[i],t[m],u[i,m]);
end do;

.1

 

10

 

.1

 

10

 

Error, Array index out of range

 

2D CTCS Explicit Wave Method
----------------------------
x                 t                 u
 0.000000         1.000000         0.000000
 0.100000         1.000000         0.000000
 0.200000         1.000000         0.000000
 0.300000         1.000000         0.000000
 0.400000         1.000000         0.000000
 0.500000         1.000000         0.000000
 0.600000         1.000000         0.000000
 0.700000         1.000000         0.000000
 0.800000         1.000000         0.000000
 0.900000         1.000000         0.000000
 1.000000         1.000000         1.000000

 

NULL


 

Download Asst_3_Q2b.mw

HI,
I want to simplify an algebraic experssion. How do I do this with Maple?
A1.mw

Hi,

In the code below I do not understand why f(3,1) cannot be computed : it returns the conjugate of D1[2,2] although I have defined it as a random number. Maybe you understand this ? Actually I first got an error message of the type "bad index into matrix". Thus I wrote ''D1''[t, t] instead of D1[t, t] to fix the issue in the product. 

Many thanks in advance for your help

with(LinearAlgebra);
D1 := evalf(RandomMatrix(3));
f := (i, j) -> if i = j then D1[i, i]; elif i = j + 1 then (1 - abs(D1[i, i])^2)^(1/2)*(1 - abs(D1[j, j])^2)^(1/2); elif j + 1 < i then (1 - abs(D1[i, i])^2)^(1/2)*(1 - abs(D1[j, j])^2)^(1/2)*product(-conjugate(''D1''[t, t]), t = j + 1 .. i - 1); else 0; end if;
f(1, 1);
f(1, 2), f(1, 3);
f(2, 2);
f(2, 3);
f(3, 3);
f(2, 1);
f(3, 2);
f(3, 1);
Modu := evalf(Matrix(3, (i, j) -> f(i, j)));

f(3,1) is given by 3222.984487*conjugate(D1[2, 2]): I do not get why the value of D1[2,2] is ignored.

Dear Colleagues,

I wish to use plot3d to the attached code but always encoutered error. However, pointplot3d runs perfectly. Please I need your assistance in this regards.

Thank you all and best regards.K2_Problem_2_two_body_kepler_e=0.mw

I have been using 'MemoryInUse()' to try to track down a memory leak that is crashing my Maple-based simulation. The problematic proc seems to be ProbDStarLNu which calculates the probablity of decay as a function of the angles of the decay product. It gets called a lot in acceptance rejection decay generation.

'MemoryInUse()' slows it down a lot. It also seemed to give weird results to me. I calculate the mem used on entry and then after the 4 trig functions have been called. The amount of mem 'in use' goes down after the trig functions are called. I was suspecting they were the source of the leak, but they seem almost an anti-leak.

This weird behavior caused me to write my own mem counting proc ('memUsed') based on summing over the results of 'mem:= kernelopts(memusage)'.

It is much faster. It gives nearly but not quite the same numbers. It still goes "backward" when the trig functions are called. Most of the mem growth comes from the algebra that follows the trig.

Why would that be?

I have included code for 'ProbDStarLNu'. It's pretty simple.

I have been having problem in solving this question because of the 'Whittaker'.

Can anyone please asist me how to integrate below problem with the 'Whitaker?

f := exp(-1.5*t)*(GAMMA(2)*t^(2-alpha)/GAMMA(3-alpha)-t^(1-alpha)/GAMMA(2-alpha)+t^2-t);
               /   (2 - alpha)        (1 - alpha)           \
               |  t                  t                 2    |
   exp(-1.5 t) |---------------- - ---------------- + t  - t|
               \GAMMA(3 - alpha)   GAMMA(2 - alpha)         /
int(f, t);
 

2.^(3.-1.*alpha)*3.^(alpha-3.)*(t^(-.5000000000*alpha)*3.^(-.5000000000*alpha)*2.^(.5000000000*alpha)*(alpha-3.)*(-2.+alpha)*exp(-.7500000000*t)*WhittakerM(-.5000000000*alpha, -.5000000000*alpha+.5000000000, 1.500000000*t)/(3.-1.*alpha)+t^(-.5000000000*alpha)*3.^(-.5000000000*alpha)*2.^(.5000000000*alpha)*(1.500000000*t-1.*alpha+2.)*(alpha-3.)*exp(-.7500000000*t)*WhittakerM(-.5000000000*alpha+1., -.5000000000*alpha+.5000000000, 1.500000000*t)/(3.-1.*alpha))/GAMMA(3.-1.*alpha)-1.*2.^(2.-1.*alpha)*3.^(-2.+alpha)*(t^(-.5000000000*alpha)*3.^(-.5000000000*alpha)*2.^(.5000000000*alpha)*exp(-.7500000000*t)*WhittakerM(-.5000000000*alpha, -.5000000000*alpha+.5000000000, 1.500000000*t)+t^(-.5000000000*alpha)*3.^(-.5000000000*alpha)*2.^(.5000000000*alpha)*(-2.+alpha)*exp(-.7500000000*t)*WhittakerM(-.5000000000*alpha+1., -.5000000000*alpha+.5000000000, 1.500000000*t)/(2.-1.*alpha))/GAMMA(2.-1.*alpha)+.1481481481+(0.9876543210e-1*(-6.750000000*t^2-9.*t-6.))*exp(-1.500000000*t)-(.2222222222*(-2.-3.*t))*exp(-1.500000000*t)

I want infinite series expansion of incomplete upper gamma function.

I'm trying to use CodeTools[Profile] to investigate my memory leak and the effect or lack there of of 'forget' to improve it.

I copied my code from an example:

with(CodeTools[Profiling]);
 [Allow, Build, Coverage, GetProfileTable, Ignore, IsProfiled, 

   LoadProfiles, Merge, PrintProfiles, Profile, Remove, 

   SaveProfiles, Select, SortBy, UnProfile]

Profile([PickAngles(1.0, 1.0, 1.0)]);
Error, (in CodeTools:-Profiling:-Profile) unexpected argument(s)

The 'unexpected argument' is the 'result' from 'PickAngles'. I've tried with and w/o the '[]' but it does the same thing failing to recognize that 'PickAngles' is a procedure.

The example I used is here:

https://www.maplesoft.com/support/help/maple/view.aspx?path=CodeTools%2FProfiling%2FProfile procedure.

I did what to make of the subscript Profiles in the example so I used '[Profiles]' and that worked or seemed to.

Dear Users!

I hope you are doing well. In the attached file I want to convert the system of ODEs (attained the system against the value of M) into matrix form and need the matrices A, B and vector b. Remember the order of A, B and b vary as M vary. I am waiting for your kind response. Please take care and thanks

System_of_ODEs.mw

I can import maple, but I get an error when importing namespace/symbols:

import maple.namespace as mpl

The below is not properly rendering in my browser. You probably have to open the worksheet
 

De Morgan's law from https://en.wikipedia.org/wiki/De_Morgan%27s_laws

NULL

iff(not (P or Q), `and`(not P, not Q))

not (P or Q) implies not (P or Q)

(1)

iff(not (P and Q), `or`(not P, not Q))

not (P and Q) implies not (P and Q)

(2)

NULL

 

Edit: Asking differently: Which symbol from the palettes can be used for equivalence (in a logic context)?

Edit2: Title changed. Original title: Why does Maple replace the equivalence symbol by an implication symbol

Download De_Morgans_law.mw

hi

I have a linear system with varibles trying to plot 3d the solutions x, y, z

here is my code: linear_var.mw

please any comment might help.

*******************************

restart;

Omega:=10:N:=0.5:M:=sqrt(N(N+1)):

a11:=0.5*(1+2*N)+M*cos(phi):
a12:=-0.5*((1+theta)^3+(1-theta)^3):a13:=-0.5*(N+M*cos(phi))*((1+theta)^3-(1-theta)^3): a21:=M*sin(phi): a22:=(-(1+2*N)+0.5*M*cos(phi))*((1+theta)^3+(1-theta)^3): a23:=-(Omega+0.5*((1+theta)^3-(1-theta)^3)*M*sin(phi)): a31:=0.25*((1+theta)^3-(1-theta)^3): a32:=Omega: a33:=-0.5-(N+0.25)*((1+theta)^3+(1-theta)^3): b1:=-0.5*a31: b2:=0: b3:=0.25+((1+theta)^3+(1-theta)^3)/8:

slove([a11*x+a12*y+a13*z=b1,a21*x+a22*y+a23*z=b2,a31*x+a32*y+a33*z=b3[,[x,y,z]);
Error, unable to match delimiters
Typesetting:-mambiguous(Typesetting:-mambiguous(slovelparlsqba11

  sdotx + a12sdoty + a13sdotzequalsb1commaa21sdotx + a22sdoty + 

  a23sdotzequalsb2commaa31sdotx + a32sdoty + a33sdotzequalsb3lsqb

  comma(xyz)rparsemi, 

  Typesetting:-merror("unable to match delimiters")))

plot3d(x, theta = .1 .. 5, phi = 0 .. 2*Pi, axes = boxed);
plot3d(y, theta = .1 .. 5, phi = 0 .. 2*Pi, axes = boxed); plot3d(z, theta = .1 .. 5, phi = 0 .. 2*Pi, axes = boxed);

I would like solving systems of congruences like the following one:

154x+69y = 0 mod 7^3

13x+716y = 0 mod 13^3

23x+3059y = 0 mod 23^3

I need the minimal non-trivial solution. I know that the solution of the system above is x=1103, y=26390.

How could I find the solution with Maple?

 

# ----------------------------------THE DESIGN OF THE MAPLET SCREEN---------------------
with(Maplets[Elements]):
HCC:=Maplet(Window('title'="HEAT CONDUCTIVITY CONTROL",["WITH THIS APPLICATION THE CONDUCTIVITY COEFFICIENT OF A ONE-DIMENSIONAL OBJECT, APPROXIMATING THE TEMPRATURE OF THE OBJECT TO A TARGET TEMPRETURE AT A CERTAIN FINAL TIME, IS CONTROLLED. ",[["l",TextField[l](3)],["T",TextField[T](3)],["f(x,t)",TextField[f](15)],["phi(x)",TextField[ph](5)]],[["k(0)",TextField[k0](3)],["g0(t)",TextField[g0](10)],["k(l)",TextField[kl](3)],["g1(t)",TextField[g1](10)],["mu(x)",TextField[mu](10)]],[["alpha",TextField[alpha](3)],["kaplus(x)",TextField[kaplus](5)],["N",TextField[N](3)],["kstart(x)",TextField[kstart](3)],["beta",TextField[beta](3)],["eps",TextField[eps](3)]] ,[Button("Calculate the Control",Evaluate('kutu'=ms(N,l,alpha,T,ph,f,g0,g1,mu,kaplus,k0,kl,kstart,beta,eps))),[TextBox['kutu'](30..30)],Button("Draw the Control",Evaluate('Draw'='plot(kutu,x=0..l)')),Plotter['Draw'](),[[Button("Distance to
Target",Evaluate('kutu2'=ms8(N,l,alpha,T,ph,f,g0,g1,mu,kaplus,k0,kl,kstart,beta,eps))),TextField['kutu2'](12)],[Button("Approximation to kaplus",Evaluate('kutu3'='evalf(int((kutu-kaplus)^2,x=0..l))')),TextField['kutu3'](12)]]],Button("Shutdown",Shutdown())])):
# -------------------------PROCEDURE FOR CALCULATION OF THE CONTROL FUNCTION-----------
with(inttrans):
with(linalg):
ms:=proc(N,l,alpha,T,ph,f,g0,g1,mu,kaplus,k0,kl,kstart,beta,eps):
with(inttrans):
with(linalg):
w:=simplify(x^2/2*g1/(l*kl)+(x^2/2-x*l)*g0/(l*k0)):
phdal:=ph-subs(t=0,w):
fdal:=simplify(f-diff(w,t)+diff(kaplus*diff(w,x),x)):
# ---------------------------------Solution of the Heat Problem------------------------------------
dp:=proc(ka)
with(inttrans):
with(linalg):
phi:=Vector(1..N):
phi[1]:=1/sqrt(l):
for i from 2 to N do
phi[i]:=evalf(sqrt(2/l)*cos((i-1)*Pi*x/l)):
od:
K:=Array(1..N,1..N):
for j from 1 to N do
for k from 1 to N do
K[j,k]:=evalf(-int(ka*diff(phi[k],x$2)*phi[j],x=0..l)):
od:
od:
F:=Vector(1..N):
for n from 1 to N do
F[n]:=evalf(int(fdal*phi[n],x=0..l)):
od:
A:=Vector(1..N):
for m from 1 to N do
A[m]:=evalf(int(phdal*phi[m],x=0..l)):
od:
KL:=Matrix(1..N,1..N):
for j1 from 1 to N do
for k1 from 1 to N do
if (j1=k1) then KL[j1,k1]:=s+K[j1,k1] else KL[j1,k1]:=K[j1,k1] fi:
od:
od:
FL:=Vector(1..N):
for i1 from 1 to N do
FL[i1]:=evalf(laplace(F[i1],t,s));
od:
S:=Vector(1..N):
for i2 from 1 to N do
S[i2]:=(A[i2]+FL[i2]);
od:
C:=Vector(1..N):
C:=evalm(inverse(KL)&*S):
c:=Vector(1..N):
for i3 from 1 to N do
c[i3]:=evalf(invlaplace(C[i3],s,t)):
od:
v:=evalf(add(c[n1]*phi[n1],n1=1..N)):
uyak:=v+w;
end:
# ---------------------------------Solution of the Adjoint Problem------------------------------------
ap:=proc(ka)
with(inttrans):
with(linalg):
utau:=evalf(subs(t=T-tau,dp(ka))):
phe:=evalf(2*(subs(tau=0,utau)-mu));
phie:=Vector(1..N):
phie[1]:=1/sqrt(l):
for i4 from 2 to N do
phie[i4]:=evalf(sqrt(2/l)*cos((i4-1)*Pi*x/l)):
od:
Kc:=Array(1..N,1..N):
for j2 from 1 to N do
for k2 from 1 to N do
Kc[j2,k2]:=evalf(-int(ka*diff(phie[k2],x$2)*phie[j2],x=0..l)):
od:
od:
Fc:=Vector(1..N):
for m1 from 1 to N do
Fc[m1]:=0:
od:
Ac:=Vector(1..N):
for cm1 from 1 to N do
Ac[cm1]:=evalf(int(phe*phie[cm1],x=0..l)):
od:
KLC:=Matrix(1..N,1..N):
for cj1 from 1 to N do
for ck1 from 1 to N do
if (cj1=ck1) then KLC[cj1,ck1]:=s+Kc[cj1,ck1] else KLC[cj1,ck1]:=Kc[cj1,ck1] fi:
od:
od:
FLC:=Vector(1..N):
for ci1 from 1 to N do
FLC[ci1]:=evalf(laplace(Fc[ci1],tau,s));
od:
Sc:=Vector(1..N):
for ci2 from 1 to N do
Sc[ci2]:=(Ac[ci2]+FLC[ci2]);
od:
CC:=Vector(1..N):
CC:=evalm(inverse(KLC)&*Sc):
cc:=Vector(1..N):
for ci3 from 1 to N do
cc[ci3]:=evalf((invlaplace(CC[ci3],s,tau))):
od:
ve:=evalf(add(cc[cn]*phie[cn],cn=1..N)):
eta:=evalf(subs(tau=T-t,ve));
end:
# ---------------------------------Calculation of the Gradient----------------------------------
T�rev:=proc(alpha,ka)
T�re:=simplify(evalf(-int(diff(dp(ka),x)*diff(ap(ka),x),t=0..T)+2*alpha*(ka-kaplus)));
end:
# ----------------------------Calculation of the Cost Functional--------------------------------
Jka:=proc(ka)
IJ1:=evalf(int((subs(t=T,dp(ka))-mu)^2,x=0..l));
end:
Sta:=proc(ka)
IJ2:=simplify(evalf((int((ka-kaplus)^2,x=0..l))));
end:
II:=proc(ka)
IJ:=simplify(evalf(Jka(ka)+alpha*Sta(ka))):
end:# 
# -----------------------------------Minimizing Process--------------------------------------------
a[0]:=kstart:
ka[0]:=kstart:
say�:=0:
for im from 0 to 60 do
a[im+1]:=simplify(evalf(ka[im-say�]-beta*T�rev(alpha,ka[im-say�]))): 
fark:=evalf(II(ka[im-say�])-II(a[im+1])): 
if(fark>0 and fark<eps) then break elif (fark>0) then 
j:=im+1: ka[j-say�]:=a[im+1]:   elif(fark<=0) then  say�:=say�+1: beta:=beta/(1.2): ka[im-say�+2]:=ka[im-say�+1]:   else fi:
od:
optcont:=a[im+1]:
end:
# -------------------------END OF THE PROCEDURE FOR CALCULATION OF THE CONTROL FUNCTION-----------
# ------PROCEDURE FOR CALCULATION OF THE DISTANCE TO THE TARGET FUNCTION-----------
ms8:=proc(N,l,alpha,T,ph,f,g0,g1,mu,kaplus,k0,kl,kstart,beta,eps):
with(inttrans):
with(linalg):
w8:=simplify(x^2/2*g1/(l*kl)+(x^2/2-x*l)*g0/(l*k0)):
phdal8:=ph-subs(t=0,w8):
fdal8:=simplify(f-diff(w8,t)+diff(kaplus*diff(w8,x),x)):
phi8:=Vector(1..N):
phi8[1]:=1/sqrt(l):
for i8 from 2 to N do
phi8[i8]:=evalf(sqrt(2/l)*cos((i8-1)*Pi*x/l)):
od:
K8:=Array(1..N,1..N):
for j8 from 1 to N do
for k8 from 1 to N do
K8[j8,k8]:=evalf(-int(ms(N,l,alpha,T,ph,f,g0,g1,mu,kaplus,k0,kl,kstart,beta,eps)*diff(phi8[k8],x$2)*phi8[j8],x=0..l)):
od:
od:
F8:=Vector(1..N):
for m28 from 1 to N do
F8[m28]:=evalf(int(fdal8*phi8[m28],x=0..l)):
od:
A8:=Vector(1..N):
for m8 from 1 to N do
A8[m8]:=evalf(int(phdal8*phi8[m8],x=0..l)):
od:
KL8:=Matrix(1..N,1..N):
for j18 from 1 to N do
for k18 from 1 to N do
if (j18=k18) then KL8[j18,k18]:=s+K8[j18,k18] else KL8[j18,k18]:=K8[j18,k18] fi:
od:
od:
FL8:=Vector(1..N):
for i148 from 1 to N do
FL8[i148]:=evalf(laplace(F8[i148],t,s));
od:
S8:=Vector(1..N):
for i48 from 1 to N do
S8[i48]:=(A8[i48]+FL8[i48]);
od:
C8:=Vector(1..N):
C8:=evalm(inverse(KL8)&*S8):
c8:=Vector(1..N):
for i58 from 1 to N do
c8[i58]:=evalf(invlaplace(C8[i58],s,t)):
od:
v8:=evalf(add(c8[n8]*phi8[n8],n8=1..N)):
uyak8:=v8+w8;
IJ18:=evalf(int((subs(t=T,uyak8)-mu)^2,x=0..l));
end:
# ------END OF THE PROCEDURE FOR CALCULATION OF THE DISTANCE TO THE TARGET FUNCTION-----------
Maplets[Display](HCC):


 

1 2 3 4 5 6 7 Last Page 1 of 2053