Question: how to break a loop and set anew iteration

here my problem i work on ;

i want maple to end the enternal loop if it can't solve the equation after  some iteration maple couldnt solve the equation and get stuck

 

with(LinearAlgebra); with(VectorCalculus); with(Student[LinearAlgebra]); with(SignalProcessing); with(Statistics); with(stats)

f[1] := n/R+sum(x[i], i = 1 .. n)-(sum((2+a[i])*x[i]*exp(R*x[i])/(exp(R*x[i])-1+Q), i = 1 .. n))

f[2] := m/S+sum(y[j], j = 1 .. m)-(sum((2+b[j])*y[j]*exp(y[j]*S)/(exp(y[j]*S)-1+Q), j = 1 .. m))

f[3] := (n+m+sum(a[i], i = 1 .. n)+sum(b[j], j = 1 .. m))/Q-(sum((2+a[i])/(exp(R*x[i])-1+Q), i = 1 .. n))-(sum((2+b[j])/(exp(y[j]*S)-1+Q), j = 1 .. m))

NULL

E1[1] := 0.5e-1

E2[1] := 0.5e-1

E3[1] := 0.5e-1

n := 45; m := 45

n := 45; m := 45

a := [seq(0, i = 1 .. 21), 2, 2, 1, seq(0, i = 1 .. 21)]; b := [seq(0, i = 1 .. 21), 2, 2, 1, seq(0, i = 1 .. 21)]

lambda1 := .9; lambda2 := .1; `α_α` := 5

K := 1000

so := 1; while so < K+1 do W := GenerateUniform(n, 0, 1); for iii to n do vv[iii] := W[iii]^(1/(iii+sum(a[jjj], jjj = n-iii+1 .. n))) end do; for sss to n do uu[sss] := 1-product(vv[n-jjj+1], jjj = 1 .. sss); x[sss] := fsolve(1-`&alpha;_&alpha;`/(exp(lambda1*t)-1+`&alpha;_&alpha;`) = uu[sss], t = 0 .. infinity) end do; U := GenerateUniform(m, 0, 1); for ii to m do v[ii] := U[ii]^(1/(ii+sum(b[jj], jj = m-ii+1 .. m))) end do; for ss to m do u[ss] := 1-product(v[m-jj+1], jj = 1 .. ss); y[ss] := fsolve(1-`&alpha;_&alpha;`/(exp(lambda2*t)-1+`&alpha;_&alpha;`) = u[ss], t = 0 .. infinity) end do; c := describe[quartile[1]]([seq(x[i], i = 1 .. n)]); cc := describe[quartile[3]]([seq(x[i], i = 1 .. n)]); L := describe[quartile[1]]([seq(y[i], i = 1 .. m)]); LL := describe[quartile[3]]([seq(y[i], i = 1 .. m)]); R[1] := fsolve(9*exp(R*c)-exp(R*cc) = 8, R = 0 .. infinity); S[1] := fsolve(9*exp(S*L)-exp(S*LL) = 8, S = 0 .. infinity); Q[1] := 3*(exp(R[1]*c)-1+(exp(S[1]*L)-1))*(1/2); for h to 40 while `and`(`and`(`and`(`and`(`and`(abs(E1[h]) > 0.5e-3, abs(E2[h]) > 0.5e-3), abs(E3[h]) > 0.5e-3), Q[h] > 2), S[h] > 0), R[h] > 0) do printlevel := 2; Q[h+1] := fsolve(eval(f[3], {R = R[h], S = S[h]}) = 0, Q = 0 .. infinity); S[h+1] := fsolve(eval(f[2], Q = Q[h+1]) = 0, S = 0 .. infinity); R[h+1] := fsolve(eval(f[1], Q = Q[h+1]) = 0, R = 0 .. infinity); if fsolve(eval(f[3], {R = R[h], S = S[h]}) = 0, Q = 0 .. infinity) = NULL then break end if; if fsolve(eval(f[2], Q = Q[h+1]) = 0, S = 0 .. infinity) = NULL then break end if; if fsolve(eval(f[1], Q = Q[h+1]) = 0, R = 0 .. infinity) = NULL then break end if; E1[h+1] := abs(R[h+1]-R[h]); E2[h+1] := abs(S[h+1]-S[h]); E3[h+1] := abs(Q[h+1]-Q[h]); KK := Matrix([[R[h]], [S[h]], [Q[h]]]) end do; A[so] := Determinant(KK[1]); B[so] := Determinant(KK[2]); C[so] := Determinant(KK[3]); so := so+1 end do

Error, cannot determine if this expression is true or false: 0 < K

 

NULL

NULL


 

Download Q3.mw

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Please Wait...