?

Average Error: 4.9 → 0.2
Time: 6.0s
Precision: binary64
Cost: 1224

?

\[\frac{x}{y \cdot y} - 3 \]
\[\begin{array}{l} t_0 := \frac{x}{y \cdot y}\\ \mathbf{if}\;t_0 \leq -5 \cdot 10^{+178}:\\ \;\;\;\;\frac{x}{y} \cdot \frac{1}{y}\\ \mathbf{elif}\;t_0 \leq 5 \cdot 10^{+14}:\\ \;\;\;\;t_0 + -3\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{y}}{y}\\ \end{array} \]
(FPCore (x y) :precision binary64 (- (/ x (* y y)) 3.0))
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (/ x (* y y))))
   (if (<= t_0 -5e+178)
     (* (/ x y) (/ 1.0 y))
     (if (<= t_0 5e+14) (+ t_0 -3.0) (/ (/ x y) y)))))
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 <= -5e+178) {
		tmp = (x / y) * (1.0 / y);
	} else if (t_0 <= 5e+14) {
		tmp = t_0 + -3.0;
	} else {
		tmp = (x / y) / y;
	}
	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 <= (-5d+178)) then
        tmp = (x / y) * (1.0d0 / y)
    else if (t_0 <= 5d+14) then
        tmp = t_0 + (-3.0d0)
    else
        tmp = (x / y) / y
    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 <= -5e+178) {
		tmp = (x / y) * (1.0 / y);
	} else if (t_0 <= 5e+14) {
		tmp = t_0 + -3.0;
	} else {
		tmp = (x / y) / y;
	}
	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 <= -5e+178:
		tmp = (x / y) * (1.0 / y)
	elif t_0 <= 5e+14:
		tmp = t_0 + -3.0
	else:
		tmp = (x / y) / y
	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 <= -5e+178)
		tmp = Float64(Float64(x / y) * Float64(1.0 / y));
	elseif (t_0 <= 5e+14)
		tmp = Float64(t_0 + -3.0);
	else
		tmp = Float64(Float64(x / y) / y);
	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 <= -5e+178)
		tmp = (x / y) * (1.0 / y);
	elseif (t_0 <= 5e+14)
		tmp = t_0 + -3.0;
	else
		tmp = (x / y) / y;
	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[LessEqual[t$95$0, -5e+178], N[(N[(x / y), $MachinePrecision] * N[(1.0 / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 5e+14], N[(t$95$0 + -3.0), $MachinePrecision], N[(N[(x / y), $MachinePrecision] / y), $MachinePrecision]]]]
\frac{x}{y \cdot y} - 3
\begin{array}{l}
t_0 := \frac{x}{y \cdot y}\\
\mathbf{if}\;t_0 \leq -5 \cdot 10^{+178}:\\
\;\;\;\;\frac{x}{y} \cdot \frac{1}{y}\\

\mathbf{elif}\;t_0 \leq 5 \cdot 10^{+14}:\\
\;\;\;\;t_0 + -3\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y}}{y}\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation?

  1. Split input into 3 regimes
  2. if (/.f64 x (*.f64 y y)) < -4.9999999999999999e178

    1. Initial program 30.8

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

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

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

      [Start]30.8

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

      unpow2 [=>]30.8

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

      *-lft-identity [<=]30.8

      \[ \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* [<=]31.7

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

      sqr-pow [<=]31.6

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

      fma-neg [=>]31.6

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

      metadata-eval [=>]31.6

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

      \[\leadsto \color{blue}{\frac{x}{{y}^{2}}} \]
    5. Simplified30.8

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

      [Start]30.8

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

      unpow2 [=>]30.8

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

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

    if -4.9999999999999999e178 < (/.f64 x (*.f64 y y)) < 5e14

    1. Initial program 0.1

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

    if 5e14 < (/.f64 x (*.f64 y y))

    1. Initial program 15.8

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

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

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

      [Start]15.8

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

      unpow2 [=>]15.8

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

      *-lft-identity [<=]15.8

      \[ \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.5

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

      *-commutative [=>]0.5

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

      unpow-1 [<=]0.5

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

      metadata-eval [<=]0.5

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

      associate-*r* [<=]17.1

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

      sqr-pow [<=]16.9

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

      fma-neg [=>]16.9

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

      metadata-eval [=>]16.9

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

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

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

      [Start]15.8

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

      unpow2 [=>]15.8

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

      associate-/r* [=>]0.3

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

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

Alternatives

Alternative 1
Error5.8
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.3
Cost1097
\[\begin{array}{l} t_0 := \frac{x}{y \cdot y}\\ \mathbf{if}\;t_0 \leq -1 \cdot 10^{+16} \lor \neg \left(t_0 \leq 0.2\right):\\ \;\;\;\;\frac{\frac{x}{y}}{y}\\ \mathbf{else}:\\ \;\;\;\;-3\\ \end{array} \]
Alternative 3
Error0.1
Cost448
\[\frac{\frac{x}{y}}{y} + -3 \]
Alternative 4
Error20.9
Cost64
\[-3 \]

Error

Reproduce?

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