
(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 90.7%
*-commutative90.7%
associate-/l*99.9%
Applied egg-rr99.9%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ (/ x y) 1.0)) (t_1 (+ y (/ y x))))
(if (<= x -4.7e+28)
t_0
(if (<= x -8.5e-68)
(/ 1.0 (/ t_1 x))
(if (<= x 8.8e-64) x (if (<= x 0.000195) (/ x t_1) t_0))))))
double code(double x, double y) {
double t_0 = (x / y) + 1.0;
double t_1 = y + (y / x);
double tmp;
if (x <= -4.7e+28) {
tmp = t_0;
} else if (x <= -8.5e-68) {
tmp = 1.0 / (t_1 / x);
} else if (x <= 8.8e-64) {
tmp = x;
} else if (x <= 0.000195) {
tmp = x / 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 = (x / y) + 1.0d0
t_1 = y + (y / x)
if (x <= (-4.7d+28)) then
tmp = t_0
else if (x <= (-8.5d-68)) then
tmp = 1.0d0 / (t_1 / x)
else if (x <= 8.8d-64) then
tmp = x
else if (x <= 0.000195d0) then
tmp = x / t_1
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 t_1 = y + (y / x);
double tmp;
if (x <= -4.7e+28) {
tmp = t_0;
} else if (x <= -8.5e-68) {
tmp = 1.0 / (t_1 / x);
} else if (x <= 8.8e-64) {
tmp = x;
} else if (x <= 0.000195) {
tmp = x / t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = (x / y) + 1.0 t_1 = y + (y / x) tmp = 0 if x <= -4.7e+28: tmp = t_0 elif x <= -8.5e-68: tmp = 1.0 / (t_1 / x) elif x <= 8.8e-64: tmp = x elif x <= 0.000195: tmp = x / t_1 else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(Float64(x / y) + 1.0) t_1 = Float64(y + Float64(y / x)) tmp = 0.0 if (x <= -4.7e+28) tmp = t_0; elseif (x <= -8.5e-68) tmp = Float64(1.0 / Float64(t_1 / x)); elseif (x <= 8.8e-64) tmp = x; elseif (x <= 0.000195) tmp = Float64(x / t_1); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = (x / y) + 1.0; t_1 = y + (y / x); tmp = 0.0; if (x <= -4.7e+28) tmp = t_0; elseif (x <= -8.5e-68) tmp = 1.0 / (t_1 / x); elseif (x <= 8.8e-64) tmp = x; elseif (x <= 0.000195) tmp = x / t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]}, Block[{t$95$1 = N[(y + N[(y / x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -4.7e+28], t$95$0, If[LessEqual[x, -8.5e-68], N[(1.0 / N[(t$95$1 / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 8.8e-64], x, If[LessEqual[x, 0.000195], N[(x / t$95$1), $MachinePrecision], t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{y} + 1\\
t_1 := y + \frac{y}{x}\\
\mathbf{if}\;x \leq -4.7 \cdot 10^{+28}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -8.5 \cdot 10^{-68}:\\
\;\;\;\;\frac{1}{\frac{t\_1}{x}}\\
\mathbf{elif}\;x \leq 8.8 \cdot 10^{-64}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 0.000195:\\
\;\;\;\;\frac{x}{t\_1}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -4.69999999999999965e28 or 1.94999999999999996e-4 < x Initial program 81.6%
*-commutative81.6%
associate-/l*100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 97.7%
if -4.69999999999999965e28 < x < -8.50000000000000026e-68Initial program 99.7%
associate-/l*99.5%
Simplified99.5%
clear-num99.5%
un-div-inv99.5%
Applied egg-rr99.5%
add-cbrt-cube66.1%
pow366.0%
Applied egg-rr66.0%
rem-cbrt-cube99.5%
clear-num99.8%
inv-pow99.8%
associate-/l/99.7%
+-commutative99.7%
Applied egg-rr99.7%
unpow-199.7%
associate-/r*99.5%
*-lft-identity99.5%
associate-*l/99.5%
distribute-rgt-in99.5%
rgt-mult-inverse99.5%
*-lft-identity99.5%
Simplified99.5%
Taylor expanded in y around 0 70.7%
distribute-lft-in70.7%
*-rgt-identity70.7%
associate-*r/70.9%
*-rgt-identity70.9%
Simplified70.9%
if -8.50000000000000026e-68 < x < 8.7999999999999998e-64Initial program 99.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around 0 81.0%
if 8.7999999999999998e-64 < x < 1.94999999999999996e-4Initial program 99.6%
associate-/l*99.4%
Simplified99.4%
clear-num99.4%
un-div-inv99.7%
Applied egg-rr99.7%
add-cbrt-cube49.5%
pow349.6%
Applied egg-rr49.6%
rem-cbrt-cube99.7%
clear-num99.5%
inv-pow99.5%
associate-/l/99.4%
+-commutative99.4%
Applied egg-rr99.4%
unpow-199.4%
associate-/r*99.1%
*-lft-identity99.1%
associate-*l/99.2%
distribute-rgt-in99.2%
rgt-mult-inverse99.2%
*-lft-identity99.2%
Simplified99.2%
Taylor expanded in y around 0 80.6%
distribute-lft-in80.6%
*-rgt-identity80.6%
associate-*r/80.5%
*-rgt-identity80.5%
Simplified80.5%
Final simplification88.6%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ (/ x y) 1.0)) (t_1 (/ x (+ y (/ y x)))))
(if (<= x -4.7e+28)
t_0
(if (<= x -7.4e-68)
t_1
(if (<= x 1.8e-66) x (if (<= x 0.000195) t_1 t_0))))))
double code(double x, double y) {
double t_0 = (x / y) + 1.0;
double t_1 = x / (y + (y / x));
double tmp;
if (x <= -4.7e+28) {
tmp = t_0;
} else if (x <= -7.4e-68) {
tmp = t_1;
} else if (x <= 1.8e-66) {
tmp = x;
} else if (x <= 0.000195) {
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 = (x / y) + 1.0d0
t_1 = x / (y + (y / x))
if (x <= (-4.7d+28)) then
tmp = t_0
else if (x <= (-7.4d-68)) then
tmp = t_1
else if (x <= 1.8d-66) then
tmp = x
else if (x <= 0.000195d0) 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 = (x / y) + 1.0;
double t_1 = x / (y + (y / x));
double tmp;
if (x <= -4.7e+28) {
tmp = t_0;
} else if (x <= -7.4e-68) {
tmp = t_1;
} else if (x <= 1.8e-66) {
tmp = x;
} else if (x <= 0.000195) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = (x / y) + 1.0 t_1 = x / (y + (y / x)) tmp = 0 if x <= -4.7e+28: tmp = t_0 elif x <= -7.4e-68: tmp = t_1 elif x <= 1.8e-66: tmp = x elif x <= 0.000195: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(Float64(x / y) + 1.0) t_1 = Float64(x / Float64(y + Float64(y / x))) tmp = 0.0 if (x <= -4.7e+28) tmp = t_0; elseif (x <= -7.4e-68) tmp = t_1; elseif (x <= 1.8e-66) tmp = x; elseif (x <= 0.000195) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = (x / y) + 1.0; t_1 = x / (y + (y / x)); tmp = 0.0; if (x <= -4.7e+28) tmp = t_0; elseif (x <= -7.4e-68) tmp = t_1; elseif (x <= 1.8e-66) tmp = x; elseif (x <= 0.000195) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]}, Block[{t$95$1 = N[(x / N[(y + N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -4.7e+28], t$95$0, If[LessEqual[x, -7.4e-68], t$95$1, If[LessEqual[x, 1.8e-66], x, If[LessEqual[x, 0.000195], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{y} + 1\\
t_1 := \frac{x}{y + \frac{y}{x}}\\
\mathbf{if}\;x \leq -4.7 \cdot 10^{+28}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -7.4 \cdot 10^{-68}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 1.8 \cdot 10^{-66}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 0.000195:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -4.69999999999999965e28 or 1.94999999999999996e-4 < x Initial program 81.6%
*-commutative81.6%
associate-/l*100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 97.7%
if -4.69999999999999965e28 < x < -7.40000000000000004e-68 or 1.80000000000000006e-66 < x < 1.94999999999999996e-4Initial program 99.6%
associate-/l*99.5%
Simplified99.5%
clear-num99.4%
un-div-inv99.6%
Applied egg-rr99.6%
add-cbrt-cube59.0%
pow359.0%
Applied egg-rr59.0%
rem-cbrt-cube99.6%
clear-num99.6%
inv-pow99.6%
associate-/l/99.6%
+-commutative99.6%
Applied egg-rr99.6%
unpow-199.6%
associate-/r*99.4%
*-lft-identity99.4%
associate-*l/99.4%
distribute-rgt-in99.3%
rgt-mult-inverse99.4%
*-lft-identity99.4%
Simplified99.4%
Taylor expanded in y around 0 74.8%
distribute-lft-in74.9%
*-rgt-identity74.9%
associate-*r/75.0%
*-rgt-identity75.0%
Simplified75.0%
if -7.40000000000000004e-68 < x < 1.80000000000000006e-66Initial program 99.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around 0 81.0%
Final simplification88.6%
(FPCore (x y) :precision binary64 (if (or (<= x -1.0) (not (<= x 0.8))) (+ (/ x y) 1.0) (* x (+ 1.0 (* x (+ (/ 1.0 y) -1.0))))))
double code(double x, double y) {
double tmp;
if ((x <= -1.0) || !(x <= 0.8)) {
tmp = (x / y) + 1.0;
} else {
tmp = x * (1.0 + (x * ((1.0 / 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 <= 0.8d0))) then
tmp = (x / y) + 1.0d0
else
tmp = x * (1.0d0 + (x * ((1.0d0 / y) + (-1.0d0))))
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) + 1.0;
} else {
tmp = x * (1.0 + (x * ((1.0 / y) + -1.0)));
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -1.0) or not (x <= 0.8): tmp = (x / y) + 1.0 else: tmp = x * (1.0 + (x * ((1.0 / y) + -1.0))) return tmp
function code(x, y) tmp = 0.0 if ((x <= -1.0) || !(x <= 0.8)) tmp = Float64(Float64(x / y) + 1.0); else tmp = Float64(x * Float64(1.0 + Float64(x * Float64(Float64(1.0 / y) + -1.0)))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -1.0) || ~((x <= 0.8))) tmp = (x / y) + 1.0; else tmp = x * (1.0 + (x * ((1.0 / y) + -1.0))); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -1.0], N[Not[LessEqual[x, 0.8]], $MachinePrecision]], N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision], N[(x * N[(1.0 + N[(x * N[(N[(1.0 / y), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 0.8\right):\\
\;\;\;\;\frac{x}{y} + 1\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 + x \cdot \left(\frac{1}{y} + -1\right)\right)\\
\end{array}
\end{array}
if x < -1 or 0.80000000000000004 < x Initial program 82.0%
*-commutative82.0%
associate-/l*100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 97.9%
if -1 < x < 0.80000000000000004Initial program 99.8%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around 0 98.3%
Final simplification98.1%
(FPCore (x y) :precision binary64 (if (or (<= x -750.0) (not (<= x 42000000.0))) (+ (/ x y) 1.0) (/ x (+ x 1.0))))
double code(double x, double y) {
double tmp;
if ((x <= -750.0) || !(x <= 42000000.0)) {
tmp = (x / y) + 1.0;
} 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 <= (-750.0d0)) .or. (.not. (x <= 42000000.0d0))) then
tmp = (x / y) + 1.0d0
else
tmp = x / (x + 1.0d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -750.0) || !(x <= 42000000.0)) {
tmp = (x / y) + 1.0;
} else {
tmp = x / (x + 1.0);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -750.0) or not (x <= 42000000.0): tmp = (x / y) + 1.0 else: tmp = x / (x + 1.0) return tmp
function code(x, y) tmp = 0.0 if ((x <= -750.0) || !(x <= 42000000.0)) tmp = Float64(Float64(x / y) + 1.0); else tmp = Float64(x / Float64(x + 1.0)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -750.0) || ~((x <= 42000000.0))) tmp = (x / y) + 1.0; else tmp = x / (x + 1.0); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -750.0], N[Not[LessEqual[x, 42000000.0]], $MachinePrecision]], N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -750 \lor \neg \left(x \leq 42000000\right):\\
\;\;\;\;\frac{x}{y} + 1\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{x + 1}\\
\end{array}
\end{array}
if x < -750 or 4.2e7 < x Initial program 81.9%
*-commutative81.9%
associate-/l*100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 98.2%
if -750 < x < 4.2e7Initial program 99.8%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around inf 69.7%
Final simplification84.2%
(FPCore (x y) :precision binary64 (if (or (<= x -750.0) (not (<= x 1.55e+103))) (/ x y) (/ x (+ x 1.0))))
double code(double x, double y) {
double tmp;
if ((x <= -750.0) || !(x <= 1.55e+103)) {
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 <= (-750.0d0)) .or. (.not. (x <= 1.55d+103))) 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 <= -750.0) || !(x <= 1.55e+103)) {
tmp = x / y;
} else {
tmp = x / (x + 1.0);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -750.0) or not (x <= 1.55e+103): tmp = x / y else: tmp = x / (x + 1.0) return tmp
function code(x, y) tmp = 0.0 if ((x <= -750.0) || !(x <= 1.55e+103)) 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 <= -750.0) || ~((x <= 1.55e+103))) tmp = x / y; else tmp = x / (x + 1.0); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -750.0], N[Not[LessEqual[x, 1.55e+103]], $MachinePrecision]], N[(x / y), $MachinePrecision], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -750 \lor \neg \left(x \leq 1.55 \cdot 10^{+103}\right):\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{x + 1}\\
\end{array}
\end{array}
if x < -750 or 1.5500000000000001e103 < x Initial program 78.2%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around inf 72.1%
if -750 < x < 1.5500000000000001e103Initial program 99.2%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around inf 66.5%
Final simplification68.8%
(FPCore (x y) :precision binary64 (if (or (<= x -1.0) (not (<= x 14200000.0))) (/ x y) x))
double code(double x, double y) {
double tmp;
if ((x <= -1.0) || !(x <= 14200000.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 <= 14200000.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 <= 14200000.0)) {
tmp = x / y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -1.0) or not (x <= 14200000.0): tmp = x / y else: tmp = x return tmp
function code(x, y) tmp = 0.0 if ((x <= -1.0) || !(x <= 14200000.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 <= 14200000.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, 14200000.0]], $MachinePrecision]], N[(x / y), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 14200000\right):\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -1 or 1.42e7 < x Initial program 81.9%
associate-/l*99.7%
Simplified99.7%
Taylor expanded in x around inf 65.7%
if -1 < x < 1.42e7Initial program 99.8%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around 0 67.6%
Final simplification66.7%
(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 90.7%
associate-/l*99.8%
Simplified99.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 90.7%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around 0 35.2%
(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 2024091
(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)))