
(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 11 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.8%
associate-/l*99.9%
Simplified99.9%
clear-num99.8%
un-div-inv99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x y)
:precision binary64
(if (<= x -3.5e+41)
(/ x y)
(if (<= x -1.02e-18)
(* x (/ 1.0 (+ x 1.0)))
(if (<= x -5.6e-88)
(* x (/ x y))
(if (<= x 3.9e+51) (/ x (+ x 1.0)) (/ x y))))))
double code(double x, double y) {
double tmp;
if (x <= -3.5e+41) {
tmp = x / y;
} else if (x <= -1.02e-18) {
tmp = x * (1.0 / (x + 1.0));
} else if (x <= -5.6e-88) {
tmp = x * (x / y);
} else if (x <= 3.9e+51) {
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 <= (-3.5d+41)) then
tmp = x / y
else if (x <= (-1.02d-18)) then
tmp = x * (1.0d0 / (x + 1.0d0))
else if (x <= (-5.6d-88)) then
tmp = x * (x / y)
else if (x <= 3.9d+51) 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 <= -3.5e+41) {
tmp = x / y;
} else if (x <= -1.02e-18) {
tmp = x * (1.0 / (x + 1.0));
} else if (x <= -5.6e-88) {
tmp = x * (x / y);
} else if (x <= 3.9e+51) {
tmp = x / (x + 1.0);
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -3.5e+41: tmp = x / y elif x <= -1.02e-18: tmp = x * (1.0 / (x + 1.0)) elif x <= -5.6e-88: tmp = x * (x / y) elif x <= 3.9e+51: tmp = x / (x + 1.0) else: tmp = x / y return tmp
function code(x, y) tmp = 0.0 if (x <= -3.5e+41) tmp = Float64(x / y); elseif (x <= -1.02e-18) tmp = Float64(x * Float64(1.0 / Float64(x + 1.0))); elseif (x <= -5.6e-88) tmp = Float64(x * Float64(x / y)); elseif (x <= 3.9e+51) 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 <= -3.5e+41) tmp = x / y; elseif (x <= -1.02e-18) tmp = x * (1.0 / (x + 1.0)); elseif (x <= -5.6e-88) tmp = x * (x / y); elseif (x <= 3.9e+51) tmp = x / (x + 1.0); else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -3.5e+41], N[(x / y), $MachinePrecision], If[LessEqual[x, -1.02e-18], N[(x * N[(1.0 / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -5.6e-88], N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 3.9e+51], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], N[(x / y), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.5 \cdot 10^{+41}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq -1.02 \cdot 10^{-18}:\\
\;\;\;\;x \cdot \frac{1}{x + 1}\\
\mathbf{elif}\;x \leq -5.6 \cdot 10^{-88}:\\
\;\;\;\;x \cdot \frac{x}{y}\\
\mathbf{elif}\;x \leq 3.9 \cdot 10^{+51}:\\
\;\;\;\;\frac{x}{x + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -3.4999999999999999e41 or 3.89999999999999984e51 < x Initial program 68.6%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around inf 81.7%
if -3.4999999999999999e41 < x < -1.02e-18Initial program 99.9%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in y around inf 72.4%
if -1.02e-18 < x < -5.59999999999999952e-88Initial program 99.7%
associate-/l*99.7%
Simplified99.7%
Taylor expanded in y around 0 75.6%
Taylor expanded in x around 0 75.6%
if -5.59999999999999952e-88 < x < 3.89999999999999984e51Initial program 99.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around inf 79.4%
Final simplification79.6%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ x (+ x 1.0))))
(if (<= x -3.6e+41)
(/ x y)
(if (<= x -1.56e-21)
t_0
(if (<= x -1.85e-88) (* x (/ x y)) (if (<= x 3e+51) t_0 (/ x y)))))))
double code(double x, double y) {
double t_0 = x / (x + 1.0);
double tmp;
if (x <= -3.6e+41) {
tmp = x / y;
} else if (x <= -1.56e-21) {
tmp = t_0;
} else if (x <= -1.85e-88) {
tmp = x * (x / y);
} else if (x <= 3e+51) {
tmp = t_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) :: t_0
real(8) :: tmp
t_0 = x / (x + 1.0d0)
if (x <= (-3.6d+41)) then
tmp = x / y
else if (x <= (-1.56d-21)) then
tmp = t_0
else if (x <= (-1.85d-88)) then
tmp = x * (x / y)
else if (x <= 3d+51) then
tmp = t_0
else
tmp = x / y
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = x / (x + 1.0);
double tmp;
if (x <= -3.6e+41) {
tmp = x / y;
} else if (x <= -1.56e-21) {
tmp = t_0;
} else if (x <= -1.85e-88) {
tmp = x * (x / y);
} else if (x <= 3e+51) {
tmp = t_0;
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): t_0 = x / (x + 1.0) tmp = 0 if x <= -3.6e+41: tmp = x / y elif x <= -1.56e-21: tmp = t_0 elif x <= -1.85e-88: tmp = x * (x / y) elif x <= 3e+51: tmp = t_0 else: tmp = x / y return tmp
function code(x, y) t_0 = Float64(x / Float64(x + 1.0)) tmp = 0.0 if (x <= -3.6e+41) tmp = Float64(x / y); elseif (x <= -1.56e-21) tmp = t_0; elseif (x <= -1.85e-88) tmp = Float64(x * Float64(x / y)); elseif (x <= 3e+51) tmp = t_0; else tmp = Float64(x / y); end return tmp end
function tmp_2 = code(x, y) t_0 = x / (x + 1.0); tmp = 0.0; if (x <= -3.6e+41) tmp = x / y; elseif (x <= -1.56e-21) tmp = t_0; elseif (x <= -1.85e-88) tmp = x * (x / y); elseif (x <= 3e+51) tmp = t_0; else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -3.6e+41], N[(x / y), $MachinePrecision], If[LessEqual[x, -1.56e-21], t$95$0, If[LessEqual[x, -1.85e-88], N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 3e+51], t$95$0, N[(x / y), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{x + 1}\\
\mathbf{if}\;x \leq -3.6 \cdot 10^{+41}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq -1.56 \cdot 10^{-21}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -1.85 \cdot 10^{-88}:\\
\;\;\;\;x \cdot \frac{x}{y}\\
\mathbf{elif}\;x \leq 3 \cdot 10^{+51}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -3.60000000000000025e41 or 3e51 < x Initial program 68.6%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around inf 81.7%
if -3.60000000000000025e41 < x < -1.55999999999999999e-21 or -1.8499999999999999e-88 < x < 3e51Initial program 99.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around inf 78.7%
if -1.55999999999999999e-21 < x < -1.8499999999999999e-88Initial program 99.7%
associate-/l*99.7%
Simplified99.7%
Taylor expanded in y around 0 75.6%
Taylor expanded in x around 0 75.6%
Final simplification79.6%
(FPCore (x y)
:precision binary64
(if (<= x -1.0)
(/ x y)
(if (<= x -5.2e-88)
(* x (/ x y))
(if (<= x 0.88) (* x (- 1.0 x)) (/ x y)))))
double code(double x, double y) {
double tmp;
if (x <= -1.0) {
tmp = x / y;
} else if (x <= -5.2e-88) {
tmp = x * (x / y);
} else if (x <= 0.88) {
tmp = x * (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 <= (-5.2d-88)) then
tmp = x * (x / y)
else if (x <= 0.88d0) then
tmp = x * (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 <= -5.2e-88) {
tmp = x * (x / y);
} else if (x <= 0.88) {
tmp = x * (1.0 - x);
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.0: tmp = x / y elif x <= -5.2e-88: tmp = x * (x / y) elif x <= 0.88: tmp = x * (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 <= -5.2e-88) tmp = Float64(x * Float64(x / y)); elseif (x <= 0.88) tmp = Float64(x * 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 <= -5.2e-88) tmp = x * (x / y); elseif (x <= 0.88) tmp = x * (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, -5.2e-88], N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.88], N[(x * 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 -5.2 \cdot 10^{-88}:\\
\;\;\;\;x \cdot \frac{x}{y}\\
\mathbf{elif}\;x \leq 0.88:\\
\;\;\;\;x \cdot \left(1 - x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -1 or 0.880000000000000004 < x Initial program 73.8%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around inf 73.6%
if -1 < x < -5.20000000000000027e-88Initial program 99.7%
associate-/l*99.7%
Simplified99.7%
Taylor expanded in y around 0 67.6%
Taylor expanded in x around 0 67.4%
if -5.20000000000000027e-88 < x < 0.880000000000000004Initial program 99.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around inf 81.3%
Taylor expanded in x around 0 80.6%
neg-mul-180.6%
sub-neg80.6%
Simplified80.6%
(FPCore (x y) :precision binary64 (if (or (<= y -4.6e-30) (not (<= y 5.8e-24))) (/ x (+ x 1.0)) (* x (/ (/ x y) (+ x 1.0)))))
double code(double x, double y) {
double tmp;
if ((y <= -4.6e-30) || !(y <= 5.8e-24)) {
tmp = x / (x + 1.0);
} else {
tmp = x * ((x / y) / (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 ((y <= (-4.6d-30)) .or. (.not. (y <= 5.8d-24))) then
tmp = x / (x + 1.0d0)
else
tmp = x * ((x / y) / (x + 1.0d0))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -4.6e-30) || !(y <= 5.8e-24)) {
tmp = x / (x + 1.0);
} else {
tmp = x * ((x / y) / (x + 1.0));
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -4.6e-30) or not (y <= 5.8e-24): tmp = x / (x + 1.0) else: tmp = x * ((x / y) / (x + 1.0)) return tmp
function code(x, y) tmp = 0.0 if ((y <= -4.6e-30) || !(y <= 5.8e-24)) tmp = Float64(x / Float64(x + 1.0)); else tmp = Float64(x * Float64(Float64(x / y) / Float64(x + 1.0))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -4.6e-30) || ~((y <= 5.8e-24))) tmp = x / (x + 1.0); else tmp = x * ((x / y) / (x + 1.0)); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -4.6e-30], N[Not[LessEqual[y, 5.8e-24]], $MachinePrecision]], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], N[(x * N[(N[(x / y), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.6 \cdot 10^{-30} \lor \neg \left(y \leq 5.8 \cdot 10^{-24}\right):\\
\;\;\;\;\frac{x}{x + 1}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{\frac{x}{y}}{x + 1}\\
\end{array}
\end{array}
if y < -4.59999999999999968e-30 or 5.7999999999999997e-24 < y Initial program 86.7%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around inf 75.5%
if -4.59999999999999968e-30 < y < 5.7999999999999997e-24Initial program 89.1%
associate-/l*99.8%
Simplified99.8%
clear-num99.7%
un-div-inv99.8%
Applied egg-rr99.8%
Taylor expanded in y around 0 80.5%
associate-/l*80.5%
Simplified80.5%
associate-/r*80.5%
associate-/r/80.5%
Applied egg-rr80.5%
Final simplification77.7%
(FPCore (x y) :precision binary64 (if (or (<= y -4e-30) (not (<= y 5.2e-24))) (/ x (+ x 1.0)) (/ x (+ y (/ y x)))))
double code(double x, double y) {
double tmp;
if ((y <= -4e-30) || !(y <= 5.2e-24)) {
tmp = x / (x + 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 ((y <= (-4d-30)) .or. (.not. (y <= 5.2d-24))) then
tmp = x / (x + 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 ((y <= -4e-30) || !(y <= 5.2e-24)) {
tmp = x / (x + 1.0);
} else {
tmp = x / (y + (y / x));
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -4e-30) or not (y <= 5.2e-24): tmp = x / (x + 1.0) else: tmp = x / (y + (y / x)) return tmp
function code(x, y) tmp = 0.0 if ((y <= -4e-30) || !(y <= 5.2e-24)) tmp = Float64(x / Float64(x + 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 ((y <= -4e-30) || ~((y <= 5.2e-24))) tmp = x / (x + 1.0); else tmp = x / (y + (y / x)); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -4e-30], N[Not[LessEqual[y, 5.2e-24]], $MachinePrecision]], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], N[(x / N[(y + N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4 \cdot 10^{-30} \lor \neg \left(y \leq 5.2 \cdot 10^{-24}\right):\\
\;\;\;\;\frac{x}{x + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y + \frac{y}{x}}\\
\end{array}
\end{array}
if y < -4e-30 or 5.2e-24 < y Initial program 86.7%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around inf 75.5%
if -4e-30 < y < 5.2e-24Initial program 89.1%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around 0 80.4%
Taylor expanded in y around 0 68.5%
+-commutative68.5%
*-commutative68.5%
unpow268.5%
associate-*r/80.4%
associate-/l/80.5%
*-commutative80.5%
associate-/l/80.4%
associate-/r/80.5%
associate-*r/80.5%
*-commutative80.5%
distribute-rgt-in75.2%
*-lft-identity75.2%
associate-*l/75.1%
associate-*r*80.4%
rgt-mult-inverse80.5%
*-lft-identity80.5%
*-lft-identity80.5%
Simplified80.5%
Final simplification77.7%
(FPCore (x y) :precision binary64 (if (or (<= x -1.0) (not (<= x 0.82))) (/ x y) (* x (- 1.0 x))))
double code(double x, double y) {
double tmp;
if ((x <= -1.0) || !(x <= 0.82)) {
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 <= 0.82d0))) 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 <= 0.82)) {
tmp = x / y;
} else {
tmp = x * (1.0 - x);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -1.0) or not (x <= 0.82): tmp = x / y else: tmp = x * (1.0 - x) return tmp
function code(x, y) tmp = 0.0 if ((x <= -1.0) || !(x <= 0.82)) 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 <= 0.82))) 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, 0.82]], $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 0.82\right):\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - x\right)\\
\end{array}
\end{array}
if x < -1 or 0.819999999999999951 < x Initial program 73.8%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around inf 73.6%
if -1 < x < 0.819999999999999951Initial program 99.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around inf 73.3%
Taylor expanded in x around 0 72.7%
neg-mul-172.7%
sub-neg72.7%
Simplified72.7%
Final simplification73.1%
(FPCore (x y) :precision binary64 (if (or (<= x -1.0) (not (<= x 1.9e-5))) (/ x y) x))
double code(double x, double y) {
double tmp;
if ((x <= -1.0) || !(x <= 1.9e-5)) {
tmp = x / y;
} else {
tmp = x;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((x <= (-1.0d0)) .or. (.not. (x <= 1.9d-5))) then
tmp = x / y
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -1.0) || !(x <= 1.9e-5)) {
tmp = x / y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -1.0) or not (x <= 1.9e-5): tmp = x / y else: tmp = x return tmp
function code(x, y) tmp = 0.0 if ((x <= -1.0) || !(x <= 1.9e-5)) tmp = Float64(x / y); else tmp = x; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -1.0) || ~((x <= 1.9e-5))) tmp = x / y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -1.0], N[Not[LessEqual[x, 1.9e-5]], $MachinePrecision]], N[(x / y), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 1.9 \cdot 10^{-5}\right):\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -1 or 1.9000000000000001e-5 < x Initial program 74.5%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around inf 72.0%
if -1 < x < 1.9000000000000001e-5Initial program 99.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around 0 73.5%
Final simplification72.8%
(FPCore (x y) :precision binary64 (if (<= x -1.0) 1.0 (if (<= x 1.0) x 1.0)))
double code(double x, double y) {
double tmp;
if (x <= -1.0) {
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 <= (-1.0d0)) 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 <= -1.0) {
tmp = 1.0;
} else if (x <= 1.0) {
tmp = x;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.0: tmp = 1.0 elif x <= 1.0: tmp = x else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -1.0) 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 <= -1.0) tmp = 1.0; elseif (x <= 1.0) tmp = x; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.0], 1.0, If[LessEqual[x, 1.0], x, 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < -1 or 1 < x Initial program 73.8%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around inf 26.9%
un-div-inv27.0%
+-commutative27.0%
Applied egg-rr27.0%
Taylor expanded in x around inf 26.6%
if -1 < x < 1Initial program 99.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around 0 72.1%
(FPCore (x y) :precision binary64 (* x (/ (+ 1.0 (/ x y)) (+ x 1.0))))
double code(double x, double y) {
return x * ((1.0 + (x / y)) / (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)) / (x + 1.0d0))
end function
public static double code(double x, double y) {
return x * ((1.0 + (x / y)) / (x + 1.0));
}
def code(x, y): return x * ((1.0 + (x / y)) / (x + 1.0))
function code(x, y) return Float64(x * Float64(Float64(1.0 + Float64(x / y)) / Float64(x + 1.0))) end
function tmp = code(x, y) tmp = x * ((1.0 + (x / y)) / (x + 1.0)); end
code[x_, y_] := N[(x * N[(N[(1.0 + N[(x / y), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \frac{1 + \frac{x}{y}}{x + 1}
\end{array}
Initial program 87.8%
associate-/l*99.9%
Simplified99.9%
Final simplification99.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.8%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around inf 51.8%
un-div-inv51.8%
+-commutative51.8%
Applied egg-rr51.8%
Taylor expanded in x around inf 14.5%
(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 2024137
(FPCore (x y)
:name "Codec.Picture.Types:toneMapping from JuicyPixels-3.2.6.1"
:precision binary64
:alt
(! :herbie-platform default (* (/ x 1) (/ (+ (/ x y) 1) (+ x 1))))
(/ (* x (+ (/ x y) 1.0)) (+ x 1.0)))