         }
     }
     
-    public static func * (r: K, f: LaurentPolynomial<K>) -> LaurentPolynomial<K> {
+    public static func * (r: R, f: LaurentPolynomial<R>) -> LaurentPolynomial<R> {
         return f.mapCoeffs { r * $0 }
     }
     
-    public static func * (f: LaurentPolynomial<K>, r: K) -> LaurentPolynomial<K> {
+    public static func * (f: LaurentPolynomial<R>, r: R) -> LaurentPolynomial<R> {
         return f.mapCoeffs { $0 * r }
     }
     

        }
    }
    
    public var leadCoeff: K {
        return coeff(upperDegree)
    }
    
    public func coeff(_ i: Int) -> K {
        return (lowerDegree ... upperDegree).contains(i) ? coeffs[i - lowerDegree] : .zero
    }
    
    public func mapCoeffs(_ f: ((K) -> K)) -> LaurentPolynomial<K> {
        return LaurentPolynomial(lowerDegree: lowerDegree, coeffs: coeffs.map(f))
    }
    
    public static var indeterminate: LaurentPolynomial<K> {
        return LaurentPolynomial<K>(.zero, .identity)
    }
    
    public static func == (f: LaurentPolynomial<K>, g: LaurentPolynomial<K>) -> Bool {
        return (f.lowerDegree == g.lowerDegree) && f.coeffs == g.coeffs
    }
    
    public static func + (f: LaurentPolynomial<K>, g: LaurentPolynomial<K>) -> LaurentPolynomial<K> {
        let (d, D) = (min(f.lowerDegree, g.lowerDegree), max(f.upperDegree, g.upperDegree))
        return LaurentPolynomial(lowerDegree: d, upperDegree: D) { f.coeff($0) + g.coeff($0) }
    }
    
    public static prefix func - (f: LaurentPolynomial<K>) -> LaurentPolynomial<K> {
        return f.mapCoeffs { -$0 }
    }
    
    public static func * (f: LaurentPolynomial<K>, g: LaurentPolynomial<K>) -> LaurentPolynomial<K> {
        let (d, D) = (f.lowerDegree + g.lowerDegree, f.upperDegree + g.upperDegree)
        return LaurentPolynomial(lowerDegree: d, upperDegree: D) { k in
            (max(f.lowerDegree, k - g.upperDegree) ... min(k - g.lowerDegree, f.upperDegree)).sum {

        return upperDegree - lowerDegree
    }
    
    public var inverse: LaurentPolynomial<R>? {
        if span == 0, let a = leadCoeff.inverse {
            return LaurentPolynomial(lowerDegree: -lowerDegree, coeffs: [a])
        } else {
