
(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 1.0)))) (+ t_0 (* t_0 (/ x y)))))
double code(double x, double y) {
double t_0 = x / (x + 1.0);
return t_0 + (t_0 * (x / y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
t_0 = x / (x + 1.0d0)
code = t_0 + (t_0 * (x / y))
end function
public static double code(double x, double y) {
double t_0 = x / (x + 1.0);
return t_0 + (t_0 * (x / y));
}
def code(x, y): t_0 = x / (x + 1.0) return t_0 + (t_0 * (x / y))
function code(x, y) t_0 = Float64(x / Float64(x + 1.0)) return Float64(t_0 + Float64(t_0 * Float64(x / y))) end
function tmp = code(x, y) t_0 = x / (x + 1.0); tmp = t_0 + (t_0 * (x / y)); end
code[x_, y_] := Block[{t$95$0 = N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, N[(t$95$0 + N[(t$95$0 * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{x + 1}\\
t\_0 + t\_0 \cdot \frac{x}{y}
\end{array}
\end{array}
Initial program 89.3%
associate-/l*99.8%
Simplified99.8%
clear-num99.7%
un-div-inv99.9%
Applied egg-rr99.9%
associate-/r/99.9%
+-commutative99.9%
+-commutative99.9%
distribute-lft-in99.9%
*-commutative99.9%
*-un-lft-identity99.9%
+-commutative99.9%
+-commutative99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* x (- 1.0 x))))
(if (<= x -1.0)
(/ x y)
(if (<= x 3.5e-186)
t_0
(if (<= x 1.9e-150) (* x (/ x y)) (if (<= x 0.39) t_0 (/ x y)))))))
double code(double x, double y) {
double t_0 = x * (1.0 - x);
double tmp;
if (x <= -1.0) {
tmp = x / y;
} else if (x <= 3.5e-186) {
tmp = t_0;
} else if (x <= 1.9e-150) {
tmp = x * (x / y);
} else if (x <= 0.39) {
tmp = t_0;
} else {
tmp = x / y;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = x * (1.0d0 - x)
if (x <= (-1.0d0)) then
tmp = x / y
else if (x <= 3.5d-186) then
tmp = t_0
else if (x <= 1.9d-150) then
tmp = x * (x / y)
else if (x <= 0.39d0) then
tmp = t_0
else
tmp = x / y
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = x * (1.0 - x);
double tmp;
if (x <= -1.0) {
tmp = x / y;
} else if (x <= 3.5e-186) {
tmp = t_0;
} else if (x <= 1.9e-150) {
tmp = x * (x / y);
} else if (x <= 0.39) {
tmp = t_0;
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): t_0 = x * (1.0 - x) tmp = 0 if x <= -1.0: tmp = x / y elif x <= 3.5e-186: tmp = t_0 elif x <= 1.9e-150: tmp = x * (x / y) elif x <= 0.39: tmp = t_0 else: tmp = x / y return tmp
function code(x, y) t_0 = Float64(x * Float64(1.0 - x)) tmp = 0.0 if (x <= -1.0) tmp = Float64(x / y); elseif (x <= 3.5e-186) tmp = t_0; elseif (x <= 1.9e-150) tmp = Float64(x * Float64(x / y)); elseif (x <= 0.39) tmp = t_0; else tmp = Float64(x / y); end return tmp end
function tmp_2 = code(x, y) t_0 = x * (1.0 - x); tmp = 0.0; if (x <= -1.0) tmp = x / y; elseif (x <= 3.5e-186) tmp = t_0; elseif (x <= 1.9e-150) tmp = x * (x / y); elseif (x <= 0.39) tmp = t_0; else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x * N[(1.0 - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.0], N[(x / y), $MachinePrecision], If[LessEqual[x, 3.5e-186], t$95$0, If[LessEqual[x, 1.9e-150], N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.39], t$95$0, N[(x / y), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(1 - x\right)\\
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq 3.5 \cdot 10^{-186}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.9 \cdot 10^{-150}:\\
\;\;\;\;x \cdot \frac{x}{y}\\
\mathbf{elif}\;x \leq 0.39:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -1 or 0.39000000000000001 < x Initial program 76.3%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around inf 78.2%
if -1 < x < 3.49999999999999989e-186 or 1.8999999999999999e-150 < x < 0.39000000000000001Initial program 99.8%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around inf 73.2%
Taylor expanded in x around 0 73.0%
neg-mul-173.0%
sub-neg73.0%
Simplified73.0%
if 3.49999999999999989e-186 < x < 1.8999999999999999e-150Initial program 99.6%
associate-/l*99.6%
Simplified99.6%
clear-num99.4%
un-div-inv99.4%
Applied egg-rr99.4%
Taylor expanded in y around 0 83.3%
Taylor expanded in x around 0 83.3%
associate-/r/83.5%
Applied egg-rr83.5%
Final simplification75.7%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ x (+ x 1.0))))
(if (<= x -1900000000.0)
(/ x y)
(if (<= x 3.5e-186)
t_0
(if (<= x 1.9e-150) (* x (/ x y)) (if (<= x 5.8e+16) t_0 (/ x y)))))))
double code(double x, double y) {
double t_0 = x / (x + 1.0);
double tmp;
if (x <= -1900000000.0) {
tmp = x / y;
} else if (x <= 3.5e-186) {
tmp = t_0;
} else if (x <= 1.9e-150) {
tmp = x * (x / y);
} else if (x <= 5.8e+16) {
tmp = t_0;
} else {
tmp = x / y;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = x / (x + 1.0d0)
if (x <= (-1900000000.0d0)) then
tmp = x / y
else if (x <= 3.5d-186) then
tmp = t_0
else if (x <= 1.9d-150) then
tmp = x * (x / y)
else if (x <= 5.8d+16) then
tmp = t_0
else
tmp = x / y
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = x / (x + 1.0);
double tmp;
if (x <= -1900000000.0) {
tmp = x / y;
} else if (x <= 3.5e-186) {
tmp = t_0;
} else if (x <= 1.9e-150) {
tmp = x * (x / y);
} else if (x <= 5.8e+16) {
tmp = t_0;
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): t_0 = x / (x + 1.0) tmp = 0 if x <= -1900000000.0: tmp = x / y elif x <= 3.5e-186: tmp = t_0 elif x <= 1.9e-150: tmp = x * (x / y) elif x <= 5.8e+16: tmp = t_0 else: tmp = x / y return tmp
function code(x, y) t_0 = Float64(x / Float64(x + 1.0)) tmp = 0.0 if (x <= -1900000000.0) tmp = Float64(x / y); elseif (x <= 3.5e-186) tmp = t_0; elseif (x <= 1.9e-150) tmp = Float64(x * Float64(x / y)); elseif (x <= 5.8e+16) tmp = t_0; else tmp = Float64(x / y); end return tmp end
function tmp_2 = code(x, y) t_0 = x / (x + 1.0); tmp = 0.0; if (x <= -1900000000.0) tmp = x / y; elseif (x <= 3.5e-186) tmp = t_0; elseif (x <= 1.9e-150) tmp = x * (x / y); elseif (x <= 5.8e+16) tmp = t_0; else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1900000000.0], N[(x / y), $MachinePrecision], If[LessEqual[x, 3.5e-186], t$95$0, If[LessEqual[x, 1.9e-150], N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 5.8e+16], t$95$0, N[(x / y), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{x + 1}\\
\mathbf{if}\;x \leq -1900000000:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq 3.5 \cdot 10^{-186}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.9 \cdot 10^{-150}:\\
\;\;\;\;x \cdot \frac{x}{y}\\
\mathbf{elif}\;x \leq 5.8 \cdot 10^{+16}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -1.9e9 or 5.8e16 < x Initial program 74.7%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around inf 82.2%
if -1.9e9 < x < 3.49999999999999989e-186 or 1.8999999999999999e-150 < x < 5.8e16Initial program 99.8%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around inf 73.1%
if 3.49999999999999989e-186 < x < 1.8999999999999999e-150Initial program 99.6%
associate-/l*99.6%
Simplified99.6%
clear-num99.4%
un-div-inv99.4%
Applied egg-rr99.4%
Taylor expanded in y around 0 83.3%
Taylor expanded in x around 0 83.3%
associate-/r/83.5%
Applied egg-rr83.5%
Final simplification77.3%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ x (+ x 1.0))))
(if (<= y -1.06e-40)
t_0
(if (<= y 1.38e-52)
(/ x (+ y (/ y x)))
(if (<= y 7e-19) x (if (<= y 1.22e+36) (/ x y) t_0))))))
double code(double x, double y) {
double t_0 = x / (x + 1.0);
double tmp;
if (y <= -1.06e-40) {
tmp = t_0;
} else if (y <= 1.38e-52) {
tmp = x / (y + (y / x));
} else if (y <= 7e-19) {
tmp = x;
} else if (y <= 1.22e+36) {
tmp = 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 / (x + 1.0d0)
if (y <= (-1.06d-40)) then
tmp = t_0
else if (y <= 1.38d-52) then
tmp = x / (y + (y / x))
else if (y <= 7d-19) then
tmp = x
else if (y <= 1.22d+36) then
tmp = x / y
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = x / (x + 1.0);
double tmp;
if (y <= -1.06e-40) {
tmp = t_0;
} else if (y <= 1.38e-52) {
tmp = x / (y + (y / x));
} else if (y <= 7e-19) {
tmp = x;
} else if (y <= 1.22e+36) {
tmp = x / y;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = x / (x + 1.0) tmp = 0 if y <= -1.06e-40: tmp = t_0 elif y <= 1.38e-52: tmp = x / (y + (y / x)) elif y <= 7e-19: tmp = x elif y <= 1.22e+36: tmp = x / y else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(x / Float64(x + 1.0)) tmp = 0.0 if (y <= -1.06e-40) tmp = t_0; elseif (y <= 1.38e-52) tmp = Float64(x / Float64(y + Float64(y / x))); elseif (y <= 7e-19) tmp = x; elseif (y <= 1.22e+36) tmp = Float64(x / y); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = x / (x + 1.0); tmp = 0.0; if (y <= -1.06e-40) tmp = t_0; elseif (y <= 1.38e-52) tmp = x / (y + (y / x)); elseif (y <= 7e-19) tmp = x; elseif (y <= 1.22e+36) tmp = x / y; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.06e-40], t$95$0, If[LessEqual[y, 1.38e-52], N[(x / N[(y + N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 7e-19], x, If[LessEqual[y, 1.22e+36], N[(x / y), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{x + 1}\\
\mathbf{if}\;y \leq -1.06 \cdot 10^{-40}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 1.38 \cdot 10^{-52}:\\
\;\;\;\;\frac{x}{y + \frac{y}{x}}\\
\mathbf{elif}\;y \leq 7 \cdot 10^{-19}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 1.22 \cdot 10^{+36}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -1.06e-40 or 1.21999999999999995e36 < y Initial program 93.1%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around inf 83.8%
if -1.06e-40 < y < 1.38000000000000008e-52Initial program 90.1%
associate-/l*99.7%
Simplified99.7%
clear-num99.6%
un-div-inv99.7%
Applied egg-rr99.7%
Taylor expanded in y around 0 83.5%
Taylor expanded in x around inf 83.5%
if 1.38000000000000008e-52 < y < 7.00000000000000031e-19Initial program 82.9%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around 0 74.8%
if 7.00000000000000031e-19 < y < 1.21999999999999995e36Initial program 48.8%
associate-/l*99.7%
Simplified99.7%
Taylor expanded in x around inf 75.5%
Final simplification82.9%
(FPCore (x y) :precision binary64 (if (or (<= x -9.3e-7) (not (<= x 2.8e-34))) (+ (/ x (+ x 1.0)) (/ x y)) (* x (+ 1.0 (- (/ x y) x)))))
double code(double x, double y) {
double tmp;
if ((x <= -9.3e-7) || !(x <= 2.8e-34)) {
tmp = (x / (x + 1.0)) + (x / y);
} else {
tmp = x * (1.0 + ((x / y) - x));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((x <= (-9.3d-7)) .or. (.not. (x <= 2.8d-34))) then
tmp = (x / (x + 1.0d0)) + (x / y)
else
tmp = x * (1.0d0 + ((x / y) - x))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -9.3e-7) || !(x <= 2.8e-34)) {
tmp = (x / (x + 1.0)) + (x / y);
} else {
tmp = x * (1.0 + ((x / y) - x));
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -9.3e-7) or not (x <= 2.8e-34): tmp = (x / (x + 1.0)) + (x / y) else: tmp = x * (1.0 + ((x / y) - x)) return tmp
function code(x, y) tmp = 0.0 if ((x <= -9.3e-7) || !(x <= 2.8e-34)) tmp = Float64(Float64(x / Float64(x + 1.0)) + Float64(x / y)); else tmp = Float64(x * Float64(1.0 + Float64(Float64(x / y) - x))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -9.3e-7) || ~((x <= 2.8e-34))) tmp = (x / (x + 1.0)) + (x / y); else tmp = x * (1.0 + ((x / y) - x)); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -9.3e-7], N[Not[LessEqual[x, 2.8e-34]], $MachinePrecision]], N[(N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] + N[(x / y), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 + N[(N[(x / y), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9.3 \cdot 10^{-7} \lor \neg \left(x \leq 2.8 \cdot 10^{-34}\right):\\
\;\;\;\;\frac{x}{x + 1} + \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 + \left(\frac{x}{y} - x\right)\right)\\
\end{array}
\end{array}
if x < -9.2999999999999999e-7 or 2.79999999999999997e-34 < x Initial program 77.2%
associate-/l*99.8%
Simplified99.8%
clear-num99.6%
un-div-inv99.9%
Applied egg-rr99.9%
associate-/r/100.0%
+-commutative100.0%
+-commutative100.0%
distribute-lft-in100.0%
*-commutative100.0%
*-un-lft-identity100.0%
+-commutative100.0%
+-commutative100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 98.8%
if -9.2999999999999999e-7 < x < 2.79999999999999997e-34Initial program 99.8%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around 0 99.8%
Taylor expanded in y around inf 99.8%
neg-mul-199.8%
+-commutative99.8%
unsub-neg99.8%
Simplified99.8%
Final simplification99.4%
(FPCore (x y) :precision binary64 (if (<= x -9.8e-5) (/ x (+ y (/ y x))) (if (<= x 1.0) (* x (+ 1.0 (- (/ x y) x))) (/ x y))))
double code(double x, double y) {
double tmp;
if (x <= -9.8e-5) {
tmp = x / (y + (y / x));
} else if (x <= 1.0) {
tmp = x * (1.0 + ((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 <= (-9.8d-5)) then
tmp = x / (y + (y / x))
else if (x <= 1.0d0) then
tmp = x * (1.0d0 + ((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 <= -9.8e-5) {
tmp = x / (y + (y / x));
} else if (x <= 1.0) {
tmp = x * (1.0 + ((x / y) - x));
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -9.8e-5: tmp = x / (y + (y / x)) elif x <= 1.0: tmp = x * (1.0 + ((x / y) - x)) else: tmp = x / y return tmp
function code(x, y) tmp = 0.0 if (x <= -9.8e-5) tmp = Float64(x / Float64(y + Float64(y / x))); elseif (x <= 1.0) tmp = Float64(x * Float64(1.0 + Float64(Float64(x / y) - x))); else tmp = Float64(x / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -9.8e-5) tmp = x / (y + (y / x)); elseif (x <= 1.0) tmp = x * (1.0 + ((x / y) - x)); else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -9.8e-5], N[(x / N[(y + N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.0], N[(x * N[(1.0 + N[(N[(x / y), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x / y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9.8 \cdot 10^{-5}:\\
\;\;\;\;\frac{x}{y + \frac{y}{x}}\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;x \cdot \left(1 + \left(\frac{x}{y} - x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -9.8e-5Initial program 81.7%
associate-/l*99.8%
Simplified99.8%
clear-num99.6%
un-div-inv99.9%
Applied egg-rr99.9%
Taylor expanded in y around 0 75.8%
Taylor expanded in x around inf 80.3%
if -9.8e-5 < x < 1Initial program 99.8%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around 0 99.6%
Taylor expanded in y around inf 99.7%
neg-mul-199.7%
+-commutative99.7%
unsub-neg99.7%
Simplified99.7%
if 1 < x Initial program 71.0%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around inf 78.5%
Final simplification90.6%
(FPCore (x y) :precision binary64 (if (<= x -2.9e-6) (* (/ x (+ x 1.0)) (/ x y)) (if (<= x 1.0) (* x (+ 1.0 (- (/ x y) x))) (/ x y))))
double code(double x, double y) {
double tmp;
if (x <= -2.9e-6) {
tmp = (x / (x + 1.0)) * (x / y);
} else if (x <= 1.0) {
tmp = x * (1.0 + ((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-6)) then
tmp = (x / (x + 1.0d0)) * (x / y)
else if (x <= 1.0d0) then
tmp = x * (1.0d0 + ((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-6) {
tmp = (x / (x + 1.0)) * (x / y);
} else if (x <= 1.0) {
tmp = x * (1.0 + ((x / y) - x));
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -2.9e-6: tmp = (x / (x + 1.0)) * (x / y) elif x <= 1.0: tmp = x * (1.0 + ((x / y) - x)) else: tmp = x / y return tmp
function code(x, y) tmp = 0.0 if (x <= -2.9e-6) tmp = Float64(Float64(x / Float64(x + 1.0)) * Float64(x / y)); elseif (x <= 1.0) tmp = Float64(x * Float64(1.0 + Float64(Float64(x / y) - x))); else tmp = Float64(x / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -2.9e-6) tmp = (x / (x + 1.0)) * (x / y); elseif (x <= 1.0) tmp = x * (1.0 + ((x / y) - x)); else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -2.9e-6], N[(N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.0], N[(x * N[(1.0 + N[(N[(x / y), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x / y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.9 \cdot 10^{-6}:\\
\;\;\;\;\frac{x}{x + 1} \cdot \frac{x}{y}\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;x \cdot \left(1 + \left(\frac{x}{y} - x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -2.9000000000000002e-6Initial program 81.7%
associate-/l*99.8%
Simplified99.8%
clear-num99.6%
un-div-inv99.9%
Applied egg-rr99.9%
Taylor expanded in y around 0 75.8%
associate-/r/75.7%
associate-*l/67.2%
+-commutative67.2%
*-commutative67.2%
frac-times80.3%
Applied egg-rr80.3%
if -2.9000000000000002e-6 < x < 1Initial program 99.8%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around 0 99.6%
Taylor expanded in y around inf 99.7%
neg-mul-199.7%
+-commutative99.7%
unsub-neg99.7%
Simplified99.7%
if 1 < x Initial program 71.0%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around inf 78.5%
Final simplification90.6%
(FPCore (x y) :precision binary64 (if (or (<= x -1.0) (not (<= x 0.8))) (/ x y) (* x (- 1.0 x))))
double code(double x, double y) {
double tmp;
if ((x <= -1.0) || !(x <= 0.8)) {
tmp = x / y;
} else {
tmp = x * (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 <= (-1.0d0)) .or. (.not. (x <= 0.8d0))) then
tmp = x / y
else
tmp = x * (1.0d0 - x)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -1.0) || !(x <= 0.8)) {
tmp = x / y;
} else {
tmp = x * (1.0 - x);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -1.0) or not (x <= 0.8): tmp = x / y else: tmp = x * (1.0 - x) return tmp
function code(x, y) tmp = 0.0 if ((x <= -1.0) || !(x <= 0.8)) tmp = Float64(x / y); else tmp = Float64(x * Float64(1.0 - x)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -1.0) || ~((x <= 0.8))) tmp = x / y; else tmp = x * (1.0 - x); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -1.0], N[Not[LessEqual[x, 0.8]], $MachinePrecision]], N[(x / y), $MachinePrecision], N[(x * N[(1.0 - x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 0.8\right):\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - x\right)\\
\end{array}
\end{array}
if x < -1 or 0.80000000000000004 < x Initial program 76.3%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around inf 78.2%
if -1 < x < 0.80000000000000004Initial program 99.8%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around inf 70.1%
Taylor expanded in x around 0 70.0%
neg-mul-170.0%
sub-neg70.0%
Simplified70.0%
Final simplification73.6%
(FPCore (x y) :precision binary64 (if (or (<= x -1.0) (not (<= x 5.8e+16))) (/ x y) x))
double code(double x, double y) {
double tmp;
if ((x <= -1.0) || !(x <= 5.8e+16)) {
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 <= 5.8d+16))) 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 <= 5.8e+16)) {
tmp = x / y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -1.0) or not (x <= 5.8e+16): tmp = x / y else: tmp = x return tmp
function code(x, y) tmp = 0.0 if ((x <= -1.0) || !(x <= 5.8e+16)) 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 <= 5.8e+16))) tmp = x / y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -1.0], N[Not[LessEqual[x, 5.8e+16]], $MachinePrecision]], N[(x / y), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 5.8 \cdot 10^{+16}\right):\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -1 or 5.8e16 < x Initial program 75.8%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around inf 79.5%
if -1 < x < 5.8e16Initial program 99.8%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around 0 68.3%
Final simplification73.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 89.3%
associate-/l*99.8%
Simplified99.8%
Final simplification99.8%
(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 89.3%
associate-/l*99.8%
Simplified99.8%
clear-num99.7%
un-div-inv99.9%
Applied egg-rr99.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 89.3%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around 0 40.1%
Final simplification40.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 2024115
(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)))