# How to make a procedure in Maple

Let the matrix $A$ be a linear map (let us take $A$ to be square matrix), and we want to solve $Ax=y$ for any $y$ in range of the linear map $A$. Can anyone help me with the code of procedure (proc) in Maple for doing this job?? Actually, I can use LinearAlgebra package and the command LinearAlgebra(A,y) for particular $y$ in range of $A$, but I need the procedure in Maple that do this thing for any matrix $A$ and for all the range of $A$. Can anyone help me in this issue?

thanks very much.

• MaplePrimes is a better place for such questions. – user64494 Jul 9 '13 at 5:58

Here is one

[> with(LinearAlgebra):
SysSolve := proc( A::Matrix, y::Vector ) local solu, B, z;
B := A;
z := y;
solu := ( LinearSolve( B, z ) );
end:


[>A := Matrix( [[1,1],[2,2]] );
y := Vector( 2, [ 1,2] );
SysSolve(A,y);


$$\left[ \begin {array}{c} 1-{\it \_t}_{{2}}\\{\it \_t}_{{2}}\end {array} \right] .$$

• This SysSolve procedure provides no more functionality than the procedure LinearAlgebra:-LinearSolve already offers. In fact it offers less functionality since it does not pass along any additional optional arguments. And it's poorly written because its source relies on loading the LinearAlgebra package outside its definition. – acer Jul 10 '13 at 1:32
• Thanks Mhenni Benghorbal, this is good, but also can you tell how to make this in general? I mean if A is not invertable the need to know what y should be (y should be in the range of A)? so how to make this procedure effective for any matrix A and any y?? thanks. – LoveMath Jul 10 '13 at 4:04
• @acer: This is a basic procedure so the OP see how he can write a procedure. To make it more sophisticated it is up to the OP. – Mhenni Benghorbal Jul 10 '13 at 4:16
• @LoveMath: The command "LinearSolve" handles the three possible cases for a linear system. Namely, a unique solution, infinite number of solutions( the example in the answer ) and no solution. – Mhenni Benghorbal Jul 10 '13 at 4:19
• @Babak S. Thanks for the edit. I really appreciate it. – Mhenni Benghorbal Jul 12 '13 at 8:36