
(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 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(x * Float64(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[(x * N[(N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \frac{\frac{x}{y} + 1}{x + 1}
\end{array}
Initial program 87.9%
associate-/l*99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y)
:precision binary64
(if (<= x -3.6e+44)
(/ x y)
(if (<= x -2.9e-7)
(/ x (+ x 1.0))
(if (<= x 3.4e-12)
(* x (+ 1.0 (* x (+ (/ 1.0 y) -1.0))))
(/ x (+ y (/ y x)))))))
double code(double x, double y) {
double tmp;
if (x <= -3.6e+44) {
tmp = x / y;
} else if (x <= -2.9e-7) {
tmp = x / (x + 1.0);
} else if (x <= 3.4e-12) {
tmp = x * (1.0 + (x * ((1.0 / y) + -1.0)));
} else {
tmp = x / (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 (x <= (-3.6d+44)) then
tmp = x / y
else if (x <= (-2.9d-7)) then
tmp = x / (x + 1.0d0)
else if (x <= 3.4d-12) then
tmp = x * (1.0d0 + (x * ((1.0d0 / y) + (-1.0d0))))
else
tmp = x / (y + (y / x))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -3.6e+44) {
tmp = x / y;
} else if (x <= -2.9e-7) {
tmp = x / (x + 1.0);
} else if (x <= 3.4e-12) {
tmp = x * (1.0 + (x * ((1.0 / y) + -1.0)));
} else {
tmp = x / (y + (y / x));
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -3.6e+44: tmp = x / y elif x <= -2.9e-7: tmp = x / (x + 1.0) elif x <= 3.4e-12: tmp = x * (1.0 + (x * ((1.0 / y) + -1.0))) else: tmp = x / (y + (y / x)) return tmp
function code(x, y) tmp = 0.0 if (x <= -3.6e+44) tmp = Float64(x / y); elseif (x <= -2.9e-7) tmp = Float64(x / Float64(x + 1.0)); elseif (x <= 3.4e-12) tmp = Float64(x * Float64(1.0 + Float64(x * Float64(Float64(1.0 / y) + -1.0)))); else tmp = Float64(x / Float64(y + Float64(y / x))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -3.6e+44) tmp = x / y; elseif (x <= -2.9e-7) tmp = x / (x + 1.0); elseif (x <= 3.4e-12) tmp = x * (1.0 + (x * ((1.0 / y) + -1.0))); else tmp = x / (y + (y / x)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -3.6e+44], N[(x / y), $MachinePrecision], If[LessEqual[x, -2.9e-7], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 3.4e-12], N[(x * N[(1.0 + N[(x * N[(N[(1.0 / y), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x / N[(y + N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.6 \cdot 10^{+44}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq -2.9 \cdot 10^{-7}:\\
\;\;\;\;\frac{x}{x + 1}\\
\mathbf{elif}\;x \leq 3.4 \cdot 10^{-12}:\\
\;\;\;\;x \cdot \left(1 + x \cdot \left(\frac{1}{y} + -1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y + \frac{y}{x}}\\
\end{array}
\end{array}
if x < -3.6e44Initial program 73.1%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around inf 76.6%
if -3.6e44 < x < -2.8999999999999998e-7Initial program 100.0%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around inf 80.9%
if -2.8999999999999998e-7 < x < 3.4000000000000001e-12Initial program 99.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around 0 100.0%
if 3.4000000000000001e-12 < x Initial program 75.5%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around 0 64.6%
clear-num64.6%
un-div-inv64.7%
+-commutative64.7%
*-commutative64.7%
associate-/l*78.3%
Applied egg-rr78.3%
Taylor expanded in x around 0 64.7%
distribute-rgt1-in64.7%
associate-*r/78.3%
distribute-lft1-in78.3%
*-commutative78.3%
associate-*l/64.7%
associate-/l*78.4%
*-inverses78.4%
*-rgt-identity78.4%
Simplified78.4%
Final simplification88.6%
(FPCore (x y)
:precision binary64
(if (<= x -4.6e+44)
(/ x y)
(if (<= x -1.22e-8)
(/ x (+ x 1.0))
(if (<= x 56.0) (* x (+ (/ x y) 1.0)) (/ x y)))))
double code(double x, double y) {
double tmp;
if (x <= -4.6e+44) {
tmp = x / y;
} else if (x <= -1.22e-8) {
tmp = x / (x + 1.0);
} else if (x <= 56.0) {
tmp = x * ((x / y) + 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 <= (-4.6d+44)) then
tmp = x / y
else if (x <= (-1.22d-8)) then
tmp = x / (x + 1.0d0)
else if (x <= 56.0d0) then
tmp = x * ((x / y) + 1.0d0)
else
tmp = x / y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -4.6e+44) {
tmp = x / y;
} else if (x <= -1.22e-8) {
tmp = x / (x + 1.0);
} else if (x <= 56.0) {
tmp = x * ((x / y) + 1.0);
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -4.6e+44: tmp = x / y elif x <= -1.22e-8: tmp = x / (x + 1.0) elif x <= 56.0: tmp = x * ((x / y) + 1.0) else: tmp = x / y return tmp
function code(x, y) tmp = 0.0 if (x <= -4.6e+44) tmp = Float64(x / y); elseif (x <= -1.22e-8) tmp = Float64(x / Float64(x + 1.0)); elseif (x <= 56.0) tmp = Float64(x * Float64(Float64(x / y) + 1.0)); else tmp = Float64(x / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -4.6e+44) tmp = x / y; elseif (x <= -1.22e-8) tmp = x / (x + 1.0); elseif (x <= 56.0) tmp = x * ((x / y) + 1.0); else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -4.6e+44], N[(x / y), $MachinePrecision], If[LessEqual[x, -1.22e-8], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 56.0], N[(x * N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(x / y), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.6 \cdot 10^{+44}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq -1.22 \cdot 10^{-8}:\\
\;\;\;\;\frac{x}{x + 1}\\
\mathbf{elif}\;x \leq 56:\\
\;\;\;\;x \cdot \left(\frac{x}{y} + 1\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -4.60000000000000009e44 or 56 < x Initial program 74.0%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around inf 76.6%
if -4.60000000000000009e44 < x < -1.22e-8Initial program 100.0%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around inf 80.9%
if -1.22e-8 < x < 56Initial program 99.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around 0 99.2%
Taylor expanded in y around 0 99.2%
Final simplification88.0%
(FPCore (x y)
:precision binary64
(if (<= x -8e+44)
(/ x y)
(if (<= x -5e-10)
(/ x (+ x 1.0))
(if (<= x 3.4e-12) (* x (+ (/ x y) 1.0)) (/ x (+ y (/ y x)))))))
double code(double x, double y) {
double tmp;
if (x <= -8e+44) {
tmp = x / y;
} else if (x <= -5e-10) {
tmp = x / (x + 1.0);
} else if (x <= 3.4e-12) {
tmp = x * ((x / y) + 1.0);
} else {
tmp = x / (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 (x <= (-8d+44)) then
tmp = x / y
else if (x <= (-5d-10)) then
tmp = x / (x + 1.0d0)
else if (x <= 3.4d-12) then
tmp = x * ((x / y) + 1.0d0)
else
tmp = x / (y + (y / x))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -8e+44) {
tmp = x / y;
} else if (x <= -5e-10) {
tmp = x / (x + 1.0);
} else if (x <= 3.4e-12) {
tmp = x * ((x / y) + 1.0);
} else {
tmp = x / (y + (y / x));
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -8e+44: tmp = x / y elif x <= -5e-10: tmp = x / (x + 1.0) elif x <= 3.4e-12: tmp = x * ((x / y) + 1.0) else: tmp = x / (y + (y / x)) return tmp
function code(x, y) tmp = 0.0 if (x <= -8e+44) tmp = Float64(x / y); elseif (x <= -5e-10) tmp = Float64(x / Float64(x + 1.0)); elseif (x <= 3.4e-12) tmp = Float64(x * Float64(Float64(x / y) + 1.0)); else tmp = Float64(x / Float64(y + Float64(y / x))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -8e+44) tmp = x / y; elseif (x <= -5e-10) tmp = x / (x + 1.0); elseif (x <= 3.4e-12) tmp = x * ((x / y) + 1.0); else tmp = x / (y + (y / x)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -8e+44], N[(x / y), $MachinePrecision], If[LessEqual[x, -5e-10], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 3.4e-12], N[(x * N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(x / N[(y + N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -8 \cdot 10^{+44}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq -5 \cdot 10^{-10}:\\
\;\;\;\;\frac{x}{x + 1}\\
\mathbf{elif}\;x \leq 3.4 \cdot 10^{-12}:\\
\;\;\;\;x \cdot \left(\frac{x}{y} + 1\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y + \frac{y}{x}}\\
\end{array}
\end{array}
if x < -8.0000000000000007e44Initial program 73.1%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around inf 76.6%
if -8.0000000000000007e44 < x < -5.00000000000000031e-10Initial program 100.0%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around inf 80.9%
if -5.00000000000000031e-10 < x < 3.4000000000000001e-12Initial program 99.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around 0 100.0%
Taylor expanded in y around 0 99.9%
if 3.4000000000000001e-12 < x Initial program 75.5%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around 0 64.6%
clear-num64.6%
un-div-inv64.7%
+-commutative64.7%
*-commutative64.7%
associate-/l*78.3%
Applied egg-rr78.3%
Taylor expanded in x around 0 64.7%
distribute-rgt1-in64.7%
associate-*r/78.3%
distribute-lft1-in78.3%
*-commutative78.3%
associate-*l/64.7%
associate-/l*78.4%
*-inverses78.4%
*-rgt-identity78.4%
Simplified78.4%
Final simplification88.6%
(FPCore (x y) :precision binary64 (if (or (<= x -1.0) (not (<= x 3.4e-12))) (/ x y) (* x (- 1.0 x))))
double code(double x, double y) {
double tmp;
if ((x <= -1.0) || !(x <= 3.4e-12)) {
tmp = x / y;
} else {
tmp = x * (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 <= (-1.0d0)) .or. (.not. (x <= 3.4d-12))) then
tmp = x / y
else
tmp = x * (1.0d0 - x)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -1.0) || !(x <= 3.4e-12)) {
tmp = x / y;
} else {
tmp = x * (1.0 - x);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -1.0) or not (x <= 3.4e-12): tmp = x / y else: tmp = x * (1.0 - x) return tmp
function code(x, y) tmp = 0.0 if ((x <= -1.0) || !(x <= 3.4e-12)) tmp = Float64(x / y); else tmp = Float64(x * Float64(1.0 - x)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -1.0) || ~((x <= 3.4e-12))) tmp = x / y; else tmp = x * (1.0 - x); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -1.0], N[Not[LessEqual[x, 3.4e-12]], $MachinePrecision]], N[(x / y), $MachinePrecision], N[(x * N[(1.0 - x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 3.4 \cdot 10^{-12}\right):\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - x\right)\\
\end{array}
\end{array}
if x < -1 or 3.4000000000000001e-12 < x Initial program 76.2%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around inf 72.0%
if -1 < x < 3.4000000000000001e-12Initial program 99.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around 0 99.8%
Taylor expanded in y around inf 85.2%
neg-mul-185.2%
sub-neg85.2%
Simplified85.2%
Final simplification78.5%
(FPCore (x y) :precision binary64 (if (or (<= x -7e+44) (not (<= x 2.4e+53))) (/ x y) (/ x (+ x 1.0))))
double code(double x, double y) {
double tmp;
if ((x <= -7e+44) || !(x <= 2.4e+53)) {
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 <= (-7d+44)) .or. (.not. (x <= 2.4d+53))) 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 <= -7e+44) || !(x <= 2.4e+53)) {
tmp = x / y;
} else {
tmp = x / (x + 1.0);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -7e+44) or not (x <= 2.4e+53): tmp = x / y else: tmp = x / (x + 1.0) return tmp
function code(x, y) tmp = 0.0 if ((x <= -7e+44) || !(x <= 2.4e+53)) 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 <= -7e+44) || ~((x <= 2.4e+53))) tmp = x / y; else tmp = x / (x + 1.0); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -7e+44], N[Not[LessEqual[x, 2.4e+53]], $MachinePrecision]], N[(x / y), $MachinePrecision], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -7 \cdot 10^{+44} \lor \neg \left(x \leq 2.4 \cdot 10^{+53}\right):\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{x + 1}\\
\end{array}
\end{array}
if x < -6.9999999999999998e44 or 2.4e53 < x Initial program 72.4%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around inf 79.3%
if -6.9999999999999998e44 < x < 2.4e53Initial program 99.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around inf 82.5%
Final simplification81.1%
(FPCore (x y) :precision binary64 (if (or (<= x -1.0) (not (<= x 3.4e-12))) (/ x y) x))
double code(double x, double y) {
double tmp;
if ((x <= -1.0) || !(x <= 3.4e-12)) {
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.4d-12))) 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.4e-12)) {
tmp = x / y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -1.0) or not (x <= 3.4e-12): tmp = x / y else: tmp = x return tmp
function code(x, y) tmp = 0.0 if ((x <= -1.0) || !(x <= 3.4e-12)) 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.4e-12))) 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.4e-12]], $MachinePrecision]], N[(x / y), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 3.4 \cdot 10^{-12}\right):\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -1 or 3.4000000000000001e-12 < x Initial program 76.2%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around inf 72.0%
if -1 < x < 3.4000000000000001e-12Initial program 99.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around 0 84.9%
Final simplification78.3%
(FPCore (x y) :precision binary64 (if (<= x -1.0) 1.0 (if (<= x 3.4e-12) x 1.0)))
double code(double x, double y) {
double tmp;
if (x <= -1.0) {
tmp = 1.0;
} else if (x <= 3.4e-12) {
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 <= 3.4d-12) 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 <= 3.4e-12) {
tmp = x;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.0: tmp = 1.0 elif x <= 3.4e-12: tmp = x else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -1.0) tmp = 1.0; elseif (x <= 3.4e-12) 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 <= 3.4e-12) tmp = x; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.0], 1.0, If[LessEqual[x, 3.4e-12], x, 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 3.4 \cdot 10^{-12}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < -1 or 3.4000000000000001e-12 < x Initial program 76.2%
Taylor expanded in y around 0 52.7%
unpow252.7%
distribute-lft-out53.1%
Simplified53.1%
Taylor expanded in x around 0 27.0%
Taylor expanded in x around inf 25.8%
if -1 < x < 3.4000000000000001e-12Initial program 99.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around 0 84.9%
Final simplification54.9%
(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.9%
Taylor expanded in y around 0 66.7%
unpow266.7%
distribute-lft-out66.9%
Simplified66.9%
Taylor expanded in x around 0 55.7%
Taylor expanded in x around inf 14.9%
Final simplification14.9%
(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 2024077
(FPCore (x y)
:name "Codec.Picture.Types:toneMapping from JuicyPixels-3.2.6.1"
:precision binary64
:alt
(* (/ x 1.0) (/ (+ (/ x y) 1.0) (+ x 1.0)))
(/ (* x (+ (/ x y) 1.0)) (+ x 1.0)))