(FPCore (x y) :precision binary64 (/ 1.0 (- (sqrt (* (+ x 1.0) (+ y 1.0))) (sqrt (* x y)))))
double code(double x, double y) { return 1.0 / (sqrt(((x + 1.0) * (y + 1.0))) - sqrt((x * y))); }
real(8) function code(x, y) real(8), intent (in) :: x real(8), intent (in) :: y code = 1.0d0 / (sqrt(((x + 1.0d0) * (y + 1.0d0))) - sqrt((x * y))) end function
public static double code(double x, double y) { return 1.0 / (Math.sqrt(((x + 1.0) * (y + 1.0))) - Math.sqrt((x * y))); }
def code(x, y): return 1.0 / (math.sqrt(((x + 1.0) * (y + 1.0))) - math.sqrt((x * y)))
function code(x, y) return Float64(1.0 / Float64(sqrt(Float64(Float64(x + 1.0) * Float64(y + 1.0))) - sqrt(Float64(x * y)))) end
function tmp = code(x, y) tmp = 1.0 / (sqrt(((x + 1.0) * (y + 1.0))) - sqrt((x * y))); end
code[x_, y_] := N[(1.0 / N[(N[Sqrt[N[(N[(x + 1.0), $MachinePrecision] * N[(y + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - N[Sqrt[N[(x * y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l} \\ \frac{1}{\sqrt{\left(x + 1\right) \cdot \left(y + 1\right)} - \sqrt{x \cdot y}} \end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
Alternative | Accuracy | Speedup |
---|
(FPCore (x y) :precision binary64 (/ 1.0 (- (sqrt (* (+ x 1.0) (+ y 1.0))) (sqrt (* x y)))))
double code(double x, double y) { return 1.0 / (sqrt(((x + 1.0) * (y + 1.0))) - sqrt((x * y))); }
real(8) function code(x, y) real(8), intent (in) :: x real(8), intent (in) :: y code = 1.0d0 / (sqrt(((x + 1.0d0) * (y + 1.0d0))) - sqrt((x * y))) end function
public static double code(double x, double y) { return 1.0 / (Math.sqrt(((x + 1.0) * (y + 1.0))) - Math.sqrt((x * y))); }
def code(x, y): return 1.0 / (math.sqrt(((x + 1.0) * (y + 1.0))) - math.sqrt((x * y)))
function code(x, y) return Float64(1.0 / Float64(sqrt(Float64(Float64(x + 1.0) * Float64(y + 1.0))) - sqrt(Float64(x * y)))) end
function tmp = code(x, y) tmp = 1.0 / (sqrt(((x + 1.0) * (y + 1.0))) - sqrt((x * y))); end
code[x_, y_] := N[(1.0 / N[(N[Sqrt[N[(N[(x + 1.0), $MachinePrecision] * N[(y + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - N[Sqrt[N[(x * y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l} \\ \frac{1}{\sqrt{\left(x + 1\right) \cdot \left(y + 1\right)} - \sqrt{x \cdot y}} \end{array}
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= x 950.0) (pow (- (sqrt (* (+ x 1.0) (+ y 1.0))) (* (sqrt y) (sqrt x))) -1.0) (pow (* (+ (fma (sqrt (/ (+ 1.0 x) (pow y 7.0))) 0.0625 (fma (sqrt (/ (+ 1.0 x) (pow y 5.0))) -0.125 (* (sqrt (/ (+ 1.0 x) (pow y 3.0))) 0.5))) (/ (fma -0.125 (sqrt (/ (pow x -1.0) y)) (fma -0.0390625 (sqrt (pow (* (pow x 5.0) y) -1.0)) (fma 0.5 (sqrt (/ x y)) (* 0.0625 (sqrt (pow (* (pow x 3.0) y) -1.0)))))) x)) y) -1.0)))
assert(x < y); double code(double x, double y) { double tmp; if (x <= 950.0) { tmp = pow((sqrt(((x + 1.0) * (y + 1.0))) - (sqrt(y) * sqrt(x))), -1.0); } else { tmp = pow(((fma(sqrt(((1.0 + x) / pow(y, 7.0))), 0.0625, fma(sqrt(((1.0 + x) / pow(y, 5.0))), -0.125, (sqrt(((1.0 + x) / pow(y, 3.0))) * 0.5))) + (fma(-0.125, sqrt((pow(x, -1.0) / y)), fma(-0.0390625, sqrt(pow((pow(x, 5.0) * y), -1.0)), fma(0.5, sqrt((x / y)), (0.0625 * sqrt(pow((pow(x, 3.0) * y), -1.0)))))) / x)) * y), -1.0); } return tmp; }
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= 950.0) tmp = Float64(sqrt(Float64(Float64(x + 1.0) * Float64(y + 1.0))) - Float64(sqrt(y) * sqrt(x))) ^ -1.0; else tmp = Float64(Float64(fma(sqrt(Float64(Float64(1.0 + x) / (y ^ 7.0))), 0.0625, fma(sqrt(Float64(Float64(1.0 + x) / (y ^ 5.0))), -0.125, Float64(sqrt(Float64(Float64(1.0 + x) / (y ^ 3.0))) * 0.5))) + Float64(fma(-0.125, sqrt(Float64((x ^ -1.0) / y)), fma(-0.0390625, sqrt((Float64((x ^ 5.0) * y) ^ -1.0)), fma(0.5, sqrt(Float64(x / y)), Float64(0.0625 * sqrt((Float64((x ^ 3.0) * y) ^ -1.0)))))) / x)) * y) ^ -1.0; end return tmp end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[x, 950.0], N[Power[N[(N[Sqrt[N[(N[(x + 1.0), $MachinePrecision] * N[(y + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - N[(N[Sqrt[y], $MachinePrecision] * N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision], N[Power[N[(N[(N[(N[Sqrt[N[(N[(1.0 + x), $MachinePrecision] / N[Power[y, 7.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 0.0625 + N[(N[Sqrt[N[(N[(1.0 + x), $MachinePrecision] / N[Power[y, 5.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * -0.125 + N[(N[Sqrt[N[(N[(1.0 + x), $MachinePrecision] / N[Power[y, 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(-0.125 * N[Sqrt[N[(N[Power[x, -1.0], $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision] + N[(-0.0390625 * N[Sqrt[N[Power[N[(N[Power[x, 5.0], $MachinePrecision] * y), $MachinePrecision], -1.0], $MachinePrecision]], $MachinePrecision] + N[(0.5 * N[Sqrt[N[(x / y), $MachinePrecision]], $MachinePrecision] + N[(0.0625 * N[Sqrt[N[Power[N[(N[Power[x, 3.0], $MachinePrecision] * y), $MachinePrecision], -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision], -1.0], $MachinePrecision]]
\begin{array}{l} [x, y] = \mathsf{sort}([x, y])\\ \\ \begin{array}{l} \mathbf{if}\;x \leq 950:\\ \;\;\;\;{\left(\sqrt{\left(x + 1\right) \cdot \left(y + 1\right)} - \sqrt{y} \cdot \sqrt{x}\right)}^{-1}\\ \mathbf{else}:\\ \;\;\;\;{\left(\left(\mathsf{fma}\left(\sqrt{\frac{1 + x}{{y}^{7}}}, 0.0625, \mathsf{fma}\left(\sqrt{\frac{1 + x}{{y}^{5}}}, -0.125, \sqrt{\frac{1 + x}{{y}^{3}}} \cdot 0.5\right)\right) + \frac{\mathsf{fma}\left(-0.125, \sqrt{\frac{{x}^{-1}}{y}}, \mathsf{fma}\left(-0.0390625, \sqrt{{\left({x}^{5} \cdot y\right)}^{-1}}, \mathsf{fma}\left(0.5, \sqrt{\frac{x}{y}}, 0.0625 \cdot \sqrt{{\left({x}^{3} \cdot y\right)}^{-1}}\right)\right)\right)}{x}\right) \cdot y\right)}^{-1}\\ \end{array} \end{array}
if x < 950
Initial program 85.3%
lift-sqrt.f64
N/A
lift-*.f64
N/A
*-commutative
N/A
sqrt-prod
N/A
lower-*.f64
N/A
lower-sqrt.f64
N/A
lower-sqrt.f64
85.2
Applied rewrites85.2%
if 950 < x
Initial program 85.3%
Taylor expanded in y around inf
Applied rewrites36.5%
Taylor expanded in x around inf
Applied rewrites48.2%
Final simplification48.2%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= x 3100.0) (pow (- (sqrt (/ (* (fma x x -1.0) (+ y 1.0)) (- x 1.0))) (sqrt (* x y))) -1.0) (pow (* (+ (fma (sqrt (/ (+ 1.0 x) (pow y 7.0))) 0.0625 (fma (sqrt (/ (+ 1.0 x) (pow y 5.0))) -0.125 (* (sqrt (/ (+ 1.0 x) (pow y 3.0))) 0.5))) (/ (fma -0.125 (sqrt (/ (pow x -1.0) y)) (fma 0.5 (sqrt (/ x y)) (* 0.0625 (sqrt (pow (* (pow x 3.0) y) -1.0))))) x)) y) -1.0)))
assert(x < y); double code(double x, double y) { double tmp; if (x <= 3100.0) { tmp = pow((sqrt(((fma(x, x, -1.0) * (y + 1.0)) / (x - 1.0))) - sqrt((x * y))), -1.0); } else { tmp = pow(((fma(sqrt(((1.0 + x) / pow(y, 7.0))), 0.0625, fma(sqrt(((1.0 + x) / pow(y, 5.0))), -0.125, (sqrt(((1.0 + x) / pow(y, 3.0))) * 0.5))) + (fma(-0.125, sqrt((pow(x, -1.0) / y)), fma(0.5, sqrt((x / y)), (0.0625 * sqrt(pow((pow(x, 3.0) * y), -1.0))))) / x)) * y), -1.0); } return tmp; }
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= 3100.0) tmp = Float64(sqrt(Float64(Float64(fma(x, x, -1.0) * Float64(y + 1.0)) / Float64(x - 1.0))) - sqrt(Float64(x * y))) ^ -1.0; else tmp = Float64(Float64(fma(sqrt(Float64(Float64(1.0 + x) / (y ^ 7.0))), 0.0625, fma(sqrt(Float64(Float64(1.0 + x) / (y ^ 5.0))), -0.125, Float64(sqrt(Float64(Float64(1.0 + x) / (y ^ 3.0))) * 0.5))) + Float64(fma(-0.125, sqrt(Float64((x ^ -1.0) / y)), fma(0.5, sqrt(Float64(x / y)), Float64(0.0625 * sqrt((Float64((x ^ 3.0) * y) ^ -1.0))))) / x)) * y) ^ -1.0; end return tmp end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[x, 3100.0], N[Power[N[(N[Sqrt[N[(N[(N[(x * x + -1.0), $MachinePrecision] * N[(y + 1.0), $MachinePrecision]), $MachinePrecision] / N[(x - 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - N[Sqrt[N[(x * y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision], N[Power[N[(N[(N[(N[Sqrt[N[(N[(1.0 + x), $MachinePrecision] / N[Power[y, 7.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 0.0625 + N[(N[Sqrt[N[(N[(1.0 + x), $MachinePrecision] / N[Power[y, 5.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * -0.125 + N[(N[Sqrt[N[(N[(1.0 + x), $MachinePrecision] / N[Power[y, 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(-0.125 * N[Sqrt[N[(N[Power[x, -1.0], $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision] + N[(0.5 * N[Sqrt[N[(x / y), $MachinePrecision]], $MachinePrecision] + N[(0.0625 * N[Sqrt[N[Power[N[(N[Power[x, 3.0], $MachinePrecision] * y), $MachinePrecision], -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision], -1.0], $MachinePrecision]]
\begin{array}{l} [x, y] = \mathsf{sort}([x, y])\\ \\ \begin{array}{l} \mathbf{if}\;x \leq 3100:\\ \;\;\;\;{\left(\sqrt{\frac{\mathsf{fma}\left(x, x, -1\right) \cdot \left(y + 1\right)}{x - 1}} - \sqrt{x \cdot y}\right)}^{-1}\\ \mathbf{else}:\\ \;\;\;\;{\left(\left(\mathsf{fma}\left(\sqrt{\frac{1 + x}{{y}^{7}}}, 0.0625, \mathsf{fma}\left(\sqrt{\frac{1 + x}{{y}^{5}}}, -0.125, \sqrt{\frac{1 + x}{{y}^{3}}} \cdot 0.5\right)\right) + \frac{\mathsf{fma}\left(-0.125, \sqrt{\frac{{x}^{-1}}{y}}, \mathsf{fma}\left(0.5, \sqrt{\frac{x}{y}}, 0.0625 \cdot \sqrt{{\left({x}^{3} \cdot y\right)}^{-1}}\right)\right)}{x}\right) \cdot y\right)}^{-1}\\ \end{array} \end{array}
if x < 3100
Initial program 93.1%
lift-*.f64
N/A
lift-+.f64
N/A
flip-+
N/A
associate-*l/
N/A
lower-/.f64
N/A
lower-*.f64
N/A
metadata-eval
N/A
sub-neg
N/A
metadata-eval
N/A
lower-fma.f64
N/A
lower--.f64
93.5
Applied rewrites93.5%
if 3100 < x
Initial program 84.7%
Taylor expanded in y around inf
Applied rewrites36.6%
Taylor expanded in x around inf
Applied rewrites47.3%
Final simplification50.7%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= x 3100.0) (pow (- (sqrt (/ (* (fma x x -1.0) (+ y 1.0)) (- x 1.0))) (sqrt (* x y))) -1.0) (pow (* (+ (fma (sqrt (/ (+ 1.0 y) (pow x 7.0))) 0.0625 (fma (sqrt (/ (+ 1.0 y) (pow x 5.0))) -0.125 (* (sqrt (/ (+ 1.0 y) (pow x 3.0))) 0.5))) (- (sqrt (/ (+ 1.0 y) x)) (sqrt (/ y x)))) x) -1.0)))
assert(x < y); double code(double x, double y) { double tmp; if (x <= 3100.0) { tmp = pow((sqrt(((fma(x, x, -1.0) * (y + 1.0)) / (x - 1.0))) - sqrt((x * y))), -1.0); } else { tmp = pow(((fma(sqrt(((1.0 + y) / pow(x, 7.0))), 0.0625, fma(sqrt(((1.0 + y) / pow(x, 5.0))), -0.125, (sqrt(((1.0 + y) / pow(x, 3.0))) * 0.5))) + (sqrt(((1.0 + y) / x)) - sqrt((y / x)))) * x), -1.0); } return tmp; }
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= 3100.0) tmp = Float64(sqrt(Float64(Float64(fma(x, x, -1.0) * Float64(y + 1.0)) / Float64(x - 1.0))) - sqrt(Float64(x * y))) ^ -1.0; else tmp = Float64(Float64(fma(sqrt(Float64(Float64(1.0 + y) / (x ^ 7.0))), 0.0625, fma(sqrt(Float64(Float64(1.0 + y) / (x ^ 5.0))), -0.125, Float64(sqrt(Float64(Float64(1.0 + y) / (x ^ 3.0))) * 0.5))) + Float64(sqrt(Float64(Float64(1.0 + y) / x)) - sqrt(Float64(y / x)))) * x) ^ -1.0; end return tmp end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[x, 3100.0], N[Power[N[(N[Sqrt[N[(N[(N[(x * x + -1.0), $MachinePrecision] * N[(y + 1.0), $MachinePrecision]), $MachinePrecision] / N[(x - 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - N[Sqrt[N[(x * y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision], N[Power[N[(N[(N[(N[Sqrt[N[(N[(1.0 + y), $MachinePrecision] / N[Power[x, 7.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 0.0625 + N[(N[Sqrt[N[(N[(1.0 + y), $MachinePrecision] / N[Power[x, 5.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * -0.125 + N[(N[Sqrt[N[(N[(1.0 + y), $MachinePrecision] / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Sqrt[N[(N[(1.0 + y), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] - N[Sqrt[N[(y / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], -1.0], $MachinePrecision]]
\begin{array}{l} [x, y] = \mathsf{sort}([x, y])\\ \\ \begin{array}{l} \mathbf{if}\;x \leq 3100:\\ \;\;\;\;{\left(\sqrt{\frac{\mathsf{fma}\left(x, x, -1\right) \cdot \left(y + 1\right)}{x - 1}} - \sqrt{x \cdot y}\right)}^{-1}\\ \mathbf{else}:\\ \;\;\;\;{\left(\left(\mathsf{fma}\left(\sqrt{\frac{1 + y}{{x}^{7}}}, 0.0625, \mathsf{fma}\left(\sqrt{\frac{1 + y}{{x}^{5}}}, -0.125, \sqrt{\frac{1 + y}{{x}^{3}}} \cdot 0.5\right)\right) + \left(\sqrt{\frac{1 + y}{x}} - \sqrt{\frac{y}{x}}\right)\right) \cdot x\right)}^{-1}\\ \end{array} \end{array}
if x < 3100
Initial program 93.1%
lift-*.f64
N/A
lift-+.f64
N/A
flip-+
N/A
associate-*l/
N/A
lower-/.f64
N/A
lower-*.f64
N/A
metadata-eval
N/A
sub-neg
N/A
metadata-eval
N/A
lower-fma.f64
N/A
lower--.f64
93.5
Applied rewrites93.5%
if 3100 < x
Initial program 84.7%
Taylor expanded in x around inf
Applied rewrites96.2%
Final simplification96.0%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (pow (* (+ (fma (sqrt (/ (+ 1.0 x) (pow y 7.0))) 0.0625 (fma (sqrt (/ (+ 1.0 x) (pow y 5.0))) -0.125 (* (sqrt (/ (+ 1.0 x) (pow y 3.0))) 0.5))) (- (sqrt (/ (+ 1.0 x) y)) (sqrt (/ x y)))) y) -1.0))
assert(x < y); double code(double x, double y) { return pow(((fma(sqrt(((1.0 + x) / pow(y, 7.0))), 0.0625, fma(sqrt(((1.0 + x) / pow(y, 5.0))), -0.125, (sqrt(((1.0 + x) / pow(y, 3.0))) * 0.5))) + (sqrt(((1.0 + x) / y)) - sqrt((x / y)))) * y), -1.0); }
x, y = sort([x, y]) function code(x, y) return Float64(Float64(fma(sqrt(Float64(Float64(1.0 + x) / (y ^ 7.0))), 0.0625, fma(sqrt(Float64(Float64(1.0 + x) / (y ^ 5.0))), -0.125, Float64(sqrt(Float64(Float64(1.0 + x) / (y ^ 3.0))) * 0.5))) + Float64(sqrt(Float64(Float64(1.0 + x) / y)) - sqrt(Float64(x / y)))) * y) ^ -1.0 end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := N[Power[N[(N[(N[(N[Sqrt[N[(N[(1.0 + x), $MachinePrecision] / N[Power[y, 7.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 0.0625 + N[(N[Sqrt[N[(N[(1.0 + x), $MachinePrecision] / N[Power[y, 5.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * -0.125 + N[(N[Sqrt[N[(N[(1.0 + x), $MachinePrecision] / N[Power[y, 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Sqrt[N[(N[(1.0 + x), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision] - N[Sqrt[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision], -1.0], $MachinePrecision]
\begin{array}{l} [x, y] = \mathsf{sort}([x, y])\\ \\ {\left(\left(\mathsf{fma}\left(\sqrt{\frac{1 + x}{{y}^{7}}}, 0.0625, \mathsf{fma}\left(\sqrt{\frac{1 + x}{{y}^{5}}}, -0.125, \sqrt{\frac{1 + x}{{y}^{3}}} \cdot 0.5\right)\right) + \left(\sqrt{\frac{1 + x}{y}} - \sqrt{\frac{x}{y}}\right)\right) \cdot y\right)}^{-1} \end{array}
Initial program 85.3%
Taylor expanded in y around inf
Applied rewrites36.5%
Final simplification36.5%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (pow (- (sqrt (+ (+ (+ x 1.0) y) (* y x))) (sqrt (* x y))) -1.0))
assert(x < y); double code(double x, double y) { return pow((sqrt((((x + 1.0) + y) + (y * x))) - sqrt((x * y))), -1.0); }
NOTE: x and y should be sorted in increasing order before calling this function. real(8) function code(x, y) real(8), intent (in) :: x real(8), intent (in) :: y code = (sqrt((((x + 1.0d0) + y) + (y * x))) - sqrt((x * y))) ** (-1.0d0) end function
assert x < y; public static double code(double x, double y) { return Math.pow((Math.sqrt((((x + 1.0) + y) + (y * x))) - Math.sqrt((x * y))), -1.0); }
[x, y] = sort([x, y]) def code(x, y): return math.pow((math.sqrt((((x + 1.0) + y) + (y * x))) - math.sqrt((x * y))), -1.0)
x, y = sort([x, y]) function code(x, y) return Float64(sqrt(Float64(Float64(Float64(x + 1.0) + y) + Float64(y * x))) - sqrt(Float64(x * y))) ^ -1.0 end
x, y = num2cell(sort([x, y])){:} function tmp = code(x, y) tmp = (sqrt((((x + 1.0) + y) + (y * x))) - sqrt((x * y))) ^ -1.0; end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := N[Power[N[(N[Sqrt[N[(N[(N[(x + 1.0), $MachinePrecision] + y), $MachinePrecision] + N[(y * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - N[Sqrt[N[(x * y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision]
\begin{array}{l} [x, y] = \mathsf{sort}([x, y])\\ \\ {\left(\sqrt{\left(\left(x + 1\right) + y\right) + y \cdot x} - \sqrt{x \cdot y}\right)}^{-1} \end{array}
Initial program 85.3%
lift-*.f64
N/A
*-commutative
N/A
lift-+.f64
N/A
distribute-rgt1-in
N/A
*-commutative
N/A
lift-+.f64
N/A
distribute-rgt1-in
N/A
lift-*.f64
N/A
associate-+r+
N/A
lower-+.f64
N/A
lower-+.f64
85.4
lift-*.f64
N/A
*-commutative
N/A
lower-*.f64
85.4
Applied rewrites85.4%
Final simplification85.4%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (let* ((t_0 (sqrt (* x y)))) (if (<= x 0.000215) (pow (- (sqrt (+ 1.0 y)) t_0) -1.0) (pow (- (sqrt (fma y x y)) t_0) -1.0))))
assert(x < y); double code(double x, double y) { double t_0 = sqrt((x * y)); double tmp; if (x <= 0.000215) { tmp = pow((sqrt((1.0 + y)) - t_0), -1.0); } else { tmp = pow((sqrt(fma(y, x, y)) - t_0), -1.0); } return tmp; }
x, y = sort([x, y]) function code(x, y) t_0 = sqrt(Float64(x * y)) tmp = 0.0 if (x <= 0.000215) tmp = Float64(sqrt(Float64(1.0 + y)) - t_0) ^ -1.0; else tmp = Float64(sqrt(fma(y, x, y)) - t_0) ^ -1.0; end return tmp end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := Block[{t$95$0 = N[Sqrt[N[(x * y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, 0.000215], N[Power[N[(N[Sqrt[N[(1.0 + y), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision], -1.0], $MachinePrecision], N[Power[N[(N[Sqrt[N[(y * x + y), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision], -1.0], $MachinePrecision]]]
\begin{array}{l} [x, y] = \mathsf{sort}([x, y])\\ \\ \begin{array}{l} t_0 := \sqrt{x \cdot y}\\ \mathbf{if}\;x \leq 0.000215:\\ \;\;\;\;{\left(\sqrt{1 + y} - t\_0\right)}^{-1}\\ \mathbf{else}:\\ \;\;\;\;{\left(\sqrt{\mathsf{fma}\left(y, x, y\right)} - t\_0\right)}^{-1}\\ \end{array} \end{array}
if x < 2.14999999999999995e-4
Initial program 85.3%
Taylor expanded in x around 0
lower-+.f64
8.0
Applied rewrites8.0%
if 2.14999999999999995e-4 < x
Initial program 85.3%
Taylor expanded in y around inf
+-commutative
N/A
distribute-lft-in
N/A
*-rgt-identity
N/A
lower-fma.f64
37.3
Applied rewrites37.3%
Final simplification37.3%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (pow (- (sqrt (+ (fma y x x) (+ y 1.0))) (sqrt (* x y))) -1.0))
assert(x < y); double code(double x, double y) { return pow((sqrt((fma(y, x, x) + (y + 1.0))) - sqrt((x * y))), -1.0); }
x, y = sort([x, y]) function code(x, y) return Float64(sqrt(Float64(fma(y, x, x) + Float64(y + 1.0))) - sqrt(Float64(x * y))) ^ -1.0 end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := N[Power[N[(N[Sqrt[N[(N[(y * x + x), $MachinePrecision] + N[(y + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - N[Sqrt[N[(x * y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision]
\begin{array}{l} [x, y] = \mathsf{sort}([x, y])\\ \\ {\left(\sqrt{\mathsf{fma}\left(y, x, x\right) + \left(y + 1\right)} - \sqrt{x \cdot y}\right)}^{-1} \end{array}
Initial program 85.3%
lift-*.f64
N/A
*-commutative
N/A
lift-+.f64
N/A
distribute-lft-in
N/A
*-rgt-identity
N/A
lower-+.f64
N/A
*-commutative
N/A
lift-+.f64
N/A
distribute-lft-in
N/A
*-rgt-identity
N/A
*-commutative
N/A
lower-fma.f64
85.4
Applied rewrites85.4%
Final simplification85.4%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (pow (- (sqrt (* (+ x 1.0) (+ y 1.0))) (sqrt (* x y))) -1.0))
assert(x < y); double code(double x, double y) { return pow((sqrt(((x + 1.0) * (y + 1.0))) - sqrt((x * y))), -1.0); }
NOTE: x and y should be sorted in increasing order before calling this function. real(8) function code(x, y) real(8), intent (in) :: x real(8), intent (in) :: y code = (sqrt(((x + 1.0d0) * (y + 1.0d0))) - sqrt((x * y))) ** (-1.0d0) end function
assert x < y; public static double code(double x, double y) { return Math.pow((Math.sqrt(((x + 1.0) * (y + 1.0))) - Math.sqrt((x * y))), -1.0); }
[x, y] = sort([x, y]) def code(x, y): return math.pow((math.sqrt(((x + 1.0) * (y + 1.0))) - math.sqrt((x * y))), -1.0)
x, y = sort([x, y]) function code(x, y) return Float64(sqrt(Float64(Float64(x + 1.0) * Float64(y + 1.0))) - sqrt(Float64(x * y))) ^ -1.0 end
x, y = num2cell(sort([x, y])){:} function tmp = code(x, y) tmp = (sqrt(((x + 1.0) * (y + 1.0))) - sqrt((x * y))) ^ -1.0; end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := N[Power[N[(N[Sqrt[N[(N[(x + 1.0), $MachinePrecision] * N[(y + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - N[Sqrt[N[(x * y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision]
\begin{array}{l} [x, y] = \mathsf{sort}([x, y])\\ \\ {\left(\sqrt{\left(x + 1\right) \cdot \left(y + 1\right)} - \sqrt{x \cdot y}\right)}^{-1} \end{array}
Initial program 85.3%
Final simplification85.3%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= x 1.0) (pow (- (sqrt (+ 1.0 y)) (sqrt (* x y))) -1.0) (pow (* 0.5 (sqrt (/ (+ 1.0 x) y))) -1.0)))
assert(x < y); double code(double x, double y) { double tmp; if (x <= 1.0) { tmp = pow((sqrt((1.0 + y)) - sqrt((x * y))), -1.0); } else { tmp = pow((0.5 * sqrt(((1.0 + x) / y))), -1.0); } return tmp; }
NOTE: x and y should be sorted in increasing order before calling this function. real(8) function code(x, y) real(8), intent (in) :: x real(8), intent (in) :: y real(8) :: tmp if (x <= 1.0d0) then tmp = (sqrt((1.0d0 + y)) - sqrt((x * y))) ** (-1.0d0) else tmp = (0.5d0 * sqrt(((1.0d0 + x) / y))) ** (-1.0d0) end if code = tmp end function
assert x < y; public static double code(double x, double y) { double tmp; if (x <= 1.0) { tmp = Math.pow((Math.sqrt((1.0 + y)) - Math.sqrt((x * y))), -1.0); } else { tmp = Math.pow((0.5 * Math.sqrt(((1.0 + x) / y))), -1.0); } return tmp; }
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if x <= 1.0: tmp = math.pow((math.sqrt((1.0 + y)) - math.sqrt((x * y))), -1.0) else: tmp = math.pow((0.5 * math.sqrt(((1.0 + x) / y))), -1.0) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= 1.0) tmp = Float64(sqrt(Float64(1.0 + y)) - sqrt(Float64(x * y))) ^ -1.0; else tmp = Float64(0.5 * sqrt(Float64(Float64(1.0 + x) / y))) ^ -1.0; end return tmp end
x, y = num2cell(sort([x, y])){:} function tmp_2 = code(x, y) tmp = 0.0; if (x <= 1.0) tmp = (sqrt((1.0 + y)) - sqrt((x * y))) ^ -1.0; else tmp = (0.5 * sqrt(((1.0 + x) / y))) ^ -1.0; end tmp_2 = tmp; end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[x, 1.0], N[Power[N[(N[Sqrt[N[(1.0 + y), $MachinePrecision]], $MachinePrecision] - N[Sqrt[N[(x * y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision], N[Power[N[(0.5 * N[Sqrt[N[(N[(1.0 + x), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision]]
\begin{array}{l} [x, y] = \mathsf{sort}([x, y])\\ \\ \begin{array}{l} \mathbf{if}\;x \leq 1:\\ \;\;\;\;{\left(\sqrt{1 + y} - \sqrt{x \cdot y}\right)}^{-1}\\ \mathbf{else}:\\ \;\;\;\;{\left(0.5 \cdot \sqrt{\frac{1 + x}{y}}\right)}^{-1}\\ \end{array} \end{array}
if x < 1
Initial program 85.3%
Taylor expanded in x around 0
lower-+.f64
8.0
Applied rewrites8.0%
if 1 < x
Initial program 85.3%
Taylor expanded in y around inf
*-commutative
N/A
lower-*.f64
N/A
Applied rewrites38.1%
Taylor expanded in y around 0
Applied rewrites6.3%
Final simplification6.3%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (pow (* 0.5 (sqrt (/ (+ 1.0 x) y))) -1.0))
assert(x < y); double code(double x, double y) { return pow((0.5 * sqrt(((1.0 + x) / y))), -1.0); }
NOTE: x and y should be sorted in increasing order before calling this function. real(8) function code(x, y) real(8), intent (in) :: x real(8), intent (in) :: y code = (0.5d0 * sqrt(((1.0d0 + x) / y))) ** (-1.0d0) end function
assert x < y; public static double code(double x, double y) { return Math.pow((0.5 * Math.sqrt(((1.0 + x) / y))), -1.0); }
[x, y] = sort([x, y]) def code(x, y): return math.pow((0.5 * math.sqrt(((1.0 + x) / y))), -1.0)
x, y = sort([x, y]) function code(x, y) return Float64(0.5 * sqrt(Float64(Float64(1.0 + x) / y))) ^ -1.0 end
x, y = num2cell(sort([x, y])){:} function tmp = code(x, y) tmp = (0.5 * sqrt(((1.0 + x) / y))) ^ -1.0; end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := N[Power[N[(0.5 * N[Sqrt[N[(N[(1.0 + x), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision]
\begin{array}{l} [x, y] = \mathsf{sort}([x, y])\\ \\ {\left(0.5 \cdot \sqrt{\frac{1 + x}{y}}\right)}^{-1} \end{array}
Initial program 85.3%
Taylor expanded in y around inf
*-commutative
N/A
lower-*.f64
N/A
Applied rewrites38.1%
Taylor expanded in y around 0
Applied rewrites6.3%
Final simplification6.3%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (pow (* 0.5 (sqrt (/ x y))) -1.0))
assert(x < y); double code(double x, double y) { return pow((0.5 * sqrt((x / y))), -1.0); }
NOTE: x and y should be sorted in increasing order before calling this function. real(8) function code(x, y) real(8), intent (in) :: x real(8), intent (in) :: y code = (0.5d0 * sqrt((x / y))) ** (-1.0d0) end function
assert x < y; public static double code(double x, double y) { return Math.pow((0.5 * Math.sqrt((x / y))), -1.0); }
[x, y] = sort([x, y]) def code(x, y): return math.pow((0.5 * math.sqrt((x / y))), -1.0)
x, y = sort([x, y]) function code(x, y) return Float64(0.5 * sqrt(Float64(x / y))) ^ -1.0 end
x, y = num2cell(sort([x, y])){:} function tmp = code(x, y) tmp = (0.5 * sqrt((x / y))) ^ -1.0; end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := N[Power[N[(0.5 * N[Sqrt[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision]
\begin{array}{l} [x, y] = \mathsf{sort}([x, y])\\ \\ {\left(0.5 \cdot \sqrt{\frac{x}{y}}\right)}^{-1} \end{array}
Initial program 85.3%
Taylor expanded in y around inf
*-commutative
N/A
lower-*.f64
N/A
Applied rewrites38.1%
Taylor expanded in x around inf
Applied rewrites6.2%
Final simplification6.2%
herbie shell --seed 1
(FPCore (x y)
:name "1/(sqrt((x + 1) * (y + 1)) - sqrt(x * y))"
:precision binary64
:pre (and (and (<= 1000.0 x) (<= x 1000000000.0)) (and (<= 0.0 y) (<= y 1.79e+308)))
(/ 1.0 (- (sqrt (* (+ x 1.0) (+ y 1.0))) (sqrt (* x y)))))