
(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 12 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 (/ x (/ (+ x 1.0) (+ 1.0 (/ x y)))))
double code(double x, double y) {
return x / ((x + 1.0) / (1.0 + (x / y)));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x / ((x + 1.0d0) / (1.0d0 + (x / y)))
end function
public static double code(double x, double y) {
return x / ((x + 1.0) / (1.0 + (x / y)));
}
def code(x, y): return x / ((x + 1.0) / (1.0 + (x / y)))
function code(x, y) return Float64(x / Float64(Float64(x + 1.0) / Float64(1.0 + Float64(x / y)))) end
function tmp = code(x, y) tmp = x / ((x + 1.0) / (1.0 + (x / y))); end
code[x_, y_] := N[(x / N[(N[(x + 1.0), $MachinePrecision] / N[(1.0 + N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{\frac{x + 1}{1 + \frac{x}{y}}}
\end{array}
Initial program 87.7%
associate-/l*99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ x (/ y x))) (t_1 (/ (+ x -1.0) y)))
(if (<= x -1.75e+56)
(/ x y)
(if (<= x -1.52e+32)
1.0
(if (<= x -1.0)
t_1
(if (<= x -6.2e-45)
t_0
(if (<= x 3.2e-127) x (if (<= x 1.3) t_0 t_1))))))))
double code(double x, double y) {
double t_0 = x / (y / x);
double t_1 = (x + -1.0) / y;
double tmp;
if (x <= -1.75e+56) {
tmp = x / y;
} else if (x <= -1.52e+32) {
tmp = 1.0;
} else if (x <= -1.0) {
tmp = t_1;
} else if (x <= -6.2e-45) {
tmp = t_0;
} else if (x <= 3.2e-127) {
tmp = x;
} else if (x <= 1.3) {
tmp = t_0;
} else {
tmp = 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 / (y / x)
t_1 = (x + (-1.0d0)) / y
if (x <= (-1.75d+56)) then
tmp = x / y
else if (x <= (-1.52d+32)) then
tmp = 1.0d0
else if (x <= (-1.0d0)) then
tmp = t_1
else if (x <= (-6.2d-45)) then
tmp = t_0
else if (x <= 3.2d-127) then
tmp = x
else if (x <= 1.3d0) then
tmp = t_0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = x / (y / x);
double t_1 = (x + -1.0) / y;
double tmp;
if (x <= -1.75e+56) {
tmp = x / y;
} else if (x <= -1.52e+32) {
tmp = 1.0;
} else if (x <= -1.0) {
tmp = t_1;
} else if (x <= -6.2e-45) {
tmp = t_0;
} else if (x <= 3.2e-127) {
tmp = x;
} else if (x <= 1.3) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y): t_0 = x / (y / x) t_1 = (x + -1.0) / y tmp = 0 if x <= -1.75e+56: tmp = x / y elif x <= -1.52e+32: tmp = 1.0 elif x <= -1.0: tmp = t_1 elif x <= -6.2e-45: tmp = t_0 elif x <= 3.2e-127: tmp = x elif x <= 1.3: tmp = t_0 else: tmp = t_1 return tmp
function code(x, y) t_0 = Float64(x / Float64(y / x)) t_1 = Float64(Float64(x + -1.0) / y) tmp = 0.0 if (x <= -1.75e+56) tmp = Float64(x / y); elseif (x <= -1.52e+32) tmp = 1.0; elseif (x <= -1.0) tmp = t_1; elseif (x <= -6.2e-45) tmp = t_0; elseif (x <= 3.2e-127) tmp = x; elseif (x <= 1.3) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y) t_0 = x / (y / x); t_1 = (x + -1.0) / y; tmp = 0.0; if (x <= -1.75e+56) tmp = x / y; elseif (x <= -1.52e+32) tmp = 1.0; elseif (x <= -1.0) tmp = t_1; elseif (x <= -6.2e-45) tmp = t_0; elseif (x <= 3.2e-127) tmp = x; elseif (x <= 1.3) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x / N[(y / x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision]}, If[LessEqual[x, -1.75e+56], N[(x / y), $MachinePrecision], If[LessEqual[x, -1.52e+32], 1.0, If[LessEqual[x, -1.0], t$95$1, If[LessEqual[x, -6.2e-45], t$95$0, If[LessEqual[x, 3.2e-127], x, If[LessEqual[x, 1.3], t$95$0, t$95$1]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{\frac{y}{x}}\\
t_1 := \frac{x + -1}{y}\\
\mathbf{if}\;x \leq -1.75 \cdot 10^{+56}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq -1.52 \cdot 10^{+32}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq -1:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq -6.2 \cdot 10^{-45}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 3.2 \cdot 10^{-127}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 1.3:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if x < -1.75e56Initial program 74.7%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around inf 87.9%
if -1.75e56 < x < -1.5200000000000001e32Initial program 100.0%
distribute-lft-in100.0%
*-rgt-identity100.0%
Applied egg-rr100.0%
Taylor expanded in y around inf 86.4%
+-commutative86.4%
Simplified86.4%
Taylor expanded in x around inf 86.4%
if -1.5200000000000001e32 < x < -1 or 1.30000000000000004 < x Initial program 78.9%
Taylor expanded in x around inf 54.8%
unpow254.8%
associate-*r/59.1%
Simplified59.1%
Taylor expanded in x around inf 80.1%
Taylor expanded in y around 0 80.1%
if -1 < x < -6.2000000000000002e-45 or 3.20000000000000017e-127 < x < 1.30000000000000004Initial program 99.5%
associate-/l*99.5%
Simplified99.5%
Taylor expanded in x around inf 68.6%
associate--l+68.6%
div-sub68.7%
unpow268.7%
Simplified68.7%
Taylor expanded in y around 0 68.9%
Taylor expanded in x around 0 61.2%
if -6.2000000000000002e-45 < x < 3.20000000000000017e-127Initial program 99.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around 0 87.3%
Final simplification82.5%
(FPCore (x y)
:precision binary64
(if (<= x -1e+56)
(/ x y)
(if (<= x -1.35e+32)
1.0
(if (<= x -1.0)
(/ x y)
(if (<= x 6.8e-51) x (if (<= x 1.0) (* x (/ x y)) (/ x y)))))))
double code(double x, double y) {
double tmp;
if (x <= -1e+56) {
tmp = x / y;
} else if (x <= -1.35e+32) {
tmp = 1.0;
} else if (x <= -1.0) {
tmp = x / y;
} else if (x <= 6.8e-51) {
tmp = x;
} else if (x <= 1.0) {
tmp = x * (x / y);
} else {
tmp = x / y;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-1d+56)) then
tmp = x / y
else if (x <= (-1.35d+32)) then
tmp = 1.0d0
else if (x <= (-1.0d0)) then
tmp = x / y
else if (x <= 6.8d-51) then
tmp = x
else if (x <= 1.0d0) then
tmp = x * (x / y)
else
tmp = x / y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -1e+56) {
tmp = x / y;
} else if (x <= -1.35e+32) {
tmp = 1.0;
} else if (x <= -1.0) {
tmp = x / y;
} else if (x <= 6.8e-51) {
tmp = x;
} else if (x <= 1.0) {
tmp = x * (x / y);
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1e+56: tmp = x / y elif x <= -1.35e+32: tmp = 1.0 elif x <= -1.0: tmp = x / y elif x <= 6.8e-51: tmp = x elif x <= 1.0: tmp = x * (x / y) else: tmp = x / y return tmp
function code(x, y) tmp = 0.0 if (x <= -1e+56) tmp = Float64(x / y); elseif (x <= -1.35e+32) tmp = 1.0; elseif (x <= -1.0) tmp = Float64(x / y); elseif (x <= 6.8e-51) tmp = x; elseif (x <= 1.0) tmp = Float64(x * Float64(x / y)); else tmp = Float64(x / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1e+56) tmp = x / y; elseif (x <= -1.35e+32) tmp = 1.0; elseif (x <= -1.0) tmp = x / y; elseif (x <= 6.8e-51) tmp = x; elseif (x <= 1.0) tmp = x * (x / y); else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1e+56], N[(x / y), $MachinePrecision], If[LessEqual[x, -1.35e+32], 1.0, If[LessEqual[x, -1.0], N[(x / y), $MachinePrecision], If[LessEqual[x, 6.8e-51], x, If[LessEqual[x, 1.0], N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision], N[(x / y), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \cdot 10^{+56}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq -1.35 \cdot 10^{+32}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq -1:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq 6.8 \cdot 10^{-51}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;x \cdot \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -1.00000000000000009e56 or -1.35000000000000006e32 < x < -1 or 1 < x Initial program 76.9%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around inf 83.6%
if -1.00000000000000009e56 < x < -1.35000000000000006e32Initial program 100.0%
distribute-lft-in100.0%
*-rgt-identity100.0%
Applied egg-rr100.0%
Taylor expanded in y around inf 86.4%
+-commutative86.4%
Simplified86.4%
Taylor expanded in x around inf 86.4%
if -1 < x < 6.80000000000000005e-51Initial program 99.8%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around 0 78.7%
if 6.80000000000000005e-51 < x < 1Initial program 99.5%
associate-/l*99.5%
Simplified99.5%
Taylor expanded in x around inf 75.4%
associate--l+75.4%
div-sub75.4%
unpow275.4%
Simplified75.4%
Taylor expanded in y around 0 75.7%
Taylor expanded in x around 0 68.4%
associate-/r/68.3%
Applied egg-rr68.3%
Final simplification81.0%
(FPCore (x y)
:precision binary64
(if (<= x -1e+56)
(/ x y)
(if (<= x -1.52e+32)
1.0
(if (<= x -1.0)
(/ x y)
(if (<= x 1.26e-50)
(- x (* x x))
(if (<= x 1.0) (* x (/ x y)) (/ x y)))))))
double code(double x, double y) {
double tmp;
if (x <= -1e+56) {
tmp = x / y;
} else if (x <= -1.52e+32) {
tmp = 1.0;
} else if (x <= -1.0) {
tmp = x / y;
} else if (x <= 1.26e-50) {
tmp = x - (x * x);
} else if (x <= 1.0) {
tmp = x * (x / y);
} else {
tmp = x / y;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-1d+56)) then
tmp = x / y
else if (x <= (-1.52d+32)) then
tmp = 1.0d0
else if (x <= (-1.0d0)) then
tmp = x / y
else if (x <= 1.26d-50) then
tmp = x - (x * x)
else if (x <= 1.0d0) then
tmp = x * (x / y)
else
tmp = x / y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -1e+56) {
tmp = x / y;
} else if (x <= -1.52e+32) {
tmp = 1.0;
} else if (x <= -1.0) {
tmp = x / y;
} else if (x <= 1.26e-50) {
tmp = x - (x * x);
} else if (x <= 1.0) {
tmp = x * (x / y);
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1e+56: tmp = x / y elif x <= -1.52e+32: tmp = 1.0 elif x <= -1.0: tmp = x / y elif x <= 1.26e-50: tmp = x - (x * x) elif x <= 1.0: tmp = x * (x / y) else: tmp = x / y return tmp
function code(x, y) tmp = 0.0 if (x <= -1e+56) tmp = Float64(x / y); elseif (x <= -1.52e+32) tmp = 1.0; elseif (x <= -1.0) tmp = Float64(x / y); elseif (x <= 1.26e-50) tmp = Float64(x - Float64(x * x)); elseif (x <= 1.0) tmp = Float64(x * Float64(x / y)); else tmp = Float64(x / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1e+56) tmp = x / y; elseif (x <= -1.52e+32) tmp = 1.0; elseif (x <= -1.0) tmp = x / y; elseif (x <= 1.26e-50) tmp = x - (x * x); elseif (x <= 1.0) tmp = x * (x / y); else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1e+56], N[(x / y), $MachinePrecision], If[LessEqual[x, -1.52e+32], 1.0, If[LessEqual[x, -1.0], N[(x / y), $MachinePrecision], If[LessEqual[x, 1.26e-50], N[(x - N[(x * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.0], N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision], N[(x / y), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \cdot 10^{+56}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq -1.52 \cdot 10^{+32}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq -1:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq 1.26 \cdot 10^{-50}:\\
\;\;\;\;x - x \cdot x\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;x \cdot \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -1.00000000000000009e56 or -1.5200000000000001e32 < x < -1 or 1 < x Initial program 76.9%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around inf 83.6%
if -1.00000000000000009e56 < x < -1.5200000000000001e32Initial program 100.0%
distribute-lft-in100.0%
*-rgt-identity100.0%
Applied egg-rr100.0%
Taylor expanded in y around inf 86.4%
+-commutative86.4%
Simplified86.4%
Taylor expanded in x around inf 86.4%
if -1 < x < 1.26e-50Initial program 99.8%
distribute-lft-in99.8%
*-rgt-identity99.8%
Applied egg-rr99.8%
Taylor expanded in y around inf 79.0%
+-commutative79.0%
Simplified79.0%
Taylor expanded in x around 0 79.1%
mul-1-neg79.1%
unsub-neg79.1%
unpow279.1%
Simplified79.1%
if 1.26e-50 < x < 1Initial program 99.5%
associate-/l*99.5%
Simplified99.5%
Taylor expanded in x around inf 75.4%
associate--l+75.4%
div-sub75.4%
unpow275.4%
Simplified75.4%
Taylor expanded in y around 0 75.7%
Taylor expanded in x around 0 68.4%
associate-/r/68.3%
Applied egg-rr68.3%
Final simplification81.1%
(FPCore (x y) :precision binary64 (if (or (<= x -1.0) (not (<= x 1.0))) (+ 1.0 (/ (+ x -1.0) y)) (+ x (* (* x x) (+ -1.0 (/ 1.0 y))))))
double code(double x, double y) {
double tmp;
if ((x <= -1.0) || !(x <= 1.0)) {
tmp = 1.0 + ((x + -1.0) / y);
} else {
tmp = x + ((x * x) * (-1.0 + (1.0 / y)));
}
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 <= 1.0d0))) then
tmp = 1.0d0 + ((x + (-1.0d0)) / y)
else
tmp = x + ((x * x) * ((-1.0d0) + (1.0d0 / y)))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -1.0) || !(x <= 1.0)) {
tmp = 1.0 + ((x + -1.0) / y);
} else {
tmp = x + ((x * x) * (-1.0 + (1.0 / y)));
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -1.0) or not (x <= 1.0): tmp = 1.0 + ((x + -1.0) / y) else: tmp = x + ((x * x) * (-1.0 + (1.0 / y))) return tmp
function code(x, y) tmp = 0.0 if ((x <= -1.0) || !(x <= 1.0)) tmp = Float64(1.0 + Float64(Float64(x + -1.0) / y)); else tmp = Float64(x + Float64(Float64(x * x) * Float64(-1.0 + Float64(1.0 / y)))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -1.0) || ~((x <= 1.0))) tmp = 1.0 + ((x + -1.0) / y); else tmp = x + ((x * x) * (-1.0 + (1.0 / y))); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -1.0], N[Not[LessEqual[x, 1.0]], $MachinePrecision]], N[(1.0 + N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(x * x), $MachinePrecision] * N[(-1.0 + N[(1.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 1\right):\\
\;\;\;\;1 + \frac{x + -1}{y}\\
\mathbf{else}:\\
\;\;\;\;x + \left(x \cdot x\right) \cdot \left(-1 + \frac{1}{y}\right)\\
\end{array}
\end{array}
if x < -1 or 1 < x Initial program 78.1%
flip-+38.3%
associate-*r/33.6%
metadata-eval33.6%
sub-neg33.6%
pow233.6%
metadata-eval33.6%
sub-neg33.6%
metadata-eval33.6%
Applied egg-rr33.6%
*-commutative33.6%
associate-/l*38.2%
+-commutative38.2%
+-commutative38.2%
Simplified38.2%
Taylor expanded in x around inf 99.3%
associate--l+99.3%
div-sub99.3%
sub-neg99.3%
metadata-eval99.3%
+-commutative99.3%
Simplified99.3%
if -1 < x < 1Initial program 99.8%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around 0 91.9%
unpow291.9%
sub-neg91.9%
metadata-eval91.9%
Simplified91.9%
Final simplification96.0%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ 1.0 (/ (+ x -1.0) y))))
(if (<= x -290000000.0)
t_0
(if (<= x 5.2e-127) (/ x (+ x 1.0)) (if (<= x 0.95) (/ x (/ y x)) t_0)))))
double code(double x, double y) {
double t_0 = 1.0 + ((x + -1.0) / y);
double tmp;
if (x <= -290000000.0) {
tmp = t_0;
} else if (x <= 5.2e-127) {
tmp = x / (x + 1.0);
} else if (x <= 0.95) {
tmp = x / (y / 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 + ((x + (-1.0d0)) / y)
if (x <= (-290000000.0d0)) then
tmp = t_0
else if (x <= 5.2d-127) then
tmp = x / (x + 1.0d0)
else if (x <= 0.95d0) then
tmp = x / (y / x)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = 1.0 + ((x + -1.0) / y);
double tmp;
if (x <= -290000000.0) {
tmp = t_0;
} else if (x <= 5.2e-127) {
tmp = x / (x + 1.0);
} else if (x <= 0.95) {
tmp = x / (y / x);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 + ((x + -1.0) / y) tmp = 0 if x <= -290000000.0: tmp = t_0 elif x <= 5.2e-127: tmp = x / (x + 1.0) elif x <= 0.95: tmp = x / (y / x) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(1.0 + Float64(Float64(x + -1.0) / y)) tmp = 0.0 if (x <= -290000000.0) tmp = t_0; elseif (x <= 5.2e-127) tmp = Float64(x / Float64(x + 1.0)); elseif (x <= 0.95) tmp = Float64(x / Float64(y / x)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 + ((x + -1.0) / y); tmp = 0.0; if (x <= -290000000.0) tmp = t_0; elseif (x <= 5.2e-127) tmp = x / (x + 1.0); elseif (x <= 0.95) tmp = x / (y / x); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(1.0 + N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -290000000.0], t$95$0, If[LessEqual[x, 5.2e-127], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.95], N[(x / N[(y / x), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{x + -1}{y}\\
\mathbf{if}\;x \leq -290000000:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 5.2 \cdot 10^{-127}:\\
\;\;\;\;\frac{x}{x + 1}\\
\mathbf{elif}\;x \leq 0.95:\\
\;\;\;\;\frac{x}{\frac{y}{x}}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -2.9e8 or 0.94999999999999996 < x Initial program 77.8%
flip-+37.4%
associate-*r/32.6%
metadata-eval32.6%
sub-neg32.6%
pow232.6%
metadata-eval32.6%
sub-neg32.6%
metadata-eval32.6%
Applied egg-rr32.6%
*-commutative32.6%
associate-/l*37.3%
+-commutative37.3%
+-commutative37.3%
Simplified37.3%
Taylor expanded in x around inf 100.0%
associate--l+100.0%
div-sub100.0%
sub-neg100.0%
metadata-eval100.0%
+-commutative100.0%
Simplified100.0%
if -2.9e8 < x < 5.19999999999999982e-127Initial program 99.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around inf 82.4%
if 5.19999999999999982e-127 < x < 0.94999999999999996Initial program 99.6%
associate-/l*99.5%
Simplified99.5%
Taylor expanded in x around inf 64.5%
associate--l+64.5%
div-sub64.6%
unpow264.6%
Simplified64.6%
Taylor expanded in y around 0 64.8%
Taylor expanded in x around 0 60.8%
Final simplification90.2%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ 1.0 (/ (+ x -1.0) y))))
(if (<= x -290000000.0)
t_0
(if (<= x 5.2e-127)
(/ x (+ x 1.0))
(if (<= x 240000.0) (/ x (+ y (/ y x))) t_0)))))
double code(double x, double y) {
double t_0 = 1.0 + ((x + -1.0) / y);
double tmp;
if (x <= -290000000.0) {
tmp = t_0;
} else if (x <= 5.2e-127) {
tmp = x / (x + 1.0);
} else if (x <= 240000.0) {
tmp = x / (y + (y / 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 + ((x + (-1.0d0)) / y)
if (x <= (-290000000.0d0)) then
tmp = t_0
else if (x <= 5.2d-127) then
tmp = x / (x + 1.0d0)
else if (x <= 240000.0d0) then
tmp = x / (y + (y / x))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = 1.0 + ((x + -1.0) / y);
double tmp;
if (x <= -290000000.0) {
tmp = t_0;
} else if (x <= 5.2e-127) {
tmp = x / (x + 1.0);
} else if (x <= 240000.0) {
tmp = x / (y + (y / x));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 + ((x + -1.0) / y) tmp = 0 if x <= -290000000.0: tmp = t_0 elif x <= 5.2e-127: tmp = x / (x + 1.0) elif x <= 240000.0: tmp = x / (y + (y / x)) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(1.0 + Float64(Float64(x + -1.0) / y)) tmp = 0.0 if (x <= -290000000.0) tmp = t_0; elseif (x <= 5.2e-127) tmp = Float64(x / Float64(x + 1.0)); elseif (x <= 240000.0) tmp = Float64(x / Float64(y + Float64(y / x))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 + ((x + -1.0) / y); tmp = 0.0; if (x <= -290000000.0) tmp = t_0; elseif (x <= 5.2e-127) tmp = x / (x + 1.0); elseif (x <= 240000.0) tmp = x / (y + (y / x)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(1.0 + N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -290000000.0], t$95$0, If[LessEqual[x, 5.2e-127], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 240000.0], N[(x / N[(y + N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{x + -1}{y}\\
\mathbf{if}\;x \leq -290000000:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 5.2 \cdot 10^{-127}:\\
\;\;\;\;\frac{x}{x + 1}\\
\mathbf{elif}\;x \leq 240000:\\
\;\;\;\;\frac{x}{y + \frac{y}{x}}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -2.9e8 or 2.4e5 < x Initial program 77.8%
flip-+37.4%
associate-*r/32.6%
metadata-eval32.6%
sub-neg32.6%
pow232.6%
metadata-eval32.6%
sub-neg32.6%
metadata-eval32.6%
Applied egg-rr32.6%
*-commutative32.6%
associate-/l*37.3%
+-commutative37.3%
+-commutative37.3%
Simplified37.3%
Taylor expanded in x around inf 100.0%
associate--l+100.0%
div-sub100.0%
sub-neg100.0%
metadata-eval100.0%
+-commutative100.0%
Simplified100.0%
if -2.9e8 < x < 5.19999999999999982e-127Initial program 99.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around inf 82.4%
if 5.19999999999999982e-127 < x < 2.4e5Initial program 99.6%
associate-/l*99.5%
Simplified99.5%
Taylor expanded in x around inf 64.5%
associate--l+64.5%
div-sub64.6%
unpow264.6%
Simplified64.6%
Taylor expanded in y around 0 64.8%
Final simplification90.5%
(FPCore (x y)
:precision binary64
(if (<= x -8.2e+56)
(/ x y)
(if (<= x -1.52e+32)
1.0
(if (<= x -1.0) (/ x y) (if (<= x 6.5e-13) x (/ x y))))))
double code(double x, double y) {
double tmp;
if (x <= -8.2e+56) {
tmp = x / y;
} else if (x <= -1.52e+32) {
tmp = 1.0;
} else if (x <= -1.0) {
tmp = x / y;
} else if (x <= 6.5e-13) {
tmp = x;
} else {
tmp = x / y;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-8.2d+56)) then
tmp = x / y
else if (x <= (-1.52d+32)) then
tmp = 1.0d0
else if (x <= (-1.0d0)) then
tmp = x / y
else if (x <= 6.5d-13) then
tmp = x
else
tmp = x / y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -8.2e+56) {
tmp = x / y;
} else if (x <= -1.52e+32) {
tmp = 1.0;
} else if (x <= -1.0) {
tmp = x / y;
} else if (x <= 6.5e-13) {
tmp = x;
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -8.2e+56: tmp = x / y elif x <= -1.52e+32: tmp = 1.0 elif x <= -1.0: tmp = x / y elif x <= 6.5e-13: tmp = x else: tmp = x / y return tmp
function code(x, y) tmp = 0.0 if (x <= -8.2e+56) tmp = Float64(x / y); elseif (x <= -1.52e+32) tmp = 1.0; elseif (x <= -1.0) tmp = Float64(x / y); elseif (x <= 6.5e-13) tmp = x; else tmp = Float64(x / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -8.2e+56) tmp = x / y; elseif (x <= -1.52e+32) tmp = 1.0; elseif (x <= -1.0) tmp = x / y; elseif (x <= 6.5e-13) tmp = x; else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -8.2e+56], N[(x / y), $MachinePrecision], If[LessEqual[x, -1.52e+32], 1.0, If[LessEqual[x, -1.0], N[(x / y), $MachinePrecision], If[LessEqual[x, 6.5e-13], x, N[(x / y), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -8.2 \cdot 10^{+56}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq -1.52 \cdot 10^{+32}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq -1:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq 6.5 \cdot 10^{-13}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -8.2000000000000007e56 or -1.5200000000000001e32 < x < -1 or 6.49999999999999957e-13 < x Initial program 77.3%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around inf 82.5%
if -8.2000000000000007e56 < x < -1.5200000000000001e32Initial program 100.0%
distribute-lft-in100.0%
*-rgt-identity100.0%
Applied egg-rr100.0%
Taylor expanded in y around inf 86.4%
+-commutative86.4%
Simplified86.4%
Taylor expanded in x around inf 86.4%
if -1 < x < 6.49999999999999957e-13Initial program 99.8%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around 0 74.6%
Final simplification79.2%
(FPCore (x y) :precision binary64 (if (<= x -1.1e+56) (/ x y) (if (<= x 3.6e-52) (/ x (+ x 1.0)) (if (<= x 1.0) (* x (/ x y)) (/ x y)))))
double code(double x, double y) {
double tmp;
if (x <= -1.1e+56) {
tmp = x / y;
} else if (x <= 3.6e-52) {
tmp = x / (x + 1.0);
} else if (x <= 1.0) {
tmp = x * (x / y);
} else {
tmp = x / y;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-1.1d+56)) then
tmp = x / y
else if (x <= 3.6d-52) then
tmp = x / (x + 1.0d0)
else if (x <= 1.0d0) then
tmp = x * (x / y)
else
tmp = x / y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -1.1e+56) {
tmp = x / y;
} else if (x <= 3.6e-52) {
tmp = x / (x + 1.0);
} else if (x <= 1.0) {
tmp = x * (x / y);
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.1e+56: tmp = x / y elif x <= 3.6e-52: tmp = x / (x + 1.0) elif x <= 1.0: tmp = x * (x / y) else: tmp = x / y return tmp
function code(x, y) tmp = 0.0 if (x <= -1.1e+56) tmp = Float64(x / y); elseif (x <= 3.6e-52) tmp = Float64(x / Float64(x + 1.0)); elseif (x <= 1.0) tmp = Float64(x * Float64(x / y)); else tmp = Float64(x / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1.1e+56) tmp = x / y; elseif (x <= 3.6e-52) tmp = x / (x + 1.0); elseif (x <= 1.0) tmp = x * (x / y); else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.1e+56], N[(x / y), $MachinePrecision], If[LessEqual[x, 3.6e-52], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.0], N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision], N[(x / y), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.1 \cdot 10^{+56}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq 3.6 \cdot 10^{-52}:\\
\;\;\;\;\frac{x}{x + 1}\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;x \cdot \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -1.10000000000000008e56 or 1 < x Initial program 75.7%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around inf 85.1%
if -1.10000000000000008e56 < x < 3.59999999999999988e-52Initial program 99.8%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around inf 77.3%
if 3.59999999999999988e-52 < x < 1Initial program 99.5%
associate-/l*99.5%
Simplified99.5%
Taylor expanded in x around inf 75.4%
associate--l+75.4%
div-sub75.4%
unpow275.4%
Simplified75.4%
Taylor expanded in y around 0 75.7%
Taylor expanded in x around 0 68.4%
associate-/r/68.3%
Applied egg-rr68.3%
Final simplification80.8%
(FPCore (x y) :precision binary64 (if (<= x -1.15e+57) (/ x y) (if (<= x 5.2e-127) (/ x (+ x 1.0)) (if (<= x 1.0) (/ x (/ y x)) (/ x y)))))
double code(double x, double y) {
double tmp;
if (x <= -1.15e+57) {
tmp = x / y;
} else if (x <= 5.2e-127) {
tmp = x / (x + 1.0);
} else if (x <= 1.0) {
tmp = x / (y / x);
} else {
tmp = x / y;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-1.15d+57)) then
tmp = x / y
else if (x <= 5.2d-127) then
tmp = x / (x + 1.0d0)
else if (x <= 1.0d0) then
tmp = x / (y / x)
else
tmp = x / y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -1.15e+57) {
tmp = x / y;
} else if (x <= 5.2e-127) {
tmp = x / (x + 1.0);
} else if (x <= 1.0) {
tmp = x / (y / x);
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.15e+57: tmp = x / y elif x <= 5.2e-127: tmp = x / (x + 1.0) elif x <= 1.0: tmp = x / (y / x) else: tmp = x / y return tmp
function code(x, y) tmp = 0.0 if (x <= -1.15e+57) tmp = Float64(x / y); elseif (x <= 5.2e-127) tmp = Float64(x / Float64(x + 1.0)); elseif (x <= 1.0) tmp = Float64(x / Float64(y / x)); else tmp = Float64(x / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1.15e+57) tmp = x / y; elseif (x <= 5.2e-127) tmp = x / (x + 1.0); elseif (x <= 1.0) tmp = x / (y / x); else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.15e+57], N[(x / y), $MachinePrecision], If[LessEqual[x, 5.2e-127], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.0], N[(x / N[(y / x), $MachinePrecision]), $MachinePrecision], N[(x / y), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.15 \cdot 10^{+57}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq 5.2 \cdot 10^{-127}:\\
\;\;\;\;\frac{x}{x + 1}\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\frac{x}{\frac{y}{x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -1.1499999999999999e57 or 1 < x Initial program 75.7%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around inf 85.1%
if -1.1499999999999999e57 < x < 5.19999999999999982e-127Initial program 99.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around inf 79.8%
if 5.19999999999999982e-127 < x < 1Initial program 99.6%
associate-/l*99.5%
Simplified99.5%
Taylor expanded in x around inf 64.5%
associate--l+64.5%
div-sub64.6%
unpow264.6%
Simplified64.6%
Taylor expanded in y around 0 64.8%
Taylor expanded in x around 0 60.8%
Final simplification80.8%
(FPCore (x y) :precision binary64 (if (<= x -0.000112) 1.0 (if (<= x 0.00345) x 1.0)))
double code(double x, double y) {
double tmp;
if (x <= -0.000112) {
tmp = 1.0;
} else if (x <= 0.00345) {
tmp = x;
} else {
tmp = 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 <= (-0.000112d0)) then
tmp = 1.0d0
else if (x <= 0.00345d0) then
tmp = x
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -0.000112) {
tmp = 1.0;
} else if (x <= 0.00345) {
tmp = x;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -0.000112: tmp = 1.0 elif x <= 0.00345: tmp = x else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -0.000112) tmp = 1.0; elseif (x <= 0.00345) tmp = x; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -0.000112) tmp = 1.0; elseif (x <= 0.00345) tmp = x; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -0.000112], 1.0, If[LessEqual[x, 0.00345], x, 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.000112:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 0.00345:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < -1.11999999999999998e-4 or 0.0034499999999999999 < x Initial program 78.5%
distribute-lft-in78.5%
*-rgt-identity78.5%
Applied egg-rr78.5%
Taylor expanded in y around inf 20.2%
+-commutative20.2%
Simplified20.2%
Taylor expanded in x around inf 19.7%
if -1.11999999999999998e-4 < x < 0.0034499999999999999Initial program 99.8%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around 0 75.3%
Final simplification43.8%
(FPCore (x y) :precision binary64 1.0)
double code(double x, double y) {
return 1.0;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0
end function
public static double code(double x, double y) {
return 1.0;
}
def code(x, y): return 1.0
function code(x, y) return 1.0 end
function tmp = code(x, y) tmp = 1.0; end
code[x_, y_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 87.7%
distribute-lft-in87.7%
*-rgt-identity87.7%
Applied egg-rr87.7%
Taylor expanded in y around inf 44.2%
+-commutative44.2%
Simplified44.2%
Taylor expanded in x around inf 12.7%
Final simplification12.7%
(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 2023279
(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)))