
(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 (/ 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 89.0%
associate-/l*99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ 1.0 (/ (+ x -1.0) y))))
(if (<= x -90000000000.0)
t_0
(if (<= x 3e-58) (/ x (+ x 1.0)) (if (<= x 0.0056) (/ x (/ y x)) t_0)))))
double code(double x, double y) {
double t_0 = 1.0 + ((x + -1.0) / y);
double tmp;
if (x <= -90000000000.0) {
tmp = t_0;
} else if (x <= 3e-58) {
tmp = x / (x + 1.0);
} else if (x <= 0.0056) {
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 <= (-90000000000.0d0)) then
tmp = t_0
else if (x <= 3d-58) then
tmp = x / (x + 1.0d0)
else if (x <= 0.0056d0) 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 <= -90000000000.0) {
tmp = t_0;
} else if (x <= 3e-58) {
tmp = x / (x + 1.0);
} else if (x <= 0.0056) {
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 <= -90000000000.0: tmp = t_0 elif x <= 3e-58: tmp = x / (x + 1.0) elif x <= 0.0056: 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 <= -90000000000.0) tmp = t_0; elseif (x <= 3e-58) tmp = Float64(x / Float64(x + 1.0)); elseif (x <= 0.0056) 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 <= -90000000000.0) tmp = t_0; elseif (x <= 3e-58) tmp = x / (x + 1.0); elseif (x <= 0.0056) 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, -90000000000.0], t$95$0, If[LessEqual[x, 3e-58], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.0056], 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 -90000000000:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 3 \cdot 10^{-58}:\\
\;\;\;\;\frac{x}{x + 1}\\
\mathbf{elif}\;x \leq 0.0056:\\
\;\;\;\;\frac{x}{\frac{y}{x}}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -9e10 or 0.00559999999999999994 < x Initial program 77.8%
associate-/l*100.0%
Simplified100.0%
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 -9e10 < x < 3.00000000000000008e-58Initial program 99.8%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around inf 72.5%
if 3.00000000000000008e-58 < x < 0.00559999999999999994Initial program 99.6%
associate-/l*99.6%
Simplified99.6%
Taylor expanded in y around 0 85.6%
+-commutative85.6%
*-commutative85.6%
+-commutative85.6%
associate-/l*85.8%
Simplified85.8%
Taylor expanded in x around 0 76.4%
Final simplification85.9%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ 1.0 (/ (+ x -1.0) y))))
(if (<= x -90000000000.0)
t_0
(if (<= x 1.4e-56)
(/ x (+ x 1.0))
(if (<= x 8600.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 <= -90000000000.0) {
tmp = t_0;
} else if (x <= 1.4e-56) {
tmp = x / (x + 1.0);
} else if (x <= 8600.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 <= (-90000000000.0d0)) then
tmp = t_0
else if (x <= 1.4d-56) then
tmp = x / (x + 1.0d0)
else if (x <= 8600.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 <= -90000000000.0) {
tmp = t_0;
} else if (x <= 1.4e-56) {
tmp = x / (x + 1.0);
} else if (x <= 8600.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 <= -90000000000.0: tmp = t_0 elif x <= 1.4e-56: tmp = x / (x + 1.0) elif x <= 8600.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 <= -90000000000.0) tmp = t_0; elseif (x <= 1.4e-56) tmp = Float64(x / Float64(x + 1.0)); elseif (x <= 8600.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 <= -90000000000.0) tmp = t_0; elseif (x <= 1.4e-56) tmp = x / (x + 1.0); elseif (x <= 8600.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, -90000000000.0], t$95$0, If[LessEqual[x, 1.4e-56], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 8600.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 -90000000000:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 1.4 \cdot 10^{-56}:\\
\;\;\;\;\frac{x}{x + 1}\\
\mathbf{elif}\;x \leq 8600:\\
\;\;\;\;\frac{x}{y + \frac{y}{x}}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -9e10 or 8600 < x Initial program 77.8%
associate-/l*100.0%
Simplified100.0%
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 -9e10 < x < 1.39999999999999997e-56Initial program 99.8%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around inf 72.5%
if 1.39999999999999997e-56 < x < 8600Initial program 99.6%
associate-/l*99.6%
Simplified99.6%
Taylor expanded in y around 0 85.6%
+-commutative85.6%
*-commutative85.6%
+-commutative85.6%
associate-/l*85.8%
Simplified85.8%
Taylor expanded in x around 0 85.8%
Final simplification86.2%
(FPCore (x y)
:precision binary64
(if (<= x -1.0)
(/ x y)
(if (<= x 2e-57)
x
(if (<= x 0.15) (* x (/ x y)) (if (<= x 2.4e+76) 1.0 (/ x y))))))
double code(double x, double y) {
double tmp;
if (x <= -1.0) {
tmp = x / y;
} else if (x <= 2e-57) {
tmp = x;
} else if (x <= 0.15) {
tmp = x * (x / y);
} else if (x <= 2.4e+76) {
tmp = 1.0;
} 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.0d0)) then
tmp = x / y
else if (x <= 2d-57) then
tmp = x
else if (x <= 0.15d0) then
tmp = x * (x / y)
else if (x <= 2.4d+76) then
tmp = 1.0d0
else
tmp = x / y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -1.0) {
tmp = x / y;
} else if (x <= 2e-57) {
tmp = x;
} else if (x <= 0.15) {
tmp = x * (x / y);
} else if (x <= 2.4e+76) {
tmp = 1.0;
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.0: tmp = x / y elif x <= 2e-57: tmp = x elif x <= 0.15: tmp = x * (x / y) elif x <= 2.4e+76: tmp = 1.0 else: tmp = x / y return tmp
function code(x, y) tmp = 0.0 if (x <= -1.0) tmp = Float64(x / y); elseif (x <= 2e-57) tmp = x; elseif (x <= 0.15) tmp = Float64(x * Float64(x / y)); elseif (x <= 2.4e+76) tmp = 1.0; else tmp = Float64(x / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1.0) tmp = x / y; elseif (x <= 2e-57) tmp = x; elseif (x <= 0.15) tmp = x * (x / y); elseif (x <= 2.4e+76) tmp = 1.0; else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.0], N[(x / y), $MachinePrecision], If[LessEqual[x, 2e-57], x, If[LessEqual[x, 0.15], N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.4e+76], 1.0, N[(x / y), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq 2 \cdot 10^{-57}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 0.15:\\
\;\;\;\;x \cdot \frac{x}{y}\\
\mathbf{elif}\;x \leq 2.4 \cdot 10^{+76}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -1 or 2.4e76 < x Initial program 75.4%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around inf 73.8%
if -1 < x < 1.99999999999999991e-57Initial program 99.8%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around 0 70.9%
if 1.99999999999999991e-57 < x < 0.149999999999999994Initial program 99.6%
associate-/l*99.6%
Simplified99.6%
Taylor expanded in y around 0 85.6%
+-commutative85.6%
*-commutative85.6%
+-commutative85.6%
associate-/l*85.8%
Simplified85.8%
Taylor expanded in x around 0 76.4%
associate-/r/76.4%
Applied egg-rr76.4%
if 0.149999999999999994 < x < 2.4e76Initial program 100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around inf 97.4%
Taylor expanded in y around inf 55.7%
Final simplification71.6%
(FPCore (x y) :precision binary64 (if (or (<= x -1.0) (not (<= x 5.4e-54))) (+ 1.0 (/ x y)) x))
double code(double x, double y) {
double tmp;
if ((x <= -1.0) || !(x <= 5.4e-54)) {
tmp = 1.0 + (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 <= 5.4d-54))) then
tmp = 1.0d0 + (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 <= 5.4e-54)) {
tmp = 1.0 + (x / y);
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -1.0) or not (x <= 5.4e-54): tmp = 1.0 + (x / y) else: tmp = x return tmp
function code(x, y) tmp = 0.0 if ((x <= -1.0) || !(x <= 5.4e-54)) tmp = Float64(1.0 + Float64(x / y)); else tmp = x; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -1.0) || ~((x <= 5.4e-54))) tmp = 1.0 + (x / y); else tmp = x; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -1.0], N[Not[LessEqual[x, 5.4e-54]], $MachinePrecision]], N[(1.0 + N[(x / y), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 5.4 \cdot 10^{-54}\right):\\
\;\;\;\;1 + \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -1 or 5.40000000000000051e-54 < x Initial program 78.8%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around inf 95.6%
associate--l+95.6%
+-commutative95.6%
sub-div95.6%
sub-neg95.6%
metadata-eval95.6%
Applied egg-rr95.6%
Taylor expanded in x around inf 95.7%
if -1 < x < 5.40000000000000051e-54Initial program 99.8%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around 0 70.6%
Final simplification83.5%
(FPCore (x y) :precision binary64 (if (or (<= x -90000000000.0) (not (<= x 5.4e-54))) (+ 1.0 (/ x y)) (/ x (+ x 1.0))))
double code(double x, double y) {
double tmp;
if ((x <= -90000000000.0) || !(x <= 5.4e-54)) {
tmp = 1.0 + (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 <= (-90000000000.0d0)) .or. (.not. (x <= 5.4d-54))) then
tmp = 1.0d0 + (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 <= -90000000000.0) || !(x <= 5.4e-54)) {
tmp = 1.0 + (x / y);
} else {
tmp = x / (x + 1.0);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -90000000000.0) or not (x <= 5.4e-54): tmp = 1.0 + (x / y) else: tmp = x / (x + 1.0) return tmp
function code(x, y) tmp = 0.0 if ((x <= -90000000000.0) || !(x <= 5.4e-54)) tmp = Float64(1.0 + 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 <= -90000000000.0) || ~((x <= 5.4e-54))) tmp = 1.0 + (x / y); else tmp = x / (x + 1.0); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -90000000000.0], N[Not[LessEqual[x, 5.4e-54]], $MachinePrecision]], N[(1.0 + N[(x / y), $MachinePrecision]), $MachinePrecision], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -90000000000 \lor \neg \left(x \leq 5.4 \cdot 10^{-54}\right):\\
\;\;\;\;1 + \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{x + 1}\\
\end{array}
\end{array}
if x < -9e10 or 5.40000000000000051e-54 < x Initial program 78.6%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around inf 95.8%
associate--l+95.8%
+-commutative95.8%
sub-div95.8%
sub-neg95.8%
metadata-eval95.8%
Applied egg-rr95.8%
Taylor expanded in x around inf 95.9%
if -9e10 < x < 5.40000000000000051e-54Initial program 99.8%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around inf 72.1%
Final simplification84.3%
(FPCore (x y) :precision binary64 (if (<= x -1.0) (/ x y) (if (<= x 5.4e-54) x (/ x y))))
double code(double x, double y) {
double tmp;
if (x <= -1.0) {
tmp = x / y;
} else if (x <= 5.4e-54) {
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 <= (-1.0d0)) then
tmp = x / y
else if (x <= 5.4d-54) 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 <= -1.0) {
tmp = x / y;
} else if (x <= 5.4e-54) {
tmp = x;
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.0: tmp = x / y elif x <= 5.4e-54: tmp = x else: tmp = x / y return tmp
function code(x, y) tmp = 0.0 if (x <= -1.0) tmp = Float64(x / y); elseif (x <= 5.4e-54) tmp = x; else tmp = Float64(x / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1.0) tmp = x / y; elseif (x <= 5.4e-54) tmp = x; else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.0], N[(x / y), $MachinePrecision], If[LessEqual[x, 5.4e-54], x, N[(x / y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq 5.4 \cdot 10^{-54}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -1 or 5.40000000000000051e-54 < x Initial program 78.8%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around inf 68.3%
if -1 < x < 5.40000000000000051e-54Initial program 99.8%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around 0 70.6%
Final simplification69.4%
(FPCore (x y) :precision binary64 (if (<= x -1.0) 1.0 (if (<= x 5.4e-54) x 1.0)))
double code(double x, double y) {
double tmp;
if (x <= -1.0) {
tmp = 1.0;
} else if (x <= 5.4e-54) {
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 <= (-1.0d0)) then
tmp = 1.0d0
else if (x <= 5.4d-54) 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 <= -1.0) {
tmp = 1.0;
} else if (x <= 5.4e-54) {
tmp = x;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.0: tmp = 1.0 elif x <= 5.4e-54: tmp = x else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -1.0) tmp = 1.0; elseif (x <= 5.4e-54) tmp = x; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1.0) tmp = 1.0; elseif (x <= 5.4e-54) tmp = x; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.0], 1.0, If[LessEqual[x, 5.4e-54], x, 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 5.4 \cdot 10^{-54}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < -1 or 5.40000000000000051e-54 < x Initial program 78.8%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around inf 95.6%
Taylor expanded in y around inf 27.2%
if -1 < x < 5.40000000000000051e-54Initial program 99.8%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around 0 70.6%
Final simplification48.2%
(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 89.0%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around inf 50.5%
Taylor expanded in y around inf 15.7%
Final simplification15.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 2023224
(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)))