Compute the canonical divisor of a ring (warning, the canonical divisor is not unique, but only unique up to linear equivalence). If the IsGraded option is set to true (default false), then it will return a canonical divisor for the Proj of R, otherwise it will return one for only the Spec. The graded version only works reliably for graded rings over a field (for instance, if you have a Rees algebra you will need to flatten the variables).
i1 : R = QQ[x,y,z] o1 = R o1 : PolynomialRing |
i2 : canonicalDivisor(R) o2 = 0, the zero divisor of R o2 : WDiv |
i3 : canonicalDivisor(R, IsGraded=>true) o3 = -3*Div(x) of R o3 : WDiv |
Note the IsGraded option makes a difference. Consider now a non-Gorenstein singularity.
i4 : R = QQ[a,b,c,d]/ideal(c^2-b*d, b*c-a*d, b^2-a*c) o4 = R o4 : QuotientRing |
i5 : canonicalDivisor(R) o5 = -2*Div(d, c, b) of R o5 : WDiv |