
(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 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 84.4%
associate-/l*99.9%
Simplified99.9%
(FPCore (x y)
:precision binary64
(if (<= x -2.9e+150)
(/ x y)
(if (<= x -8.2e+78)
1.0
(if (<= x -2.3e+55)
(/ x y)
(if (<= x 8.5e-94)
(/ x (+ x 1.0))
(if (<= x 48000000000.0) (* x (/ x (* y (+ x 1.0)))) (/ x y)))))))
double code(double x, double y) {
double tmp;
if (x <= -2.9e+150) {
tmp = x / y;
} else if (x <= -8.2e+78) {
tmp = 1.0;
} else if (x <= -2.3e+55) {
tmp = x / y;
} else if (x <= 8.5e-94) {
tmp = x / (x + 1.0);
} else if (x <= 48000000000.0) {
tmp = x * (x / (y * (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) :: tmp
if (x <= (-2.9d+150)) then
tmp = x / y
else if (x <= (-8.2d+78)) then
tmp = 1.0d0
else if (x <= (-2.3d+55)) then
tmp = x / y
else if (x <= 8.5d-94) then
tmp = x / (x + 1.0d0)
else if (x <= 48000000000.0d0) then
tmp = x * (x / (y * (x + 1.0d0)))
else
tmp = x / y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -2.9e+150) {
tmp = x / y;
} else if (x <= -8.2e+78) {
tmp = 1.0;
} else if (x <= -2.3e+55) {
tmp = x / y;
} else if (x <= 8.5e-94) {
tmp = x / (x + 1.0);
} else if (x <= 48000000000.0) {
tmp = x * (x / (y * (x + 1.0)));
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -2.9e+150: tmp = x / y elif x <= -8.2e+78: tmp = 1.0 elif x <= -2.3e+55: tmp = x / y elif x <= 8.5e-94: tmp = x / (x + 1.0) elif x <= 48000000000.0: tmp = x * (x / (y * (x + 1.0))) else: tmp = x / y return tmp
function code(x, y) tmp = 0.0 if (x <= -2.9e+150) tmp = Float64(x / y); elseif (x <= -8.2e+78) tmp = 1.0; elseif (x <= -2.3e+55) tmp = Float64(x / y); elseif (x <= 8.5e-94) tmp = Float64(x / Float64(x + 1.0)); elseif (x <= 48000000000.0) tmp = Float64(x * Float64(x / Float64(y * Float64(x + 1.0)))); else tmp = Float64(x / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -2.9e+150) tmp = x / y; elseif (x <= -8.2e+78) tmp = 1.0; elseif (x <= -2.3e+55) tmp = x / y; elseif (x <= 8.5e-94) tmp = x / (x + 1.0); elseif (x <= 48000000000.0) tmp = x * (x / (y * (x + 1.0))); else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -2.9e+150], N[(x / y), $MachinePrecision], If[LessEqual[x, -8.2e+78], 1.0, If[LessEqual[x, -2.3e+55], N[(x / y), $MachinePrecision], If[LessEqual[x, 8.5e-94], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 48000000000.0], N[(x * N[(x / N[(y * N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x / y), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.9 \cdot 10^{+150}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq -8.2 \cdot 10^{+78}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq -2.3 \cdot 10^{+55}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq 8.5 \cdot 10^{-94}:\\
\;\;\;\;\frac{x}{x + 1}\\
\mathbf{elif}\;x \leq 48000000000:\\
\;\;\;\;x \cdot \frac{x}{y \cdot \left(x + 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -2.90000000000000011e150 or -8.1999999999999994e78 < x < -2.29999999999999987e55 or 4.8e10 < x Initial program 67.0%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around inf 76.0%
if -2.90000000000000011e150 < x < -8.1999999999999994e78Initial program 89.1%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around inf 63.3%
Taylor expanded in x around inf 63.4%
if -2.29999999999999987e55 < x < 8.50000000000000003e-94Initial program 100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in y around inf 82.4%
if 8.50000000000000003e-94 < x < 4.8e10Initial program 99.7%
associate-/l*99.7%
Simplified99.7%
Taylor expanded in y around 0 66.6%
Final simplification76.5%
(FPCore (x y)
:precision binary64
(if (<= x -2.9e+150)
(/ x y)
(if (<= x -9.2e+78)
1.0
(if (<= x -4.5e+51)
(/ x y)
(if (<= x 8.5e-94)
(/ x (+ x 1.0))
(if (<= x 1.0) (/ x (/ y x)) (/ x y)))))))
double code(double x, double y) {
double tmp;
if (x <= -2.9e+150) {
tmp = x / y;
} else if (x <= -9.2e+78) {
tmp = 1.0;
} else if (x <= -4.5e+51) {
tmp = x / y;
} else if (x <= 8.5e-94) {
tmp = x / (x + 1.0);
} else if (x <= 1.0) {
tmp = x / (y / 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 <= (-2.9d+150)) then
tmp = x / y
else if (x <= (-9.2d+78)) then
tmp = 1.0d0
else if (x <= (-4.5d+51)) then
tmp = x / y
else if (x <= 8.5d-94) then
tmp = x / (x + 1.0d0)
else if (x <= 1.0d0) then
tmp = x / (y / x)
else
tmp = x / y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -2.9e+150) {
tmp = x / y;
} else if (x <= -9.2e+78) {
tmp = 1.0;
} else if (x <= -4.5e+51) {
tmp = x / y;
} else if (x <= 8.5e-94) {
tmp = x / (x + 1.0);
} else if (x <= 1.0) {
tmp = x / (y / x);
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -2.9e+150: tmp = x / y elif x <= -9.2e+78: tmp = 1.0 elif x <= -4.5e+51: tmp = x / y elif x <= 8.5e-94: tmp = x / (x + 1.0) elif x <= 1.0: tmp = x / (y / x) else: tmp = x / y return tmp
function code(x, y) tmp = 0.0 if (x <= -2.9e+150) tmp = Float64(x / y); elseif (x <= -9.2e+78) tmp = 1.0; elseif (x <= -4.5e+51) tmp = Float64(x / y); elseif (x <= 8.5e-94) tmp = Float64(x / Float64(x + 1.0)); elseif (x <= 1.0) tmp = Float64(x / Float64(y / x)); else tmp = Float64(x / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -2.9e+150) tmp = x / y; elseif (x <= -9.2e+78) tmp = 1.0; elseif (x <= -4.5e+51) tmp = x / y; elseif (x <= 8.5e-94) tmp = x / (x + 1.0); elseif (x <= 1.0) tmp = x / (y / x); else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -2.9e+150], N[(x / y), $MachinePrecision], If[LessEqual[x, -9.2e+78], 1.0, If[LessEqual[x, -4.5e+51], N[(x / y), $MachinePrecision], If[LessEqual[x, 8.5e-94], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.0], N[(x / N[(y / x), $MachinePrecision]), $MachinePrecision], N[(x / y), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.9 \cdot 10^{+150}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq -9.2 \cdot 10^{+78}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq -4.5 \cdot 10^{+51}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq 8.5 \cdot 10^{-94}:\\
\;\;\;\;\frac{x}{x + 1}\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\frac{x}{\frac{y}{x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -2.90000000000000011e150 or -9.2000000000000008e78 < x < -4.5e51 or 1 < x Initial program 67.6%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around inf 75.2%
if -2.90000000000000011e150 < x < -9.2000000000000008e78Initial program 89.1%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around inf 63.3%
Taylor expanded in x around inf 63.4%
if -4.5e51 < x < 8.50000000000000003e-94Initial program 100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in y around inf 82.4%
if 8.50000000000000003e-94 < x < 1Initial program 99.8%
associate-/l*99.7%
Simplified99.7%
Taylor expanded in y around 0 64.2%
Taylor expanded in x around 0 63.1%
clear-num63.0%
un-div-inv63.1%
Applied egg-rr63.1%
Final simplification75.8%
(FPCore (x y)
:precision binary64
(if (<= x -2.9e+150)
(/ x y)
(if (<= x -1.02e+79)
1.0
(if (<= x -3.7e+52)
(/ x y)
(if (<= x 8.5e-94)
(/ x (+ x 1.0))
(if (<= x 1.0) (* x (/ x y)) (/ x y)))))))
double code(double x, double y) {
double tmp;
if (x <= -2.9e+150) {
tmp = x / y;
} else if (x <= -1.02e+79) {
tmp = 1.0;
} else if (x <= -3.7e+52) {
tmp = x / y;
} else if (x <= 8.5e-94) {
tmp = x / (x + 1.0);
} 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 <= (-2.9d+150)) then
tmp = x / y
else if (x <= (-1.02d+79)) then
tmp = 1.0d0
else if (x <= (-3.7d+52)) then
tmp = x / y
else if (x <= 8.5d-94) then
tmp = x / (x + 1.0d0)
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 <= -2.9e+150) {
tmp = x / y;
} else if (x <= -1.02e+79) {
tmp = 1.0;
} else if (x <= -3.7e+52) {
tmp = x / y;
} else if (x <= 8.5e-94) {
tmp = x / (x + 1.0);
} else if (x <= 1.0) {
tmp = x * (x / y);
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -2.9e+150: tmp = x / y elif x <= -1.02e+79: tmp = 1.0 elif x <= -3.7e+52: tmp = x / y elif x <= 8.5e-94: tmp = x / (x + 1.0) elif x <= 1.0: tmp = x * (x / y) else: tmp = x / y return tmp
function code(x, y) tmp = 0.0 if (x <= -2.9e+150) tmp = Float64(x / y); elseif (x <= -1.02e+79) tmp = 1.0; elseif (x <= -3.7e+52) tmp = Float64(x / y); elseif (x <= 8.5e-94) tmp = Float64(x / Float64(x + 1.0)); 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 <= -2.9e+150) tmp = x / y; elseif (x <= -1.02e+79) tmp = 1.0; elseif (x <= -3.7e+52) tmp = x / y; elseif (x <= 8.5e-94) tmp = x / (x + 1.0); elseif (x <= 1.0) tmp = x * (x / y); else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -2.9e+150], N[(x / y), $MachinePrecision], If[LessEqual[x, -1.02e+79], 1.0, If[LessEqual[x, -3.7e+52], N[(x / y), $MachinePrecision], If[LessEqual[x, 8.5e-94], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], 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 -2.9 \cdot 10^{+150}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq -1.02 \cdot 10^{+79}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq -3.7 \cdot 10^{+52}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq 8.5 \cdot 10^{-94}:\\
\;\;\;\;\frac{x}{x + 1}\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;x \cdot \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -2.90000000000000011e150 or -1.02000000000000006e79 < x < -3.7e52 or 1 < x Initial program 67.6%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around inf 75.2%
if -2.90000000000000011e150 < x < -1.02000000000000006e79Initial program 89.1%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around inf 63.3%
Taylor expanded in x around inf 63.4%
if -3.7e52 < x < 8.50000000000000003e-94Initial program 100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in y around inf 82.4%
if 8.50000000000000003e-94 < x < 1Initial program 99.8%
associate-/l*99.7%
Simplified99.7%
Taylor expanded in y around 0 64.2%
Taylor expanded in x around 0 63.1%
Final simplification75.8%
(FPCore (x y)
:precision binary64
(if (<= x -2.9e+150)
(/ x y)
(if (<= x -8.6e+78)
1.0
(if (<= x -1.0)
(/ x y)
(if (<= x 3.2e-94) x (if (<= x 1.0) (* x (/ x y)) (/ x y)))))))
double code(double x, double y) {
double tmp;
if (x <= -2.9e+150) {
tmp = x / y;
} else if (x <= -8.6e+78) {
tmp = 1.0;
} else if (x <= -1.0) {
tmp = x / y;
} else if (x <= 3.2e-94) {
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 <= (-2.9d+150)) then
tmp = x / y
else if (x <= (-8.6d+78)) then
tmp = 1.0d0
else if (x <= (-1.0d0)) then
tmp = x / y
else if (x <= 3.2d-94) 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 <= -2.9e+150) {
tmp = x / y;
} else if (x <= -8.6e+78) {
tmp = 1.0;
} else if (x <= -1.0) {
tmp = x / y;
} else if (x <= 3.2e-94) {
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 <= -2.9e+150: tmp = x / y elif x <= -8.6e+78: tmp = 1.0 elif x <= -1.0: tmp = x / y elif x <= 3.2e-94: 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 <= -2.9e+150) tmp = Float64(x / y); elseif (x <= -8.6e+78) tmp = 1.0; elseif (x <= -1.0) tmp = Float64(x / y); elseif (x <= 3.2e-94) 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 <= -2.9e+150) tmp = x / y; elseif (x <= -8.6e+78) tmp = 1.0; elseif (x <= -1.0) tmp = x / y; elseif (x <= 3.2e-94) 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, -2.9e+150], N[(x / y), $MachinePrecision], If[LessEqual[x, -8.6e+78], 1.0, If[LessEqual[x, -1.0], N[(x / y), $MachinePrecision], If[LessEqual[x, 3.2e-94], 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 -2.9 \cdot 10^{+150}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq -8.6 \cdot 10^{+78}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq -1:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq 3.2 \cdot 10^{-94}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;x \cdot \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -2.90000000000000011e150 or -8.59999999999999962e78 < x < -1 or 1 < x Initial program 69.4%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around inf 73.2%
if -2.90000000000000011e150 < x < -8.59999999999999962e78Initial program 89.1%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around inf 63.3%
Taylor expanded in x around inf 63.4%
if -1 < x < 3.19999999999999997e-94Initial program 100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around 0 83.5%
if 3.19999999999999997e-94 < x < 1Initial program 99.8%
associate-/l*99.7%
Simplified99.7%
Taylor expanded in y around 0 64.2%
Taylor expanded in x around 0 63.1%
(FPCore (x y)
:precision binary64
(if (<= x -3e+150)
(/ x y)
(if (<= x -1.02e+79)
1.0
(if (<= x -4.6e+51)
(/ x y)
(if (<= x 8.5e-94) (/ x (+ x 1.0)) (/ x (* (+ x 1.0) (/ y x))))))))
double code(double x, double y) {
double tmp;
if (x <= -3e+150) {
tmp = x / y;
} else if (x <= -1.02e+79) {
tmp = 1.0;
} else if (x <= -4.6e+51) {
tmp = x / y;
} else if (x <= 8.5e-94) {
tmp = x / (x + 1.0);
} else {
tmp = x / ((x + 1.0) * (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 <= (-3d+150)) then
tmp = x / y
else if (x <= (-1.02d+79)) then
tmp = 1.0d0
else if (x <= (-4.6d+51)) then
tmp = x / y
else if (x <= 8.5d-94) then
tmp = x / (x + 1.0d0)
else
tmp = x / ((x + 1.0d0) * (y / x))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -3e+150) {
tmp = x / y;
} else if (x <= -1.02e+79) {
tmp = 1.0;
} else if (x <= -4.6e+51) {
tmp = x / y;
} else if (x <= 8.5e-94) {
tmp = x / (x + 1.0);
} else {
tmp = x / ((x + 1.0) * (y / x));
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -3e+150: tmp = x / y elif x <= -1.02e+79: tmp = 1.0 elif x <= -4.6e+51: tmp = x / y elif x <= 8.5e-94: tmp = x / (x + 1.0) else: tmp = x / ((x + 1.0) * (y / x)) return tmp
function code(x, y) tmp = 0.0 if (x <= -3e+150) tmp = Float64(x / y); elseif (x <= -1.02e+79) tmp = 1.0; elseif (x <= -4.6e+51) tmp = Float64(x / y); elseif (x <= 8.5e-94) tmp = Float64(x / Float64(x + 1.0)); else tmp = Float64(x / Float64(Float64(x + 1.0) * Float64(y / x))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -3e+150) tmp = x / y; elseif (x <= -1.02e+79) tmp = 1.0; elseif (x <= -4.6e+51) tmp = x / y; elseif (x <= 8.5e-94) tmp = x / (x + 1.0); else tmp = x / ((x + 1.0) * (y / x)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -3e+150], N[(x / y), $MachinePrecision], If[LessEqual[x, -1.02e+79], 1.0, If[LessEqual[x, -4.6e+51], N[(x / y), $MachinePrecision], If[LessEqual[x, 8.5e-94], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], N[(x / N[(N[(x + 1.0), $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3 \cdot 10^{+150}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq -1.02 \cdot 10^{+79}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq -4.6 \cdot 10^{+51}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq 8.5 \cdot 10^{-94}:\\
\;\;\;\;\frac{x}{x + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\left(x + 1\right) \cdot \frac{y}{x}}\\
\end{array}
\end{array}
if x < -3.00000000000000012e150 or -1.02000000000000006e79 < x < -4.6000000000000001e51Initial program 71.1%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around inf 78.8%
if -3.00000000000000012e150 < x < -1.02000000000000006e79Initial program 89.1%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around inf 63.3%
Taylor expanded in x around inf 63.4%
if -4.6000000000000001e51 < x < 8.50000000000000003e-94Initial program 100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in y around inf 82.4%
if 8.50000000000000003e-94 < x Initial program 74.9%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around 0 56.3%
clear-num56.3%
un-div-inv56.4%
+-commutative56.4%
*-commutative56.4%
associate-/l*71.6%
Applied egg-rr71.6%
Final simplification76.4%
(FPCore (x y) :precision binary64 (if (<= x -2.9e+150) (/ x y) (if (<= x -8e+78) 1.0 (if (or (<= x -1.0) (not (<= x 6.2))) (/ x y) x))))
double code(double x, double y) {
double tmp;
if (x <= -2.9e+150) {
tmp = x / y;
} else if (x <= -8e+78) {
tmp = 1.0;
} else if ((x <= -1.0) || !(x <= 6.2)) {
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 <= (-2.9d+150)) then
tmp = x / y
else if (x <= (-8d+78)) then
tmp = 1.0d0
else if ((x <= (-1.0d0)) .or. (.not. (x <= 6.2d0))) 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 <= -2.9e+150) {
tmp = x / y;
} else if (x <= -8e+78) {
tmp = 1.0;
} else if ((x <= -1.0) || !(x <= 6.2)) {
tmp = x / y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -2.9e+150: tmp = x / y elif x <= -8e+78: tmp = 1.0 elif (x <= -1.0) or not (x <= 6.2): tmp = x / y else: tmp = x return tmp
function code(x, y) tmp = 0.0 if (x <= -2.9e+150) tmp = Float64(x / y); elseif (x <= -8e+78) tmp = 1.0; elseif ((x <= -1.0) || !(x <= 6.2)) tmp = Float64(x / y); else tmp = x; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -2.9e+150) tmp = x / y; elseif (x <= -8e+78) tmp = 1.0; elseif ((x <= -1.0) || ~((x <= 6.2))) tmp = x / y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -2.9e+150], N[(x / y), $MachinePrecision], If[LessEqual[x, -8e+78], 1.0, If[Or[LessEqual[x, -1.0], N[Not[LessEqual[x, 6.2]], $MachinePrecision]], N[(x / y), $MachinePrecision], x]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.9 \cdot 10^{+150}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq -8 \cdot 10^{+78}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq -1 \lor \neg \left(x \leq 6.2\right):\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -2.90000000000000011e150 or -8.00000000000000007e78 < x < -1 or 6.20000000000000018 < x Initial program 69.4%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around inf 73.2%
if -2.90000000000000011e150 < x < -8.00000000000000007e78Initial program 89.1%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around inf 63.3%
Taylor expanded in x around inf 63.4%
if -1 < x < 6.20000000000000018Initial program 99.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around 0 72.4%
Final simplification72.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 71.8%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around inf 30.1%
Taylor expanded in x around inf 29.4%
if -1 < x < 1Initial program 99.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around 0 72.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 84.4%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around inf 49.7%
Taylor expanded in x around inf 18.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 2024100
(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)))