
(FPCore (x y) :precision binary64 (+ (- 1.0 x) (* y (sqrt x))))
double code(double x, double y) {
return (1.0 - x) + (y * sqrt(x));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (1.0d0 - x) + (y * sqrt(x))
end function
public static double code(double x, double y) {
return (1.0 - x) + (y * Math.sqrt(x));
}
def code(x, y): return (1.0 - x) + (y * math.sqrt(x))
function code(x, y) return Float64(Float64(1.0 - x) + Float64(y * sqrt(x))) end
function tmp = code(x, y) tmp = (1.0 - x) + (y * sqrt(x)); end
code[x_, y_] := N[(N[(1.0 - x), $MachinePrecision] + N[(y * N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(1 - x\right) + y \cdot \sqrt{x}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (+ (- 1.0 x) (* y (sqrt x))))
double code(double x, double y) {
return (1.0 - x) + (y * sqrt(x));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (1.0d0 - x) + (y * sqrt(x))
end function
public static double code(double x, double y) {
return (1.0 - x) + (y * Math.sqrt(x));
}
def code(x, y): return (1.0 - x) + (y * math.sqrt(x))
function code(x, y) return Float64(Float64(1.0 - x) + Float64(y * sqrt(x))) end
function tmp = code(x, y) tmp = (1.0 - x) + (y * sqrt(x)); end
code[x_, y_] := N[(N[(1.0 - x), $MachinePrecision] + N[(y * N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(1 - x\right) + y \cdot \sqrt{x}
\end{array}
(FPCore (x y) :precision binary64 (+ (- 1.0 x) (* y (sqrt x))))
double code(double x, double y) {
return (1.0 - x) + (y * sqrt(x));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (1.0d0 - x) + (y * sqrt(x))
end function
public static double code(double x, double y) {
return (1.0 - x) + (y * Math.sqrt(x));
}
def code(x, y): return (1.0 - x) + (y * math.sqrt(x))
function code(x, y) return Float64(Float64(1.0 - x) + Float64(y * sqrt(x))) end
function tmp = code(x, y) tmp = (1.0 - x) + (y * sqrt(x)); end
code[x_, y_] := N[(N[(1.0 - x), $MachinePrecision] + N[(y * N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(1 - x\right) + y \cdot \sqrt{x}
\end{array}
Initial program 99.9%
Final simplification99.9%
(FPCore (x y) :precision binary64 (if (or (<= y -6.8e+70) (not (<= y 1.02e+14))) (+ 1.0 (* y (sqrt x))) (- 1.0 x)))
double code(double x, double y) {
double tmp;
if ((y <= -6.8e+70) || !(y <= 1.02e+14)) {
tmp = 1.0 + (y * sqrt(x));
} else {
tmp = 1.0 - x;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((y <= (-6.8d+70)) .or. (.not. (y <= 1.02d+14))) then
tmp = 1.0d0 + (y * sqrt(x))
else
tmp = 1.0d0 - x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -6.8e+70) || !(y <= 1.02e+14)) {
tmp = 1.0 + (y * Math.sqrt(x));
} else {
tmp = 1.0 - x;
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -6.8e+70) or not (y <= 1.02e+14): tmp = 1.0 + (y * math.sqrt(x)) else: tmp = 1.0 - x return tmp
function code(x, y) tmp = 0.0 if ((y <= -6.8e+70) || !(y <= 1.02e+14)) tmp = Float64(1.0 + Float64(y * sqrt(x))); else tmp = Float64(1.0 - x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -6.8e+70) || ~((y <= 1.02e+14))) tmp = 1.0 + (y * sqrt(x)); else tmp = 1.0 - x; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -6.8e+70], N[Not[LessEqual[y, 1.02e+14]], $MachinePrecision]], N[(1.0 + N[(y * N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 - x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.8 \cdot 10^{+70} \lor \neg \left(y \leq 1.02 \cdot 10^{+14}\right):\\
\;\;\;\;1 + y \cdot \sqrt{x}\\
\mathbf{else}:\\
\;\;\;\;1 - x\\
\end{array}
\end{array}
if y < -6.8000000000000002e70 or 1.02e14 < y Initial program 99.8%
Taylor expanded in x around 0 93.1%
if -6.8000000000000002e70 < y < 1.02e14Initial program 100.0%
Taylor expanded in y around 0 98.8%
Final simplification96.5%
(FPCore (x y) :precision binary64 (if (or (<= y -7.8e+71) (not (<= y 5.5e+41))) (* y (sqrt x)) (- 1.0 x)))
double code(double x, double y) {
double tmp;
if ((y <= -7.8e+71) || !(y <= 5.5e+41)) {
tmp = y * sqrt(x);
} else {
tmp = 1.0 - x;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((y <= (-7.8d+71)) .or. (.not. (y <= 5.5d+41))) then
tmp = y * sqrt(x)
else
tmp = 1.0d0 - x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -7.8e+71) || !(y <= 5.5e+41)) {
tmp = y * Math.sqrt(x);
} else {
tmp = 1.0 - x;
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -7.8e+71) or not (y <= 5.5e+41): tmp = y * math.sqrt(x) else: tmp = 1.0 - x return tmp
function code(x, y) tmp = 0.0 if ((y <= -7.8e+71) || !(y <= 5.5e+41)) tmp = Float64(y * sqrt(x)); else tmp = Float64(1.0 - x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -7.8e+71) || ~((y <= 5.5e+41))) tmp = y * sqrt(x); else tmp = 1.0 - x; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -7.8e+71], N[Not[LessEqual[y, 5.5e+41]], $MachinePrecision]], N[(y * N[Sqrt[x], $MachinePrecision]), $MachinePrecision], N[(1.0 - x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7.8 \cdot 10^{+71} \lor \neg \left(y \leq 5.5 \cdot 10^{+41}\right):\\
\;\;\;\;y \cdot \sqrt{x}\\
\mathbf{else}:\\
\;\;\;\;1 - x\\
\end{array}
\end{array}
if y < -7.8000000000000002e71 or 5.5000000000000003e41 < y Initial program 99.8%
+-commutative99.8%
*-commutative99.8%
add-sqr-sqrt99.3%
associate-*l*99.4%
fma-define99.4%
pow1/299.4%
sqrt-pow199.5%
metadata-eval99.5%
pow1/299.5%
sqrt-pow199.4%
metadata-eval99.4%
Applied egg-rr99.4%
Taylor expanded in y around inf 87.9%
if -7.8000000000000002e71 < y < 5.5000000000000003e41Initial program 100.0%
Taylor expanded in y around 0 96.7%
Final simplification93.5%
(FPCore (x y) :precision binary64 (let* ((t_0 (* y (sqrt x)))) (if (<= x 1.0) (+ 1.0 t_0) (- t_0 x))))
double code(double x, double y) {
double t_0 = y * sqrt(x);
double tmp;
if (x <= 1.0) {
tmp = 1.0 + t_0;
} else {
tmp = t_0 - x;
}
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 = y * sqrt(x)
if (x <= 1.0d0) then
tmp = 1.0d0 + t_0
else
tmp = t_0 - x
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = y * Math.sqrt(x);
double tmp;
if (x <= 1.0) {
tmp = 1.0 + t_0;
} else {
tmp = t_0 - x;
}
return tmp;
}
def code(x, y): t_0 = y * math.sqrt(x) tmp = 0 if x <= 1.0: tmp = 1.0 + t_0 else: tmp = t_0 - x return tmp
function code(x, y) t_0 = Float64(y * sqrt(x)) tmp = 0.0 if (x <= 1.0) tmp = Float64(1.0 + t_0); else tmp = Float64(t_0 - x); end return tmp end
function tmp_2 = code(x, y) t_0 = y * sqrt(x); tmp = 0.0; if (x <= 1.0) tmp = 1.0 + t_0; else tmp = t_0 - x; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(y * N[Sqrt[x], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 1.0], N[(1.0 + t$95$0), $MachinePrecision], N[(t$95$0 - x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \sqrt{x}\\
\mathbf{if}\;x \leq 1:\\
\;\;\;\;1 + t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_0 - x\\
\end{array}
\end{array}
if x < 1Initial program 99.9%
Taylor expanded in x around 0 98.5%
if 1 < x Initial program 99.9%
Taylor expanded in x around inf 98.7%
Taylor expanded in x around 0 98.8%
neg-mul-198.8%
+-commutative98.8%
*-commutative98.8%
sub-neg98.8%
Simplified98.8%
Final simplification98.7%
(FPCore (x y) :precision binary64 (if (<= y 4e+104) (- 1.0 x) (pow y 2.0)))
double code(double x, double y) {
double tmp;
if (y <= 4e+104) {
tmp = 1.0 - x;
} else {
tmp = pow(y, 2.0);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 4d+104) then
tmp = 1.0d0 - x
else
tmp = y ** 2.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 4e+104) {
tmp = 1.0 - x;
} else {
tmp = Math.pow(y, 2.0);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 4e+104: tmp = 1.0 - x else: tmp = math.pow(y, 2.0) return tmp
function code(x, y) tmp = 0.0 if (y <= 4e+104) tmp = Float64(1.0 - x); else tmp = y ^ 2.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 4e+104) tmp = 1.0 - x; else tmp = y ^ 2.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 4e+104], N[(1.0 - x), $MachinePrecision], N[Power[y, 2.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4 \cdot 10^{+104}:\\
\;\;\;\;1 - x\\
\mathbf{else}:\\
\;\;\;\;{y}^{2}\\
\end{array}
\end{array}
if y < 4e104Initial program 99.9%
Taylor expanded in y around 0 75.4%
if 4e104 < y Initial program 100.0%
flip-+39.7%
div-sub39.7%
pow239.7%
associate--l-39.7%
*-commutative39.7%
*-commutative39.7%
swap-sqr19.9%
add-sqr-sqrt19.9%
pow219.9%
associate--l-19.9%
Applied egg-rr19.9%
div-sub19.9%
*-commutative19.9%
Simplified19.9%
Taylor expanded in y around inf 21.1%
associate-*r*21.1%
neg-mul-121.1%
*-commutative21.1%
Simplified21.1%
Taylor expanded in x around inf 49.8%
Taylor expanded in y around 0 28.1%
Final simplification69.1%
(FPCore (x y) :precision binary64 (- 1.0 x))
double code(double x, double y) {
return 1.0 - x;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0 - x
end function
public static double code(double x, double y) {
return 1.0 - x;
}
def code(x, y): return 1.0 - x
function code(x, y) return Float64(1.0 - x) end
function tmp = code(x, y) tmp = 1.0 - x; end
code[x_, y_] := N[(1.0 - x), $MachinePrecision]
\begin{array}{l}
\\
1 - x
\end{array}
Initial program 99.9%
Taylor expanded in y around 0 65.8%
Final simplification65.8%
(FPCore (x y) :precision binary64 (- x))
double code(double x, double y) {
return -x;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = -x
end function
public static double code(double x, double y) {
return -x;
}
def code(x, y): return -x
function code(x, y) return Float64(-x) end
function tmp = code(x, y) tmp = -x; end
code[x_, y_] := (-x)
\begin{array}{l}
\\
-x
\end{array}
Initial program 99.9%
Taylor expanded in x around inf 60.9%
Taylor expanded in y around 0 31.6%
neg-mul-131.6%
Simplified31.6%
Final simplification31.6%
herbie shell --seed 2024055
(FPCore (x y)
:name "Numeric.SpecFunctions:invIncompleteBetaWorker from math-functions-0.1.5.2, E"
:precision binary64
(+ (- 1.0 x) (* y (sqrt x))))