
(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 9 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 88.5%
associate-/l*99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ x (+ x 1.0))))
(if (<= x -57000.0)
(+ 1.0 (/ (+ x -1.0) y))
(if (<= x -9.6e-32)
t_0
(if (<= x -4e-81)
(* x (- (/ x y) x))
(if (<= x 112.0) t_0 (- (+ 1.0 (/ x y)) (/ 1.0 y))))))))
double code(double x, double y) {
double t_0 = x / (x + 1.0);
double tmp;
if (x <= -57000.0) {
tmp = 1.0 + ((x + -1.0) / y);
} else if (x <= -9.6e-32) {
tmp = t_0;
} else if (x <= -4e-81) {
tmp = x * ((x / y) - x);
} else if (x <= 112.0) {
tmp = t_0;
} 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 <= (-57000.0d0)) then
tmp = 1.0d0 + ((x + (-1.0d0)) / y)
else if (x <= (-9.6d-32)) then
tmp = t_0
else if (x <= (-4d-81)) then
tmp = x * ((x / y) - x)
else if (x <= 112.0d0) then
tmp = t_0
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 <= -57000.0) {
tmp = 1.0 + ((x + -1.0) / y);
} else if (x <= -9.6e-32) {
tmp = t_0;
} else if (x <= -4e-81) {
tmp = x * ((x / y) - x);
} else if (x <= 112.0) {
tmp = t_0;
} 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 <= -57000.0: tmp = 1.0 + ((x + -1.0) / y) elif x <= -9.6e-32: tmp = t_0 elif x <= -4e-81: tmp = x * ((x / y) - x) elif x <= 112.0: tmp = t_0 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 <= -57000.0) tmp = Float64(1.0 + Float64(Float64(x + -1.0) / y)); elseif (x <= -9.6e-32) tmp = t_0; elseif (x <= -4e-81) tmp = Float64(x * Float64(Float64(x / y) - x)); elseif (x <= 112.0) tmp = t_0; 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 <= -57000.0) tmp = 1.0 + ((x + -1.0) / y); elseif (x <= -9.6e-32) tmp = t_0; elseif (x <= -4e-81) tmp = x * ((x / y) - x); elseif (x <= 112.0) tmp = t_0; 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, -57000.0], N[(1.0 + N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -9.6e-32], t$95$0, If[LessEqual[x, -4e-81], N[(x * N[(N[(x / y), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 112.0], t$95$0, 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 -57000:\\
\;\;\;\;1 + \frac{x + -1}{y}\\
\mathbf{elif}\;x \leq -9.6 \cdot 10^{-32}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -4 \cdot 10^{-81}:\\
\;\;\;\;x \cdot \left(\frac{x}{y} - x\right)\\
\mathbf{elif}\;x \leq 112:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\left(1 + \frac{x}{y}\right) - \frac{1}{y}\\
\end{array}
\end{array}
if x < -57000Initial program 77.2%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around inf 99.0%
associate--l+99.0%
+-commutative99.0%
sub-div99.0%
sub-neg99.0%
metadata-eval99.0%
Applied egg-rr99.0%
if -57000 < x < -9.6000000000000005e-32 or -3.9999999999999998e-81 < x < 112Initial program 99.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around inf 83.4%
if -9.6000000000000005e-32 < x < -3.9999999999999998e-81Initial program 99.7%
associate-/l*99.4%
Simplified99.4%
Taylor expanded in x around 0 99.7%
fma-def99.6%
sub-neg99.6%
metadata-eval99.6%
unpow299.6%
Simplified99.6%
Taylor expanded in x around inf 66.8%
unpow266.8%
*-commutative66.8%
sub-neg66.8%
metadata-eval66.8%
+-commutative66.8%
distribute-rgt-in66.8%
neg-mul-166.8%
distribute-lft-neg-in66.8%
associate-*l/66.8%
*-commutative66.8%
*-rgt-identity66.8%
associate-*l/67.0%
distribute-rgt-out67.0%
Simplified67.0%
if 112 < x Initial program 74.2%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around inf 97.9%
Final simplification89.8%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ 1.0 (/ (+ x -1.0) y))) (t_1 (/ x (+ x 1.0))))
(if (<= x -950000.0)
t_0
(if (<= x -6e-31)
t_1
(if (<= x -9e-83) (* x (/ x y)) (if (<= x 220.0) t_1 t_0))))))
double code(double x, double y) {
double t_0 = 1.0 + ((x + -1.0) / y);
double t_1 = x / (x + 1.0);
double tmp;
if (x <= -950000.0) {
tmp = t_0;
} else if (x <= -6e-31) {
tmp = t_1;
} else if (x <= -9e-83) {
tmp = x * (x / y);
} else if (x <= 220.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 + (-1.0d0)) / y)
t_1 = x / (x + 1.0d0)
if (x <= (-950000.0d0)) then
tmp = t_0
else if (x <= (-6d-31)) then
tmp = t_1
else if (x <= (-9d-83)) then
tmp = x * (x / y)
else if (x <= 220.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 + -1.0) / y);
double t_1 = x / (x + 1.0);
double tmp;
if (x <= -950000.0) {
tmp = t_0;
} else if (x <= -6e-31) {
tmp = t_1;
} else if (x <= -9e-83) {
tmp = x * (x / y);
} else if (x <= 220.0) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 + ((x + -1.0) / y) t_1 = x / (x + 1.0) tmp = 0 if x <= -950000.0: tmp = t_0 elif x <= -6e-31: tmp = t_1 elif x <= -9e-83: tmp = x * (x / y) elif x <= 220.0: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(1.0 + Float64(Float64(x + -1.0) / y)) t_1 = Float64(x / Float64(x + 1.0)) tmp = 0.0 if (x <= -950000.0) tmp = t_0; elseif (x <= -6e-31) tmp = t_1; elseif (x <= -9e-83) tmp = Float64(x * Float64(x / y)); elseif (x <= 220.0) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 + ((x + -1.0) / y); t_1 = x / (x + 1.0); tmp = 0.0; if (x <= -950000.0) tmp = t_0; elseif (x <= -6e-31) tmp = t_1; elseif (x <= -9e-83) tmp = x * (x / y); elseif (x <= 220.0) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(1.0 + N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -950000.0], t$95$0, If[LessEqual[x, -6e-31], t$95$1, If[LessEqual[x, -9e-83], N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 220.0], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{x + -1}{y}\\
t_1 := \frac{x}{x + 1}\\
\mathbf{if}\;x \leq -950000:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -6 \cdot 10^{-31}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq -9 \cdot 10^{-83}:\\
\;\;\;\;x \cdot \frac{x}{y}\\
\mathbf{elif}\;x \leq 220:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -9.5e5 or 220 < x Initial program 75.6%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around inf 98.5%
associate--l+98.5%
+-commutative98.5%
sub-div98.5%
sub-neg98.5%
metadata-eval98.5%
Applied egg-rr98.5%
if -9.5e5 < x < -5.99999999999999962e-31 or -8.99999999999999995e-83 < x < 220Initial program 99.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around inf 83.4%
if -5.99999999999999962e-31 < x < -8.99999999999999995e-83Initial program 99.7%
associate-/l*99.4%
Simplified99.4%
Taylor expanded in x around 0 99.7%
fma-def99.6%
sub-neg99.6%
metadata-eval99.6%
unpow299.6%
Simplified99.6%
Taylor expanded in x around inf 66.8%
sub-neg66.8%
metadata-eval66.8%
unpow266.8%
Simplified66.8%
Taylor expanded in y around 0 66.4%
unpow266.4%
associate-*r/66.6%
Simplified66.6%
Final simplification89.7%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ 1.0 (/ (+ x -1.0) y))) (t_1 (/ x (+ x 1.0))))
(if (<= x -280000.0)
t_0
(if (<= x -2.8e-31)
t_1
(if (<= x -4.6e-81) (* x (- (/ x y) x)) (if (<= x 220.0) t_1 t_0))))))
double code(double x, double y) {
double t_0 = 1.0 + ((x + -1.0) / y);
double t_1 = x / (x + 1.0);
double tmp;
if (x <= -280000.0) {
tmp = t_0;
} else if (x <= -2.8e-31) {
tmp = t_1;
} else if (x <= -4.6e-81) {
tmp = x * ((x / y) - x);
} else if (x <= 220.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 + (-1.0d0)) / y)
t_1 = x / (x + 1.0d0)
if (x <= (-280000.0d0)) then
tmp = t_0
else if (x <= (-2.8d-31)) then
tmp = t_1
else if (x <= (-4.6d-81)) then
tmp = x * ((x / y) - x)
else if (x <= 220.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 + -1.0) / y);
double t_1 = x / (x + 1.0);
double tmp;
if (x <= -280000.0) {
tmp = t_0;
} else if (x <= -2.8e-31) {
tmp = t_1;
} else if (x <= -4.6e-81) {
tmp = x * ((x / y) - x);
} else if (x <= 220.0) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 + ((x + -1.0) / y) t_1 = x / (x + 1.0) tmp = 0 if x <= -280000.0: tmp = t_0 elif x <= -2.8e-31: tmp = t_1 elif x <= -4.6e-81: tmp = x * ((x / y) - x) elif x <= 220.0: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(1.0 + Float64(Float64(x + -1.0) / y)) t_1 = Float64(x / Float64(x + 1.0)) tmp = 0.0 if (x <= -280000.0) tmp = t_0; elseif (x <= -2.8e-31) tmp = t_1; elseif (x <= -4.6e-81) tmp = Float64(x * Float64(Float64(x / y) - x)); elseif (x <= 220.0) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 + ((x + -1.0) / y); t_1 = x / (x + 1.0); tmp = 0.0; if (x <= -280000.0) tmp = t_0; elseif (x <= -2.8e-31) tmp = t_1; elseif (x <= -4.6e-81) tmp = x * ((x / y) - x); elseif (x <= 220.0) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(1.0 + N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -280000.0], t$95$0, If[LessEqual[x, -2.8e-31], t$95$1, If[LessEqual[x, -4.6e-81], N[(x * N[(N[(x / y), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 220.0], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{x + -1}{y}\\
t_1 := \frac{x}{x + 1}\\
\mathbf{if}\;x \leq -280000:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -2.8 \cdot 10^{-31}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq -4.6 \cdot 10^{-81}:\\
\;\;\;\;x \cdot \left(\frac{x}{y} - x\right)\\
\mathbf{elif}\;x \leq 220:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -2.8e5 or 220 < x Initial program 75.6%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around inf 98.5%
associate--l+98.5%
+-commutative98.5%
sub-div98.5%
sub-neg98.5%
metadata-eval98.5%
Applied egg-rr98.5%
if -2.8e5 < x < -2.7999999999999999e-31 or -4.59999999999999982e-81 < x < 220Initial program 99.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around inf 83.4%
if -2.7999999999999999e-31 < x < -4.59999999999999982e-81Initial program 99.7%
associate-/l*99.4%
Simplified99.4%
Taylor expanded in x around 0 99.7%
fma-def99.6%
sub-neg99.6%
metadata-eval99.6%
unpow299.6%
Simplified99.6%
Taylor expanded in x around inf 66.8%
unpow266.8%
*-commutative66.8%
sub-neg66.8%
metadata-eval66.8%
+-commutative66.8%
distribute-rgt-in66.8%
neg-mul-166.8%
distribute-lft-neg-in66.8%
associate-*l/66.8%
*-commutative66.8%
*-rgt-identity66.8%
associate-*l/67.0%
distribute-rgt-out67.0%
Simplified67.0%
Final simplification89.8%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ x (+ x 1.0))))
(if (<= x -7.4e+34)
(/ x y)
(if (<= x -1.4e-31)
t_0
(if (<= x -4.05e-81) (* x (/ x y)) (if (<= x 2.05e+63) t_0 (/ x y)))))))
double code(double x, double y) {
double t_0 = x / (x + 1.0);
double tmp;
if (x <= -7.4e+34) {
tmp = x / y;
} else if (x <= -1.4e-31) {
tmp = t_0;
} else if (x <= -4.05e-81) {
tmp = x * (x / y);
} else if (x <= 2.05e+63) {
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 + 1.0d0)
if (x <= (-7.4d+34)) then
tmp = x / y
else if (x <= (-1.4d-31)) then
tmp = t_0
else if (x <= (-4.05d-81)) then
tmp = x * (x / y)
else if (x <= 2.05d+63) 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 + 1.0);
double tmp;
if (x <= -7.4e+34) {
tmp = x / y;
} else if (x <= -1.4e-31) {
tmp = t_0;
} else if (x <= -4.05e-81) {
tmp = x * (x / y);
} else if (x <= 2.05e+63) {
tmp = t_0;
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): t_0 = x / (x + 1.0) tmp = 0 if x <= -7.4e+34: tmp = x / y elif x <= -1.4e-31: tmp = t_0 elif x <= -4.05e-81: tmp = x * (x / y) elif x <= 2.05e+63: tmp = t_0 else: tmp = x / y return tmp
function code(x, y) t_0 = Float64(x / Float64(x + 1.0)) tmp = 0.0 if (x <= -7.4e+34) tmp = Float64(x / y); elseif (x <= -1.4e-31) tmp = t_0; elseif (x <= -4.05e-81) tmp = Float64(x * Float64(x / y)); elseif (x <= 2.05e+63) tmp = t_0; else tmp = Float64(x / y); end return tmp end
function tmp_2 = code(x, y) t_0 = x / (x + 1.0); tmp = 0.0; if (x <= -7.4e+34) tmp = x / y; elseif (x <= -1.4e-31) tmp = t_0; elseif (x <= -4.05e-81) tmp = x * (x / y); elseif (x <= 2.05e+63) tmp = t_0; else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -7.4e+34], N[(x / y), $MachinePrecision], If[LessEqual[x, -1.4e-31], t$95$0, If[LessEqual[x, -4.05e-81], N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.05e+63], t$95$0, N[(x / y), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{x + 1}\\
\mathbf{if}\;x \leq -7.4 \cdot 10^{+34}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq -1.4 \cdot 10^{-31}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -4.05 \cdot 10^{-81}:\\
\;\;\;\;x \cdot \frac{x}{y}\\
\mathbf{elif}\;x \leq 2.05 \cdot 10^{+63}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -7.40000000000000017e34 or 2.04999999999999996e63 < x Initial program 71.7%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around inf 82.2%
if -7.40000000000000017e34 < x < -1.3999999999999999e-31 or -4.0500000000000001e-81 < x < 2.04999999999999996e63Initial program 99.3%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around inf 79.5%
if -1.3999999999999999e-31 < x < -4.0500000000000001e-81Initial program 99.7%
associate-/l*99.4%
Simplified99.4%
Taylor expanded in x around 0 99.7%
fma-def99.6%
sub-neg99.6%
metadata-eval99.6%
unpow299.6%
Simplified99.6%
Taylor expanded in x around inf 66.8%
sub-neg66.8%
metadata-eval66.8%
unpow266.8%
Simplified66.8%
Taylor expanded in y around 0 66.4%
unpow266.4%
associate-*r/66.6%
Simplified66.6%
Final simplification80.0%
(FPCore (x y)
:precision binary64
(if (<= x -1.0)
(/ x y)
(if (<= x -4.7e-32)
x
(if (<= x -4.6e-81) (* x (/ x y)) (if (<= x 100.0) x (/ x y))))))
double code(double x, double y) {
double tmp;
if (x <= -1.0) {
tmp = x / y;
} else if (x <= -4.7e-32) {
tmp = x;
} else if (x <= -4.6e-81) {
tmp = x * (x / y);
} else if (x <= 100.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 <= (-4.7d-32)) then
tmp = x
else if (x <= (-4.6d-81)) then
tmp = x * (x / y)
else if (x <= 100.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 <= -4.7e-32) {
tmp = x;
} else if (x <= -4.6e-81) {
tmp = x * (x / y);
} else if (x <= 100.0) {
tmp = x;
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.0: tmp = x / y elif x <= -4.7e-32: tmp = x elif x <= -4.6e-81: tmp = x * (x / y) elif x <= 100.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 <= -4.7e-32) tmp = x; elseif (x <= -4.6e-81) tmp = Float64(x * Float64(x / y)); elseif (x <= 100.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 <= -4.7e-32) tmp = x; elseif (x <= -4.6e-81) tmp = x * (x / y); elseif (x <= 100.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, -4.7e-32], x, If[LessEqual[x, -4.6e-81], N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 100.0], x, N[(x / y), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq -4.7 \cdot 10^{-32}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq -4.6 \cdot 10^{-81}:\\
\;\;\;\;x \cdot \frac{x}{y}\\
\mathbf{elif}\;x \leq 100:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -1 or 100 < x Initial program 75.6%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around inf 74.0%
if -1 < x < -4.70000000000000019e-32 or -4.59999999999999982e-81 < x < 100Initial program 99.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around 0 82.6%
if -4.70000000000000019e-32 < x < -4.59999999999999982e-81Initial program 99.7%
associate-/l*99.4%
Simplified99.4%
Taylor expanded in x around 0 99.7%
fma-def99.6%
sub-neg99.6%
metadata-eval99.6%
unpow299.6%
Simplified99.6%
Taylor expanded in x around inf 66.8%
sub-neg66.8%
metadata-eval66.8%
unpow266.8%
Simplified66.8%
Taylor expanded in y around 0 66.4%
unpow266.4%
associate-*r/66.6%
Simplified66.6%
Final simplification77.9%
(FPCore (x y) :precision binary64 (if (<= x -1.0) (/ x y) (if (<= x 95.0) x (/ x y))))
double code(double x, double y) {
double tmp;
if (x <= -1.0) {
tmp = x / y;
} else if (x <= 95.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 <= 95.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 <= 95.0) {
tmp = x;
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.0: tmp = x / y elif x <= 95.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 <= 95.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 <= 95.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, 95.0], x, N[(x / y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq 95:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -1 or 95 < x Initial program 75.6%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around inf 74.0%
if -1 < x < 95Initial program 99.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around 0 77.8%
Final simplification76.0%
(FPCore (x y) :precision binary64 (if (<= x -2400000.0) 1.0 (if (<= x 2e-7) x 1.0)))
double code(double x, double y) {
double tmp;
if (x <= -2400000.0) {
tmp = 1.0;
} else if (x <= 2e-7) {
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 <= (-2400000.0d0)) then
tmp = 1.0d0
else if (x <= 2d-7) 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 <= -2400000.0) {
tmp = 1.0;
} else if (x <= 2e-7) {
tmp = x;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -2400000.0: tmp = 1.0 elif x <= 2e-7: tmp = x else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -2400000.0) tmp = 1.0; elseif (x <= 2e-7) tmp = x; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -2400000.0) tmp = 1.0; elseif (x <= 2e-7) tmp = x; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -2400000.0], 1.0, If[LessEqual[x, 2e-7], x, 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2400000:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 2 \cdot 10^{-7}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < -2.4e6 or 1.9999999999999999e-7 < x Initial program 75.8%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around inf 97.2%
Taylor expanded in y around inf 23.7%
if -2.4e6 < x < 1.9999999999999999e-7Initial program 99.9%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around 0 78.3%
Final simplification52.5%
(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.5%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around inf 47.8%
Taylor expanded in y 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 2023176
(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)))