?

Average Error: 5.2 → 0.3
Time: 6.3s
Precision: binary64
Cost: 1225

?

\[\frac{x}{y \cdot y} - 3 \]
\[\begin{array}{l} t_0 := \frac{x}{y \cdot y}\\ \mathbf{if}\;t_0 \leq -1 \cdot 10^{+115} \lor \neg \left(t_0 \leq 4\right):\\ \;\;\;\;\frac{\frac{x}{y}}{y}\\ \mathbf{else}:\\ \;\;\;\;t_0 + -3\\ \end{array} \]
(FPCore (x y) :precision binary64 (- (/ x (* y y)) 3.0))
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (/ x (* y y))))
   (if (or (<= t_0 -1e+115) (not (<= t_0 4.0))) (/ (/ x y) y) (+ t_0 -3.0))))
double code(double x, double y) {
	return (x / (y * y)) - 3.0;
}
double code(double x, double y) {
	double t_0 = x / (y * y);
	double tmp;
	if ((t_0 <= -1e+115) || !(t_0 <= 4.0)) {
		tmp = (x / y) / y;
	} else {
		tmp = t_0 + -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) :: t_0
    real(8) :: tmp
    t_0 = x / (y * y)
    if ((t_0 <= (-1d+115)) .or. (.not. (t_0 <= 4.0d0))) then
        tmp = (x / y) / y
    else
        tmp = t_0 + (-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 t_0 = x / (y * y);
	double tmp;
	if ((t_0 <= -1e+115) || !(t_0 <= 4.0)) {
		tmp = (x / y) / y;
	} else {
		tmp = t_0 + -3.0;
	}
	return tmp;
}
def code(x, y):
	return (x / (y * y)) - 3.0
def code(x, y):
	t_0 = x / (y * y)
	tmp = 0
	if (t_0 <= -1e+115) or not (t_0 <= 4.0):
		tmp = (x / y) / y
	else:
		tmp = t_0 + -3.0
	return tmp
function code(x, y)
	return Float64(Float64(x / Float64(y * y)) - 3.0)
end
function code(x, y)
	t_0 = Float64(x / Float64(y * y))
	tmp = 0.0
	if ((t_0 <= -1e+115) || !(t_0 <= 4.0))
		tmp = Float64(Float64(x / y) / y);
	else
		tmp = Float64(t_0 + -3.0);
	end
	return tmp
end
function tmp = code(x, y)
	tmp = (x / (y * y)) - 3.0;
end
function tmp_2 = code(x, y)
	t_0 = x / (y * y);
	tmp = 0.0;
	if ((t_0 <= -1e+115) || ~((t_0 <= 4.0)))
		tmp = (x / y) / y;
	else
		tmp = t_0 + -3.0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := N[(N[(x / N[(y * y), $MachinePrecision]), $MachinePrecision] - 3.0), $MachinePrecision]
code[x_, y_] := Block[{t$95$0 = N[(x / N[(y * y), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -1e+115], N[Not[LessEqual[t$95$0, 4.0]], $MachinePrecision]], N[(N[(x / y), $MachinePrecision] / y), $MachinePrecision], N[(t$95$0 + -3.0), $MachinePrecision]]]
\frac{x}{y \cdot y} - 3
\begin{array}{l}
t_0 := \frac{x}{y \cdot y}\\
\mathbf{if}\;t_0 \leq -1 \cdot 10^{+115} \lor \neg \left(t_0 \leq 4\right):\\
\;\;\;\;\frac{\frac{x}{y}}{y}\\

\mathbf{else}:\\
\;\;\;\;t_0 + -3\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation?

  1. Split input into 2 regimes
  2. if (/.f64 x (*.f64 y y)) < -1e115 or 4 < (/.f64 x (*.f64 y y))

    1. Initial program 18.4

      \[\frac{x}{y \cdot y} - 3 \]
    2. Taylor expanded in x around 0 18.4

      \[\leadsto \color{blue}{\frac{x}{{y}^{2}} - 3} \]
    3. Simplified19.5

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, {y}^{-2}, -3\right)} \]
      Proof

      [Start]18.4

      \[ \frac{x}{{y}^{2}} - 3 \]

      unpow2 [=>]18.4

      \[ \frac{x}{\color{blue}{y \cdot y}} - 3 \]

      *-lft-identity [<=]18.4

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

      times-frac [=>]0.4

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

      unpow-1 [<=]0.4

      \[ \color{blue}{{y}^{-1}} \cdot \frac{x}{y} - 3 \]

      metadata-eval [<=]0.4

      \[ {y}^{\color{blue}{\left(\frac{-2}{2}\right)}} \cdot \frac{x}{y} - 3 \]

      *-commutative [<=]0.4

      \[ \color{blue}{\frac{x}{y} \cdot {y}^{\left(\frac{-2}{2}\right)}} - 3 \]

      *-lft-identity [<=]0.4

      \[ \frac{\color{blue}{1 \cdot x}}{y} \cdot {y}^{\left(\frac{-2}{2}\right)} - 3 \]

      associate-*l/ [<=]0.6

      \[ \color{blue}{\left(\frac{1}{y} \cdot x\right)} \cdot {y}^{\left(\frac{-2}{2}\right)} - 3 \]

      *-commutative [=>]0.6

      \[ \color{blue}{\left(x \cdot \frac{1}{y}\right)} \cdot {y}^{\left(\frac{-2}{2}\right)} - 3 \]

      unpow-1 [<=]0.6

      \[ \left(x \cdot \color{blue}{{y}^{-1}}\right) \cdot {y}^{\left(\frac{-2}{2}\right)} - 3 \]

      metadata-eval [<=]0.6

      \[ \left(x \cdot {y}^{\color{blue}{\left(\frac{-2}{2}\right)}}\right) \cdot {y}^{\left(\frac{-2}{2}\right)} - 3 \]

      associate-*r* [<=]19.7

      \[ \color{blue}{x \cdot \left({y}^{\left(\frac{-2}{2}\right)} \cdot {y}^{\left(\frac{-2}{2}\right)}\right)} - 3 \]

      sqr-pow [<=]19.5

      \[ x \cdot \color{blue}{{y}^{-2}} - 3 \]

      fma-neg [=>]19.5

      \[ \color{blue}{\mathsf{fma}\left(x, {y}^{-2}, -3\right)} \]

      metadata-eval [=>]19.5

      \[ \mathsf{fma}\left(x, {y}^{-2}, \color{blue}{-3}\right) \]
    4. Taylor expanded in x around inf 19.1

      \[\leadsto \color{blue}{\frac{x}{{y}^{2}}} \]
    5. Simplified1.0

      \[\leadsto \color{blue}{\frac{\frac{x}{y}}{y}} \]
      Proof

      [Start]19.1

      \[ \frac{x}{{y}^{2}} \]

      unpow2 [=>]19.1

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

      associate-/r* [=>]1.0

      \[ \color{blue}{\frac{\frac{x}{y}}{y}} \]

    if -1e115 < (/.f64 x (*.f64 y y)) < 4

    1. Initial program 0.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x}{y \cdot y} \leq -1 \cdot 10^{+115} \lor \neg \left(\frac{x}{y \cdot y} \leq 4\right):\\ \;\;\;\;\frac{\frac{x}{y}}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y \cdot y} + -3\\ \end{array} \]

Alternatives

Alternative 1
Error6.0
Cost1097
\[\begin{array}{l} t_0 := \frac{x}{y \cdot y}\\ \mathbf{if}\;t_0 \leq -3 \lor \neg \left(t_0 \leq 3\right):\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;-3\\ \end{array} \]
Alternative 2
Error1.0
Cost1097
\[\begin{array}{l} t_0 := \frac{x}{y \cdot y}\\ \mathbf{if}\;t_0 \leq -50000000 \lor \neg \left(t_0 \leq 4\right):\\ \;\;\;\;\frac{\frac{x}{y}}{y}\\ \mathbf{else}:\\ \;\;\;\;-3\\ \end{array} \]
Alternative 3
Error0.1
Cost448
\[\frac{\frac{x}{y}}{y} + -3 \]
Alternative 4
Error21.2
Cost64
\[-3 \]

Error

Reproduce?

herbie shell --seed 2023060 
(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))