
(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 11 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 99.9%
(FPCore (x y)
:precision binary64
(if (<= y -1.4e+47)
1.0
(if (<= y -1.0)
(/ x y)
(if (<= y 2.15e-23) x (if (<= y 1.75) (* y (- 1.0 y)) 1.0)))))
double code(double x, double y) {
double tmp;
if (y <= -1.4e+47) {
tmp = 1.0;
} else if (y <= -1.0) {
tmp = x / y;
} else if (y <= 2.15e-23) {
tmp = x;
} else if (y <= 1.75) {
tmp = y * (1.0 - 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.4d+47)) then
tmp = 1.0d0
else if (y <= (-1.0d0)) then
tmp = x / y
else if (y <= 2.15d-23) then
tmp = x
else if (y <= 1.75d0) then
tmp = y * (1.0d0 - y)
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -1.4e+47) {
tmp = 1.0;
} else if (y <= -1.0) {
tmp = x / y;
} else if (y <= 2.15e-23) {
tmp = x;
} else if (y <= 1.75) {
tmp = y * (1.0 - y);
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.4e+47: tmp = 1.0 elif y <= -1.0: tmp = x / y elif y <= 2.15e-23: tmp = x elif y <= 1.75: tmp = y * (1.0 - y) else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -1.4e+47) tmp = 1.0; elseif (y <= -1.0) tmp = Float64(x / y); elseif (y <= 2.15e-23) tmp = x; elseif (y <= 1.75) tmp = Float64(y * Float64(1.0 - y)); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1.4e+47) tmp = 1.0; elseif (y <= -1.0) tmp = x / y; elseif (y <= 2.15e-23) tmp = x; elseif (y <= 1.75) tmp = y * (1.0 - y); else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.4e+47], 1.0, If[LessEqual[y, -1.0], N[(x / y), $MachinePrecision], If[LessEqual[y, 2.15e-23], x, If[LessEqual[y, 1.75], N[(y * N[(1.0 - y), $MachinePrecision]), $MachinePrecision], 1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.4 \cdot 10^{+47}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -1:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;y \leq 2.15 \cdot 10^{-23}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 1.75:\\
\;\;\;\;y \cdot \left(1 - y\right)\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1.39999999999999994e47 or 1.75 < y Initial program 100.0%
Taylor expanded in y around inf 75.0%
if -1.39999999999999994e47 < y < -1Initial program 100.0%
Taylor expanded in x around inf 64.2%
+-commutative64.2%
Simplified64.2%
Taylor expanded in y around inf 58.8%
if -1 < y < 2.15000000000000001e-23Initial program 100.0%
Taylor expanded in y around 0 77.0%
if 2.15000000000000001e-23 < y < 1.75Initial program 98.9%
Taylor expanded in y around inf 99.1%
Taylor expanded in x around 0 85.6%
Taylor expanded in y around 0 68.2%
neg-mul-168.2%
sub-neg68.2%
Simplified68.2%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ 1.0 (/ x y))))
(if (<= y -540000000000.0)
t_0
(if (<= y 1.2e-20)
(/ x (+ y 1.0))
(if (<= y 2400000.0) (/ y (+ y 1.0)) t_0)))))
double code(double x, double y) {
double t_0 = 1.0 + (x / y);
double tmp;
if (y <= -540000000000.0) {
tmp = t_0;
} else if (y <= 1.2e-20) {
tmp = x / (y + 1.0);
} else if (y <= 2400000.0) {
tmp = y / (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 <= (-540000000000.0d0)) then
tmp = t_0
else if (y <= 1.2d-20) then
tmp = x / (y + 1.0d0)
else if (y <= 2400000.0d0) then
tmp = y / (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 <= -540000000000.0) {
tmp = t_0;
} else if (y <= 1.2e-20) {
tmp = x / (y + 1.0);
} else if (y <= 2400000.0) {
tmp = y / (y + 1.0);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 + (x / y) tmp = 0 if y <= -540000000000.0: tmp = t_0 elif y <= 1.2e-20: tmp = x / (y + 1.0) elif y <= 2400000.0: tmp = y / (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 <= -540000000000.0) tmp = t_0; elseif (y <= 1.2e-20) tmp = Float64(x / Float64(y + 1.0)); elseif (y <= 2400000.0) tmp = Float64(y / 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 <= -540000000000.0) tmp = t_0; elseif (y <= 1.2e-20) tmp = x / (y + 1.0); elseif (y <= 2400000.0) tmp = y / (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, -540000000000.0], t$95$0, If[LessEqual[y, 1.2e-20], N[(x / N[(y + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2400000.0], N[(y / 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 -540000000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 1.2 \cdot 10^{-20}:\\
\;\;\;\;\frac{x}{y + 1}\\
\mathbf{elif}\;y \leq 2400000:\\
\;\;\;\;\frac{y}{y + 1}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -5.4e11 or 2.4e6 < y Initial program 100.0%
Taylor expanded in y around inf 100.0%
Taylor expanded in y around inf 99.0%
Taylor expanded in x around 0 99.0%
if -5.4e11 < y < 1.19999999999999996e-20Initial program 100.0%
Taylor expanded in x around inf 77.8%
+-commutative77.8%
Simplified77.8%
if 1.19999999999999996e-20 < y < 2.4e6Initial program 99.1%
Taylor expanded in x around 0 78.2%
+-commutative78.2%
Simplified78.2%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ 1.0 (/ x y))))
(if (<= y -1.0)
t_0
(if (<= y 3.05e-24)
(- x (* x y))
(if (<= y 0.031) (* y (- 1.0 y)) t_0)))))
double code(double x, double y) {
double t_0 = 1.0 + (x / y);
double tmp;
if (y <= -1.0) {
tmp = t_0;
} else if (y <= 3.05e-24) {
tmp = x - (x * y);
} else if (y <= 0.031) {
tmp = y * (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 <= (-1.0d0)) then
tmp = t_0
else if (y <= 3.05d-24) then
tmp = x - (x * y)
else if (y <= 0.031d0) then
tmp = y * (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 <= -1.0) {
tmp = t_0;
} else if (y <= 3.05e-24) {
tmp = x - (x * y);
} else if (y <= 0.031) {
tmp = y * (1.0 - y);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 + (x / y) tmp = 0 if y <= -1.0: tmp = t_0 elif y <= 3.05e-24: tmp = x - (x * y) elif y <= 0.031: tmp = y * (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 <= -1.0) tmp = t_0; elseif (y <= 3.05e-24) tmp = Float64(x - Float64(x * y)); elseif (y <= 0.031) tmp = Float64(y * 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 <= -1.0) tmp = t_0; elseif (y <= 3.05e-24) tmp = x - (x * y); elseif (y <= 0.031) tmp = y * (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, -1.0], t$95$0, If[LessEqual[y, 3.05e-24], N[(x - N[(x * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 0.031], N[(y * N[(1.0 - y), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{x}{y}\\
\mathbf{if}\;y \leq -1:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 3.05 \cdot 10^{-24}:\\
\;\;\;\;x - x \cdot y\\
\mathbf{elif}\;y \leq 0.031:\\
\;\;\;\;y \cdot \left(1 - y\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -1 or 0.031 < y Initial program 100.0%
Taylor expanded in y around inf 100.0%
Taylor expanded in y around inf 96.0%
Taylor expanded in x around 0 96.0%
if -1 < y < 3.05000000000000018e-24Initial program 100.0%
Taylor expanded in x around inf 78.5%
+-commutative78.5%
Simplified78.5%
Taylor expanded in y around 0 77.8%
mul-1-neg77.8%
unsub-neg77.8%
*-commutative77.8%
Simplified77.8%
if 3.05000000000000018e-24 < y < 0.031Initial program 99.0%
Taylor expanded in y around inf 99.0%
Taylor expanded in x around 0 99.7%
Taylor expanded in y around 0 78.8%
neg-mul-178.8%
sub-neg78.8%
Simplified78.8%
Final simplification87.7%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ 1.0 (/ x y))))
(if (<= y -1.0)
t_0
(if (<= y 4.9e-20) x (if (<= y 0.02) (* y (- 1.0 y)) t_0)))))
double code(double x, double y) {
double t_0 = 1.0 + (x / y);
double tmp;
if (y <= -1.0) {
tmp = t_0;
} else if (y <= 4.9e-20) {
tmp = x;
} else if (y <= 0.02) {
tmp = y * (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 <= (-1.0d0)) then
tmp = t_0
else if (y <= 4.9d-20) then
tmp = x
else if (y <= 0.02d0) then
tmp = y * (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 <= -1.0) {
tmp = t_0;
} else if (y <= 4.9e-20) {
tmp = x;
} else if (y <= 0.02) {
tmp = y * (1.0 - y);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 + (x / y) tmp = 0 if y <= -1.0: tmp = t_0 elif y <= 4.9e-20: tmp = x elif y <= 0.02: tmp = y * (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 <= -1.0) tmp = t_0; elseif (y <= 4.9e-20) tmp = x; elseif (y <= 0.02) tmp = Float64(y * 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 <= -1.0) tmp = t_0; elseif (y <= 4.9e-20) tmp = x; elseif (y <= 0.02) tmp = y * (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, -1.0], t$95$0, If[LessEqual[y, 4.9e-20], x, If[LessEqual[y, 0.02], N[(y * N[(1.0 - y), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{x}{y}\\
\mathbf{if}\;y \leq -1:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 4.9 \cdot 10^{-20}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 0.02:\\
\;\;\;\;y \cdot \left(1 - y\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -1 or 0.0200000000000000004 < y Initial program 100.0%
Taylor expanded in y around inf 100.0%
Taylor expanded in y around inf 96.0%
Taylor expanded in x around 0 96.0%
if -1 < y < 4.9000000000000002e-20Initial program 100.0%
Taylor expanded in y around 0 77.0%
if 4.9000000000000002e-20 < y < 0.0200000000000000004Initial program 99.0%
Taylor expanded in y around inf 99.0%
Taylor expanded in x around 0 99.7%
Taylor expanded in y around 0 78.8%
neg-mul-178.8%
sub-neg78.8%
Simplified78.8%
(FPCore (x y) :precision binary64 (if (or (<= y -1.0) (not (<= y 1.0))) (+ 1.0 (/ (+ x -1.0) y)) (* (+ x y) (- 1.0 y))))
double code(double x, double y) {
double tmp;
if ((y <= -1.0) || !(y <= 1.0)) {
tmp = 1.0 + ((x + -1.0) / y);
} else {
tmp = (x + y) * (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 <= (-1.0d0)) .or. (.not. (y <= 1.0d0))) then
tmp = 1.0d0 + ((x + (-1.0d0)) / y)
else
tmp = (x + y) * (1.0d0 - y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -1.0) || !(y <= 1.0)) {
tmp = 1.0 + ((x + -1.0) / y);
} else {
tmp = (x + y) * (1.0 - y);
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -1.0) or not (y <= 1.0): tmp = 1.0 + ((x + -1.0) / y) else: tmp = (x + y) * (1.0 - y) return tmp
function code(x, y) tmp = 0.0 if ((y <= -1.0) || !(y <= 1.0)) tmp = Float64(1.0 + Float64(Float64(x + -1.0) / y)); else tmp = Float64(Float64(x + y) * Float64(1.0 - y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -1.0) || ~((y <= 1.0))) tmp = 1.0 + ((x + -1.0) / y); else tmp = (x + y) * (1.0 - y); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -1.0], N[Not[LessEqual[y, 1.0]], $MachinePrecision]], N[(1.0 + N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(N[(x + y), $MachinePrecision] * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1 \lor \neg \left(y \leq 1\right):\\
\;\;\;\;1 + \frac{x + -1}{y}\\
\mathbf{else}:\\
\;\;\;\;\left(x + y\right) \cdot \left(1 - y\right)\\
\end{array}
\end{array}
if y < -1 or 1 < y Initial program 100.0%
Taylor expanded in y around inf 96.8%
associate--l+96.8%
div-sub96.8%
sub-neg96.8%
metadata-eval96.8%
Simplified96.8%
if -1 < y < 1Initial program 99.9%
clear-num99.7%
associate-/r/99.9%
Applied egg-rr99.9%
Taylor expanded in y around 0 98.2%
neg-mul-198.2%
sub-neg98.2%
Simplified98.2%
Final simplification97.5%
(FPCore (x y) :precision binary64 (if (or (<= y -1.0) (not (<= y 0.76))) (+ 1.0 (/ x y)) (* (+ x y) (- 1.0 y))))
double code(double x, double y) {
double tmp;
if ((y <= -1.0) || !(y <= 0.76)) {
tmp = 1.0 + (x / y);
} else {
tmp = (x + y) * (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 <= (-1.0d0)) .or. (.not. (y <= 0.76d0))) then
tmp = 1.0d0 + (x / y)
else
tmp = (x + y) * (1.0d0 - y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -1.0) || !(y <= 0.76)) {
tmp = 1.0 + (x / y);
} else {
tmp = (x + y) * (1.0 - y);
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -1.0) or not (y <= 0.76): tmp = 1.0 + (x / y) else: tmp = (x + y) * (1.0 - y) return tmp
function code(x, y) tmp = 0.0 if ((y <= -1.0) || !(y <= 0.76)) tmp = Float64(1.0 + Float64(x / y)); else tmp = Float64(Float64(x + y) * Float64(1.0 - y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -1.0) || ~((y <= 0.76))) tmp = 1.0 + (x / y); else tmp = (x + y) * (1.0 - y); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -1.0], N[Not[LessEqual[y, 0.76]], $MachinePrecision]], N[(1.0 + N[(x / y), $MachinePrecision]), $MachinePrecision], N[(N[(x + y), $MachinePrecision] * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1 \lor \neg \left(y \leq 0.76\right):\\
\;\;\;\;1 + \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\left(x + y\right) \cdot \left(1 - y\right)\\
\end{array}
\end{array}
if y < -1 or 0.76000000000000001 < y Initial program 100.0%
Taylor expanded in y around inf 100.0%
Taylor expanded in y around inf 96.0%
Taylor expanded in x around 0 96.0%
if -1 < y < 0.76000000000000001Initial program 99.9%
clear-num99.7%
associate-/r/99.9%
Applied egg-rr99.9%
Taylor expanded in y around 0 98.2%
neg-mul-198.2%
sub-neg98.2%
Simplified98.2%
Final simplification97.0%
(FPCore (x y) :precision binary64 (if (<= y -2.4e+46) 1.0 (if (<= y -1.0) (/ x y) (if (<= y 7.2e-20) x 1.0))))
double code(double x, double y) {
double tmp;
if (y <= -2.4e+46) {
tmp = 1.0;
} else if (y <= -1.0) {
tmp = x / y;
} else if (y <= 7.2e-20) {
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 <= (-2.4d+46)) then
tmp = 1.0d0
else if (y <= (-1.0d0)) then
tmp = x / y
else if (y <= 7.2d-20) 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 <= -2.4e+46) {
tmp = 1.0;
} else if (y <= -1.0) {
tmp = x / y;
} else if (y <= 7.2e-20) {
tmp = x;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -2.4e+46: tmp = 1.0 elif y <= -1.0: tmp = x / y elif y <= 7.2e-20: tmp = x else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -2.4e+46) tmp = 1.0; elseif (y <= -1.0) tmp = Float64(x / y); elseif (y <= 7.2e-20) tmp = x; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -2.4e+46) tmp = 1.0; elseif (y <= -1.0) tmp = x / y; elseif (y <= 7.2e-20) tmp = x; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -2.4e+46], 1.0, If[LessEqual[y, -1.0], N[(x / y), $MachinePrecision], If[LessEqual[y, 7.2e-20], x, 1.0]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.4 \cdot 10^{+46}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -1:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;y \leq 7.2 \cdot 10^{-20}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -2.40000000000000008e46 or 7.19999999999999948e-20 < y Initial program 99.9%
Taylor expanded in y around inf 71.5%
if -2.40000000000000008e46 < y < -1Initial program 100.0%
Taylor expanded in x around inf 64.2%
+-commutative64.2%
Simplified64.2%
Taylor expanded in y around inf 58.8%
if -1 < y < 7.19999999999999948e-20Initial program 100.0%
Taylor expanded in y around 0 77.0%
(FPCore (x y) :precision binary64 (if (or (<= y -540000000000.0) (not (<= y 106000000.0))) (+ 1.0 (/ x y)) (/ x (+ y 1.0))))
double code(double x, double y) {
double tmp;
if ((y <= -540000000000.0) || !(y <= 106000000.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 <= (-540000000000.0d0)) .or. (.not. (y <= 106000000.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 <= -540000000000.0) || !(y <= 106000000.0)) {
tmp = 1.0 + (x / y);
} else {
tmp = x / (y + 1.0);
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -540000000000.0) or not (y <= 106000000.0): tmp = 1.0 + (x / y) else: tmp = x / (y + 1.0) return tmp
function code(x, y) tmp = 0.0 if ((y <= -540000000000.0) || !(y <= 106000000.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 <= -540000000000.0) || ~((y <= 106000000.0))) tmp = 1.0 + (x / y); else tmp = x / (y + 1.0); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -540000000000.0], N[Not[LessEqual[y, 106000000.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 -540000000000 \lor \neg \left(y \leq 106000000\right):\\
\;\;\;\;1 + \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y + 1}\\
\end{array}
\end{array}
if y < -5.4e11 or 1.06e8 < y Initial program 100.0%
Taylor expanded in y around inf 100.0%
Taylor expanded in y around inf 99.3%
Taylor expanded in x around 0 99.4%
if -5.4e11 < y < 1.06e8Initial program 99.9%
Taylor expanded in x around inf 74.1%
+-commutative74.1%
Simplified74.1%
Final simplification86.9%
(FPCore (x y) :precision binary64 (if (<= y -1.0) 1.0 (if (<= y 7.2e-20) x 1.0)))
double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = 1.0;
} else if (y <= 7.2e-20) {
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 <= 7.2d-20) 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 <= 7.2e-20) {
tmp = x;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.0: tmp = 1.0 elif y <= 7.2e-20: tmp = x else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -1.0) tmp = 1.0; elseif (y <= 7.2e-20) 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 <= 7.2e-20) tmp = x; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.0], 1.0, If[LessEqual[y, 7.2e-20], x, 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 7.2 \cdot 10^{-20}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1 or 7.19999999999999948e-20 < y Initial program 99.9%
Taylor expanded in y around inf 66.8%
if -1 < y < 7.19999999999999948e-20Initial program 100.0%
Taylor expanded in y around 0 77.0%
(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 99.9%
Taylor expanded in y around inf 39.4%
herbie shell --seed 2024172
(FPCore (x y)
:name "Data.Colour.SRGB:invTransferFunction from colour-2.3.3"
:precision binary64
(/ (+ x y) (+ y 1.0)))