Hello I am trying to evaluate the bottom expression inside the Do loop
testMatrixSummed=Table[Total[testMatrix[[i,j]],2],{i,1,2},{j,1,2}]
testValues=Eigenvalues[testMatrixSummed];
N[testValues];
(*new eigenvector*)
testWaveFunctions=Eigenvectors[testMatrixSummed];
N[testWaveFunctions]
(*new eigenvalues*)
Min[chemicalPotentialValues] (*choosing the min eigenvalue*)
waveFunctions[[ Min[Position[chemicalPotentialValues,Min[chemicalPotentialValues]]] ]](*setting the eigenvector corresponding to the min eigenvalue to the list*)
testN=N[ testWaveFunctions[[ Min[Position[testValues,Min[testValues]]] ]] ]
When I put this expression inside the 'Do' loop it says 'Set::write' Tag Times in {0.6856, -0.72} is Protected. When I just copy and paste the above expression multiple times and run, It computes. But when I put it inside the 'Do' loop, it gives me an error.
If you want to see what I am doing here is the full code
(*Test*)
testN=List[1,2];
test[x_,y_,z_,t_]:=testN[[y]]*testN[[z]]*(x+y+z+t)
testMatrix=Table[Table[test[x,y,z,t],{y,{1,2}},{z,{1,2}}],{x,{1,2}},{t,{1,2}}];
testMatrix=Table[Table[test[x,y,z,t],{y,{1,2}},{z,{1,2}}],{x,{1,2}},{t,{1,2}}];
testMatrixSummed=Table[Total[testMatrix[[i,j]],2],{i,1,2},{j,1,2}]
testValues=Eigenvalues[testMatrixSummed];
testWaveFunctions=Eigenvectors[testMatrixSummed];
testN=N[ testWaveFunctions[[ Min[Position[testValues,Min[testValues]]] ]] ]
Do[
testMatrix=Table[Table[test[x,y,z,t],{y,{1,2}},{z,{1,2}}],{x,{1,2}},{t,{1,2}}];
testMatrixSummed=Table[Total[testMatrix[[i,j]],2],{i,1,2},{j,1,2}]
testValues=Eigenvalues[testMatrixSummed];
N[testValues]
testWaveFunctions=Eigenvectors[testMatrixSummed];
N[testWaveFunctions]
testN=N[ testWaveFunctions[[ Min[Position[testValues,Min[testValues]]] ]] ]
,2]
Could you help me understand what I am doing wrong inside the loop?
Thank you.