
(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 11 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 87.5%
associate-/l*99.9%
Simplified99.9%
clear-num99.7%
un-div-inv99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (+ x y) y)))
(if (<= x -650.0)
t_0
(if (<= x 2.15e-97)
(/ x (+ x 1.0))
(if (<= x 13200000000000.0) (/ (/ x (/ y x)) (+ x 1.0)) t_0)))))
double code(double x, double y) {
double t_0 = (x + y) / y;
double tmp;
if (x <= -650.0) {
tmp = t_0;
} else if (x <= 2.15e-97) {
tmp = x / (x + 1.0);
} else if (x <= 13200000000000.0) {
tmp = (x / (y / x)) / (x + 1.0);
} 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 <= (-650.0d0)) then
tmp = t_0
else if (x <= 2.15d-97) then
tmp = x / (x + 1.0d0)
else if (x <= 13200000000000.0d0) then
tmp = (x / (y / x)) / (x + 1.0d0)
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 <= -650.0) {
tmp = t_0;
} else if (x <= 2.15e-97) {
tmp = x / (x + 1.0);
} else if (x <= 13200000000000.0) {
tmp = (x / (y / x)) / (x + 1.0);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = (x + y) / y tmp = 0 if x <= -650.0: tmp = t_0 elif x <= 2.15e-97: tmp = x / (x + 1.0) elif x <= 13200000000000.0: tmp = (x / (y / x)) / (x + 1.0) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(Float64(x + y) / y) tmp = 0.0 if (x <= -650.0) tmp = t_0; elseif (x <= 2.15e-97) tmp = Float64(x / Float64(x + 1.0)); elseif (x <= 13200000000000.0) tmp = Float64(Float64(x / Float64(y / x)) / Float64(x + 1.0)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = (x + y) / y; tmp = 0.0; if (x <= -650.0) tmp = t_0; elseif (x <= 2.15e-97) tmp = x / (x + 1.0); elseif (x <= 13200000000000.0) tmp = (x / (y / x)) / (x + 1.0); 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, -650.0], t$95$0, If[LessEqual[x, 2.15e-97], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 13200000000000.0], N[(N[(x / N[(y / x), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x + y}{y}\\
\mathbf{if}\;x \leq -650:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 2.15 \cdot 10^{-97}:\\
\;\;\;\;\frac{x}{x + 1}\\
\mathbf{elif}\;x \leq 13200000000000:\\
\;\;\;\;\frac{\frac{x}{\frac{y}{x}}}{x + 1}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -650 or 1.32e13 < x Initial program 72.8%
associate-/l*99.9%
Simplified99.9%
clear-num99.8%
un-div-inv100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 99.4%
Taylor expanded in y around 0 99.4%
+-commutative99.4%
Simplified99.4%
if -650 < x < 2.15e-97Initial program 99.9%
Taylor expanded in y around inf 80.1%
if 2.15e-97 < x < 1.32e13Initial program 99.7%
Taylor expanded in x around inf 65.5%
clear-num65.3%
un-div-inv65.5%
Applied egg-rr65.5%
Final simplification87.3%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (+ x y) y)))
(if (<= x -920.0)
t_0
(if (<= x 3.1e-96)
(/ x (+ x 1.0))
(if (<= x 13200000000000.0) (/ (* x (/ x y)) (+ x 1.0)) t_0)))))
double code(double x, double y) {
double t_0 = (x + y) / y;
double tmp;
if (x <= -920.0) {
tmp = t_0;
} else if (x <= 3.1e-96) {
tmp = x / (x + 1.0);
} else if (x <= 13200000000000.0) {
tmp = (x * (x / y)) / (x + 1.0);
} 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 <= (-920.0d0)) then
tmp = t_0
else if (x <= 3.1d-96) then
tmp = x / (x + 1.0d0)
else if (x <= 13200000000000.0d0) then
tmp = (x * (x / y)) / (x + 1.0d0)
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 <= -920.0) {
tmp = t_0;
} else if (x <= 3.1e-96) {
tmp = x / (x + 1.0);
} else if (x <= 13200000000000.0) {
tmp = (x * (x / y)) / (x + 1.0);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = (x + y) / y tmp = 0 if x <= -920.0: tmp = t_0 elif x <= 3.1e-96: tmp = x / (x + 1.0) elif x <= 13200000000000.0: tmp = (x * (x / y)) / (x + 1.0) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(Float64(x + y) / y) tmp = 0.0 if (x <= -920.0) tmp = t_0; elseif (x <= 3.1e-96) tmp = Float64(x / Float64(x + 1.0)); elseif (x <= 13200000000000.0) tmp = Float64(Float64(x * Float64(x / y)) / Float64(x + 1.0)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = (x + y) / y; tmp = 0.0; if (x <= -920.0) tmp = t_0; elseif (x <= 3.1e-96) tmp = x / (x + 1.0); elseif (x <= 13200000000000.0) tmp = (x * (x / y)) / (x + 1.0); 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, -920.0], t$95$0, If[LessEqual[x, 3.1e-96], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 13200000000000.0], N[(N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x + y}{y}\\
\mathbf{if}\;x \leq -920:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 3.1 \cdot 10^{-96}:\\
\;\;\;\;\frac{x}{x + 1}\\
\mathbf{elif}\;x \leq 13200000000000:\\
\;\;\;\;\frac{x \cdot \frac{x}{y}}{x + 1}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -920 or 1.32e13 < x Initial program 72.8%
associate-/l*99.9%
Simplified99.9%
clear-num99.8%
un-div-inv100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 99.4%
Taylor expanded in y around 0 99.4%
+-commutative99.4%
Simplified99.4%
if -920 < x < 3.0999999999999999e-96Initial program 99.9%
Taylor expanded in y around inf 80.1%
if 3.0999999999999999e-96 < x < 1.32e13Initial program 99.7%
Taylor expanded in x around inf 65.5%
Final simplification87.3%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (+ x y) y)))
(if (<= x -180.0)
t_0
(if (<= x 2e-96)
(/ x (+ x 1.0))
(if (<= x 13200000000000.0) (/ x (* y (+ 1.0 (/ 1.0 x)))) t_0)))))
double code(double x, double y) {
double t_0 = (x + y) / y;
double tmp;
if (x <= -180.0) {
tmp = t_0;
} else if (x <= 2e-96) {
tmp = x / (x + 1.0);
} else if (x <= 13200000000000.0) {
tmp = x / (y * (1.0 + (1.0 / 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 <= (-180.0d0)) then
tmp = t_0
else if (x <= 2d-96) then
tmp = x / (x + 1.0d0)
else if (x <= 13200000000000.0d0) then
tmp = x / (y * (1.0d0 + (1.0d0 / 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 <= -180.0) {
tmp = t_0;
} else if (x <= 2e-96) {
tmp = x / (x + 1.0);
} else if (x <= 13200000000000.0) {
tmp = x / (y * (1.0 + (1.0 / x)));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = (x + y) / y tmp = 0 if x <= -180.0: tmp = t_0 elif x <= 2e-96: tmp = x / (x + 1.0) elif x <= 13200000000000.0: tmp = x / (y * (1.0 + (1.0 / x))) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(Float64(x + y) / y) tmp = 0.0 if (x <= -180.0) tmp = t_0; elseif (x <= 2e-96) tmp = Float64(x / Float64(x + 1.0)); elseif (x <= 13200000000000.0) tmp = Float64(x / Float64(y * Float64(1.0 + Float64(1.0 / 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 <= -180.0) tmp = t_0; elseif (x <= 2e-96) tmp = x / (x + 1.0); elseif (x <= 13200000000000.0) tmp = x / (y * (1.0 + (1.0 / 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, -180.0], t$95$0, If[LessEqual[x, 2e-96], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 13200000000000.0], N[(x / N[(y * N[(1.0 + N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x + y}{y}\\
\mathbf{if}\;x \leq -180:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 2 \cdot 10^{-96}:\\
\;\;\;\;\frac{x}{x + 1}\\
\mathbf{elif}\;x \leq 13200000000000:\\
\;\;\;\;\frac{x}{y \cdot \left(1 + \frac{1}{x}\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -180 or 1.32e13 < x Initial program 72.8%
associate-/l*99.9%
Simplified99.9%
clear-num99.8%
un-div-inv100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 99.4%
Taylor expanded in y around 0 99.4%
+-commutative99.4%
Simplified99.4%
if -180 < x < 1.9999999999999998e-96Initial program 99.9%
Taylor expanded in y around inf 80.1%
if 1.9999999999999998e-96 < x < 1.32e13Initial program 99.7%
associate-/l*99.6%
Simplified99.6%
Taylor expanded in y around 0 99.6%
clear-num99.4%
un-div-inv99.7%
div-inv99.6%
div-inv99.6%
distribute-rgt-out99.6%
+-commutative99.6%
Applied egg-rr99.6%
Taylor expanded in y around 0 65.5%
associate-/l*65.4%
*-lft-identity65.4%
associate-*l/65.4%
+-commutative65.4%
distribute-rgt-in65.4%
rgt-mult-inverse65.4%
*-lft-identity65.4%
Simplified65.4%
Final simplification87.3%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (+ x y) y)) (t_1 (/ x (+ x 1.0))))
(if (<= x -60.0)
t_0
(if (<= x 1.7e-100)
t_1
(if (<= x 13200000000000.0) (* x (/ t_1 y)) t_0)))))
double code(double x, double y) {
double t_0 = (x + y) / y;
double t_1 = x / (x + 1.0);
double tmp;
if (x <= -60.0) {
tmp = t_0;
} else if (x <= 1.7e-100) {
tmp = t_1;
} else if (x <= 13200000000000.0) {
tmp = x * (t_1 / y);
} 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 = (x + y) / y
t_1 = x / (x + 1.0d0)
if (x <= (-60.0d0)) then
tmp = t_0
else if (x <= 1.7d-100) then
tmp = t_1
else if (x <= 13200000000000.0d0) then
tmp = x * (t_1 / y)
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 t_1 = x / (x + 1.0);
double tmp;
if (x <= -60.0) {
tmp = t_0;
} else if (x <= 1.7e-100) {
tmp = t_1;
} else if (x <= 13200000000000.0) {
tmp = x * (t_1 / y);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = (x + y) / y t_1 = x / (x + 1.0) tmp = 0 if x <= -60.0: tmp = t_0 elif x <= 1.7e-100: tmp = t_1 elif x <= 13200000000000.0: tmp = x * (t_1 / y) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(Float64(x + y) / y) t_1 = Float64(x / Float64(x + 1.0)) tmp = 0.0 if (x <= -60.0) tmp = t_0; elseif (x <= 1.7e-100) tmp = t_1; elseif (x <= 13200000000000.0) tmp = Float64(x * Float64(t_1 / y)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = (x + y) / y; t_1 = x / (x + 1.0); tmp = 0.0; if (x <= -60.0) tmp = t_0; elseif (x <= 1.7e-100) tmp = t_1; elseif (x <= 13200000000000.0) tmp = x * (t_1 / y); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(x + y), $MachinePrecision] / y), $MachinePrecision]}, Block[{t$95$1 = N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -60.0], t$95$0, If[LessEqual[x, 1.7e-100], t$95$1, If[LessEqual[x, 13200000000000.0], N[(x * N[(t$95$1 / y), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x + y}{y}\\
t_1 := \frac{x}{x + 1}\\
\mathbf{if}\;x \leq -60:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.7 \cdot 10^{-100}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 13200000000000:\\
\;\;\;\;x \cdot \frac{t\_1}{y}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -60 or 1.32e13 < x Initial program 72.8%
associate-/l*99.9%
Simplified99.9%
clear-num99.8%
un-div-inv100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 99.4%
Taylor expanded in y around 0 99.4%
+-commutative99.4%
Simplified99.4%
if -60 < x < 1.69999999999999988e-100Initial program 99.9%
Taylor expanded in y around inf 80.1%
if 1.69999999999999988e-100 < x < 1.32e13Initial program 99.7%
associate-/l*99.6%
Simplified99.6%
Taylor expanded in y around 0 99.6%
Taylor expanded in y around 0 65.4%
Final simplification87.3%
(FPCore (x y) :precision binary64 (if (or (<= x -1.0) (not (<= x 0.85))) (/ (+ x y) y) (* x (+ 1.0 (* x (+ (/ 1.0 y) -1.0))))))
double code(double x, double y) {
double tmp;
if ((x <= -1.0) || !(x <= 0.85)) {
tmp = (x + y) / y;
} else {
tmp = x * (1.0 + (x * ((1.0 / y) + -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)) .or. (.not. (x <= 0.85d0))) then
tmp = (x + y) / y
else
tmp = x * (1.0d0 + (x * ((1.0d0 / y) + (-1.0d0))))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -1.0) || !(x <= 0.85)) {
tmp = (x + y) / y;
} else {
tmp = x * (1.0 + (x * ((1.0 / y) + -1.0)));
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -1.0) or not (x <= 0.85): tmp = (x + y) / y else: tmp = x * (1.0 + (x * ((1.0 / y) + -1.0))) return tmp
function code(x, y) tmp = 0.0 if ((x <= -1.0) || !(x <= 0.85)) tmp = Float64(Float64(x + y) / y); else tmp = Float64(x * Float64(1.0 + Float64(x * Float64(Float64(1.0 / y) + -1.0)))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -1.0) || ~((x <= 0.85))) tmp = (x + y) / y; else tmp = x * (1.0 + (x * ((1.0 / y) + -1.0))); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -1.0], N[Not[LessEqual[x, 0.85]], $MachinePrecision]], N[(N[(x + y), $MachinePrecision] / y), $MachinePrecision], N[(x * N[(1.0 + N[(x * N[(N[(1.0 / y), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 0.85\right):\\
\;\;\;\;\frac{x + y}{y}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 + x \cdot \left(\frac{1}{y} + -1\right)\right)\\
\end{array}
\end{array}
if x < -1 or 0.849999999999999978 < x Initial program 73.7%
associate-/l*99.9%
Simplified99.9%
clear-num99.8%
un-div-inv100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 97.8%
Taylor expanded in y around 0 97.8%
+-commutative97.8%
Simplified97.8%
if -1 < x < 0.849999999999999978Initial program 99.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around 0 98.3%
Final simplification98.1%
(FPCore (x y) :precision binary64 (if (or (<= x -1020.0) (not (<= x 85.0))) (/ (+ x y) y) (/ x (+ x 1.0))))
double code(double x, double y) {
double tmp;
if ((x <= -1020.0) || !(x <= 85.0)) {
tmp = (x + y) / y;
} else {
tmp = x / (x + 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 <= (-1020.0d0)) .or. (.not. (x <= 85.0d0))) then
tmp = (x + y) / y
else
tmp = x / (x + 1.0d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -1020.0) || !(x <= 85.0)) {
tmp = (x + y) / y;
} else {
tmp = x / (x + 1.0);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -1020.0) or not (x <= 85.0): tmp = (x + y) / y else: tmp = x / (x + 1.0) return tmp
function code(x, y) tmp = 0.0 if ((x <= -1020.0) || !(x <= 85.0)) tmp = Float64(Float64(x + y) / y); else tmp = Float64(x / Float64(x + 1.0)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -1020.0) || ~((x <= 85.0))) tmp = (x + y) / y; else tmp = x / (x + 1.0); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -1020.0], N[Not[LessEqual[x, 85.0]], $MachinePrecision]], N[(N[(x + y), $MachinePrecision] / y), $MachinePrecision], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1020 \lor \neg \left(x \leq 85\right):\\
\;\;\;\;\frac{x + y}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{x + 1}\\
\end{array}
\end{array}
if x < -1020 or 85 < x Initial program 73.7%
associate-/l*99.9%
Simplified99.9%
clear-num99.8%
un-div-inv100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 97.8%
Taylor expanded in y around 0 97.8%
+-commutative97.8%
Simplified97.8%
if -1020 < x < 85Initial program 99.9%
Taylor expanded in y around inf 73.5%
Final simplification85.0%
(FPCore (x y) :precision binary64 (if (or (<= x -1080.0) (not (<= x 5.5e+116))) (/ x y) (/ x (+ x 1.0))))
double code(double x, double y) {
double tmp;
if ((x <= -1080.0) || !(x <= 5.5e+116)) {
tmp = x / y;
} else {
tmp = x / (x + 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 <= (-1080.0d0)) .or. (.not. (x <= 5.5d+116))) then
tmp = x / y
else
tmp = x / (x + 1.0d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -1080.0) || !(x <= 5.5e+116)) {
tmp = x / y;
} else {
tmp = x / (x + 1.0);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -1080.0) or not (x <= 5.5e+116): tmp = x / y else: tmp = x / (x + 1.0) return tmp
function code(x, y) tmp = 0.0 if ((x <= -1080.0) || !(x <= 5.5e+116)) tmp = Float64(x / y); else tmp = Float64(x / Float64(x + 1.0)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -1080.0) || ~((x <= 5.5e+116))) tmp = x / y; else tmp = x / (x + 1.0); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -1080.0], N[Not[LessEqual[x, 5.5e+116]], $MachinePrecision]], N[(x / y), $MachinePrecision], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1080 \lor \neg \left(x \leq 5.5 \cdot 10^{+116}\right):\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{x + 1}\\
\end{array}
\end{array}
if x < -1080 or 5.50000000000000035e116 < x Initial program 68.5%
associate-/l*99.9%
Simplified99.9%
clear-num99.8%
un-div-inv100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 86.9%
if -1080 < x < 5.50000000000000035e116Initial program 99.9%
Taylor expanded in y around inf 71.3%
Final simplification77.5%
(FPCore (x y) :precision binary64 (if (or (<= x -1.0) (not (<= x 2.8))) (/ x y) x))
double code(double x, double y) {
double tmp;
if ((x <= -1.0) || !(x <= 2.8)) {
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 <= 2.8d0))) 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 <= 2.8)) {
tmp = x / y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -1.0) or not (x <= 2.8): tmp = x / y else: tmp = x return tmp
function code(x, y) tmp = 0.0 if ((x <= -1.0) || !(x <= 2.8)) 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 <= 2.8))) tmp = x / y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -1.0], N[Not[LessEqual[x, 2.8]], $MachinePrecision]], N[(x / y), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 2.8\right):\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -1 or 2.7999999999999998 < x Initial program 73.7%
associate-/l*99.9%
Simplified99.9%
clear-num99.8%
un-div-inv100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 78.7%
if -1 < x < 2.7999999999999998Initial program 99.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around 0 71.9%
Taylor expanded in x around 0 71.9%
Final simplification75.1%
(FPCore (x y) :precision binary64 (* x (/ (+ 1.0 (/ x y)) (+ x 1.0))))
double code(double x, double y) {
return x * ((1.0 + (x / y)) / (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)) / (x + 1.0d0))
end function
public static double code(double x, double y) {
return x * ((1.0 + (x / y)) / (x + 1.0));
}
def code(x, y): return x * ((1.0 + (x / y)) / (x + 1.0))
function code(x, y) return Float64(x * Float64(Float64(1.0 + Float64(x / y)) / Float64(x + 1.0))) end
function tmp = code(x, y) tmp = x * ((1.0 + (x / y)) / (x + 1.0)); end
code[x_, y_] := N[(x * N[(N[(1.0 + N[(x / y), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \frac{1 + \frac{x}{y}}{x + 1}
\end{array}
Initial program 87.5%
associate-/l*99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y) :precision binary64 x)
double code(double x, double y) {
return x;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x
end function
public static double code(double x, double y) {
return x;
}
def code(x, y): return x
function code(x, y) return x end
function tmp = code(x, y) tmp = x; end
code[x_, y_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 87.5%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around 0 39.9%
Taylor expanded in x around 0 39.9%
(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 2024139
(FPCore (x y)
:name "Codec.Picture.Types:toneMapping from JuicyPixels-3.2.6.1"
:precision binary64
:alt
(! :herbie-platform default (* (/ x 1) (/ (+ (/ x y) 1) (+ x 1))))
(/ (* x (+ (/ x y) 1.0)) (+ x 1.0)))