
(FPCore (x y) :precision binary64 (/ (* x (+ (/ x y) 1.0)) (+ x 1.0)))
double code(double x, double y) {
return (x * ((x / y) + 1.0)) / (x + 1.0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x * ((x / y) + 1.0d0)) / (x + 1.0d0)
end function
public static double code(double x, double y) {
return (x * ((x / y) + 1.0)) / (x + 1.0);
}
def code(x, y): return (x * ((x / y) + 1.0)) / (x + 1.0)
function code(x, y) return Float64(Float64(x * Float64(Float64(x / y) + 1.0)) / Float64(x + 1.0)) end
function tmp = code(x, y) tmp = (x * ((x / y) + 1.0)) / (x + 1.0); end
code[x_, y_] := N[(N[(x * N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (/ (* x (+ (/ x y) 1.0)) (+ x 1.0)))
double code(double x, double y) {
return (x * ((x / y) + 1.0)) / (x + 1.0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x * ((x / y) + 1.0d0)) / (x + 1.0d0)
end function
public static double code(double x, double y) {
return (x * ((x / y) + 1.0)) / (x + 1.0);
}
def code(x, y): return (x * ((x / y) + 1.0)) / (x + 1.0)
function code(x, y) return Float64(Float64(x * Float64(Float64(x / y) + 1.0)) / Float64(x + 1.0)) end
function tmp = code(x, y) tmp = (x * ((x / y) + 1.0)) / (x + 1.0); end
code[x_, y_] := N[(N[(x * N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1}
\end{array}
(FPCore (x y) :precision binary64 (* (+ (/ x y) 1.0) (/ x (+ x 1.0))))
double code(double x, double y) {
return ((x / y) + 1.0) * (x / (x + 1.0));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((x / y) + 1.0d0) * (x / (x + 1.0d0))
end function
public static double code(double x, double y) {
return ((x / y) + 1.0) * (x / (x + 1.0));
}
def code(x, y): return ((x / y) + 1.0) * (x / (x + 1.0))
function code(x, y) return Float64(Float64(Float64(x / y) + 1.0) * Float64(x / Float64(x + 1.0))) end
function tmp = code(x, y) tmp = ((x / y) + 1.0) * (x / (x + 1.0)); end
code[x_, y_] := N[(N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision] * N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\frac{x}{y} + 1\right) \cdot \frac{x}{x + 1}
\end{array}
Initial program 88.9%
*-commutative88.9%
associate-/l*99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ x (+ x 1.0))))
(if (<= x -1.2e+15)
(/ x y)
(if (<= x 2.3e-85)
t_0
(if (<= x 4.2e-22)
(* x (- (/ x y) x))
(if (<= x 3.75e+62) t_0 (/ x y)))))))
double code(double x, double y) {
double t_0 = x / (x + 1.0);
double tmp;
if (x <= -1.2e+15) {
tmp = x / y;
} else if (x <= 2.3e-85) {
tmp = t_0;
} else if (x <= 4.2e-22) {
tmp = x * ((x / y) - x);
} else if (x <= 3.75e+62) {
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 <= (-1.2d+15)) then
tmp = x / y
else if (x <= 2.3d-85) then
tmp = t_0
else if (x <= 4.2d-22) then
tmp = x * ((x / y) - x)
else if (x <= 3.75d+62) 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 <= -1.2e+15) {
tmp = x / y;
} else if (x <= 2.3e-85) {
tmp = t_0;
} else if (x <= 4.2e-22) {
tmp = x * ((x / y) - x);
} else if (x <= 3.75e+62) {
tmp = t_0;
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): t_0 = x / (x + 1.0) tmp = 0 if x <= -1.2e+15: tmp = x / y elif x <= 2.3e-85: tmp = t_0 elif x <= 4.2e-22: tmp = x * ((x / y) - x) elif x <= 3.75e+62: 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 <= -1.2e+15) tmp = Float64(x / y); elseif (x <= 2.3e-85) tmp = t_0; elseif (x <= 4.2e-22) tmp = Float64(x * Float64(Float64(x / y) - x)); elseif (x <= 3.75e+62) 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 <= -1.2e+15) tmp = x / y; elseif (x <= 2.3e-85) tmp = t_0; elseif (x <= 4.2e-22) tmp = x * ((x / y) - x); elseif (x <= 3.75e+62) 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, -1.2e+15], N[(x / y), $MachinePrecision], If[LessEqual[x, 2.3e-85], t$95$0, If[LessEqual[x, 4.2e-22], N[(x * N[(N[(x / y), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 3.75e+62], t$95$0, N[(x / y), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{x + 1}\\
\mathbf{if}\;x \leq -1.2 \cdot 10^{+15}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq 2.3 \cdot 10^{-85}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 4.2 \cdot 10^{-22}:\\
\;\;\;\;x \cdot \left(\frac{x}{y} - x\right)\\
\mathbf{elif}\;x \leq 3.75 \cdot 10^{+62}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -1.2e15 or 3.74999999999999999e62 < x Initial program 74.9%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around inf 79.1%
if -1.2e15 < x < 2.3e-85 or 4.20000000000000016e-22 < x < 3.74999999999999999e62Initial program 99.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around inf 74.2%
if 2.3e-85 < x < 4.20000000000000016e-22Initial program 99.6%
associate-/l*99.6%
Simplified99.6%
Taylor expanded in x around 0 99.5%
Taylor expanded in x around inf 65.3%
unpow265.3%
sub-neg65.3%
metadata-eval65.3%
associate-*l*65.1%
distribute-rgt-in65.1%
neg-mul-165.1%
unsub-neg65.1%
associate-*l/65.2%
*-lft-identity65.2%
Simplified65.2%
Final simplification75.8%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ (/ x y) 1.0)))
(if (<= x -126000.0)
t_0
(if (<= x 2.3e-85)
(/ x (+ x 1.0))
(if (<= x 0.0043) (* x (- (/ x y) x)) t_0)))))
double code(double x, double y) {
double t_0 = (x / y) + 1.0;
double tmp;
if (x <= -126000.0) {
tmp = t_0;
} else if (x <= 2.3e-85) {
tmp = x / (x + 1.0);
} else if (x <= 0.0043) {
tmp = x * ((x / y) - 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) + 1.0d0
if (x <= (-126000.0d0)) then
tmp = t_0
else if (x <= 2.3d-85) then
tmp = x / (x + 1.0d0)
else if (x <= 0.0043d0) then
tmp = x * ((x / y) - x)
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 <= -126000.0) {
tmp = t_0;
} else if (x <= 2.3e-85) {
tmp = x / (x + 1.0);
} else if (x <= 0.0043) {
tmp = x * ((x / y) - x);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = (x / y) + 1.0 tmp = 0 if x <= -126000.0: tmp = t_0 elif x <= 2.3e-85: tmp = x / (x + 1.0) elif x <= 0.0043: tmp = x * ((x / y) - x) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(Float64(x / y) + 1.0) tmp = 0.0 if (x <= -126000.0) tmp = t_0; elseif (x <= 2.3e-85) tmp = Float64(x / Float64(x + 1.0)); elseif (x <= 0.0043) tmp = Float64(x * Float64(Float64(x / y) - x)); 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 <= -126000.0) tmp = t_0; elseif (x <= 2.3e-85) tmp = x / (x + 1.0); elseif (x <= 0.0043) tmp = x * ((x / y) - x); 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, -126000.0], t$95$0, If[LessEqual[x, 2.3e-85], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.0043], N[(x * N[(N[(x / y), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{y} + 1\\
\mathbf{if}\;x \leq -126000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 2.3 \cdot 10^{-85}:\\
\;\;\;\;\frac{x}{x + 1}\\
\mathbf{elif}\;x \leq 0.0043:\\
\;\;\;\;x \cdot \left(\frac{x}{y} - x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -126000 or 0.0043 < x Initial program 78.2%
*-commutative78.2%
associate-/l*100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 98.8%
if -126000 < x < 2.3e-85Initial program 99.9%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around inf 76.6%
if 2.3e-85 < x < 0.0043Initial program 99.6%
associate-/l*99.6%
Simplified99.6%
Taylor expanded in x around 0 96.5%
Taylor expanded in x around inf 60.6%
unpow260.6%
sub-neg60.6%
metadata-eval60.6%
associate-*l*60.5%
distribute-rgt-in60.5%
neg-mul-160.5%
unsub-neg60.5%
associate-*l/60.5%
*-lft-identity60.5%
Simplified60.5%
Final simplification86.7%
(FPCore (x y) :precision binary64 (if (or (<= x -1.0) (not (<= x 0.86))) (+ (/ x y) 1.0) (* x (+ (/ x y) (- 1.0 x)))))
double code(double x, double y) {
double tmp;
if ((x <= -1.0) || !(x <= 0.86)) {
tmp = (x / y) + 1.0;
} else {
tmp = x * ((x / y) + (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.86d0))) then
tmp = (x / y) + 1.0d0
else
tmp = x * ((x / y) + (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.86)) {
tmp = (x / y) + 1.0;
} else {
tmp = x * ((x / y) + (1.0 - x));
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -1.0) or not (x <= 0.86): tmp = (x / y) + 1.0 else: tmp = x * ((x / y) + (1.0 - x)) return tmp
function code(x, y) tmp = 0.0 if ((x <= -1.0) || !(x <= 0.86)) tmp = Float64(Float64(x / y) + 1.0); else tmp = Float64(x * Float64(Float64(x / y) + Float64(1.0 - x))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -1.0) || ~((x <= 0.86))) tmp = (x / y) + 1.0; else tmp = x * ((x / y) + (1.0 - x)); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -1.0], N[Not[LessEqual[x, 0.86]], $MachinePrecision]], N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision], N[(x * N[(N[(x / y), $MachinePrecision] + N[(1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 0.86\right):\\
\;\;\;\;\frac{x}{y} + 1\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\frac{x}{y} + \left(1 - x\right)\right)\\
\end{array}
\end{array}
if x < -1 or 0.859999999999999987 < x Initial program 78.7%
*-commutative78.7%
associate-/l*100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 97.4%
if -1 < x < 0.859999999999999987Initial program 99.8%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around 0 98.6%
Taylor expanded in y around 0 98.6%
neg-mul-198.6%
associate-+r+98.6%
sub-neg98.6%
Simplified98.6%
Final simplification98.0%
(FPCore (x y) :precision binary64 (if (or (<= x -1.0) (not (<= x 1.0))) (+ (+ (/ x y) 1.0) (/ -1.0 y)) (* x (+ (/ x y) (- 1.0 x)))))
double code(double x, double y) {
double tmp;
if ((x <= -1.0) || !(x <= 1.0)) {
tmp = ((x / y) + 1.0) + (-1.0 / y);
} else {
tmp = x * ((x / y) + (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 <= 1.0d0))) then
tmp = ((x / y) + 1.0d0) + ((-1.0d0) / y)
else
tmp = x * ((x / y) + (1.0d0 - x))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -1.0) || !(x <= 1.0)) {
tmp = ((x / y) + 1.0) + (-1.0 / y);
} else {
tmp = x * ((x / y) + (1.0 - x));
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -1.0) or not (x <= 1.0): tmp = ((x / y) + 1.0) + (-1.0 / y) else: tmp = x * ((x / y) + (1.0 - x)) return tmp
function code(x, y) tmp = 0.0 if ((x <= -1.0) || !(x <= 1.0)) tmp = Float64(Float64(Float64(x / y) + 1.0) + Float64(-1.0 / y)); else tmp = Float64(x * Float64(Float64(x / y) + Float64(1.0 - x))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -1.0) || ~((x <= 1.0))) tmp = ((x / y) + 1.0) + (-1.0 / y); else tmp = x * ((x / y) + (1.0 - x)); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -1.0], N[Not[LessEqual[x, 1.0]], $MachinePrecision]], N[(N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision] + N[(-1.0 / y), $MachinePrecision]), $MachinePrecision], N[(x * N[(N[(x / y), $MachinePrecision] + N[(1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 1\right):\\
\;\;\;\;\left(\frac{x}{y} + 1\right) + \frac{-1}{y}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\frac{x}{y} + \left(1 - x\right)\right)\\
\end{array}
\end{array}
if x < -1 or 1 < x Initial program 78.7%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around inf 97.9%
if -1 < x < 1Initial program 99.8%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around 0 98.6%
Taylor expanded in y around 0 98.6%
neg-mul-198.6%
associate-+r+98.6%
sub-neg98.6%
Simplified98.6%
Final simplification98.2%
(FPCore (x y) :precision binary64 (if (or (<= x -1.12e+17) (not (<= x 3.5e+62))) (/ x y) (/ x (+ x 1.0))))
double code(double x, double y) {
double tmp;
if ((x <= -1.12e+17) || !(x <= 3.5e+62)) {
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 <= (-1.12d+17)) .or. (.not. (x <= 3.5d+62))) 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 <= -1.12e+17) || !(x <= 3.5e+62)) {
tmp = x / y;
} else {
tmp = x / (x + 1.0);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -1.12e+17) or not (x <= 3.5e+62): tmp = x / y else: tmp = x / (x + 1.0) return tmp
function code(x, y) tmp = 0.0 if ((x <= -1.12e+17) || !(x <= 3.5e+62)) 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 <= -1.12e+17) || ~((x <= 3.5e+62))) tmp = x / y; else tmp = x / (x + 1.0); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -1.12e+17], N[Not[LessEqual[x, 3.5e+62]], $MachinePrecision]], N[(x / y), $MachinePrecision], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.12 \cdot 10^{+17} \lor \neg \left(x \leq 3.5 \cdot 10^{+62}\right):\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{x + 1}\\
\end{array}
\end{array}
if x < -1.12e17 or 3.49999999999999984e62 < x Initial program 74.9%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around inf 79.1%
if -1.12e17 < x < 3.49999999999999984e62Initial program 99.8%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around inf 69.3%
Final simplification73.6%
(FPCore (x y) :precision binary64 (if (or (<= x -1.0) (not (<= x 56.0))) (/ x y) x))
double code(double x, double y) {
double tmp;
if ((x <= -1.0) || !(x <= 56.0)) {
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 <= 56.0d0))) 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 <= 56.0)) {
tmp = x / y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -1.0) or not (x <= 56.0): tmp = x / y else: tmp = x return tmp
function code(x, y) tmp = 0.0 if ((x <= -1.0) || !(x <= 56.0)) 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 <= 56.0))) tmp = x / y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -1.0], N[Not[LessEqual[x, 56.0]], $MachinePrecision]], N[(x / y), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 56\right):\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -1 or 56 < x Initial program 78.5%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around inf 72.2%
if -1 < x < 56Initial program 99.8%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around 0 69.3%
Final simplification70.8%
(FPCore (x y) :precision binary64 (* x (/ (+ (/ x y) 1.0) (+ x 1.0))))
double code(double x, double y) {
return x * (((x / y) + 1.0) / (x + 1.0));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x * (((x / y) + 1.0d0) / (x + 1.0d0))
end function
public static double code(double x, double y) {
return x * (((x / y) + 1.0) / (x + 1.0));
}
def code(x, y): return x * (((x / y) + 1.0) / (x + 1.0))
function code(x, y) return Float64(x * Float64(Float64(Float64(x / y) + 1.0) / Float64(x + 1.0))) end
function tmp = code(x, y) tmp = x * (((x / y) + 1.0) / (x + 1.0)); end
code[x_, y_] := N[(x * N[(N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \frac{\frac{x}{y} + 1}{x + 1}
\end{array}
Initial program 88.9%
associate-/l*99.8%
Simplified99.8%
Final simplification99.8%
(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 88.9%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around 0 35.8%
Final simplification35.8%
(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 2024039
(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)))