I'M TRYIN TO CREATE A PROGRAM USING MAPLE FOR GAUSSING ELIMINATION BUT I KEEP GETTING THIS ERROR
Gauss := proc (n::posint, A::matrix, c::Vector)
local a, i, k, j, p;
with(MTM):
n := linalg[rowdim](A);
if det(A) = 0 then print('matrice*doit*etre*caree')
else if det(A) <> 0
then a := `<|>`(A, c);
for k to n-1 do
for i from k+1 to n do
if a[i, i] = 0 then swaprow(a, k, i)
else p = a[i, k]/a[k, k];
for j from k+1 to n+1 do a[i, j] = a[i, j]-p*a[k, j]
end do;
end if;
end do;
end do;
else print('rien')
end if; end if; end proc;
Error, (in Gauss) illegal use of a formal parameter
There were quite a few mistakes, so let's hope I get most of them.
I didn't bother doing 7. You should do it.
with
inside a procedure.linalg
package, not theMTM
package.n
as one of its parameters, but inside it you also try to assign a value ton
, the argument for which you passed in as the number 3. That's where your error message is coming from. You can't do that.=
instead of:=
for assignments. The=
does nothing.det(A)=0
is wrong is wrong in several ways. I'll just say that it doesn't actually test whether theA
is square. Compare the row & column dimensions if you want to test thatA
is square.LinearAlgebra
equivalents instead of thelinalg
commands commandsswaprow
,coldim
.a
.swaprow
is was not actually updatinga
. It was just throwing way the result.