anchor.diff:              )
           |> Array.filter (fun x -> x <> [])
           |> List.concat
  -        |> List.distinctBy (fun (indicator,xVal) -> round 2 xVal )
  +        |> List.distinctBy (fun (indicator,xVal) -> roundToNext xVal x) //round necessary when root is small and f'(x)=0 at 1.02 and 1.04 because of floating point issues in the root (must be 0)
  +        //possibility to ignore exrema if max and min are present within 0.2 x Values
   
       type Condition =
           | In0 //monotonically increasing
  
positive.code:         let n = a.Length
          match con with
          | In0       -> extremaCount = 0 && a.[0] <= a.[n-1]
          | In1       -> extremaCount = 1 && (fst extrema.[0]) = 1.
          | In2       -> extremaCount = 2 && (fst extrema.[0]) = 1. && (fst extrema.[1]) = -1.
          | In3       -> extremaCount = 3 && (fst extrema.[0]) = 1.
          | In4       -> extremaCount = 4 && (fst extrema.[0]) = 1. && (fst extrema.[1]) = -1.
          | De0       -> extremaCount = 0 && a.[0] >= a.[n-1]
          | De1       -> extremaCount = 1 && (fst extrema.[0]) = -1.
          | De2       -> extremaCount = 2 && (fst extrema.[0]) = -1. && (fst extrema.[1]) = 1.
          | De3       -> extremaCount = 3 && (fst extrema.[0]) = -1.
          | De4       -> extremaCount = 4 && (fst extrema.[0]) = -1. && (fst extrema.[1]) = 1.
          | Complex   -> true
  
      let mapCondition (operator:Matrix<float> -> matrix) con =
  
negative.code:     let splineDecreasing (x:Vector<float>) (y:Vector<float>) (W:Matrix<float>) con = 
          spline (~+) x y W con
  
      type Minimizer = 
          | GCV
          | AICc
  
      ///returns the best fit of the observation x,-and y-values and a given weightingMatrix
      let getBestFitOfWeighting x_values y_values wMat minimizer = 
          let getinitialestimate = getInitialEstimateOfWXY wMat (vector y_values) x_values
          //monotone splines
          let fst1 =(In0,splineIncreasing x_values (vector y_values) wMat 0) |> fun (shapeClass,(constraintMatrices,result)) -> shapeClass,result 
          let fst2 =(De0,splineDecreasing x_values (vector y_values) wMat 0) |> fun (shapeClass,(constraintMatrices,result)) -> shapeClass,result 
  
          //splines with one extremum
          let snd1 =(In1,splineIncreasing x_values (vector y_values) wMat 1) |> fun (shapeClass,(constraintMatrices,result)) -> shapeClass,result 
          let snd2 =(De1,splineDecreasing x_values (vector y_values) wMat 1) |> fun (shapeClass,(constraintMatrices,result)) -> shapeClass,result 
  
          //splines with two extrema                                                                                                              
          let trd1 =(In2,splineIncreasing x_values (vector y_values) wMat 2) |> fun (shapeClass,(constraintMatrices,result)) -> shapeClass,result 
          let trd2 =(De2,splineDecreasing x_values (vector y_values) wMat 2) |> fun (shapeClass,(constraintMatrices,result)) -> shapeClass,result 
  
          //splines with three extremum
          let qua1 =(In3,splineIncreasing x_values (vector y_values) wMat 3) |> fun (shapeClass,(constraintMatrices,result)) -> shapeClass,result 
          let qua2 =(De3,splineDecreasing x_values (vector y_values) wMat 3) |> fun (shapeClass,(constraintMatrices,result)) -> shapeClass,result 
  
          //splines with four extrema                                                                                                             
          let qui1 =(In4,splineIncreasing x_values (vector y_values) wMat 4) |> fun (shapeClass,(constraintMatrices,result)) -> shapeClass,result 
          let qui2 =(De4,splineDecreasing x_values (vector y_values) wMat 4) |> fun (shapeClass,(constraintMatrices,result)) -> shapeClass,result 
  
          match minimizer with
          | Minimizer.AICc -> 
              let initialSelectionCriterion = getinitialestimate.AICc
          
              let bestfst = [fst1;fst2] |> List.minBy (fun (cl,x) -> x.AICc)                                                                
              let bestsnd = [snd1;snd2] |> List.minBy (fun (cl,x) -> x.AICc)                                                               
              let besttrd = [trd1;trd2] |> List.minBy (fun (cl,x) -> x.AICc)
              let bestqua = [qua1;qua2] |> List.minBy (fun (cl,x) -> x.AICc)                                                               
              let bestqui = [qui1;qui2] |> List.minBy (fun (cl,x) -> x.AICc)
  
              //selection of optimal shape possibility by model selection via AICc 
              [bestfst;bestsnd;besttrd;bestqua;bestqui]
              |> List.indexed 
              |> List.minBy (fun (i,(cl,result)) -> 1.05**(float i) * result.AICc)
              |> fun (i,(cl,result)) -> if result.AICc < initialSelectionCriterion then (cl,result) else Complex,result        
          | Minimizer.GCV -> 
              let initialSelectionCriterion = getinitialestimate.GCV             
              let bestfst = [fst1;fst2] |> List.minBy (fun (cl,x) -> x.GCV)                                                                
              let bestsnd = [snd1;snd2] |> List.minBy (fun (cl,x) -> x.GCV)                                                               
              let besttrd = [trd1;trd2] |> List.minBy (fun (cl,x) -> x.GCV)
              let bestqua = [qua1;qua2] |> List.minBy (fun (cl,x) -> x.GCV)                                                               
              let bestqui = [qui1;qui2] |> List.minBy (fun (cl,x) -> x.GCV)
  
              //selection of optimal shape possibility by model selection via AICc 
              [bestfst;bestsnd;besttrd;bestqua;bestqui]
              |> List.indexed 
              |> List.minBy (fun (i,(cl,result)) -> 1.05**(float i) * result.GCV)
              |> fun (i,(cl,result)) -> if result.GCV < initialSelectionCriterion then (cl,result) else Complex,result        
               
  
      [<Obsolete("Only applicable at equal x spacing. Use initEvalAt instead")>]
      //same as initEvalAt, but with recalculated polynomial coefficients
      let initFunctionWithCoefficients (x:Vector<float>) (a:Vector<float>) (c:Vector<float>) =  
          let n = x.Length
  