"Sparse or not sparse, that is the question"

What is sparse?

m=6;
A= RandomReal[{-1,1},{m,m}];

TridiagonalA=SparseArray[{
Band[{1,1}]->Diagonal[A],
Band[{1,2}]->Diagonal[A,1],
Band[{2,1}]->Diagonal[A,-1]
},
{m,m}];

SparseAOne=0.0*A;
SparseAOne[[1,1]]=A[[1,1]];
SparseAOne[[1,2]]=A[[1,2]];
SparseAOne[[2,1]]=A[[2,1]];
SparseAOne[[m,m]]=A[[m,m]];
Do[ 
SparseAOne[[i,i]]=A[[i,i]];
SparseAOne[[i+1,i]]=A[[i+1,i]];
SparseAOne[[i,i+1]]=A[[i,i+1]],
{i,2,m-1}]

SparseATwo=SparseArray[
Flatten[{
{1,1}->A[[1,1]],
{1,2}->A[[1,2]],
{2,1}->A[[2,1]],
{m,m}->A[[m,m]],
Table[{
{i,i}->A[[i,i]],
{i,i+1}->A[[i,i+1]],
{i+1,i}->A[[i+1,i]]
},
{i,2,m-1}]
}],
{m,m}];

A
TridiagonalA
SparseAOne
SparseATwo

MatrixForm[TridiagonalA]
MatrixForm[SparseAOne]
MatrixForm[SparseATwo]

ByteCount[SparseAOne]
ByteCount[TridiagonalA]
ByteCount[SparseATwo]

Timings etc.

MakeTri[A_]:= SparseArray[{
Band[{1,1}]->Diagonal[A],
Band[{1,2}]->Diagonal[A,1],
Band[{2,1}]->Diagonal[A,-1]
},
Dimensions[A]
];
MakeNotSparse[A_]:= Module[
{SparseA=0*A,i,m=Length[A]},
SparseA=0.0*A;
SparseA[[1,1]]=A[[1,1]];
SparseA[[1,2]]=A[[1,2]];
SparseA[[2,1]]=A[[2,1]];
SparseA[[m,m]]=A[[m,m]];
Do[ 
SparseA[[i,i]]=A[[i,i]];
SparseA[[i+1,i]]=A[[i+1,i]];
SparseA[[i,i+1]]=A[[i,i+1]],
{i,2,m-1}];
SparseA
]
MakeSparse[A_]:= Module[
{m=Length[A],i},
SparseArray[
Flatten[{
{1,1}->A[[1,1]],
{1,2}->A[[1,2]],
{2,1}->A[[2,1]],
{m,m}->A[[m,m]],
Table[{
{i,i}->A[[i,i]],
{i,i+1}->A[[i,i+1]],
{i+1,i}->A[[i+1,i]]
},
{i,2,m-1}]
}],
{m,m}]
]

Now some timings for linear solve!

DataFull=Table[
m=Floor[(2^p)];
A= RandomReal[{-1,1},{m,m}];
TridiagonalA=SparseArray[{
Band[{1,1}]->Diagonal[A],
Band[{1,2}]->Diagonal[A,1],
Band[{2,1}]->Diagonal[A,-1]
},
{m,m}];
b = RandomReal[{-1,1},{m}];
{m, Timing[LinearSolve[A,b];][[1]]},
{p,6,11,0.5}
]

DataTri=Table[
m=Floor[(2^p)];
A= RandomReal[{-1,1},{m,m}];
TridiagonalA=SparseArray[{
Band[{1,1}]->Diagonal[A],
Band[{1,2}]->Diagonal[A,1],
Band[{2,1}]->Diagonal[A,-1]
},
{m,m}];
b = RandomReal[{-1,1},{m}];
{m, Timing[LinearSolve[TriDiagonalA,b];][[1]]},
{p,6,11,0.5}
]

ListLogLogPlot[
{DataFull,DataTri},
Frame->True,
GridLines->Automatic,
FrameLabel->{"m","sec"}]

3x3 SVD

m = 3;
A=RandomReal[{-1,1},{m,m}];
{u,w,v}=SingularValueDecomposition[A,1];
u=Flatten[u];
v=Flatten[v];
x0 =RandomReal[{-1,1},{m}];
i=Ordering[Map[Norm,A],-1][[1]]
Map[Norm,A]
x0=A[[1]];
x=x0/Norm[x0];
Eigenvalues[A.Transpose[A]]
Table[
x=Transpose[A].A.x;
x=x/Norm[x];
y=A.x; y=y/Norm[y];
{i,180/π ArcSin[Sqrt[1-(({v.x,u.y})^2)]]},
{i,1,4}
]//TableForm

?Ordering

MatrixForm[A]

u

{U,W,V}=SingularValueDecomposition[A]
uu=Transpose[U][[2]]
uu.y

0.05677399350498526`

?ArcCos

Plot[ArcCos[t],{t,-1,1}]

((Flatten[u])^2)

w

?SingularValueDecomposition