Data.Random.Distribution.Normal:normalF from random-fu-0.2.6.2

Percentage Accurate: 100.0% → 100.0%
Time: 981.0ms
Alternatives: 3
Speedup: 1.0×

Specification

?
\[e^{\left(x \cdot y\right) \cdot y} \]
(FPCore (x y)
  :precision binary64
  :pre TRUE
  (exp (* (* x y) y)))
double code(double x, double y) {
	return exp(((x * y) * y));
}
real(8) function code(x, y)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = exp(((x * y) * y))
end function
public static double code(double x, double y) {
	return Math.exp(((x * y) * y));
}
def code(x, y):
	return math.exp(((x * y) * y))
function code(x, y)
	return exp(Float64(Float64(x * y) * y))
end
function tmp = code(x, y)
	tmp = exp(((x * y) * y));
end
code[x_, y_] := N[Exp[N[(N[(x * y), $MachinePrecision] * y), $MachinePrecision]], $MachinePrecision]
f(x, y):
	x in [-inf, +inf],
	y in [-inf, +inf]
code: THEORY
BEGIN
f(x, y: real): real =
	exp(((x * y) * y))
END code
e^{\left(x \cdot y\right) \cdot y}

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 3 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 100.0% accurate, 1.0× speedup?

\[e^{\left(x \cdot y\right) \cdot y} \]
(FPCore (x y)
  :precision binary64
  :pre TRUE
  (exp (* (* x y) y)))
double code(double x, double y) {
	return exp(((x * y) * y));
}
real(8) function code(x, y)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = exp(((x * y) * y))
end function
public static double code(double x, double y) {
	return Math.exp(((x * y) * y));
}
def code(x, y):
	return math.exp(((x * y) * y))
function code(x, y)
	return exp(Float64(Float64(x * y) * y))
end
function tmp = code(x, y)
	tmp = exp(((x * y) * y));
end
code[x_, y_] := N[Exp[N[(N[(x * y), $MachinePrecision] * y), $MachinePrecision]], $MachinePrecision]
f(x, y):
	x in [-inf, +inf],
	y in [-inf, +inf]
code: THEORY
BEGIN
f(x, y: real): real =
	exp(((x * y) * y))
END code
e^{\left(x \cdot y\right) \cdot y}

Alternative 1: 75.7% accurate, 1.7× speedup?

\[\begin{array}{l} \mathbf{if}\;\left(x \cdot y\right) \cdot y \leq -143750390.52798983:\\ \;\;\;\;0\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
(FPCore (x y)
  :precision binary64
  :pre TRUE
  (if (<= (* (* x y) y) -143750390.52798983) 0.0 1.0))
double code(double x, double y) {
	double tmp;
	if (((x * y) * y) <= -143750390.52798983) {
		tmp = 0.0;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
real(8) function code(x, y)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if (((x * y) * y) <= (-143750390.52798983d0)) then
        tmp = 0.0d0
    else
        tmp = 1.0d0
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if (((x * y) * y) <= -143750390.52798983) {
		tmp = 0.0;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if ((x * y) * y) <= -143750390.52798983:
		tmp = 0.0
	else:
		tmp = 1.0
	return tmp
function code(x, y)
	tmp = 0.0
	if (Float64(Float64(x * y) * y) <= -143750390.52798983)
		tmp = 0.0;
	else
		tmp = 1.0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (((x * y) * y) <= -143750390.52798983)
		tmp = 0.0;
	else
		tmp = 1.0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[N[(N[(x * y), $MachinePrecision] * y), $MachinePrecision], -143750390.52798983], 0.0, 1.0]
f(x, y):
	x in [-inf, +inf],
	y in [-inf, +inf]
code: THEORY
BEGIN
f(x, y: real): real =
	LET tmp = IF (((x * y) * y) <= (-1437503905279898345470428466796875e-25)) THEN (0) ELSE (1) ENDIF IN
	tmp
END code
\begin{array}{l}
\mathbf{if}\;\left(x \cdot y\right) \cdot y \leq -143750390.52798983:\\
\;\;\;\;0\\

\mathbf{else}:\\
\;\;\;\;1\\


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 (*.f64 x y) y) < -143750390.52798983

    1. Initial program 100.0%

      \[e^{\left(x \cdot y\right) \cdot y} \]
    2. Taylor expanded in x around 0

      \[\leadsto 1 \]
    3. Step-by-step derivation
      1. Applied rewrites51.4%

        \[\leadsto 1 \]
      2. Taylor expanded in undef-var around zero

        \[\leadsto 0 \]
      3. Step-by-step derivation
        1. Applied rewrites27.1%

          \[\leadsto 0 \]

        if -143750390.52798983 < (*.f64 (*.f64 x y) y)

        1. Initial program 100.0%

          \[e^{\left(x \cdot y\right) \cdot y} \]
        2. Taylor expanded in x around 0

          \[\leadsto 1 \]
        3. Step-by-step derivation
          1. Applied rewrites51.4%

            \[\leadsto 1 \]
        4. Recombined 2 regimes into one program.
        5. Add Preprocessing

        Alternative 2: 51.4% accurate, 18.0× speedup?

        \[1 \]
        (FPCore (x y)
          :precision binary64
          :pre TRUE
          1.0)
        double code(double x, double y) {
        	return 1.0;
        }
        
        real(8) function code(x, y)
        use fmin_fmax_functions
            real(8), intent (in) :: x
            real(8), intent (in) :: y
            code = 1.0d0
        end function
        
        public static double code(double x, double y) {
        	return 1.0;
        }
        
        def code(x, y):
        	return 1.0
        
        function code(x, y)
        	return 1.0
        end
        
        function tmp = code(x, y)
        	tmp = 1.0;
        end
        
        code[x_, y_] := 1.0
        
        f(x, y):
        	x in [-inf, +inf],
        	y in [-inf, +inf]
        code: THEORY
        BEGIN
        f(x, y: real): real =
        	1
        END code
        1
        
        Derivation
        1. Initial program 100.0%

          \[e^{\left(x \cdot y\right) \cdot y} \]
        2. Taylor expanded in x around 0

          \[\leadsto 1 \]
        3. Step-by-step derivation
          1. Applied rewrites51.4%

            \[\leadsto 1 \]
          2. Add Preprocessing

          Reproduce

          ?
          herbie shell --seed 2026092 
          (FPCore (x y)
            :name "Data.Random.Distribution.Normal:normalF from random-fu-0.2.6.2"
            :precision binary64
            (exp (* (* x y) y)))