Let f : A 2 X 2 → P 3 be linear transform defined by:
f ( ∣ ∣ ∣ ∣ p 1 p 3 p 2 p 4 ∣ ∣ ∣ ∣ ) = p 1 + p 2 ∗ x + p 3 ∗ x 2 + p 4 ∗ x 3
Let A = { ∣ ∣ ∣ ∣ 1 3 2 4 ∣ ∣ ∣ ∣ , ∣ ∣ ∣ ∣ − 2 5 1 3 ∣ ∣ ∣ ∣ , ∣ ∣ ∣ ∣ 4 1 − 2 7 ∣ ∣ ∣ ∣ , ∣ ∣ ∣ ∣ 7 4 6 3 ∣ ∣ ∣ ∣ } be a basis for A 2 X 2
and,
B = { 2 − x + 4 ∗ x 2 + 3 ∗ x 3 , 5 + 2 ∗ x + x 2 + 4 ∗ x 3 , 1 − x + x 2 + 2 ∗ x 3 , 2 + x 2 − x 3 } be a basis for P 3
If M = [ a i j ] 4 x 4 represents the linear transform above find S = i = 1 ∑ 4 j = 1 ∑ 4 a i j .
Express the result to four decimal places.
If your interested you can write a program(in any language) for the General Case below and use it to find the above result.
General Case:(For program)
For this case I wrote the matrix in an unconventional manner.
Let f : A n X n → P n 2 − 1 be linear transform defined by:
f ( ∣ ∣ ∣ ∣ ∣ ∣ ∣ ∣ ∣ ∣ ∣ ∣ x 1 x n + 1 . . . x ( j − 1 ) ∗ n + 1 . . . x ( n − 1 ) ∗ n + 1 x 2 x n + 2 . . . x ( j − 1 ) ∗ n + 2 . . . x ( n − 1 ) ∗ n + 2 . . . . . . . . . . . . . . . . . . x n x 2 ∗ n x j ∗ n x n 2 ∣ ∣ ∣ ∣ ∣ ∣ ∣ ∣ ∣ ∣ ∣ ∣ ) = j = 1 ∑ n 2 p j ∗ x j − 1
Let V q = ∣ ∣ ∣ ∣ ∣ ∣ ∣ ∣ ∣ ∣ ∣ ∣ x 1 q x ( n + 1 ) q . . . x ( ( j − 1 ) ∗ n + 1 ) q . . . x ( ( n − 1 ) ∗ n + 1 ) q x 2 q x ( n + 2 ) q . . . x ( ( j − 1 ) ∗ n + 2 ) q . . . x ( ( n − 1 ) ∗ n + 2 ) q . . . . . . . . . . . . . . . . . . x n q x ( 2 ∗ n ) q x ( j ∗ n ) q x ( n 2 ) q ∣ ∣ ∣ ∣ ∣ ∣ ∣ ∣ ∣ ∣ ∣ ∣
and A = { V q ∣ ( 1 < = q < = n 2 ) } be a basis for A n X n .
Let W q = j = 1 ∑ n 2 p j q ∗ x j − 1
and B = { W q ∣ ( 1 < = q < = n 2 ) } be a basis for P n 2 − 1
Write a program in any language to find the matrix M = [ a i j ] n 2 x n 2 representation of the general linear transform above and the sum S = i = 1 ∑ n 2 j = 1 ∑ n 2 a i j .
Make certain A and B are bases for A n X n and P n 2 − 1 .
You can use the program written to find the matrix M = [ a i j ] 4 x 4 that represents the linear transform above and output S = i = 1 ∑ 4 j = 1 ∑ 4 a i j .
Let X = ∣ ∣ ∣ ∣ 3 5 − 2 7 ∣ ∣ ∣ ∣
To check the matrix M = [ a i j ] 4 x 4 found, first find [ f ( X ) ] B without using the matrix M = [ a i j ] 4 x 4 , then find [ f ( X ) ] B using the matrix M = [ a i j ] 4 x 4 .
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
Problem Loading...
Note Loading...
Set Loading...
After doing the problem I supply the program I wrote for the general case which generated the output for this specific problem.
Since f : A 2 X 2 → P 3 is a linear transform, for each integer j ∋ ( 1 < = j < = 4 )
f ( ∣ ∣ ∣ ∣ x 1 j x 3 j x 2 j x 4 j ∣ ∣ ∣ ∣ ) = α 1 j ∗ ( 2 − x + 4 ∗ x 2 + 3 ∗ x 2 ) + α 2 j ∗ ( 5 + 2 ∗ x + x 2 + 4 ∗ x 3 ) + α 3 j ∗ ( 1 − x + x + 2 ∗ x 3 ) + α 4 j ∗ ( 2 + x 2 − x 3 ) =
⎣ ⎢ ⎢ ⎡ 2 − 1 4 3 5 2 1 4 1 − 1 1 2 2 0 1 − 1 ⎦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5 4 0 . 6 2 7 1 − 2 . 2 7 1 2 − 1 . 4 5 7 6 2 . 6 1 0 2 0 . 0 5 0 8 − 3 . 5 0 8 5 − 1 . 9 8 3 1 − 0 . 7 1 1 9 0 . 4 4 0 7 3 . 5 9 3 2 − 0 . 1 8 6 4 1 . 7 2 8 8 1 . 6 4 4 1 − 4 . 4 4 0 7 − 0 . 1 1 8 6 ⎦ ⎥ ⎥ ⎤
and S = ∑ i = 1 4 ∑ j = 1 4 a i j = − 2 . 4 5 7 6 .
Check [ f ( X ) ] B :
Without using matrix M :
Let X = ∣ ∣ ∣ ∣ 3 5 − 2 7 ∣ ∣ ∣ ∣
⟹
f ( ∣ ∣ ∣ ∣ 3 5 − 2 7 ∣ ∣ ∣ ∣ ) = 3 − 2 ∗ x + 5 ∗ x 2 + 7 ∗ x 3 = α 1 ∗ ( 2 − x + 4 ∗ x 2 + 3 ∗ x 2 ) + α 2 ∗ ( 5 + 2 ∗ x + x 2 + 4 ∗ x 3 ) + α 3 ∗ ( 1 − x + x + 2 ∗ x 3 ) + α 4 ∗ ( 2 + x 2 − x 3 ) =
⎣ ⎢ ⎢ ⎡ 2 − 1 4 3 5 2 1 4 1 − 1 1 2 2 0 1 − 1 ⎦ ⎥ ⎥ ⎤ * ∣ ∣ ∣ ∣ ∣ ∣ ∣ ∣ α 1 α 2 α 3 α 4 ∣ ∣ ∣ ∣ ∣ ∣ ∣ ∣
Using the above we can set up the augmented matrix:
⎣ ⎢ ⎢ ⎢ ⎢ ⎡ 2 . 0 0 0 0 − 1 . 0 0 0 0 4 . 0 0 0 0 3 . 0 0 0 0 5 . 0 0 0 0 2 . 0 0 0 0 1 . 0 0 0 0 4 . 0 0 0 0 1 . 0 0 0 0 − 1 . 0 0 0 0 1 . 0 0 0 0 2 . 0 0 0 0 2 . 0 0 0 0 0 . 0 0 0 0 1 . 0 0 0 0 − 1 . 0 0 0 0 3 − 2 5 7 ⎦ ⎥ ⎥ ⎥ ⎥ ⎤
Using row operations on the above augmented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 . 9 8 3 1 − 0 . 7 1 1 9 0 . 4 4 0 7 3 . 5 9 3 2 − 0 . 1 8 6 4 1 . 7 2 8 8 1 . 6 4 4 1 − 4 . 4 4 0 7 − 0 . 1 1 8 6 ⎦ ⎥ ⎥ ⎤ ∗ ⎣ ⎢ ⎢ ⎡ − 1 . 8 2 7 4 1 . 5 1 1 2 1 . 2 1 3 0 0 . 4 2 8 3 ⎦ ⎥ ⎥ ⎤ = ⎝ ⎜ ⎜ ⎛ 1 . 0 3 3 9 0 . 1 6 9 5 1 . 3 0 5 1 − 0 . 6 1 0 2 ⎠ ⎟ ⎟ ⎞
I used Free Pascal to write the program below:
program matrixrepresenationoflineartransform_6; {$R-}
{restricted to f:Rm --> Anxn}
uses crt;
const maxnum = 100;
type matrix = array[1 .. maxnum,1 .. maxnum] of real;
var
function intpower(base,exponent:integer):longint;
var product,k:longint;
begin{intpower}
product:= 1;
end;{intpower}
procedure Getsize;
begin
writeln('Enter size of matrix');
readln(n);
end;
procedure Getmatrices;
var k,q,p:integer;
begin
writeln('To Enter ', intpower(n,2), ' basis vectors for A',n,'X',n,' : ');
for q:= 1 to intpower(n,2) do
begin
write('Enter matrix ', q, ' on one line: ');
for k:= 1 to intpower(n,2) do
begin
read(b[k,q]);
end;
end;
writeln('To Enter ',intpower(n,2), ' polynomials of degree ', intpower(n,2) - 1,' : ');
for q:= 1 to intpower(n,2) do
begin
write('Enter coefficients of polynomial ',q,': ');
for k:= 1 to intpower(n,2) do
begin
read(a[k,q]);
end;
writeln;
end;
for q:= 1 to intpower(n,2) do
begin
for k:= 1 to intpower(n,2) do
begin
a[k,intpower(n,2) + q]:= b[k,q];
end;
end;
writeln(' Solve the ',intpower(n,2),' X ',intpower(n,2),' system using the augmented matrix below:');
writeln;
for q:= 1 to intpower(n,2) do
begin
for k:= 1 to 2 * intpower(n,2) do
begin
write(a[q,k]:0:4,' ');
end;
writeln;
end;
for q:= 1 to intpower(n,2) do
begin
for k:= 1 to 2 * intpower(n,2) do
begin
write(mywork5,a[q,k]:0:4,' ');
end;
writeln(mywork5);
end;
end;
{For check bases}
{begin}
procedure hold(var c:matrix; e:matrix; m:integer);
var k,j:integer;
begin
for k:= 1 to m do
begin
for j:= 1 to m do
begin
c[k,j]:= e[k,j];
end;
end;
end;
{Determinants-To check Bases}
procedure switch2(var c:matrix; l,p,n:integer);
var q:integer;
begin{switch}
for q:= 1 to n do
begin{m}
end;{m}
end;{switch}
procedure safeguard2(var c:matrix; l:integer; var p:integer; n:integer; var v:integer; var product:real);
var q:integer;
begin{safeguard}
v:=0;
if (c[l,l] = 0) then
begin{then}
v:= 1;
q:= l;
while ((q + 1) <= n) and (v = 1) do
begin{loop}
if c[q + 1,l] <> 0 then
begin{then}
end;{then}
q:= q + 1;
end;{loop}
end;{then}
end;{safeguard}
procedure operation11(var a:matrix; l,n:integer; var product:real);
var k,q:integer;
procedure operation21(var a:matrix; l,n:integer);
var k,r,q:integer;
FUNCTION DETERMINANT(a:matrix; n:integer; PRODUCT:real):real;
var j:integer;
begin{DETERMINANT}
DIAGONAL:= 1;
FOR j:= 1 TO N DO
BEGIN{LOOP}
DIAGONAL:= DIAGONAL * (a[j,j]);
END;{LOOP}
IF DIAGONAL = 1 THEN
DET:= 1/PRODUCT
ELSE
DET:= 0;
DETERMINANT:= DET;
END;{DETERMINANT}
{end-check bases}
procedure switch(var c:matrix; l,p:integer);
var q:integer;
begin{switch}
for q:= 1 to 2 * intpower(n,2) do
begin{m}
end;{m}
end;{switch}
procedure safeguard(var c:matrix; l:integer; var p:integer; var v:integer);
var q:integer;
begin{safeguard}
v:=0;
if (c[l,l] = 0) then
begin{then}
v:= 1;
q:= l;
while ((q + 1) <= 2 * intpower(n,2)) and (v = 1) do
begin{loop}
if c[q + 1,l] <> 0 then
begin{then}
end;{then}
q:= q + 1;
end;{loop}
end;{then}
end;{safeguard}
procedure operation1(var a:matrix; l:integer);
var q,k:integer;
begin{op1}
for q:= 1 to 2 * intpower(n,2) do
begin{m}
s[l,q]:= a[l,q]/a[l,l];
end;{m}
x:= 1/(a[l,l]);
for q:= 1 to 2 * intpower(n,2) do
begin{m}
a[l,q]:= s[l,q];
end;{m}
writeln(mywork5, x:0:4,' * Row',l);
writeln(mywork5);
for q:= 1 to intpower(n,2) do
begin
for k:= 1 to 2 * intpower(n,2) do
begin
write(mywork5, a[q,k]:0:4,' ');
end;
writeln(mywork5);
end;
writeln(mywork5);
end;{op1}
procedure operation2(var a:matrix; l:integer);
var q,r,k:integer;
begin{op2}
for q:= 1 to intpower(n,2) do
begin{q}
if q <> l then
begin{then}
x:= a[q,l];
for r:= 1 to 2 * intpower(n,2) do
begin{m}
s[q,r]:= -1 * x * a[l,r] + a[q,r];
end;{m}
for r:= 1 to 2 * intpower(n,2) do
begin{m}
a[q,r]:= s[q,r];
end;{m}
writeln(mywork5, -1 * x:0:4,' * ROW ', l,' + ROW',q);
end;{then}
end;{q}
writeln(mywork5);
for q:= 1 to intpower(n,2) do
begin
for k:= 1 to 2 * intpower(n,2) do
begin
write(mywork5, a[q,k]:0:4,' ');
end;
writeln(mywork5);
end;
writeln(mywork5);
end;{op2}
PROCEDURE SHOWDATA;
VAR J,k:INTEGER;
BEGIN
assign(myfile2,'holdsolution5.txt');
rewrite(myfile2);
writeln;
writeln('Matrix Representation of linear transformation f: A',n,' X ',n, ' ---> P',intpower(n,2) - 1,' : ');
writeln('--------------------------------------------------------------------------------------------');
writeln;
for j:= 1 to intpower(n,2) do
begin
for k:= intpower(n,2) + 1 to 2 * intpower(n,2) do
begin
write(myfile2,a[j,k],' ');
end;
writeln(myfile2);
end;
reset(myfile2);
for j:= 1 to intpower(n,2) do
begin
for k:= 1 to intpower(n,2) do
begin
read(myfile2,sol[j,k]);
end;
end;
close(myfile2);
for j:= 1 to intpower(n,2) do
begin
for k:= 1 to intpower(n,2) do
begin
write(sol[j,k]:0:4,' ');
end;
writeln;
end;
{For brillant only}
sum:= 0;
for j:= 1 to intpower(n,2) do
begin
for k:= 1 to intpower(n,2) do
begin
sum:= sum + sol[j,k];
end;
end;
writeln;
writeln('Sum of elements of matrix = ',sum:0:4);
END;
{Last check [f(x)]B }
procedure switch3(var c:matrix; l,p,n:integer);
var r:integer;
z:real;
begin{switch3}
for r:= 1 to n + 1 do
begin{m}
end;{m}
end;{switch3}
procedure safeguard3(var c:matrix; l:integer; var p:integer; n:integer; var v:integer);
var r:integer;
begin{safeguard3}
v:=0;
if (c[l,l] = 0) then
begin{then}
v:= 1;
r:= l;
while ((r + 1) <= n) and (v = 1) do
begin{loop}
if c[r + 1,l] <> 0 then
begin{then}
end;{then}
r:= r + 1;
end;{loop}
end;{then}
end;{safeguard3}
procedure operation13(var a:matrix; l,n:integer);
var r,k:integer;
begin{op13}
for r:= 1 to n + 1 do
begin{r}
s[l,r]:= a[l,r]/a[l,l];
end;{r}
x:= 1/(a[l,l]);
for r:= 1 to n + 1 do
begin{m}
a[l,r]:= s[l,r];
end;{r}
end;{op13}
procedure operation23(var a:matrix; l,n:integer);
var q,r:integer;
begin{op23}
for q:= 1 to n do
begin{q}
if q <> l then
begin{then}
x:= a[q,l];
for r:= 1 to n + 1 do
begin{r}
s[q,r]:= -1 * x * a[l,r] + a[q,r];
end;{r}
for r:= 1 to n + 1 do
begin{r}
a[q,r]:= s[q,r];
end;{r}
end;{then}
end;{q}
end;{op23}
procedure solution(y:matrix; n:integer);
var q:integer;
begin{solution}
end;{solution}
procedure matrixmult(a,b:matrix; var summat:matrix);
var j,k,s:integer;
begin{matrixmult}
for j:= 1 to intpower(n,2) do
begin{j}
for k:= 1 to 1 do
begin{k}
for s:= 1 to intpower(n,2) do
begin{s}
end;{s}
writeln(mywork5,sum:0:4);
end;{j}
writeln(mywork5);
end;{matrixmult}
procedure check;
var p,j,k:integer;
begin
{without using matrix}
writeln(mywork5, ' Check [f(p)]B');
writeln(' -------------');
writeln(mywork5);
writeln('Enter a vector in M ',n,' X ',n,' on one line');
for j:= 1 to intpower(n,2) do
begin
read(f[j,intpower(n,2) + 1]);
end;
for j:= 1 to intpower(n,2) do
begin
e[j,intpower(n,2) + 1]:= f[j,intpower(n,2) + 1];
end;
for j:= 1 to intpower(n,2) do
begin
for k:= 1 to intpower(n,2) + 1 do
begin
write(mywork5,f[j,k]:0:4,' ');
end;
writeln(mywork5);
end;
{Next Use operations on matrix f}
writeln(mywork5);
writeln(mywork5, 'Check [f(p)]B');
writeln(mywork5);
for l:= 1 to intpower(n,2) do
begin{l}
safeguard3(f,l,p,intpower(n,2),v);
if v = 0 then
begin{then}
operation13(f,l,intpower(n,2));
operation23(f,l,intpower(n,2));
end;{then}
end;{l}
writeln(mywork5);
solution(f,intpower(n,2));
{Now do using matrix M}
writeln(mywork5);
writeln(mywork5);
for j:= 1 to intpower(n,2) do
begin
for k:= 1 to intpower(n,2) + 1 do
begin
write(mywork5,e[j,k]:0:4,' ');
end;
writeln(mywork5);
end;
for l:= 1 to intpower(n,2) do
begin{l}
safeguard3(e,l,p,intpower(n,2),v);
if v = 0 then
begin{then}
operation13(e,l,intpower(n,2));
operation23(e,l,intpower(n,2));
end;{then}
end;{l}
writeln(mywork5);
solution(e,intpower(n,2));
writeln(mywork5);
writeln(mywork5);
for j:= 1 to intpower(n,2) do
begin
u[j,1]:= e[j,intpower(n,2) + 1];
end;
writeln(mywork5);
writeln(mywork5);
matrixmult(sol,u,prod);
end;
begin
assign(mywork5,'mywork5.txt');
rewrite(mywork5);
getsize;
getmatrices;
hold(f,a,intpower(n,2)); {for me only-check [f(X)]}
hold(e,b,intpower(n,2));
{do determinants here}
{To do determinants to check bases here, then done.}
{checking basis for A(2x2)}
PRODUCT:= 1;
for l:= 1 to intpower(n,2) do
begin{l}
safeguard2(b,l,p,intpower(n,2),v,PRODUCT);
if v = 0 then
begin{then}
operation11(b,l,intpower(n,2),PRODUCT);
operation21(b,l,intpower(n,2));
end;{then}
end;{l}
DETB:= DETERMINANT(b,intpower(n,2),PRODUCT);
writeln;
while detb = 0 do
begin
writeln('Set of matrices is not a basis for A ',n,' X ',n);
writeln;
getmatrices;
PRODUCT:= 1;
for l:= 1 to intpower(n,2) do
begin{l}
safeguard2(b,l,p,intpower(n,2),v,PRODUCT);
if v = 0 then
begin{then}
operation11(b,l,intpower(n,2),PRODUCT);
operation21(b,l,intpower(n,2));
end;{then}
end;{l}
DETB:= DETERMINANT(b,intpower(n,2),PRODUCT);
end;
{checking basis for Rn^2}
hold(c,a,intpower(n,2));
PRODUCT:= 1;
for l:= 1 to intpower(n,2) do
begin{l}
safeguard2(c,l,p,intpower(n,2),v,PRODUCT);
if v = 0 then
begin{then}
operation11(c,l,intpower(n,2),PRODUCT);
operation21(c,l,intpower(n,2));
end;{then}
end;{l}
DETA:= DETERMINANT(c,intpower(n,2),PRODUCT);
writeln;
while deta = 0 do
begin
writeln('Set of vectors is not a basis for R',intpower(n,2));
writeln;
getmatrices;
hold(c,a,intpower(n,2));
PRODUCT:= 1;
for l:= 1 to intpower(n,2) do
begin{l}
safeguard2(c,l,p,intpower(n,2),v,PRODUCT);
if v = 0 then
begin{then}
operation11(c,l,intpower(n,2),PRODUCT);
operation21(c,l,intpower(n,2));
end;{then}
end;{l}
DETA:= DETERMINANT(c,intpower(n,2),PRODUCT);
end;
{Only getting through if deta <> 0 and detb <> 0}
for l:= 1 to intpower(n,2) do
begin{l}
safeguard(a,l,p,v);
if v = 0 then
begin{then}
operation1(a,l);
operation2(a,l);
end;{then}
end;{l}
showdata;
check;
close(mywork5);
readln;
readln;
end.