
(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 89.6%
associate-/l*99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (x y)
:precision binary64
(if (<= x -0.00145)
(/ x (* (/ y x) (+ x 1.0)))
(if (<= x 2.6e-5)
(* x (+ 1.0 (* x (+ (/ 1.0 y) -1.0))))
(if (<= x 1.6e+44) (/ x (+ x 1.0)) (/ x y)))))
double code(double x, double y) {
double tmp;
if (x <= -0.00145) {
tmp = x / ((y / x) * (x + 1.0));
} else if (x <= 2.6e-5) {
tmp = x * (1.0 + (x * ((1.0 / y) + -1.0)));
} else if (x <= 1.6e+44) {
tmp = x / (x + 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 <= (-0.00145d0)) then
tmp = x / ((y / x) * (x + 1.0d0))
else if (x <= 2.6d-5) then
tmp = x * (1.0d0 + (x * ((1.0d0 / y) + (-1.0d0))))
else if (x <= 1.6d+44) then
tmp = x / (x + 1.0d0)
else
tmp = x / y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -0.00145) {
tmp = x / ((y / x) * (x + 1.0));
} else if (x <= 2.6e-5) {
tmp = x * (1.0 + (x * ((1.0 / y) + -1.0)));
} else if (x <= 1.6e+44) {
tmp = x / (x + 1.0);
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -0.00145: tmp = x / ((y / x) * (x + 1.0)) elif x <= 2.6e-5: tmp = x * (1.0 + (x * ((1.0 / y) + -1.0))) elif x <= 1.6e+44: tmp = x / (x + 1.0) else: tmp = x / y return tmp
function code(x, y) tmp = 0.0 if (x <= -0.00145) tmp = Float64(x / Float64(Float64(y / x) * Float64(x + 1.0))); elseif (x <= 2.6e-5) tmp = Float64(x * Float64(1.0 + Float64(x * Float64(Float64(1.0 / y) + -1.0)))); elseif (x <= 1.6e+44) tmp = Float64(x / Float64(x + 1.0)); else tmp = Float64(x / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -0.00145) tmp = x / ((y / x) * (x + 1.0)); elseif (x <= 2.6e-5) tmp = x * (1.0 + (x * ((1.0 / y) + -1.0))); elseif (x <= 1.6e+44) tmp = x / (x + 1.0); else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -0.00145], N[(x / N[(N[(y / x), $MachinePrecision] * N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.6e-5], N[(x * N[(1.0 + N[(x * N[(N[(1.0 / y), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.6e+44], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], N[(x / y), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.00145:\\
\;\;\;\;\frac{x}{\frac{y}{x} \cdot \left(x + 1\right)}\\
\mathbf{elif}\;x \leq 2.6 \cdot 10^{-5}:\\
\;\;\;\;x \cdot \left(1 + x \cdot \left(\frac{1}{y} + -1\right)\right)\\
\mathbf{elif}\;x \leq 1.6 \cdot 10^{+44}:\\
\;\;\;\;\frac{x}{x + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -0.00145Initial program 78.8%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around 0 72.7%
clear-num72.7%
un-div-inv72.8%
+-commutative72.8%
*-commutative72.8%
associate-/l*80.9%
Applied egg-rr80.9%
*-commutative80.9%
+-commutative80.9%
Simplified80.9%
if -0.00145 < x < 2.59999999999999984e-5Initial program 99.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around 0 99.8%
if 2.59999999999999984e-5 < x < 1.60000000000000002e44Initial program 99.9%
associate-/l*99.4%
Simplified99.4%
Taylor expanded in y around inf 81.9%
if 1.60000000000000002e44 < x Initial program 75.0%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around inf 82.4%
Final simplification90.7%
(FPCore (x y) :precision binary64 (if (<= x -1.0) (/ x y) (if (<= x 1.3) x (if (<= x 1.6e+44) (+ 1.0 (/ -1.0 x)) (/ x y)))))
double code(double x, double y) {
double tmp;
if (x <= -1.0) {
tmp = x / y;
} else if (x <= 1.3) {
tmp = x;
} else if (x <= 1.6e+44) {
tmp = 1.0 + (-1.0 / 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 <= 1.3d0) then
tmp = x
else if (x <= 1.6d+44) then
tmp = 1.0d0 + ((-1.0d0) / 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 <= 1.3) {
tmp = x;
} else if (x <= 1.6e+44) {
tmp = 1.0 + (-1.0 / x);
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.0: tmp = x / y elif x <= 1.3: tmp = x elif x <= 1.6e+44: tmp = 1.0 + (-1.0 / x) else: tmp = x / y return tmp
function code(x, y) tmp = 0.0 if (x <= -1.0) tmp = Float64(x / y); elseif (x <= 1.3) tmp = x; elseif (x <= 1.6e+44) tmp = Float64(1.0 + Float64(-1.0 / 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 <= 1.3) tmp = x; elseif (x <= 1.6e+44) tmp = 1.0 + (-1.0 / 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, 1.3], x, If[LessEqual[x, 1.6e+44], N[(1.0 + N[(-1.0 / x), $MachinePrecision]), $MachinePrecision], N[(x / y), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq 1.3:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 1.6 \cdot 10^{+44}:\\
\;\;\;\;1 + \frac{-1}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -1 or 1.60000000000000002e44 < x Initial program 77.0%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around inf 80.5%
if -1 < x < 1.30000000000000004Initial program 99.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around 0 77.0%
if 1.30000000000000004 < x < 1.60000000000000002e44Initial program 100.0%
associate-/l*99.5%
Simplified99.5%
Taylor expanded in y around inf 78.0%
Taylor expanded in x around inf 76.5%
Final simplification78.5%
(FPCore (x y) :precision binary64 (if (<= x -1.0) (/ x y) (if (<= x 1.0) x (if (<= x 1.6e+44) 1.0 (/ x y)))))
double code(double x, double y) {
double tmp;
if (x <= -1.0) {
tmp = x / y;
} else if (x <= 1.0) {
tmp = x;
} else if (x <= 1.6e+44) {
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 <= 1.0d0) then
tmp = x
else if (x <= 1.6d+44) 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 <= 1.0) {
tmp = x;
} else if (x <= 1.6e+44) {
tmp = 1.0;
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.0: tmp = x / y elif x <= 1.0: tmp = x elif x <= 1.6e+44: 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 <= 1.0) tmp = x; elseif (x <= 1.6e+44) 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 <= 1.0) tmp = x; elseif (x <= 1.6e+44) 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, 1.0], x, If[LessEqual[x, 1.6e+44], 1.0, N[(x / y), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 1.6 \cdot 10^{+44}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -1 or 1.60000000000000002e44 < x Initial program 77.0%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around inf 80.5%
if -1 < x < 1Initial program 99.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around 0 77.0%
if 1 < x < 1.60000000000000002e44Initial program 100.0%
associate-/l*99.5%
Simplified99.5%
Taylor expanded in y around inf 78.0%
Taylor expanded in x around inf 63.5%
Final simplification78.1%
(FPCore (x y) :precision binary64 (if (or (<= x -4e+17) (not (<= x 1.6e+44))) (/ x y) (/ x (+ x 1.0))))
double code(double x, double y) {
double tmp;
if ((x <= -4e+17) || !(x <= 1.6e+44)) {
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 <= (-4d+17)) .or. (.not. (x <= 1.6d+44))) 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 <= -4e+17) || !(x <= 1.6e+44)) {
tmp = x / y;
} else {
tmp = x / (x + 1.0);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -4e+17) or not (x <= 1.6e+44): tmp = x / y else: tmp = x / (x + 1.0) return tmp
function code(x, y) tmp = 0.0 if ((x <= -4e+17) || !(x <= 1.6e+44)) 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 <= -4e+17) || ~((x <= 1.6e+44))) tmp = x / y; else tmp = x / (x + 1.0); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -4e+17], N[Not[LessEqual[x, 1.6e+44]], $MachinePrecision]], N[(x / y), $MachinePrecision], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4 \cdot 10^{+17} \lor \neg \left(x \leq 1.6 \cdot 10^{+44}\right):\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{x + 1}\\
\end{array}
\end{array}
if x < -4e17 or 1.60000000000000002e44 < x Initial program 76.2%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around inf 82.5%
if -4e17 < x < 1.60000000000000002e44Initial program 99.9%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around inf 77.4%
Final simplification79.6%
(FPCore (x y) :precision binary64 (if (<= x -1.45e-12) (* x (/ (/ x y) (+ x 1.0))) (if (<= x 1.6e+44) (/ x (+ x 1.0)) (/ x y))))
double code(double x, double y) {
double tmp;
if (x <= -1.45e-12) {
tmp = x * ((x / y) / (x + 1.0));
} else if (x <= 1.6e+44) {
tmp = x / (x + 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.45d-12)) then
tmp = x * ((x / y) / (x + 1.0d0))
else if (x <= 1.6d+44) then
tmp = x / (x + 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.45e-12) {
tmp = x * ((x / y) / (x + 1.0));
} else if (x <= 1.6e+44) {
tmp = x / (x + 1.0);
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.45e-12: tmp = x * ((x / y) / (x + 1.0)) elif x <= 1.6e+44: tmp = x / (x + 1.0) else: tmp = x / y return tmp
function code(x, y) tmp = 0.0 if (x <= -1.45e-12) tmp = Float64(x * Float64(Float64(x / y) / Float64(x + 1.0))); elseif (x <= 1.6e+44) tmp = Float64(x / Float64(x + 1.0)); else tmp = Float64(x / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1.45e-12) tmp = x * ((x / y) / (x + 1.0)); elseif (x <= 1.6e+44) tmp = x / (x + 1.0); else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.45e-12], N[(x * N[(N[(x / y), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.6e+44], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], N[(x / y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.45 \cdot 10^{-12}:\\
\;\;\;\;x \cdot \frac{\frac{x}{y}}{x + 1}\\
\mathbf{elif}\;x \leq 1.6 \cdot 10^{+44}:\\
\;\;\;\;\frac{x}{x + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -1.4500000000000001e-12Initial program 78.8%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around 0 72.7%
div-inv72.6%
+-commutative72.6%
*-commutative72.6%
Applied egg-rr72.6%
*-commutative72.6%
associate-*l/72.7%
times-frac80.7%
associate-*l/80.8%
*-lft-identity80.8%
+-commutative80.8%
Simplified80.8%
if -1.4500000000000001e-12 < x < 1.60000000000000002e44Initial program 99.9%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around inf 78.7%
if 1.60000000000000002e44 < x Initial program 75.0%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around inf 82.4%
Final simplification80.0%
(FPCore (x y) :precision binary64 (if (<= x -8.8e-10) (/ x (* (/ y x) (+ x 1.0))) (if (<= x 1.6e+44) (/ x (+ x 1.0)) (/ x y))))
double code(double x, double y) {
double tmp;
if (x <= -8.8e-10) {
tmp = x / ((y / x) * (x + 1.0));
} else if (x <= 1.6e+44) {
tmp = x / (x + 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 <= (-8.8d-10)) then
tmp = x / ((y / x) * (x + 1.0d0))
else if (x <= 1.6d+44) then
tmp = x / (x + 1.0d0)
else
tmp = x / y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -8.8e-10) {
tmp = x / ((y / x) * (x + 1.0));
} else if (x <= 1.6e+44) {
tmp = x / (x + 1.0);
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -8.8e-10: tmp = x / ((y / x) * (x + 1.0)) elif x <= 1.6e+44: tmp = x / (x + 1.0) else: tmp = x / y return tmp
function code(x, y) tmp = 0.0 if (x <= -8.8e-10) tmp = Float64(x / Float64(Float64(y / x) * Float64(x + 1.0))); elseif (x <= 1.6e+44) tmp = Float64(x / Float64(x + 1.0)); else tmp = Float64(x / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -8.8e-10) tmp = x / ((y / x) * (x + 1.0)); elseif (x <= 1.6e+44) tmp = x / (x + 1.0); else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -8.8e-10], N[(x / N[(N[(y / x), $MachinePrecision] * N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.6e+44], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], N[(x / y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -8.8 \cdot 10^{-10}:\\
\;\;\;\;\frac{x}{\frac{y}{x} \cdot \left(x + 1\right)}\\
\mathbf{elif}\;x \leq 1.6 \cdot 10^{+44}:\\
\;\;\;\;\frac{x}{x + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -8.7999999999999996e-10Initial program 78.8%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around 0 72.7%
clear-num72.7%
un-div-inv72.8%
+-commutative72.8%
*-commutative72.8%
associate-/l*80.9%
Applied egg-rr80.9%
*-commutative80.9%
+-commutative80.9%
Simplified80.9%
if -8.7999999999999996e-10 < x < 1.60000000000000002e44Initial program 99.9%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around inf 78.7%
if 1.60000000000000002e44 < x Initial program 75.0%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around inf 82.4%
Final simplification80.0%
(FPCore (x y) :precision binary64 (if (<= x -0.95) 1.0 (if (<= x 1.0) x 1.0)))
double code(double x, double y) {
double tmp;
if (x <= -0.95) {
tmp = 1.0;
} else if (x <= 1.0) {
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.95d0)) then
tmp = 1.0d0
else if (x <= 1.0d0) 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.95) {
tmp = 1.0;
} else if (x <= 1.0) {
tmp = x;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -0.95: tmp = 1.0 elif x <= 1.0: tmp = x else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -0.95) tmp = 1.0; elseif (x <= 1.0) tmp = x; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -0.95) tmp = 1.0; elseif (x <= 1.0) tmp = x; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -0.95], 1.0, If[LessEqual[x, 1.0], x, 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.95:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < -0.94999999999999996 or 1 < x Initial program 78.9%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around inf 23.7%
Taylor expanded in x around inf 22.1%
if -0.94999999999999996 < x < 1Initial program 99.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around 0 77.6%
Final simplification50.5%
(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.6%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around inf 51.9%
Taylor expanded in x around inf 12.8%
Final simplification12.8%
(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 2024059
(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)))