                 let x1 = t1 * cos(phi/3) - a/3
                 let x2 = t1 * cos((phi+tau)/3) - a/3
                 let x3 = t1 * cos((phi+2*tau)/3) - a/3
-                return [x1, x2, x3].filter(reduce).map(clamp)
+                return [x1, x2, x3].compactMap(clamp)
             }
             else if discriminant == 0 {
                 let u1 = q2 < 0 ? crt(-q2) : -crt(q2)
                 let x1 = 2*u1-a/3
                 let x2 = -u1 - a/3
-                return [x1,x2].filter(reduce).map(clamp)
+                return [x1,x2].compactMap(clamp)
             }
             else {
                 let sd = sqrt(discriminant)
                 let u1 = crt(-q2+sd)
                 let v1 = crt(q2+sd)
-                return [u1-v1-a/3].filter(reduce).map(clamp)
+                return [u1-v1-a/3].compactMap(clamp)
             }
         }
         else {

internal class Utils {

    // float precision significant decimal
    static let epsilon: CGFloat = 0.000001
    static let tau: CGFloat = 2.0 * CGFloat.pi
    static let quart: CGFloat = CGFloat.pi / 2.0
    
    // Legendre-Gauss abscissae with n=24 (x_i values, defined at i=n as the roots of the nth order Legendre polynomial Pn(x))
    static let Tvalues: ContiguousArray<CGFloat> = [

        }
        else if order == 3 {
            // see http://www.trans4mind.com/personal_development/mathematics/polynomials/cubicAlgebra.htm
            let pa = Double(p[0].y)
            let pb = Double(p[1].y)
            let pc = Double(p[2].y)
            let pd = Double(p[3].y)
            let temp1 = -pa
            let temp2 = 3*pb
            let temp3 = -3*pc
