Karim Belabas on Thu, 10 Jul 2025 22:41:45 +0200 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: question on setminus(set,element) |
* American Citizen [2025-07-10 22:21]: > Can anyone explain why setminus(Set,element) won't work the first time, but > works the second time? The first time, your set S contains [Pol(1), Pol(0)]. So, when you try to remove [1,0], it doesn't work. Either use S = setunion(S, simplify([[xt, yt]])) or replace S = simplify(S). Cheers, K.B. -- Pr. Karim Belabas, U. Bordeaux, Vice-président en charge du Numérique Institut de Mathématiques de Bordeaux UMR 5251 - (+33) 05 40 00 29 77 http://www.math.u-bordeaux.fr/~kbelabas/ > {point_on_conic(C,pt)= > my(a,b,c,d,e,f,r,s); > if(matsize(C)[2]!=6,return();); > [a,b,c,d,e,f]=C; > [r,s]=pt; > return(a*r^2+b*r*s+c*s^2+d*r+e*s+f); > } > > {parameterize_conic(conic,pt)= > my(k,x1,y1,P,R,rsz,S,T); > if(matsize(conic)[2]!=6,return();); > x1=pt[1];y1=pt[2]; > k=point_on_conic(conic,pt); > if(k!=0,print("Point not on conic!");return();); > y=t*(x-x1)+y1; > P=point_on_conic(conic,[x,y]); > print("P=",P); > R=factor(P); > print("Factored P =",R); > rsz=matsize(R)[1]; > S=Set(); > for(i=1,rsz, > xt=-polcoef(R[i,1],0)/polcoef(R[i,1],1); > yt=t*(xt-x1)+y1; > print("at root #",i," xt,yt = ",xt,",",yt); > print("type xt = ",type(xt)," type yt = ",type(yt)); > S=setunion(S,[[xt,yt]]); > \\if(type(xt)!="t_POL",S=setunion(S,[xt,yt]);); > ); > print("S=",S); > print("Attemting to remove point ",pt," from S"); > print("T=setminus(S,[",pt,"])"); > T=setminus(S,[pt]); > print("T=",T); > print("we now define S again"); > S=[[1, 0], [(t^2 - 1)/(t^2 + 1), -2*t/(t^2 + 1)]]; > print("S = ",S); > print("remove ",pt); > T=setminus(S,[pt]); > print("new T = ",T," which is what we want"); > print("why cannot the point be removed the first time?"); > > if(matsize(T)[2]==1,T=T[1];); > return(T); > } > c=[1,0,1,0,0,-1] > pt=[1,0] > parameterize_conic(c,pt) > >