
(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 (+ 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(Float64(x / 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[(N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{x + 1} \cdot \left(1 + \frac{x}{y}\right)
\end{array}
Initial program 88.0%
associate-/l*99.9%
associate-/r/99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ 1.0 (/ x y))) (t_1 (+ y (/ y x))))
(if (<= x -7.8e+15)
t_0
(if (<= x -8.5e-110)
(* x (/ 1.0 t_1))
(if (<= x 1.36e-124)
x
(if (<= x 2.7e-7) (/ x t_1) (+ t_0 (/ -1.0 y))))))))
double code(double x, double y) {
double t_0 = 1.0 + (x / y);
double t_1 = y + (y / x);
double tmp;
if (x <= -7.8e+15) {
tmp = t_0;
} else if (x <= -8.5e-110) {
tmp = x * (1.0 / t_1);
} else if (x <= 1.36e-124) {
tmp = x;
} else if (x <= 2.7e-7) {
tmp = x / t_1;
} else {
tmp = t_0 + (-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) :: t_1
real(8) :: tmp
t_0 = 1.0d0 + (x / y)
t_1 = y + (y / x)
if (x <= (-7.8d+15)) then
tmp = t_0
else if (x <= (-8.5d-110)) then
tmp = x * (1.0d0 / t_1)
else if (x <= 1.36d-124) then
tmp = x
else if (x <= 2.7d-7) then
tmp = x / t_1
else
tmp = t_0 + ((-1.0d0) / y)
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = 1.0 + (x / y);
double t_1 = y + (y / x);
double tmp;
if (x <= -7.8e+15) {
tmp = t_0;
} else if (x <= -8.5e-110) {
tmp = x * (1.0 / t_1);
} else if (x <= 1.36e-124) {
tmp = x;
} else if (x <= 2.7e-7) {
tmp = x / t_1;
} else {
tmp = t_0 + (-1.0 / y);
}
return tmp;
}
def code(x, y): t_0 = 1.0 + (x / y) t_1 = y + (y / x) tmp = 0 if x <= -7.8e+15: tmp = t_0 elif x <= -8.5e-110: tmp = x * (1.0 / t_1) elif x <= 1.36e-124: tmp = x elif x <= 2.7e-7: tmp = x / t_1 else: tmp = t_0 + (-1.0 / y) return tmp
function code(x, y) t_0 = Float64(1.0 + Float64(x / y)) t_1 = Float64(y + Float64(y / x)) tmp = 0.0 if (x <= -7.8e+15) tmp = t_0; elseif (x <= -8.5e-110) tmp = Float64(x * Float64(1.0 / t_1)); elseif (x <= 1.36e-124) tmp = x; elseif (x <= 2.7e-7) tmp = Float64(x / t_1); else tmp = Float64(t_0 + Float64(-1.0 / y)); end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 + (x / y); t_1 = y + (y / x); tmp = 0.0; if (x <= -7.8e+15) tmp = t_0; elseif (x <= -8.5e-110) tmp = x * (1.0 / t_1); elseif (x <= 1.36e-124) tmp = x; elseif (x <= 2.7e-7) tmp = x / t_1; else tmp = t_0 + (-1.0 / y); 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[(y + N[(y / x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -7.8e+15], t$95$0, If[LessEqual[x, -8.5e-110], N[(x * N[(1.0 / t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.36e-124], x, If[LessEqual[x, 2.7e-7], N[(x / t$95$1), $MachinePrecision], N[(t$95$0 + N[(-1.0 / y), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{x}{y}\\
t_1 := y + \frac{y}{x}\\
\mathbf{if}\;x \leq -7.8 \cdot 10^{+15}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -8.5 \cdot 10^{-110}:\\
\;\;\;\;x \cdot \frac{1}{t_1}\\
\mathbf{elif}\;x \leq 1.36 \cdot 10^{-124}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 2.7 \cdot 10^{-7}:\\
\;\;\;\;\frac{x}{t_1}\\
\mathbf{else}:\\
\;\;\;\;t_0 + \frac{-1}{y}\\
\end{array}
\end{array}
if x < -7.8e15Initial program 76.2%
associate-/l*100.0%
associate-/r/100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 100.0%
if -7.8e15 < x < -8.50000000000000029e-110Initial program 99.7%
*-commutative99.7%
associate-/l*99.5%
+-commutative99.5%
remove-double-neg99.5%
unsub-neg99.5%
div-sub99.4%
distribute-frac-neg99.4%
*-inverses99.4%
metadata-eval99.4%
Simplified99.4%
Taylor expanded in y around 0 71.1%
distribute-lft-in71.1%
*-rgt-identity71.1%
associate-*r/71.2%
*-rgt-identity71.2%
Simplified71.2%
clear-num71.1%
associate-/r/71.3%
Applied egg-rr71.3%
if -8.50000000000000029e-110 < x < 1.3599999999999999e-124Initial program 99.9%
Taylor expanded in x around 0 89.5%
if 1.3599999999999999e-124 < x < 2.70000000000000009e-7Initial program 99.8%
*-commutative99.8%
associate-/l*99.8%
+-commutative99.8%
remove-double-neg99.8%
unsub-neg99.8%
div-sub99.8%
distribute-frac-neg99.8%
*-inverses99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around 0 67.2%
distribute-lft-in67.2%
*-rgt-identity67.2%
associate-*r/67.4%
*-rgt-identity67.4%
Simplified67.4%
if 2.70000000000000009e-7 < x Initial program 82.2%
Taylor expanded in x around inf 97.3%
Final simplification91.4%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* x (/ x y))))
(if (<= x -1.0)
(/ x y)
(if (<= x -8.2e-108)
t_0
(if (<= x 1.36e-124)
x
(if (<= x 5.1e-49)
t_0
(if (<= x 98000000.0) (/ x (+ x 1.0)) (/ x y))))))))
double code(double x, double y) {
double t_0 = x * (x / y);
double tmp;
if (x <= -1.0) {
tmp = x / y;
} else if (x <= -8.2e-108) {
tmp = t_0;
} else if (x <= 1.36e-124) {
tmp = x;
} else if (x <= 5.1e-49) {
tmp = t_0;
} else if (x <= 98000000.0) {
tmp = x / (x + 1.0);
} else {
tmp = x / y;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = x * (x / y)
if (x <= (-1.0d0)) then
tmp = x / y
else if (x <= (-8.2d-108)) then
tmp = t_0
else if (x <= 1.36d-124) then
tmp = x
else if (x <= 5.1d-49) then
tmp = t_0
else if (x <= 98000000.0d0) then
tmp = x / (x + 1.0d0)
else
tmp = x / y
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = x * (x / y);
double tmp;
if (x <= -1.0) {
tmp = x / y;
} else if (x <= -8.2e-108) {
tmp = t_0;
} else if (x <= 1.36e-124) {
tmp = x;
} else if (x <= 5.1e-49) {
tmp = t_0;
} else if (x <= 98000000.0) {
tmp = x / (x + 1.0);
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): t_0 = x * (x / y) tmp = 0 if x <= -1.0: tmp = x / y elif x <= -8.2e-108: tmp = t_0 elif x <= 1.36e-124: tmp = x elif x <= 5.1e-49: tmp = t_0 elif x <= 98000000.0: tmp = x / (x + 1.0) else: tmp = x / y return tmp
function code(x, y) t_0 = Float64(x * Float64(x / y)) tmp = 0.0 if (x <= -1.0) tmp = Float64(x / y); elseif (x <= -8.2e-108) tmp = t_0; elseif (x <= 1.36e-124) tmp = x; elseif (x <= 5.1e-49) tmp = t_0; elseif (x <= 98000000.0) tmp = Float64(x / Float64(x + 1.0)); else tmp = Float64(x / y); end return tmp end
function tmp_2 = code(x, y) t_0 = x * (x / y); tmp = 0.0; if (x <= -1.0) tmp = x / y; elseif (x <= -8.2e-108) tmp = t_0; elseif (x <= 1.36e-124) tmp = x; elseif (x <= 5.1e-49) tmp = t_0; elseif (x <= 98000000.0) tmp = x / (x + 1.0); else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.0], N[(x / y), $MachinePrecision], If[LessEqual[x, -8.2e-108], t$95$0, If[LessEqual[x, 1.36e-124], x, If[LessEqual[x, 5.1e-49], t$95$0, If[LessEqual[x, 98000000.0], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], N[(x / y), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \frac{x}{y}\\
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq -8.2 \cdot 10^{-108}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 1.36 \cdot 10^{-124}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 5.1 \cdot 10^{-49}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 98000000:\\
\;\;\;\;\frac{x}{x + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -1 or 9.8e7 < x Initial program 79.0%
Taylor expanded in x around inf 79.1%
if -1 < x < -8.20000000000000074e-108 or 1.3599999999999999e-124 < x < 5.10000000000000026e-49Initial program 99.8%
*-commutative99.8%
associate-/l*99.6%
+-commutative99.6%
remove-double-neg99.6%
unsub-neg99.6%
div-sub99.5%
distribute-frac-neg99.5%
*-inverses99.5%
metadata-eval99.5%
Simplified99.5%
Taylor expanded in y around 0 71.8%
Taylor expanded in x around 0 69.1%
associate-/r/69.2%
Applied egg-rr69.2%
if -8.20000000000000074e-108 < x < 1.3599999999999999e-124Initial program 99.9%
Taylor expanded in x around 0 89.5%
if 5.10000000000000026e-49 < x < 9.8e7Initial program 99.9%
Taylor expanded in y around inf 58.7%
+-commutative58.7%
Simplified58.7%
Final simplification79.5%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ 1.0 (/ x y))) (t_1 (/ x (+ y (/ y x)))))
(if (<= x -7.8e+15)
t_0
(if (<= x -3.6e-106)
t_1
(if (<= x 1.36e-124) x (if (<= x 2.7e-7) t_1 t_0))))))
double code(double x, double y) {
double t_0 = 1.0 + (x / y);
double t_1 = x / (y + (y / x));
double tmp;
if (x <= -7.8e+15) {
tmp = t_0;
} else if (x <= -3.6e-106) {
tmp = t_1;
} else if (x <= 1.36e-124) {
tmp = x;
} else if (x <= 2.7e-7) {
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 / (y + (y / x))
if (x <= (-7.8d+15)) then
tmp = t_0
else if (x <= (-3.6d-106)) then
tmp = t_1
else if (x <= 1.36d-124) then
tmp = x
else if (x <= 2.7d-7) 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 / (y + (y / x));
double tmp;
if (x <= -7.8e+15) {
tmp = t_0;
} else if (x <= -3.6e-106) {
tmp = t_1;
} else if (x <= 1.36e-124) {
tmp = x;
} else if (x <= 2.7e-7) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 + (x / y) t_1 = x / (y + (y / x)) tmp = 0 if x <= -7.8e+15: tmp = t_0 elif x <= -3.6e-106: tmp = t_1 elif x <= 1.36e-124: tmp = x elif x <= 2.7e-7: 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(y + Float64(y / x))) tmp = 0.0 if (x <= -7.8e+15) tmp = t_0; elseif (x <= -3.6e-106) tmp = t_1; elseif (x <= 1.36e-124) tmp = x; elseif (x <= 2.7e-7) 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 / (y + (y / x)); tmp = 0.0; if (x <= -7.8e+15) tmp = t_0; elseif (x <= -3.6e-106) tmp = t_1; elseif (x <= 1.36e-124) tmp = x; elseif (x <= 2.7e-7) 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[(y + N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -7.8e+15], t$95$0, If[LessEqual[x, -3.6e-106], t$95$1, If[LessEqual[x, 1.36e-124], x, If[LessEqual[x, 2.7e-7], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{x}{y}\\
t_1 := \frac{x}{y + \frac{y}{x}}\\
\mathbf{if}\;x \leq -7.8 \cdot 10^{+15}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -3.6 \cdot 10^{-106}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 1.36 \cdot 10^{-124}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 2.7 \cdot 10^{-7}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -7.8e15 or 2.70000000000000009e-7 < x Initial program 79.2%
associate-/l*100.0%
associate-/r/100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 98.3%
if -7.8e15 < x < -3.60000000000000013e-106 or 1.3599999999999999e-124 < x < 2.70000000000000009e-7Initial program 99.8%
*-commutative99.8%
associate-/l*99.6%
+-commutative99.6%
remove-double-neg99.6%
unsub-neg99.6%
div-sub99.6%
distribute-frac-neg99.6%
*-inverses99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in y around 0 69.6%
distribute-lft-in69.6%
*-rgt-identity69.6%
associate-*r/69.7%
*-rgt-identity69.7%
Simplified69.7%
if -3.60000000000000013e-106 < x < 1.3599999999999999e-124Initial program 99.9%
Taylor expanded in x around 0 89.5%
Final simplification91.2%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ 1.0 (/ x y))) (t_1 (+ y (/ y x))))
(if (<= x -7.8e+15)
t_0
(if (<= x -5.2e-106)
(* x (/ 1.0 t_1))
(if (<= x 8e-125) x (if (<= x 2.7e-7) (/ x t_1) t_0))))))
double code(double x, double y) {
double t_0 = 1.0 + (x / y);
double t_1 = y + (y / x);
double tmp;
if (x <= -7.8e+15) {
tmp = t_0;
} else if (x <= -5.2e-106) {
tmp = x * (1.0 / t_1);
} else if (x <= 8e-125) {
tmp = x;
} else if (x <= 2.7e-7) {
tmp = x / 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 = y + (y / x)
if (x <= (-7.8d+15)) then
tmp = t_0
else if (x <= (-5.2d-106)) then
tmp = x * (1.0d0 / t_1)
else if (x <= 8d-125) then
tmp = x
else if (x <= 2.7d-7) then
tmp = x / 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 = y + (y / x);
double tmp;
if (x <= -7.8e+15) {
tmp = t_0;
} else if (x <= -5.2e-106) {
tmp = x * (1.0 / t_1);
} else if (x <= 8e-125) {
tmp = x;
} else if (x <= 2.7e-7) {
tmp = x / t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 + (x / y) t_1 = y + (y / x) tmp = 0 if x <= -7.8e+15: tmp = t_0 elif x <= -5.2e-106: tmp = x * (1.0 / t_1) elif x <= 8e-125: tmp = x elif x <= 2.7e-7: tmp = x / t_1 else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(1.0 + Float64(x / y)) t_1 = Float64(y + Float64(y / x)) tmp = 0.0 if (x <= -7.8e+15) tmp = t_0; elseif (x <= -5.2e-106) tmp = Float64(x * Float64(1.0 / t_1)); elseif (x <= 8e-125) tmp = x; elseif (x <= 2.7e-7) tmp = Float64(x / t_1); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 + (x / y); t_1 = y + (y / x); tmp = 0.0; if (x <= -7.8e+15) tmp = t_0; elseif (x <= -5.2e-106) tmp = x * (1.0 / t_1); elseif (x <= 8e-125) tmp = x; elseif (x <= 2.7e-7) tmp = x / 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[(y + N[(y / x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -7.8e+15], t$95$0, If[LessEqual[x, -5.2e-106], N[(x * N[(1.0 / t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 8e-125], x, If[LessEqual[x, 2.7e-7], N[(x / t$95$1), $MachinePrecision], t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{x}{y}\\
t_1 := y + \frac{y}{x}\\
\mathbf{if}\;x \leq -7.8 \cdot 10^{+15}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -5.2 \cdot 10^{-106}:\\
\;\;\;\;x \cdot \frac{1}{t_1}\\
\mathbf{elif}\;x \leq 8 \cdot 10^{-125}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 2.7 \cdot 10^{-7}:\\
\;\;\;\;\frac{x}{t_1}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -7.8e15 or 2.70000000000000009e-7 < x Initial program 79.2%
associate-/l*100.0%
associate-/r/100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 98.3%
if -7.8e15 < x < -5.2000000000000001e-106Initial program 99.7%
*-commutative99.7%
associate-/l*99.5%
+-commutative99.5%
remove-double-neg99.5%
unsub-neg99.5%
div-sub99.4%
distribute-frac-neg99.4%
*-inverses99.4%
metadata-eval99.4%
Simplified99.4%
Taylor expanded in y around 0 71.1%
distribute-lft-in71.1%
*-rgt-identity71.1%
associate-*r/71.2%
*-rgt-identity71.2%
Simplified71.2%
clear-num71.1%
associate-/r/71.3%
Applied egg-rr71.3%
if -5.2000000000000001e-106 < x < 8.0000000000000001e-125Initial program 99.9%
Taylor expanded in x around 0 89.5%
if 8.0000000000000001e-125 < x < 2.70000000000000009e-7Initial program 99.8%
*-commutative99.8%
associate-/l*99.8%
+-commutative99.8%
remove-double-neg99.8%
unsub-neg99.8%
div-sub99.8%
distribute-frac-neg99.8%
*-inverses99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around 0 67.2%
distribute-lft-in67.2%
*-rgt-identity67.2%
associate-*r/67.4%
*-rgt-identity67.4%
Simplified67.4%
Final simplification91.2%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* x (/ x y))))
(if (<= x -1.0)
(/ x y)
(if (<= x -4.1e-106)
t_0
(if (<= x 1.36e-124) x (if (<= x 1.0) t_0 (/ x y)))))))
double code(double x, double y) {
double t_0 = x * (x / y);
double tmp;
if (x <= -1.0) {
tmp = x / y;
} else if (x <= -4.1e-106) {
tmp = t_0;
} else if (x <= 1.36e-124) {
tmp = x;
} else if (x <= 1.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 * (x / y)
if (x <= (-1.0d0)) then
tmp = x / y
else if (x <= (-4.1d-106)) then
tmp = t_0
else if (x <= 1.36d-124) then
tmp = x
else if (x <= 1.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 * (x / y);
double tmp;
if (x <= -1.0) {
tmp = x / y;
} else if (x <= -4.1e-106) {
tmp = t_0;
} else if (x <= 1.36e-124) {
tmp = x;
} else if (x <= 1.0) {
tmp = t_0;
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): t_0 = x * (x / y) tmp = 0 if x <= -1.0: tmp = x / y elif x <= -4.1e-106: tmp = t_0 elif x <= 1.36e-124: tmp = x elif x <= 1.0: tmp = t_0 else: tmp = x / y return tmp
function code(x, y) t_0 = Float64(x * Float64(x / y)) tmp = 0.0 if (x <= -1.0) tmp = Float64(x / y); elseif (x <= -4.1e-106) tmp = t_0; elseif (x <= 1.36e-124) tmp = x; elseif (x <= 1.0) tmp = t_0; else tmp = Float64(x / y); end return tmp end
function tmp_2 = code(x, y) t_0 = x * (x / y); tmp = 0.0; if (x <= -1.0) tmp = x / y; elseif (x <= -4.1e-106) tmp = t_0; elseif (x <= 1.36e-124) tmp = x; elseif (x <= 1.0) tmp = t_0; else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.0], N[(x / y), $MachinePrecision], If[LessEqual[x, -4.1e-106], t$95$0, If[LessEqual[x, 1.36e-124], x, If[LessEqual[x, 1.0], t$95$0, N[(x / y), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \frac{x}{y}\\
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq -4.1 \cdot 10^{-106}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 1.36 \cdot 10^{-124}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -1 or 1 < x Initial program 79.4%
Taylor expanded in x around inf 77.9%
if -1 < x < -4.0999999999999999e-106 or 1.3599999999999999e-124 < x < 1Initial program 99.8%
*-commutative99.8%
associate-/l*99.6%
+-commutative99.6%
remove-double-neg99.6%
unsub-neg99.6%
div-sub99.6%
distribute-frac-neg99.6%
*-inverses99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in y around 0 65.9%
Taylor expanded in x around 0 62.9%
associate-/r/63.0%
Applied egg-rr63.0%
if -4.0999999999999999e-106 < x < 1.3599999999999999e-124Initial program 99.9%
Taylor expanded in x around 0 89.5%
Final simplification78.4%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ 1.0 (/ x y))) (t_1 (* x (/ x y))))
(if (<= x -1.0)
t_0
(if (<= x -1.45e-111)
t_1
(if (<= x 9.2e-125) x (if (<= x 2.7e-7) t_1 t_0))))))
double code(double x, double y) {
double t_0 = 1.0 + (x / y);
double t_1 = x * (x / y);
double tmp;
if (x <= -1.0) {
tmp = t_0;
} else if (x <= -1.45e-111) {
tmp = t_1;
} else if (x <= 9.2e-125) {
tmp = x;
} else if (x <= 2.7e-7) {
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 * (x / y)
if (x <= (-1.0d0)) then
tmp = t_0
else if (x <= (-1.45d-111)) then
tmp = t_1
else if (x <= 9.2d-125) then
tmp = x
else if (x <= 2.7d-7) 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 * (x / y);
double tmp;
if (x <= -1.0) {
tmp = t_0;
} else if (x <= -1.45e-111) {
tmp = t_1;
} else if (x <= 9.2e-125) {
tmp = x;
} else if (x <= 2.7e-7) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 + (x / y) t_1 = x * (x / y) tmp = 0 if x <= -1.0: tmp = t_0 elif x <= -1.45e-111: tmp = t_1 elif x <= 9.2e-125: tmp = x elif x <= 2.7e-7: 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(x / y)) tmp = 0.0 if (x <= -1.0) tmp = t_0; elseif (x <= -1.45e-111) tmp = t_1; elseif (x <= 9.2e-125) tmp = x; elseif (x <= 2.7e-7) 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 * (x / y); tmp = 0.0; if (x <= -1.0) tmp = t_0; elseif (x <= -1.45e-111) tmp = t_1; elseif (x <= 9.2e-125) tmp = x; elseif (x <= 2.7e-7) 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[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.0], t$95$0, If[LessEqual[x, -1.45e-111], t$95$1, If[LessEqual[x, 9.2e-125], x, If[LessEqual[x, 2.7e-7], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{x}{y}\\
t_1 := x \cdot \frac{x}{y}\\
\mathbf{if}\;x \leq -1:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -1.45 \cdot 10^{-111}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 9.2 \cdot 10^{-125}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 2.7 \cdot 10^{-7}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -1 or 2.70000000000000009e-7 < x Initial program 79.6%
associate-/l*100.0%
associate-/r/100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 98.3%
if -1 < x < -1.45000000000000001e-111 or 9.1999999999999996e-125 < x < 2.70000000000000009e-7Initial program 99.8%
*-commutative99.8%
associate-/l*99.6%
+-commutative99.6%
remove-double-neg99.6%
unsub-neg99.6%
div-sub99.6%
distribute-frac-neg99.6%
*-inverses99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in y around 0 67.4%
Taylor expanded in x around 0 64.4%
associate-/r/64.5%
Applied egg-rr64.5%
if -1.45000000000000001e-111 < x < 9.1999999999999996e-125Initial program 99.9%
Taylor expanded in x around 0 89.5%
Final simplification90.7%
(FPCore (x y) :precision binary64 (if (or (<= x -1.0) (not (<= x 6200.0))) (/ x y) x))
double code(double x, double y) {
double tmp;
if ((x <= -1.0) || !(x <= 6200.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 <= 6200.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 <= 6200.0)) {
tmp = x / y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -1.0) or not (x <= 6200.0): tmp = x / y else: tmp = x return tmp
function code(x, y) tmp = 0.0 if ((x <= -1.0) || !(x <= 6200.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 <= 6200.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, 6200.0]], $MachinePrecision]], N[(x / y), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 6200\right):\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -1 or 6200 < x Initial program 79.3%
Taylor expanded in x around inf 78.4%
if -1 < x < 6200Initial program 99.9%
Taylor expanded in x around 0 67.1%
Final simplification73.6%
(FPCore (x y) :precision binary64 (if (<= x -105000000000.0) 1.0 (if (<= x 1.0) x 1.0)))
double code(double x, double y) {
double tmp;
if (x <= -105000000000.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 <= (-105000000000.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 <= -105000000000.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 <= -105000000000.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 <= -105000000000.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 <= -105000000000.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, -105000000000.0], 1.0, If[LessEqual[x, 1.0], x, 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -105000000000:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < -1.05e11 or 1 < x Initial program 79.3%
Taylor expanded in y around inf 24.2%
+-commutative24.2%
Simplified24.2%
Taylor expanded in x around inf 23.5%
if -1.05e11 < x < 1Initial program 99.9%
Taylor expanded in x around 0 67.0%
Final simplification41.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 88.0%
Taylor expanded in y around inf 42.4%
+-commutative42.4%
Simplified42.4%
Taylor expanded in x around inf 15.1%
Final simplification15.1%
(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 2023308
(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)))