
(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.9%
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f6499.8%
Simplified99.8%
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f6499.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ 1.0 (/ x y))))
(if (<= x -1.0)
t_0
(if (<= x -3.1e-63) (* x (/ x y)) (if (<= x 0.0003) x t_0)))))
double code(double x, double y) {
double t_0 = 1.0 + (x / y);
double tmp;
if (x <= -1.0) {
tmp = t_0;
} else if (x <= -3.1e-63) {
tmp = x * (x / y);
} else if (x <= 0.0003) {
tmp = 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 = 1.0d0 + (x / y)
if (x <= (-1.0d0)) then
tmp = t_0
else if (x <= (-3.1d-63)) then
tmp = x * (x / y)
else if (x <= 0.0003d0) then
tmp = x
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = 1.0 + (x / y);
double tmp;
if (x <= -1.0) {
tmp = t_0;
} else if (x <= -3.1e-63) {
tmp = x * (x / y);
} else if (x <= 0.0003) {
tmp = x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 + (x / y) tmp = 0 if x <= -1.0: tmp = t_0 elif x <= -3.1e-63: tmp = x * (x / y) elif x <= 0.0003: tmp = x else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(1.0 + Float64(x / y)) tmp = 0.0 if (x <= -1.0) tmp = t_0; elseif (x <= -3.1e-63) tmp = Float64(x * Float64(x / y)); elseif (x <= 0.0003) tmp = x; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 + (x / y); tmp = 0.0; if (x <= -1.0) tmp = t_0; elseif (x <= -3.1e-63) tmp = x * (x / y); elseif (x <= 0.0003) tmp = x; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(1.0 + N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.0], t$95$0, If[LessEqual[x, -3.1e-63], N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.0003], x, t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{x}{y}\\
\mathbf{if}\;x \leq -1:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -3.1 \cdot 10^{-63}:\\
\;\;\;\;x \cdot \frac{x}{y}\\
\mathbf{elif}\;x \leq 0.0003:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1 or 2.99999999999999974e-4 < x Initial program 76.5%
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f6499.8%
Simplified99.8%
Taylor expanded in x around inf
sub-negN/A
distribute-lft-inN/A
distribute-rgt-inN/A
lft-mult-inverseN/A
associate-*l/N/A
*-lft-identityN/A
+-commutativeN/A
associate-+l+N/A
distribute-rgt-neg-outN/A
associate-/r*N/A
associate-*r/N/A
rgt-mult-inverseN/A
+-commutativeN/A
neg-sub0N/A
associate-+l-N/A
neg-sub0N/A
mul-1-negN/A
+-lowering-+.f64N/A
Simplified97.2%
Taylor expanded in y around inf
Simplified96.5%
if -1 < x < -3.09999999999999984e-63Initial program 99.7%
Taylor expanded in x around 0
Simplified76.0%
/-rgt-identityN/A
+-commutativeN/A
*-lft-identityN/A
*-commutativeN/A
*-lowering-*.f64N/A
*-lft-identityN/A
+-lowering-+.f64N/A
/-lowering-/.f6476.0%
Applied egg-rr76.0%
Taylor expanded in x around inf
/-lowering-/.f6459.2%
Simplified59.2%
if -3.09999999999999984e-63 < x < 2.99999999999999974e-4Initial program 99.9%
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f6499.9%
Simplified99.9%
Taylor expanded in x around 0
Simplified82.3%
Final simplification88.3%
(FPCore (x y) :precision binary64 (let* ((t_0 (+ (/ x y) (+ 1.0 (/ -1.0 y))))) (if (<= x -1.0) t_0 (if (<= x 1.26) (* x (+ 1.0 (/ x y))) t_0))))
double code(double x, double y) {
double t_0 = (x / y) + (1.0 + (-1.0 / y));
double tmp;
if (x <= -1.0) {
tmp = t_0;
} else if (x <= 1.26) {
tmp = x * (1.0 + (x / 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) :: tmp
t_0 = (x / y) + (1.0d0 + ((-1.0d0) / y))
if (x <= (-1.0d0)) then
tmp = t_0
else if (x <= 1.26d0) then
tmp = x * (1.0d0 + (x / y))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = (x / y) + (1.0 + (-1.0 / y));
double tmp;
if (x <= -1.0) {
tmp = t_0;
} else if (x <= 1.26) {
tmp = x * (1.0 + (x / y));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = (x / y) + (1.0 + (-1.0 / y)) tmp = 0 if x <= -1.0: tmp = t_0 elif x <= 1.26: tmp = x * (1.0 + (x / y)) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(Float64(x / y) + Float64(1.0 + Float64(-1.0 / y))) tmp = 0.0 if (x <= -1.0) tmp = t_0; elseif (x <= 1.26) tmp = Float64(x * Float64(1.0 + Float64(x / y))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = (x / y) + (1.0 + (-1.0 / y)); tmp = 0.0; if (x <= -1.0) tmp = t_0; elseif (x <= 1.26) tmp = x * (1.0 + (x / y)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(x / y), $MachinePrecision] + N[(1.0 + N[(-1.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.0], t$95$0, If[LessEqual[x, 1.26], N[(x * N[(1.0 + N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{y} + \left(1 + \frac{-1}{y}\right)\\
\mathbf{if}\;x \leq -1:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.26:\\
\;\;\;\;x \cdot \left(1 + \frac{x}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1 or 1.26000000000000001 < x Initial program 76.5%
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f6499.8%
Simplified99.8%
Taylor expanded in x around inf
sub-negN/A
distribute-lft-inN/A
distribute-rgt-inN/A
lft-mult-inverseN/A
associate-*l/N/A
*-lft-identityN/A
+-commutativeN/A
associate-+l+N/A
distribute-rgt-neg-outN/A
associate-/r*N/A
associate-*r/N/A
rgt-mult-inverseN/A
+-commutativeN/A
neg-sub0N/A
associate-+l-N/A
neg-sub0N/A
mul-1-negN/A
+-lowering-+.f64N/A
Simplified97.2%
if -1 < x < 1.26000000000000001Initial program 99.8%
Taylor expanded in x around 0
Simplified96.8%
/-rgt-identityN/A
+-commutativeN/A
*-lft-identityN/A
*-commutativeN/A
*-lowering-*.f64N/A
*-lft-identityN/A
+-lowering-+.f64N/A
/-lowering-/.f6496.8%
Applied egg-rr96.8%
Final simplification97.0%
(FPCore (x y) :precision binary64 (if (<= x -1.0) (/ x y) (if (<= x -4.3e-66) (* x (/ x y)) (if (<= x 0.0145) x (/ x y)))))
double code(double x, double y) {
double tmp;
if (x <= -1.0) {
tmp = x / y;
} else if (x <= -4.3e-66) {
tmp = x * (x / y);
} else if (x <= 0.0145) {
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.3d-66)) then
tmp = x * (x / y)
else if (x <= 0.0145d0) 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.3e-66) {
tmp = x * (x / y);
} else if (x <= 0.0145) {
tmp = x;
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.0: tmp = x / y elif x <= -4.3e-66: tmp = x * (x / y) elif x <= 0.0145: 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.3e-66) tmp = Float64(x * Float64(x / y)); elseif (x <= 0.0145) 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.3e-66) tmp = x * (x / y); elseif (x <= 0.0145) 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.3e-66], N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.0145], x, N[(x / y), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq -4.3 \cdot 10^{-66}:\\
\;\;\;\;x \cdot \frac{x}{y}\\
\mathbf{elif}\;x \leq 0.0145:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -1 or 0.0145000000000000007 < x Initial program 76.5%
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f6499.8%
Simplified99.8%
Taylor expanded in x around inf
/-lowering-/.f6470.7%
Simplified70.7%
if -1 < x < -4.30000000000000013e-66Initial program 99.7%
Taylor expanded in x around 0
Simplified76.0%
/-rgt-identityN/A
+-commutativeN/A
*-lft-identityN/A
*-commutativeN/A
*-lowering-*.f64N/A
*-lft-identityN/A
+-lowering-+.f64N/A
/-lowering-/.f6476.0%
Applied egg-rr76.0%
Taylor expanded in x around inf
/-lowering-/.f6459.2%
Simplified59.2%
if -4.30000000000000013e-66 < x < 0.0145000000000000007Initial program 99.9%
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f6499.9%
Simplified99.9%
Taylor expanded in x around 0
Simplified82.3%
Final simplification75.1%
(FPCore (x y) :precision binary64 (let* ((t_0 (+ 1.0 (/ x y)))) (if (<= x -1.0) t_0 (if (<= x 1.0) (* x t_0) t_0))))
double code(double x, double y) {
double t_0 = 1.0 + (x / y);
double tmp;
if (x <= -1.0) {
tmp = t_0;
} else if (x <= 1.0) {
tmp = x * t_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 = 1.0d0 + (x / y)
if (x <= (-1.0d0)) then
tmp = t_0
else if (x <= 1.0d0) then
tmp = x * t_0
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = 1.0 + (x / y);
double tmp;
if (x <= -1.0) {
tmp = t_0;
} else if (x <= 1.0) {
tmp = x * t_0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 + (x / y) tmp = 0 if x <= -1.0: tmp = t_0 elif x <= 1.0: tmp = x * t_0 else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(1.0 + Float64(x / y)) tmp = 0.0 if (x <= -1.0) tmp = t_0; elseif (x <= 1.0) tmp = Float64(x * t_0); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 + (x / y); tmp = 0.0; if (x <= -1.0) tmp = t_0; elseif (x <= 1.0) tmp = x * t_0; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(1.0 + N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.0], t$95$0, If[LessEqual[x, 1.0], N[(x * t$95$0), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{x}{y}\\
\mathbf{if}\;x \leq -1:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;x \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1 or 1 < x Initial program 76.5%
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f6499.8%
Simplified99.8%
Taylor expanded in x around inf
sub-negN/A
distribute-lft-inN/A
distribute-rgt-inN/A
lft-mult-inverseN/A
associate-*l/N/A
*-lft-identityN/A
+-commutativeN/A
associate-+l+N/A
distribute-rgt-neg-outN/A
associate-/r*N/A
associate-*r/N/A
rgt-mult-inverseN/A
+-commutativeN/A
neg-sub0N/A
associate-+l-N/A
neg-sub0N/A
mul-1-negN/A
+-lowering-+.f64N/A
Simplified97.2%
Taylor expanded in y around inf
Simplified96.5%
if -1 < x < 1Initial program 99.8%
Taylor expanded in x around 0
Simplified96.8%
/-rgt-identityN/A
+-commutativeN/A
*-lft-identityN/A
*-commutativeN/A
*-lowering-*.f64N/A
*-lft-identityN/A
+-lowering-+.f64N/A
/-lowering-/.f6496.8%
Applied egg-rr96.8%
Final simplification96.6%
(FPCore (x y) :precision binary64 (let* ((t_0 (+ 1.0 (/ x y)))) (if (<= x -31.0) t_0 (if (<= x 12000.0) (* x (/ 1.0 (+ x 1.0))) t_0))))
double code(double x, double y) {
double t_0 = 1.0 + (x / y);
double tmp;
if (x <= -31.0) {
tmp = t_0;
} else if (x <= 12000.0) {
tmp = x * (1.0 / (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 = 1.0d0 + (x / y)
if (x <= (-31.0d0)) then
tmp = t_0
else if (x <= 12000.0d0) then
tmp = x * (1.0d0 / (x + 1.0d0))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = 1.0 + (x / y);
double tmp;
if (x <= -31.0) {
tmp = t_0;
} else if (x <= 12000.0) {
tmp = x * (1.0 / (x + 1.0));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 + (x / y) tmp = 0 if x <= -31.0: tmp = t_0 elif x <= 12000.0: tmp = x * (1.0 / (x + 1.0)) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(1.0 + Float64(x / y)) tmp = 0.0 if (x <= -31.0) tmp = t_0; elseif (x <= 12000.0) tmp = Float64(x * Float64(1.0 / Float64(x + 1.0))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 + (x / y); tmp = 0.0; if (x <= -31.0) tmp = t_0; elseif (x <= 12000.0) tmp = x * (1.0 / (x + 1.0)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(1.0 + N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -31.0], t$95$0, If[LessEqual[x, 12000.0], N[(x * N[(1.0 / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{x}{y}\\
\mathbf{if}\;x \leq -31:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 12000:\\
\;\;\;\;x \cdot \frac{1}{x + 1}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -31 or 12000 < x Initial program 76.0%
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f6499.8%
Simplified99.8%
Taylor expanded in x around inf
sub-negN/A
distribute-lft-inN/A
distribute-rgt-inN/A
lft-mult-inverseN/A
associate-*l/N/A
*-lft-identityN/A
+-commutativeN/A
associate-+l+N/A
distribute-rgt-neg-outN/A
associate-/r*N/A
associate-*r/N/A
rgt-mult-inverseN/A
+-commutativeN/A
neg-sub0N/A
associate-+l-N/A
neg-sub0N/A
mul-1-negN/A
+-lowering-+.f64N/A
Simplified98.6%
Taylor expanded in y around inf
Simplified98.0%
if -31 < x < 12000Initial program 99.8%
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f6499.8%
Simplified99.8%
Taylor expanded in y around inf
/-lowering-/.f64N/A
+-commutativeN/A
+-lowering-+.f6476.0%
Simplified76.0%
Final simplification87.0%
(FPCore (x y) :precision binary64 (let* ((t_0 (+ 1.0 (/ x y)))) (if (<= x -31.0) t_0 (if (<= x 11000.0) (/ x (+ x 1.0)) t_0))))
double code(double x, double y) {
double t_0 = 1.0 + (x / y);
double tmp;
if (x <= -31.0) {
tmp = t_0;
} else if (x <= 11000.0) {
tmp = 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 = 1.0d0 + (x / y)
if (x <= (-31.0d0)) then
tmp = t_0
else if (x <= 11000.0d0) then
tmp = 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 = 1.0 + (x / y);
double tmp;
if (x <= -31.0) {
tmp = t_0;
} else if (x <= 11000.0) {
tmp = x / (x + 1.0);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 + (x / y) tmp = 0 if x <= -31.0: tmp = t_0 elif x <= 11000.0: tmp = x / (x + 1.0) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(1.0 + Float64(x / y)) tmp = 0.0 if (x <= -31.0) tmp = t_0; elseif (x <= 11000.0) tmp = Float64(x / Float64(x + 1.0)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 + (x / y); tmp = 0.0; if (x <= -31.0) tmp = t_0; elseif (x <= 11000.0) tmp = x / (x + 1.0); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(1.0 + N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -31.0], t$95$0, If[LessEqual[x, 11000.0], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{x}{y}\\
\mathbf{if}\;x \leq -31:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 11000:\\
\;\;\;\;\frac{x}{x + 1}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -31 or 11000 < x Initial program 76.0%
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f6499.8%
Simplified99.8%
Taylor expanded in x around inf
sub-negN/A
distribute-lft-inN/A
distribute-rgt-inN/A
lft-mult-inverseN/A
associate-*l/N/A
*-lft-identityN/A
+-commutativeN/A
associate-+l+N/A
distribute-rgt-neg-outN/A
associate-/r*N/A
associate-*r/N/A
rgt-mult-inverseN/A
+-commutativeN/A
neg-sub0N/A
associate-+l-N/A
neg-sub0N/A
mul-1-negN/A
+-lowering-+.f64N/A
Simplified98.6%
Taylor expanded in y around inf
Simplified98.0%
if -31 < x < 11000Initial program 99.8%
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f6499.8%
Simplified99.8%
Taylor expanded in y around inf
/-lowering-/.f64N/A
+-commutativeN/A
+-lowering-+.f6475.9%
Simplified75.9%
Final simplification87.0%
(FPCore (x y) :precision binary64 (if (<= x -1.0) (/ x y) (if (<= x 0.38) x (/ x y))))
double code(double x, double y) {
double tmp;
if (x <= -1.0) {
tmp = x / y;
} else if (x <= 0.38) {
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 <= 0.38d0) 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 <= 0.38) {
tmp = x;
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.0: tmp = x / y elif x <= 0.38: 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 <= 0.38) 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 <= 0.38) 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, 0.38], x, N[(x / y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq 0.38:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -1 or 0.38 < x Initial program 76.5%
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f6499.8%
Simplified99.8%
Taylor expanded in x around inf
/-lowering-/.f6470.7%
Simplified70.7%
if -1 < x < 0.38Initial program 99.8%
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f6499.8%
Simplified99.8%
Taylor expanded in x around 0
Simplified74.9%
(FPCore (x y) :precision binary64 (if (<= x -205000000.0) 1.0 (if (<= x 1.0) x 1.0)))
double code(double x, double y) {
double tmp;
if (x <= -205000000.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 <= (-205000000.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 <= -205000000.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 <= -205000000.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 <= -205000000.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 <= -205000000.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, -205000000.0], 1.0, If[LessEqual[x, 1.0], x, 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -205000000:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < -2.05e8 or 1 < x Initial program 76.0%
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f6499.8%
Simplified99.8%
Taylor expanded in y around inf
/-lowering-/.f64N/A
+-commutativeN/A
+-lowering-+.f6428.8%
Simplified28.8%
Taylor expanded in x around inf
Simplified27.8%
if -2.05e8 < x < 1Initial program 99.8%
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f6499.9%
Simplified99.9%
Taylor expanded in x around 0
Simplified73.2%
(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.9%
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f6499.8%
Simplified99.8%
Final simplification99.8%
(FPCore (x y) :precision binary64 1.0)
double code(double x, double y) {
return 1.0;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0
end function
public static double code(double x, double y) {
return 1.0;
}
def code(x, y): return 1.0
function code(x, y) return 1.0 end
function tmp = code(x, y) tmp = 1.0; end
code[x_, y_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 87.9%
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f6499.8%
Simplified99.8%
Taylor expanded in y around inf
/-lowering-/.f64N/A
+-commutativeN/A
+-lowering-+.f6452.0%
Simplified52.0%
Taylor expanded in x around inf
Simplified15.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 2024161
(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)))