Numeric.SpecFunctions:incompleteBetaApprox from math-functions-0.1.5.2, A

?

Percentage Accurate: 68.7% → 99.7%
Time: 17.6s
Precision: binary64
Cost: 1216

?

\[ \begin{array}{c}[x, y] = \mathsf{sort}([x, y])\\ \end{array} \]
\[\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(\left(x + y\right) + 1\right)} \]
\[\left(\frac{x}{x + y} \cdot \frac{1}{x + y}\right) \cdot \frac{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 (+ x y)) (/ 1.0 (+ x y))) (/ 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 / (x + y)) * (1.0 / (x + y))) * (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 / (x + y)) * (1.0d0 / (x + y))) * (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 / (x + y)) * (1.0 / (x + y))) * (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 / (x + y)) * (1.0 / (x + y))) * (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(x + y)) * Float64(1.0 / Float64(x + y))) * Float64(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 / (x + y)) * (1.0 / (x + y))) * (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[(x + y), $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(y / N[(x + N[(y + 1.0), $MachinePrecision]), $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)}
\left(\frac{x}{x + y} \cdot \frac{1}{x + y}\right) \cdot \frac{y}{x + \left(y + 1\right)}

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.

Herbie found 19 alternatives:

AlternativeAccuracySpeedup

Accuracy vs Speed

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.

Bogosity?

Bogosity

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original68.7%
Target99.8%
Herbie99.7%
\[\frac{\frac{\frac{x}{\left(y + 1\right) + x}}{y + x}}{\frac{1}{\frac{y}{y + x}}} \]

Derivation?

  1. Initial program 70.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. Simplified90.8%

    \[\leadsto \color{blue}{\frac{x}{\left(x + y\right) \cdot \left(x + y\right)} \cdot \frac{y}{x + \left(y + 1\right)}} \]
    Step-by-step derivation

    [Start]70.3%

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

    times-frac [=>]90.8%

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

    /-rgt-identity [<=]90.8%

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

    associate-/l/ [=>]90.8%

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

    *-lft-identity [=>]90.8%

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

    associate-+l+ [=>]90.8%

    \[ \frac{x}{\left(x + y\right) \cdot \left(x + y\right)} \cdot \frac{y}{\color{blue}{x + \left(y + 1\right)}} \]
  3. Applied egg-rr99.8%

    \[\leadsto \color{blue}{\left(\frac{x}{y + x} \cdot \frac{1}{y + x}\right)} \cdot \frac{y}{x + \left(y + 1\right)} \]
    Step-by-step derivation

    [Start]90.8%

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

    associate-/r* [=>]99.8%

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

    div-inv [=>]99.8%

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

    +-commutative [=>]99.8%

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

    +-commutative [=>]99.8%

    \[ \left(\frac{x}{y + x} \cdot \frac{1}{\color{blue}{y + x}}\right) \cdot \frac{y}{x + \left(y + 1\right)} \]
  4. Final simplification99.8%

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

Alternatives

Alternative 1
Accuracy99.7%
Cost1216
\[\left(\frac{x}{x + y} \cdot \frac{1}{x + y}\right) \cdot \frac{y}{x + \left(y + 1\right)} \]
Alternative 2
Accuracy97.2%
Cost1352
\[\begin{array}{l} t_0 := \frac{x}{x + y}\\ \mathbf{if}\;x \leq -1.45 \cdot 10^{+166}:\\ \;\;\;\;\left(t_0 \cdot \frac{1}{x + y}\right) \cdot \frac{y}{x}\\ \mathbf{elif}\;x \leq -7 \cdot 10^{-129}:\\ \;\;\;\;\frac{y}{x + \left(y + 1\right)} \cdot \frac{x}{\left(x + y\right) \cdot \left(x + y\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{t_0}{\left(x + y\right) \cdot \frac{y + 1}{y}}\\ \end{array} \]
Alternative 3
Accuracy86.8%
Cost1224
\[\begin{array}{l} \mathbf{if}\;y \leq 3.2 \cdot 10^{-108}:\\ \;\;\;\;\frac{\frac{y}{1 + \left(x + y\right)}}{x}\\ \mathbf{elif}\;y \leq 2.5 \cdot 10^{+176}:\\ \;\;\;\;\frac{x}{\left(x + y\right) \cdot \left(x + y\right)} \cdot \frac{y}{y + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{x + y}}{x + y}\\ \end{array} \]
Alternative 4
Accuracy94.6%
Cost1092
\[\begin{array}{l} t_0 := \frac{x}{x + y}\\ \mathbf{if}\;x \leq -430000:\\ \;\;\;\;\left(t_0 \cdot \frac{1}{x + y}\right) \cdot \frac{y}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{t_0}{\left(x + y\right) \cdot \frac{y + 1}{y}}\\ \end{array} \]
Alternative 5
Accuracy99.8%
Cost1088
\[\frac{y}{x + \left(y + 1\right)} \cdot \frac{\frac{x}{x + y}}{x + y} \]
Alternative 6
Accuracy76.1%
Cost976
\[\begin{array}{l} t_0 := \frac{\frac{y}{x}}{x}\\ \mathbf{if}\;y \leq -1.6 \cdot 10^{-172}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1.75 \cdot 10^{-160}:\\ \;\;\;\;\frac{y}{x}\\ \mathbf{elif}\;y \leq 5.2 \cdot 10^{-107}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 8 \cdot 10^{+176}:\\ \;\;\;\;\frac{x}{y \cdot \left(y + 1\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{y}}{y}\\ \end{array} \]
Alternative 7
Accuracy85.7%
Cost972
\[\begin{array}{l} \mathbf{if}\;y \leq 7.2 \cdot 10^{-108}:\\ \;\;\;\;\frac{\frac{y}{1 + \left(x + y\right)}}{x}\\ \mathbf{elif}\;y \leq 7.2 \cdot 10^{-12}:\\ \;\;\;\;y \cdot \frac{x}{\left(x + y\right) \cdot \left(x + y\right)}\\ \mathbf{elif}\;y \leq 1.15 \cdot 10^{+176}:\\ \;\;\;\;\frac{x}{\left(y + 1\right) \cdot \left(x + y\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{y}}{y}\\ \end{array} \]
Alternative 8
Accuracy85.7%
Cost972
\[\begin{array}{l} \mathbf{if}\;y \leq 6.6 \cdot 10^{-108}:\\ \;\;\;\;\frac{\frac{y}{1 + \left(x + y\right)}}{x}\\ \mathbf{elif}\;y \leq 1.85 \cdot 10^{-11}:\\ \;\;\;\;y \cdot \frac{x}{\left(x + y\right) \cdot \left(x + y\right)}\\ \mathbf{elif}\;y \leq 5 \cdot 10^{+178}:\\ \;\;\;\;\frac{x}{\left(y + 1\right) \cdot \left(x + y\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{x + y}}{x + y}\\ \end{array} \]
Alternative 9
Accuracy72.5%
Cost848
\[\begin{array}{l} t_0 := \frac{y}{x \cdot x}\\ \mathbf{if}\;y \leq -2.2 \cdot 10^{-173}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 2.55 \cdot 10^{-167}:\\ \;\;\;\;\frac{y}{x}\\ \mathbf{elif}\;y \leq 5.2 \cdot 10^{-107}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 0.76:\\ \;\;\;\;\frac{x}{y} - x\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y \cdot y}\\ \end{array} \]
Alternative 10
Accuracy74.6%
Cost848
\[\begin{array}{l} t_0 := \frac{y}{x \cdot x}\\ \mathbf{if}\;y \leq -1.12 \cdot 10^{-179}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 2.8 \cdot 10^{-164}:\\ \;\;\;\;\frac{y}{x}\\ \mathbf{elif}\;y \leq 4.8 \cdot 10^{-107}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 0.76:\\ \;\;\;\;\frac{x}{y} - x\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{y}}{y}\\ \end{array} \]
Alternative 11
Accuracy76.0%
Cost848
\[\begin{array}{l} t_0 := \frac{\frac{y}{x}}{x}\\ \mathbf{if}\;y \leq -3.5 \cdot 10^{-178}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 3.9 \cdot 10^{-164}:\\ \;\;\;\;\frac{y}{x}\\ \mathbf{elif}\;y \leq 2.55 \cdot 10^{-107}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 0.76:\\ \;\;\;\;\frac{x}{y} - x\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{y}}{y}\\ \end{array} \]
Alternative 12
Accuracy81.5%
Cost844
\[\begin{array}{l} \mathbf{if}\;y \leq -5.4 \cdot 10^{-39}:\\ \;\;\;\;\frac{\frac{y}{x}}{x}\\ \mathbf{elif}\;y \leq 5.2 \cdot 10^{-107}:\\ \;\;\;\;\frac{y}{x \cdot \left(x + 1\right)}\\ \mathbf{elif}\;y \leq 3.6 \cdot 10^{+180}:\\ \;\;\;\;\frac{x}{y \cdot \left(y + 1\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{y}}{y}\\ \end{array} \]
Alternative 13
Accuracy83.0%
Cost840
\[\begin{array}{l} \mathbf{if}\;y \leq 5.2 \cdot 10^{-107}:\\ \;\;\;\;\frac{\frac{y}{x + 1}}{x}\\ \mathbf{elif}\;y \leq 1.6 \cdot 10^{+179}:\\ \;\;\;\;\frac{x}{\left(y + 1\right) \cdot \left(x + y\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{y}}{y}\\ \end{array} \]
Alternative 14
Accuracy83.0%
Cost840
\[\begin{array}{l} \mathbf{if}\;y \leq 5.2 \cdot 10^{-107}:\\ \;\;\;\;\frac{\frac{y}{1 + \left(x + y\right)}}{x}\\ \mathbf{elif}\;y \leq 1.2 \cdot 10^{+179}:\\ \;\;\;\;\frac{x}{\left(y + 1\right) \cdot \left(x + y\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{y}}{y}\\ \end{array} \]
Alternative 15
Accuracy81.6%
Cost712
\[\begin{array}{l} \mathbf{if}\;y \leq 5.2 \cdot 10^{-107}:\\ \;\;\;\;\frac{\frac{y}{x + 1}}{x}\\ \mathbf{elif}\;y \leq 1.6 \cdot 10^{+180}:\\ \;\;\;\;\frac{x}{y \cdot \left(y + 1\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{y}}{y}\\ \end{array} \]
Alternative 16
Accuracy64.5%
Cost584
\[\begin{array}{l} \mathbf{if}\;y \leq 2.42 \cdot 10^{-107}:\\ \;\;\;\;\frac{y}{x}\\ \mathbf{elif}\;y \leq 0.76:\\ \;\;\;\;\frac{x}{y} - x\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y \cdot y}\\ \end{array} \]
Alternative 17
Accuracy28.3%
Cost324
\[\begin{array}{l} \mathbf{if}\;x \leq -1750000:\\ \;\;\;\;\frac{1}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \]
Alternative 18
Accuracy44.1%
Cost324
\[\begin{array}{l} \mathbf{if}\;y \leq 3.6 \cdot 10^{-107}:\\ \;\;\;\;\frac{y}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \]
Alternative 19
Accuracy4.3%
Cost192
\[\frac{1}{x} \]

Reproduce?

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