
(FPCore (x y) :precision binary64 (- (- 1.0 (/ 1.0 (* x 9.0))) (/ y (* 3.0 (sqrt x)))))
double code(double x, double y) {
return (1.0 - (1.0 / (x * 9.0))) - (y / (3.0 * sqrt(x)));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (1.0d0 - (1.0d0 / (x * 9.0d0))) - (y / (3.0d0 * sqrt(x)))
end function
public static double code(double x, double y) {
return (1.0 - (1.0 / (x * 9.0))) - (y / (3.0 * Math.sqrt(x)));
}
def code(x, y): return (1.0 - (1.0 / (x * 9.0))) - (y / (3.0 * math.sqrt(x)))
function code(x, y) return Float64(Float64(1.0 - Float64(1.0 / Float64(x * 9.0))) - Float64(y / Float64(3.0 * sqrt(x)))) end
function tmp = code(x, y) tmp = (1.0 - (1.0 / (x * 9.0))) - (y / (3.0 * sqrt(x))); end
code[x_, y_] := N[(N[(1.0 - N[(1.0 / N[(x * 9.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(y / N[(3.0 * N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(1 - \frac{1}{x \cdot 9}\right) - \frac{y}{3 \cdot \sqrt{x}}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (- (- 1.0 (/ 1.0 (* x 9.0))) (/ y (* 3.0 (sqrt x)))))
double code(double x, double y) {
return (1.0 - (1.0 / (x * 9.0))) - (y / (3.0 * sqrt(x)));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (1.0d0 - (1.0d0 / (x * 9.0d0))) - (y / (3.0d0 * sqrt(x)))
end function
public static double code(double x, double y) {
return (1.0 - (1.0 / (x * 9.0))) - (y / (3.0 * Math.sqrt(x)));
}
def code(x, y): return (1.0 - (1.0 / (x * 9.0))) - (y / (3.0 * math.sqrt(x)))
function code(x, y) return Float64(Float64(1.0 - Float64(1.0 / Float64(x * 9.0))) - Float64(y / Float64(3.0 * sqrt(x)))) end
function tmp = code(x, y) tmp = (1.0 - (1.0 / (x * 9.0))) - (y / (3.0 * sqrt(x))); end
code[x_, y_] := N[(N[(1.0 - N[(1.0 / N[(x * 9.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(y / N[(3.0 * N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(1 - \frac{1}{x \cdot 9}\right) - \frac{y}{3 \cdot \sqrt{x}}
\end{array}
(FPCore (x y) :precision binary64 (- (- 1.0 (/ 1.0 (* 9.0 x))) (/ y (* (sqrt x) 3.0))))
double code(double x, double y) {
return (1.0 - (1.0 / (9.0 * x))) - (y / (sqrt(x) * 3.0));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (1.0d0 - (1.0d0 / (9.0d0 * x))) - (y / (sqrt(x) * 3.0d0))
end function
public static double code(double x, double y) {
return (1.0 - (1.0 / (9.0 * x))) - (y / (Math.sqrt(x) * 3.0));
}
def code(x, y): return (1.0 - (1.0 / (9.0 * x))) - (y / (math.sqrt(x) * 3.0))
function code(x, y) return Float64(Float64(1.0 - Float64(1.0 / Float64(9.0 * x))) - Float64(y / Float64(sqrt(x) * 3.0))) end
function tmp = code(x, y) tmp = (1.0 - (1.0 / (9.0 * x))) - (y / (sqrt(x) * 3.0)); end
code[x_, y_] := N[(N[(1.0 - N[(1.0 / N[(9.0 * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(y / N[(N[Sqrt[x], $MachinePrecision] * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(1 - \frac{1}{9 \cdot x}\right) - \frac{y}{\sqrt{x} \cdot 3}
\end{array}
Initial program 99.7%
Final simplification99.7%
(FPCore (x y) :precision binary64 (fma (/ -1.0 (sqrt x)) (* 0.3333333333333333 y) (- 1.0 (/ 0.1111111111111111 x))))
double code(double x, double y) {
return fma((-1.0 / sqrt(x)), (0.3333333333333333 * y), (1.0 - (0.1111111111111111 / x)));
}
function code(x, y) return fma(Float64(-1.0 / sqrt(x)), Float64(0.3333333333333333 * y), Float64(1.0 - Float64(0.1111111111111111 / x))) end
code[x_, y_] := N[(N[(-1.0 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision] * N[(0.3333333333333333 * y), $MachinePrecision] + N[(1.0 - N[(0.1111111111111111 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{-1}{\sqrt{x}}, 0.3333333333333333 \cdot y, 1 - \frac{0.1111111111111111}{x}\right)
\end{array}
Initial program 99.7%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-/.f64N/A
distribute-neg-fracN/A
neg-mul-1N/A
lift-*.f64N/A
*-commutativeN/A
times-fracN/A
lower-fma.f64N/A
lower-/.f64N/A
clear-numN/A
associate-/r/N/A
lower-*.f64N/A
metadata-eval99.7
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
metadata-evalN/A
metadata-evalN/A
lower-/.f64N/A
metadata-eval99.7
Applied rewrites99.7%
(FPCore (x y)
:precision binary64
(let* ((t_0 (- 1.0 (/ y (* (sqrt x) 3.0)))))
(if (<= y -170000000000.0)
t_0
(if (<= y 9.5e+45) (- 1.0 (/ 0.1111111111111111 x)) t_0))))
double code(double x, double y) {
double t_0 = 1.0 - (y / (sqrt(x) * 3.0));
double tmp;
if (y <= -170000000000.0) {
tmp = t_0;
} else if (y <= 9.5e+45) {
tmp = 1.0 - (0.1111111111111111 / x);
} else {
tmp = t_0;
}
return tmp;
}
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 = 1.0d0 - (y / (sqrt(x) * 3.0d0))
if (y <= (-170000000000.0d0)) then
tmp = t_0
else if (y <= 9.5d+45) then
tmp = 1.0d0 - (0.1111111111111111d0 / x)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = 1.0 - (y / (Math.sqrt(x) * 3.0));
double tmp;
if (y <= -170000000000.0) {
tmp = t_0;
} else if (y <= 9.5e+45) {
tmp = 1.0 - (0.1111111111111111 / x);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 - (y / (math.sqrt(x) * 3.0)) tmp = 0 if y <= -170000000000.0: tmp = t_0 elif y <= 9.5e+45: tmp = 1.0 - (0.1111111111111111 / x) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(1.0 - Float64(y / Float64(sqrt(x) * 3.0))) tmp = 0.0 if (y <= -170000000000.0) tmp = t_0; elseif (y <= 9.5e+45) tmp = Float64(1.0 - Float64(0.1111111111111111 / x)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 - (y / (sqrt(x) * 3.0)); tmp = 0.0; if (y <= -170000000000.0) tmp = t_0; elseif (y <= 9.5e+45) tmp = 1.0 - (0.1111111111111111 / x); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(1.0 - N[(y / N[(N[Sqrt[x], $MachinePrecision] * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -170000000000.0], t$95$0, If[LessEqual[y, 9.5e+45], N[(1.0 - N[(0.1111111111111111 / x), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{y}{\sqrt{x} \cdot 3}\\
\mathbf{if}\;y \leq -170000000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 9.5 \cdot 10^{+45}:\\
\;\;\;\;1 - \frac{0.1111111111111111}{x}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -1.7e11 or 9.4999999999999998e45 < y Initial program 99.5%
Taylor expanded in x around inf
Applied rewrites93.8%
if -1.7e11 < y < 9.4999999999999998e45Initial program 99.8%
Taylor expanded in x around 0
lower-/.f64N/A
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
lower-sqrt.f6499.8
Applied rewrites99.8%
Taylor expanded in y around 0
Applied rewrites99.2%
Applied rewrites99.2%
Final simplification96.8%
(FPCore (x y) :precision binary64 (if (<= x 2.8e+19) (/ (- (fma (* -0.3333333333333333 y) (sqrt x) x) 0.1111111111111111) x) (- 1.0 (/ y (* (sqrt x) 3.0)))))
double code(double x, double y) {
double tmp;
if (x <= 2.8e+19) {
tmp = (fma((-0.3333333333333333 * y), sqrt(x), x) - 0.1111111111111111) / x;
} else {
tmp = 1.0 - (y / (sqrt(x) * 3.0));
}
return tmp;
}
function code(x, y) tmp = 0.0 if (x <= 2.8e+19) tmp = Float64(Float64(fma(Float64(-0.3333333333333333 * y), sqrt(x), x) - 0.1111111111111111) / x); else tmp = Float64(1.0 - Float64(y / Float64(sqrt(x) * 3.0))); end return tmp end
code[x_, y_] := If[LessEqual[x, 2.8e+19], N[(N[(N[(N[(-0.3333333333333333 * y), $MachinePrecision] * N[Sqrt[x], $MachinePrecision] + x), $MachinePrecision] - 0.1111111111111111), $MachinePrecision] / x), $MachinePrecision], N[(1.0 - N[(y / N[(N[Sqrt[x], $MachinePrecision] * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.8 \cdot 10^{+19}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-0.3333333333333333 \cdot y, \sqrt{x}, x\right) - 0.1111111111111111}{x}\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{y}{\sqrt{x} \cdot 3}\\
\end{array}
\end{array}
if x < 2.8e19Initial program 99.5%
Taylor expanded in x around 0
lower-/.f64N/A
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
lower-sqrt.f6499.5
Applied rewrites99.5%
Applied rewrites99.5%
Applied rewrites99.5%
if 2.8e19 < x Initial program 99.8%
Taylor expanded in x around inf
Applied rewrites99.8%
Final simplification99.7%
(FPCore (x y) :precision binary64 (if (<= x 2.8e+19) (/ (- x (fma (* 0.3333333333333333 y) (sqrt x) 0.1111111111111111)) x) (- 1.0 (/ y (* (sqrt x) 3.0)))))
double code(double x, double y) {
double tmp;
if (x <= 2.8e+19) {
tmp = (x - fma((0.3333333333333333 * y), sqrt(x), 0.1111111111111111)) / x;
} else {
tmp = 1.0 - (y / (sqrt(x) * 3.0));
}
return tmp;
}
function code(x, y) tmp = 0.0 if (x <= 2.8e+19) tmp = Float64(Float64(x - fma(Float64(0.3333333333333333 * y), sqrt(x), 0.1111111111111111)) / x); else tmp = Float64(1.0 - Float64(y / Float64(sqrt(x) * 3.0))); end return tmp end
code[x_, y_] := If[LessEqual[x, 2.8e+19], N[(N[(x - N[(N[(0.3333333333333333 * y), $MachinePrecision] * N[Sqrt[x], $MachinePrecision] + 0.1111111111111111), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], N[(1.0 - N[(y / N[(N[Sqrt[x], $MachinePrecision] * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.8 \cdot 10^{+19}:\\
\;\;\;\;\frac{x - \mathsf{fma}\left(0.3333333333333333 \cdot y, \sqrt{x}, 0.1111111111111111\right)}{x}\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{y}{\sqrt{x} \cdot 3}\\
\end{array}
\end{array}
if x < 2.8e19Initial program 99.5%
Taylor expanded in x around 0
lower-/.f64N/A
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
lower-sqrt.f6499.5
Applied rewrites99.5%
Applied rewrites99.5%
if 2.8e19 < x Initial program 99.8%
Taylor expanded in x around inf
Applied rewrites99.8%
Final simplification99.7%
(FPCore (x y) :precision binary64 (fma (/ -0.3333333333333333 (sqrt x)) y (- 1.0 (/ 0.1111111111111111 x))))
double code(double x, double y) {
return fma((-0.3333333333333333 / sqrt(x)), y, (1.0 - (0.1111111111111111 / x)));
}
function code(x, y) return fma(Float64(-0.3333333333333333 / sqrt(x)), y, Float64(1.0 - Float64(0.1111111111111111 / x))) end
code[x_, y_] := N[(N[(-0.3333333333333333 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision] * y + N[(1.0 - N[(0.1111111111111111 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{-0.3333333333333333}{\sqrt{x}}, y, 1 - \frac{0.1111111111111111}{x}\right)
\end{array}
Initial program 99.7%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-/.f64N/A
clear-numN/A
associate-/r/N/A
distribute-lft-neg-inN/A
distribute-frac-neg2N/A
lower-fma.f64N/A
distribute-frac-neg2N/A
lift-*.f64N/A
associate-/r*N/A
distribute-neg-fracN/A
lower-/.f64N/A
metadata-evalN/A
metadata-eval99.7
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
metadata-evalN/A
metadata-evalN/A
lower-/.f64N/A
Applied rewrites99.6%
(FPCore (x y) :precision binary64 (fma -0.3333333333333333 (/ y (sqrt x)) (- 1.0 (/ 0.1111111111111111 x))))
double code(double x, double y) {
return fma(-0.3333333333333333, (y / sqrt(x)), (1.0 - (0.1111111111111111 / x)));
}
function code(x, y) return fma(-0.3333333333333333, Float64(y / sqrt(x)), Float64(1.0 - Float64(0.1111111111111111 / x))) end
code[x_, y_] := N[(-0.3333333333333333 * N[(y / N[Sqrt[x], $MachinePrecision]), $MachinePrecision] + N[(1.0 - N[(0.1111111111111111 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(-0.3333333333333333, \frac{y}{\sqrt{x}}, 1 - \frac{0.1111111111111111}{x}\right)
\end{array}
Initial program 99.7%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-/.f64N/A
distribute-neg-fracN/A
neg-mul-1N/A
lift-*.f64N/A
times-fracN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
lower-fma.f64N/A
metadata-evalN/A
metadata-evalN/A
lower-/.f6499.6
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
metadata-evalN/A
metadata-evalN/A
lower-/.f64N/A
metadata-eval99.6
Applied rewrites99.6%
(FPCore (x y) :precision binary64 (if (<= x 26500.0) (/ (+ -0.1111111111111111 (* (* (sqrt x) y) -0.3333333333333333)) x) (- 1.0 (/ y (* (sqrt x) 3.0)))))
double code(double x, double y) {
double tmp;
if (x <= 26500.0) {
tmp = (-0.1111111111111111 + ((sqrt(x) * y) * -0.3333333333333333)) / x;
} else {
tmp = 1.0 - (y / (sqrt(x) * 3.0));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= 26500.0d0) then
tmp = ((-0.1111111111111111d0) + ((sqrt(x) * y) * (-0.3333333333333333d0))) / x
else
tmp = 1.0d0 - (y / (sqrt(x) * 3.0d0))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= 26500.0) {
tmp = (-0.1111111111111111 + ((Math.sqrt(x) * y) * -0.3333333333333333)) / x;
} else {
tmp = 1.0 - (y / (Math.sqrt(x) * 3.0));
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 26500.0: tmp = (-0.1111111111111111 + ((math.sqrt(x) * y) * -0.3333333333333333)) / x else: tmp = 1.0 - (y / (math.sqrt(x) * 3.0)) return tmp
function code(x, y) tmp = 0.0 if (x <= 26500.0) tmp = Float64(Float64(-0.1111111111111111 + Float64(Float64(sqrt(x) * y) * -0.3333333333333333)) / x); else tmp = Float64(1.0 - Float64(y / Float64(sqrt(x) * 3.0))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 26500.0) tmp = (-0.1111111111111111 + ((sqrt(x) * y) * -0.3333333333333333)) / x; else tmp = 1.0 - (y / (sqrt(x) * 3.0)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 26500.0], N[(N[(-0.1111111111111111 + N[(N[(N[Sqrt[x], $MachinePrecision] * y), $MachinePrecision] * -0.3333333333333333), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], N[(1.0 - N[(y / N[(N[Sqrt[x], $MachinePrecision] * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 26500:\\
\;\;\;\;\frac{-0.1111111111111111 + \left(\sqrt{x} \cdot y\right) \cdot -0.3333333333333333}{x}\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{y}{\sqrt{x} \cdot 3}\\
\end{array}
\end{array}
if x < 26500Initial program 99.5%
lift-/.f64N/A
inv-powN/A
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
rem-square-sqrtN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
swap-sqrN/A
lift-*.f64N/A
lift-*.f64N/A
pow-prod-downN/A
inv-powN/A
inv-powN/A
lift-*.f64N/A
associate-/r*N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites99.1%
Taylor expanded in x around 0
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
+-commutativeN/A
distribute-neg-inN/A
distribute-lft-neg-inN/A
metadata-evalN/A
metadata-evalN/A
lower-fma.f64N/A
lower-*.f64N/A
lower-sqrt.f6498.4
Applied rewrites98.4%
Applied rewrites98.4%
if 26500 < x Initial program 99.8%
Taylor expanded in x around inf
Applied rewrites99.5%
Final simplification99.0%
(FPCore (x y)
:precision binary64
(let* ((t_0 (fma (/ -0.3333333333333333 (sqrt x)) y 1.0)))
(if (<= y -170000000000.0)
t_0
(if (<= y 9.5e+45) (- 1.0 (/ 0.1111111111111111 x)) t_0))))
double code(double x, double y) {
double t_0 = fma((-0.3333333333333333 / sqrt(x)), y, 1.0);
double tmp;
if (y <= -170000000000.0) {
tmp = t_0;
} else if (y <= 9.5e+45) {
tmp = 1.0 - (0.1111111111111111 / x);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y) t_0 = fma(Float64(-0.3333333333333333 / sqrt(x)), y, 1.0) tmp = 0.0 if (y <= -170000000000.0) tmp = t_0; elseif (y <= 9.5e+45) tmp = Float64(1.0 - Float64(0.1111111111111111 / x)); else tmp = t_0; end return tmp end
code[x_, y_] := Block[{t$95$0 = N[(N[(-0.3333333333333333 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision] * y + 1.0), $MachinePrecision]}, If[LessEqual[y, -170000000000.0], t$95$0, If[LessEqual[y, 9.5e+45], N[(1.0 - N[(0.1111111111111111 / x), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\frac{-0.3333333333333333}{\sqrt{x}}, y, 1\right)\\
\mathbf{if}\;y \leq -170000000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 9.5 \cdot 10^{+45}:\\
\;\;\;\;1 - \frac{0.1111111111111111}{x}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -1.7e11 or 9.4999999999999998e45 < y Initial program 99.5%
Taylor expanded in x around inf
Applied rewrites93.8%
lift--.f64N/A
sub-negN/A
lift-/.f64N/A
distribute-neg-fracN/A
neg-mul-1N/A
lift-*.f64N/A
times-fracN/A
metadata-evalN/A
associate-/l*N/A
associate-*l/N/A
lift-/.f64N/A
+-commutativeN/A
lower-fma.f6493.8
Applied rewrites93.8%
if -1.7e11 < y < 9.4999999999999998e45Initial program 99.8%
Taylor expanded in x around 0
lower-/.f64N/A
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
lower-sqrt.f6499.8
Applied rewrites99.8%
Taylor expanded in y around 0
Applied rewrites99.2%
Applied rewrites99.2%
(FPCore (x y) :precision binary64 (if (<= x 26500.0) (/ (fma -0.3333333333333333 (* (sqrt x) y) -0.1111111111111111) x) (- 1.0 (/ y (* (sqrt x) 3.0)))))
double code(double x, double y) {
double tmp;
if (x <= 26500.0) {
tmp = fma(-0.3333333333333333, (sqrt(x) * y), -0.1111111111111111) / x;
} else {
tmp = 1.0 - (y / (sqrt(x) * 3.0));
}
return tmp;
}
function code(x, y) tmp = 0.0 if (x <= 26500.0) tmp = Float64(fma(-0.3333333333333333, Float64(sqrt(x) * y), -0.1111111111111111) / x); else tmp = Float64(1.0 - Float64(y / Float64(sqrt(x) * 3.0))); end return tmp end
code[x_, y_] := If[LessEqual[x, 26500.0], N[(N[(-0.3333333333333333 * N[(N[Sqrt[x], $MachinePrecision] * y), $MachinePrecision] + -0.1111111111111111), $MachinePrecision] / x), $MachinePrecision], N[(1.0 - N[(y / N[(N[Sqrt[x], $MachinePrecision] * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 26500:\\
\;\;\;\;\frac{\mathsf{fma}\left(-0.3333333333333333, \sqrt{x} \cdot y, -0.1111111111111111\right)}{x}\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{y}{\sqrt{x} \cdot 3}\\
\end{array}
\end{array}
if x < 26500Initial program 99.5%
Taylor expanded in x around 0
mul-1-negN/A
distribute-neg-fracN/A
lower-/.f64N/A
+-commutativeN/A
distribute-neg-inN/A
metadata-evalN/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-fma.f64N/A
lower-*.f64N/A
lower-sqrt.f6498.4
Applied rewrites98.4%
if 26500 < x Initial program 99.8%
Taylor expanded in x around inf
Applied rewrites99.5%
Final simplification99.0%
(FPCore (x y) :precision binary64 (- 1.0 (/ 0.1111111111111111 x)))
double code(double x, double y) {
return 1.0 - (0.1111111111111111 / x);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0 - (0.1111111111111111d0 / x)
end function
public static double code(double x, double y) {
return 1.0 - (0.1111111111111111 / x);
}
def code(x, y): return 1.0 - (0.1111111111111111 / x)
function code(x, y) return Float64(1.0 - Float64(0.1111111111111111 / x)) end
function tmp = code(x, y) tmp = 1.0 - (0.1111111111111111 / x); end
code[x_, y_] := N[(1.0 - N[(0.1111111111111111 / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 - \frac{0.1111111111111111}{x}
\end{array}
Initial program 99.7%
Taylor expanded in x around 0
lower-/.f64N/A
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
lower-sqrt.f6493.7
Applied rewrites93.7%
Taylor expanded in y around 0
Applied rewrites62.9%
Applied rewrites62.9%
(FPCore (x y) :precision binary64 (/ -0.1111111111111111 x))
double code(double x, double y) {
return -0.1111111111111111 / x;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (-0.1111111111111111d0) / x
end function
public static double code(double x, double y) {
return -0.1111111111111111 / x;
}
def code(x, y): return -0.1111111111111111 / x
function code(x, y) return Float64(-0.1111111111111111 / x) end
function tmp = code(x, y) tmp = -0.1111111111111111 / x; end
code[x_, y_] := N[(-0.1111111111111111 / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{-0.1111111111111111}{x}
\end{array}
Initial program 99.7%
lift-/.f64N/A
inv-powN/A
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
rem-square-sqrtN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
swap-sqrN/A
lift-*.f64N/A
lift-*.f64N/A
pow-prod-downN/A
inv-powN/A
inv-powN/A
lift-*.f64N/A
associate-/r*N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites99.4%
Taylor expanded in x around 0
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
+-commutativeN/A
distribute-neg-inN/A
distribute-lft-neg-inN/A
metadata-evalN/A
metadata-evalN/A
lower-fma.f64N/A
lower-*.f64N/A
lower-sqrt.f6462.2
Applied rewrites62.2%
Taylor expanded in y around 0
Applied rewrites31.7%
(FPCore (x y) :precision binary64 (- (- 1.0 (/ (/ 1.0 x) 9.0)) (/ y (* 3.0 (sqrt x)))))
double code(double x, double y) {
return (1.0 - ((1.0 / x) / 9.0)) - (y / (3.0 * sqrt(x)));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (1.0d0 - ((1.0d0 / x) / 9.0d0)) - (y / (3.0d0 * sqrt(x)))
end function
public static double code(double x, double y) {
return (1.0 - ((1.0 / x) / 9.0)) - (y / (3.0 * Math.sqrt(x)));
}
def code(x, y): return (1.0 - ((1.0 / x) / 9.0)) - (y / (3.0 * math.sqrt(x)))
function code(x, y) return Float64(Float64(1.0 - Float64(Float64(1.0 / x) / 9.0)) - Float64(y / Float64(3.0 * sqrt(x)))) end
function tmp = code(x, y) tmp = (1.0 - ((1.0 / x) / 9.0)) - (y / (3.0 * sqrt(x))); end
code[x_, y_] := N[(N[(1.0 - N[(N[(1.0 / x), $MachinePrecision] / 9.0), $MachinePrecision]), $MachinePrecision] - N[(y / N[(3.0 * N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(1 - \frac{\frac{1}{x}}{9}\right) - \frac{y}{3 \cdot \sqrt{x}}
\end{array}
herbie shell --seed 2024294
(FPCore (x y)
:name "Numeric.SpecFunctions:invIncompleteGamma from math-functions-0.1.5.2, D"
:precision binary64
:alt
(! :herbie-platform default (- (- 1 (/ (/ 1 x) 9)) (/ y (* 3 (sqrt x)))))
(- (- 1.0 (/ 1.0 (* x 9.0))) (/ y (* 3.0 (sqrt x)))))