hermann on Fri, 09 Feb 2024 20:17:46 +0100 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: Best way to determine horizontal plane ℤ³ that contains most vectors of given vector of vectrs |
On 2024-02-09 18:19, Gareth Ma wrote:
Thank you, that is definitely more compact and nicer than my 3 lines before.Try this: ? z = vecsort(matreduce([v[3] | v <- S])~, 2, 4)[1, 1]; z %21 = -1 ?
I simplified my code, now these 6 lines of PARI/GP compute everything: https://github.com/Hermann-SW/GP3D/blob/main/tqf_3D.2.gp#L38-L43 Q=qflllgram(get_tqf(n))^-1; M=Q~*Q; S=[x|x<-Vec(qfminim(M,n)[3]),qfeval(M,x)<=n]; P=[(Q*v)~|v<-S,v[3]==vecsort(matreduce([v[3]|v<-S])~,2,4)[1,1]]; v=matker(Mat(apply(x->concat(x,1),P~)))[,1]; PO=-v[4]/(norml2(v[1..3]))*v[1..3]~;Q is the matrix to multiply [0,0,1]~ with to result in sum of three squares of n (Dirichlet 1850)
S are all points in ℤ³ with norml2()==n,n-1,...,1P is the mapped by Q plane determined now with mapreduce (for -3, the purple vertices)
v is a normal vector of plane through all PPO is point on plane with minimal distance to origin (small black sphere)
https://stamm-wilbrandt.de/images/tqf_3D.2.gp.n_37.jpg Interactive: https://stamm-wilbrandt.de/tqf_3D.2.gp.n_37.html Regards, Hermann.