
(FPCore (x y) :precision binary64 (/ (+ x y) (+ y 1.0)))
double code(double x, double y) {
return (x + y) / (y + 1.0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x + y) / (y + 1.0d0)
end function
public static double code(double x, double y) {
return (x + y) / (y + 1.0);
}
def code(x, y): return (x + y) / (y + 1.0)
function code(x, y) return Float64(Float64(x + y) / Float64(y + 1.0)) end
function tmp = code(x, y) tmp = (x + y) / (y + 1.0); end
code[x_, y_] := N[(N[(x + y), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x + y}{y + 1}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (/ (+ x y) (+ y 1.0)))
double code(double x, double y) {
return (x + y) / (y + 1.0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x + y) / (y + 1.0d0)
end function
public static double code(double x, double y) {
return (x + y) / (y + 1.0);
}
def code(x, y): return (x + y) / (y + 1.0)
function code(x, y) return Float64(Float64(x + y) / Float64(y + 1.0)) end
function tmp = code(x, y) tmp = (x + y) / (y + 1.0); end
code[x_, y_] := N[(N[(x + y), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x + y}{y + 1}
\end{array}
(FPCore (x y) :precision binary64 (/ (+ x y) (+ y 1.0)))
double code(double x, double y) {
return (x + y) / (y + 1.0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x + y) / (y + 1.0d0)
end function
public static double code(double x, double y) {
return (x + y) / (y + 1.0);
}
def code(x, y): return (x + y) / (y + 1.0)
function code(x, y) return Float64(Float64(x + y) / Float64(y + 1.0)) end
function tmp = code(x, y) tmp = (x + y) / (y + 1.0); end
code[x_, y_] := N[(N[(x + y), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x + y}{y + 1}
\end{array}
Initial program 100.0%
Final simplification100.0%
(FPCore (x y)
:precision binary64
(if (<= y -1.7e+96)
1.0
(if (<= y -6.7e+19)
(/ x y)
(if (<= y -1.0)
1.0
(if (<= y 7800.0)
x
(if (<= y 5e+68) 1.0 (if (<= y 1.08e+130) (/ x y) 1.0)))))))
double code(double x, double y) {
double tmp;
if (y <= -1.7e+96) {
tmp = 1.0;
} else if (y <= -6.7e+19) {
tmp = x / y;
} else if (y <= -1.0) {
tmp = 1.0;
} else if (y <= 7800.0) {
tmp = x;
} else if (y <= 5e+68) {
tmp = 1.0;
} else if (y <= 1.08e+130) {
tmp = x / y;
} 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 (y <= (-1.7d+96)) then
tmp = 1.0d0
else if (y <= (-6.7d+19)) then
tmp = x / y
else if (y <= (-1.0d0)) then
tmp = 1.0d0
else if (y <= 7800.0d0) then
tmp = x
else if (y <= 5d+68) then
tmp = 1.0d0
else if (y <= 1.08d+130) then
tmp = x / y
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -1.7e+96) {
tmp = 1.0;
} else if (y <= -6.7e+19) {
tmp = x / y;
} else if (y <= -1.0) {
tmp = 1.0;
} else if (y <= 7800.0) {
tmp = x;
} else if (y <= 5e+68) {
tmp = 1.0;
} else if (y <= 1.08e+130) {
tmp = x / y;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.7e+96: tmp = 1.0 elif y <= -6.7e+19: tmp = x / y elif y <= -1.0: tmp = 1.0 elif y <= 7800.0: tmp = x elif y <= 5e+68: tmp = 1.0 elif y <= 1.08e+130: tmp = x / y else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -1.7e+96) tmp = 1.0; elseif (y <= -6.7e+19) tmp = Float64(x / y); elseif (y <= -1.0) tmp = 1.0; elseif (y <= 7800.0) tmp = x; elseif (y <= 5e+68) tmp = 1.0; elseif (y <= 1.08e+130) tmp = Float64(x / y); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1.7e+96) tmp = 1.0; elseif (y <= -6.7e+19) tmp = x / y; elseif (y <= -1.0) tmp = 1.0; elseif (y <= 7800.0) tmp = x; elseif (y <= 5e+68) tmp = 1.0; elseif (y <= 1.08e+130) tmp = x / y; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.7e+96], 1.0, If[LessEqual[y, -6.7e+19], N[(x / y), $MachinePrecision], If[LessEqual[y, -1.0], 1.0, If[LessEqual[y, 7800.0], x, If[LessEqual[y, 5e+68], 1.0, If[LessEqual[y, 1.08e+130], N[(x / y), $MachinePrecision], 1.0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.7 \cdot 10^{+96}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -6.7 \cdot 10^{+19}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;y \leq -1:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 7800:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 5 \cdot 10^{+68}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 1.08 \cdot 10^{+130}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1.7e96 or -6.7e19 < y < -1 or 7800 < y < 5.0000000000000004e68 or 1.08e130 < y Initial program 100.0%
Taylor expanded in y around inf 78.2%
if -1.7e96 < y < -6.7e19 or 5.0000000000000004e68 < y < 1.08e130Initial program 100.0%
Taylor expanded in y around inf 100.0%
+-commutative100.0%
associate--l+100.0%
+-commutative100.0%
associate--r-100.0%
div-sub100.0%
Simplified100.0%
Taylor expanded in x around inf 69.7%
if -1 < y < 7800Initial program 100.0%
Taylor expanded in y around 0 79.2%
Final simplification77.8%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ 1.0 (/ x y))))
(if (<= y -2.15e+18)
t_0
(if (<= y -1.02e-55)
(/ y (+ y 1.0))
(if (<= y 75000.0) (* x (/ -1.0 (- -1.0 y))) t_0)))))
double code(double x, double y) {
double t_0 = 1.0 + (x / y);
double tmp;
if (y <= -2.15e+18) {
tmp = t_0;
} else if (y <= -1.02e-55) {
tmp = y / (y + 1.0);
} else if (y <= 75000.0) {
tmp = x * (-1.0 / (-1.0 - 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 = 1.0d0 + (x / y)
if (y <= (-2.15d+18)) then
tmp = t_0
else if (y <= (-1.02d-55)) then
tmp = y / (y + 1.0d0)
else if (y <= 75000.0d0) then
tmp = x * ((-1.0d0) / ((-1.0d0) - y))
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 (y <= -2.15e+18) {
tmp = t_0;
} else if (y <= -1.02e-55) {
tmp = y / (y + 1.0);
} else if (y <= 75000.0) {
tmp = x * (-1.0 / (-1.0 - y));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 + (x / y) tmp = 0 if y <= -2.15e+18: tmp = t_0 elif y <= -1.02e-55: tmp = y / (y + 1.0) elif y <= 75000.0: tmp = x * (-1.0 / (-1.0 - y)) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(1.0 + Float64(x / y)) tmp = 0.0 if (y <= -2.15e+18) tmp = t_0; elseif (y <= -1.02e-55) tmp = Float64(y / Float64(y + 1.0)); elseif (y <= 75000.0) tmp = Float64(x * Float64(-1.0 / Float64(-1.0 - y))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 + (x / y); tmp = 0.0; if (y <= -2.15e+18) tmp = t_0; elseif (y <= -1.02e-55) tmp = y / (y + 1.0); elseif (y <= 75000.0) tmp = x * (-1.0 / (-1.0 - y)); 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[y, -2.15e+18], t$95$0, If[LessEqual[y, -1.02e-55], N[(y / N[(y + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 75000.0], N[(x * N[(-1.0 / N[(-1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{x}{y}\\
\mathbf{if}\;y \leq -2.15 \cdot 10^{+18}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -1.02 \cdot 10^{-55}:\\
\;\;\;\;\frac{y}{y + 1}\\
\mathbf{elif}\;y \leq 75000:\\
\;\;\;\;x \cdot \frac{-1}{-1 - y}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if y < -2.15e18 or 75000 < y Initial program 100.0%
Taylor expanded in y around inf 99.7%
+-commutative99.7%
associate--l+99.7%
+-commutative99.7%
associate--r-99.7%
div-sub99.7%
Simplified99.7%
Taylor expanded in x around inf 99.5%
mul-1-neg99.5%
distribute-neg-frac99.5%
Simplified99.5%
Taylor expanded in x around 0 99.5%
+-commutative99.5%
Simplified99.5%
if -2.15e18 < y < -1.02e-55Initial program 100.0%
Taylor expanded in x around 0 79.9%
+-commutative79.9%
Simplified79.9%
if -1.02e-55 < y < 75000Initial program 100.0%
Taylor expanded in x around inf 84.7%
+-commutative84.7%
Simplified84.7%
div-inv84.7%
*-commutative84.7%
frac-2neg84.7%
metadata-eval84.7%
distribute-neg-in84.7%
metadata-eval84.7%
+-commutative84.7%
sub-neg84.7%
Applied egg-rr84.7%
Final simplification91.6%
(FPCore (x y)
:precision binary64
(if (<= y -2.15e+18)
(+ 1.0 (/ x y))
(if (<= y -9.5e-56)
(/ y (+ y 1.0))
(if (<= y 8000.0) (* x (/ -1.0 (- -1.0 y))) (+ 1.0 (/ (+ x -1.0) y))))))
double code(double x, double y) {
double tmp;
if (y <= -2.15e+18) {
tmp = 1.0 + (x / y);
} else if (y <= -9.5e-56) {
tmp = y / (y + 1.0);
} else if (y <= 8000.0) {
tmp = x * (-1.0 / (-1.0 - y));
} else {
tmp = 1.0 + ((x + -1.0) / y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-2.15d+18)) then
tmp = 1.0d0 + (x / y)
else if (y <= (-9.5d-56)) then
tmp = y / (y + 1.0d0)
else if (y <= 8000.0d0) then
tmp = x * ((-1.0d0) / ((-1.0d0) - y))
else
tmp = 1.0d0 + ((x + (-1.0d0)) / y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -2.15e+18) {
tmp = 1.0 + (x / y);
} else if (y <= -9.5e-56) {
tmp = y / (y + 1.0);
} else if (y <= 8000.0) {
tmp = x * (-1.0 / (-1.0 - y));
} else {
tmp = 1.0 + ((x + -1.0) / y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -2.15e+18: tmp = 1.0 + (x / y) elif y <= -9.5e-56: tmp = y / (y + 1.0) elif y <= 8000.0: tmp = x * (-1.0 / (-1.0 - y)) else: tmp = 1.0 + ((x + -1.0) / y) return tmp
function code(x, y) tmp = 0.0 if (y <= -2.15e+18) tmp = Float64(1.0 + Float64(x / y)); elseif (y <= -9.5e-56) tmp = Float64(y / Float64(y + 1.0)); elseif (y <= 8000.0) tmp = Float64(x * Float64(-1.0 / Float64(-1.0 - y))); else tmp = Float64(1.0 + Float64(Float64(x + -1.0) / y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -2.15e+18) tmp = 1.0 + (x / y); elseif (y <= -9.5e-56) tmp = y / (y + 1.0); elseif (y <= 8000.0) tmp = x * (-1.0 / (-1.0 - y)); else tmp = 1.0 + ((x + -1.0) / y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -2.15e+18], N[(1.0 + N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -9.5e-56], N[(y / N[(y + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 8000.0], N[(x * N[(-1.0 / N[(-1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.15 \cdot 10^{+18}:\\
\;\;\;\;1 + \frac{x}{y}\\
\mathbf{elif}\;y \leq -9.5 \cdot 10^{-56}:\\
\;\;\;\;\frac{y}{y + 1}\\
\mathbf{elif}\;y \leq 8000:\\
\;\;\;\;x \cdot \frac{-1}{-1 - y}\\
\mathbf{else}:\\
\;\;\;\;1 + \frac{x + -1}{y}\\
\end{array}
\end{array}
if y < -2.15e18Initial program 100.0%
Taylor expanded in y around inf 100.0%
+-commutative100.0%
associate--l+100.0%
+-commutative100.0%
associate--r-100.0%
div-sub100.0%
Simplified100.0%
Taylor expanded in x around inf 100.0%
mul-1-neg100.0%
distribute-neg-frac100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
+-commutative100.0%
Simplified100.0%
if -2.15e18 < y < -9.4999999999999991e-56Initial program 100.0%
Taylor expanded in x around 0 79.9%
+-commutative79.9%
Simplified79.9%
if -9.4999999999999991e-56 < y < 8e3Initial program 100.0%
Taylor expanded in x around inf 84.7%
+-commutative84.7%
Simplified84.7%
div-inv84.7%
*-commutative84.7%
frac-2neg84.7%
metadata-eval84.7%
distribute-neg-in84.7%
metadata-eval84.7%
+-commutative84.7%
sub-neg84.7%
Applied egg-rr84.7%
if 8e3 < y Initial program 100.0%
Taylor expanded in y around inf 99.5%
+-commutative99.5%
associate--l+99.5%
+-commutative99.5%
associate--r-99.5%
div-sub99.5%
Simplified99.5%
Final simplification91.7%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ 1.0 (/ x y))))
(if (<= y -2.15e+18)
t_0
(if (<= y -1.02e-55)
(/ y (+ y 1.0))
(if (<= y 90000.0) (/ x (+ y 1.0)) t_0)))))
double code(double x, double y) {
double t_0 = 1.0 + (x / y);
double tmp;
if (y <= -2.15e+18) {
tmp = t_0;
} else if (y <= -1.02e-55) {
tmp = y / (y + 1.0);
} else if (y <= 90000.0) {
tmp = x / (y + 1.0);
} 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 (y <= (-2.15d+18)) then
tmp = t_0
else if (y <= (-1.02d-55)) then
tmp = y / (y + 1.0d0)
else if (y <= 90000.0d0) then
tmp = x / (y + 1.0d0)
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 (y <= -2.15e+18) {
tmp = t_0;
} else if (y <= -1.02e-55) {
tmp = y / (y + 1.0);
} else if (y <= 90000.0) {
tmp = x / (y + 1.0);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 + (x / y) tmp = 0 if y <= -2.15e+18: tmp = t_0 elif y <= -1.02e-55: tmp = y / (y + 1.0) elif y <= 90000.0: tmp = x / (y + 1.0) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(1.0 + Float64(x / y)) tmp = 0.0 if (y <= -2.15e+18) tmp = t_0; elseif (y <= -1.02e-55) tmp = Float64(y / Float64(y + 1.0)); elseif (y <= 90000.0) tmp = Float64(x / Float64(y + 1.0)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 + (x / y); tmp = 0.0; if (y <= -2.15e+18) tmp = t_0; elseif (y <= -1.02e-55) tmp = y / (y + 1.0); elseif (y <= 90000.0) tmp = x / (y + 1.0); 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[y, -2.15e+18], t$95$0, If[LessEqual[y, -1.02e-55], N[(y / N[(y + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 90000.0], N[(x / N[(y + 1.0), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{x}{y}\\
\mathbf{if}\;y \leq -2.15 \cdot 10^{+18}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -1.02 \cdot 10^{-55}:\\
\;\;\;\;\frac{y}{y + 1}\\
\mathbf{elif}\;y \leq 90000:\\
\;\;\;\;\frac{x}{y + 1}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if y < -2.15e18 or 9e4 < y Initial program 100.0%
Taylor expanded in y around inf 99.7%
+-commutative99.7%
associate--l+99.7%
+-commutative99.7%
associate--r-99.7%
div-sub99.7%
Simplified99.7%
Taylor expanded in x around inf 99.5%
mul-1-neg99.5%
distribute-neg-frac99.5%
Simplified99.5%
Taylor expanded in x around 0 99.5%
+-commutative99.5%
Simplified99.5%
if -2.15e18 < y < -1.02e-55Initial program 100.0%
Taylor expanded in x around 0 79.9%
+-commutative79.9%
Simplified79.9%
if -1.02e-55 < y < 9e4Initial program 100.0%
Taylor expanded in x around inf 84.7%
+-commutative84.7%
Simplified84.7%
Final simplification91.6%
(FPCore (x y) :precision binary64 (if (or (<= y -1.0) (not (<= y 2.8e-9))) (+ 1.0 (/ x y)) x))
double code(double x, double y) {
double tmp;
if ((y <= -1.0) || !(y <= 2.8e-9)) {
tmp = 1.0 + (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 ((y <= (-1.0d0)) .or. (.not. (y <= 2.8d-9))) then
tmp = 1.0d0 + (x / y)
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -1.0) || !(y <= 2.8e-9)) {
tmp = 1.0 + (x / y);
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -1.0) or not (y <= 2.8e-9): tmp = 1.0 + (x / y) else: tmp = x return tmp
function code(x, y) tmp = 0.0 if ((y <= -1.0) || !(y <= 2.8e-9)) tmp = Float64(1.0 + Float64(x / y)); else tmp = x; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -1.0) || ~((y <= 2.8e-9))) tmp = 1.0 + (x / y); else tmp = x; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -1.0], N[Not[LessEqual[y, 2.8e-9]], $MachinePrecision]], N[(1.0 + N[(x / y), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1 \lor \neg \left(y \leq 2.8 \cdot 10^{-9}\right):\\
\;\;\;\;1 + \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -1 or 2.79999999999999984e-9 < y Initial program 100.0%
Taylor expanded in y around inf 96.4%
+-commutative96.4%
associate--l+96.4%
+-commutative96.4%
associate--r-96.4%
div-sub96.4%
Simplified96.4%
Taylor expanded in x around inf 95.8%
mul-1-neg95.8%
distribute-neg-frac95.8%
Simplified95.8%
Taylor expanded in x around 0 95.8%
+-commutative95.8%
Simplified95.8%
if -1 < y < 2.79999999999999984e-9Initial program 100.0%
Taylor expanded in y around 0 81.5%
Final simplification88.9%
(FPCore (x y) :precision binary64 (if (or (<= y -240.0) (not (<= y 38000.0))) (+ 1.0 (/ x y)) (/ x (+ y 1.0))))
double code(double x, double y) {
double tmp;
if ((y <= -240.0) || !(y <= 38000.0)) {
tmp = 1.0 + (x / y);
} else {
tmp = x / (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 ((y <= (-240.0d0)) .or. (.not. (y <= 38000.0d0))) then
tmp = 1.0d0 + (x / y)
else
tmp = x / (y + 1.0d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -240.0) || !(y <= 38000.0)) {
tmp = 1.0 + (x / y);
} else {
tmp = x / (y + 1.0);
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -240.0) or not (y <= 38000.0): tmp = 1.0 + (x / y) else: tmp = x / (y + 1.0) return tmp
function code(x, y) tmp = 0.0 if ((y <= -240.0) || !(y <= 38000.0)) tmp = Float64(1.0 + Float64(x / y)); else tmp = Float64(x / Float64(y + 1.0)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -240.0) || ~((y <= 38000.0))) tmp = 1.0 + (x / y); else tmp = x / (y + 1.0); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -240.0], N[Not[LessEqual[y, 38000.0]], $MachinePrecision]], N[(1.0 + N[(x / y), $MachinePrecision]), $MachinePrecision], N[(x / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -240 \lor \neg \left(y \leq 38000\right):\\
\;\;\;\;1 + \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y + 1}\\
\end{array}
\end{array}
if y < -240 or 38000 < y Initial program 100.0%
Taylor expanded in y around inf 98.9%
+-commutative98.9%
associate--l+98.9%
+-commutative98.9%
associate--r-98.9%
div-sub98.9%
Simplified98.9%
Taylor expanded in x around inf 98.2%
mul-1-neg98.2%
distribute-neg-frac98.2%
Simplified98.2%
Taylor expanded in x around 0 98.2%
+-commutative98.2%
Simplified98.2%
if -240 < y < 38000Initial program 100.0%
Taylor expanded in x around inf 81.2%
+-commutative81.2%
Simplified81.2%
Final simplification89.8%
(FPCore (x y) :precision binary64 (if (<= y -1.0) 1.0 (if (<= y 7800.0) x 1.0)))
double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = 1.0;
} else if (y <= 7800.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 (y <= (-1.0d0)) then
tmp = 1.0d0
else if (y <= 7800.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 (y <= -1.0) {
tmp = 1.0;
} else if (y <= 7800.0) {
tmp = x;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.0: tmp = 1.0 elif y <= 7800.0: tmp = x else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -1.0) tmp = 1.0; elseif (y <= 7800.0) tmp = x; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1.0) tmp = 1.0; elseif (y <= 7800.0) tmp = x; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.0], 1.0, If[LessEqual[y, 7800.0], x, 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 7800:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1 or 7800 < y Initial program 100.0%
Taylor expanded in y around inf 68.5%
if -1 < y < 7800Initial program 100.0%
Taylor expanded in y around 0 79.2%
Final simplification73.8%
(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 100.0%
Taylor expanded in y around inf 36.2%
Final simplification36.2%
herbie shell --seed 2023301
(FPCore (x y)
:name "Data.Colour.SRGB:invTransferFunction from colour-2.3.3"
:precision binary64
(/ (+ x y) (+ y 1.0)))