
(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 10 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 (<= t_0 -2e-243)
(* (/ z (- z y)) (+ x y))
(if (<= t_0 2e-190) (* z (/ (+ x y) (- z y))) t_0))))
double code(double x, double y, double z) {
double t_0 = (x + y) / (1.0 - (y / z));
double tmp;
if (t_0 <= -2e-243) {
tmp = (z / (z - y)) * (x + y);
} else if (t_0 <= 2e-190) {
tmp = z * ((x + y) / (z - y));
} 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 = (x + y) / (1.0d0 - (y / z))
if (t_0 <= (-2d-243)) then
tmp = (z / (z - y)) * (x + y)
else if (t_0 <= 2d-190) then
tmp = z * ((x + y) / (z - y))
else
tmp = t_0
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 <= -2e-243) {
tmp = (z / (z - y)) * (x + y);
} else if (t_0 <= 2e-190) {
tmp = z * ((x + y) / (z - y));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (x + y) / (1.0 - (y / z)) tmp = 0 if t_0 <= -2e-243: tmp = (z / (z - y)) * (x + y) elif t_0 <= 2e-190: tmp = z * ((x + y) / (z - y)) else: tmp = t_0 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 <= -2e-243) tmp = Float64(Float64(z / Float64(z - y)) * Float64(x + y)); elseif (t_0 <= 2e-190) tmp = Float64(z * Float64(Float64(x + y) / Float64(z - y))); else tmp = t_0; 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 <= -2e-243) tmp = (z / (z - y)) * (x + y); elseif (t_0 <= 2e-190) tmp = z * ((x + y) / (z - y)); else tmp = t_0; 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[LessEqual[t$95$0, -2e-243], N[(N[(z / N[(z - y), $MachinePrecision]), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 2e-190], N[(z * N[(N[(x + y), $MachinePrecision] / N[(z - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x + y}{1 - \frac{y}{z}}\\
\mathbf{if}\;t\_0 \leq -2 \cdot 10^{-243}:\\
\;\;\;\;\frac{z}{z - y} \cdot \left(x + y\right)\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{-190}:\\
\;\;\;\;z \cdot \frac{x + y}{z - y}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (/.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) (/.f64 y z))) < -1.99999999999999999e-243Initial program 99.9%
Taylor expanded in z around 0 99.9%
Taylor expanded in x around 0 76.6%
associate-*r/87.3%
associate-/l*99.9%
distribute-rgt-in99.9%
+-commutative99.9%
Simplified99.9%
if -1.99999999999999999e-243 < (/.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) (/.f64 y z))) < 2e-190Initial program 33.2%
Taylor expanded in z around 0 33.2%
associate-/r/99.9%
Applied egg-rr99.9%
if 2e-190 < (/.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) (/.f64 y z))) Initial program 99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (or (<= y -1e+63) (not (<= y 4.8e-71))) (* z (/ (+ x y) (- z y))) (* (/ z (- z y)) (+ x y))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1e+63) || !(y <= 4.8e-71)) {
tmp = z * ((x + y) / (z - y));
} else {
tmp = (z / (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) :: tmp
if ((y <= (-1d+63)) .or. (.not. (y <= 4.8d-71))) then
tmp = z * ((x + y) / (z - y))
else
tmp = (z / (z - y)) * (x + y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -1e+63) || !(y <= 4.8e-71)) {
tmp = z * ((x + y) / (z - y));
} else {
tmp = (z / (z - y)) * (x + y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1e+63) or not (y <= 4.8e-71): tmp = z * ((x + y) / (z - y)) else: tmp = (z / (z - y)) * (x + y) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1e+63) || !(y <= 4.8e-71)) tmp = Float64(z * Float64(Float64(x + y) / Float64(z - y))); else tmp = Float64(Float64(z / Float64(z - y)) * Float64(x + y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1e+63) || ~((y <= 4.8e-71))) tmp = z * ((x + y) / (z - y)); else tmp = (z / (z - y)) * (x + y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1e+63], N[Not[LessEqual[y, 4.8e-71]], $MachinePrecision]], N[(z * N[(N[(x + y), $MachinePrecision] / N[(z - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(z / N[(z - y), $MachinePrecision]), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1 \cdot 10^{+63} \lor \neg \left(y \leq 4.8 \cdot 10^{-71}\right):\\
\;\;\;\;z \cdot \frac{x + y}{z - y}\\
\mathbf{else}:\\
\;\;\;\;\frac{z}{z - y} \cdot \left(x + y\right)\\
\end{array}
\end{array}
if y < -1.00000000000000006e63 or 4.8e-71 < y Initial program 76.6%
Taylor expanded in z around 0 76.6%
associate-/r/99.8%
Applied egg-rr99.8%
if -1.00000000000000006e63 < y < 4.8e-71Initial program 99.9%
Taylor expanded in z around 0 99.9%
Taylor expanded in x around 0 84.1%
associate-*r/96.2%
associate-/l*100.0%
distribute-rgt-in99.9%
+-commutative99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (or (<= y -5e+66) (not (<= y 2.9e+182))) (* z (/ y (- z y))) (* (/ z (- z y)) (+ x y))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -5e+66) || !(y <= 2.9e+182)) {
tmp = z * (y / (z - y));
} else {
tmp = (z / (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) :: tmp
if ((y <= (-5d+66)) .or. (.not. (y <= 2.9d+182))) then
tmp = z * (y / (z - y))
else
tmp = (z / (z - y)) * (x + y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -5e+66) || !(y <= 2.9e+182)) {
tmp = z * (y / (z - y));
} else {
tmp = (z / (z - y)) * (x + y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -5e+66) or not (y <= 2.9e+182): tmp = z * (y / (z - y)) else: tmp = (z / (z - y)) * (x + y) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -5e+66) || !(y <= 2.9e+182)) tmp = Float64(z * Float64(y / Float64(z - y))); else tmp = Float64(Float64(z / Float64(z - y)) * Float64(x + y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -5e+66) || ~((y <= 2.9e+182))) tmp = z * (y / (z - y)); else tmp = (z / (z - y)) * (x + y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -5e+66], N[Not[LessEqual[y, 2.9e+182]], $MachinePrecision]], N[(z * N[(y / N[(z - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(z / N[(z - y), $MachinePrecision]), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5 \cdot 10^{+66} \lor \neg \left(y \leq 2.9 \cdot 10^{+182}\right):\\
\;\;\;\;z \cdot \frac{y}{z - y}\\
\mathbf{else}:\\
\;\;\;\;\frac{z}{z - y} \cdot \left(x + y\right)\\
\end{array}
\end{array}
if y < -4.99999999999999991e66 or 2.8999999999999998e182 < y Initial program 66.1%
Taylor expanded in z around 0 66.1%
associate-/r/99.9%
Applied egg-rr99.9%
Taylor expanded in x around 0 91.4%
if -4.99999999999999991e66 < y < 2.8999999999999998e182Initial program 97.3%
Taylor expanded in z around 0 97.3%
Taylor expanded in x around 0 82.6%
associate-*r/93.9%
associate-/l*98.1%
distribute-rgt-in98.1%
+-commutative98.1%
Simplified98.1%
Final simplification96.0%
(FPCore (x y z) :precision binary64 (if (<= y -3.2e+85) (- z) (if (<= y -3e-71) (* y (/ z (- z y))) (if (<= y 3.6e+91) (+ x y) (- z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -3.2e+85) {
tmp = -z;
} else if (y <= -3e-71) {
tmp = y * (z / (z - y));
} else if (y <= 3.6e+91) {
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 <= (-3.2d+85)) then
tmp = -z
else if (y <= (-3d-71)) then
tmp = y * (z / (z - y))
else if (y <= 3.6d+91) 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 <= -3.2e+85) {
tmp = -z;
} else if (y <= -3e-71) {
tmp = y * (z / (z - y));
} else if (y <= 3.6e+91) {
tmp = x + y;
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -3.2e+85: tmp = -z elif y <= -3e-71: tmp = y * (z / (z - y)) elif y <= 3.6e+91: tmp = x + y else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if (y <= -3.2e+85) tmp = Float64(-z); elseif (y <= -3e-71) tmp = Float64(y * Float64(z / Float64(z - y))); elseif (y <= 3.6e+91) tmp = Float64(x + y); else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -3.2e+85) tmp = -z; elseif (y <= -3e-71) tmp = y * (z / (z - y)); elseif (y <= 3.6e+91) tmp = x + y; else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -3.2e+85], (-z), If[LessEqual[y, -3e-71], N[(y * N[(z / N[(z - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.6e+91], N[(x + y), $MachinePrecision], (-z)]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.2 \cdot 10^{+85}:\\
\;\;\;\;-z\\
\mathbf{elif}\;y \leq -3 \cdot 10^{-71}:\\
\;\;\;\;y \cdot \frac{z}{z - y}\\
\mathbf{elif}\;y \leq 3.6 \cdot 10^{+91}:\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if y < -3.20000000000000018e85 or 3.6e91 < y Initial program 72.1%
Taylor expanded in y around inf 69.7%
neg-mul-169.7%
Simplified69.7%
if -3.20000000000000018e85 < y < -3.0000000000000001e-71Initial program 93.3%
Taylor expanded in z around 0 93.3%
Taylor expanded in x around 0 50.8%
associate-/l*53.4%
Simplified53.4%
if -3.0000000000000001e-71 < y < 3.6e91Initial program 98.4%
Taylor expanded in z around inf 73.2%
+-commutative73.2%
Simplified73.2%
Final simplification68.7%
(FPCore (x y z) :precision binary64 (if (or (<= x -2.1e+109) (not (<= x 2.3e-18))) (/ x (- 1.0 (/ y z))) (* z (/ y (- z y)))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -2.1e+109) || !(x <= 2.3e-18)) {
tmp = x / (1.0 - (y / z));
} else {
tmp = z * (y / (z - 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 ((x <= (-2.1d+109)) .or. (.not. (x <= 2.3d-18))) then
tmp = x / (1.0d0 - (y / z))
else
tmp = z * (y / (z - y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -2.1e+109) || !(x <= 2.3e-18)) {
tmp = x / (1.0 - (y / z));
} else {
tmp = z * (y / (z - y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -2.1e+109) or not (x <= 2.3e-18): tmp = x / (1.0 - (y / z)) else: tmp = z * (y / (z - y)) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -2.1e+109) || !(x <= 2.3e-18)) tmp = Float64(x / Float64(1.0 - Float64(y / z))); else tmp = Float64(z * Float64(y / Float64(z - y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -2.1e+109) || ~((x <= 2.3e-18))) tmp = x / (1.0 - (y / z)); else tmp = z * (y / (z - y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -2.1e+109], N[Not[LessEqual[x, 2.3e-18]], $MachinePrecision]], N[(x / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z * N[(y / N[(z - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.1 \cdot 10^{+109} \lor \neg \left(x \leq 2.3 \cdot 10^{-18}\right):\\
\;\;\;\;\frac{x}{1 - \frac{y}{z}}\\
\mathbf{else}:\\
\;\;\;\;z \cdot \frac{y}{z - y}\\
\end{array}
\end{array}
if x < -2.1000000000000001e109 or 2.3000000000000001e-18 < x Initial program 94.7%
Taylor expanded in x around inf 80.8%
if -2.1000000000000001e109 < x < 2.3000000000000001e-18Initial program 82.7%
Taylor expanded in z around 0 82.7%
associate-/r/95.5%
Applied egg-rr95.5%
Taylor expanded in x around 0 76.1%
Final simplification78.1%
(FPCore (x y z) :precision binary64 (if (or (<= y -3.8e-71) (not (<= y 8.8e+88))) (* z (/ y (- z y))) (+ x y)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -3.8e-71) || !(y <= 8.8e+88)) {
tmp = z * (y / (z - 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 <= (-3.8d-71)) .or. (.not. (y <= 8.8d+88))) then
tmp = z * (y / (z - 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 <= -3.8e-71) || !(y <= 8.8e+88)) {
tmp = z * (y / (z - y));
} else {
tmp = x + y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -3.8e-71) or not (y <= 8.8e+88): tmp = z * (y / (z - y)) else: tmp = x + y return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -3.8e-71) || !(y <= 8.8e+88)) tmp = Float64(z * Float64(y / Float64(z - y))); else tmp = Float64(x + y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -3.8e-71) || ~((y <= 8.8e+88))) tmp = z * (y / (z - y)); else tmp = x + y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -3.8e-71], N[Not[LessEqual[y, 8.8e+88]], $MachinePrecision]], N[(z * N[(y / N[(z - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.8 \cdot 10^{-71} \lor \neg \left(y \leq 8.8 \cdot 10^{+88}\right):\\
\;\;\;\;z \cdot \frac{y}{z - y}\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
\end{array}
if y < -3.79999999999999992e-71 or 8.80000000000000035e88 < y Initial program 78.5%
Taylor expanded in z around 0 78.5%
associate-/r/99.9%
Applied egg-rr99.9%
Taylor expanded in x around 0 75.3%
if -3.79999999999999992e-71 < y < 8.80000000000000035e88Initial program 98.4%
Taylor expanded in z around inf 73.2%
+-commutative73.2%
Simplified73.2%
Final simplification74.3%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.65e+49) (not (<= y 2.35e+89))) (- z) (+ x y)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.65e+49) || !(y <= 2.35e+89)) {
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 <= (-1.65d+49)) .or. (.not. (y <= 2.35d+89))) 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 <= -1.65e+49) || !(y <= 2.35e+89)) {
tmp = -z;
} else {
tmp = x + y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.65e+49) or not (y <= 2.35e+89): tmp = -z else: tmp = x + y return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.65e+49) || !(y <= 2.35e+89)) tmp = Float64(-z); else tmp = Float64(x + y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1.65e+49) || ~((y <= 2.35e+89))) tmp = -z; else tmp = x + y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.65e+49], N[Not[LessEqual[y, 2.35e+89]], $MachinePrecision]], (-z), N[(x + y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.65 \cdot 10^{+49} \lor \neg \left(y \leq 2.35 \cdot 10^{+89}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
\end{array}
if y < -1.6499999999999999e49 or 2.35000000000000011e89 < y Initial program 72.9%
Taylor expanded in y around inf 66.2%
neg-mul-166.2%
Simplified66.2%
if -1.6499999999999999e49 < y < 2.35000000000000011e89Initial program 98.7%
Taylor expanded in z around inf 67.2%
+-commutative67.2%
Simplified67.2%
Final simplification66.7%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.46e-40) (not (<= y 9.2e+88))) (- z) x))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.46e-40) || !(y <= 9.2e+88)) {
tmp = -z;
} 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 ((y <= (-1.46d-40)) .or. (.not. (y <= 9.2d+88))) then
tmp = -z
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -1.46e-40) || !(y <= 9.2e+88)) {
tmp = -z;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.46e-40) or not (y <= 9.2e+88): tmp = -z else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.46e-40) || !(y <= 9.2e+88)) tmp = Float64(-z); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1.46e-40) || ~((y <= 9.2e+88))) tmp = -z; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.46e-40], N[Not[LessEqual[y, 9.2e+88]], $MachinePrecision]], (-z), x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.46 \cdot 10^{-40} \lor \neg \left(y \leq 9.2 \cdot 10^{+88}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -1.46000000000000005e-40 or 9.2000000000000007e88 < y Initial program 77.8%
Taylor expanded in y around inf 59.8%
neg-mul-159.8%
Simplified59.8%
if -1.46000000000000005e-40 < y < 9.2000000000000007e88Initial program 98.4%
Taylor expanded in y around 0 60.1%
Final simplification59.9%
(FPCore (x y z) :precision binary64 (if (<= x -1.35e-121) x (if (<= x 2.4e-201) y x)))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.35e-121) {
tmp = x;
} else if (x <= 2.4e-201) {
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.35d-121)) then
tmp = x
else if (x <= 2.4d-201) 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.35e-121) {
tmp = x;
} else if (x <= 2.4e-201) {
tmp = y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1.35e-121: tmp = x elif x <= 2.4e-201: tmp = y else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if (x <= -1.35e-121) tmp = x; elseif (x <= 2.4e-201) tmp = y; else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -1.35e-121) tmp = x; elseif (x <= 2.4e-201) tmp = y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1.35e-121], x, If[LessEqual[x, 2.4e-201], y, x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.35 \cdot 10^{-121}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 2.4 \cdot 10^{-201}:\\
\;\;\;\;y\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -1.3500000000000001e-121 or 2.40000000000000009e-201 < x Initial program 89.2%
Taylor expanded in y around 0 40.4%
if -1.3500000000000001e-121 < x < 2.40000000000000009e-201Initial program 83.9%
Taylor expanded in x around 0 73.7%
Taylor expanded in y around 0 36.0%
(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 87.9%
Taylor expanded in y around 0 33.9%
(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 2024116
(FPCore (x y z)
:name "Graphics.Rendering.Chart.Backend.Diagrams:calcFontMetrics from Chart-diagrams-1.5.1, A"
:precision binary64
:alt
(! :herbie-platform default (if (< y -3742931076268985600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (* (/ (+ y x) (- y)) z) (if (< y 3553466245608673400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (/ (+ x y) (- 1 (/ y z))) (* (/ (+ y x) (- y)) z))))
(/ (+ x y) (- 1.0 (/ y z))))