Average Error: 20.3 → 0.1
Time: 15.4s
Precision: binary64
Cost: 1088
\[\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(\left(x + y\right) + 1\right)} \]
\[\frac{\frac{x \cdot \frac{y}{x + y}}{x + y}}{x + \left(y + 1\right)} \]
(FPCore (x y)
 :precision binary64
 (/ (* x y) (* (* (+ x y) (+ x y)) (+ (+ x y) 1.0))))
(FPCore (x y)
 :precision binary64
 (/ (/ (* x (/ y (+ x y))) (+ x y)) (+ x (+ y 1.0))))
double code(double x, double y) {
	return (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0));
}
double code(double x, double y) {
	return ((x * (y / (x + y))) / (x + y)) / (x + (y + 1.0));
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0d0))
end function
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = ((x * (y / (x + y))) / (x + y)) / (x + (y + 1.0d0))
end function
public static double code(double x, double y) {
	return (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0));
}
public static double code(double x, double y) {
	return ((x * (y / (x + y))) / (x + y)) / (x + (y + 1.0));
}
def code(x, y):
	return (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0))
def code(x, y):
	return ((x * (y / (x + y))) / (x + y)) / (x + (y + 1.0))
function code(x, y)
	return Float64(Float64(x * y) / Float64(Float64(Float64(x + y) * Float64(x + y)) * Float64(Float64(x + y) + 1.0)))
end
function code(x, y)
	return Float64(Float64(Float64(x * Float64(y / Float64(x + y))) / Float64(x + y)) / Float64(x + Float64(y + 1.0)))
end
function tmp = code(x, y)
	tmp = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0));
end
function tmp = code(x, y)
	tmp = ((x * (y / (x + y))) / (x + y)) / (x + (y + 1.0));
end
code[x_, y_] := N[(N[(x * y), $MachinePrecision] / N[(N[(N[(x + y), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision] * N[(N[(x + y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_] := N[(N[(N[(x * N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision] / N[(x + N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(\left(x + y\right) + 1\right)}
\frac{\frac{x \cdot \frac{y}{x + y}}{x + y}}{x + \left(y + 1\right)}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original20.3
Target0.1
Herbie0.1
\[\frac{\frac{\frac{x}{\left(y + 1\right) + x}}{y + x}}{\frac{1}{\frac{y}{y + x}}} \]

Derivation

  1. Initial program 20.3

    \[\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(\left(x + y\right) + 1\right)} \]
  2. Simplified17.6

    \[\leadsto \color{blue}{\frac{\frac{x \cdot y}{\left(x + y\right) \cdot \left(x + y\right)}}{x + \left(y + 1\right)}} \]
    Proof
    (/.f64 (/.f64 (*.f64 x y) (*.f64 (+.f64 x y) (+.f64 x y))) (+.f64 x (+.f64 y 1))): 0 points increase in error, 0 points decrease in error
    (/.f64 (/.f64 (*.f64 x y) (*.f64 (+.f64 x y) (+.f64 x y))) (Rewrite<= associate-+l+_binary64 (+.f64 (+.f64 x y) 1))): 0 points increase in error, 3 points decrease in error
    (Rewrite<= associate-/r*_binary64 (/.f64 (*.f64 x y) (*.f64 (*.f64 (+.f64 x y) (+.f64 x y)) (+.f64 (+.f64 x y) 1)))): 3 points increase in error, 0 points decrease in error
  3. Applied egg-rr0.1

    \[\leadsto \frac{\color{blue}{\frac{x}{x + y} \cdot \frac{y}{x + y}}}{x + \left(y + 1\right)} \]
  4. Simplified0.1

    \[\leadsto \frac{\color{blue}{\frac{x \cdot \frac{y}{x + y}}{x + y}}}{x + \left(y + 1\right)} \]
    Proof
    (/.f64 (/.f64 (*.f64 x (/.f64 y (+.f64 x y))) (+.f64 x y)) (+.f64 x (+.f64 y 1))): 0 points increase in error, 0 points decrease in error
    (/.f64 (Rewrite<= associate-*l/_binary64 (*.f64 (/.f64 x (+.f64 x y)) (/.f64 y (+.f64 x y)))) (+.f64 x (+.f64 y 1))): 0 points increase in error, 0 points decrease in error
  5. Final simplification0.1

    \[\leadsto \frac{\frac{x \cdot \frac{y}{x + y}}{x + y}}{x + \left(y + 1\right)} \]

Alternatives

Alternative 1
Error24.9
Cost1229
\[\begin{array}{l} \mathbf{if}\;y \leq 5.5 \cdot 10^{-130}:\\ \;\;\;\;\frac{\frac{y}{x}}{x + \left(y + 1\right)}\\ \mathbf{elif}\;y \leq 5.8 \cdot 10^{-86} \lor \neg \left(y \leq 5.8 \cdot 10^{-55}\right):\\ \;\;\;\;\frac{\frac{x}{x + y}}{\left(y + 1\right) + x \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{\frac{1}{x}}{x + 1}\\ \end{array} \]
Alternative 2
Error30.0
Cost1108
\[\begin{array}{l} t_0 := \frac{\frac{y}{x}}{x}\\ \mathbf{if}\;y \leq -1.4 \cdot 10^{-126}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 2 \cdot 10^{-182}:\\ \;\;\;\;\frac{y}{x}\\ \mathbf{elif}\;y \leq 4.1 \cdot 10^{-85}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;y \leq 3.2 \cdot 10^{-55}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1.12 \cdot 10^{+166}:\\ \;\;\;\;\frac{x}{y \cdot \left(y + 1\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y} \cdot \frac{1}{y}\\ \end{array} \]
Alternative 3
Error25.0
Cost1101
\[\begin{array}{l} t_0 := x + \left(y + 1\right)\\ \mathbf{if}\;y \leq 3.1 \cdot 10^{-128}:\\ \;\;\;\;\frac{\frac{y}{x}}{t_0}\\ \mathbf{elif}\;y \leq 9.6 \cdot 10^{-86} \lor \neg \left(y \leq 7 \cdot 10^{-55}\right):\\ \;\;\;\;\frac{\frac{x}{x + y}}{t_0}\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{\frac{1}{x}}{x + 1}\\ \end{array} \]
Alternative 4
Error12.4
Cost1092
\[\begin{array}{l} t_0 := \frac{x}{x + y}\\ \mathbf{if}\;y \leq 10^{-14}:\\ \;\;\;\;\frac{\frac{y}{x + y} \cdot t_0}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{t_0}{\left(y + 1\right) + x \cdot 2}\\ \end{array} \]
Alternative 5
Error12.4
Cost1092
\[\begin{array}{l} \mathbf{if}\;y \leq 10^{-14}:\\ \;\;\;\;\frac{\frac{x \cdot \frac{y}{x + y}}{x + y}}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{x + y}}{\left(y + 1\right) + x \cdot 2}\\ \end{array} \]
Alternative 6
Error0.1
Cost1088
\[\frac{x}{x + y} \cdot \frac{\frac{y}{x + y}}{y + \left(x + 1\right)} \]
Alternative 7
Error0.1
Cost1088
\[\frac{\frac{y}{x + y} \cdot \frac{x}{x + y}}{x + \left(y + 1\right)} \]
Alternative 8
Error31.1
Cost980
\[\begin{array}{l} t_0 := \frac{y}{x \cdot x}\\ \mathbf{if}\;y \leq -8.5 \cdot 10^{-127}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 2 \cdot 10^{-182}:\\ \;\;\;\;\frac{y}{x}\\ \mathbf{elif}\;y \leq 1.16 \cdot 10^{-84}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;y \leq 2.2 \cdot 10^{-55}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y \cdot y}\\ \end{array} \]
Alternative 9
Error30.7
Cost980
\[\begin{array}{l} t_0 := \frac{y}{x \cdot x}\\ \mathbf{if}\;y \leq -9 \cdot 10^{-127}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 2 \cdot 10^{-182}:\\ \;\;\;\;\frac{y}{x}\\ \mathbf{elif}\;y \leq 2.9 \cdot 10^{-83}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;y \leq 1.8 \cdot 10^{-57}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{y}}{y}\\ \end{array} \]
Alternative 10
Error30.3
Cost980
\[\begin{array}{l} t_0 := \frac{\frac{y}{x}}{x}\\ \mathbf{if}\;y \leq -8.5 \cdot 10^{-127}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 2 \cdot 10^{-182}:\\ \;\;\;\;\frac{y}{x}\\ \mathbf{elif}\;y \leq 3.1 \cdot 10^{-85}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;y \leq 1.85 \cdot 10^{-61}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{y}}{y}\\ \end{array} \]
Alternative 11
Error30.0
Cost976
\[\begin{array}{l} t_0 := \frac{\frac{y}{x}}{x}\\ \mathbf{if}\;y \leq -9 \cdot 10^{-127}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 2 \cdot 10^{-182}:\\ \;\;\;\;\frac{y}{x}\\ \mathbf{elif}\;y \leq 4.5 \cdot 10^{-85}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;y \leq 1.4 \cdot 10^{-59}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{y}}{y + 1}\\ \end{array} \]
Alternative 12
Error25.3
Cost973
\[\begin{array}{l} \mathbf{if}\;y \leq 3.2 \cdot 10^{-128}:\\ \;\;\;\;\frac{\frac{y}{x}}{x + 1}\\ \mathbf{elif}\;y \leq 1.55 \cdot 10^{-85} \lor \neg \left(y \leq 6.8 \cdot 10^{-55}\right):\\ \;\;\;\;\frac{\frac{x}{x + y}}{y + 1}\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{\frac{1}{x}}{x + 1}\\ \end{array} \]
Alternative 13
Error25.2
Cost973
\[\begin{array}{l} \mathbf{if}\;y \leq 3.2 \cdot 10^{-128}:\\ \;\;\;\;\frac{\frac{y}{x}}{x + \left(y + 1\right)}\\ \mathbf{elif}\;y \leq 2.7 \cdot 10^{-86} \lor \neg \left(y \leq 6 \cdot 10^{-57}\right):\\ \;\;\;\;\frac{\frac{x}{x + y}}{y + 1}\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{\frac{1}{x}}{x + 1}\\ \end{array} \]
Alternative 14
Error25.4
Cost972
\[\begin{array}{l} \mathbf{if}\;y \leq 1.15 \cdot 10^{-128}:\\ \;\;\;\;\frac{\frac{y}{x}}{x + 1}\\ \mathbf{elif}\;y \leq 2.35 \cdot 10^{-86}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;y \leq 7.5 \cdot 10^{-55}:\\ \;\;\;\;y \cdot \frac{\frac{1}{x}}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{y}}{y + 1}\\ \end{array} \]
Alternative 15
Error25.4
Cost972
\[\begin{array}{l} \mathbf{if}\;y \leq 2.8 \cdot 10^{-128}:\\ \;\;\;\;\frac{\frac{y}{x}}{x + 1}\\ \mathbf{elif}\;y \leq 1.15 \cdot 10^{-84}:\\ \;\;\;\;\frac{x}{y + y \cdot \left(x + y\right)}\\ \mathbf{elif}\;y \leq 4.8 \cdot 10^{-57}:\\ \;\;\;\;y \cdot \frac{\frac{1}{x}}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{y}}{y + 1}\\ \end{array} \]
Alternative 16
Error25.3
Cost972
\[\begin{array}{l} \mathbf{if}\;y \leq 3.2 \cdot 10^{-128}:\\ \;\;\;\;\frac{\frac{y}{x}}{x + 1}\\ \mathbf{elif}\;y \leq 1.02 \cdot 10^{-84}:\\ \;\;\;\;\frac{x}{y + y \cdot \left(x + y\right)}\\ \mathbf{elif}\;y \leq 5.5 \cdot 10^{-55}:\\ \;\;\;\;y \cdot \frac{\frac{1}{x}}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{y}}{x + \left(y + 1\right)}\\ \end{array} \]
Alternative 17
Error25.4
Cost844
\[\begin{array}{l} t_0 := \frac{\frac{y}{x}}{x + 1}\\ \mathbf{if}\;y \leq 3.2 \cdot 10^{-128}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 2.35 \cdot 10^{-86}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;y \leq 6.2 \cdot 10^{-56}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{y}}{y + 1}\\ \end{array} \]
Alternative 18
Error36.4
Cost584
\[\begin{array}{l} \mathbf{if}\;y \leq 2 \cdot 10^{-182}:\\ \;\;\;\;\frac{y}{x}\\ \mathbf{elif}\;y \leq 1:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y \cdot y}\\ \end{array} \]
Alternative 19
Error43.3
Cost324
\[\begin{array}{l} \mathbf{if}\;y \leq 1.9 \cdot 10^{-182}:\\ \;\;\;\;\frac{y}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \]
Alternative 20
Error61.3
Cost192
\[\frac{1}{x} \]
Alternative 21
Error61.3
Cost192
\[\frac{1}{y} \]
Alternative 22
Error47.3
Cost192
\[\frac{x}{y} \]

Error

Reproduce

herbie shell --seed 2022343 
(FPCore (x y)
  :name "Numeric.SpecFunctions:incompleteBetaApprox from math-functions-0.1.5.2, A"
  :precision binary64

  :herbie-target
  (/ (/ (/ x (+ (+ y 1.0) x)) (+ y x)) (/ 1.0 (/ y (+ y x))))

  (/ (* x y) (* (* (+ x y) (+ x y)) (+ (+ x y) 1.0))))