
(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 (* (sqrt x) y)) x))
double code(double x, double y) {
return (1.0 + (sqrt(x) * y)) - x;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (1.0d0 + (sqrt(x) * y)) - x
end function
public static double code(double x, double y) {
return (1.0 + (Math.sqrt(x) * y)) - x;
}
def code(x, y): return (1.0 + (math.sqrt(x) * y)) - x
function code(x, y) return Float64(Float64(1.0 + Float64(sqrt(x) * y)) - x) end
function tmp = code(x, y) tmp = (1.0 + (sqrt(x) * y)) - x; end
code[x_, y_] := N[(N[(1.0 + N[(N[Sqrt[x], $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]
\begin{array}{l}
\\
\left(1 + \sqrt{x} \cdot y\right) - x
\end{array}
Initial program 99.9%
Taylor expanded in y around 0 99.9%
Final simplification99.9%
(FPCore (x y) :precision binary64 (if (or (<= y -2.8e+72) (not (<= y 4.5e+74))) (+ 1.0 (* (sqrt x) y)) (- 1.0 x)))
double code(double x, double y) {
double tmp;
if ((y <= -2.8e+72) || !(y <= 4.5e+74)) {
tmp = 1.0 + (sqrt(x) * y);
} 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 <= (-2.8d+72)) .or. (.not. (y <= 4.5d+74))) then
tmp = 1.0d0 + (sqrt(x) * y)
else
tmp = 1.0d0 - x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -2.8e+72) || !(y <= 4.5e+74)) {
tmp = 1.0 + (Math.sqrt(x) * y);
} else {
tmp = 1.0 - x;
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -2.8e+72) or not (y <= 4.5e+74): tmp = 1.0 + (math.sqrt(x) * y) else: tmp = 1.0 - x return tmp
function code(x, y) tmp = 0.0 if ((y <= -2.8e+72) || !(y <= 4.5e+74)) tmp = Float64(1.0 + Float64(sqrt(x) * y)); else tmp = Float64(1.0 - x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -2.8e+72) || ~((y <= 4.5e+74))) tmp = 1.0 + (sqrt(x) * y); else tmp = 1.0 - x; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -2.8e+72], N[Not[LessEqual[y, 4.5e+74]], $MachinePrecision]], N[(1.0 + N[(N[Sqrt[x], $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision], N[(1.0 - x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.8 \cdot 10^{+72} \lor \neg \left(y \leq 4.5 \cdot 10^{+74}\right):\\
\;\;\;\;1 + \sqrt{x} \cdot y\\
\mathbf{else}:\\
\;\;\;\;1 - x\\
\end{array}
\end{array}
if y < -2.7999999999999999e72 or 4.5e74 < y Initial program 99.7%
Taylor expanded in x around 0 95.0%
if -2.7999999999999999e72 < y < 4.5e74Initial program 100.0%
Taylor expanded in y around 0 95.3%
Final simplification95.2%
(FPCore (x y) :precision binary64 (if (or (<= y -5.7e+82) (not (<= y 4.4e+74))) (* (sqrt x) y) (- 1.0 x)))
double code(double x, double y) {
double tmp;
if ((y <= -5.7e+82) || !(y <= 4.4e+74)) {
tmp = sqrt(x) * y;
} 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 <= (-5.7d+82)) .or. (.not. (y <= 4.4d+74))) then
tmp = sqrt(x) * y
else
tmp = 1.0d0 - x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -5.7e+82) || !(y <= 4.4e+74)) {
tmp = Math.sqrt(x) * y;
} else {
tmp = 1.0 - x;
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -5.7e+82) or not (y <= 4.4e+74): tmp = math.sqrt(x) * y else: tmp = 1.0 - x return tmp
function code(x, y) tmp = 0.0 if ((y <= -5.7e+82) || !(y <= 4.4e+74)) tmp = Float64(sqrt(x) * y); else tmp = Float64(1.0 - x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -5.7e+82) || ~((y <= 4.4e+74))) tmp = sqrt(x) * y; else tmp = 1.0 - x; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -5.7e+82], N[Not[LessEqual[y, 4.4e+74]], $MachinePrecision]], N[(N[Sqrt[x], $MachinePrecision] * y), $MachinePrecision], N[(1.0 - x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.7 \cdot 10^{+82} \lor \neg \left(y \leq 4.4 \cdot 10^{+74}\right):\\
\;\;\;\;\sqrt{x} \cdot y\\
\mathbf{else}:\\
\;\;\;\;1 - x\\
\end{array}
\end{array}
if y < -5.70000000000000016e82 or 4.4000000000000002e74 < y Initial program 99.7%
Taylor expanded in x around inf 68.5%
Taylor expanded in y around inf 94.0%
mul-1-neg94.0%
unsub-neg94.0%
Simplified94.0%
Taylor expanded in x around 0 89.1%
if -5.70000000000000016e82 < y < 4.4000000000000002e74Initial program 100.0%
Taylor expanded in y around 0 94.7%
Final simplification92.6%
(FPCore (x y) :precision binary64 (let* ((t_0 (* (sqrt x) y))) (if (<= x 1.0) (+ 1.0 t_0) (- t_0 x))))
double code(double x, double y) {
double t_0 = sqrt(x) * y;
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 = sqrt(x) * y
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 = Math.sqrt(x) * y;
double tmp;
if (x <= 1.0) {
tmp = 1.0 + t_0;
} else {
tmp = t_0 - x;
}
return tmp;
}
def code(x, y): t_0 = math.sqrt(x) * y 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(sqrt(x) * y) 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 = sqrt(x) * y; 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[(N[Sqrt[x], $MachinePrecision] * y), $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 := \sqrt{x} \cdot y\\
\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.2%
if 1 < x Initial program 99.9%
Taylor expanded in x around inf 99.2%
Taylor expanded in x around 0 99.3%
neg-mul-199.3%
+-commutative99.3%
sub-neg99.3%
Simplified99.3%
Final simplification98.7%
(FPCore (x y) :precision binary64 (+ (- 1.0 x) (* (sqrt x) y)))
double code(double x, double y) {
return (1.0 - x) + (sqrt(x) * y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (1.0d0 - x) + (sqrt(x) * y)
end function
public static double code(double x, double y) {
return (1.0 - x) + (Math.sqrt(x) * y);
}
def code(x, y): return (1.0 - x) + (math.sqrt(x) * y)
function code(x, y) return Float64(Float64(1.0 - x) + Float64(sqrt(x) * y)) end
function tmp = code(x, y) tmp = (1.0 - x) + (sqrt(x) * y); end
code[x_, y_] := N[(N[(1.0 - x), $MachinePrecision] + N[(N[Sqrt[x], $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(1 - x\right) + \sqrt{x} \cdot y
\end{array}
Initial program 99.9%
Final simplification99.9%
(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 62.7%
Final simplification62.7%
(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 57.8%
Taylor expanded in y around 0 30.9%
neg-mul-130.9%
Simplified30.9%
Final simplification30.9%
herbie shell --seed 2024078
(FPCore (x y)
:name "Numeric.SpecFunctions:invIncompleteBetaWorker from math-functions-0.1.5.2, E"
:precision binary64
(+ (- 1.0 x) (* y (sqrt x))))