
(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 10 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 (/ (+ 1.0 (/ x y)) (+ 1.0 x))))
double code(double x, double y) {
return x * ((1.0 + (x / y)) / (1.0 + x));
}
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))
end function
public static double code(double x, double y) {
return x * ((1.0 + (x / y)) / (1.0 + x));
}
def code(x, y): return x * ((1.0 + (x / y)) / (1.0 + x))
function code(x, y) return Float64(x * Float64(Float64(1.0 + Float64(x / y)) / Float64(1.0 + x))) end
function tmp = code(x, y) tmp = x * ((1.0 + (x / y)) / (1.0 + x)); end
code[x_, y_] := N[(x * N[(N[(1.0 + N[(x / y), $MachinePrecision]), $MachinePrecision] / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \frac{1 + \frac{x}{y}}{1 + x}
\end{array}
Initial program 89.0%
associate-/l*99.9%
Simplified99.9%
clear-num99.7%
associate-/r/99.8%
clear-num99.9%
+-commutative99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ x (+ 1.0 x))))
(if (<= x -1.6e+69)
(/ x y)
(if (<= x 2.1e-91)
t_0
(if (<= x 6.2e-51)
(* x (/ x y))
(if (<= x 700000000000.0) t_0 (/ x y)))))))
double code(double x, double y) {
double t_0 = x / (1.0 + x);
double tmp;
if (x <= -1.6e+69) {
tmp = x / y;
} else if (x <= 2.1e-91) {
tmp = t_0;
} else if (x <= 6.2e-51) {
tmp = x * (x / y);
} else if (x <= 700000000000.0) {
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 / (1.0d0 + x)
if (x <= (-1.6d+69)) then
tmp = x / y
else if (x <= 2.1d-91) then
tmp = t_0
else if (x <= 6.2d-51) then
tmp = x * (x / y)
else if (x <= 700000000000.0d0) 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 / (1.0 + x);
double tmp;
if (x <= -1.6e+69) {
tmp = x / y;
} else if (x <= 2.1e-91) {
tmp = t_0;
} else if (x <= 6.2e-51) {
tmp = x * (x / y);
} else if (x <= 700000000000.0) {
tmp = t_0;
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): t_0 = x / (1.0 + x) tmp = 0 if x <= -1.6e+69: tmp = x / y elif x <= 2.1e-91: tmp = t_0 elif x <= 6.2e-51: tmp = x * (x / y) elif x <= 700000000000.0: tmp = t_0 else: tmp = x / y return tmp
function code(x, y) t_0 = Float64(x / Float64(1.0 + x)) tmp = 0.0 if (x <= -1.6e+69) tmp = Float64(x / y); elseif (x <= 2.1e-91) tmp = t_0; elseif (x <= 6.2e-51) tmp = Float64(x * Float64(x / y)); elseif (x <= 700000000000.0) tmp = t_0; else tmp = Float64(x / y); end return tmp end
function tmp_2 = code(x, y) t_0 = x / (1.0 + x); tmp = 0.0; if (x <= -1.6e+69) tmp = x / y; elseif (x <= 2.1e-91) tmp = t_0; elseif (x <= 6.2e-51) tmp = x * (x / y); elseif (x <= 700000000000.0) tmp = t_0; else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.6e+69], N[(x / y), $MachinePrecision], If[LessEqual[x, 2.1e-91], t$95$0, If[LessEqual[x, 6.2e-51], N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 700000000000.0], t$95$0, N[(x / y), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{1 + x}\\
\mathbf{if}\;x \leq -1.6 \cdot 10^{+69}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq 2.1 \cdot 10^{-91}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 6.2 \cdot 10^{-51}:\\
\;\;\;\;x \cdot \frac{x}{y}\\
\mathbf{elif}\;x \leq 700000000000:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -1.59999999999999992e69 or 7e11 < x Initial program 74.6%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around inf 79.7%
if -1.59999999999999992e69 < x < 2.0999999999999999e-91 or 6.1999999999999995e-51 < x < 7e11Initial program 99.9%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around inf 80.6%
if 2.0999999999999999e-91 < x < 6.1999999999999995e-51Initial program 99.2%
Taylor expanded in x around inf 94.9%
unpow294.9%
associate-*r/94.7%
Simplified94.7%
Taylor expanded in x around 0 94.9%
unpow294.9%
associate-*r/94.7%
Simplified94.7%
Final simplification80.5%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ x (+ 1.0 x))))
(if (<= x -1.3e+67)
(/ x y)
(if (<= x 2.6e-91)
t_0
(if (<= x 1.35e-51) (/ x (/ y x)) (if (<= x 1e+15) t_0 (/ x y)))))))
double code(double x, double y) {
double t_0 = x / (1.0 + x);
double tmp;
if (x <= -1.3e+67) {
tmp = x / y;
} else if (x <= 2.6e-91) {
tmp = t_0;
} else if (x <= 1.35e-51) {
tmp = x / (y / x);
} else if (x <= 1e+15) {
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 / (1.0d0 + x)
if (x <= (-1.3d+67)) then
tmp = x / y
else if (x <= 2.6d-91) then
tmp = t_0
else if (x <= 1.35d-51) then
tmp = x / (y / x)
else if (x <= 1d+15) 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 / (1.0 + x);
double tmp;
if (x <= -1.3e+67) {
tmp = x / y;
} else if (x <= 2.6e-91) {
tmp = t_0;
} else if (x <= 1.35e-51) {
tmp = x / (y / x);
} else if (x <= 1e+15) {
tmp = t_0;
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): t_0 = x / (1.0 + x) tmp = 0 if x <= -1.3e+67: tmp = x / y elif x <= 2.6e-91: tmp = t_0 elif x <= 1.35e-51: tmp = x / (y / x) elif x <= 1e+15: tmp = t_0 else: tmp = x / y return tmp
function code(x, y) t_0 = Float64(x / Float64(1.0 + x)) tmp = 0.0 if (x <= -1.3e+67) tmp = Float64(x / y); elseif (x <= 2.6e-91) tmp = t_0; elseif (x <= 1.35e-51) tmp = Float64(x / Float64(y / x)); elseif (x <= 1e+15) tmp = t_0; else tmp = Float64(x / y); end return tmp end
function tmp_2 = code(x, y) t_0 = x / (1.0 + x); tmp = 0.0; if (x <= -1.3e+67) tmp = x / y; elseif (x <= 2.6e-91) tmp = t_0; elseif (x <= 1.35e-51) tmp = x / (y / x); elseif (x <= 1e+15) tmp = t_0; else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.3e+67], N[(x / y), $MachinePrecision], If[LessEqual[x, 2.6e-91], t$95$0, If[LessEqual[x, 1.35e-51], N[(x / N[(y / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1e+15], t$95$0, N[(x / y), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{1 + x}\\
\mathbf{if}\;x \leq -1.3 \cdot 10^{+67}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq 2.6 \cdot 10^{-91}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 1.35 \cdot 10^{-51}:\\
\;\;\;\;\frac{x}{\frac{y}{x}}\\
\mathbf{elif}\;x \leq 10^{+15}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -1.3e67 or 1e15 < x Initial program 74.6%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around inf 79.7%
if -1.3e67 < x < 2.60000000000000014e-91 or 1.3499999999999999e-51 < x < 1e15Initial program 99.9%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around inf 80.6%
if 2.60000000000000014e-91 < x < 1.3499999999999999e-51Initial program 99.2%
Taylor expanded in x around inf 94.9%
unpow294.9%
associate-*r/94.7%
Simplified94.7%
Taylor expanded in x around 0 94.9%
unpow294.9%
associate-*r/94.7%
Simplified94.7%
clear-num94.7%
un-div-inv95.2%
Applied egg-rr95.2%
Final simplification80.5%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ 1.0 (/ x y))) (t_1 (/ x (+ 1.0 x))))
(if (<= x -330000.0)
t_0
(if (<= x 2.8e-91)
t_1
(if (<= x 1.65e-51) (/ x (/ y x)) (if (<= x 105000000.0) t_1 t_0))))))
double code(double x, double y) {
double t_0 = 1.0 + (x / y);
double t_1 = x / (1.0 + x);
double tmp;
if (x <= -330000.0) {
tmp = t_0;
} else if (x <= 2.8e-91) {
tmp = t_1;
} else if (x <= 1.65e-51) {
tmp = x / (y / x);
} else if (x <= 105000000.0) {
tmp = t_1;
} 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) :: t_1
real(8) :: tmp
t_0 = 1.0d0 + (x / y)
t_1 = x / (1.0d0 + x)
if (x <= (-330000.0d0)) then
tmp = t_0
else if (x <= 2.8d-91) then
tmp = t_1
else if (x <= 1.65d-51) then
tmp = x / (y / x)
else if (x <= 105000000.0d0) then
tmp = t_1
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 t_1 = x / (1.0 + x);
double tmp;
if (x <= -330000.0) {
tmp = t_0;
} else if (x <= 2.8e-91) {
tmp = t_1;
} else if (x <= 1.65e-51) {
tmp = x / (y / x);
} else if (x <= 105000000.0) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 + (x / y) t_1 = x / (1.0 + x) tmp = 0 if x <= -330000.0: tmp = t_0 elif x <= 2.8e-91: tmp = t_1 elif x <= 1.65e-51: tmp = x / (y / x) elif x <= 105000000.0: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(1.0 + Float64(x / y)) t_1 = Float64(x / Float64(1.0 + x)) tmp = 0.0 if (x <= -330000.0) tmp = t_0; elseif (x <= 2.8e-91) tmp = t_1; elseif (x <= 1.65e-51) tmp = Float64(x / Float64(y / x)); elseif (x <= 105000000.0) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 + (x / y); t_1 = x / (1.0 + x); tmp = 0.0; if (x <= -330000.0) tmp = t_0; elseif (x <= 2.8e-91) tmp = t_1; elseif (x <= 1.65e-51) tmp = x / (y / x); elseif (x <= 105000000.0) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(1.0 + N[(x / y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -330000.0], t$95$0, If[LessEqual[x, 2.8e-91], t$95$1, If[LessEqual[x, 1.65e-51], N[(x / N[(y / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 105000000.0], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{x}{y}\\
t_1 := \frac{x}{1 + x}\\
\mathbf{if}\;x \leq -330000:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 2.8 \cdot 10^{-91}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 1.65 \cdot 10^{-51}:\\
\;\;\;\;\frac{x}{\frac{y}{x}}\\
\mathbf{elif}\;x \leq 105000000:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -3.3e5 or 1.05e8 < x Initial program 77.1%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around inf 99.9%
Taylor expanded in y around -inf 99.9%
mul-1-neg99.9%
unsub-neg99.9%
neg-mul-199.9%
unsub-neg99.9%
Simplified99.9%
Taylor expanded in x around inf 99.4%
neg-mul-199.4%
distribute-neg-frac99.4%
Simplified99.4%
if -3.3e5 < x < 2.8e-91 or 1.64999999999999986e-51 < x < 1.05e8Initial program 99.9%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around inf 82.5%
if 2.8e-91 < x < 1.64999999999999986e-51Initial program 99.2%
Taylor expanded in x around inf 94.9%
unpow294.9%
associate-*r/94.7%
Simplified94.7%
Taylor expanded in x around 0 94.9%
unpow294.9%
associate-*r/94.7%
Simplified94.7%
clear-num94.7%
un-div-inv95.2%
Applied egg-rr95.2%
Final simplification90.9%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ x (+ 1.0 x))))
(if (<= x -13500.0)
(+ 1.0 (/ (+ x -1.0) y))
(if (<= x 2.8e-91)
t_0
(if (<= x 3.6e-52)
(/ x (/ y x))
(if (<= x 14500000.0) t_0 (+ 1.0 (/ x y))))))))
double code(double x, double y) {
double t_0 = x / (1.0 + x);
double tmp;
if (x <= -13500.0) {
tmp = 1.0 + ((x + -1.0) / y);
} else if (x <= 2.8e-91) {
tmp = t_0;
} else if (x <= 3.6e-52) {
tmp = x / (y / x);
} else if (x <= 14500000.0) {
tmp = t_0;
} else {
tmp = 1.0 + (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 / (1.0d0 + x)
if (x <= (-13500.0d0)) then
tmp = 1.0d0 + ((x + (-1.0d0)) / y)
else if (x <= 2.8d-91) then
tmp = t_0
else if (x <= 3.6d-52) then
tmp = x / (y / x)
else if (x <= 14500000.0d0) then
tmp = t_0
else
tmp = 1.0d0 + (x / y)
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = x / (1.0 + x);
double tmp;
if (x <= -13500.0) {
tmp = 1.0 + ((x + -1.0) / y);
} else if (x <= 2.8e-91) {
tmp = t_0;
} else if (x <= 3.6e-52) {
tmp = x / (y / x);
} else if (x <= 14500000.0) {
tmp = t_0;
} else {
tmp = 1.0 + (x / y);
}
return tmp;
}
def code(x, y): t_0 = x / (1.0 + x) tmp = 0 if x <= -13500.0: tmp = 1.0 + ((x + -1.0) / y) elif x <= 2.8e-91: tmp = t_0 elif x <= 3.6e-52: tmp = x / (y / x) elif x <= 14500000.0: tmp = t_0 else: tmp = 1.0 + (x / y) return tmp
function code(x, y) t_0 = Float64(x / Float64(1.0 + x)) tmp = 0.0 if (x <= -13500.0) tmp = Float64(1.0 + Float64(Float64(x + -1.0) / y)); elseif (x <= 2.8e-91) tmp = t_0; elseif (x <= 3.6e-52) tmp = Float64(x / Float64(y / x)); elseif (x <= 14500000.0) tmp = t_0; else tmp = Float64(1.0 + Float64(x / y)); end return tmp end
function tmp_2 = code(x, y) t_0 = x / (1.0 + x); tmp = 0.0; if (x <= -13500.0) tmp = 1.0 + ((x + -1.0) / y); elseif (x <= 2.8e-91) tmp = t_0; elseif (x <= 3.6e-52) tmp = x / (y / x); elseif (x <= 14500000.0) tmp = t_0; else tmp = 1.0 + (x / y); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -13500.0], N[(1.0 + N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.8e-91], t$95$0, If[LessEqual[x, 3.6e-52], N[(x / N[(y / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 14500000.0], t$95$0, N[(1.0 + N[(x / y), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{1 + x}\\
\mathbf{if}\;x \leq -13500:\\
\;\;\;\;1 + \frac{x + -1}{y}\\
\mathbf{elif}\;x \leq 2.8 \cdot 10^{-91}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 3.6 \cdot 10^{-52}:\\
\;\;\;\;\frac{x}{\frac{y}{x}}\\
\mathbf{elif}\;x \leq 14500000:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;1 + \frac{x}{y}\\
\end{array}
\end{array}
if x < -13500Initial program 68.8%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around inf 99.7%
Taylor expanded in y around -inf 99.8%
mul-1-neg99.8%
unsub-neg99.8%
neg-mul-199.8%
unsub-neg99.8%
Simplified99.8%
if -13500 < x < 2.8e-91 or 3.59999999999999988e-52 < x < 1.45e7Initial program 99.9%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around inf 82.5%
if 2.8e-91 < x < 3.59999999999999988e-52Initial program 99.2%
Taylor expanded in x around inf 94.9%
unpow294.9%
associate-*r/94.7%
Simplified94.7%
Taylor expanded in x around 0 94.9%
unpow294.9%
associate-*r/94.7%
Simplified94.7%
clear-num94.7%
un-div-inv95.2%
Applied egg-rr95.2%
if 1.45e7 < x Initial program 85.9%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around inf 100.0%
Taylor expanded in y around -inf 100.0%
mul-1-neg100.0%
unsub-neg100.0%
neg-mul-1100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in x around inf 100.0%
neg-mul-1100.0%
distribute-neg-frac100.0%
Simplified100.0%
Final simplification91.1%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ x (+ 1.0 x))))
(if (<= x -65000.0)
(+ 1.0 (/ (+ x -1.0) y))
(if (<= x 2.8e-91)
t_0
(if (<= x 5.8e-52)
(/ 1.0 (/ y (* x x)))
(if (<= x 495000000.0) t_0 (+ 1.0 (/ x y))))))))
double code(double x, double y) {
double t_0 = x / (1.0 + x);
double tmp;
if (x <= -65000.0) {
tmp = 1.0 + ((x + -1.0) / y);
} else if (x <= 2.8e-91) {
tmp = t_0;
} else if (x <= 5.8e-52) {
tmp = 1.0 / (y / (x * x));
} else if (x <= 495000000.0) {
tmp = t_0;
} else {
tmp = 1.0 + (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 / (1.0d0 + x)
if (x <= (-65000.0d0)) then
tmp = 1.0d0 + ((x + (-1.0d0)) / y)
else if (x <= 2.8d-91) then
tmp = t_0
else if (x <= 5.8d-52) then
tmp = 1.0d0 / (y / (x * x))
else if (x <= 495000000.0d0) then
tmp = t_0
else
tmp = 1.0d0 + (x / y)
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = x / (1.0 + x);
double tmp;
if (x <= -65000.0) {
tmp = 1.0 + ((x + -1.0) / y);
} else if (x <= 2.8e-91) {
tmp = t_0;
} else if (x <= 5.8e-52) {
tmp = 1.0 / (y / (x * x));
} else if (x <= 495000000.0) {
tmp = t_0;
} else {
tmp = 1.0 + (x / y);
}
return tmp;
}
def code(x, y): t_0 = x / (1.0 + x) tmp = 0 if x <= -65000.0: tmp = 1.0 + ((x + -1.0) / y) elif x <= 2.8e-91: tmp = t_0 elif x <= 5.8e-52: tmp = 1.0 / (y / (x * x)) elif x <= 495000000.0: tmp = t_0 else: tmp = 1.0 + (x / y) return tmp
function code(x, y) t_0 = Float64(x / Float64(1.0 + x)) tmp = 0.0 if (x <= -65000.0) tmp = Float64(1.0 + Float64(Float64(x + -1.0) / y)); elseif (x <= 2.8e-91) tmp = t_0; elseif (x <= 5.8e-52) tmp = Float64(1.0 / Float64(y / Float64(x * x))); elseif (x <= 495000000.0) tmp = t_0; else tmp = Float64(1.0 + Float64(x / y)); end return tmp end
function tmp_2 = code(x, y) t_0 = x / (1.0 + x); tmp = 0.0; if (x <= -65000.0) tmp = 1.0 + ((x + -1.0) / y); elseif (x <= 2.8e-91) tmp = t_0; elseif (x <= 5.8e-52) tmp = 1.0 / (y / (x * x)); elseif (x <= 495000000.0) tmp = t_0; else tmp = 1.0 + (x / y); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -65000.0], N[(1.0 + N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.8e-91], t$95$0, If[LessEqual[x, 5.8e-52], N[(1.0 / N[(y / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 495000000.0], t$95$0, N[(1.0 + N[(x / y), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{1 + x}\\
\mathbf{if}\;x \leq -65000:\\
\;\;\;\;1 + \frac{x + -1}{y}\\
\mathbf{elif}\;x \leq 2.8 \cdot 10^{-91}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 5.8 \cdot 10^{-52}:\\
\;\;\;\;\frac{1}{\frac{y}{x \cdot x}}\\
\mathbf{elif}\;x \leq 495000000:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;1 + \frac{x}{y}\\
\end{array}
\end{array}
if x < -65000Initial program 68.8%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around inf 99.7%
Taylor expanded in y around -inf 99.8%
mul-1-neg99.8%
unsub-neg99.8%
neg-mul-199.8%
unsub-neg99.8%
Simplified99.8%
if -65000 < x < 2.8e-91 or 5.8000000000000003e-52 < x < 4.95e8Initial program 99.9%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around inf 82.5%
if 2.8e-91 < x < 5.8000000000000003e-52Initial program 99.2%
Taylor expanded in x around inf 94.9%
unpow294.9%
associate-*r/94.7%
Simplified94.7%
Taylor expanded in x around 0 94.9%
unpow294.9%
associate-*r/94.7%
Simplified94.7%
associate-*r/94.9%
clear-num95.2%
Applied egg-rr95.2%
if 4.95e8 < x Initial program 85.9%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around inf 100.0%
Taylor expanded in y around -inf 100.0%
mul-1-neg100.0%
unsub-neg100.0%
neg-mul-1100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in x around inf 100.0%
neg-mul-1100.0%
distribute-neg-frac100.0%
Simplified100.0%
Final simplification91.1%
(FPCore (x y)
:precision binary64
(if (<= x -1.0)
(/ x y)
(if (<= x 2.8e-91)
x
(if (<= x 1.5e-52) (* x (/ x y)) (if (<= x 3100000.0) x (/ x y))))))
double code(double x, double y) {
double tmp;
if (x <= -1.0) {
tmp = x / y;
} else if (x <= 2.8e-91) {
tmp = x;
} else if (x <= 1.5e-52) {
tmp = x * (x / y);
} else if (x <= 3100000.0) {
tmp = 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 <= 2.8d-91) then
tmp = x
else if (x <= 1.5d-52) then
tmp = x * (x / y)
else if (x <= 3100000.0d0) then
tmp = 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 <= 2.8e-91) {
tmp = x;
} else if (x <= 1.5e-52) {
tmp = x * (x / y);
} else if (x <= 3100000.0) {
tmp = x;
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.0: tmp = x / y elif x <= 2.8e-91: tmp = x elif x <= 1.5e-52: tmp = x * (x / y) elif x <= 3100000.0: tmp = x else: tmp = x / y return tmp
function code(x, y) tmp = 0.0 if (x <= -1.0) tmp = Float64(x / y); elseif (x <= 2.8e-91) tmp = x; elseif (x <= 1.5e-52) tmp = Float64(x * Float64(x / y)); elseif (x <= 3100000.0) tmp = 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 <= 2.8e-91) tmp = x; elseif (x <= 1.5e-52) tmp = x * (x / y); elseif (x <= 3100000.0) tmp = 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, 2.8e-91], x, If[LessEqual[x, 1.5e-52], N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 3100000.0], x, N[(x / y), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq 2.8 \cdot 10^{-91}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 1.5 \cdot 10^{-52}:\\
\;\;\;\;x \cdot \frac{x}{y}\\
\mathbf{elif}\;x \leq 3100000:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -1 or 3.1e6 < x Initial program 77.5%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around inf 74.4%
if -1 < x < 2.8e-91 or 1.5e-52 < x < 3.1e6Initial program 99.9%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around 0 79.3%
if 2.8e-91 < x < 1.5e-52Initial program 99.2%
Taylor expanded in x around inf 94.9%
unpow294.9%
associate-*r/94.7%
Simplified94.7%
Taylor expanded in x around 0 94.9%
unpow294.9%
associate-*r/94.7%
Simplified94.7%
Final simplification77.3%
(FPCore (x y) :precision binary64 (if (<= x -1.0) (/ x y) (if (<= x 3100000.0) x (/ x y))))
double code(double x, double y) {
double tmp;
if (x <= -1.0) {
tmp = x / y;
} else if (x <= 3100000.0) {
tmp = 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 <= 3100000.0d0) then
tmp = 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 <= 3100000.0) {
tmp = x;
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.0: tmp = x / y elif x <= 3100000.0: tmp = x else: tmp = x / y return tmp
function code(x, y) tmp = 0.0 if (x <= -1.0) tmp = Float64(x / y); elseif (x <= 3100000.0) tmp = 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 <= 3100000.0) tmp = 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, 3100000.0], x, N[(x / y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq 3100000:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -1 or 3.1e6 < x Initial program 77.5%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around inf 74.4%
if -1 < x < 3.1e6Initial program 99.9%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around 0 75.9%
Final simplification75.2%
(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 77.8%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in y around inf 27.2%
Taylor expanded in x around inf 25.2%
if -1 < x < 1Initial program 99.9%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around 0 76.9%
Final simplification51.4%
(FPCore (x y) :precision binary64 1.0)
double code(double x, double y) {
return 1.0;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0
end function
public static double code(double x, double y) {
return 1.0;
}
def code(x, y): return 1.0
function code(x, y) return 1.0 end
function tmp = code(x, y) tmp = 1.0; end
code[x_, y_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 89.0%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around inf 53.2%
Taylor expanded in x around inf 14.2%
Final simplification14.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 2023199
(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)))