mehdibgh

240 Reputation

6 Badges

7 years, 332 days

MaplePrimes Activity


These are questions asked by mehdibgh

Where is the problem within this procedure which I can not get the numerical values of V[1] , V[2], ...

restart

A := Matrix([[2*t, 2, 3], [4, 5*t, 6], [7, 8*t, 9]])

A := Matrix(3, 3, {(1, 1) = 2*t, (1, 2) = 2, (1, 3) = 3, (2, 1) = 4, (2, 2) = 5*t, (2, 3) = 6, (3, 1) = 7, (3, 2) = 8*t, (3, 3) = 9})

(1)

B := LinearAlgebra:-Transpose(Matrix([t, 2*t, 3*t]))

B := Matrix(3, 1, {(1, 1) = t, (2, 1) = 2*t, (3, 1) = 3*t})

(2)

``

test:=proc(n)
  local s,t,M,V;
  s:=1:
  for t from 1 to n do
    M:=A+A^(-1);
    V[s]:=(M.B):
    s:=s+1:
  end do;
  V;
end proc:

``

test(4)

V

(3)

V[1]

V[1]

(4)

``

``

Download ProcPropl.mw

In part of my program, I have a loop that the iterative calculations are performed there. During running the program when it comes to the loop the memory usage become full in a short period of time and I face the memory shortage. Since my program is so long and huge, I only can show the loop part of it here, you may look at where is the problem of high memory usage in loop and how to deal with it. Any comment will be appreciated.

I again note that, this segment can not be run independently since it is a part of big program. I put it just to see and mmake comment if any.

M := 3; Nm := 1

w0 := Matrix(M+Nm, 1)

wd0 := Matrix(M+Nm, 1)

taim := 1

F0 := convert([seq(Quadrature(Quadrature(simplify(add(add(W[i, j, 4, r]*LegendreP(i, 1)*LegendreP(j, 0), i = 0 .. II), j = 0 .. JJ)), `ζ__1` = -1 .. 1, method = romberg[3]), `η__1` = -1 .. 1, method = romberg[3]), r = 1 .. M), seq(0, n = 1 .. Nm)], Matrix)

T := 1/(2*Pi*`ω__km`[M][2])

dt := (1/10)*T

0.1123479896110e-4

(1)

for i to M do tau[i](t) := tau[i] end do

for i to Nm do p[i](t) := p[i] end do

`α__N` := .5; `β__N` := .25; a__0 := 1/(`β__N`*dt^2); a__1 := `α__N`/(`β__N`*dt); a__2 := 1/(`β__N`*dt); a__3 := 1/(2*`β__N`)-1; a__4 := `α__N`/`β__N`-1; a__5 := dt*(`α__N`/(2*`β__N`)-1); a__6 := dt*(1-`α__N`); a__7 := `α__N`*dt

q := Matrix(1 .. M+Nm, 1 .. floor(taim/dt)+1)

dq := Matrix(1 .. M+Nm, 1 .. floor(taim/dt)+1)

ddq := Matrix(1 .. M+Nm, 1 .. floor(taim/dt)+1)

q(1 .. M+Nm, 1) := w0

dq(1 .. M+Nm, 1) := wd0

for i to M do tau[i] := q(i, 1) end do

for i to Nm do p[i] := q(M+i, 1) end do

ddq(1 .. M+Nm, 1) := 1/ML.(diff((diff(sin(`ω__b`*t__0), t__0))*LinearAlgebra:-Transpose(F0), t__0)-CL.dq(1 .. M+Nm, 1 .. 1)-KL.q(1 .. M+Nm, 1 .. 1)-eqMNL)

t__0 := dt

V := LinearAlgebra:-Transpose(convert([seq(Tau[i], i = 1 .. M), seq(P[i], i = 1 .. Nm)], Matrix))

Qn__2 := LinearAlgebra:-Transpose(Matrix(1, M+Nm))

Qn__3 := LinearAlgebra:-Transpose(Matrix(1, M+Nm))

External force

 

`ω__b` := 25

``

F := diff((diff(sin(`ω__b`*t), t))*LinearAlgebra:-Transpose(convert(F0, Matrix)), t)

``

s := 1

k__d := 100000

with(Student[NumericalAnalysis]); dt

``

Loop

 

for t from t__0 by dt to taim do EQ := KL.V+a__0*ML.V+a__1*CL.V-ML.(a__0*q(1 .. M+Nm, s .. s)+a__2*dq(1 .. M+Nm, s .. s)+a__3*ddq(1 .. M+Nm, s .. s))-CL.(a__1*q(1 .. M+Nm, s .. s)+a__4*dq(1 .. M+Nm, s .. s)+a__5*ddq(1 .. M+Nm, s .. s))-F-Qn__2-Qn__3; G := Matrix(M+Nm, proc (i, j) options operator, arrow; (diff(EQ[i], V[j, 1]))[1] end proc); G1 := 1/G; if t = t__0 then X[1] := 1/(CL*a__1+ML*a__0+KL).(F+ML.(a__0*q(1 .. M+Nm, s .. s)+a__2*dq(1 .. M+Nm, s .. s)+a__3*ddq(1 .. M+Nm, s .. s))+CL.(a__1*q(1 .. M+Nm, s .. s)+a__4*dq(1 .. M+Nm, s .. s)+a__5*ddq(1 .. M+Nm, s .. s))) else X[1] := q(1 .. M+Nm, s .. s) end if; for k to 11 do X[k+1] := eval(V-G1.EQ, Equate(V, X[k])) end do; q(1 .. M+Nm, s+1 .. s+1) := X[k]; ddq(1 .. M+Nm, s+1 .. s+1) := a__0*(q(1 .. M+Nm, s+1 .. s+1)-q(1 .. M+Nm, s .. s))-a__2*dq(1 .. M+Nm, s .. s)-a__3*ddq(1 .. M+Nm, s .. s); dq(1 .. M+Nm, s+1 .. s+1) := dq(1 .. M+Nm, s .. s)+a__6*ddq(1 .. M+Nm, s .. s)+a__7*ddq(1 .. M+Nm, s+1 .. s+1); Wxy2 := add(add(add(h*W[i, j, 2, o]*LegendreP(i, `&zeta;__2`)*LegendreP(j, `&eta;__2`)*q[o, s+1], i = 0 .. II), j = 0 .. JJ), o = 1 .. M); Wxy3 := add(add(add(h*W[i, j, 3, o]*LegendreP(i, `&zeta;__2`)*LegendreP(j, `&eta;__2`)*q[o, s+1], i = 0 .. II), j = 0 .. JJ), o = 1 .. M); Plt := plots:-implicitplot(Wxy2-Wxy3, `&zeta;__2` = -1 .. 1, `&eta;__2` = -1 .. 1, color = red, thickness = 2, gridrefine = 3); j := 111111; Hvs2 := 1; for i while i <= j do Pnt[i] := op([1, i], Plt); if Wxy2-Wxy3 = 0 then j := 0 elif convert(Pnt[i], string)[1] = "C" then j := 0 else a__e[i] := (1/2)*abs(max(Column(Pnt[i], 1))-min(Column(Pnt[i], 1))); if a__e[i] = 0 then a__e[i] = 0.1e-5 end if; b__e[i] := (1/2)*abs(max(Column(Pnt[i], 2))-min(Column(Pnt[i], 2))); if b__e[i] = 0 then b__e[i] = 0.1e-5 end if; xc[i] := (max(Column(Pnt[i], 1))+min(Column(Pnt[i], 1)))*(1/2); yc[i] := (max(Column(Pnt[i], 2))+min(Column(Pnt[i], 2)))*(1/2); Hv2[i] := ((`&zeta;__2`-xc[i])/a__e[i])^2+((`&eta;__2`-yc[i])/b__e[i])^2-1; Hvs2 := Hv2[i]*Hvs2 end if end do; Qn__2 := LinearAlgebra:-Transpose(convert([(1/2)*k__d*Grid:-Seq(Quadrature(Quadrature(Heaviside(-Hvs2)*abs(Wxy2-Wxy3)*add(add(W[i, j, 2, r]*LegendreP(i, `&zeta;__2`)*LegendreP(j, `&eta;__2`), i = 0 .. II), j = 0 .. JJ), `&zeta;__2` = -1 .. 1, method = romberg[5]), `&eta;__2` = -1 .. 1, method = romberg[5]), r = 1 .. M), seq(0, n = 1 .. Nm)], Matrix)); Qn__3 := -Qn__2; s := s+1 end do

``

Download HighMemUseProb.mw

I am trying to do the following computation. I  extracted n*1 matrix from n*n matrix which unbelievably gives vector?

How I can do the following multiplication without using convert command? Or how to extract n*1 matrix (not vector) from n*n matrix without using convert?

``

restart

``

``

A := Matrix(4, 4, {(1, 1) = m[1, 1], (1, 2) = m[1, 2], (1, 3) = m[1, 3], (1, 4) = m[1, 4], (2, 1) = m[2, 1], (2, 2) = m[2, 2], (2, 3) = m[2, 3], (2, 4) = m[2, 4], (3, 1) = m[3, 1], (3, 2) = m[3, 2], (3, 3) = m[3, 3], (3, 4) = m[3, 4], (4, 1) = m[4, 1], (4, 2) = m[4, 2], (4, 3) = m[4, 3], (4, 4) = m[4, 4]})

A := Matrix(4, 4, {(1, 1) = 0, (1, 2) = m[1, 2], (1, 3) = m[1, 3], (1, 4) = m[1, 4], (2, 1) = 0, (2, 2) = m[2, 2], (2, 3) = m[2, 3], (2, 4) = m[2, 4], (3, 1) = 0, (3, 2) = m[3, 2], (3, 3) = m[3, 3], (3, 4) = m[3, 4], (4, 1) = 0, (4, 2) = m[4, 2], (4, 3) = m[4, 3], (4, 4) = m[4, 4]})

(1)

A(1 .. 4, 1) := Matrix(4, 1):

A

Matrix([[0, m[1, 2], m[1, 3], m[1, 4]], [0, m[2, 2], m[2, 3], m[2, 4]], [0, m[3, 2], m[3, 3], m[3, 4]], [0, m[4, 2], m[4, 3], m[4, 4]]])

(2)

B := A(1 .. 4, 2)

B := Vector(4, {(1) = m[1, 2], (2) = m[2, 2], (3) = m[3, 2], (4) = m[4, 2]})

(3)

A.B

4

(4)

F := Matrix(4, 1, {(1, 1) = 0.4279668887e-7, (2, 1) = -0.3901148183e-7, (3, 1) = 0.3900685346e-7, (4, 1) = 0.})

Typesetting:-delayDotProduct(A, B)-F

Error, (in rtable/Sum) invalid input: dimensions do not match: Vector[column](1 .. 4) cannot be added to Matrix(1 .. 4, 1 .. 1)

 

A.convert(B, Matrix)-F

Matrix(4, 1, {(1, 1) = m[1, 2]*m[2, 2]+m[1, 3]*m[3, 2]+m[1, 4]*m[4, 2]-0.4279668887e-7, (2, 1) = m[2, 2]^2+m[2, 3]*m[3, 2]+m[2, 4]*m[4, 2]+0.3901148183e-7, (3, 1) = m[3, 2]*m[2, 2]+m[3, 3]*m[3, 2]+m[3, 4]*m[4, 2]-0.3900685346e-7, (4, 1) = m[2, 2]*m[4, 2]+m[3, 2]*m[4, 3]+m[4, 2]*m[4, 4]})

(5)

``

Download soalzarb.mw

I want to plot a number created in a loop to monitor how it varies while keeping all previous ones on the figure. This is simply done in Matlab by hold on command, but I dont know how it is possible in Maple?

for i to 22 do
plot([i], [i^.5], style = point) :
end do

Note I want to monitor points during the loop running not after it finishes.

I am trying to find a fast method for integration of a function composed of several Heavisides. I used Quadrature-Romberg, but no success. What is the problem with it and what method do you recommend instead?

``

restart

``

A := Heaviside(zeta__2-.6429162216568)*Heaviside(eta__2+.5050000000000-10.98537767108*sqrt(492.5151416233-zeta__2^2))+Heaviside(zeta__2-.9999999999936)*Heaviside(eta__2+.9875792458758+3.881485663812*10^9*sqrt(9.765625000000*10^22-zeta__2^2))+Heaviside(zeta__2+1.000000000000)*Heaviside(eta__2-.4637698986762+2.327456686822*10^11*sqrt(2.777777777778*10^24-zeta__2^2))-Heaviside(zeta__2+1.000000000000)*Heaviside(eta__2-.4637698986762-2.327456686822*10^11*sqrt(2.777777777778*10^24-zeta__2^2))+Heaviside(zeta__2+1.000000000000)*Heaviside(eta__2+.1619291800251+3.018371923484*10^11*sqrt(4.000000000000*10^24-zeta__2^2))-Heaviside(zeta__2+1.000000000000)*Heaviside(eta__2+.1619291800251-3.018371923484*10^11*sqrt(4.000000000000*10^24-zeta__2^2))+Heaviside(zeta__2+1.000000000000)*Heaviside(eta__2+.7243706106403+1.382194833711*10^11*sqrt(1.562500000000*10^24-zeta__2^2))-Heaviside(zeta__2+1.000000000000)*Heaviside(eta__2+.7243706106403-1.382194833711*10^11*sqrt(1.562500000000*10^24-zeta__2^2))+Heaviside(zeta__2-1.000000000000)*Heaviside(eta__2+.9875792458758-3.881485663812*10^9*sqrt(9.765625000000*10^22-zeta__2^2))-Heaviside(zeta__2-1.000000000000)*Heaviside(eta__2+.9875792458758+3.881485663812*10^9*sqrt(9.765625000000*10^22-zeta__2^2))+Heaviside(zeta__2-1.000000000000)*Heaviside(eta__2-.8341191288491-1.298592148442*10^10*sqrt(9.706617486471*10^21-zeta__2^2))-Heaviside(zeta__2-1.000000000000)*Heaviside(eta__2-.8341191288491+1.298592148442*10^10*sqrt(9.706617486471*10^21-zeta__2^2))-Heaviside(zeta__2-.9999999999796)*Heaviside(eta__2-.8341191288491-1.298592148442*10^10*sqrt(9.706617486471*10^21-zeta__2^2))-Heaviside(zeta__2-.5527964251744)*Heaviside(eta__2+.5050000000000-10.98537767108*sqrt(492.5151416233-zeta__2^2))+Heaviside(zeta__2-.5527964251744)*Heaviside(eta__2+.5050000000000+10.98537767108*sqrt(492.5151416233-zeta__2^2))+Heaviside(zeta__2-.7684252323012)*Heaviside(eta__2-.5050000000000-8.127372424924*sqrt(269.5813999936-zeta__2^2))-Heaviside(zeta__2-.6466146460206)*Heaviside(eta__2-.5050000000000-8.127372424924*sqrt(269.5813999936-zeta__2^2))-Heaviside(zeta__2-.7684252323012)*Heaviside(eta__2-.5050000000000+8.127372424924*sqrt(269.5813999936-zeta__2^2))+Heaviside(zeta__2-.6466146460206)*Heaviside(eta__2-.5050000000000+8.127372424924*sqrt(269.5813999936-zeta__2^2))-Heaviside(zeta__2-.9999999999936)*Heaviside(eta__2+.9875792458758-3.881485663812*10^9*sqrt(9.765625000000*10^22-zeta__2^2))+Heaviside(zeta__2-.9999999999796)*Heaviside(eta__2-.8341191288491+1.298592148442*10^10*sqrt(9.706617486471*10^21-zeta__2^2))+Heaviside(zeta__2+.9999999999972)*Heaviside(eta__2+.9842650870048-1.085166413462*10^10*sqrt(4.756242568371*10^23-zeta__2^2))-Heaviside(zeta__2+.9999999999972)*Heaviside(eta__2+.9842650870048+1.085166413462*10^10*sqrt(4.756242568371*10^23-zeta__2^2))+Heaviside(zeta__2+.9999999999990)*Heaviside(eta__2+.1619291800251-3.018371923484*10^11*sqrt(4.000000000000*10^24-zeta__2^2))-Heaviside(zeta__2+.9999999999990)*Heaviside(eta__2+.1619291800251+3.018371923484*10^11*sqrt(4.000000000000*10^24-zeta__2^2))+Heaviside(zeta__2+.9999999999988)*Heaviside(eta__2-.4637698986762-2.327456686822*10^11*sqrt(2.777777777778*10^24-zeta__2^2))-Heaviside(zeta__2+.9999999999988)*Heaviside(eta__2-.4637698986762+2.327456686822*10^11*sqrt(2.777777777778*10^24-zeta__2^2))+Heaviside(zeta__2+.9999999999984)*Heaviside(eta__2+.7243706106403-1.382194833711*10^11*sqrt(1.562500000000*10^24-zeta__2^2))-Heaviside(zeta__2+.9999999999984)*Heaviside(eta__2+.7243706106403+1.382194833711*10^11*sqrt(1.562500000000*10^24-zeta__2^2))+Heaviside(zeta__2+.9999999999984)*Heaviside(eta__2-.9031048925918-8.123652892875*10^10*sqrt(1.562500000000*10^24-zeta__2^2))-Heaviside(zeta__2+.9999999999984)*Heaviside(eta__2-.9031048925918+8.123652892875*10^10*sqrt(1.562500000000*10^24-zeta__2^2))-Heaviside(zeta__2+1.000000000000)*Heaviside(eta__2+.9842650870048-1.085166413462*10^10*sqrt(4.756242568371*10^23-zeta__2^2))+Heaviside(zeta__2+1.000000000000)*Heaviside(eta__2+.9842650870048+1.085166413462*10^10*sqrt(4.756242568371*10^23-zeta__2^2))-Heaviside(zeta__2-.6429162216568)*Heaviside(eta__2+.5050000000000+10.98537767108*sqrt(492.5151416233-zeta__2^2))-Heaviside(zeta__2+1.000000000000)*Heaviside(eta__2-.9031048925918-8.123652892875*10^10*sqrt(1.562500000000*10^24-zeta__2^2))+Heaviside(zeta__2+1.000000000000)*Heaviside(eta__2-.9031048925918+8.123652892875*10^10*sqrt(1.562500000000*10^24-zeta__2^2)):

plot3d(A, zeta__2 = -1 .. 1, eta__2 = -1 .. 1, color = green)

 

Digits := 22:

with(Student[NumericalAnalysis]):

Quadrature(Quadrature(A, zeta__2 = -1 .. 1, method = romberg[8]), eta__4 = -1 .. 1, method = romberg[8])

Float(undefined)*Heaviside(eta__2+1212964270000000000001.)+Float(undefined)*Heaviside(eta__2-1279401131003415700657.)-0.1513022270849353690226e-1*Heaviside(eta__2-133.8411610374164929382)+Float(undefined)*Heaviside(eta__2-7483906296259851792359.)+Float(undefined)*Heaviside(eta__2+7483906296259851792361.)+Float(undefined)*Heaviside(eta__2-0.1015456611625000000000e24)+Float(undefined)*Heaviside(eta__2+0.1015456611625000000000e24)+Float(undefined)*Heaviside(eta__2+0.3879094478488497112464e24)+Float(undefined)*Heaviside(eta__2+1279401131003415700655.)-0.4538512794872905686682e-1*Heaviside(eta__2-133.8360207224718595497)+0.4538512794872905686682e-1*Heaviside(eta__2+132.8260207224718595497)+0.4538512794872905686682e-1*Heaviside(eta__2+132.8042477794001150390)-0.4538512794872905686682e-1*Heaviside(eta__2-133.8253766167816064928)-0.4538512794872905686682e-1*Heaviside(eta__2-243.1883998382669648802)+0.1513022270849353690226e-1*Heaviside(eta__2+132.8311610374164929382)+Float(undefined)*Heaviside(eta__2-0.1727743542500000000000e24)-0.1513022270849353690226e-1*Heaviside(eta__2-243.2027260661341424950)+0.1513022270849353690226e-1*Heaviside(eta__2+244.2127260661341424950)+0.4538512794872905686682e-1*Heaviside(eta__2+244.1983998382669648802)-0.4538512794872905686682e-1*Heaviside(eta__2-243.1980716456433769010)+0.4538512794872905686682e-1*Heaviside(eta__2+244.2080716456433769010)+0.4538512794872905686682e-1*Heaviside(eta__2+132.8153766167816064928)+0.1513022270849353690226e-1*Heaviside(eta__2+132.8098727970154075001)+Float(undefined)*Heaviside(eta__2-0.3879094478488497112464e24)-0.4538512794872905686682e-1*Heaviside(eta__2-243.2072595071292620415)+Float(undefined)*Heaviside(eta__2+0.6036743846000000000000e24)+Float(undefined)*Heaviside(eta__2-0.6036743846000000000000e24)+Float(undefined)*Heaviside(eta__2+0.1727743542500000000000e24)-0.1916322521366165064753e-1*Heaviside(eta__2-133.8307592537082147847)+0.1916322521366165064753e-1*Heaviside(eta__2+132.8207592537082147847)-0.1916322521366165064753e-1*Heaviside(eta__2-243.2116719753798543789)+0.1916322521366165064753e-1*Heaviside(eta__2+244.2216719753798543789)-0.4538512794872905686682e-1*Heaviside(eta__2-133.8026340889186250133)+0.4538512794872905686682e-1*Heaviside(eta__2+132.7926340889186250133)-0.4538512794872905686682e-1*Heaviside(eta__2-133.8142477794001150390)-0.1513022270849353690226e-1*Heaviside(eta__2-133.8198727970154075001)+0.4538512794872905686682e-1*Heaviside(eta__2+244.2172595071292620415)-0.1903631769101229216919e-1*Heaviside(eta__2-133.8085015485931455736)+0.1903631769101229216919e-1*Heaviside(eta__2+132.7985015485931455736)+0.1903531841918040745676e-1*Heaviside(eta__2+244.2032962387251632874)-0.1903531841918040745676e-1*Heaviside(eta__2-243.1932962387251632874)+Float(undefined)*Heaviside(eta__2-1212964269999999999999.)

(1)

int(int(A, zeta__2 = -1 .. 1), eta__2 = -1 .. 1)

.4238607655960000000000

(2)

``

Download romberg.mw

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