This is an application of the method SegreClass. See also the corresponding methods in the packages CSM-A, by P. Aluffi, and CharacteristicClasses, by M. Helmer and C. Jost.
In general, even if the input ideal defines a singular variety $X$, the returned value equals the degree of the component of dimension 0 of the Chern-Fulton class of $X$. The Euler characteristic of a singular variety can be computed via the method ChernSchwartzMacPherson.
In the example below, we compute the Euler characteristic of $\mathbb{G}(1,4)\subset\mathbb{P}^{9}$, using both a probabilistic and a non-probabilistic approach.
i1 : I = Grassmannian(1,4,CoefficientRing=>ZZ/190181); ZZ o1 : Ideal of ------[p ..p , p , p , p , p , p , p , p , p ] 190181 0,1 0,2 1,2 0,3 1,3 2,3 0,4 1,4 2,4 3,4 |
i2 : time EulerCharacteristic I -- used 0.36301 seconds o2 = 10 |
i3 : time EulerCharacteristic(I,MathMode=>true) MathMode: output certified! -- used 0.0971544 seconds o3 = 10 |
The object EulerCharacteristic is a method function with options.