Average Error: 5.2 → 0.1
Time: 3.3s
Precision: binary64
Cost: 708
\[\frac{x}{y \cdot y} - 3 \]
\[\begin{array}{l} \mathbf{if}\;y \cdot y \leq 5 \cdot 10^{-310}:\\ \;\;\;\;\frac{x}{y} \cdot \frac{1}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y \cdot y} + -3\\ \end{array} \]
(FPCore (x y) :precision binary64 (- (/ x (* y y)) 3.0))
(FPCore (x y)
 :precision binary64
 (if (<= (* y y) 5e-310) (* (/ x y) (/ 1.0 y)) (+ (/ x (* y y)) -3.0)))
double code(double x, double y) {
	return (x / (y * y)) - 3.0;
}
double code(double x, double y) {
	double tmp;
	if ((y * y) <= 5e-310) {
		tmp = (x / y) * (1.0 / y);
	} else {
		tmp = (x / (y * y)) + -3.0;
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = (x / (y * y)) - 3.0d0
end function
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if ((y * y) <= 5d-310) then
        tmp = (x / y) * (1.0d0 / y)
    else
        tmp = (x / (y * y)) + (-3.0d0)
    end if
    code = tmp
end function
public static double code(double x, double y) {
	return (x / (y * y)) - 3.0;
}
public static double code(double x, double y) {
	double tmp;
	if ((y * y) <= 5e-310) {
		tmp = (x / y) * (1.0 / y);
	} else {
		tmp = (x / (y * y)) + -3.0;
	}
	return tmp;
}
def code(x, y):
	return (x / (y * y)) - 3.0
def code(x, y):
	tmp = 0
	if (y * y) <= 5e-310:
		tmp = (x / y) * (1.0 / y)
	else:
		tmp = (x / (y * y)) + -3.0
	return tmp
function code(x, y)
	return Float64(Float64(x / Float64(y * y)) - 3.0)
end
function code(x, y)
	tmp = 0.0
	if (Float64(y * y) <= 5e-310)
		tmp = Float64(Float64(x / y) * Float64(1.0 / y));
	else
		tmp = Float64(Float64(x / Float64(y * y)) + -3.0);
	end
	return tmp
end
function tmp = code(x, y)
	tmp = (x / (y * y)) - 3.0;
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if ((y * y) <= 5e-310)
		tmp = (x / y) * (1.0 / y);
	else
		tmp = (x / (y * y)) + -3.0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := N[(N[(x / N[(y * y), $MachinePrecision]), $MachinePrecision] - 3.0), $MachinePrecision]
code[x_, y_] := If[LessEqual[N[(y * y), $MachinePrecision], 5e-310], N[(N[(x / y), $MachinePrecision] * N[(1.0 / y), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(y * y), $MachinePrecision]), $MachinePrecision] + -3.0), $MachinePrecision]]
\frac{x}{y \cdot y} - 3
\begin{array}{l}
\mathbf{if}\;y \cdot y \leq 5 \cdot 10^{-310}:\\
\;\;\;\;\frac{x}{y} \cdot \frac{1}{y}\\

\mathbf{else}:\\
\;\;\;\;\frac{x}{y \cdot y} + -3\\


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original5.2
Target0.1
Herbie0.1
\[\frac{\frac{x}{y}}{y} - 3 \]

Derivation

  1. Split input into 2 regimes
  2. if (*.f64 y y) < 4.999999999999985e-310

    1. Initial program 60.9

      \[\frac{x}{y \cdot y} - 3 \]
    2. Applied egg-rr0.4

      \[\leadsto \color{blue}{\frac{x}{y} \cdot \frac{1}{y}} - 3 \]
    3. Applied egg-rr0.4

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{x}{y}, \frac{1}{y}, -3\right)} \]
    4. Taylor expanded in x around inf 60.9

      \[\leadsto \color{blue}{\frac{x}{{y}^{2}}} \]
    5. Simplified60.9

      \[\leadsto \color{blue}{\frac{x}{y \cdot y}} \]
      Proof
      (/.f64 x (*.f64 y y)): 0 points increase in error, 0 points decrease in error
      (/.f64 x (Rewrite<= unpow2_binary64 (pow.f64 y 2))): 0 points increase in error, 0 points decrease in error
    6. Applied egg-rr0.4

      \[\leadsto \color{blue}{\frac{x}{y} \cdot \frac{1}{y}} \]

    if 4.999999999999985e-310 < (*.f64 y y)

    1. Initial program 0.1

      \[\frac{x}{y \cdot y} - 3 \]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot y \leq 5 \cdot 10^{-310}:\\ \;\;\;\;\frac{x}{y} \cdot \frac{1}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y \cdot y} + -3\\ \end{array} \]

Alternatives

Alternative 1
Error1.1
Cost1224
\[\begin{array}{l} t_0 := \frac{x}{y \cdot y}\\ t_1 := \frac{x}{y} \cdot \frac{1}{y}\\ \mathbf{if}\;t_0 \leq -1000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_0 \leq 2:\\ \;\;\;\;-3\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error6.2
Cost1096
\[\begin{array}{l} t_0 := \frac{x}{y \cdot y}\\ \mathbf{if}\;t_0 \leq -3:\\ \;\;\;\;t_0\\ \mathbf{elif}\;t_0 \leq 3:\\ \;\;\;\;-3\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error0.1
Cost448
\[\frac{\frac{x}{y}}{y} + -3 \]
Alternative 4
Error20.8
Cost64
\[-3 \]

Error

Reproduce

herbie shell --seed 2022325 
(FPCore (x y)
  :name "Statistics.Sample:$skurtosis from math-functions-0.1.5.2"
  :precision binary64

  :herbie-target
  (- (/ (/ x y) y) 3.0)

  (- (/ x (* y y)) 3.0))