Here you can find the source of absApproximation(double x, double M)
public static double absApproximation(double x, double M)
//package com.java2s; public class Main { public static double absApproximation(double x, double M) { return huberPenaltyFunction(x, M) / (2 * M); }/*from w w w .j av a2 s. c o m*/ /** * This function computes the Huber penalty function of an * input. The Huber penalty function is equal to x^2 for |x| <= M, * and linear for |x| > M. * @param x the value at which to compute the Huber penalty function * @param M the parameter which determines the linear/quadratic region * @return The Huber penalty function at x */ public static double huberPenaltyFunction(double x, double M) { if (Math.abs(x) <= M) { return x * x; } else { return M * (2 * Math.abs(x) - M); } } }