
(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 12 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
(let* ((t_0 (/ (* x (+ (/ x y) 1.0)) (+ x 1.0))))
(if (<= t_0 -5e+24)
(/ x (+ y (/ y x)))
(if (<= t_0 5e+95) t_0 (/ x (* y (+ 1.0 (/ 1.0 x))))))))
double code(double x, double y) {
double t_0 = (x * ((x / y) + 1.0)) / (x + 1.0);
double tmp;
if (t_0 <= -5e+24) {
tmp = x / (y + (y / x));
} else if (t_0 <= 5e+95) {
tmp = t_0;
} else {
tmp = x / (y * (1.0 + (1.0 / x)));
}
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) + 1.0d0)) / (x + 1.0d0)
if (t_0 <= (-5d+24)) then
tmp = x / (y + (y / x))
else if (t_0 <= 5d+95) then
tmp = t_0
else
tmp = x / (y * (1.0d0 + (1.0d0 / x)))
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = (x * ((x / y) + 1.0)) / (x + 1.0);
double tmp;
if (t_0 <= -5e+24) {
tmp = x / (y + (y / x));
} else if (t_0 <= 5e+95) {
tmp = t_0;
} else {
tmp = x / (y * (1.0 + (1.0 / x)));
}
return tmp;
}
def code(x, y): t_0 = (x * ((x / y) + 1.0)) / (x + 1.0) tmp = 0 if t_0 <= -5e+24: tmp = x / (y + (y / x)) elif t_0 <= 5e+95: tmp = t_0 else: tmp = x / (y * (1.0 + (1.0 / x))) return tmp
function code(x, y) t_0 = Float64(Float64(x * Float64(Float64(x / y) + 1.0)) / Float64(x + 1.0)) tmp = 0.0 if (t_0 <= -5e+24) tmp = Float64(x / Float64(y + Float64(y / x))); elseif (t_0 <= 5e+95) tmp = t_0; else tmp = Float64(x / Float64(y * Float64(1.0 + Float64(1.0 / x)))); end return tmp end
function tmp_2 = code(x, y) t_0 = (x * ((x / y) + 1.0)) / (x + 1.0); tmp = 0.0; if (t_0 <= -5e+24) tmp = x / (y + (y / x)); elseif (t_0 <= 5e+95) tmp = t_0; else tmp = x / (y * (1.0 + (1.0 / x))); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(x * N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -5e+24], N[(x / N[(y + N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 5e+95], t$95$0, N[(x / N[(y * N[(1.0 + N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1}\\
\mathbf{if}\;t_0 \leq -5 \cdot 10^{+24}:\\
\;\;\;\;\frac{x}{y + \frac{y}{x}}\\
\mathbf{elif}\;t_0 \leq 5 \cdot 10^{+95}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y \cdot \left(1 + \frac{1}{x}\right)}\\
\end{array}
\end{array}
if (/.f64 (*.f64 x (+.f64 (/.f64 x y) 1)) (+.f64 x 1)) < -5.00000000000000045e24Initial program 78.3%
*-commutative78.3%
associate-/l*99.9%
remove-double-neg99.9%
neg-mul-199.9%
*-commutative99.9%
associate-/r*99.9%
+-commutative99.9%
remove-double-neg99.9%
unsub-neg99.9%
div-sub99.9%
*-inverses99.9%
div-sub99.9%
associate-/r*99.9%
*-commutative99.9%
neg-mul-199.9%
remove-double-neg99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around 0 99.9%
distribute-lft-in99.9%
*-rgt-identity99.9%
associate-*r/100.0%
*-rgt-identity100.0%
Simplified100.0%
if -5.00000000000000045e24 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) 1)) (+.f64 x 1)) < 5.00000000000000025e95Initial program 99.9%
if 5.00000000000000025e95 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) 1)) (+.f64 x 1)) Initial program 70.1%
*-commutative70.1%
associate-/l*99.9%
remove-double-neg99.9%
neg-mul-199.9%
*-commutative99.9%
associate-/r*99.9%
+-commutative99.9%
remove-double-neg99.9%
unsub-neg99.9%
div-sub100.0%
*-inverses100.0%
div-sub100.0%
associate-/r*100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 100.0%
Final simplification99.9%
(FPCore (x y) :precision binary64 (let* ((t_0 (+ 1.0 (/ 1.0 x)))) (+ (/ (/ x y) t_0) (/ 1.0 t_0))))
double code(double x, double y) {
double t_0 = 1.0 + (1.0 / x);
return ((x / y) / t_0) + (1.0 / t_0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
t_0 = 1.0d0 + (1.0d0 / x)
code = ((x / y) / t_0) + (1.0d0 / t_0)
end function
public static double code(double x, double y) {
double t_0 = 1.0 + (1.0 / x);
return ((x / y) / t_0) + (1.0 / t_0);
}
def code(x, y): t_0 = 1.0 + (1.0 / x) return ((x / y) / t_0) + (1.0 / t_0)
function code(x, y) t_0 = Float64(1.0 + Float64(1.0 / x)) return Float64(Float64(Float64(x / y) / t_0) + Float64(1.0 / t_0)) end
function tmp = code(x, y) t_0 = 1.0 + (1.0 / x); tmp = ((x / y) / t_0) + (1.0 / t_0); end
code[x_, y_] := Block[{t$95$0 = N[(1.0 + N[(1.0 / x), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[(x / y), $MachinePrecision] / t$95$0), $MachinePrecision] + N[(1.0 / t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{1}{x}\\
\frac{\frac{x}{y}}{t_0} + \frac{1}{t_0}
\end{array}
\end{array}
Initial program 89.7%
*-commutative89.7%
associate-/l*99.8%
remove-double-neg99.8%
neg-mul-199.8%
*-commutative99.8%
associate-/r*99.8%
+-commutative99.8%
remove-double-neg99.8%
unsub-neg99.8%
div-sub99.8%
*-inverses99.8%
div-sub99.8%
associate-/r*99.8%
*-commutative99.8%
neg-mul-199.8%
remove-double-neg99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around 0 99.8%
+-commutative99.8%
associate-/r*99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (x y) :precision binary64 (if (or (<= x -80000.0) (not (<= x 1900000.0))) (+ 1.0 (/ (+ x -1.0) y)) (+ x (/ (/ x y) (+ 1.0 (/ 1.0 x))))))
double code(double x, double y) {
double tmp;
if ((x <= -80000.0) || !(x <= 1900000.0)) {
tmp = 1.0 + ((x + -1.0) / y);
} else {
tmp = x + ((x / y) / (1.0 + (1.0 / x)));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((x <= (-80000.0d0)) .or. (.not. (x <= 1900000.0d0))) then
tmp = 1.0d0 + ((x + (-1.0d0)) / y)
else
tmp = x + ((x / y) / (1.0d0 + (1.0d0 / x)))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -80000.0) || !(x <= 1900000.0)) {
tmp = 1.0 + ((x + -1.0) / y);
} else {
tmp = x + ((x / y) / (1.0 + (1.0 / x)));
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -80000.0) or not (x <= 1900000.0): tmp = 1.0 + ((x + -1.0) / y) else: tmp = x + ((x / y) / (1.0 + (1.0 / x))) return tmp
function code(x, y) tmp = 0.0 if ((x <= -80000.0) || !(x <= 1900000.0)) tmp = Float64(1.0 + Float64(Float64(x + -1.0) / y)); else tmp = Float64(x + Float64(Float64(x / y) / Float64(1.0 + Float64(1.0 / x)))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -80000.0) || ~((x <= 1900000.0))) tmp = 1.0 + ((x + -1.0) / y); else tmp = x + ((x / y) / (1.0 + (1.0 / x))); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -80000.0], N[Not[LessEqual[x, 1900000.0]], $MachinePrecision]], N[(1.0 + N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(x / y), $MachinePrecision] / N[(1.0 + N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -80000 \lor \neg \left(x \leq 1900000\right):\\
\;\;\;\;1 + \frac{x + -1}{y}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{\frac{x}{y}}{1 + \frac{1}{x}}\\
\end{array}
\end{array}
if x < -8e4 or 1.9e6 < x Initial program 79.4%
Taylor expanded in x around inf 99.7%
Taylor expanded in y around -inf 99.7%
mul-1-neg99.7%
unsub-neg99.7%
neg-mul-199.7%
unsub-neg99.7%
Simplified99.7%
if -8e4 < x < 1.9e6Initial program 99.9%
*-commutative99.9%
associate-/l*99.7%
remove-double-neg99.7%
neg-mul-199.7%
*-commutative99.7%
associate-/r*99.7%
+-commutative99.7%
remove-double-neg99.7%
unsub-neg99.7%
div-sub99.7%
*-inverses99.7%
div-sub99.7%
associate-/r*99.7%
*-commutative99.7%
neg-mul-199.7%
remove-double-neg99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in y around 0 99.6%
+-commutative99.6%
associate-/r*99.7%
Simplified99.7%
Taylor expanded in x around 0 98.3%
Final simplification99.0%
(FPCore (x y)
:precision binary64
(if (<= x -1.0)
(/ x y)
(if (<= x -4.3e-66)
(* x (/ x y))
(if (<= x 4.1e+30) (/ x (+ x 1.0)) (/ 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 <= 4.1e+30) {
tmp = x / (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 <= (-1.0d0)) then
tmp = x / y
else if (x <= (-4.3d-66)) then
tmp = x * (x / y)
else if (x <= 4.1d+30) then
tmp = x / (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 <= -1.0) {
tmp = x / y;
} else if (x <= -4.3e-66) {
tmp = x * (x / y);
} else if (x <= 4.1e+30) {
tmp = x / (x + 1.0);
} 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 <= 4.1e+30: tmp = x / (x + 1.0) 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 <= 4.1e+30) tmp = Float64(x / Float64(x + 1.0)); 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 <= 4.1e+30) tmp = x / (x + 1.0); 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, 4.1e+30], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], 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 4.1 \cdot 10^{+30}:\\
\;\;\;\;\frac{x}{x + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -1 or 4.10000000000000005e30 < x Initial program 78.2%
Taylor expanded in x around inf 83.2%
if -1 < x < -4.30000000000000013e-66Initial program 99.7%
*-commutative99.7%
associate-/l*99.1%
remove-double-neg99.1%
neg-mul-199.1%
*-commutative99.1%
associate-/r*99.1%
+-commutative99.1%
remove-double-neg99.1%
unsub-neg99.1%
div-sub99.1%
*-inverses99.1%
div-sub99.1%
associate-/r*99.1%
*-commutative99.1%
neg-mul-199.1%
remove-double-neg99.1%
metadata-eval99.1%
Simplified99.1%
Taylor expanded in y around 0 77.8%
associate-/r*77.3%
Simplified77.3%
Taylor expanded in x around 0 64.3%
associate-/r/64.7%
/-rgt-identity64.7%
Applied egg-rr64.7%
if -4.30000000000000013e-66 < x < 4.10000000000000005e30Initial program 99.9%
Taylor expanded in y around inf 74.4%
+-commutative74.4%
Simplified74.4%
Final simplification78.0%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (+ x -1.0) y)))
(if (<= x -1.0)
t_0
(if (<= x -1.2e-64) (* x (/ x y)) (if (<= x 30.0) (/ x (+ x 1.0)) t_0)))))
double code(double x, double y) {
double t_0 = (x + -1.0) / y;
double tmp;
if (x <= -1.0) {
tmp = t_0;
} else if (x <= -1.2e-64) {
tmp = x * (x / y);
} else if (x <= 30.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 = (x + (-1.0d0)) / y
if (x <= (-1.0d0)) then
tmp = t_0
else if (x <= (-1.2d-64)) then
tmp = x * (x / y)
else if (x <= 30.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 = (x + -1.0) / y;
double tmp;
if (x <= -1.0) {
tmp = t_0;
} else if (x <= -1.2e-64) {
tmp = x * (x / y);
} else if (x <= 30.0) {
tmp = x / (x + 1.0);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = (x + -1.0) / y tmp = 0 if x <= -1.0: tmp = t_0 elif x <= -1.2e-64: tmp = x * (x / y) elif x <= 30.0: tmp = x / (x + 1.0) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(Float64(x + -1.0) / y) tmp = 0.0 if (x <= -1.0) tmp = t_0; elseif (x <= -1.2e-64) tmp = Float64(x * Float64(x / y)); elseif (x <= 30.0) tmp = Float64(x / Float64(x + 1.0)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = (x + -1.0) / y; tmp = 0.0; if (x <= -1.0) tmp = t_0; elseif (x <= -1.2e-64) tmp = x * (x / y); elseif (x <= 30.0) tmp = x / (x + 1.0); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision]}, If[LessEqual[x, -1.0], t$95$0, If[LessEqual[x, -1.2e-64], N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 30.0], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x + -1}{y}\\
\mathbf{if}\;x \leq -1:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -1.2 \cdot 10^{-64}:\\
\;\;\;\;x \cdot \frac{x}{y}\\
\mathbf{elif}\;x \leq 30:\\
\;\;\;\;\frac{x}{x + 1}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -1 or 30 < x Initial program 79.8%
Taylor expanded in x around inf 98.6%
Taylor expanded in y around 0 80.8%
if -1 < x < -1.19999999999999999e-64Initial program 99.7%
*-commutative99.7%
associate-/l*99.1%
remove-double-neg99.1%
neg-mul-199.1%
*-commutative99.1%
associate-/r*99.1%
+-commutative99.1%
remove-double-neg99.1%
unsub-neg99.1%
div-sub99.1%
*-inverses99.1%
div-sub99.1%
associate-/r*99.1%
*-commutative99.1%
neg-mul-199.1%
remove-double-neg99.1%
metadata-eval99.1%
Simplified99.1%
Taylor expanded in y around 0 77.8%
associate-/r*77.3%
Simplified77.3%
Taylor expanded in x around 0 64.3%
associate-/r/64.7%
/-rgt-identity64.7%
Applied egg-rr64.7%
if -1.19999999999999999e-64 < x < 30Initial program 99.9%
Taylor expanded in y around inf 77.0%
+-commutative77.0%
Simplified77.0%
Final simplification78.3%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ (/ x y) 1.0)))
(if (<= x -1.0)
t_0
(if (<= x -2.7e-67) (* x (/ x y)) (if (<= x 0.6) (/ x (+ x 1.0)) t_0)))))
double code(double x, double y) {
double t_0 = (x / y) + 1.0;
double tmp;
if (x <= -1.0) {
tmp = t_0;
} else if (x <= -2.7e-67) {
tmp = x * (x / y);
} else if (x <= 0.6) {
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 = (x / y) + 1.0d0
if (x <= (-1.0d0)) then
tmp = t_0
else if (x <= (-2.7d-67)) then
tmp = x * (x / y)
else if (x <= 0.6d0) 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 = (x / y) + 1.0;
double tmp;
if (x <= -1.0) {
tmp = t_0;
} else if (x <= -2.7e-67) {
tmp = x * (x / y);
} else if (x <= 0.6) {
tmp = x / (x + 1.0);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = (x / y) + 1.0 tmp = 0 if x <= -1.0: tmp = t_0 elif x <= -2.7e-67: tmp = x * (x / y) elif x <= 0.6: tmp = x / (x + 1.0) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(Float64(x / y) + 1.0) tmp = 0.0 if (x <= -1.0) tmp = t_0; elseif (x <= -2.7e-67) tmp = Float64(x * Float64(x / y)); elseif (x <= 0.6) tmp = Float64(x / Float64(x + 1.0)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = (x / y) + 1.0; tmp = 0.0; if (x <= -1.0) tmp = t_0; elseif (x <= -2.7e-67) tmp = x * (x / y); elseif (x <= 0.6) tmp = 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] + 1.0), $MachinePrecision]}, If[LessEqual[x, -1.0], t$95$0, If[LessEqual[x, -2.7e-67], N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.6], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{y} + 1\\
\mathbf{if}\;x \leq -1:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -2.7 \cdot 10^{-67}:\\
\;\;\;\;x \cdot \frac{x}{y}\\
\mathbf{elif}\;x \leq 0.6:\\
\;\;\;\;\frac{x}{x + 1}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -1 or 0.599999999999999978 < x Initial program 80.0%
Taylor expanded in x around inf 97.8%
Taylor expanded in y around -inf 97.8%
mul-1-neg97.8%
unsub-neg97.8%
neg-mul-197.8%
unsub-neg97.8%
Simplified97.8%
Taylor expanded in x around inf 96.8%
neg-mul-196.8%
distribute-neg-frac96.8%
Simplified96.8%
if -1 < x < -2.70000000000000016e-67Initial program 99.7%
*-commutative99.7%
associate-/l*99.1%
remove-double-neg99.1%
neg-mul-199.1%
*-commutative99.1%
associate-/r*99.1%
+-commutative99.1%
remove-double-neg99.1%
unsub-neg99.1%
div-sub99.1%
*-inverses99.1%
div-sub99.1%
associate-/r*99.1%
*-commutative99.1%
neg-mul-199.1%
remove-double-neg99.1%
metadata-eval99.1%
Simplified99.1%
Taylor expanded in y around 0 77.8%
associate-/r*77.3%
Simplified77.3%
Taylor expanded in x around 0 64.3%
associate-/r/64.7%
/-rgt-identity64.7%
Applied egg-rr64.7%
if -2.70000000000000016e-67 < x < 0.599999999999999978Initial program 99.9%
Taylor expanded in y around inf 77.7%
+-commutative77.7%
Simplified77.7%
Final simplification86.9%
(FPCore (x y) :precision binary64 (let* ((t_0 (+ (/ x y) 1.0))) (if (or (<= x -1.0) (not (<= x 1.0))) t_0 (* x t_0))))
double code(double x, double y) {
double t_0 = (x / y) + 1.0;
double tmp;
if ((x <= -1.0) || !(x <= 1.0)) {
tmp = t_0;
} else {
tmp = x * 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
if ((x <= (-1.0d0)) .or. (.not. (x <= 1.0d0))) then
tmp = t_0
else
tmp = x * t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = (x / y) + 1.0;
double tmp;
if ((x <= -1.0) || !(x <= 1.0)) {
tmp = t_0;
} else {
tmp = x * t_0;
}
return tmp;
}
def code(x, y): t_0 = (x / y) + 1.0 tmp = 0 if (x <= -1.0) or not (x <= 1.0): tmp = t_0 else: tmp = x * t_0 return tmp
function code(x, y) t_0 = Float64(Float64(x / y) + 1.0) tmp = 0.0 if ((x <= -1.0) || !(x <= 1.0)) tmp = t_0; else tmp = Float64(x * t_0); end return tmp end
function tmp_2 = code(x, y) t_0 = (x / y) + 1.0; tmp = 0.0; if ((x <= -1.0) || ~((x <= 1.0))) tmp = t_0; else tmp = x * t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]}, If[Or[LessEqual[x, -1.0], N[Not[LessEqual[x, 1.0]], $MachinePrecision]], t$95$0, N[(x * t$95$0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{y} + 1\\
\mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 1\right):\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;x \cdot t_0\\
\end{array}
\end{array}
if x < -1 or 1 < x Initial program 79.8%
Taylor expanded in x around inf 98.6%
Taylor expanded in y around -inf 98.6%
mul-1-neg98.6%
unsub-neg98.6%
neg-mul-198.6%
unsub-neg98.6%
Simplified98.6%
Taylor expanded in x around inf 97.5%
neg-mul-197.5%
distribute-neg-frac97.5%
Simplified97.5%
if -1 < x < 1Initial program 99.9%
*-commutative99.9%
associate-/l*99.7%
remove-double-neg99.7%
neg-mul-199.7%
*-commutative99.7%
associate-/r*99.7%
+-commutative99.7%
remove-double-neg99.7%
unsub-neg99.7%
div-sub99.7%
*-inverses99.7%
div-sub99.7%
associate-/r*99.7%
*-commutative99.7%
neg-mul-199.7%
remove-double-neg99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in x around 0 95.9%
associate-/r/96.2%
/-rgt-identity96.2%
+-commutative96.2%
Applied egg-rr96.2%
Final simplification96.8%
(FPCore (x y) :precision binary64 (if (or (<= x -1.0) (not (<= x 1.22))) (+ 1.0 (/ (+ x -1.0) y)) (* x (+ (/ x y) 1.0))))
double code(double x, double y) {
double tmp;
if ((x <= -1.0) || !(x <= 1.22)) {
tmp = 1.0 + ((x + -1.0) / y);
} else {
tmp = x * ((x / 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 <= 1.22d0))) then
tmp = 1.0d0 + ((x + (-1.0d0)) / y)
else
tmp = x * ((x / y) + 1.0d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -1.0) || !(x <= 1.22)) {
tmp = 1.0 + ((x + -1.0) / y);
} else {
tmp = x * ((x / y) + 1.0);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -1.0) or not (x <= 1.22): tmp = 1.0 + ((x + -1.0) / y) else: tmp = x * ((x / y) + 1.0) return tmp
function code(x, y) tmp = 0.0 if ((x <= -1.0) || !(x <= 1.22)) tmp = Float64(1.0 + Float64(Float64(x + -1.0) / y)); else tmp = Float64(x * Float64(Float64(x / y) + 1.0)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -1.0) || ~((x <= 1.22))) tmp = 1.0 + ((x + -1.0) / y); else tmp = x * ((x / y) + 1.0); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -1.0], N[Not[LessEqual[x, 1.22]], $MachinePrecision]], N[(1.0 + N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(x * N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 1.22\right):\\
\;\;\;\;1 + \frac{x + -1}{y}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\frac{x}{y} + 1\right)\\
\end{array}
\end{array}
if x < -1 or 1.21999999999999997 < x Initial program 79.8%
Taylor expanded in x around inf 98.6%
Taylor expanded in y around -inf 98.6%
mul-1-neg98.6%
unsub-neg98.6%
neg-mul-198.6%
unsub-neg98.6%
Simplified98.6%
if -1 < x < 1.21999999999999997Initial program 99.9%
*-commutative99.9%
associate-/l*99.7%
remove-double-neg99.7%
neg-mul-199.7%
*-commutative99.7%
associate-/r*99.7%
+-commutative99.7%
remove-double-neg99.7%
unsub-neg99.7%
div-sub99.7%
*-inverses99.7%
div-sub99.7%
associate-/r*99.7%
*-commutative99.7%
neg-mul-199.7%
remove-double-neg99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in x around 0 95.9%
associate-/r/96.2%
/-rgt-identity96.2%
+-commutative96.2%
Applied egg-rr96.2%
Final simplification97.4%
(FPCore (x y) :precision binary64 (/ (+ (/ x y) 1.0) (- (/ 1.0 x) -1.0)))
double code(double x, double y) {
return ((x / y) + 1.0) / ((1.0 / x) - -1.0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((x / y) + 1.0d0) / ((1.0d0 / x) - (-1.0d0))
end function
public static double code(double x, double y) {
return ((x / y) + 1.0) / ((1.0 / x) - -1.0);
}
def code(x, y): return ((x / y) + 1.0) / ((1.0 / x) - -1.0)
function code(x, y) return Float64(Float64(Float64(x / y) + 1.0) / Float64(Float64(1.0 / x) - -1.0)) end
function tmp = code(x, y) tmp = ((x / y) + 1.0) / ((1.0 / x) - -1.0); end
code[x_, y_] := N[(N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision] / N[(N[(1.0 / x), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{x}{y} + 1}{\frac{1}{x} - -1}
\end{array}
Initial program 89.7%
*-commutative89.7%
associate-/l*99.8%
remove-double-neg99.8%
neg-mul-199.8%
*-commutative99.8%
associate-/r*99.8%
+-commutative99.8%
remove-double-neg99.8%
unsub-neg99.8%
div-sub99.8%
*-inverses99.8%
div-sub99.8%
associate-/r*99.8%
*-commutative99.8%
neg-mul-199.8%
remove-double-neg99.8%
metadata-eval99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (x y) :precision binary64 (if (<= x -1.0) (/ x y) (if (<= x -7.2e-65) (* x (/ x y)) (if (<= x 0.4) x (/ x y)))))
double code(double x, double y) {
double tmp;
if (x <= -1.0) {
tmp = x / y;
} else if (x <= -7.2e-65) {
tmp = x * (x / y);
} else if (x <= 0.4) {
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 <= (-7.2d-65)) then
tmp = x * (x / y)
else if (x <= 0.4d0) 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 <= -7.2e-65) {
tmp = x * (x / y);
} else if (x <= 0.4) {
tmp = x;
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.0: tmp = x / y elif x <= -7.2e-65: tmp = x * (x / y) elif x <= 0.4: 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 <= -7.2e-65) tmp = Float64(x * Float64(x / y)); elseif (x <= 0.4) 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 <= -7.2e-65) tmp = x * (x / y); elseif (x <= 0.4) 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, -7.2e-65], N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.4], x, N[(x / y), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq -7.2 \cdot 10^{-65}:\\
\;\;\;\;x \cdot \frac{x}{y}\\
\mathbf{elif}\;x \leq 0.4:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -1 or 0.40000000000000002 < x Initial program 80.0%
Taylor expanded in x around inf 79.2%
if -1 < x < -7.1999999999999996e-65Initial program 99.7%
*-commutative99.7%
associate-/l*99.1%
remove-double-neg99.1%
neg-mul-199.1%
*-commutative99.1%
associate-/r*99.1%
+-commutative99.1%
remove-double-neg99.1%
unsub-neg99.1%
div-sub99.1%
*-inverses99.1%
div-sub99.1%
associate-/r*99.1%
*-commutative99.1%
neg-mul-199.1%
remove-double-neg99.1%
metadata-eval99.1%
Simplified99.1%
Taylor expanded in y around 0 77.8%
associate-/r*77.3%
Simplified77.3%
Taylor expanded in x around 0 64.3%
associate-/r/64.7%
/-rgt-identity64.7%
Applied egg-rr64.7%
if -7.1999999999999996e-65 < x < 0.40000000000000002Initial program 99.9%
Taylor expanded in x around 0 76.6%
Final simplification77.4%
(FPCore (x y) :precision binary64 (if (or (<= x -1.0) (not (<= x 0.48))) (/ x y) x))
double code(double x, double y) {
double tmp;
if ((x <= -1.0) || !(x <= 0.48)) {
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 <= 0.48d0))) 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 <= 0.48)) {
tmp = x / y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -1.0) or not (x <= 0.48): tmp = x / y else: tmp = x return tmp
function code(x, y) tmp = 0.0 if ((x <= -1.0) || !(x <= 0.48)) 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 <= 0.48))) tmp = x / y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -1.0], N[Not[LessEqual[x, 0.48]], $MachinePrecision]], N[(x / y), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 0.48\right):\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -1 or 0.47999999999999998 < x Initial program 80.0%
Taylor expanded in x around inf 79.2%
if -1 < x < 0.47999999999999998Initial program 99.9%
Taylor expanded in x around 0 70.6%
Final simplification75.0%
(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 89.7%
Taylor expanded in x around 0 36.7%
Final simplification36.7%
(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 2023322
(FPCore (x y)
:name "Codec.Picture.Types:toneMapping from JuicyPixels-3.2.6.1"
:precision binary64
:herbie-target
(* (/ x 1.0) (/ (+ (/ x y) 1.0) (+ x 1.0)))
(/ (* x (+ (/ x y) 1.0)) (+ x 1.0)))