Register to reply 
Loop troubles in Maple 
Share this thread: 
#1
Apr1809, 11:13 PM

P: 20

I am trying to write a Gauss Seidel iteration for maple, but my troubles are because of a nested for loop.
What i want to do is like this, function := proc(....) for ....... do for ....... do (computations) end do; (if something > something, then return solution); end do; return solution; end proc; the statment if something > something is giving me troubles. Even if i don't include a return statement i get the error. It seems like I'm not allowed to put anything in between the end do's. What am i doing wrong and how can i fix this? My exact code is this: with (linalg); gauss_seidel := proc (A, B, x_0, eps, N) local i, j, k, m, n, x, sol; n := coldim(A); for i from 1 to n do x[i,1] := x_0[i] od; for m from 1 to N do for j from 1 to n do x[j,m+1] := 1/A[j,j] * ( B[j]  sum(A[j,k]*x[k,m+1] , k=1..(j1))  sum( A[j,k]*x[k,m], k=(j+1)..n)) end do; if abs( max( [seq(x[i,m+1], i=1..n)]  [seq(x[i,m], i=1..n)])) < eps then return (<seq(x[i,m+1], i=1..n)>); end do; return <seq(x[i,N+1], i=1..n)>; end proc; 


Register to reply 
Related Discussions  
Riding a Loop the Loop (velocity at the bottom of the loop)  Introductory Physics Homework  13  
Calculating normal force in a looptheloop situation  Introductory Physics Homework  2  
Matlab, for loop troubles.  Math & Science Software  10  
Loop Impedance Meaning...Data Logger Troubles  Electrical Engineering  7  
Maple Download and MapleMatlab  Math & Science Software  9 