
(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 (let* ((t_0 (/ x (+ x 1.0)))) (+ t_0 (* t_0 (/ x y)))))
double code(double x, double y) {
double t_0 = x / (x + 1.0);
return t_0 + (t_0 * (x / y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
t_0 = x / (x + 1.0d0)
code = t_0 + (t_0 * (x / y))
end function
public static double code(double x, double y) {
double t_0 = x / (x + 1.0);
return t_0 + (t_0 * (x / y));
}
def code(x, y): t_0 = x / (x + 1.0) return t_0 + (t_0 * (x / y))
function code(x, y) t_0 = Float64(x / Float64(x + 1.0)) return Float64(t_0 + Float64(t_0 * Float64(x / y))) end
function tmp = code(x, y) t_0 = x / (x + 1.0); tmp = t_0 + (t_0 * (x / y)); end
code[x_, y_] := Block[{t$95$0 = N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, N[(t$95$0 + N[(t$95$0 * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{x + 1}\\
t\_0 + t\_0 \cdot \frac{x}{y}
\end{array}
\end{array}
Initial program 87.7%
associate-/l*99.9%
Simplified99.9%
clear-num99.7%
un-div-inv99.9%
Applied egg-rr99.9%
associate-/r/99.9%
+-commutative99.9%
un-div-inv99.8%
+-commutative99.8%
distribute-lft-in99.8%
*-commutative99.8%
*-un-lft-identity99.8%
un-div-inv99.8%
+-commutative99.8%
un-div-inv99.9%
+-commutative99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ x (+ y (/ y x)))))
(if (<= x -6.8e-7)
t_0
(if (<= x 2.9e-7)
(* x (+ 1.0 (* x (/ 1.0 y))))
(if (or (<= x 5.7e+104) (not (<= x 3.15e+134))) t_0 1.0)))))
double code(double x, double y) {
double t_0 = x / (y + (y / x));
double tmp;
if (x <= -6.8e-7) {
tmp = t_0;
} else if (x <= 2.9e-7) {
tmp = x * (1.0 + (x * (1.0 / y)));
} else if ((x <= 5.7e+104) || !(x <= 3.15e+134)) {
tmp = t_0;
} else {
tmp = 1.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 = x / (y + (y / x))
if (x <= (-6.8d-7)) then
tmp = t_0
else if (x <= 2.9d-7) then
tmp = x * (1.0d0 + (x * (1.0d0 / y)))
else if ((x <= 5.7d+104) .or. (.not. (x <= 3.15d+134))) then
tmp = t_0
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = x / (y + (y / x));
double tmp;
if (x <= -6.8e-7) {
tmp = t_0;
} else if (x <= 2.9e-7) {
tmp = x * (1.0 + (x * (1.0 / y)));
} else if ((x <= 5.7e+104) || !(x <= 3.15e+134)) {
tmp = t_0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): t_0 = x / (y + (y / x)) tmp = 0 if x <= -6.8e-7: tmp = t_0 elif x <= 2.9e-7: tmp = x * (1.0 + (x * (1.0 / y))) elif (x <= 5.7e+104) or not (x <= 3.15e+134): tmp = t_0 else: tmp = 1.0 return tmp
function code(x, y) t_0 = Float64(x / Float64(y + Float64(y / x))) tmp = 0.0 if (x <= -6.8e-7) tmp = t_0; elseif (x <= 2.9e-7) tmp = Float64(x * Float64(1.0 + Float64(x * Float64(1.0 / y)))); elseif ((x <= 5.7e+104) || !(x <= 3.15e+134)) tmp = t_0; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) t_0 = x / (y + (y / x)); tmp = 0.0; if (x <= -6.8e-7) tmp = t_0; elseif (x <= 2.9e-7) tmp = x * (1.0 + (x * (1.0 / y))); elseif ((x <= 5.7e+104) || ~((x <= 3.15e+134))) tmp = t_0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x / N[(y + N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -6.8e-7], t$95$0, If[LessEqual[x, 2.9e-7], N[(x * N[(1.0 + N[(x * N[(1.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[x, 5.7e+104], N[Not[LessEqual[x, 3.15e+134]], $MachinePrecision]], t$95$0, 1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{y + \frac{y}{x}}\\
\mathbf{if}\;x \leq -6.8 \cdot 10^{-7}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 2.9 \cdot 10^{-7}:\\
\;\;\;\;x \cdot \left(1 + x \cdot \frac{1}{y}\right)\\
\mathbf{elif}\;x \leq 5.7 \cdot 10^{+104} \lor \neg \left(x \leq 3.15 \cdot 10^{+134}\right):\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < -6.79999999999999948e-7 or 2.8999999999999998e-7 < x < 5.69999999999999985e104 or 3.1500000000000001e134 < x Initial program 75.3%
associate-/l*99.9%
Simplified99.9%
clear-num99.7%
un-div-inv100.0%
Applied egg-rr100.0%
Taylor expanded in y around 0 66.8%
Taylor expanded in x around 0 66.8%
distribute-rgt1-in66.8%
*-commutative66.8%
associate-*r/83.2%
*-lft-identity83.2%
associate-*l/83.1%
distribute-rgt-in83.1%
rgt-mult-inverse83.2%
*-lft-identity83.2%
distribute-lft-in83.2%
*-rgt-identity83.2%
associate-*r/83.2%
*-rgt-identity83.2%
Simplified83.2%
if -6.79999999999999948e-7 < x < 2.8999999999999998e-7Initial program 99.8%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around 0 99.2%
Taylor expanded in y around 0 98.4%
if 5.69999999999999985e104 < x < 3.1500000000000001e134Initial program 100.0%
associate-/l*99.7%
Simplified99.7%
Taylor expanded in y around inf 99.7%
un-div-inv100.0%
+-commutative100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 100.0%
Final simplification90.9%
(FPCore (x y)
:precision binary64
(if (<= x -1.0)
(/ x y)
(if (<= x 0.022)
x
(if (or (<= x 4.9e+104) (not (<= x 3.15e+134))) (/ x y) 1.0))))
double code(double x, double y) {
double tmp;
if (x <= -1.0) {
tmp = x / y;
} else if (x <= 0.022) {
tmp = x;
} else if ((x <= 4.9e+104) || !(x <= 3.15e+134)) {
tmp = x / y;
} 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 = x / y
else if (x <= 0.022d0) then
tmp = x
else if ((x <= 4.9d+104) .or. (.not. (x <= 3.15d+134))) then
tmp = x / y
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 = x / y;
} else if (x <= 0.022) {
tmp = x;
} else if ((x <= 4.9e+104) || !(x <= 3.15e+134)) {
tmp = x / y;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.0: tmp = x / y elif x <= 0.022: tmp = x elif (x <= 4.9e+104) or not (x <= 3.15e+134): tmp = x / y else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -1.0) tmp = Float64(x / y); elseif (x <= 0.022) tmp = x; elseif ((x <= 4.9e+104) || !(x <= 3.15e+134)) tmp = Float64(x / y); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1.0) tmp = x / y; elseif (x <= 0.022) tmp = x; elseif ((x <= 4.9e+104) || ~((x <= 3.15e+134))) tmp = x / y; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.0], N[(x / y), $MachinePrecision], If[LessEqual[x, 0.022], x, If[Or[LessEqual[x, 4.9e+104], N[Not[LessEqual[x, 3.15e+134]], $MachinePrecision]], N[(x / y), $MachinePrecision], 1.0]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq 0.022:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 4.9 \cdot 10^{+104} \lor \neg \left(x \leq 3.15 \cdot 10^{+134}\right):\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < -1 or 0.021999999999999999 < x < 4.89999999999999985e104 or 3.1500000000000001e134 < x Initial program 75.1%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around inf 80.9%
if -1 < x < 0.021999999999999999Initial program 99.8%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around 0 64.1%
if 4.89999999999999985e104 < x < 3.1500000000000001e134Initial program 100.0%
associate-/l*99.7%
Simplified99.7%
Taylor expanded in y around inf 99.7%
un-div-inv100.0%
+-commutative100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 100.0%
Final simplification73.0%
(FPCore (x y)
:precision binary64
(if (<= x -1.0)
(/ x y)
(if (<= x 0.112)
(* x (- 1.0 x))
(if (or (<= x 5.7e+104) (not (<= x 3.3e+134))) (/ x y) 1.0))))
double code(double x, double y) {
double tmp;
if (x <= -1.0) {
tmp = x / y;
} else if (x <= 0.112) {
tmp = x * (1.0 - x);
} else if ((x <= 5.7e+104) || !(x <= 3.3e+134)) {
tmp = x / y;
} 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 = x / y
else if (x <= 0.112d0) then
tmp = x * (1.0d0 - x)
else if ((x <= 5.7d+104) .or. (.not. (x <= 3.3d+134))) then
tmp = x / y
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 = x / y;
} else if (x <= 0.112) {
tmp = x * (1.0 - x);
} else if ((x <= 5.7e+104) || !(x <= 3.3e+134)) {
tmp = x / y;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.0: tmp = x / y elif x <= 0.112: tmp = x * (1.0 - x) elif (x <= 5.7e+104) or not (x <= 3.3e+134): tmp = x / y else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -1.0) tmp = Float64(x / y); elseif (x <= 0.112) tmp = Float64(x * Float64(1.0 - x)); elseif ((x <= 5.7e+104) || !(x <= 3.3e+134)) tmp = Float64(x / y); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1.0) tmp = x / y; elseif (x <= 0.112) tmp = x * (1.0 - x); elseif ((x <= 5.7e+104) || ~((x <= 3.3e+134))) tmp = x / y; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.0], N[(x / y), $MachinePrecision], If[LessEqual[x, 0.112], N[(x * N[(1.0 - x), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[x, 5.7e+104], N[Not[LessEqual[x, 3.3e+134]], $MachinePrecision]], N[(x / y), $MachinePrecision], 1.0]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq 0.112:\\
\;\;\;\;x \cdot \left(1 - x\right)\\
\mathbf{elif}\;x \leq 5.7 \cdot 10^{+104} \lor \neg \left(x \leq 3.3 \cdot 10^{+134}\right):\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < -1 or 0.112000000000000002 < x < 5.69999999999999985e104 or 3.3e134 < x Initial program 75.1%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around inf 80.9%
if -1 < x < 0.112000000000000002Initial program 99.8%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around inf 65.0%
Taylor expanded in x around 0 65.0%
neg-mul-165.0%
sub-neg65.0%
Simplified65.0%
if 5.69999999999999985e104 < x < 3.3e134Initial program 100.0%
associate-/l*99.7%
Simplified99.7%
Taylor expanded in y around inf 99.7%
un-div-inv100.0%
+-commutative100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 100.0%
Final simplification73.4%
(FPCore (x y)
:precision binary64
(if (<= x -9.5e+29)
(/ x y)
(if (<= x 0.4)
(/ x (+ x 1.0))
(if (or (<= x 5.7e+104) (not (<= x 3.15e+134))) (/ x y) 1.0))))
double code(double x, double y) {
double tmp;
if (x <= -9.5e+29) {
tmp = x / y;
} else if (x <= 0.4) {
tmp = x / (x + 1.0);
} else if ((x <= 5.7e+104) || !(x <= 3.15e+134)) {
tmp = x / y;
} 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 <= (-9.5d+29)) then
tmp = x / y
else if (x <= 0.4d0) then
tmp = x / (x + 1.0d0)
else if ((x <= 5.7d+104) .or. (.not. (x <= 3.15d+134))) then
tmp = x / y
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -9.5e+29) {
tmp = x / y;
} else if (x <= 0.4) {
tmp = x / (x + 1.0);
} else if ((x <= 5.7e+104) || !(x <= 3.15e+134)) {
tmp = x / y;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -9.5e+29: tmp = x / y elif x <= 0.4: tmp = x / (x + 1.0) elif (x <= 5.7e+104) or not (x <= 3.15e+134): tmp = x / y else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -9.5e+29) tmp = Float64(x / y); elseif (x <= 0.4) tmp = Float64(x / Float64(x + 1.0)); elseif ((x <= 5.7e+104) || !(x <= 3.15e+134)) tmp = Float64(x / y); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -9.5e+29) tmp = x / y; elseif (x <= 0.4) tmp = x / (x + 1.0); elseif ((x <= 5.7e+104) || ~((x <= 3.15e+134))) tmp = x / y; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -9.5e+29], N[(x / y), $MachinePrecision], If[LessEqual[x, 0.4], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[x, 5.7e+104], N[Not[LessEqual[x, 3.15e+134]], $MachinePrecision]], N[(x / y), $MachinePrecision], 1.0]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9.5 \cdot 10^{+29}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq 0.4:\\
\;\;\;\;\frac{x}{x + 1}\\
\mathbf{elif}\;x \leq 5.7 \cdot 10^{+104} \lor \neg \left(x \leq 3.15 \cdot 10^{+134}\right):\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < -9.5000000000000003e29 or 0.40000000000000002 < x < 5.69999999999999985e104 or 3.1500000000000001e134 < x Initial program 73.7%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around inf 83.8%
if -9.5000000000000003e29 < x < 0.40000000000000002Initial program 99.8%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around inf 63.9%
if 5.69999999999999985e104 < x < 3.1500000000000001e134Initial program 100.0%
associate-/l*99.7%
Simplified99.7%
Taylor expanded in y around inf 99.7%
un-div-inv100.0%
+-commutative100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 100.0%
Final simplification73.8%
(FPCore (x y) :precision binary64 (if (or (<= x -0.027) (not (<= x 0.41))) (+ (/ x (+ x 1.0)) (/ x y)) (* x (+ 1.0 (* x (+ (/ 1.0 y) -1.0))))))
double code(double x, double y) {
double tmp;
if ((x <= -0.027) || !(x <= 0.41)) {
tmp = (x / (x + 1.0)) + (x / y);
} else {
tmp = x * (1.0 + (x * ((1.0 / y) + -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.027d0)) .or. (.not. (x <= 0.41d0))) then
tmp = (x / (x + 1.0d0)) + (x / y)
else
tmp = x * (1.0d0 + (x * ((1.0d0 / y) + (-1.0d0))))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -0.027) || !(x <= 0.41)) {
tmp = (x / (x + 1.0)) + (x / y);
} else {
tmp = x * (1.0 + (x * ((1.0 / y) + -1.0)));
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -0.027) or not (x <= 0.41): tmp = (x / (x + 1.0)) + (x / y) else: tmp = x * (1.0 + (x * ((1.0 / y) + -1.0))) return tmp
function code(x, y) tmp = 0.0 if ((x <= -0.027) || !(x <= 0.41)) tmp = Float64(Float64(x / Float64(x + 1.0)) + Float64(x / y)); else tmp = Float64(x * Float64(1.0 + Float64(x * Float64(Float64(1.0 / y) + -1.0)))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -0.027) || ~((x <= 0.41))) tmp = (x / (x + 1.0)) + (x / y); else tmp = x * (1.0 + (x * ((1.0 / y) + -1.0))); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -0.027], N[Not[LessEqual[x, 0.41]], $MachinePrecision]], N[(N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] + N[(x / y), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 + N[(x * N[(N[(1.0 / y), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.027 \lor \neg \left(x \leq 0.41\right):\\
\;\;\;\;\frac{x}{x + 1} + \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 + x \cdot \left(\frac{1}{y} + -1\right)\right)\\
\end{array}
\end{array}
if x < -0.0269999999999999997 or 0.409999999999999976 < x Initial program 75.9%
associate-/l*99.9%
Simplified99.9%
clear-num99.7%
un-div-inv100.0%
Applied egg-rr100.0%
associate-/r/100.0%
+-commutative100.0%
un-div-inv99.8%
+-commutative99.8%
distribute-lft-in99.8%
*-commutative99.8%
*-un-lft-identity99.8%
un-div-inv99.9%
+-commutative99.9%
un-div-inv100.0%
+-commutative100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 98.5%
if -0.0269999999999999997 < x < 0.409999999999999976Initial program 99.8%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around 0 98.0%
Final simplification98.3%
(FPCore (x y) :precision binary64 (if (or (<= x -1.15e-9) (not (<= x 1.7e-12))) (+ (/ x (+ x 1.0)) (/ x y)) (* x (+ 1.0 (* x (/ 1.0 y))))))
double code(double x, double y) {
double tmp;
if ((x <= -1.15e-9) || !(x <= 1.7e-12)) {
tmp = (x / (x + 1.0)) + (x / y);
} else {
tmp = x * (1.0 + (x * (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.15d-9)) .or. (.not. (x <= 1.7d-12))) then
tmp = (x / (x + 1.0d0)) + (x / y)
else
tmp = x * (1.0d0 + (x * (1.0d0 / y)))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -1.15e-9) || !(x <= 1.7e-12)) {
tmp = (x / (x + 1.0)) + (x / y);
} else {
tmp = x * (1.0 + (x * (1.0 / y)));
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -1.15e-9) or not (x <= 1.7e-12): tmp = (x / (x + 1.0)) + (x / y) else: tmp = x * (1.0 + (x * (1.0 / y))) return tmp
function code(x, y) tmp = 0.0 if ((x <= -1.15e-9) || !(x <= 1.7e-12)) tmp = Float64(Float64(x / Float64(x + 1.0)) + Float64(x / y)); else tmp = Float64(x * Float64(1.0 + Float64(x * Float64(1.0 / y)))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -1.15e-9) || ~((x <= 1.7e-12))) tmp = (x / (x + 1.0)) + (x / y); else tmp = x * (1.0 + (x * (1.0 / y))); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -1.15e-9], N[Not[LessEqual[x, 1.7e-12]], $MachinePrecision]], N[(N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] + N[(x / y), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 + N[(x * N[(1.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.15 \cdot 10^{-9} \lor \neg \left(x \leq 1.7 \cdot 10^{-12}\right):\\
\;\;\;\;\frac{x}{x + 1} + \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 + x \cdot \frac{1}{y}\right)\\
\end{array}
\end{array}
if x < -1.15e-9 or 1.7e-12 < x Initial program 76.7%
associate-/l*99.9%
Simplified99.9%
clear-num99.7%
un-div-inv100.0%
Applied egg-rr100.0%
associate-/r/100.0%
+-commutative100.0%
un-div-inv99.8%
+-commutative99.8%
distribute-lft-in99.8%
*-commutative99.8%
*-un-lft-identity99.8%
un-div-inv99.8%
+-commutative99.8%
un-div-inv100.0%
+-commutative100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 96.9%
if -1.15e-9 < x < 1.7e-12Initial program 99.8%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around 0 99.2%
Taylor expanded in y around 0 99.1%
Final simplification98.0%
(FPCore (x y) :precision binary64 (if (or (<= y -7.4e-14) (not (<= y 8.5e+71))) (/ x (+ x 1.0)) (/ x (+ y (/ y x)))))
double code(double x, double y) {
double tmp;
if ((y <= -7.4e-14) || !(y <= 8.5e+71)) {
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 <= (-7.4d-14)) .or. (.not. (y <= 8.5d+71))) 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 <= -7.4e-14) || !(y <= 8.5e+71)) {
tmp = x / (x + 1.0);
} else {
tmp = x / (y + (y / x));
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -7.4e-14) or not (y <= 8.5e+71): tmp = x / (x + 1.0) else: tmp = x / (y + (y / x)) return tmp
function code(x, y) tmp = 0.0 if ((y <= -7.4e-14) || !(y <= 8.5e+71)) 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 <= -7.4e-14) || ~((y <= 8.5e+71))) tmp = x / (x + 1.0); else tmp = x / (y + (y / x)); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -7.4e-14], N[Not[LessEqual[y, 8.5e+71]], $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 -7.4 \cdot 10^{-14} \lor \neg \left(y \leq 8.5 \cdot 10^{+71}\right):\\
\;\;\;\;\frac{x}{x + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y + \frac{y}{x}}\\
\end{array}
\end{array}
if y < -7.40000000000000002e-14 or 8.4999999999999996e71 < y Initial program 84.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around inf 76.7%
if -7.40000000000000002e-14 < y < 8.4999999999999996e71Initial program 89.8%
associate-/l*99.8%
Simplified99.8%
clear-num99.7%
un-div-inv99.8%
Applied egg-rr99.8%
Taylor expanded in y around 0 81.4%
Taylor expanded in x around 0 81.4%
distribute-rgt1-in81.4%
*-commutative81.4%
associate-*r/82.1%
*-lft-identity82.1%
associate-*l/82.0%
distribute-rgt-in82.0%
rgt-mult-inverse82.1%
*-lft-identity82.1%
distribute-lft-in82.1%
*-rgt-identity82.1%
associate-*r/82.1%
*-rgt-identity82.1%
Simplified82.1%
Final simplification79.8%
(FPCore (x y) :precision binary64 (if (<= x -2.3) 1.0 (if (<= x 7.5e+17) x 1.0)))
double code(double x, double y) {
double tmp;
if (x <= -2.3) {
tmp = 1.0;
} else if (x <= 7.5e+17) {
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 <= (-2.3d0)) then
tmp = 1.0d0
else if (x <= 7.5d+17) 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 <= -2.3) {
tmp = 1.0;
} else if (x <= 7.5e+17) {
tmp = x;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -2.3: tmp = 1.0 elif x <= 7.5e+17: tmp = x else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -2.3) tmp = 1.0; elseif (x <= 7.5e+17) tmp = x; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -2.3) tmp = 1.0; elseif (x <= 7.5e+17) tmp = x; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -2.3], 1.0, If[LessEqual[x, 7.5e+17], x, 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.3:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 7.5 \cdot 10^{+17}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < -2.2999999999999998 or 7.5e17 < x Initial program 75.1%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around inf 23.6%
un-div-inv23.7%
+-commutative23.7%
Applied egg-rr23.7%
Taylor expanded in x around inf 23.2%
if -2.2999999999999998 < x < 7.5e17Initial program 99.8%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around 0 62.0%
Final simplification43.0%
(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.7%
associate-/l*99.9%
Simplified99.9%
Final simplification99.9%
(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%
clear-num99.7%
un-div-inv99.9%
Applied egg-rr99.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.7%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around inf 43.6%
un-div-inv43.6%
+-commutative43.6%
Applied egg-rr43.6%
Taylor expanded in x around inf 13.2%
Final simplification13.2%
(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 2024071
(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)))