<Text-field style="Heading 1" layout="Heading 1">Matrix Vector Product </Text-field> This algorithm will return the product of a matrix and a vector MVProduct:=proc(n,A,x) #This algorithm will return the product of a matrix and a vector local i,j,p; p:=Array(1..n); for i from 1 to n do for j from 1 to n do p(i):=p(i)+A(i,j)*x(j): end do: end do: p: end proc:
<Text-field style="Heading 1" layout="Heading 1">SqrMatrixProduct </Text-field> This algorithm will mutiply two square matrices with simple for loops. SqrMatrixProduct:=proc(n,A,B) #multiplies two square nxn matrices A and B local i,j,k,C: C:=Array(1..n,1..n): for i from 1 to n do for j from 1 to n do for k from 1 to n do C[i,k]:=C[i,k]+A[i,j]*B[j,k]; end do: end do: end do: return(C); end proc: A:=Array([[1,2,3],[3,4,5],[3,4,-1]]); B:=Array([[5,6,2],[7,8,6],[2,5,-2]]); LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYoLUkjbWlHRiQ2JVEiQUYnLyUnaXRhbGljR1EldHJ1ZUYnLyUsbWF0aHZhcmlhbnRHUSdpdGFsaWNGJy1JI21vR0YkNi1RIzo9RicvRjNRJ25vcm1hbEYnLyUmZmVuY2VHUSZmYWxzZUYnLyUqc2VwYXJhdG9yR0Y9LyUpc3RyZXRjaHlHRj0vJSpzeW1tZXRyaWNHRj0vJShsYXJnZW9wR0Y9LyUubW92YWJsZWxpbWl0c0dGPS8lJ2FjY2VudEdGPS8lJ2xzcGFjZUdRLDAuMjc3Nzc3OGVtRicvJSdyc3BhY2VHRkwtSShtYWN0aW9uR0YkNiUtSShtZmVuY2VkR0YkNigtRiM2Ji1JJ210YWJsZUdGJDY3LUkkbXRyR0YkNigtSSRtdGRHRiQ2KC1JI21uR0YkNiRRIjFGJ0Y5LyUpcm93YWxpZ25HUSFGJy8lLGNvbHVtbmFsaWduR0Zgby8lK2dyb3VwYWxpZ25HRmBvLyUocm93c3BhbkdRIjFGJy8lK2NvbHVtbnNwYW5HRmdvLUZobjYoLUZbbz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W5nR1EsMC40ZW1+MC41ZXhGJy8lKmVxdWFscm93c0dGPS8lLWVxdWFsY29sdW1uc0dGPS8lLWRpc3BsYXlzdHlsZUdGPS8lJXNpZGVHRmJyLyUwbWlubGFiZWxzcGFjaW5nR0Zhcy8lK2ZvcmVncm91bmRHUShbMCwwLDBdRicvJSlyZWFkb25seUdGPUY5RjkvSSttc2VtYW50aWNzR0YkUSdNYXRyaXhGJy8lJW9wZW5HUSJbRicvJSZjbG9zZUdRIl1GJ0ZbdS8lK2FjdGlvbnR5cGVHUS5ydGFibGVhZGRyZXNzRicvJSlydGFibGVpZEdRKjI0OTU5NzQ2MEYnRmZ0Rml0Rjk= LUknTWF0cml4RzYkJSpwcm90ZWN0ZWRHSShfc3lzbGliRzYiNiMvSSQlaWRHRiciKic0LidcIw==
<Text-field style="Heading 1" layout="Heading 1">IdentityMatrix</Text-field> IdentityMatrix:=proc(n) local i,j,M; M:=Array(1..n,1..n): for i from 1 to n do M(i,i):=1: end do: M; end proc: A:=IdentityMatrix(10); LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYoLUkjbWlHRiQ2JVEiQUYnLyUnaXRhbGljR1EldHJ1ZUYnLyUsbWF0aHZhcmlhbnRHUSdpdGFsaWNGJy1JI21vR0YkNi1RIzo9RicvRjNRJ25vcm1hbEYnLyUmZmVuY2VHUSZmYWxzZUYnLyUqc2VwYXJhdG9yR0Y9LyUpc3RyZXRjaHlHRj0vJSpzeW1tZXRyaWNHRj0vJShsYXJnZW9wR0Y9LyUubW92YWJsZWxpbWl0c0dGPS8lJ2FjY2VudEdGPS8lJ2xzcGFjZUdRLDAuMjc3Nzc3OGVtRicvJSdyc3BhY2VHRkwtSShtYWN0aW9uR0YkNiUtSShtZmVuY2VkR0YkNigtRiM2Ji1JJ210YWJsZUdGJDY+LUkkbXRyR0YkNi8tSSRtdGRHRiQ2KC1JI21uR0YkNiRRIjFGJ0Y5LyUp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5jb2x1bW5zcGFjaW5nR1EmMC44ZW1GJy8lKXJvd2xpbmVzR1Elbm9uZUYnLyUsY29sdW1ubGluZXNHRmlyLyUmZnJhbWVHRmlyLyUtZnJhbWVzcGFjaW5nR1EsMC40ZW1+MC41ZXhGJy8lKmVxdWFscm93c0dGPS8lLWVxdWFsY29sdW1uc0dGPS8lLWRpc3BsYXlzdHlsZUdGPS8lJXNpZGVHRmdxLyUwbWlubGFiZWxzcGFjaW5nR0Zmci8lK2ZvcmVncm91bmRHUShbMCwwLDBdRicvJSlyZWFkb25seUdGPUY5RjkvSSttc2VtYW50aWNzR0YkUSdNYXRyaXhGJy8lJW9wZW5HUSJbRicvJSZjbG9zZUdRIl1GJ0ZgdC8lK2FjdGlvbnR5cGVHUS5ydGFibGVhZGRyZXNzRicvJSlydGFibGVpZEdRKjI0OTYwNjYwOEYnRlt0Rl50Rjk=
<Text-field style="Heading 1" layout="Heading 1">InfNorm(x)</Text-field> InfNorm:=proc(n,x) local inf_norm,j,p: inf_norm:=x[1]: for j from 2 to n do if abs(x[j])>inf_norm then inf_norm:=abs(x[j]): p:=j: end if: end do: return(inf_norm,p); end proc: x:=array([3,2,4,1,6]); LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYoLUkjbWlHRiQ2JVEieEYnLyUnaXRhbGljR1EldHJ1ZUYnLyUsbWF0aHZhcmlhbnRHUSdpdGFsaWNGJy1JI21vR0YkNi1RIzo9RicvRjNRJ25vcm1hbEYnLyUmZmVuY2VHUSZmYWxzZUYnLyUqc2VwYXJhdG9yR0Y9LyUpc3RyZXRjaHlHRj0vJSpzeW1tZXRyaWNHRj0vJShsYXJnZW9wR0Y9LyUubW92YWJsZWxpbWl0c0dGPS8lJ2FjY2VudEdGPS8lJ2xzcGFjZUdRLDAuMjc3Nzc3OGVtRicvJSdyc3BhY2VHRkwtSShtZmVuY2VkR0YkNiYtSSdtdGFibGVHRiQ2NS1JJG10ckdGJDYqLUkkbXRkR0YkNigtSSNtbkdGJDYkUSIzRidGOS8lKXJvd2FsaWduR1EhRicvJSxjb2x1bW5hbGlnbkdGW28vJStncm91cGFsaWduR0Zbby8lKHJvd3NwYW5HUSIxRicvJStjb2x1bW5zcGFuR0Ziby1GWTYoLUZmbjYkUSIyRidGOUZpbkZcb0Zeb0Zgb0Zjby1GWTYoLUZmbjYkUSI0RidGOUZpbkZcb0Zeb0Zgb0Zjby1GWTYoLUZmbjYkUSIxRidGOUZpbkZcb0Zeb0Zgb0Zjby1GWTYoLUZmbjYkUSI2RidGOUZpbkZcb0Zeb0Zgb0Zjb0ZpbkZcb0Zeby8lJmFsaWduR1ElYXhpc0YnL0ZqblEpYmFzZWxpbmVGJy9GXW9RJ2NlbnRlckYnL0Zfb1EnfGZybGVmdHxockYnLyUvYWxpZ25tZW50c2NvcGVHRjEvJSxjb2x1bW53aWR0aEdRJWF1dG9GJy8lJndpZHRoR0ZmcS8lK3Jvd3NwYWNpbmdHUSYxLjBleEYnLyUuY29sdW1uc3BhY2luZ0dRJjAuOGVtRicvJSlyb3dsaW5lc0dRJW5vbmVGJy8lLGNvbHVtbmxpbmVzR0Zhci8lJmZyYW1lR0Zhci8lLWZyYW1lc3BhY2luZ0dRLDAuNGVtfjAuNWV4RicvJSplcXVhbHJvd3NHRj0vJS1lcXVhbGNvbHVtbnNHRj0vJS1kaXNwbGF5c3R5bGVHRj0vJSVzaWRlR1EmcmlnaHRGJy8lMG1pbmxhYmVsc3BhY2luZ0dGXnJGOS8lJW9wZW5HUSJbRicvJSZjbG9zZUdRIl1GJy8lK2ZvcmVncm91bmRHUShbMCwwLDBdRicvJSlyZWFkb25seUdGPUY5 yp,p:=InfNorm(5,x); NiQiIiciIiY= yp; IiIn p; IiIm
<Text-field style="Heading 1" layout="Heading 1">fixedpt(n,G,x0,TOL,M)</Text-field> fixedpt:=proc(n,G,x0,TOL,M) #iterates multiple functions to find the location of a fixed point. #n=number of vars, G=array of functions for G={x1,x2,...,xn}, #x0= 1xn array for initial values, TOL=tolerance, M=max iterations local i,x; ###Subprocess section InfNorm:=proc(n,x) local inf_norm,j,p: inf_norm:=x[1]: for j from 2 to n do if abs(x[j])>inf_norm then inf_norm:=abs(x[j]): p:=j: end if: end do: return(inf_norm,p); end proc: x:=x0: x1:=Array(1..n): k:=1: while k<=M do if InfNorm(n,(x-x1))<TOL then return(x); print("Iterations=",k): break: end if: break Warning, premature end of input, use <Shift> + <Enter> to avoid this message.
<Text-field style="Heading 1" layout="Heading 1">MatrixTranspose(n,A)</Text-field> MatrixTranspose:=proc(m,n,A) local i,j,trans: trans:=Array(1..n,1..m); for i from 1 to m do for j from 1 to n do trans(j,i):=A(i,j): end do: end do: return(trans): end proc:
<Text-field style="Heading 1" layout="Heading 1">gauss(a,b,n)</Text-field> Solve the linear system ax = b where a is an array(1..n,1..n) b is an array(1..n) x is an array(1..n) nrow is the pivoting array(1..n) n = number of variables gauss:=proc(a, b, n) local i, j, k, p, m, tmp, maxval, tmpval, s, x, nrow; x:=array(1..n); nrow:=array(1..n); for i from 1 to n do nrow[i]:= i; end do; s:=array(1..n); for i from 1 to n do maxval:=abs(a[i,1]); for j from 2 to n do tmpval:=abs(a[i,j]); if ( tmpval > maxval ) then maxval:=tmpval; end if; end do; s[i]:=maxval; end do; for i from 1 to n-1 do # find pivot row maxval:= abs(a[nrow[i],i])/s[nrow[i]]; p:=i; for j from i+1 to n do tmpval:= abs(a[nrow[j],i])/s[nrow[j]]; if (tmpval > maxval) then p:=j; maxval:=tmpval; end if; end do; if ( maxval = 0 ) then return(0); end if; # switch rows if ( p <> i ) then tmp:=nrow[p]; nrow[p]:=nrow[i]; nrow[i]:=tmp; end if; # zero out column i for k from i+1 to n do m:=a[nrow[k],i]/a[nrow[i],i]; a[nrow[k],i]:=0; for j from i+1 to n do a[nrow[k],j]:=a[nrow[k],j]-m*a[nrow[i],j]; end do; b[nrow[k]]:=b[nrow[k]]-m*b[nrow[i]]; end do; if ( a[nrow[n],n] = 0 ) then return(0); end if; end do; # backward substitution x[n]:= b[nrow[n]]/a[nrow[n],n]; for j from n-1 to 1 by -1 do x[j]:=b[nrow[j]]; for k from n to j+1 by -1 do x[j]:=x[j]- a[nrow[j],k]*x[k]; end do; x[j]:=x[j]/a[nrow[j],j]; end do; x; end:
<Text-field style="Heading 1" layout="Heading 1">MxInverse(n,A)</Text-field> MxInverse:=proc(n,A) #This algorithm computes the inverse of an nxn matrix using #the gauss algorithm to solve the system Ax=b local i,j,b,x,Inv: Inv:=Array(1..n,1..n): for i from 1 to n do b:=Array(1..n): b[i]:=1: x:=gauss(A,b,n): for j from 1 to n do Inv[j,i]:=x[j]: end do: end do: return (Inv): end proc: A1:=Array([[1,-9],[7,5]]); A2:=MatrixInverse(2,A1); LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYoLUkjbWlHRiQ2JVEjQTFGJy8lJ2l0YWxpY0dRJXRydWVGJy8lLG1hdGh2YXJpYW50R1EnaXRhbGljRictSSNtb0dGJDYtUSM6PUYnL0YzUSdub3JtYWxGJy8lJmZlbmNlR1EmZmFsc2VGJy8lKnNlcGFyYXRvckdGPS8lKXN0cmV0Y2h5R0Y9LyUqc3ltbWV0cmljR0Y9LyUobGFyZ2VvcEdGPS8lLm1vdmFibGVsaW1pdHNHRj0vJSdhY2NlbnRHRj0vJSdsc3BhY2VHUSwwLjI3Nzc3NzhlbUYnLyUncnNwYWNlR0ZMLUkobWFjdGlvbkdGJDYlLUkobWZlbmNlZEdGJDYoLUYjNiYtSSdtdGFibGVHRiQ2Ni1JJG10ckdGJDYnLUkkbXRkR0YkNigtSSNtbkdGJDYkUSIxRidGOS8lKXJvd2FsaWduR1EhRicvJSxjb2x1bW5hbGlnbkdGYG8vJStncm91cGFsaWduR0Zgby8lKHJvd3NwYW5HUSIxRicvJStjb2x1bW5zcGFuR0Znby1GaG42KC1GIzYlLUY2Ni1RKiZ1bWludXM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VtbndpZHRoR1ElYXV0b0YnLyUmd2lkdGhHRmdzLyUrcm93c3BhY2luZ0dRJjEuMGV4RicvJS5jb2x1bW5zcGFjaW5nR1EmMC44ZW1GJy8lKXJvd2xpbmVzR1Elbm9uZUYnLyUsY29sdW1ubGluZXNHRmJ0LyUmZnJhbWVHRmJ0LyUtZnJhbWVzcGFjaW5nR1EsMC40ZW1+MC41ZXhGJy8lKmVxdWFscm93c0dGPS8lLWVxdWFsY29sdW1uc0dGPS8lLWRpc3BsYXlzdHlsZUdGPS8lJXNpZGVHUSZyaWdodEYnLyUwbWlubGFiZWxzcGFjaW5nR0ZfdEZhckZkckY5RjkvSSttc2VtYW50aWNzR0YkUSdNYXRyaXhGJy8lJW9wZW5HUSJbRicvJSZjbG9zZUdRIl1GJ0ZldS8lK2FjdGlvbnR5cGVHUS5ydGFibGVhZGRyZXNzRicvJSlydGFibGVpZEdRKjI0OTYyNjY5NkYnRmFyRmRyRjk= SqrMatrixProduct(2,A1,A2); LUkmQXJyYXlHJSpwcm90ZWN0ZWRHNiMvSSQlaWRHNiIiKiN6RidcIw==
<Text-field style="Heading 1" layout="Heading 1">L2Norm(n,x)</Text-field> L2Norm:=proc(n,x) local j,total; total:=0: for j from 1 to n do total:=total+x[j]^2: end do: return (evalf(total^(1/2))); end proc: x:=Array([3,4]); LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYoLUkjbWlHRiQ2JVEieEYnLyUnaXRhbGljR1EldHJ1ZUYnLyUsbWF0aHZhcmlhbnRHUSdpdGFsaWNGJy1JI21vR0YkNi1RIzo9RicvRjNRJ25vcm1hbEYnLyUmZmVuY2VHUSZmYWxzZUYnLyUqc2VwYXJhdG9yR0Y9LyUpc3RyZXRjaHlHRj0vJSpzeW1tZXRyaWNHRj0vJShsYXJnZW9wR0Y9LyUubW92YWJsZWxpbWl0c0dGPS8lJ2FjY2VudEdGPS8lJ2xzcGFjZUdRLDA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