
(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 8 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 92.2%
associate-/l*99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ 1.0 (/ (+ x -1.0) y))) (t_1 (/ x (+ x 1.0))))
(if (<= x -3300000000000.0)
t_0
(if (<= x 2.8e-40)
t_1
(if (<= x 500000000000.0)
(/ x (+ y (/ y x)))
(if (<= x 3e+15) t_1 t_0))))))
double code(double x, double y) {
double t_0 = 1.0 + ((x + -1.0) / y);
double t_1 = x / (x + 1.0);
double tmp;
if (x <= -3300000000000.0) {
tmp = t_0;
} else if (x <= 2.8e-40) {
tmp = t_1;
} else if (x <= 500000000000.0) {
tmp = x / (y + (y / x));
} else if (x <= 3e+15) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 1.0d0 + ((x + (-1.0d0)) / y)
t_1 = x / (x + 1.0d0)
if (x <= (-3300000000000.0d0)) then
tmp = t_0
else if (x <= 2.8d-40) then
tmp = t_1
else if (x <= 500000000000.0d0) then
tmp = x / (y + (y / x))
else if (x <= 3d+15) then
tmp = t_1
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = 1.0 + ((x + -1.0) / y);
double t_1 = x / (x + 1.0);
double tmp;
if (x <= -3300000000000.0) {
tmp = t_0;
} else if (x <= 2.8e-40) {
tmp = t_1;
} else if (x <= 500000000000.0) {
tmp = x / (y + (y / x));
} else if (x <= 3e+15) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 + ((x + -1.0) / y) t_1 = x / (x + 1.0) tmp = 0 if x <= -3300000000000.0: tmp = t_0 elif x <= 2.8e-40: tmp = t_1 elif x <= 500000000000.0: tmp = x / (y + (y / x)) elif x <= 3e+15: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(1.0 + Float64(Float64(x + -1.0) / y)) t_1 = Float64(x / Float64(x + 1.0)) tmp = 0.0 if (x <= -3300000000000.0) tmp = t_0; elseif (x <= 2.8e-40) tmp = t_1; elseif (x <= 500000000000.0) tmp = Float64(x / Float64(y + Float64(y / x))); elseif (x <= 3e+15) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 + ((x + -1.0) / y); t_1 = x / (x + 1.0); tmp = 0.0; if (x <= -3300000000000.0) tmp = t_0; elseif (x <= 2.8e-40) tmp = t_1; elseif (x <= 500000000000.0) tmp = x / (y + (y / x)); elseif (x <= 3e+15) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(1.0 + N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -3300000000000.0], t$95$0, If[LessEqual[x, 2.8e-40], t$95$1, If[LessEqual[x, 500000000000.0], N[(x / N[(y + N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 3e+15], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{x + -1}{y}\\
t_1 := \frac{x}{x + 1}\\
\mathbf{if}\;x \leq -3300000000000:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 2.8 \cdot 10^{-40}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 500000000000:\\
\;\;\;\;\frac{x}{y + \frac{y}{x}}\\
\mathbf{elif}\;x \leq 3 \cdot 10^{+15}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -3.3e12 or 3e15 < x Initial program 84.3%
distribute-lft-in84.3%
*-rgt-identity84.3%
Applied egg-rr84.3%
Taylor expanded in x around inf 100.0%
+-commutative100.0%
associate-+r-100.0%
+-commutative100.0%
associate-+l-100.0%
div-sub100.0%
Simplified100.0%
if -3.3e12 < x < 2.8e-40 or 5e11 < x < 3e15Initial program 99.9%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around inf 79.8%
if 2.8e-40 < x < 5e11Initial program 99.4%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in y around 0 100.0%
Taylor expanded in x around 0 99.7%
Final simplification90.1%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ 1.0 (/ (+ x -1.0) y))) (t_1 (/ x (+ x 1.0))))
(if (<= x -3300000000000.0)
t_0
(if (<= x 5.5e-41)
t_1
(if (<= x 245000000000.0)
(/ x (/ (* y (+ x 1.0)) x))
(if (<= x 3e+15) t_1 t_0))))))
double code(double x, double y) {
double t_0 = 1.0 + ((x + -1.0) / y);
double t_1 = x / (x + 1.0);
double tmp;
if (x <= -3300000000000.0) {
tmp = t_0;
} else if (x <= 5.5e-41) {
tmp = t_1;
} else if (x <= 245000000000.0) {
tmp = x / ((y * (x + 1.0)) / x);
} else if (x <= 3e+15) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 1.0d0 + ((x + (-1.0d0)) / y)
t_1 = x / (x + 1.0d0)
if (x <= (-3300000000000.0d0)) then
tmp = t_0
else if (x <= 5.5d-41) then
tmp = t_1
else if (x <= 245000000000.0d0) then
tmp = x / ((y * (x + 1.0d0)) / x)
else if (x <= 3d+15) then
tmp = t_1
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = 1.0 + ((x + -1.0) / y);
double t_1 = x / (x + 1.0);
double tmp;
if (x <= -3300000000000.0) {
tmp = t_0;
} else if (x <= 5.5e-41) {
tmp = t_1;
} else if (x <= 245000000000.0) {
tmp = x / ((y * (x + 1.0)) / x);
} else if (x <= 3e+15) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 + ((x + -1.0) / y) t_1 = x / (x + 1.0) tmp = 0 if x <= -3300000000000.0: tmp = t_0 elif x <= 5.5e-41: tmp = t_1 elif x <= 245000000000.0: tmp = x / ((y * (x + 1.0)) / x) elif x <= 3e+15: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(1.0 + Float64(Float64(x + -1.0) / y)) t_1 = Float64(x / Float64(x + 1.0)) tmp = 0.0 if (x <= -3300000000000.0) tmp = t_0; elseif (x <= 5.5e-41) tmp = t_1; elseif (x <= 245000000000.0) tmp = Float64(x / Float64(Float64(y * Float64(x + 1.0)) / x)); elseif (x <= 3e+15) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 + ((x + -1.0) / y); t_1 = x / (x + 1.0); tmp = 0.0; if (x <= -3300000000000.0) tmp = t_0; elseif (x <= 5.5e-41) tmp = t_1; elseif (x <= 245000000000.0) tmp = x / ((y * (x + 1.0)) / x); elseif (x <= 3e+15) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(1.0 + N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -3300000000000.0], t$95$0, If[LessEqual[x, 5.5e-41], t$95$1, If[LessEqual[x, 245000000000.0], N[(x / N[(N[(y * N[(x + 1.0), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 3e+15], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{x + -1}{y}\\
t_1 := \frac{x}{x + 1}\\
\mathbf{if}\;x \leq -3300000000000:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 5.5 \cdot 10^{-41}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 245000000000:\\
\;\;\;\;\frac{x}{\frac{y \cdot \left(x + 1\right)}{x}}\\
\mathbf{elif}\;x \leq 3 \cdot 10^{+15}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -3.3e12 or 3e15 < x Initial program 84.3%
distribute-lft-in84.3%
*-rgt-identity84.3%
Applied egg-rr84.3%
Taylor expanded in x around inf 100.0%
+-commutative100.0%
associate-+r-100.0%
+-commutative100.0%
associate-+l-100.0%
div-sub100.0%
Simplified100.0%
if -3.3e12 < x < 5.50000000000000022e-41 or 2.45e11 < x < 3e15Initial program 99.9%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around inf 79.8%
if 5.50000000000000022e-41 < x < 2.45e11Initial program 99.4%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in y around 0 100.0%
Final simplification90.1%
(FPCore (x y) :precision binary64 (if (or (<= x -3300000000000.0) (not (<= x 13800.0))) (+ 1.0 (/ (+ x -1.0) y)) (/ x (+ x 1.0))))
double code(double x, double y) {
double tmp;
if ((x <= -3300000000000.0) || !(x <= 13800.0)) {
tmp = 1.0 + ((x + -1.0) / 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 <= (-3300000000000.0d0)) .or. (.not. (x <= 13800.0d0))) then
tmp = 1.0d0 + ((x + (-1.0d0)) / 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 <= -3300000000000.0) || !(x <= 13800.0)) {
tmp = 1.0 + ((x + -1.0) / y);
} else {
tmp = x / (x + 1.0);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -3300000000000.0) or not (x <= 13800.0): tmp = 1.0 + ((x + -1.0) / y) else: tmp = x / (x + 1.0) return tmp
function code(x, y) tmp = 0.0 if ((x <= -3300000000000.0) || !(x <= 13800.0)) tmp = Float64(1.0 + Float64(Float64(x + -1.0) / y)); else tmp = Float64(x / Float64(x + 1.0)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -3300000000000.0) || ~((x <= 13800.0))) tmp = 1.0 + ((x + -1.0) / y); else tmp = x / (x + 1.0); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -3300000000000.0], N[Not[LessEqual[x, 13800.0]], $MachinePrecision]], N[(1.0 + N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3300000000000 \lor \neg \left(x \leq 13800\right):\\
\;\;\;\;1 + \frac{x + -1}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{x + 1}\\
\end{array}
\end{array}
if x < -3.3e12 or 13800 < x Initial program 84.7%
distribute-lft-in84.7%
*-rgt-identity84.7%
Applied egg-rr84.7%
Taylor expanded in x around inf 99.8%
+-commutative99.8%
associate-+r-99.8%
+-commutative99.8%
associate-+l-99.8%
div-sub99.8%
Simplified99.8%
if -3.3e12 < x < 13800Initial program 99.9%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around inf 77.1%
Final simplification88.6%
(FPCore (x y) :precision binary64 (if (<= x -2.1e+21) (/ x y) (if (<= x 1.95e+18) (/ x (+ x 1.0)) (/ x y))))
double code(double x, double y) {
double tmp;
if (x <= -2.1e+21) {
tmp = x / y;
} else if (x <= 1.95e+18) {
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 <= (-2.1d+21)) then
tmp = x / y
else if (x <= 1.95d+18) 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 <= -2.1e+21) {
tmp = x / y;
} else if (x <= 1.95e+18) {
tmp = x / (x + 1.0);
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -2.1e+21: tmp = x / y elif x <= 1.95e+18: tmp = x / (x + 1.0) else: tmp = x / y return tmp
function code(x, y) tmp = 0.0 if (x <= -2.1e+21) tmp = Float64(x / y); elseif (x <= 1.95e+18) 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 <= -2.1e+21) tmp = x / y; elseif (x <= 1.95e+18) tmp = x / (x + 1.0); else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -2.1e+21], N[(x / y), $MachinePrecision], If[LessEqual[x, 1.95e+18], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], N[(x / y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.1 \cdot 10^{+21}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq 1.95 \cdot 10^{+18}:\\
\;\;\;\;\frac{x}{x + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -2.1e21 or 1.95e18 < x Initial program 84.2%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around inf 75.0%
if -2.1e21 < x < 1.95e18Initial program 99.9%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around inf 77.1%
Final simplification76.1%
(FPCore (x y) :precision binary64 (if (<= x -1.0) (/ x y) (if (<= x 3.6e-40) x (/ x y))))
double code(double x, double y) {
double tmp;
if (x <= -1.0) {
tmp = x / y;
} else if (x <= 3.6e-40) {
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 <= 3.6d-40) 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 <= 3.6e-40) {
tmp = x;
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.0: tmp = x / y elif x <= 3.6e-40: 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 <= 3.6e-40) 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 <= 3.6e-40) 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, 3.6e-40], x, N[(x / y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq 3.6 \cdot 10^{-40}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -1 or 3.6e-40 < x Initial program 85.2%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around inf 70.9%
if -1 < x < 3.6e-40Initial program 99.9%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around 0 79.0%
Final simplification74.7%
(FPCore (x y) :precision binary64 (if (<= x -1.0) 1.0 (if (<= x 3.6e-40) x 1.0)))
double code(double x, double y) {
double tmp;
if (x <= -1.0) {
tmp = 1.0;
} else if (x <= 3.6e-40) {
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 <= (-1.0d0)) then
tmp = 1.0d0
else if (x <= 3.6d-40) 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 <= -1.0) {
tmp = 1.0;
} else if (x <= 3.6e-40) {
tmp = x;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.0: tmp = 1.0 elif x <= 3.6e-40: tmp = x else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -1.0) tmp = 1.0; elseif (x <= 3.6e-40) tmp = x; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1.0) tmp = 1.0; elseif (x <= 3.6e-40) tmp = x; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.0], 1.0, If[LessEqual[x, 3.6e-40], x, 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 3.6 \cdot 10^{-40}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < -1 or 3.6e-40 < x Initial program 85.2%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in y around inf 27.5%
Taylor expanded in x around inf 27.2%
if -1 < x < 3.6e-40Initial program 99.9%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around 0 79.0%
Final simplification51.9%
(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 92.2%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around inf 52.2%
Taylor expanded in x around inf 16.1%
Final simplification16.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 2023257
(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)))