
(FPCore (x y) :precision binary64 (/ (* x (+ (/ x y) 1.0)) (+ x 1.0)))
double code(double x, double y) {
return (x * ((x / y) + 1.0)) / (x + 1.0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x * ((x / y) + 1.0d0)) / (x + 1.0d0)
end function
public static double code(double x, double y) {
return (x * ((x / y) + 1.0)) / (x + 1.0);
}
def code(x, y): return (x * ((x / y) + 1.0)) / (x + 1.0)
function code(x, y) return Float64(Float64(x * Float64(Float64(x / y) + 1.0)) / Float64(x + 1.0)) end
function tmp = code(x, y) tmp = (x * ((x / y) + 1.0)) / (x + 1.0); end
code[x_, y_] := N[(N[(x * N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (/ (* x (+ (/ x y) 1.0)) (+ x 1.0)))
double code(double x, double y) {
return (x * ((x / y) + 1.0)) / (x + 1.0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x * ((x / y) + 1.0d0)) / (x + 1.0d0)
end function
public static double code(double x, double y) {
return (x * ((x / y) + 1.0)) / (x + 1.0);
}
def code(x, y): return (x * ((x / y) + 1.0)) / (x + 1.0)
function code(x, y) return Float64(Float64(x * Float64(Float64(x / y) + 1.0)) / Float64(x + 1.0)) end
function tmp = code(x, y) tmp = (x * ((x / y) + 1.0)) / (x + 1.0); end
code[x_, y_] := N[(N[(x * N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1}
\end{array}
(FPCore (x y) :precision binary64 (let* ((t_0 (/ (* x (+ (/ x y) 1.0)) (+ x 1.0))) (t_1 (+ y (/ y x)))) (if (<= t_0 -1e+100) (/ x t_1) (if (<= t_0 2e-34) t_0 (/ (+ x y) t_1)))))
double code(double x, double y) {
double t_0 = (x * ((x / y) + 1.0)) / (x + 1.0);
double t_1 = y + (y / x);
double tmp;
if (t_0 <= -1e+100) {
tmp = x / t_1;
} else if (t_0 <= 2e-34) {
tmp = t_0;
} else {
tmp = (x + y) / t_1;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (x * ((x / y) + 1.0d0)) / (x + 1.0d0)
t_1 = y + (y / x)
if (t_0 <= (-1d+100)) then
tmp = x / t_1
else if (t_0 <= 2d-34) then
tmp = t_0
else
tmp = (x + y) / t_1
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = (x * ((x / y) + 1.0)) / (x + 1.0);
double t_1 = y + (y / x);
double tmp;
if (t_0 <= -1e+100) {
tmp = x / t_1;
} else if (t_0 <= 2e-34) {
tmp = t_0;
} else {
tmp = (x + y) / t_1;
}
return tmp;
}
def code(x, y): t_0 = (x * ((x / y) + 1.0)) / (x + 1.0) t_1 = y + (y / x) tmp = 0 if t_0 <= -1e+100: tmp = x / t_1 elif t_0 <= 2e-34: tmp = t_0 else: tmp = (x + y) / t_1 return tmp
function code(x, y) t_0 = Float64(Float64(x * Float64(Float64(x / y) + 1.0)) / Float64(x + 1.0)) t_1 = Float64(y + Float64(y / x)) tmp = 0.0 if (t_0 <= -1e+100) tmp = Float64(x / t_1); elseif (t_0 <= 2e-34) tmp = t_0; else tmp = Float64(Float64(x + y) / t_1); end return tmp end
function tmp_2 = code(x, y) t_0 = (x * ((x / y) + 1.0)) / (x + 1.0); t_1 = y + (y / x); tmp = 0.0; if (t_0 <= -1e+100) tmp = x / t_1; elseif (t_0 <= 2e-34) tmp = t_0; else tmp = (x + y) / t_1; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(x * N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(y + N[(y / x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -1e+100], N[(x / t$95$1), $MachinePrecision], If[LessEqual[t$95$0, 2e-34], t$95$0, N[(N[(x + y), $MachinePrecision] / t$95$1), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1}\\
t_1 := y + \frac{y}{x}\\
\mathbf{if}\;t_0 \leq -1 \cdot 10^{+100}:\\
\;\;\;\;\frac{x}{t_1}\\
\mathbf{elif}\;t_0 \leq 2 \cdot 10^{-34}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{x + y}{t_1}\\
\end{array}
\end{array}
if (/.f64 (*.f64 x (+.f64 (/.f64 x y) 1)) (+.f64 x 1)) < -1.00000000000000002e100Initial program 60.2%
*-commutative60.2%
associate-/l*99.9%
remove-double-neg99.9%
neg-mul-199.9%
*-commutative99.9%
associate-/r*99.9%
+-commutative99.9%
remove-double-neg99.9%
unsub-neg99.9%
div-sub100.0%
*-inverses100.0%
div-sub100.0%
associate-/r*100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 100.0%
distribute-lft-in100.0%
*-rgt-identity100.0%
associate-*r/100.0%
*-rgt-identity100.0%
Simplified100.0%
if -1.00000000000000002e100 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) 1)) (+.f64 x 1)) < 1.99999999999999986e-34Initial program 99.9%
if 1.99999999999999986e-34 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) 1)) (+.f64 x 1)) Initial program 78.7%
*-commutative78.7%
associate-/l*99.9%
remove-double-neg99.9%
neg-mul-199.9%
*-commutative99.9%
associate-/r*99.9%
+-commutative99.9%
remove-double-neg99.9%
unsub-neg99.9%
div-sub99.9%
*-inverses99.9%
div-sub99.9%
associate-/r*99.9%
*-commutative99.9%
neg-mul-199.9%
remove-double-neg99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around 0 99.9%
+-commutative99.9%
associate-/r*99.9%
Simplified99.9%
+-commutative99.9%
associate-/l/99.9%
frac-add99.8%
*-un-lft-identity99.8%
*-commutative99.8%
*-commutative99.8%
Applied egg-rr99.8%
associate-/r*99.9%
div-inv99.6%
*-commutative99.6%
distribute-lft-out99.6%
distribute-lft-in99.6%
*-rgt-identity99.6%
un-div-inv99.7%
Applied egg-rr99.7%
associate-*r/99.9%
*-rgt-identity99.9%
associate-/l*99.7%
associate-/r/100.0%
*-inverses100.0%
*-lft-identity100.0%
+-commutative100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x y) :precision binary64 (if (or (<= x -2.1e-43) (not (<= x 6e-23))) (/ (+ x y) (+ y (/ y x))) (+ x (/ (/ x y) (+ 1.0 (/ 1.0 x))))))
double code(double x, double y) {
double tmp;
if ((x <= -2.1e-43) || !(x <= 6e-23)) {
tmp = (x + y) / (y + (y / x));
} else {
tmp = x + ((x / y) / (1.0 + (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 ((x <= (-2.1d-43)) .or. (.not. (x <= 6d-23))) then
tmp = (x + y) / (y + (y / x))
else
tmp = x + ((x / y) / (1.0d0 + (1.0d0 / x)))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -2.1e-43) || !(x <= 6e-23)) {
tmp = (x + y) / (y + (y / x));
} else {
tmp = x + ((x / y) / (1.0 + (1.0 / x)));
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -2.1e-43) or not (x <= 6e-23): tmp = (x + y) / (y + (y / x)) else: tmp = x + ((x / y) / (1.0 + (1.0 / x))) return tmp
function code(x, y) tmp = 0.0 if ((x <= -2.1e-43) || !(x <= 6e-23)) tmp = Float64(Float64(x + y) / Float64(y + Float64(y / x))); else tmp = Float64(x + Float64(Float64(x / y) / Float64(1.0 + Float64(1.0 / x)))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -2.1e-43) || ~((x <= 6e-23))) tmp = (x + y) / (y + (y / x)); else tmp = x + ((x / y) / (1.0 + (1.0 / x))); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -2.1e-43], N[Not[LessEqual[x, 6e-23]], $MachinePrecision]], N[(N[(x + y), $MachinePrecision] / N[(y + N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(x / y), $MachinePrecision] / N[(1.0 + N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.1 \cdot 10^{-43} \lor \neg \left(x \leq 6 \cdot 10^{-23}\right):\\
\;\;\;\;\frac{x + y}{y + \frac{y}{x}}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{\frac{x}{y}}{1 + \frac{1}{x}}\\
\end{array}
\end{array}
if x < -2.1000000000000001e-43 or 6.00000000000000006e-23 < x Initial program 74.5%
*-commutative74.5%
associate-/l*100.0%
remove-double-neg100.0%
neg-mul-1100.0%
*-commutative100.0%
associate-/r*100.0%
+-commutative100.0%
remove-double-neg100.0%
unsub-neg100.0%
div-sub100.0%
*-inverses100.0%
div-sub100.0%
associate-/r*100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 100.0%
+-commutative100.0%
associate-/r*100.0%
Simplified100.0%
+-commutative100.0%
associate-/l/100.0%
frac-add99.9%
*-un-lft-identity99.9%
*-commutative99.9%
*-commutative99.9%
Applied egg-rr99.9%
associate-/r*99.9%
div-inv99.7%
*-commutative99.7%
distribute-lft-out99.7%
distribute-lft-in99.7%
*-rgt-identity99.7%
un-div-inv99.7%
Applied egg-rr99.7%
associate-*r/100.0%
*-rgt-identity100.0%
associate-/l*99.8%
associate-/r/100.0%
*-inverses100.0%
*-lft-identity100.0%
+-commutative100.0%
Simplified100.0%
if -2.1000000000000001e-43 < x < 6.00000000000000006e-23Initial program 99.9%
*-commutative99.9%
associate-/l*99.6%
remove-double-neg99.6%
neg-mul-199.6%
*-commutative99.6%
associate-/r*99.6%
+-commutative99.6%
remove-double-neg99.6%
unsub-neg99.6%
div-sub99.6%
*-inverses99.6%
div-sub99.6%
associate-/r*99.6%
*-commutative99.6%
neg-mul-199.6%
remove-double-neg99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in y around 0 99.7%
+-commutative99.7%
associate-/r*99.7%
Simplified99.7%
Taylor expanded in x around 0 99.9%
Final simplification99.9%
(FPCore (x y) :precision binary64 (if (or (<= y -5.5e+168) (not (<= y 3.2e+149))) (/ x (+ x 1.0)) (/ (+ x y) (+ y (/ y x)))))
double code(double x, double y) {
double tmp;
if ((y <= -5.5e+168) || !(y <= 3.2e+149)) {
tmp = x / (x + 1.0);
} else {
tmp = (x + y) / (y + (y / 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.5d+168)) .or. (.not. (y <= 3.2d+149))) then
tmp = x / (x + 1.0d0)
else
tmp = (x + y) / (y + (y / x))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -5.5e+168) || !(y <= 3.2e+149)) {
tmp = x / (x + 1.0);
} else {
tmp = (x + y) / (y + (y / x));
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -5.5e+168) or not (y <= 3.2e+149): tmp = x / (x + 1.0) else: tmp = (x + y) / (y + (y / x)) return tmp
function code(x, y) tmp = 0.0 if ((y <= -5.5e+168) || !(y <= 3.2e+149)) tmp = Float64(x / Float64(x + 1.0)); else tmp = Float64(Float64(x + y) / Float64(y + Float64(y / x))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -5.5e+168) || ~((y <= 3.2e+149))) tmp = x / (x + 1.0); else tmp = (x + y) / (y + (y / x)); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -5.5e+168], N[Not[LessEqual[y, 3.2e+149]], $MachinePrecision]], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(x + y), $MachinePrecision] / N[(y + N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.5 \cdot 10^{+168} \lor \neg \left(y \leq 3.2 \cdot 10^{+149}\right):\\
\;\;\;\;\frac{x}{x + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{x + y}{y + \frac{y}{x}}\\
\end{array}
\end{array}
if y < -5.5000000000000001e168 or 3.2000000000000002e149 < y Initial program 100.0%
Taylor expanded in y around inf 96.6%
+-commutative96.6%
Simplified96.6%
if -5.5000000000000001e168 < y < 3.2000000000000002e149Initial program 81.0%
*-commutative81.0%
associate-/l*99.8%
remove-double-neg99.8%
neg-mul-199.8%
*-commutative99.8%
associate-/r*99.8%
+-commutative99.8%
remove-double-neg99.8%
unsub-neg99.8%
div-sub99.8%
*-inverses99.8%
div-sub99.8%
associate-/r*99.8%
*-commutative99.8%
neg-mul-199.8%
remove-double-neg99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around 0 99.8%
+-commutative99.8%
associate-/r*99.8%
Simplified99.8%
+-commutative99.8%
associate-/l/99.8%
frac-add83.2%
*-un-lft-identity83.2%
*-commutative83.2%
*-commutative83.2%
Applied egg-rr83.2%
associate-/r*96.2%
div-inv95.9%
*-commutative95.9%
distribute-lft-out95.9%
distribute-lft-in95.9%
*-rgt-identity95.9%
un-div-inv95.9%
Applied egg-rr95.9%
associate-*r/96.2%
*-rgt-identity96.2%
associate-/l*86.0%
associate-/r/96.7%
*-inverses96.7%
*-lft-identity96.7%
+-commutative96.7%
Simplified96.7%
Final simplification96.7%
(FPCore (x y) :precision binary64 (if (or (<= x -58000000000.0) (not (<= x 3500.0))) (+ 1.0 (/ (+ x -1.0) y)) (/ x (+ x 1.0))))
double code(double x, double y) {
double tmp;
if ((x <= -58000000000.0) || !(x <= 3500.0)) {
tmp = 1.0 + ((x + -1.0) / y);
} else {
tmp = x / (x + 1.0);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((x <= (-58000000000.0d0)) .or. (.not. (x <= 3500.0d0))) then
tmp = 1.0d0 + ((x + (-1.0d0)) / y)
else
tmp = x / (x + 1.0d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -58000000000.0) || !(x <= 3500.0)) {
tmp = 1.0 + ((x + -1.0) / y);
} else {
tmp = x / (x + 1.0);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -58000000000.0) or not (x <= 3500.0): tmp = 1.0 + ((x + -1.0) / y) else: tmp = x / (x + 1.0) return tmp
function code(x, y) tmp = 0.0 if ((x <= -58000000000.0) || !(x <= 3500.0)) tmp = Float64(1.0 + Float64(Float64(x + -1.0) / y)); else tmp = Float64(x / Float64(x + 1.0)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -58000000000.0) || ~((x <= 3500.0))) tmp = 1.0 + ((x + -1.0) / y); else tmp = x / (x + 1.0); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -58000000000.0], N[Not[LessEqual[x, 3500.0]], $MachinePrecision]], N[(1.0 + N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -58000000000 \lor \neg \left(x \leq 3500\right):\\
\;\;\;\;1 + \frac{x + -1}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{x + 1}\\
\end{array}
\end{array}
if x < -5.8e10 or 3500 < x Initial program 71.6%
Taylor expanded in x around inf 99.5%
associate--l+99.5%
+-commutative99.5%
sub-div99.5%
sub-neg99.5%
metadata-eval99.5%
Applied egg-rr99.5%
if -5.8e10 < x < 3500Initial program 99.9%
Taylor expanded in y around inf 77.5%
+-commutative77.5%
Simplified77.5%
Final simplification88.6%
(FPCore (x y) :precision binary64 (let* ((t_0 (+ 1.0 (/ 1.0 x)))) (+ (/ (/ x y) t_0) (/ 1.0 t_0))))
double code(double x, double y) {
double t_0 = 1.0 + (1.0 / x);
return ((x / y) / t_0) + (1.0 / t_0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
t_0 = 1.0d0 + (1.0d0 / x)
code = ((x / y) / t_0) + (1.0d0 / t_0)
end function
public static double code(double x, double y) {
double t_0 = 1.0 + (1.0 / x);
return ((x / y) / t_0) + (1.0 / t_0);
}
def code(x, y): t_0 = 1.0 + (1.0 / x) return ((x / y) / t_0) + (1.0 / t_0)
function code(x, y) t_0 = Float64(1.0 + Float64(1.0 / x)) return Float64(Float64(Float64(x / y) / t_0) + Float64(1.0 / t_0)) end
function tmp = code(x, y) t_0 = 1.0 + (1.0 / x); tmp = ((x / y) / t_0) + (1.0 / t_0); end
code[x_, y_] := Block[{t$95$0 = N[(1.0 + N[(1.0 / x), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[(x / y), $MachinePrecision] / t$95$0), $MachinePrecision] + N[(1.0 / t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{1}{x}\\
\frac{\frac{x}{y}}{t_0} + \frac{1}{t_0}
\end{array}
\end{array}
Initial program 85.6%
*-commutative85.6%
associate-/l*99.8%
remove-double-neg99.8%
neg-mul-199.8%
*-commutative99.8%
associate-/r*99.8%
+-commutative99.8%
remove-double-neg99.8%
unsub-neg99.8%
div-sub99.8%
*-inverses99.8%
div-sub99.8%
associate-/r*99.8%
*-commutative99.8%
neg-mul-199.8%
remove-double-neg99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around 0 99.8%
+-commutative99.8%
associate-/r*99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (x y) :precision binary64 (if (or (<= x -2.5e+42) (not (<= x 4.5e+95))) (/ x y) (/ x (+ x 1.0))))
double code(double x, double y) {
double tmp;
if ((x <= -2.5e+42) || !(x <= 4.5e+95)) {
tmp = x / y;
} else {
tmp = x / (x + 1.0);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((x <= (-2.5d+42)) .or. (.not. (x <= 4.5d+95))) then
tmp = x / y
else
tmp = x / (x + 1.0d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -2.5e+42) || !(x <= 4.5e+95)) {
tmp = x / y;
} else {
tmp = x / (x + 1.0);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -2.5e+42) or not (x <= 4.5e+95): tmp = x / y else: tmp = x / (x + 1.0) return tmp
function code(x, y) tmp = 0.0 if ((x <= -2.5e+42) || !(x <= 4.5e+95)) tmp = Float64(x / y); else tmp = Float64(x / Float64(x + 1.0)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -2.5e+42) || ~((x <= 4.5e+95))) tmp = x / y; else tmp = x / (x + 1.0); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -2.5e+42], N[Not[LessEqual[x, 4.5e+95]], $MachinePrecision]], N[(x / y), $MachinePrecision], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.5 \cdot 10^{+42} \lor \neg \left(x \leq 4.5 \cdot 10^{+95}\right):\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{x + 1}\\
\end{array}
\end{array}
if x < -2.50000000000000003e42 or 4.50000000000000017e95 < x Initial program 66.5%
Taylor expanded in x around inf 82.7%
if -2.50000000000000003e42 < x < 4.50000000000000017e95Initial program 98.7%
Taylor expanded in y around inf 74.2%
+-commutative74.2%
Simplified74.2%
Final simplification77.7%
(FPCore (x y) :precision binary64 (if (or (<= x -1.0) (not (<= x 3.6e-5))) (/ x y) x))
double code(double x, double y) {
double tmp;
if ((x <= -1.0) || !(x <= 3.6e-5)) {
tmp = x / y;
} else {
tmp = x;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((x <= (-1.0d0)) .or. (.not. (x <= 3.6d-5))) then
tmp = x / y
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -1.0) || !(x <= 3.6e-5)) {
tmp = x / y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -1.0) or not (x <= 3.6e-5): tmp = x / y else: tmp = x return tmp
function code(x, y) tmp = 0.0 if ((x <= -1.0) || !(x <= 3.6e-5)) tmp = Float64(x / y); else tmp = x; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -1.0) || ~((x <= 3.6e-5))) tmp = x / y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -1.0], N[Not[LessEqual[x, 3.6e-5]], $MachinePrecision]], N[(x / y), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 3.6 \cdot 10^{-5}\right):\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -1 or 3.60000000000000009e-5 < x Initial program 72.2%
Taylor expanded in x around inf 73.5%
if -1 < x < 3.60000000000000009e-5Initial program 99.9%
Taylor expanded in x around 0 76.8%
Final simplification75.1%
(FPCore (x y) :precision binary64 (/ (+ (/ x y) 1.0) (- (/ 1.0 x) -1.0)))
double code(double x, double y) {
return ((x / y) + 1.0) / ((1.0 / x) - -1.0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((x / y) + 1.0d0) / ((1.0d0 / x) - (-1.0d0))
end function
public static double code(double x, double y) {
return ((x / y) + 1.0) / ((1.0 / x) - -1.0);
}
def code(x, y): return ((x / y) + 1.0) / ((1.0 / x) - -1.0)
function code(x, y) return Float64(Float64(Float64(x / y) + 1.0) / Float64(Float64(1.0 / x) - -1.0)) end
function tmp = code(x, y) tmp = ((x / y) + 1.0) / ((1.0 / x) - -1.0); end
code[x_, y_] := N[(N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision] / N[(N[(1.0 / x), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{x}{y} + 1}{\frac{1}{x} - -1}
\end{array}
Initial program 85.6%
*-commutative85.6%
associate-/l*99.8%
remove-double-neg99.8%
neg-mul-199.8%
*-commutative99.8%
associate-/r*99.8%
+-commutative99.8%
remove-double-neg99.8%
unsub-neg99.8%
div-sub99.8%
*-inverses99.8%
div-sub99.8%
associate-/r*99.8%
*-commutative99.8%
neg-mul-199.8%
remove-double-neg99.8%
metadata-eval99.8%
Simplified99.8%
Final simplification99.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 x end
function tmp = code(x, y) tmp = x; end
code[x_, y_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 85.6%
Taylor expanded in x around 0 39.3%
Final simplification39.3%
(FPCore (x y) :precision binary64 (* (/ x 1.0) (/ (+ (/ x y) 1.0) (+ x 1.0))))
double code(double x, double y) {
return (x / 1.0) * (((x / y) + 1.0) / (x + 1.0));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x / 1.0d0) * (((x / y) + 1.0d0) / (x + 1.0d0))
end function
public static double code(double x, double y) {
return (x / 1.0) * (((x / y) + 1.0) / (x + 1.0));
}
def code(x, y): return (x / 1.0) * (((x / y) + 1.0) / (x + 1.0))
function code(x, y) return Float64(Float64(x / 1.0) * Float64(Float64(Float64(x / y) + 1.0) / Float64(x + 1.0))) end
function tmp = code(x, y) tmp = (x / 1.0) * (((x / y) + 1.0) / (x + 1.0)); end
code[x_, y_] := N[(N[(x / 1.0), $MachinePrecision] * N[(N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{1} \cdot \frac{\frac{x}{y} + 1}{x + 1}
\end{array}
herbie shell --seed 2024026
(FPCore (x y)
:name "Codec.Picture.Types:toneMapping from JuicyPixels-3.2.6.1"
:precision binary64
:herbie-target
(* (/ x 1.0) (/ (+ (/ x y) 1.0) (+ x 1.0)))
(/ (* x (+ (/ x y) 1.0)) (+ x 1.0)))