
(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 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(x * Float64(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[(x * N[(N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \frac{\frac{x}{y} + 1}{x + 1}
\end{array}
Initial program 89.0%
associate-/l*99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* x (/ x y))))
(if (<= x -3e+22)
(/ x y)
(if (<= x -9.8e-17)
(/ x (+ x 1.0))
(if (<= x -2e-52)
t_0
(if (<= x 1e-82) 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 <= -3e+22) {
tmp = x / y;
} else if (x <= -9.8e-17) {
tmp = x / (x + 1.0);
} else if (x <= -2e-52) {
tmp = t_0;
} else if (x <= 1e-82) {
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 <= (-3d+22)) then
tmp = x / y
else if (x <= (-9.8d-17)) then
tmp = x / (x + 1.0d0)
else if (x <= (-2d-52)) then
tmp = t_0
else if (x <= 1d-82) 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 <= -3e+22) {
tmp = x / y;
} else if (x <= -9.8e-17) {
tmp = x / (x + 1.0);
} else if (x <= -2e-52) {
tmp = t_0;
} else if (x <= 1e-82) {
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 <= -3e+22: tmp = x / y elif x <= -9.8e-17: tmp = x / (x + 1.0) elif x <= -2e-52: tmp = t_0 elif x <= 1e-82: 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 <= -3e+22) tmp = Float64(x / y); elseif (x <= -9.8e-17) tmp = Float64(x / Float64(x + 1.0)); elseif (x <= -2e-52) tmp = t_0; elseif (x <= 1e-82) 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 <= -3e+22) tmp = x / y; elseif (x <= -9.8e-17) tmp = x / (x + 1.0); elseif (x <= -2e-52) tmp = t_0; elseif (x <= 1e-82) 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, -3e+22], N[(x / y), $MachinePrecision], If[LessEqual[x, -9.8e-17], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -2e-52], t$95$0, If[LessEqual[x, 1e-82], 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 -3 \cdot 10^{+22}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq -9.8 \cdot 10^{-17}:\\
\;\;\;\;\frac{x}{x + 1}\\
\mathbf{elif}\;x \leq -2 \cdot 10^{-52}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 10^{-82}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -3e22 or 1 < x Initial program 76.4%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around inf 82.0%
if -3e22 < x < -9.80000000000000024e-17Initial program 100.0%
associate-/l*99.7%
Simplified99.7%
Taylor expanded in y around inf 73.5%
if -9.80000000000000024e-17 < x < -2e-52 or 1e-82 < x < 1Initial program 99.6%
associate-/l*99.6%
Simplified99.6%
Taylor expanded in y around 0 77.6%
Taylor expanded in x around 0 77.5%
if -2e-52 < x < 1e-82Initial program 100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around 0 86.9%
Final simplification83.0%
(FPCore (x y)
:precision binary64
(if (<= x -5e+19)
(/ x y)
(if (<= x -9.4e-17)
(/ x (+ x 1.0))
(if (<= x -3e-52)
(* x (- (/ x y) x))
(if (<= x 3.9e-89) x (if (<= x 1.0) (* x (/ x y)) (/ x y)))))))
double code(double x, double y) {
double tmp;
if (x <= -5e+19) {
tmp = x / y;
} else if (x <= -9.4e-17) {
tmp = x / (x + 1.0);
} else if (x <= -3e-52) {
tmp = x * ((x / y) - x);
} else if (x <= 3.9e-89) {
tmp = x;
} else if (x <= 1.0) {
tmp = x * (x / y);
} 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 <= (-5d+19)) then
tmp = x / y
else if (x <= (-9.4d-17)) then
tmp = x / (x + 1.0d0)
else if (x <= (-3d-52)) then
tmp = x * ((x / y) - x)
else if (x <= 3.9d-89) then
tmp = x
else if (x <= 1.0d0) then
tmp = x * (x / y)
else
tmp = x / y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -5e+19) {
tmp = x / y;
} else if (x <= -9.4e-17) {
tmp = x / (x + 1.0);
} else if (x <= -3e-52) {
tmp = x * ((x / y) - x);
} else if (x <= 3.9e-89) {
tmp = x;
} else if (x <= 1.0) {
tmp = x * (x / y);
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -5e+19: tmp = x / y elif x <= -9.4e-17: tmp = x / (x + 1.0) elif x <= -3e-52: tmp = x * ((x / y) - x) elif x <= 3.9e-89: tmp = x elif x <= 1.0: tmp = x * (x / y) else: tmp = x / y return tmp
function code(x, y) tmp = 0.0 if (x <= -5e+19) tmp = Float64(x / y); elseif (x <= -9.4e-17) tmp = Float64(x / Float64(x + 1.0)); elseif (x <= -3e-52) tmp = Float64(x * Float64(Float64(x / y) - x)); elseif (x <= 3.9e-89) tmp = x; elseif (x <= 1.0) tmp = Float64(x * Float64(x / y)); else tmp = Float64(x / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -5e+19) tmp = x / y; elseif (x <= -9.4e-17) tmp = x / (x + 1.0); elseif (x <= -3e-52) tmp = x * ((x / y) - x); elseif (x <= 3.9e-89) tmp = x; elseif (x <= 1.0) tmp = x * (x / y); else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -5e+19], N[(x / y), $MachinePrecision], If[LessEqual[x, -9.4e-17], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -3e-52], N[(x * N[(N[(x / y), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 3.9e-89], x, If[LessEqual[x, 1.0], N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision], N[(x / y), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5 \cdot 10^{+19}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq -9.4 \cdot 10^{-17}:\\
\;\;\;\;\frac{x}{x + 1}\\
\mathbf{elif}\;x \leq -3 \cdot 10^{-52}:\\
\;\;\;\;x \cdot \left(\frac{x}{y} - x\right)\\
\mathbf{elif}\;x \leq 3.9 \cdot 10^{-89}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;x \cdot \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -5e19 or 1 < x Initial program 76.4%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around inf 82.0%
if -5e19 < x < -9.3999999999999999e-17Initial program 100.0%
associate-/l*99.7%
Simplified99.7%
Taylor expanded in y around inf 73.5%
if -9.3999999999999999e-17 < x < -3e-52Initial program 99.8%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around 0 99.4%
Taylor expanded in x around inf 74.8%
unpow274.8%
associate-*r*74.8%
sub-neg74.8%
metadata-eval74.8%
distribute-lft-in74.8%
associate-*r/74.9%
*-rgt-identity74.9%
remove-double-neg74.9%
remove-double-neg74.9%
*-commutative74.9%
neg-mul-174.9%
unsub-neg74.9%
Simplified74.9%
if -3e-52 < x < 3.89999999999999978e-89Initial program 100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around 0 86.9%
if 3.89999999999999978e-89 < x < 1Initial program 99.5%
associate-/l*99.5%
Simplified99.5%
Taylor expanded in y around 0 79.1%
Taylor expanded in x around 0 79.0%
Final simplification83.0%
(FPCore (x y)
:precision binary64
(if (<= x -5.2e+19)
(/ x y)
(if (<= x -1.25e-16)
(/ x (+ x 1.0))
(if (or (<= x -6e-52) (not (<= x 2.8e-82))) (/ x (+ y (/ y x))) x))))
double code(double x, double y) {
double tmp;
if (x <= -5.2e+19) {
tmp = x / y;
} else if (x <= -1.25e-16) {
tmp = x / (x + 1.0);
} else if ((x <= -6e-52) || !(x <= 2.8e-82)) {
tmp = x / (y + (y / x));
} 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 <= (-5.2d+19)) then
tmp = x / y
else if (x <= (-1.25d-16)) then
tmp = x / (x + 1.0d0)
else if ((x <= (-6d-52)) .or. (.not. (x <= 2.8d-82))) then
tmp = x / (y + (y / x))
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -5.2e+19) {
tmp = x / y;
} else if (x <= -1.25e-16) {
tmp = x / (x + 1.0);
} else if ((x <= -6e-52) || !(x <= 2.8e-82)) {
tmp = x / (y + (y / x));
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -5.2e+19: tmp = x / y elif x <= -1.25e-16: tmp = x / (x + 1.0) elif (x <= -6e-52) or not (x <= 2.8e-82): tmp = x / (y + (y / x)) else: tmp = x return tmp
function code(x, y) tmp = 0.0 if (x <= -5.2e+19) tmp = Float64(x / y); elseif (x <= -1.25e-16) tmp = Float64(x / Float64(x + 1.0)); elseif ((x <= -6e-52) || !(x <= 2.8e-82)) tmp = Float64(x / Float64(y + Float64(y / x))); else tmp = x; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -5.2e+19) tmp = x / y; elseif (x <= -1.25e-16) tmp = x / (x + 1.0); elseif ((x <= -6e-52) || ~((x <= 2.8e-82))) tmp = x / (y + (y / x)); else tmp = x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -5.2e+19], N[(x / y), $MachinePrecision], If[LessEqual[x, -1.25e-16], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[x, -6e-52], N[Not[LessEqual[x, 2.8e-82]], $MachinePrecision]], N[(x / N[(y + N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], x]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.2 \cdot 10^{+19}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq -1.25 \cdot 10^{-16}:\\
\;\;\;\;\frac{x}{x + 1}\\
\mathbf{elif}\;x \leq -6 \cdot 10^{-52} \lor \neg \left(x \leq 2.8 \cdot 10^{-82}\right):\\
\;\;\;\;\frac{x}{y + \frac{y}{x}}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -5.2e19Initial program 74.4%
associate-/l*99.7%
Simplified99.7%
Taylor expanded in x around inf 86.3%
if -5.2e19 < x < -1.2500000000000001e-16Initial program 100.0%
associate-/l*99.7%
Simplified99.7%
Taylor expanded in y around inf 73.5%
if -1.2500000000000001e-16 < x < -6e-52 or 2.80000000000000024e-82 < x Initial program 84.8%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around 0 68.8%
clear-num68.8%
un-div-inv69.0%
*-commutative69.0%
associate-/l*78.4%
+-commutative78.4%
Applied egg-rr78.4%
Taylor expanded in x around inf 78.4%
if -6e-52 < x < 2.80000000000000024e-82Initial program 100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around 0 86.9%
Final simplification83.1%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* x (/ x y))))
(if (<= x -75000000000.0)
(/ x y)
(if (<= x -1.36e-52)
t_0
(if (<= x 7.5e-89) 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 <= -75000000000.0) {
tmp = x / y;
} else if (x <= -1.36e-52) {
tmp = t_0;
} else if (x <= 7.5e-89) {
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 <= (-75000000000.0d0)) then
tmp = x / y
else if (x <= (-1.36d-52)) then
tmp = t_0
else if (x <= 7.5d-89) 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 <= -75000000000.0) {
tmp = x / y;
} else if (x <= -1.36e-52) {
tmp = t_0;
} else if (x <= 7.5e-89) {
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 <= -75000000000.0: tmp = x / y elif x <= -1.36e-52: tmp = t_0 elif x <= 7.5e-89: 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 <= -75000000000.0) tmp = Float64(x / y); elseif (x <= -1.36e-52) tmp = t_0; elseif (x <= 7.5e-89) 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 <= -75000000000.0) tmp = x / y; elseif (x <= -1.36e-52) tmp = t_0; elseif (x <= 7.5e-89) 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, -75000000000.0], N[(x / y), $MachinePrecision], If[LessEqual[x, -1.36e-52], t$95$0, If[LessEqual[x, 7.5e-89], 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 -75000000000:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq -1.36 \cdot 10^{-52}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 7.5 \cdot 10^{-89}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -7.5e10 or 1 < x Initial program 76.6%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around inf 81.3%
if -7.5e10 < x < -1.36e-52 or 7.4999999999999999e-89 < x < 1Initial program 99.7%
associate-/l*99.6%
Simplified99.6%
Taylor expanded in y around 0 65.9%
Taylor expanded in x around 0 61.2%
if -1.36e-52 < x < 7.4999999999999999e-89Initial program 100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around 0 86.9%
Final simplification80.4%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (+ x y) y)))
(if (<= x -4.4e+19)
t_0
(if (<= x 3.4e-82)
(/ x (+ x 1.0))
(if (<= x 66000000000000.0) (/ x (+ y (/ y x))) t_0)))))
double code(double x, double y) {
double t_0 = (x + y) / y;
double tmp;
if (x <= -4.4e+19) {
tmp = t_0;
} else if (x <= 3.4e-82) {
tmp = x / (x + 1.0);
} else if (x <= 66000000000000.0) {
tmp = x / (y + (y / x));
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = (x + y) / y
if (x <= (-4.4d+19)) then
tmp = t_0
else if (x <= 3.4d-82) then
tmp = x / (x + 1.0d0)
else if (x <= 66000000000000.0d0) then
tmp = x / (y + (y / x))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = (x + y) / y;
double tmp;
if (x <= -4.4e+19) {
tmp = t_0;
} else if (x <= 3.4e-82) {
tmp = x / (x + 1.0);
} else if (x <= 66000000000000.0) {
tmp = x / (y + (y / x));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = (x + y) / y tmp = 0 if x <= -4.4e+19: tmp = t_0 elif x <= 3.4e-82: tmp = x / (x + 1.0) elif x <= 66000000000000.0: tmp = x / (y + (y / x)) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(Float64(x + y) / y) tmp = 0.0 if (x <= -4.4e+19) tmp = t_0; elseif (x <= 3.4e-82) tmp = Float64(x / Float64(x + 1.0)); elseif (x <= 66000000000000.0) tmp = Float64(x / Float64(y + Float64(y / x))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = (x + y) / y; tmp = 0.0; if (x <= -4.4e+19) tmp = t_0; elseif (x <= 3.4e-82) tmp = x / (x + 1.0); elseif (x <= 66000000000000.0) tmp = x / (y + (y / x)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(x + y), $MachinePrecision] / y), $MachinePrecision]}, If[LessEqual[x, -4.4e+19], t$95$0, If[LessEqual[x, 3.4e-82], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 66000000000000.0], N[(x / N[(y + N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x + y}{y}\\
\mathbf{if}\;x \leq -4.4 \cdot 10^{+19}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 3.4 \cdot 10^{-82}:\\
\;\;\;\;\frac{x}{x + 1}\\
\mathbf{elif}\;x \leq 66000000000000:\\
\;\;\;\;\frac{x}{y + \frac{y}{x}}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -4.4e19 or 6.6e13 < x Initial program 75.8%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around 0 68.5%
*-commutative68.5%
+-commutative68.5%
associate-/l*73.8%
*-lft-identity73.8%
associate-*l/73.7%
unpow273.7%
+-commutative73.7%
associate-/l*99.9%
*-lft-identity99.9%
associate-*l/99.8%
distribute-rgt-out99.8%
associate-*l/100.0%
*-lft-identity100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in x around inf 100.0%
if -4.4e19 < x < 3.39999999999999975e-82Initial program 99.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around inf 80.1%
if 3.39999999999999975e-82 < x < 6.6e13Initial program 99.6%
associate-/l*99.5%
Simplified99.5%
Taylor expanded in y around 0 77.4%
clear-num77.4%
un-div-inv77.5%
*-commutative77.5%
associate-/l*77.5%
+-commutative77.5%
Applied egg-rr77.5%
Taylor expanded in x around inf 77.5%
Final simplification88.9%
(FPCore (x y) :precision binary64 (if (or (<= x -1.0) (not (<= x 0.8))) (/ (+ x y) y) (* x (+ 1.0 (- (/ x y) x)))))
double code(double x, double y) {
double tmp;
if ((x <= -1.0) || !(x <= 0.8)) {
tmp = (x + y) / y;
} else {
tmp = x * (1.0 + ((x / y) - 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.8d0))) then
tmp = (x + y) / y
else
tmp = x * (1.0d0 + ((x / y) - x))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -1.0) || !(x <= 0.8)) {
tmp = (x + y) / y;
} else {
tmp = x * (1.0 + ((x / y) - x));
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -1.0) or not (x <= 0.8): tmp = (x + y) / y else: tmp = x * (1.0 + ((x / y) - x)) return tmp
function code(x, y) tmp = 0.0 if ((x <= -1.0) || !(x <= 0.8)) tmp = Float64(Float64(x + y) / y); else tmp = Float64(x * Float64(1.0 + Float64(Float64(x / y) - x))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -1.0) || ~((x <= 0.8))) tmp = (x + y) / y; else tmp = x * (1.0 + ((x / y) - x)); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -1.0], N[Not[LessEqual[x, 0.8]], $MachinePrecision]], N[(N[(x + y), $MachinePrecision] / y), $MachinePrecision], N[(x * N[(1.0 + N[(N[(x / y), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 0.8\right):\\
\;\;\;\;\frac{x + y}{y}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 + \left(\frac{x}{y} - x\right)\right)\\
\end{array}
\end{array}
if x < -1 or 0.80000000000000004 < x Initial program 77.2%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around 0 70.3%
*-commutative70.3%
+-commutative70.3%
associate-/l*75.3%
*-lft-identity75.3%
associate-*l/75.2%
unpow275.2%
+-commutative75.2%
associate-/l*99.9%
*-lft-identity99.9%
associate-*l/99.8%
distribute-rgt-out99.8%
associate-*l/100.0%
*-lft-identity100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in x around inf 98.0%
if -1 < x < 0.80000000000000004Initial program 99.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around 0 97.3%
Taylor expanded in y around inf 97.4%
neg-mul-197.4%
+-commutative97.4%
unsub-neg97.4%
Simplified97.4%
Final simplification97.7%
(FPCore (x y) :precision binary64 (if (or (<= x -1.0) (not (<= x 4e-18))) (/ x y) x))
double code(double x, double y) {
double tmp;
if ((x <= -1.0) || !(x <= 4e-18)) {
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 <= 4d-18))) 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 <= 4e-18)) {
tmp = x / y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -1.0) or not (x <= 4e-18): tmp = x / y else: tmp = x return tmp
function code(x, y) tmp = 0.0 if ((x <= -1.0) || !(x <= 4e-18)) 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 <= 4e-18))) tmp = x / y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -1.0], N[Not[LessEqual[x, 4e-18]], $MachinePrecision]], N[(x / y), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 4 \cdot 10^{-18}\right):\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -1 or 4.0000000000000003e-18 < x Initial program 77.9%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around inf 77.2%
if -1 < x < 4.0000000000000003e-18Initial program 99.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around 0 72.1%
Final simplification74.7%
(FPCore (x y) :precision binary64 (if (<= x -1.0) 1.0 (if (<= x 4e-18) x 1.0)))
double code(double x, double y) {
double tmp;
if (x <= -1.0) {
tmp = 1.0;
} else if (x <= 4e-18) {
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 <= 4d-18) 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 <= 4e-18) {
tmp = x;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.0: tmp = 1.0 elif x <= 4e-18: tmp = x else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -1.0) tmp = 1.0; elseif (x <= 4e-18) 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 <= 4e-18) tmp = x; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.0], 1.0, If[LessEqual[x, 4e-18], x, 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 4 \cdot 10^{-18}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < -1 or 4.0000000000000003e-18 < x Initial program 77.9%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around inf 21.4%
un-div-inv21.5%
+-commutative21.5%
Applied egg-rr21.5%
Taylor expanded in x around inf 19.9%
if -1 < x < 4.0000000000000003e-18Initial program 99.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around 0 72.1%
Final simplification46.2%
(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.8%
Simplified99.8%
Taylor expanded in y around inf 47.7%
un-div-inv47.7%
+-commutative47.7%
Applied egg-rr47.7%
Taylor expanded in x around inf 11.4%
Final simplification11.4%
(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 2024055
(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)))