
(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.8%
Simplified99.8%
clear-num99.7%
un-div-inv99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x y) :precision binary64 (if (or (<= x -1.0) (not (<= x 0.8))) (+ 1.0 (/ x y)) (* x (+ 1.0 (* x (+ (/ 1.0 y) -1.0))))))
double code(double x, double y) {
double tmp;
if ((x <= -1.0) || !(x <= 0.8)) {
tmp = 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 <= (-1.0d0)) .or. (.not. (x <= 0.8d0))) then
tmp = 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 <= -1.0) || !(x <= 0.8)) {
tmp = 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 <= -1.0) or not (x <= 0.8): tmp = 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 <= -1.0) || !(x <= 0.8)) tmp = Float64(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 <= -1.0) || ~((x <= 0.8))) tmp = 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, -1.0], N[Not[LessEqual[x, 0.8]], $MachinePrecision]], N[(1.0 + 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 -1 \lor \neg \left(x \leq 0.8\right):\\
\;\;\;\;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 < -1 or 0.80000000000000004 < x Initial program 76.5%
Taylor expanded in y around 0 56.4%
unpow256.4%
distribute-lft-out56.7%
Simplified56.7%
associate-/r*62.6%
*-commutative62.6%
+-commutative62.6%
associate-/l*73.2%
+-commutative73.2%
associate-/r*99.8%
+-commutative99.8%
Applied egg-rr99.8%
Taylor expanded in x around inf 96.2%
Taylor expanded in x around 0 96.5%
+-commutative96.5%
Simplified96.5%
if -1 < x < 0.80000000000000004Initial program 99.8%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around 0 98.9%
Final simplification97.7%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ 1.0 (/ x y))))
(if (<= x -1500000000.0)
t_0
(if (<= x -8.5e-41)
(/ x (* (+ x 1.0) (/ y x)))
(if (<= x 920000.0) (/ x (+ x 1.0)) t_0)))))
double code(double x, double y) {
double t_0 = 1.0 + (x / y);
double tmp;
if (x <= -1500000000.0) {
tmp = t_0;
} else if (x <= -8.5e-41) {
tmp = x / ((x + 1.0) * (y / x));
} else if (x <= 920000.0) {
tmp = x / (x + 1.0);
} 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 <= (-1500000000.0d0)) then
tmp = t_0
else if (x <= (-8.5d-41)) then
tmp = x / ((x + 1.0d0) * (y / x))
else if (x <= 920000.0d0) then
tmp = x / (x + 1.0d0)
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 <= -1500000000.0) {
tmp = t_0;
} else if (x <= -8.5e-41) {
tmp = x / ((x + 1.0) * (y / x));
} else if (x <= 920000.0) {
tmp = x / (x + 1.0);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 + (x / y) tmp = 0 if x <= -1500000000.0: tmp = t_0 elif x <= -8.5e-41: tmp = x / ((x + 1.0) * (y / x)) elif x <= 920000.0: tmp = x / (x + 1.0) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(1.0 + Float64(x / y)) tmp = 0.0 if (x <= -1500000000.0) tmp = t_0; elseif (x <= -8.5e-41) tmp = Float64(x / Float64(Float64(x + 1.0) * Float64(y / x))); elseif (x <= 920000.0) tmp = Float64(x / Float64(x + 1.0)); 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 <= -1500000000.0) tmp = t_0; elseif (x <= -8.5e-41) tmp = x / ((x + 1.0) * (y / x)); elseif (x <= 920000.0) tmp = x / (x + 1.0); 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, -1500000000.0], t$95$0, If[LessEqual[x, -8.5e-41], N[(x / N[(N[(x + 1.0), $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 920000.0], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{x}{y}\\
\mathbf{if}\;x \leq -1500000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -8.5 \cdot 10^{-41}:\\
\;\;\;\;\frac{x}{\left(x + 1\right) \cdot \frac{y}{x}}\\
\mathbf{elif}\;x \leq 920000:\\
\;\;\;\;\frac{x}{x + 1}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1.5e9 or 9.2e5 < x Initial program 75.6%
Taylor expanded in y around 0 54.7%
unpow254.7%
distribute-lft-out55.0%
Simplified55.0%
associate-/r*61.2%
*-commutative61.2%
+-commutative61.2%
associate-/l*72.2%
+-commutative72.2%
associate-/r*99.8%
+-commutative99.8%
Applied egg-rr99.8%
Taylor expanded in x around inf 98.1%
Taylor expanded in x around 0 98.4%
+-commutative98.4%
Simplified98.4%
if -1.5e9 < x < -8.4999999999999996e-41Initial program 99.5%
associate-/l*99.4%
Simplified99.4%
Taylor expanded in y around 0 74.7%
clear-num74.7%
un-div-inv74.7%
+-commutative74.7%
*-commutative74.7%
associate-/l*74.9%
Applied egg-rr74.9%
if -8.4999999999999996e-41 < x < 9.2e5Initial program 99.9%
Taylor expanded in y around 0 84.2%
unpow284.2%
distribute-lft-out84.3%
Simplified84.3%
associate-/r*84.2%
*-commutative84.2%
+-commutative84.2%
associate-/l*69.9%
+-commutative69.9%
associate-/r*69.9%
+-commutative69.9%
Applied egg-rr69.9%
Taylor expanded in y around inf 78.9%
+-commutative78.9%
Simplified78.9%
Final simplification88.3%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ 1.0 (/ x y))))
(if (<= x -1500000000.0)
t_0
(if (<= x -3e-43)
(* x (/ x (* (+ x 1.0) y)))
(if (<= x 90000.0) (/ x (+ x 1.0)) t_0)))))
double code(double x, double y) {
double t_0 = 1.0 + (x / y);
double tmp;
if (x <= -1500000000.0) {
tmp = t_0;
} else if (x <= -3e-43) {
tmp = x * (x / ((x + 1.0) * y));
} else if (x <= 90000.0) {
tmp = x / (x + 1.0);
} 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 <= (-1500000000.0d0)) then
tmp = t_0
else if (x <= (-3d-43)) then
tmp = x * (x / ((x + 1.0d0) * y))
else if (x <= 90000.0d0) then
tmp = x / (x + 1.0d0)
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 <= -1500000000.0) {
tmp = t_0;
} else if (x <= -3e-43) {
tmp = x * (x / ((x + 1.0) * y));
} else if (x <= 90000.0) {
tmp = x / (x + 1.0);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 + (x / y) tmp = 0 if x <= -1500000000.0: tmp = t_0 elif x <= -3e-43: tmp = x * (x / ((x + 1.0) * y)) elif x <= 90000.0: tmp = x / (x + 1.0) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(1.0 + Float64(x / y)) tmp = 0.0 if (x <= -1500000000.0) tmp = t_0; elseif (x <= -3e-43) tmp = Float64(x * Float64(x / Float64(Float64(x + 1.0) * y))); elseif (x <= 90000.0) tmp = Float64(x / Float64(x + 1.0)); 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 <= -1500000000.0) tmp = t_0; elseif (x <= -3e-43) tmp = x * (x / ((x + 1.0) * y)); elseif (x <= 90000.0) tmp = x / (x + 1.0); 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, -1500000000.0], t$95$0, If[LessEqual[x, -3e-43], N[(x * N[(x / N[(N[(x + 1.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 90000.0], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{x}{y}\\
\mathbf{if}\;x \leq -1500000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -3 \cdot 10^{-43}:\\
\;\;\;\;x \cdot \frac{x}{\left(x + 1\right) \cdot y}\\
\mathbf{elif}\;x \leq 90000:\\
\;\;\;\;\frac{x}{x + 1}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1.5e9 or 9e4 < x Initial program 75.6%
Taylor expanded in y around 0 54.7%
unpow254.7%
distribute-lft-out55.0%
Simplified55.0%
associate-/r*61.2%
*-commutative61.2%
+-commutative61.2%
associate-/l*72.2%
+-commutative72.2%
associate-/r*99.8%
+-commutative99.8%
Applied egg-rr99.8%
Taylor expanded in x around inf 98.1%
Taylor expanded in x around 0 98.4%
+-commutative98.4%
Simplified98.4%
if -1.5e9 < x < -3.00000000000000003e-43Initial program 99.5%
associate-/l*99.4%
Simplified99.4%
Taylor expanded in y around 0 74.7%
if -3.00000000000000003e-43 < x < 9e4Initial program 99.9%
Taylor expanded in y around 0 84.2%
unpow284.2%
distribute-lft-out84.3%
Simplified84.3%
associate-/r*84.2%
*-commutative84.2%
+-commutative84.2%
associate-/l*69.9%
+-commutative69.9%
associate-/r*69.9%
+-commutative69.9%
Applied egg-rr69.9%
Taylor expanded in y around inf 78.9%
+-commutative78.9%
Simplified78.9%
Final simplification88.3%
(FPCore (x y) :precision binary64 (if (or (<= x -900.0) (not (<= x 320000.0))) (+ 1.0 (/ x y)) (/ x (+ x 1.0))))
double code(double x, double y) {
double tmp;
if ((x <= -900.0) || !(x <= 320000.0)) {
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 <= (-900.0d0)) .or. (.not. (x <= 320000.0d0))) 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 <= -900.0) || !(x <= 320000.0)) {
tmp = 1.0 + (x / y);
} else {
tmp = x / (x + 1.0);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -900.0) or not (x <= 320000.0): tmp = 1.0 + (x / y) else: tmp = x / (x + 1.0) return tmp
function code(x, y) tmp = 0.0 if ((x <= -900.0) || !(x <= 320000.0)) 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 <= -900.0) || ~((x <= 320000.0))) tmp = 1.0 + (x / y); else tmp = x / (x + 1.0); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -900.0], N[Not[LessEqual[x, 320000.0]], $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 -900 \lor \neg \left(x \leq 320000\right):\\
\;\;\;\;1 + \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{x + 1}\\
\end{array}
\end{array}
if x < -900 or 3.2e5 < x Initial program 76.3%
Taylor expanded in y around 0 56.1%
unpow256.1%
distribute-lft-out56.4%
Simplified56.4%
associate-/r*62.3%
*-commutative62.3%
+-commutative62.3%
associate-/l*73.0%
+-commutative73.0%
associate-/r*99.8%
+-commutative99.8%
Applied egg-rr99.8%
Taylor expanded in x around inf 96.6%
Taylor expanded in x around 0 96.9%
+-commutative96.9%
Simplified96.9%
if -900 < x < 3.2e5Initial program 99.8%
Taylor expanded in y around 0 85.7%
unpow285.7%
distribute-lft-out85.7%
Simplified85.7%
associate-/r*85.7%
*-commutative85.7%
+-commutative85.7%
associate-/l*72.0%
+-commutative72.0%
associate-/r*72.0%
+-commutative72.0%
Applied egg-rr72.0%
Taylor expanded in y around inf 74.0%
+-commutative74.0%
Simplified74.0%
Final simplification85.8%
(FPCore (x y) :precision binary64 (if (or (<= x -600.0) (not (<= x 320000.0))) (+ 1.0 (/ x y)) (/ x (+ x 1.0))))
double code(double x, double y) {
double tmp;
if ((x <= -600.0) || !(x <= 320000.0)) {
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 <= (-600.0d0)) .or. (.not. (x <= 320000.0d0))) 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 <= -600.0) || !(x <= 320000.0)) {
tmp = 1.0 + (x / y);
} else {
tmp = x / (x + 1.0);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -600.0) or not (x <= 320000.0): tmp = 1.0 + (x / y) else: tmp = x / (x + 1.0) return tmp
function code(x, y) tmp = 0.0 if ((x <= -600.0) || !(x <= 320000.0)) 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 <= -600.0) || ~((x <= 320000.0))) tmp = 1.0 + (x / y); else tmp = x / (x + 1.0); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -600.0], N[Not[LessEqual[x, 320000.0]], $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 -600 \lor \neg \left(x \leq 320000\right):\\
\;\;\;\;1 + \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{x + 1}\\
\end{array}
\end{array}
if x < -600 or 3.2e5 < x Initial program 76.3%
Taylor expanded in y around 0 56.1%
unpow256.1%
distribute-lft-out56.4%
Simplified56.4%
associate-/r*62.3%
*-commutative62.3%
+-commutative62.3%
associate-/l*73.0%
+-commutative73.0%
associate-/r*99.8%
+-commutative99.8%
Applied egg-rr99.8%
Taylor expanded in x around inf 96.6%
Taylor expanded in x around 0 96.9%
+-commutative96.9%
Simplified96.9%
if -600 < x < 3.2e5Initial program 99.8%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around inf 74.0%
Final simplification85.8%
(FPCore (x y) :precision binary64 (if (or (<= x -1.0) (not (<= x 0.054))) (+ 1.0 (/ x y)) (* x (- 1.0 x))))
double code(double x, double y) {
double tmp;
if ((x <= -1.0) || !(x <= 0.054)) {
tmp = 1.0 + (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.054d0))) then
tmp = 1.0d0 + (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.054)) {
tmp = 1.0 + (x / y);
} else {
tmp = x * (1.0 - x);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -1.0) or not (x <= 0.054): tmp = 1.0 + (x / y) else: tmp = x * (1.0 - x) return tmp
function code(x, y) tmp = 0.0 if ((x <= -1.0) || !(x <= 0.054)) tmp = Float64(1.0 + 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.054))) tmp = 1.0 + (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.054]], $MachinePrecision]], N[(1.0 + N[(x / y), $MachinePrecision]), $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.054\right):\\
\;\;\;\;1 + \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - x\right)\\
\end{array}
\end{array}
if x < -1 or 0.0539999999999999994 < x Initial program 76.5%
Taylor expanded in y around 0 56.4%
unpow256.4%
distribute-lft-out56.7%
Simplified56.7%
associate-/r*62.6%
*-commutative62.6%
+-commutative62.6%
associate-/l*73.2%
+-commutative73.2%
associate-/r*99.8%
+-commutative99.8%
Applied egg-rr99.8%
Taylor expanded in x around inf 96.2%
Taylor expanded in x around 0 96.5%
+-commutative96.5%
Simplified96.5%
if -1 < x < 0.0539999999999999994Initial program 99.8%
Taylor expanded in y around 0 85.6%
unpow285.6%
distribute-lft-out85.6%
Simplified85.6%
associate-/r*85.6%
*-commutative85.6%
+-commutative85.6%
associate-/l*71.8%
+-commutative71.8%
associate-/r*71.8%
+-commutative71.8%
Applied egg-rr71.8%
Taylor expanded in y around inf 74.0%
+-commutative74.0%
Simplified74.0%
Taylor expanded in x around 0 74.0%
neg-mul-174.0%
sub-neg74.0%
Simplified74.0%
Final simplification85.6%
(FPCore (x y) :precision binary64 (if (or (<= x -1.0) (not (<= x 0.62))) (/ x y) (* x (- 1.0 x))))
double code(double x, double y) {
double tmp;
if ((x <= -1.0) || !(x <= 0.62)) {
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.62d0))) 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.62)) {
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.62): tmp = x / y else: tmp = x * (1.0 - x) return tmp
function code(x, y) tmp = 0.0 if ((x <= -1.0) || !(x <= 0.62)) 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.62))) 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.62]], $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.62\right):\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - x\right)\\
\end{array}
\end{array}
if x < -1 or 0.619999999999999996 < x Initial program 76.5%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around inf 73.3%
if -1 < x < 0.619999999999999996Initial program 99.8%
Taylor expanded in y around 0 85.6%
unpow285.6%
distribute-lft-out85.6%
Simplified85.6%
associate-/r*85.6%
*-commutative85.6%
+-commutative85.6%
associate-/l*71.8%
+-commutative71.8%
associate-/r*71.8%
+-commutative71.8%
Applied egg-rr71.8%
Taylor expanded in y around inf 74.0%
+-commutative74.0%
Simplified74.0%
Taylor expanded in x around 0 74.0%
neg-mul-174.0%
sub-neg74.0%
Simplified74.0%
Final simplification73.6%
(FPCore (x y) :precision binary64 (if (or (<= x -1.0) (not (<= x 21000.0))) (/ x y) x))
double code(double x, double y) {
double tmp;
if ((x <= -1.0) || !(x <= 21000.0)) {
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 <= 21000.0d0))) 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 <= 21000.0)) {
tmp = x / y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -1.0) or not (x <= 21000.0): tmp = x / y else: tmp = x return tmp
function code(x, y) tmp = 0.0 if ((x <= -1.0) || !(x <= 21000.0)) 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 <= 21000.0))) tmp = x / y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -1.0], N[Not[LessEqual[x, 21000.0]], $MachinePrecision]], N[(x / y), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 21000\right):\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -1 or 21000 < x Initial program 76.3%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around inf 73.8%
if -1 < x < 21000Initial program 99.8%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around 0 73.4%
Final simplification73.6%
(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.8%
Simplified99.8%
Final simplification99.8%
(FPCore (x y) :precision binary64 x)
double code(double x, double y) {
return x;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x
end function
public static double code(double x, double y) {
return x;
}
def code(x, y): return x
function code(x, y) return x end
function tmp = code(x, y) tmp = x; end
code[x_, y_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 87.8%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around 0 37.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 2024103
(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)))