read NearestNpoly: f1 := randpoly([x,y],degree=4,dense); f2 := randpoly([x,y],degree=5,dense); f := expand(f1*f2)/99; F := evalf(f, 3); NF := NearestNpoly(F, 20); res := TrivialFactoring(NF, 20); Digits := 15: Distance(expand(res),NF): "Distance res to NF is:", evalf(%,6); Digits := 10: "Distance NF to F is:", Distance(NF, F); "Distance f to F is:", Distance(f, F); # Again, we found a reducible polynomial NF, with factorization res, # that is closer to the input F than f was.