
(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 13 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 86.6%
associate-/l*99.9%
Simplified99.9%
associate-/r/99.9%
+-commutative99.9%
distribute-rgt-in99.9%
*-un-lft-identity99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ x (+ x 1.0))))
(if (<= x -1.0)
(+ t_0 (/ x y))
(if (<= x 39000.0)
(+ t_0 (* x (/ x y)))
(+ (+ 1.0 (/ x y)) (/ -1.0 y))))))
double code(double x, double y) {
double t_0 = x / (x + 1.0);
double tmp;
if (x <= -1.0) {
tmp = t_0 + (x / y);
} else if (x <= 39000.0) {
tmp = t_0 + (x * (x / y));
} else {
tmp = (1.0 + (x / y)) + (-1.0 / 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 <= (-1.0d0)) then
tmp = t_0 + (x / y)
else if (x <= 39000.0d0) then
tmp = t_0 + (x * (x / y))
else
tmp = (1.0d0 + (x / y)) + ((-1.0d0) / 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 <= -1.0) {
tmp = t_0 + (x / y);
} else if (x <= 39000.0) {
tmp = t_0 + (x * (x / y));
} else {
tmp = (1.0 + (x / y)) + (-1.0 / y);
}
return tmp;
}
def code(x, y): t_0 = x / (x + 1.0) tmp = 0 if x <= -1.0: tmp = t_0 + (x / y) elif x <= 39000.0: tmp = t_0 + (x * (x / y)) else: tmp = (1.0 + (x / y)) + (-1.0 / y) return tmp
function code(x, y) t_0 = Float64(x / Float64(x + 1.0)) tmp = 0.0 if (x <= -1.0) tmp = Float64(t_0 + Float64(x / y)); elseif (x <= 39000.0) tmp = Float64(t_0 + Float64(x * Float64(x / y))); else tmp = Float64(Float64(1.0 + Float64(x / y)) + Float64(-1.0 / y)); end return tmp end
function tmp_2 = code(x, y) t_0 = x / (x + 1.0); tmp = 0.0; if (x <= -1.0) tmp = t_0 + (x / y); elseif (x <= 39000.0) tmp = t_0 + (x * (x / y)); else tmp = (1.0 + (x / y)) + (-1.0 / y); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.0], N[(t$95$0 + N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 39000.0], N[(t$95$0 + N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(x / y), $MachinePrecision]), $MachinePrecision] + N[(-1.0 / y), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{x + 1}\\
\mathbf{if}\;x \leq -1:\\
\;\;\;\;t_0 + \frac{x}{y}\\
\mathbf{elif}\;x \leq 39000:\\
\;\;\;\;t_0 + x \cdot \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\left(1 + \frac{x}{y}\right) + \frac{-1}{y}\\
\end{array}
\end{array}
if x < -1Initial program 72.8%
associate-/l*99.9%
Simplified99.9%
associate-/r/100.0%
+-commutative100.0%
distribute-rgt-in100.0%
*-un-lft-identity100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 98.5%
if -1 < x < 39000Initial program 99.8%
associate-/l*99.8%
Simplified99.8%
associate-/r/99.8%
+-commutative99.8%
distribute-rgt-in99.8%
*-un-lft-identity99.8%
Applied egg-rr99.8%
Taylor expanded in x around 0 99.3%
if 39000 < x Initial program 74.1%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around inf 99.7%
Final simplification99.2%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ 1.0 (/ x y))))
(if (<= x -390000.0)
t_0
(if (<= x 7.7e-75)
(/ x (+ x 1.0))
(if (<= x 1260000000.0) (/ x (+ y (/ y x))) t_0)))))
double code(double x, double y) {
double t_0 = 1.0 + (x / y);
double tmp;
if (x <= -390000.0) {
tmp = t_0;
} else if (x <= 7.7e-75) {
tmp = x / (x + 1.0);
} else if (x <= 1260000000.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 / y)
if (x <= (-390000.0d0)) then
tmp = t_0
else if (x <= 7.7d-75) then
tmp = x / (x + 1.0d0)
else if (x <= 1260000000.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 / y);
double tmp;
if (x <= -390000.0) {
tmp = t_0;
} else if (x <= 7.7e-75) {
tmp = x / (x + 1.0);
} else if (x <= 1260000000.0) {
tmp = x / (y + (y / x));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 + (x / y) tmp = 0 if x <= -390000.0: tmp = t_0 elif x <= 7.7e-75: tmp = x / (x + 1.0) elif x <= 1260000000.0: tmp = x / (y + (y / x)) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(1.0 + Float64(x / y)) tmp = 0.0 if (x <= -390000.0) tmp = t_0; elseif (x <= 7.7e-75) tmp = Float64(x / Float64(x + 1.0)); elseif (x <= 1260000000.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 / y); tmp = 0.0; if (x <= -390000.0) tmp = t_0; elseif (x <= 7.7e-75) tmp = x / (x + 1.0); elseif (x <= 1260000000.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[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -390000.0], t$95$0, If[LessEqual[x, 7.7e-75], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1260000000.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}{y}\\
\mathbf{if}\;x \leq -390000:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 7.7 \cdot 10^{-75}:\\
\;\;\;\;\frac{x}{x + 1}\\
\mathbf{elif}\;x \leq 1260000000:\\
\;\;\;\;\frac{x}{y + \frac{y}{x}}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -3.9e5 or 1.26e9 < x Initial program 72.4%
associate-/l*100.0%
Simplified100.0%
associate-/r/100.0%
+-commutative100.0%
distribute-rgt-in100.0%
*-un-lft-identity100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 99.9%
Taylor expanded in x around inf 99.8%
+-commutative99.8%
Simplified99.8%
if -3.9e5 < x < 7.69999999999999958e-75Initial program 99.9%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around inf 75.7%
if 7.69999999999999958e-75 < x < 1.26e9Initial program 99.3%
*-commutative99.3%
associate-/l*99.3%
+-commutative99.3%
remove-double-neg99.3%
unsub-neg99.3%
div-sub99.4%
distribute-frac-neg99.4%
*-inverses99.4%
metadata-eval99.4%
Simplified99.4%
Taylor expanded in y around 0 78.9%
distribute-rgt-in78.9%
*-lft-identity78.9%
associate-*l/78.8%
*-lft-identity78.8%
Simplified78.8%
Final simplification87.4%
(FPCore (x y) :precision binary64 (if (or (<= x -3.1e-12) (not (<= x 4.8e-12))) (+ (/ x (+ x 1.0)) (/ x y)) (- x (/ (* x x) (- y)))))
double code(double x, double y) {
double tmp;
if ((x <= -3.1e-12) || !(x <= 4.8e-12)) {
tmp = (x / (x + 1.0)) + (x / y);
} else {
tmp = x - ((x * 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.1d-12)) .or. (.not. (x <= 4.8d-12))) then
tmp = (x / (x + 1.0d0)) + (x / y)
else
tmp = x - ((x * x) / -y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -3.1e-12) || !(x <= 4.8e-12)) {
tmp = (x / (x + 1.0)) + (x / y);
} else {
tmp = x - ((x * x) / -y);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -3.1e-12) or not (x <= 4.8e-12): tmp = (x / (x + 1.0)) + (x / y) else: tmp = x - ((x * x) / -y) return tmp
function code(x, y) tmp = 0.0 if ((x <= -3.1e-12) || !(x <= 4.8e-12)) tmp = Float64(Float64(x / Float64(x + 1.0)) + Float64(x / y)); else tmp = Float64(x - Float64(Float64(x * x) / Float64(-y))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -3.1e-12) || ~((x <= 4.8e-12))) tmp = (x / (x + 1.0)) + (x / y); else tmp = x - ((x * x) / -y); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -3.1e-12], N[Not[LessEqual[x, 4.8e-12]], $MachinePrecision]], N[(N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] + N[(x / y), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[(x * x), $MachinePrecision] / (-y)), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.1 \cdot 10^{-12} \lor \neg \left(x \leq 4.8 \cdot 10^{-12}\right):\\
\;\;\;\;\frac{x}{x + 1} + \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{x \cdot x}{-y}\\
\end{array}
\end{array}
if x < -3.1000000000000001e-12 or 4.79999999999999974e-12 < x Initial program 74.4%
associate-/l*99.9%
Simplified99.9%
associate-/r/100.0%
+-commutative100.0%
distribute-rgt-in100.0%
*-un-lft-identity100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 98.0%
if -3.1000000000000001e-12 < x < 4.79999999999999974e-12Initial program 99.8%
associate-/l*99.8%
Simplified99.8%
associate-/r/99.8%
+-commutative99.8%
distribute-rgt-in99.8%
*-un-lft-identity99.8%
Applied egg-rr99.8%
*-commutative99.8%
frac-2neg99.8%
associate-*r/90.8%
Applied egg-rr90.8%
Taylor expanded in x around 0 90.8%
Taylor expanded in x around 0 90.8%
Final simplification94.5%
(FPCore (x y) :precision binary64 (if (<= x -3.1e-12) (+ (/ x (+ x 1.0)) (/ x y)) (if (<= x 1.28) (- x (/ (* x x) (- y))) (+ (+ 1.0 (/ x y)) (/ -1.0 y)))))
double code(double x, double y) {
double tmp;
if (x <= -3.1e-12) {
tmp = (x / (x + 1.0)) + (x / y);
} else if (x <= 1.28) {
tmp = x - ((x * x) / -y);
} else {
tmp = (1.0 + (x / y)) + (-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 <= (-3.1d-12)) then
tmp = (x / (x + 1.0d0)) + (x / y)
else if (x <= 1.28d0) then
tmp = x - ((x * x) / -y)
else
tmp = (1.0d0 + (x / y)) + ((-1.0d0) / y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -3.1e-12) {
tmp = (x / (x + 1.0)) + (x / y);
} else if (x <= 1.28) {
tmp = x - ((x * x) / -y);
} else {
tmp = (1.0 + (x / y)) + (-1.0 / y);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -3.1e-12: tmp = (x / (x + 1.0)) + (x / y) elif x <= 1.28: tmp = x - ((x * x) / -y) else: tmp = (1.0 + (x / y)) + (-1.0 / y) return tmp
function code(x, y) tmp = 0.0 if (x <= -3.1e-12) tmp = Float64(Float64(x / Float64(x + 1.0)) + Float64(x / y)); elseif (x <= 1.28) tmp = Float64(x - Float64(Float64(x * x) / Float64(-y))); else tmp = Float64(Float64(1.0 + Float64(x / y)) + Float64(-1.0 / y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -3.1e-12) tmp = (x / (x + 1.0)) + (x / y); elseif (x <= 1.28) tmp = x - ((x * x) / -y); else tmp = (1.0 + (x / y)) + (-1.0 / y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -3.1e-12], N[(N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] + N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.28], N[(x - N[(N[(x * x), $MachinePrecision] / (-y)), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(x / y), $MachinePrecision]), $MachinePrecision] + N[(-1.0 / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.1 \cdot 10^{-12}:\\
\;\;\;\;\frac{x}{x + 1} + \frac{x}{y}\\
\mathbf{elif}\;x \leq 1.28:\\
\;\;\;\;x - \frac{x \cdot x}{-y}\\
\mathbf{else}:\\
\;\;\;\;\left(1 + \frac{x}{y}\right) + \frac{-1}{y}\\
\end{array}
\end{array}
if x < -3.1000000000000001e-12Initial program 74.1%
associate-/l*99.9%
Simplified99.9%
associate-/r/99.9%
+-commutative99.9%
distribute-rgt-in99.9%
*-un-lft-identity99.9%
Applied egg-rr99.9%
Taylor expanded in x around inf 98.5%
if -3.1000000000000001e-12 < x < 1.28000000000000003Initial program 99.8%
associate-/l*99.8%
Simplified99.8%
associate-/r/99.8%
+-commutative99.8%
distribute-rgt-in99.8%
*-un-lft-identity99.8%
Applied egg-rr99.8%
*-commutative99.8%
frac-2neg99.8%
associate-*r/90.9%
Applied egg-rr90.9%
Taylor expanded in x around 0 90.4%
Taylor expanded in x around 0 90.2%
if 1.28000000000000003 < x Initial program 74.1%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around inf 99.7%
Final simplification94.8%
(FPCore (x y) :precision binary64 (if (or (<= x -1.0) (not (<= x 1.0))) (+ 1.0 (/ x y)) (- x (/ (* x x) (- y)))))
double code(double x, double y) {
double tmp;
if ((x <= -1.0) || !(x <= 1.0)) {
tmp = 1.0 + (x / y);
} else {
tmp = x - ((x * 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)) .or. (.not. (x <= 1.0d0))) then
tmp = 1.0d0 + (x / y)
else
tmp = x - ((x * x) / -y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -1.0) || !(x <= 1.0)) {
tmp = 1.0 + (x / y);
} else {
tmp = x - ((x * x) / -y);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -1.0) or not (x <= 1.0): tmp = 1.0 + (x / y) else: tmp = x - ((x * x) / -y) return tmp
function code(x, y) tmp = 0.0 if ((x <= -1.0) || !(x <= 1.0)) tmp = Float64(1.0 + Float64(x / y)); else tmp = Float64(x - Float64(Float64(x * x) / Float64(-y))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -1.0) || ~((x <= 1.0))) tmp = 1.0 + (x / y); else tmp = x - ((x * x) / -y); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -1.0], N[Not[LessEqual[x, 1.0]], $MachinePrecision]], N[(1.0 + N[(x / y), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[(x * x), $MachinePrecision] / (-y)), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 1\right):\\
\;\;\;\;1 + \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{x \cdot x}{-y}\\
\end{array}
\end{array}
if x < -1 or 1 < x Initial program 73.5%
associate-/l*100.0%
Simplified100.0%
associate-/r/100.0%
+-commutative100.0%
distribute-rgt-in100.0%
*-un-lft-identity100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 98.7%
Taylor expanded in x around inf 97.6%
+-commutative97.6%
Simplified97.6%
if -1 < x < 1Initial program 99.8%
associate-/l*99.8%
Simplified99.8%
associate-/r/99.8%
+-commutative99.8%
distribute-rgt-in99.8%
*-un-lft-identity99.8%
Applied egg-rr99.8%
*-commutative99.8%
frac-2neg99.8%
associate-*r/91.1%
Applied egg-rr91.1%
Taylor expanded in x around 0 90.6%
Taylor expanded in x around 0 89.8%
Final simplification93.7%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ 1.0 (/ x y))))
(if (<= x -11000000.0)
t_0
(if (<= x 1.12e-73)
(/ x (+ x 1.0))
(if (<= x 0.108) (/ x (/ y x)) t_0)))))
double code(double x, double y) {
double t_0 = 1.0 + (x / y);
double tmp;
if (x <= -11000000.0) {
tmp = t_0;
} else if (x <= 1.12e-73) {
tmp = x / (x + 1.0);
} else if (x <= 0.108) {
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 / y)
if (x <= (-11000000.0d0)) then
tmp = t_0
else if (x <= 1.12d-73) then
tmp = x / (x + 1.0d0)
else if (x <= 0.108d0) 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 / y);
double tmp;
if (x <= -11000000.0) {
tmp = t_0;
} else if (x <= 1.12e-73) {
tmp = x / (x + 1.0);
} else if (x <= 0.108) {
tmp = x / (y / x);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 + (x / y) tmp = 0 if x <= -11000000.0: tmp = t_0 elif x <= 1.12e-73: tmp = x / (x + 1.0) elif x <= 0.108: tmp = x / (y / x) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(1.0 + Float64(x / y)) tmp = 0.0 if (x <= -11000000.0) tmp = t_0; elseif (x <= 1.12e-73) tmp = Float64(x / Float64(x + 1.0)); elseif (x <= 0.108) 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 / y); tmp = 0.0; if (x <= -11000000.0) tmp = t_0; elseif (x <= 1.12e-73) tmp = x / (x + 1.0); elseif (x <= 0.108) tmp = x / (y / x); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(1.0 + N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -11000000.0], t$95$0, If[LessEqual[x, 1.12e-73], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.108], N[(x / N[(y / x), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{x}{y}\\
\mathbf{if}\;x \leq -11000000:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 1.12 \cdot 10^{-73}:\\
\;\;\;\;\frac{x}{x + 1}\\
\mathbf{elif}\;x \leq 0.108:\\
\;\;\;\;\frac{x}{\frac{y}{x}}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -1.1e7 or 0.107999999999999999 < x Initial program 72.8%
associate-/l*100.0%
Simplified100.0%
associate-/r/100.0%
+-commutative100.0%
distribute-rgt-in100.0%
*-un-lft-identity100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 99.2%
Taylor expanded in x around inf 99.1%
+-commutative99.1%
Simplified99.1%
if -1.1e7 < x < 1.11999999999999995e-73Initial program 99.9%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around inf 75.7%
if 1.11999999999999995e-73 < x < 0.107999999999999999Initial program 99.1%
*-commutative99.1%
associate-/l*99.2%
+-commutative99.2%
remove-double-neg99.2%
unsub-neg99.2%
div-sub99.3%
distribute-frac-neg99.3%
*-inverses99.3%
metadata-eval99.3%
Simplified99.3%
Taylor expanded in y around 0 75.1%
distribute-rgt-in75.1%
*-lft-identity75.1%
associate-*l/75.0%
*-lft-identity75.0%
Simplified75.0%
Taylor expanded in x around 0 68.8%
Final simplification86.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 86.6%
associate-/l*99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y) :precision binary64 (if (or (<= x -1.0) (not (<= x 0.00155))) (+ 1.0 (/ x y)) x))
double code(double x, double y) {
double tmp;
if ((x <= -1.0) || !(x <= 0.00155)) {
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 <= 0.00155d0))) 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 <= 0.00155)) {
tmp = 1.0 + (x / y);
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -1.0) or not (x <= 0.00155): tmp = 1.0 + (x / y) else: tmp = x return tmp
function code(x, y) tmp = 0.0 if ((x <= -1.0) || !(x <= 0.00155)) 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 <= 0.00155))) 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, 0.00155]], $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 0.00155\right):\\
\;\;\;\;1 + \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -1 or 0.00154999999999999995 < x Initial program 73.7%
associate-/l*100.0%
Simplified100.0%
associate-/r/100.0%
+-commutative100.0%
distribute-rgt-in100.0%
*-un-lft-identity100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 98.0%
Taylor expanded in x around inf 96.9%
+-commutative96.9%
Simplified96.9%
if -1 < x < 0.00154999999999999995Initial program 99.8%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around 0 70.9%
Final simplification84.0%
(FPCore (x y) :precision binary64 (if (or (<= x -28000000.0) (not (<= x 0.0027))) (+ 1.0 (/ x y)) (/ x (+ x 1.0))))
double code(double x, double y) {
double tmp;
if ((x <= -28000000.0) || !(x <= 0.0027)) {
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 <= (-28000000.0d0)) .or. (.not. (x <= 0.0027d0))) 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 <= -28000000.0) || !(x <= 0.0027)) {
tmp = 1.0 + (x / y);
} else {
tmp = x / (x + 1.0);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -28000000.0) or not (x <= 0.0027): tmp = 1.0 + (x / y) else: tmp = x / (x + 1.0) return tmp
function code(x, y) tmp = 0.0 if ((x <= -28000000.0) || !(x <= 0.0027)) 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 <= -28000000.0) || ~((x <= 0.0027))) tmp = 1.0 + (x / y); else tmp = x / (x + 1.0); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -28000000.0], N[Not[LessEqual[x, 0.0027]], $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 -28000000 \lor \neg \left(x \leq 0.0027\right):\\
\;\;\;\;1 + \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{x + 1}\\
\end{array}
\end{array}
if x < -2.8e7 or 0.0027000000000000001 < x Initial program 73.1%
associate-/l*100.0%
Simplified100.0%
associate-/r/100.0%
+-commutative100.0%
distribute-rgt-in100.0%
*-un-lft-identity100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 98.6%
Taylor expanded in x around inf 98.5%
+-commutative98.5%
Simplified98.5%
if -2.8e7 < x < 0.0027000000000000001Initial program 99.8%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around inf 71.6%
Final simplification84.8%
(FPCore (x y) :precision binary64 (if (or (<= x -1.0) (not (<= x 0.00085))) (/ x y) x))
double code(double x, double y) {
double tmp;
if ((x <= -1.0) || !(x <= 0.00085)) {
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 <= 0.00085d0))) 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 <= 0.00085)) {
tmp = x / y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -1.0) or not (x <= 0.00085): tmp = x / y else: tmp = x return tmp
function code(x, y) tmp = 0.0 if ((x <= -1.0) || !(x <= 0.00085)) 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 <= 0.00085))) tmp = x / y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -1.0], N[Not[LessEqual[x, 0.00085]], $MachinePrecision]], N[(x / y), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 0.00085\right):\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -1 or 8.49999999999999953e-4 < x Initial program 73.7%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around inf 74.8%
if -1 < x < 8.49999999999999953e-4Initial program 99.8%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around 0 70.9%
Final simplification72.8%
(FPCore (x y) :precision binary64 (if (<= x -38.0) 1.0 (if (<= x 33000000.0) x 1.0)))
double code(double x, double y) {
double tmp;
if (x <= -38.0) {
tmp = 1.0;
} else if (x <= 33000000.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 <= (-38.0d0)) then
tmp = 1.0d0
else if (x <= 33000000.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 <= -38.0) {
tmp = 1.0;
} else if (x <= 33000000.0) {
tmp = x;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -38.0: tmp = 1.0 elif x <= 33000000.0: tmp = x else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -38.0) tmp = 1.0; elseif (x <= 33000000.0) tmp = x; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -38.0) tmp = 1.0; elseif (x <= 33000000.0) tmp = x; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -38.0], 1.0, If[LessEqual[x, 33000000.0], x, 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -38:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 33000000:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < -38 or 3.3e7 < x Initial program 73.1%
*-commutative73.1%
associate-/l*100.0%
+-commutative100.0%
remove-double-neg100.0%
unsub-neg100.0%
div-sub100.0%
distribute-frac-neg100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 24.6%
flip-+24.6%
associate-/r/24.6%
metadata-eval24.6%
inv-pow24.6%
inv-pow24.6%
pow-prod-up24.6%
metadata-eval24.6%
Applied egg-rr24.6%
associate-*l/24.6%
*-lft-identity24.6%
sub-neg24.6%
distribute-neg-frac24.6%
metadata-eval24.6%
Simplified24.6%
Taylor expanded in x around inf 23.5%
if -38 < x < 3.3e7Initial program 99.8%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around 0 69.4%
Final simplification46.8%
(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 86.6%
*-commutative86.6%
associate-/l*99.5%
+-commutative99.5%
remove-double-neg99.5%
unsub-neg99.5%
div-sub99.5%
distribute-frac-neg99.5%
*-inverses99.5%
metadata-eval99.5%
Simplified99.5%
Taylor expanded in y around inf 47.4%
flip-+26.9%
associate-/r/26.9%
metadata-eval26.9%
inv-pow26.9%
inv-pow26.9%
pow-prod-up26.9%
metadata-eval26.9%
Applied egg-rr26.9%
associate-*l/26.9%
*-lft-identity26.9%
sub-neg26.9%
distribute-neg-frac26.9%
metadata-eval26.9%
Simplified26.9%
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 2023318
(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)))