New Jacobi

J[{i_,j_},{p1_,p2_},m_]:= Module[
{n=Norm[{p1,p2}]},
(* (({{ p1, p2}, {-p2, P1}}))*)
 SparseArray[{
{i,i}->p1,
{j,j}->p1,
{i,j}->p2,
{j,i}->-1p2,
Band[{1,1}]->1
},
{m,m}
]
]

MatrixForm[J[ {4,6}, {c,s}, 6]]

J[{i_,j_,k_,l_},{p1_,p2_,p3_,p4_},m_]:= Module[
{n=Norm[{p1,p2,p3,p4}],pp1,pp2,pp3,pp4},
(* LinAlg+App 332(2001) 37-80 Fasbender p65 *)
(* (({{ p1,  p2,  p3,  p4}, {-p2,  p1,  p4, -p3}, {-p3, -p4,  p1,  p2}, {-p4,  p3, -p2,  p1}})) *)
{pp1,pp2,pp3,pp4}={p1,p2,p3,p4}/n;
 SparseArray[{
{i,i}->pp1,  {i,j}->pp2,{i,k}->pp3, {i,l}->pp4,
{j,i}->-pp2,{j,j}->pp1,{j,k}->pp4,{j,l}->-pp3,
{k,i}->-pp3,{k,j}->-pp4,{k,k}->pp1,{k,l}->pp2,
{l,i}->-pp4,{l,j}->pp3,{l,k}->-pp2,{l,l}->pp1,
Band[{1,1}]->1
},
{m,m}
]
]

J[
{i1_,i2_,i3_,i4_,i5_,i6_,i7_,i8_},
{p1_,p2_,p3_,p4_,p5_,p6_,p7_,p8_},
m_]:= Module[
{n=Norm[{p1,p2,p3,p4,p5,p6,p7,p8}],
pp1,pp2,pp3,pp4,pp5,pp6,pp7,pp8},
(* LinAlg+App 332(2001) 37-80 Fasbender p66 *)
(* (({{ p1,  p2,  p3,  p4,  p5,  p6,  p7,  p8}, {-p2,  p1,  p4, -p3,  p6, -p5, -p8,  p7}, {-p3, -p4,  p1,  p2,  p7,  p8, -p5, -p6}, {-p4,  p3, -p2,  p1,  p8, -p7,  p6, -p5}, {-p5, -p6, -p7, -p8,  p1,  p2,  p3,  p4}, {-p6,  p5, -p8,  p7, -p2,  p1,  p4, -p3}, {-p7,  p8,  p5, -p6, -p3, -p4,  p1,  p2}, {-p8, -p7,  p6, -p5, -p4,  p3, -p2,  p1}})) *)
{pp1,pp2,pp3,pp4}={p1,p2,p3,p4}/n;
 SparseArray[{
{i,i}->pp1,  {i,j}->pp2,{i,k}->pp3, {i,l}->pp4,
{j,i}->-pp2,{j,j}->pp1,{j,k}->pp4,{j,l}->-pp3,
{k,i}->-pp3,{k,j}->-pp4,{k,k}->pp1,{k,l}->pp2,
{l,i}->-pp4,{l,j}->pp3,{l,k}->-pp2,{l,l}->pp1,
Band[{1,1}]->1
},
{m,m}
]
]

m=12;
A=RandomReal[{-1,1},{m,m}];
A=A+Transpose[A];
{i,j,k,l}={1,2,3,9};
p=A[[{i,j,k,l},i]];
JJ=J[{i,j,k,l}, p,m];
MatrixForm[JJ]
MatrixForm[A]
MatrixForm[JJ.A]

MatrixForm[A]
MatrixForm[Chop[JJ.A.Transpose[JJ]]]

Optimization Jacobi

What I have in the books etc are definitions of convenient and easily computed rotations.  The default versions zero entries in a column in the forward mode.
	A⟶J.A
The ArcTan version for the 2×2 does simultaneous zeroing in a symetric matrix for two entries in the similarity case
	A⟶J.A.(J^T)
No matter what I plug in J is always a rotation.

The questiona are:
	1) Are there simultaneous zeroing condition for the 4×4 an 8×8 cases?
	2) Is it better to make the off diagonal small in the block rather than make some elenments zero?
	
This starts to sound like an optimization problem to maximize the diagonal entries in the block.    The deal here is that we are hoping to have a simple analytic answer to the optimization problem

A= Array[a,{2,2}](*/.a[2,1]->a[1,2];*) 
JJ = J[{1,2},{p1,p2},2];
MatrixForm[JJ]
AA=JJ.A.Transpose[JJ]
F[{p1_,p2_}]=Simplify[((Diagonal[AA])^2)]/.List->Plus
Minimize[{
F[{p1,p2}],
(p1^2)+(p2^2)==1
},
{p1,p2}]

Simplify[
Simplify[
AA[[1,2]]/.{p2->ϵ p1}
]/(p1^2)]==0
Simplify[
Simplify[
AA[[2,1]]/.{p2->ϵ p1}
]/(p1^2)]==0

Solve[
Simplify[
Simplify[
AA[[1,2]]/.{p2->ϵ p1}
]/(p1^2)]==0, ϵ]//Simplify

?Solve

Clear[p1,p2]
Solve[
{
AA[[1,2]]==0,
(p1^2)+(p2^2)==1
},
p2]

Solve[ AA[[1,2]]==0,p2]

Minimize[{
F[{p1,p2}],
(p1^2)+(p2^2)==1
},
{p1,p2}]

D

Clear[c,s]
JJ=J[{1,2},{p1,p2},2]
A={
{p1,p2},
{p2,p1}
}
AA=JJ.A
Simplify[((Norm[Expand[Diagonal[AA]]/.{(s^2)->1-(c^2),s->(Sqrt[1-(c^2)])}])^2).
Assumptions->{0≤c≤1}
]

MatrixForm[Simplify[AA/.a[2,1]->a[1,2]]]

Expand[AA[[1,2]]]/(c s) == 0

Solve[ 
AA[[1,2]] == 0,
c]

Jacob Shifts

m=4;
A= RandomReal[{-1,1},{m,m}];
A= A + Transpose[A];
MatrixForm[A]

JJ=Simplify[J[{1,2,3,4},{p1,p2,p3,p4},m] Norm[{p1,p2,p3,p4}]]
MatrixForm[JJ]

dia=Diagonal[JJ.A.Transpose[JJ]];
dia=Expand[dia.dia]
MatrixForm[
D[ dia,{{p1,p2,p3,p4}}]
]

A=Array[a,{4,4}];
Simplify[Eigenvalues[A][[1]]]

Local Sweeps