
(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 10 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 88.6%
associate-/l*99.9%
Simplified99.9%
clear-num99.8%
un-div-inv99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x y)
:precision binary64
(if (<= x -8.6e+70)
(/ x y)
(if (<= x -1.0)
1.0
(if (<= x 0.125) (* x (- 1.0 x)) (if (<= x 5e+131) 1.0 (/ x y))))))
double code(double x, double y) {
double tmp;
if (x <= -8.6e+70) {
tmp = x / y;
} else if (x <= -1.0) {
tmp = 1.0;
} else if (x <= 0.125) {
tmp = x * (1.0 - x);
} else if (x <= 5e+131) {
tmp = 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 <= (-8.6d+70)) then
tmp = x / y
else if (x <= (-1.0d0)) then
tmp = 1.0d0
else if (x <= 0.125d0) then
tmp = x * (1.0d0 - x)
else if (x <= 5d+131) then
tmp = 1.0d0
else
tmp = x / y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -8.6e+70) {
tmp = x / y;
} else if (x <= -1.0) {
tmp = 1.0;
} else if (x <= 0.125) {
tmp = x * (1.0 - x);
} else if (x <= 5e+131) {
tmp = 1.0;
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -8.6e+70: tmp = x / y elif x <= -1.0: tmp = 1.0 elif x <= 0.125: tmp = x * (1.0 - x) elif x <= 5e+131: tmp = 1.0 else: tmp = x / y return tmp
function code(x, y) tmp = 0.0 if (x <= -8.6e+70) tmp = Float64(x / y); elseif (x <= -1.0) tmp = 1.0; elseif (x <= 0.125) tmp = Float64(x * Float64(1.0 - x)); elseif (x <= 5e+131) tmp = 1.0; else tmp = Float64(x / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -8.6e+70) tmp = x / y; elseif (x <= -1.0) tmp = 1.0; elseif (x <= 0.125) tmp = x * (1.0 - x); elseif (x <= 5e+131) tmp = 1.0; else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -8.6e+70], N[(x / y), $MachinePrecision], If[LessEqual[x, -1.0], 1.0, If[LessEqual[x, 0.125], N[(x * N[(1.0 - x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 5e+131], 1.0, N[(x / y), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -8.6 \cdot 10^{+70}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq -1:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 0.125:\\
\;\;\;\;x \cdot \left(1 - x\right)\\
\mathbf{elif}\;x \leq 5 \cdot 10^{+131}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -8.6000000000000002e70 or 4.99999999999999995e131 < x Initial program 69.3%
associate-/l*99.9%
Simplified99.9%
clear-num99.9%
un-div-inv100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 83.3%
if -8.6000000000000002e70 < x < -1 or 0.125 < x < 4.99999999999999995e131Initial program 97.7%
Taylor expanded in x around inf 87.5%
Taylor expanded in x around 0 89.8%
Taylor expanded in x around 0 57.3%
if -1 < x < 0.125Initial program 99.9%
Taylor expanded in y around inf 78.6%
Taylor expanded in x around 0 78.5%
neg-mul-178.5%
sub-neg78.5%
Simplified78.5%
(FPCore (x y) :precision binary64 (if (<= x -8.1e+70) (/ x y) (if (<= x -1.0) 1.0 (if (<= x 155000.0) x (if (<= x 9e+132) 1.0 (/ x y))))))
double code(double x, double y) {
double tmp;
if (x <= -8.1e+70) {
tmp = x / y;
} else if (x <= -1.0) {
tmp = 1.0;
} else if (x <= 155000.0) {
tmp = x;
} else if (x <= 9e+132) {
tmp = 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 <= (-8.1d+70)) then
tmp = x / y
else if (x <= (-1.0d0)) then
tmp = 1.0d0
else if (x <= 155000.0d0) then
tmp = x
else if (x <= 9d+132) then
tmp = 1.0d0
else
tmp = x / y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -8.1e+70) {
tmp = x / y;
} else if (x <= -1.0) {
tmp = 1.0;
} else if (x <= 155000.0) {
tmp = x;
} else if (x <= 9e+132) {
tmp = 1.0;
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -8.1e+70: tmp = x / y elif x <= -1.0: tmp = 1.0 elif x <= 155000.0: tmp = x elif x <= 9e+132: tmp = 1.0 else: tmp = x / y return tmp
function code(x, y) tmp = 0.0 if (x <= -8.1e+70) tmp = Float64(x / y); elseif (x <= -1.0) tmp = 1.0; elseif (x <= 155000.0) tmp = x; elseif (x <= 9e+132) tmp = 1.0; else tmp = Float64(x / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -8.1e+70) tmp = x / y; elseif (x <= -1.0) tmp = 1.0; elseif (x <= 155000.0) tmp = x; elseif (x <= 9e+132) tmp = 1.0; else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -8.1e+70], N[(x / y), $MachinePrecision], If[LessEqual[x, -1.0], 1.0, If[LessEqual[x, 155000.0], x, If[LessEqual[x, 9e+132], 1.0, N[(x / y), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -8.1 \cdot 10^{+70}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq -1:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 155000:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 9 \cdot 10^{+132}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -8.0999999999999999e70 or 8.99999999999999944e132 < x Initial program 69.3%
associate-/l*99.9%
Simplified99.9%
clear-num99.9%
un-div-inv100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 83.3%
if -8.0999999999999999e70 < x < -1 or 155000 < x < 8.99999999999999944e132Initial program 97.6%
Taylor expanded in x around inf 92.2%
Taylor expanded in x around 0 94.6%
Taylor expanded in x around 0 61.2%
if -1 < x < 155000Initial program 99.9%
associate-/l*99.9%
Simplified99.9%
clear-num99.8%
un-div-inv99.8%
Applied egg-rr99.8%
Taylor expanded in x around 0 76.5%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ 1.0 (/ x y))))
(if (<= x -18500000000.0)
t_0
(if (<= x 3.8e-28)
(/ x (+ x 1.0))
(if (<= x 1850000.0) (/ x (+ y (/ y x))) t_0)))))
double code(double x, double y) {
double t_0 = 1.0 + (x / y);
double tmp;
if (x <= -18500000000.0) {
tmp = t_0;
} else if (x <= 3.8e-28) {
tmp = x / (x + 1.0);
} else if (x <= 1850000.0) {
tmp = x / (y + (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 = 1.0d0 + (x / y)
if (x <= (-18500000000.0d0)) then
tmp = t_0
else if (x <= 3.8d-28) then
tmp = x / (x + 1.0d0)
else if (x <= 1850000.0d0) then
tmp = x / (y + (y / x))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = 1.0 + (x / y);
double tmp;
if (x <= -18500000000.0) {
tmp = t_0;
} else if (x <= 3.8e-28) {
tmp = x / (x + 1.0);
} else if (x <= 1850000.0) {
tmp = x / (y + (y / x));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 + (x / y) tmp = 0 if x <= -18500000000.0: tmp = t_0 elif x <= 3.8e-28: tmp = x / (x + 1.0) elif x <= 1850000.0: tmp = x / (y + (y / x)) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(1.0 + Float64(x / y)) tmp = 0.0 if (x <= -18500000000.0) tmp = t_0; elseif (x <= 3.8e-28) tmp = Float64(x / Float64(x + 1.0)); elseif (x <= 1850000.0) tmp = Float64(x / Float64(y + Float64(y / x))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 + (x / y); tmp = 0.0; if (x <= -18500000000.0) tmp = t_0; elseif (x <= 3.8e-28) tmp = x / (x + 1.0); elseif (x <= 1850000.0) tmp = x / (y + (y / x)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(1.0 + N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -18500000000.0], t$95$0, If[LessEqual[x, 3.8e-28], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1850000.0], N[(x / N[(y + N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{x}{y}\\
\mathbf{if}\;x \leq -18500000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 3.8 \cdot 10^{-28}:\\
\;\;\;\;\frac{x}{x + 1}\\
\mathbf{elif}\;x \leq 1850000:\\
\;\;\;\;\frac{x}{y + \frac{y}{x}}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1.85e10 or 1.85e6 < x Initial program 77.2%
Taylor expanded in x around inf 76.5%
Taylor expanded in x around 0 99.3%
if -1.85e10 < x < 3.80000000000000009e-28Initial program 99.9%
Taylor expanded in y around inf 81.8%
if 3.80000000000000009e-28 < x < 1.85e6Initial program 99.3%
distribute-lft-in99.3%
fma-define99.3%
*-rgt-identity99.3%
Simplified99.3%
Taylor expanded in y around 0 99.5%
unpow299.5%
distribute-lft-out99.5%
+-commutative99.5%
Simplified99.5%
*-commutative99.5%
associate-/l*99.3%
Applied egg-rr99.3%
Taylor expanded in y around 0 75.7%
unpow275.7%
+-commutative75.7%
times-frac75.7%
associate-/r/76.0%
associate-/r/75.8%
*-lft-identity75.8%
associate-*l/75.4%
*-commutative75.4%
associate-*r*75.1%
distribute-lft-in75.1%
*-rgt-identity75.1%
lft-mult-inverse75.1%
distribute-rgt-in75.4%
*-lft-identity75.4%
associate-*l/76.0%
*-lft-identity76.0%
Simplified76.0%
Final simplification90.2%
(FPCore (x y) :precision binary64 (if (or (<= x -1.0) (not (<= x 0.85))) (+ 1.0 (/ x y)) (* x (+ 1.0 (* x (+ (/ 1.0 y) -1.0))))))
double code(double x, double y) {
double tmp;
if ((x <= -1.0) || !(x <= 0.85)) {
tmp = 1.0 + (x / y);
} 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.85d0))) then
tmp = 1.0d0 + (x / y)
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.85)) {
tmp = 1.0 + (x / y);
} 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.85): tmp = 1.0 + (x / y) 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.85)) tmp = Float64(1.0 + Float64(x / y)); 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.85))) tmp = 1.0 + (x / y); 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.85]], $MachinePrecision]], N[(1.0 + N[(x / y), $MachinePrecision]), $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.85\right):\\
\;\;\;\;1 + \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 + x \cdot \left(\frac{1}{y} + -1\right)\right)\\
\end{array}
\end{array}
if x < -1 or 0.849999999999999978 < x Initial program 78.1%
Taylor expanded in x around inf 75.5%
Taylor expanded in x around 0 97.4%
if -1 < x < 0.849999999999999978Initial program 99.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around 0 98.5%
Final simplification97.9%
(FPCore (x y) :precision binary64 (if (or (<= x -16500000000.0) (not (<= x 0.125))) (+ 1.0 (/ x y)) (/ x (+ x 1.0))))
double code(double x, double y) {
double tmp;
if ((x <= -16500000000.0) || !(x <= 0.125)) {
tmp = 1.0 + (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 <= (-16500000000.0d0)) .or. (.not. (x <= 0.125d0))) then
tmp = 1.0d0 + (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 <= -16500000000.0) || !(x <= 0.125)) {
tmp = 1.0 + (x / y);
} else {
tmp = x / (x + 1.0);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -16500000000.0) or not (x <= 0.125): tmp = 1.0 + (x / y) else: tmp = x / (x + 1.0) return tmp
function code(x, y) tmp = 0.0 if ((x <= -16500000000.0) || !(x <= 0.125)) tmp = Float64(1.0 + 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 <= -16500000000.0) || ~((x <= 0.125))) tmp = 1.0 + (x / y); else tmp = x / (x + 1.0); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -16500000000.0], N[Not[LessEqual[x, 0.125]], $MachinePrecision]], N[(1.0 + N[(x / y), $MachinePrecision]), $MachinePrecision], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -16500000000 \lor \neg \left(x \leq 0.125\right):\\
\;\;\;\;1 + \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{x + 1}\\
\end{array}
\end{array}
if x < -1.65e10 or 0.125 < x Initial program 77.9%
Taylor expanded in x around inf 75.2%
Taylor expanded in x around 0 97.3%
if -1.65e10 < x < 0.125Initial program 99.9%
Taylor expanded in y around inf 79.0%
Final simplification88.4%
(FPCore (x y) :precision binary64 (if (or (<= x -1.0) (not (<= x 0.055))) (+ 1.0 (/ x y)) (* x (- 1.0 x))))
double code(double x, double y) {
double tmp;
if ((x <= -1.0) || !(x <= 0.055)) {
tmp = 1.0 + (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.055d0))) then
tmp = 1.0d0 + (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.055)) {
tmp = 1.0 + (x / y);
} else {
tmp = x * (1.0 - x);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -1.0) or not (x <= 0.055): tmp = 1.0 + (x / y) else: tmp = x * (1.0 - x) return tmp
function code(x, y) tmp = 0.0 if ((x <= -1.0) || !(x <= 0.055)) tmp = Float64(1.0 + 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.055))) tmp = 1.0 + (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.055]], $MachinePrecision]], N[(1.0 + N[(x / y), $MachinePrecision]), $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.055\right):\\
\;\;\;\;1 + \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - x\right)\\
\end{array}
\end{array}
if x < -1 or 0.0550000000000000003 < x Initial program 78.3%
Taylor expanded in x around inf 75.0%
Taylor expanded in x around 0 96.8%
if -1 < x < 0.0550000000000000003Initial program 99.9%
Taylor expanded in y around inf 78.6%
Taylor expanded in x around 0 78.5%
neg-mul-178.5%
sub-neg78.5%
Simplified78.5%
Final simplification88.0%
(FPCore (x y) :precision binary64 (if (<= x -1.0) 1.0 (if (<= x 155000.0) x 1.0)))
double code(double x, double y) {
double tmp;
if (x <= -1.0) {
tmp = 1.0;
} else if (x <= 155000.0) {
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 <= 155000.0d0) 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 <= 155000.0) {
tmp = x;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.0: tmp = 1.0 elif x <= 155000.0: tmp = x else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -1.0) tmp = 1.0; elseif (x <= 155000.0) 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 <= 155000.0) tmp = x; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.0], 1.0, If[LessEqual[x, 155000.0], x, 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 155000:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < -1 or 155000 < x Initial program 77.8%
Taylor expanded in x around inf 76.1%
Taylor expanded in x around 0 98.4%
Taylor expanded in x around 0 30.7%
if -1 < x < 155000Initial program 99.9%
associate-/l*99.9%
Simplified99.9%
clear-num99.8%
un-div-inv99.8%
Applied egg-rr99.8%
Taylor expanded in x around 0 76.5%
(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 88.6%
associate-/l*99.9%
Simplified99.9%
Final simplification99.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 88.6%
Taylor expanded in x around inf 40.9%
Taylor expanded in x around 0 52.1%
Taylor expanded in x around 0 17.6%
(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 2024150
(FPCore (x y)
:name "Codec.Picture.Types:toneMapping from JuicyPixels-3.2.6.1"
:precision binary64
:alt
(! :herbie-platform default (* (/ x 1) (/ (+ (/ x y) 1) (+ x 1))))
(/ (* x (+ (/ x y) 1.0)) (+ x 1.0)))