
(FPCore (x y z) :precision binary64 (/ (+ x y) (- 1.0 (/ y z))))
double code(double x, double y, double z) {
return (x + y) / (1.0 - (y / z));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x + y) / (1.0d0 - (y / z))
end function
public static double code(double x, double y, double z) {
return (x + y) / (1.0 - (y / z));
}
def code(x, y, z): return (x + y) / (1.0 - (y / z))
function code(x, y, z) return Float64(Float64(x + y) / Float64(1.0 - Float64(y / z))) end
function tmp = code(x, y, z) tmp = (x + y) / (1.0 - (y / z)); end
code[x_, y_, z_] := N[(N[(x + y), $MachinePrecision] / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x + y}{1 - \frac{y}{z}}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (/ (+ x y) (- 1.0 (/ y z))))
double code(double x, double y, double z) {
return (x + y) / (1.0 - (y / z));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x + y) / (1.0d0 - (y / z))
end function
public static double code(double x, double y, double z) {
return (x + y) / (1.0 - (y / z));
}
def code(x, y, z): return (x + y) / (1.0 - (y / z))
function code(x, y, z) return Float64(Float64(x + y) / Float64(1.0 - Float64(y / z))) end
function tmp = code(x, y, z) tmp = (x + y) / (1.0 - (y / z)); end
code[x_, y_, z_] := N[(N[(x + y), $MachinePrecision] / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x + y}{1 - \frac{y}{z}}
\end{array}
(FPCore (x y z) :precision binary64 (let* ((t_0 (/ (+ x y) (- 1.0 (/ y z))))) (if (or (<= t_0 -5e-246) (not (<= t_0 0.0))) t_0 (* z (/ (- (- y) x) y)))))
double code(double x, double y, double z) {
double t_0 = (x + y) / (1.0 - (y / z));
double tmp;
if ((t_0 <= -5e-246) || !(t_0 <= 0.0)) {
tmp = t_0;
} else {
tmp = z * ((-y - x) / y);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = (x + y) / (1.0d0 - (y / z))
if ((t_0 <= (-5d-246)) .or. (.not. (t_0 <= 0.0d0))) then
tmp = t_0
else
tmp = z * ((-y - x) / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (x + y) / (1.0 - (y / z));
double tmp;
if ((t_0 <= -5e-246) || !(t_0 <= 0.0)) {
tmp = t_0;
} else {
tmp = z * ((-y - x) / y);
}
return tmp;
}
def code(x, y, z): t_0 = (x + y) / (1.0 - (y / z)) tmp = 0 if (t_0 <= -5e-246) or not (t_0 <= 0.0): tmp = t_0 else: tmp = z * ((-y - x) / y) return tmp
function code(x, y, z) t_0 = Float64(Float64(x + y) / Float64(1.0 - Float64(y / z))) tmp = 0.0 if ((t_0 <= -5e-246) || !(t_0 <= 0.0)) tmp = t_0; else tmp = Float64(z * Float64(Float64(Float64(-y) - x) / y)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x + y) / (1.0 - (y / z)); tmp = 0.0; if ((t_0 <= -5e-246) || ~((t_0 <= 0.0))) tmp = t_0; else tmp = z * ((-y - x) / y); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x + y), $MachinePrecision] / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -5e-246], N[Not[LessEqual[t$95$0, 0.0]], $MachinePrecision]], t$95$0, N[(z * N[(N[((-y) - x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x + y}{1 - \frac{y}{z}}\\
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{-246} \lor \neg \left(t\_0 \leq 0\right):\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;z \cdot \frac{\left(-y\right) - x}{y}\\
\end{array}
\end{array}
if (/.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) (/.f64 y z))) < -4.9999999999999997e-246 or 0.0 < (/.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) (/.f64 y z))) Initial program 99.9%
if -4.9999999999999997e-246 < (/.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) (/.f64 y z))) < 0.0Initial program 8.5%
Taylor expanded in z around 0 99.9%
mul-1-neg99.9%
associate-/l*99.9%
distribute-rgt-neg-in99.9%
distribute-neg-frac299.9%
+-commutative99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ (* z (+ x y)) (- y))))
(if (<= y -5.5e+184)
(- z)
(if (<= y -1350000.0)
t_0
(if (<= y -1.85e-56)
(+ x y)
(if (<= y -1.8e-63)
t_0
(if (<= y 4.2e-74)
(/ x (- 1.0 (/ y z)))
(if (<= y 1.06e+49)
(+ x y)
(if (<= y 2.05e+186) t_0 (- z))))))))))
double code(double x, double y, double z) {
double t_0 = (z * (x + y)) / -y;
double tmp;
if (y <= -5.5e+184) {
tmp = -z;
} else if (y <= -1350000.0) {
tmp = t_0;
} else if (y <= -1.85e-56) {
tmp = x + y;
} else if (y <= -1.8e-63) {
tmp = t_0;
} else if (y <= 4.2e-74) {
tmp = x / (1.0 - (y / z));
} else if (y <= 1.06e+49) {
tmp = x + y;
} else if (y <= 2.05e+186) {
tmp = t_0;
} else {
tmp = -z;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = (z * (x + y)) / -y
if (y <= (-5.5d+184)) then
tmp = -z
else if (y <= (-1350000.0d0)) then
tmp = t_0
else if (y <= (-1.85d-56)) then
tmp = x + y
else if (y <= (-1.8d-63)) then
tmp = t_0
else if (y <= 4.2d-74) then
tmp = x / (1.0d0 - (y / z))
else if (y <= 1.06d+49) then
tmp = x + y
else if (y <= 2.05d+186) then
tmp = t_0
else
tmp = -z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (z * (x + y)) / -y;
double tmp;
if (y <= -5.5e+184) {
tmp = -z;
} else if (y <= -1350000.0) {
tmp = t_0;
} else if (y <= -1.85e-56) {
tmp = x + y;
} else if (y <= -1.8e-63) {
tmp = t_0;
} else if (y <= 4.2e-74) {
tmp = x / (1.0 - (y / z));
} else if (y <= 1.06e+49) {
tmp = x + y;
} else if (y <= 2.05e+186) {
tmp = t_0;
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): t_0 = (z * (x + y)) / -y tmp = 0 if y <= -5.5e+184: tmp = -z elif y <= -1350000.0: tmp = t_0 elif y <= -1.85e-56: tmp = x + y elif y <= -1.8e-63: tmp = t_0 elif y <= 4.2e-74: tmp = x / (1.0 - (y / z)) elif y <= 1.06e+49: tmp = x + y elif y <= 2.05e+186: tmp = t_0 else: tmp = -z return tmp
function code(x, y, z) t_0 = Float64(Float64(z * Float64(x + y)) / Float64(-y)) tmp = 0.0 if (y <= -5.5e+184) tmp = Float64(-z); elseif (y <= -1350000.0) tmp = t_0; elseif (y <= -1.85e-56) tmp = Float64(x + y); elseif (y <= -1.8e-63) tmp = t_0; elseif (y <= 4.2e-74) tmp = Float64(x / Float64(1.0 - Float64(y / z))); elseif (y <= 1.06e+49) tmp = Float64(x + y); elseif (y <= 2.05e+186) tmp = t_0; else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (z * (x + y)) / -y; tmp = 0.0; if (y <= -5.5e+184) tmp = -z; elseif (y <= -1350000.0) tmp = t_0; elseif (y <= -1.85e-56) tmp = x + y; elseif (y <= -1.8e-63) tmp = t_0; elseif (y <= 4.2e-74) tmp = x / (1.0 - (y / z)); elseif (y <= 1.06e+49) tmp = x + y; elseif (y <= 2.05e+186) tmp = t_0; else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(z * N[(x + y), $MachinePrecision]), $MachinePrecision] / (-y)), $MachinePrecision]}, If[LessEqual[y, -5.5e+184], (-z), If[LessEqual[y, -1350000.0], t$95$0, If[LessEqual[y, -1.85e-56], N[(x + y), $MachinePrecision], If[LessEqual[y, -1.8e-63], t$95$0, If[LessEqual[y, 4.2e-74], N[(x / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.06e+49], N[(x + y), $MachinePrecision], If[LessEqual[y, 2.05e+186], t$95$0, (-z)]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{z \cdot \left(x + y\right)}{-y}\\
\mathbf{if}\;y \leq -5.5 \cdot 10^{+184}:\\
\;\;\;\;-z\\
\mathbf{elif}\;y \leq -1350000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq -1.85 \cdot 10^{-56}:\\
\;\;\;\;x + y\\
\mathbf{elif}\;y \leq -1.8 \cdot 10^{-63}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 4.2 \cdot 10^{-74}:\\
\;\;\;\;\frac{x}{1 - \frac{y}{z}}\\
\mathbf{elif}\;y \leq 1.06 \cdot 10^{+49}:\\
\;\;\;\;x + y\\
\mathbf{elif}\;y \leq 2.05 \cdot 10^{+186}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if y < -5.5000000000000002e184 or 2.05e186 < y Initial program 61.8%
Taylor expanded in y around inf 83.1%
mul-1-neg83.1%
Simplified83.1%
if -5.5000000000000002e184 < y < -1.35e6 or -1.8500000000000001e-56 < y < -1.80000000000000004e-63 or 1.06e49 < y < 2.05e186Initial program 82.5%
Taylor expanded in z around 0 77.0%
mul-1-neg77.0%
+-commutative77.0%
Simplified77.0%
if -1.35e6 < y < -1.8500000000000001e-56 or 4.2e-74 < y < 1.06e49Initial program 100.0%
Taylor expanded in z around inf 77.4%
+-commutative77.4%
Simplified77.4%
if -1.80000000000000004e-63 < y < 4.2e-74Initial program 100.0%
Taylor expanded in x around inf 84.0%
Final simplification81.0%
(FPCore (x y z) :precision binary64 (if (<= y -900000.0) (- z) (if (<= y 7.5e-9) x (if (<= y 4.2e+41) y (if (<= y 7.5e+48) x (- z))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -900000.0) {
tmp = -z;
} else if (y <= 7.5e-9) {
tmp = x;
} else if (y <= 4.2e+41) {
tmp = y;
} else if (y <= 7.5e+48) {
tmp = x;
} else {
tmp = -z;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-900000.0d0)) then
tmp = -z
else if (y <= 7.5d-9) then
tmp = x
else if (y <= 4.2d+41) then
tmp = y
else if (y <= 7.5d+48) then
tmp = x
else
tmp = -z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -900000.0) {
tmp = -z;
} else if (y <= 7.5e-9) {
tmp = x;
} else if (y <= 4.2e+41) {
tmp = y;
} else if (y <= 7.5e+48) {
tmp = x;
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -900000.0: tmp = -z elif y <= 7.5e-9: tmp = x elif y <= 4.2e+41: tmp = y elif y <= 7.5e+48: tmp = x else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if (y <= -900000.0) tmp = Float64(-z); elseif (y <= 7.5e-9) tmp = x; elseif (y <= 4.2e+41) tmp = y; elseif (y <= 7.5e+48) tmp = x; else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -900000.0) tmp = -z; elseif (y <= 7.5e-9) tmp = x; elseif (y <= 4.2e+41) tmp = y; elseif (y <= 7.5e+48) tmp = x; else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -900000.0], (-z), If[LessEqual[y, 7.5e-9], x, If[LessEqual[y, 4.2e+41], y, If[LessEqual[y, 7.5e+48], x, (-z)]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -900000:\\
\;\;\;\;-z\\
\mathbf{elif}\;y \leq 7.5 \cdot 10^{-9}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 4.2 \cdot 10^{+41}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 7.5 \cdot 10^{+48}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if y < -9e5 or 7.5000000000000006e48 < y Initial program 72.6%
Taylor expanded in y around inf 66.7%
mul-1-neg66.7%
Simplified66.7%
if -9e5 < y < 7.49999999999999933e-9 or 4.1999999999999999e41 < y < 7.5000000000000006e48Initial program 100.0%
Taylor expanded in y around 0 64.5%
if 7.49999999999999933e-9 < y < 4.1999999999999999e41Initial program 100.0%
Taylor expanded in x around 0 64.5%
Taylor expanded in y around 0 61.6%
(FPCore (x y z) :precision binary64 (if (or (<= y -3000000.0) (not (<= y 2.4e+49))) (* z (/ (- (- y) x) y)) (+ x y)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -3000000.0) || !(y <= 2.4e+49)) {
tmp = z * ((-y - x) / y);
} else {
tmp = x + y;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((y <= (-3000000.0d0)) .or. (.not. (y <= 2.4d+49))) then
tmp = z * ((-y - x) / y)
else
tmp = x + y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -3000000.0) || !(y <= 2.4e+49)) {
tmp = z * ((-y - x) / y);
} else {
tmp = x + y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -3000000.0) or not (y <= 2.4e+49): tmp = z * ((-y - x) / y) else: tmp = x + y return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -3000000.0) || !(y <= 2.4e+49)) tmp = Float64(z * Float64(Float64(Float64(-y) - x) / y)); else tmp = Float64(x + y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -3000000.0) || ~((y <= 2.4e+49))) tmp = z * ((-y - x) / y); else tmp = x + y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -3000000.0], N[Not[LessEqual[y, 2.4e+49]], $MachinePrecision]], N[(z * N[(N[((-y) - x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(x + y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3000000 \lor \neg \left(y \leq 2.4 \cdot 10^{+49}\right):\\
\;\;\;\;z \cdot \frac{\left(-y\right) - x}{y}\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
\end{array}
if y < -3e6 or 2.4e49 < y Initial program 72.6%
Taylor expanded in z around 0 65.5%
mul-1-neg65.5%
associate-/l*85.0%
distribute-rgt-neg-in85.0%
distribute-neg-frac285.0%
+-commutative85.0%
Simplified85.0%
if -3e6 < y < 2.4e49Initial program 100.0%
Taylor expanded in z around inf 78.3%
+-commutative78.3%
Simplified78.3%
Final simplification81.5%
(FPCore (x y z) :precision binary64 (if (<= y -1.4e+100) (- z) (if (<= y -11.0) (/ y (- 1.0 (/ y z))) (if (<= y 1.65e+50) (+ x y) (- z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.4e+100) {
tmp = -z;
} else if (y <= -11.0) {
tmp = y / (1.0 - (y / z));
} else if (y <= 1.65e+50) {
tmp = x + y;
} else {
tmp = -z;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-1.4d+100)) then
tmp = -z
else if (y <= (-11.0d0)) then
tmp = y / (1.0d0 - (y / z))
else if (y <= 1.65d+50) then
tmp = x + y
else
tmp = -z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -1.4e+100) {
tmp = -z;
} else if (y <= -11.0) {
tmp = y / (1.0 - (y / z));
} else if (y <= 1.65e+50) {
tmp = x + y;
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.4e+100: tmp = -z elif y <= -11.0: tmp = y / (1.0 - (y / z)) elif y <= 1.65e+50: tmp = x + y else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.4e+100) tmp = Float64(-z); elseif (y <= -11.0) tmp = Float64(y / Float64(1.0 - Float64(y / z))); elseif (y <= 1.65e+50) tmp = Float64(x + y); else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.4e+100) tmp = -z; elseif (y <= -11.0) tmp = y / (1.0 - (y / z)); elseif (y <= 1.65e+50) tmp = x + y; else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.4e+100], (-z), If[LessEqual[y, -11.0], N[(y / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.65e+50], N[(x + y), $MachinePrecision], (-z)]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.4 \cdot 10^{+100}:\\
\;\;\;\;-z\\
\mathbf{elif}\;y \leq -11:\\
\;\;\;\;\frac{y}{1 - \frac{y}{z}}\\
\mathbf{elif}\;y \leq 1.65 \cdot 10^{+50}:\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if y < -1.3999999999999999e100 or 1.65e50 < y Initial program 68.5%
Taylor expanded in y around inf 72.5%
mul-1-neg72.5%
Simplified72.5%
if -1.3999999999999999e100 < y < -11Initial program 95.2%
Taylor expanded in x around 0 60.3%
if -11 < y < 1.65e50Initial program 100.0%
Taylor expanded in z around inf 78.6%
+-commutative78.6%
Simplified78.6%
Final simplification74.7%
(FPCore (x y z) :precision binary64 (if (or (<= y -7000000.0) (not (<= y 2.7e+50))) (- z) (+ x y)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -7000000.0) || !(y <= 2.7e+50)) {
tmp = -z;
} else {
tmp = x + y;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((y <= (-7000000.0d0)) .or. (.not. (y <= 2.7d+50))) then
tmp = -z
else
tmp = x + y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -7000000.0) || !(y <= 2.7e+50)) {
tmp = -z;
} else {
tmp = x + y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -7000000.0) or not (y <= 2.7e+50): tmp = -z else: tmp = x + y return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -7000000.0) || !(y <= 2.7e+50)) tmp = Float64(-z); else tmp = Float64(x + y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -7000000.0) || ~((y <= 2.7e+50))) tmp = -z; else tmp = x + y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -7000000.0], N[Not[LessEqual[y, 2.7e+50]], $MachinePrecision]], (-z), N[(x + y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7000000 \lor \neg \left(y \leq 2.7 \cdot 10^{+50}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
\end{array}
if y < -7e6 or 2.7e50 < y Initial program 72.6%
Taylor expanded in y around inf 66.7%
mul-1-neg66.7%
Simplified66.7%
if -7e6 < y < 2.7e50Initial program 100.0%
Taylor expanded in z around inf 78.3%
+-commutative78.3%
Simplified78.3%
Final simplification72.7%
(FPCore (x y z) :precision binary64 (if (<= x -1.9e-136) x (if (<= x 1.55e-125) y x)))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.9e-136) {
tmp = x;
} else if (x <= 1.55e-125) {
tmp = y;
} else {
tmp = x;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (x <= (-1.9d-136)) then
tmp = x
else if (x <= 1.55d-125) then
tmp = y
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -1.9e-136) {
tmp = x;
} else if (x <= 1.55e-125) {
tmp = y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1.9e-136: tmp = x elif x <= 1.55e-125: tmp = y else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if (x <= -1.9e-136) tmp = x; elseif (x <= 1.55e-125) tmp = y; else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -1.9e-136) tmp = x; elseif (x <= 1.55e-125) tmp = y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1.9e-136], x, If[LessEqual[x, 1.55e-125], y, x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.9 \cdot 10^{-136}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 1.55 \cdot 10^{-125}:\\
\;\;\;\;y\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -1.9000000000000001e-136 or 1.55000000000000006e-125 < x Initial program 84.6%
Taylor expanded in y around 0 42.5%
if -1.9000000000000001e-136 < x < 1.55000000000000006e-125Initial program 92.7%
Taylor expanded in x around 0 83.2%
Taylor expanded in y around 0 42.5%
(FPCore (x y z) :precision binary64 x)
double code(double x, double y, double z) {
return x;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x
end function
public static double code(double x, double y, double z) {
return x;
}
def code(x, y, z): return x
function code(x, y, z) return x end
function tmp = code(x, y, z) tmp = x; end
code[x_, y_, z_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 86.7%
Taylor expanded in y around 0 35.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (/ (+ y x) (- y)) z)))
(if (< y -3.7429310762689856e+171)
t_0
(if (< y 3.5534662456086734e+168) (/ (+ x y) (- 1.0 (/ y z))) t_0))))
double code(double x, double y, double z) {
double t_0 = ((y + x) / -y) * z;
double tmp;
if (y < -3.7429310762689856e+171) {
tmp = t_0;
} else if (y < 3.5534662456086734e+168) {
tmp = (x + y) / (1.0 - (y / z));
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = ((y + x) / -y) * z
if (y < (-3.7429310762689856d+171)) then
tmp = t_0
else if (y < 3.5534662456086734d+168) then
tmp = (x + y) / (1.0d0 - (y / z))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = ((y + x) / -y) * z;
double tmp;
if (y < -3.7429310762689856e+171) {
tmp = t_0;
} else if (y < 3.5534662456086734e+168) {
tmp = (x + y) / (1.0 - (y / z));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = ((y + x) / -y) * z tmp = 0 if y < -3.7429310762689856e+171: tmp = t_0 elif y < 3.5534662456086734e+168: tmp = (x + y) / (1.0 - (y / z)) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(Float64(y + x) / Float64(-y)) * z) tmp = 0.0 if (y < -3.7429310762689856e+171) tmp = t_0; elseif (y < 3.5534662456086734e+168) tmp = Float64(Float64(x + y) / Float64(1.0 - Float64(y / z))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = ((y + x) / -y) * z; tmp = 0.0; if (y < -3.7429310762689856e+171) tmp = t_0; elseif (y < 3.5534662456086734e+168) tmp = (x + y) / (1.0 - (y / z)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(y + x), $MachinePrecision] / (-y)), $MachinePrecision] * z), $MachinePrecision]}, If[Less[y, -3.7429310762689856e+171], t$95$0, If[Less[y, 3.5534662456086734e+168], N[(N[(x + y), $MachinePrecision] / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y + x}{-y} \cdot z\\
\mathbf{if}\;y < -3.7429310762689856 \cdot 10^{+171}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y < 3.5534662456086734 \cdot 10^{+168}:\\
\;\;\;\;\frac{x + y}{1 - \frac{y}{z}}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
herbie shell --seed 2024100
(FPCore (x y z)
:name "Graphics.Rendering.Chart.Backend.Diagrams:calcFontMetrics from Chart-diagrams-1.5.1, A"
:precision binary64
:alt
(if (< y -3.7429310762689856e+171) (* (/ (+ y x) (- y)) z) (if (< y 3.5534662456086734e+168) (/ (+ x y) (- 1.0 (/ y z))) (* (/ (+ y x) (- y)) z)))
(/ (+ x y) (- 1.0 (/ y z))))