
(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 12 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 -5e-247)
(/ (+ x y) (/ (- z y) z))
(if (<= t_0 0.0) (* z (/ (- (- x) y) 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 <= -5e-247) {
tmp = (x + y) / ((z - y) / z);
} else if (t_0 <= 0.0) {
tmp = z * ((-x - y) / 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 <= (-5d-247)) then
tmp = (x + y) / ((z - y) / z)
else if (t_0 <= 0.0d0) then
tmp = z * ((-x - y) / 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 <= -5e-247) {
tmp = (x + y) / ((z - y) / z);
} else if (t_0 <= 0.0) {
tmp = z * ((-x - y) / 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 <= -5e-247: tmp = (x + y) / ((z - y) / z) elif t_0 <= 0.0: tmp = z * ((-x - y) / 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 <= -5e-247) tmp = Float64(Float64(x + y) / Float64(Float64(z - y) / z)); elseif (t_0 <= 0.0) tmp = Float64(z * Float64(Float64(Float64(-x) - y) / 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 <= -5e-247) tmp = (x + y) / ((z - y) / z); elseif (t_0 <= 0.0) tmp = z * ((-x - y) / 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, -5e-247], N[(N[(x + y), $MachinePrecision] / N[(N[(z - y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 0.0], N[(z * N[(N[((-x) - y), $MachinePrecision] / y), $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 -5 \cdot 10^{-247}:\\
\;\;\;\;\frac{x + y}{\frac{z - y}{z}}\\
\mathbf{elif}\;t\_0 \leq 0:\\
\;\;\;\;z \cdot \frac{\left(-x\right) - y}{y}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (/.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) (/.f64 y z))) < -4.99999999999999978e-247Initial program 99.8%
Taylor expanded in z around 0 99.8%
if -4.99999999999999978e-247 < (/.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) (/.f64 y z))) < 0.0Initial program 12.1%
Taylor expanded in z around 0 94.0%
mul-1-neg94.0%
associate-/l*100.0%
distribute-rgt-neg-in100.0%
distribute-neg-frac2100.0%
+-commutative100.0%
Simplified100.0%
if 0.0 < (/.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 (let* ((t_0 (/ (+ x y) (- 1.0 (/ y z))))) (if (or (<= t_0 -5e-247) (not (<= t_0 0.0))) t_0 (* z (/ (- (- x) y) y)))))
double code(double x, double y, double z) {
double t_0 = (x + y) / (1.0 - (y / z));
double tmp;
if ((t_0 <= -5e-247) || !(t_0 <= 0.0)) {
tmp = t_0;
} else {
tmp = z * ((-x - y) / 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-247)) .or. (.not. (t_0 <= 0.0d0))) then
tmp = t_0
else
tmp = z * ((-x - y) / 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-247) || !(t_0 <= 0.0)) {
tmp = t_0;
} else {
tmp = z * ((-x - y) / y);
}
return tmp;
}
def code(x, y, z): t_0 = (x + y) / (1.0 - (y / z)) tmp = 0 if (t_0 <= -5e-247) or not (t_0 <= 0.0): tmp = t_0 else: tmp = z * ((-x - y) / 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-247) || !(t_0 <= 0.0)) tmp = t_0; else tmp = Float64(z * Float64(Float64(Float64(-x) - y) / 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-247) || ~((t_0 <= 0.0))) tmp = t_0; else tmp = z * ((-x - y) / 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-247], N[Not[LessEqual[t$95$0, 0.0]], $MachinePrecision]], t$95$0, N[(z * N[(N[((-x) - y), $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^{-247} \lor \neg \left(t\_0 \leq 0\right):\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;z \cdot \frac{\left(-x\right) - y}{y}\\
\end{array}
\end{array}
if (/.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) (/.f64 y z))) < -4.99999999999999978e-247 or 0.0 < (/.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) (/.f64 y z))) Initial program 99.8%
if -4.99999999999999978e-247 < (/.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) (/.f64 y z))) < 0.0Initial program 12.1%
Taylor expanded in z around 0 94.0%
mul-1-neg94.0%
associate-/l*100.0%
distribute-rgt-neg-in100.0%
distribute-neg-frac2100.0%
+-commutative100.0%
Simplified100.0%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (or (<= z -7.5e-25) (not (<= z 4.5e-14))) (* (+ x y) (+ 1.0 (/ y z))) (/ (* z (- (- x) y)) y)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -7.5e-25) || !(z <= 4.5e-14)) {
tmp = (x + y) * (1.0 + (y / z));
} else {
tmp = (z * (-x - y)) / 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 ((z <= (-7.5d-25)) .or. (.not. (z <= 4.5d-14))) then
tmp = (x + y) * (1.0d0 + (y / z))
else
tmp = (z * (-x - y)) / y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -7.5e-25) || !(z <= 4.5e-14)) {
tmp = (x + y) * (1.0 + (y / z));
} else {
tmp = (z * (-x - y)) / y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -7.5e-25) or not (z <= 4.5e-14): tmp = (x + y) * (1.0 + (y / z)) else: tmp = (z * (-x - y)) / y return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -7.5e-25) || !(z <= 4.5e-14)) tmp = Float64(Float64(x + y) * Float64(1.0 + Float64(y / z))); else tmp = Float64(Float64(z * Float64(Float64(-x) - y)) / y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -7.5e-25) || ~((z <= 4.5e-14))) tmp = (x + y) * (1.0 + (y / z)); else tmp = (z * (-x - y)) / y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -7.5e-25], N[Not[LessEqual[z, 4.5e-14]], $MachinePrecision]], N[(N[(x + y), $MachinePrecision] * N[(1.0 + N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(z * N[((-x) - y), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -7.5 \cdot 10^{-25} \lor \neg \left(z \leq 4.5 \cdot 10^{-14}\right):\\
\;\;\;\;\left(x + y\right) \cdot \left(1 + \frac{y}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{z \cdot \left(\left(-x\right) - y\right)}{y}\\
\end{array}
\end{array}
if z < -7.49999999999999989e-25 or 4.4999999999999998e-14 < z Initial program 99.9%
Taylor expanded in z around inf 74.0%
associate-+r+74.0%
*-rgt-identity74.0%
*-commutative74.0%
associate-/l*78.3%
distribute-lft-in78.3%
+-commutative78.3%
Simplified78.3%
if -7.49999999999999989e-25 < z < 4.4999999999999998e-14Initial program 77.6%
Taylor expanded in z around 0 76.8%
associate-*r/76.8%
*-commutative76.8%
associate-*r*76.8%
neg-mul-176.8%
distribute-neg-in76.8%
unsub-neg76.8%
Simplified76.8%
Final simplification77.6%
(FPCore (x y z) :precision binary64 (if (or (<= z -5.8e-25) (not (<= z 2.2e-17))) (+ x y) (/ (* z (- (- x) y)) y)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -5.8e-25) || !(z <= 2.2e-17)) {
tmp = x + y;
} else {
tmp = (z * (-x - y)) / 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 ((z <= (-5.8d-25)) .or. (.not. (z <= 2.2d-17))) then
tmp = x + y
else
tmp = (z * (-x - y)) / y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -5.8e-25) || !(z <= 2.2e-17)) {
tmp = x + y;
} else {
tmp = (z * (-x - y)) / y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -5.8e-25) or not (z <= 2.2e-17): tmp = x + y else: tmp = (z * (-x - y)) / y return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -5.8e-25) || !(z <= 2.2e-17)) tmp = Float64(x + y); else tmp = Float64(Float64(z * Float64(Float64(-x) - y)) / y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -5.8e-25) || ~((z <= 2.2e-17))) tmp = x + y; else tmp = (z * (-x - y)) / y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -5.8e-25], N[Not[LessEqual[z, 2.2e-17]], $MachinePrecision]], N[(x + y), $MachinePrecision], N[(N[(z * N[((-x) - y), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.8 \cdot 10^{-25} \lor \neg \left(z \leq 2.2 \cdot 10^{-17}\right):\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;\frac{z \cdot \left(\left(-x\right) - y\right)}{y}\\
\end{array}
\end{array}
if z < -5.8000000000000001e-25 or 2.2e-17 < z Initial program 99.9%
Taylor expanded in z around inf 78.1%
+-commutative78.1%
Simplified78.1%
if -5.8000000000000001e-25 < z < 2.2e-17Initial program 77.6%
Taylor expanded in z around 0 76.8%
associate-*r/76.8%
*-commutative76.8%
associate-*r*76.8%
neg-mul-176.8%
distribute-neg-in76.8%
unsub-neg76.8%
Simplified76.8%
Final simplification77.5%
(FPCore (x y z) :precision binary64 (if (or (<= y -6.5e-80) (not (<= y 2.5e-25))) (* z (/ (- (- x) y) y)) (+ x y)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -6.5e-80) || !(y <= 2.5e-25)) {
tmp = z * ((-x - y) / 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 <= (-6.5d-80)) .or. (.not. (y <= 2.5d-25))) then
tmp = z * ((-x - y) / 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 <= -6.5e-80) || !(y <= 2.5e-25)) {
tmp = z * ((-x - y) / y);
} else {
tmp = x + y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -6.5e-80) or not (y <= 2.5e-25): tmp = z * ((-x - y) / y) else: tmp = x + y return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -6.5e-80) || !(y <= 2.5e-25)) tmp = Float64(z * Float64(Float64(Float64(-x) - y) / y)); else tmp = Float64(x + y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -6.5e-80) || ~((y <= 2.5e-25))) tmp = z * ((-x - y) / y); else tmp = x + y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -6.5e-80], N[Not[LessEqual[y, 2.5e-25]], $MachinePrecision]], N[(z * N[(N[((-x) - y), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(x + y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.5 \cdot 10^{-80} \lor \neg \left(y \leq 2.5 \cdot 10^{-25}\right):\\
\;\;\;\;z \cdot \frac{\left(-x\right) - y}{y}\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
\end{array}
if y < -6.49999999999999984e-80 or 2.49999999999999981e-25 < y Initial program 80.8%
Taylor expanded in z around 0 64.1%
mul-1-neg64.1%
associate-/l*73.4%
distribute-rgt-neg-in73.4%
distribute-neg-frac273.4%
+-commutative73.4%
Simplified73.4%
if -6.49999999999999984e-80 < y < 2.49999999999999981e-25Initial program 99.9%
Taylor expanded in z around inf 82.1%
+-commutative82.1%
Simplified82.1%
Final simplification77.0%
(FPCore (x y z) :precision binary64 (let* ((t_0 (/ z (- z y)))) (if (or (<= x -2.8e-63) (not (<= x 3.5e-123))) (* x t_0) (* y t_0))))
double code(double x, double y, double z) {
double t_0 = z / (z - y);
double tmp;
if ((x <= -2.8e-63) || !(x <= 3.5e-123)) {
tmp = x * t_0;
} else {
tmp = y * 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 = z / (z - y)
if ((x <= (-2.8d-63)) .or. (.not. (x <= 3.5d-123))) then
tmp = x * t_0
else
tmp = y * t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = z / (z - y);
double tmp;
if ((x <= -2.8e-63) || !(x <= 3.5e-123)) {
tmp = x * t_0;
} else {
tmp = y * t_0;
}
return tmp;
}
def code(x, y, z): t_0 = z / (z - y) tmp = 0 if (x <= -2.8e-63) or not (x <= 3.5e-123): tmp = x * t_0 else: tmp = y * t_0 return tmp
function code(x, y, z) t_0 = Float64(z / Float64(z - y)) tmp = 0.0 if ((x <= -2.8e-63) || !(x <= 3.5e-123)) tmp = Float64(x * t_0); else tmp = Float64(y * t_0); end return tmp end
function tmp_2 = code(x, y, z) t_0 = z / (z - y); tmp = 0.0; if ((x <= -2.8e-63) || ~((x <= 3.5e-123))) tmp = x * t_0; else tmp = y * t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(z / N[(z - y), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[x, -2.8e-63], N[Not[LessEqual[x, 3.5e-123]], $MachinePrecision]], N[(x * t$95$0), $MachinePrecision], N[(y * t$95$0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{z}{z - y}\\
\mathbf{if}\;x \leq -2.8 \cdot 10^{-63} \lor \neg \left(x \leq 3.5 \cdot 10^{-123}\right):\\
\;\;\;\;x \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;y \cdot t\_0\\
\end{array}
\end{array}
if x < -2.8000000000000002e-63 or 3.4999999999999999e-123 < x Initial program 89.2%
Taylor expanded in x around inf 73.3%
div-inv73.3%
*-commutative73.3%
*-inverses73.3%
div-sub73.3%
clear-num73.4%
Applied egg-rr73.4%
if -2.8000000000000002e-63 < x < 3.4999999999999999e-123Initial program 88.3%
Taylor expanded in z around 0 88.3%
Taylor expanded in x around 0 76.8%
associate-/l*76.8%
Simplified76.8%
Final simplification74.6%
(FPCore (x y z) :precision binary64 (if (or (<= x -1.22e-64) (not (<= x 4.9e-92))) (* z (/ x (- z y))) (* y (/ z (- z y)))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.22e-64) || !(x <= 4.9e-92)) {
tmp = z * (x / (z - y));
} else {
tmp = y * (z / (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 <= (-1.22d-64)) .or. (.not. (x <= 4.9d-92))) then
tmp = z * (x / (z - y))
else
tmp = y * (z / (z - y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -1.22e-64) || !(x <= 4.9e-92)) {
tmp = z * (x / (z - y));
} else {
tmp = y * (z / (z - y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1.22e-64) or not (x <= 4.9e-92): tmp = z * (x / (z - y)) else: tmp = y * (z / (z - y)) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1.22e-64) || !(x <= 4.9e-92)) tmp = Float64(z * Float64(x / Float64(z - y))); else tmp = Float64(y * Float64(z / Float64(z - y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -1.22e-64) || ~((x <= 4.9e-92))) tmp = z * (x / (z - y)); else tmp = y * (z / (z - y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -1.22e-64], N[Not[LessEqual[x, 4.9e-92]], $MachinePrecision]], N[(z * N[(x / N[(z - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y * N[(z / N[(z - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.22 \cdot 10^{-64} \lor \neg \left(x \leq 4.9 \cdot 10^{-92}\right):\\
\;\;\;\;z \cdot \frac{x}{z - y}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{z}{z - y}\\
\end{array}
\end{array}
if x < -1.22000000000000003e-64 or 4.9e-92 < x Initial program 89.9%
Taylor expanded in x around inf 74.5%
div-inv74.5%
*-commutative74.5%
*-inverses74.5%
div-sub74.5%
clear-num74.6%
Applied egg-rr74.6%
Taylor expanded in x around 0 58.0%
*-commutative58.0%
associate-/l*68.0%
Simplified68.0%
if -1.22000000000000003e-64 < x < 4.9e-92Initial program 87.3%
Taylor expanded in z around 0 87.3%
Taylor expanded in x around 0 74.6%
associate-/l*74.6%
Simplified74.6%
Final simplification70.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ z (- z y))))
(if (<= x -1.9e-63)
(/ x (- 1.0 (/ y z)))
(if (<= x 3.1e-123) (* y t_0) (* x t_0)))))
double code(double x, double y, double z) {
double t_0 = z / (z - y);
double tmp;
if (x <= -1.9e-63) {
tmp = x / (1.0 - (y / z));
} else if (x <= 3.1e-123) {
tmp = y * t_0;
} else {
tmp = x * 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 = z / (z - y)
if (x <= (-1.9d-63)) then
tmp = x / (1.0d0 - (y / z))
else if (x <= 3.1d-123) then
tmp = y * t_0
else
tmp = x * t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = z / (z - y);
double tmp;
if (x <= -1.9e-63) {
tmp = x / (1.0 - (y / z));
} else if (x <= 3.1e-123) {
tmp = y * t_0;
} else {
tmp = x * t_0;
}
return tmp;
}
def code(x, y, z): t_0 = z / (z - y) tmp = 0 if x <= -1.9e-63: tmp = x / (1.0 - (y / z)) elif x <= 3.1e-123: tmp = y * t_0 else: tmp = x * t_0 return tmp
function code(x, y, z) t_0 = Float64(z / Float64(z - y)) tmp = 0.0 if (x <= -1.9e-63) tmp = Float64(x / Float64(1.0 - Float64(y / z))); elseif (x <= 3.1e-123) tmp = Float64(y * t_0); else tmp = Float64(x * t_0); end return tmp end
function tmp_2 = code(x, y, z) t_0 = z / (z - y); tmp = 0.0; if (x <= -1.9e-63) tmp = x / (1.0 - (y / z)); elseif (x <= 3.1e-123) tmp = y * t_0; else tmp = x * t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(z / N[(z - y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.9e-63], N[(x / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 3.1e-123], N[(y * t$95$0), $MachinePrecision], N[(x * t$95$0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{z}{z - y}\\
\mathbf{if}\;x \leq -1.9 \cdot 10^{-63}:\\
\;\;\;\;\frac{x}{1 - \frac{y}{z}}\\
\mathbf{elif}\;x \leq 3.1 \cdot 10^{-123}:\\
\;\;\;\;y \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;x \cdot t\_0\\
\end{array}
\end{array}
if x < -1.90000000000000009e-63Initial program 92.2%
Taylor expanded in x around inf 78.4%
if -1.90000000000000009e-63 < x < 3.09999999999999998e-123Initial program 88.3%
Taylor expanded in z around 0 88.3%
Taylor expanded in x around 0 76.8%
associate-/l*76.8%
Simplified76.8%
if 3.09999999999999998e-123 < x Initial program 87.3%
Taylor expanded in x around inf 70.0%
div-inv70.0%
*-commutative70.0%
*-inverses70.0%
div-sub70.0%
clear-num70.2%
Applied egg-rr70.2%
Final simplification74.7%
(FPCore (x y z) :precision binary64 (if (or (<= y -6.8e+67) (not (<= y 2.9e+18))) (- z) (+ x y)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -6.8e+67) || !(y <= 2.9e+18)) {
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 <= (-6.8d+67)) .or. (.not. (y <= 2.9d+18))) 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 <= -6.8e+67) || !(y <= 2.9e+18)) {
tmp = -z;
} else {
tmp = x + y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -6.8e+67) or not (y <= 2.9e+18): tmp = -z else: tmp = x + y return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -6.8e+67) || !(y <= 2.9e+18)) tmp = Float64(-z); else tmp = Float64(x + y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -6.8e+67) || ~((y <= 2.9e+18))) tmp = -z; else tmp = x + y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -6.8e+67], N[Not[LessEqual[y, 2.9e+18]], $MachinePrecision]], (-z), N[(x + y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.8 \cdot 10^{+67} \lor \neg \left(y \leq 2.9 \cdot 10^{+18}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
\end{array}
if y < -6.8000000000000003e67 or 2.9e18 < y Initial program 70.6%
Taylor expanded in y around inf 67.6%
neg-mul-167.6%
Simplified67.6%
if -6.8000000000000003e67 < y < 2.9e18Initial program 99.8%
Taylor expanded in z around inf 69.6%
+-commutative69.6%
Simplified69.6%
Final simplification68.8%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.36e-45) (not (<= y 4.2e-36))) (- z) x))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.36e-45) || !(y <= 4.2e-36)) {
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.36d-45)) .or. (.not. (y <= 4.2d-36))) 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.36e-45) || !(y <= 4.2e-36)) {
tmp = -z;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.36e-45) or not (y <= 4.2e-36): tmp = -z else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.36e-45) || !(y <= 4.2e-36)) tmp = Float64(-z); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1.36e-45) || ~((y <= 4.2e-36))) tmp = -z; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.36e-45], N[Not[LessEqual[y, 4.2e-36]], $MachinePrecision]], (-z), x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.36 \cdot 10^{-45} \lor \neg \left(y \leq 4.2 \cdot 10^{-36}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -1.35999999999999998e-45 or 4.19999999999999982e-36 < y Initial program 79.7%
Taylor expanded in y around inf 54.3%
neg-mul-154.3%
Simplified54.3%
if -1.35999999999999998e-45 < y < 4.19999999999999982e-36Initial program 99.9%
Taylor expanded in y around 0 60.9%
Final simplification57.3%
(FPCore (x y z) :precision binary64 (if (<= x -9e-75) x (if (<= x 4.4e-126) y x)))
double code(double x, double y, double z) {
double tmp;
if (x <= -9e-75) {
tmp = x;
} else if (x <= 4.4e-126) {
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 <= (-9d-75)) then
tmp = x
else if (x <= 4.4d-126) 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 <= -9e-75) {
tmp = x;
} else if (x <= 4.4e-126) {
tmp = y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -9e-75: tmp = x elif x <= 4.4e-126: tmp = y else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if (x <= -9e-75) tmp = x; elseif (x <= 4.4e-126) tmp = y; else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -9e-75) tmp = x; elseif (x <= 4.4e-126) tmp = y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -9e-75], x, If[LessEqual[x, 4.4e-126], y, x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9 \cdot 10^{-75}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 4.4 \cdot 10^{-126}:\\
\;\;\;\;y\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -9.0000000000000006e-75 or 4.40000000000000029e-126 < x Initial program 89.4%
Taylor expanded in y around 0 46.1%
if -9.0000000000000006e-75 < x < 4.40000000000000029e-126Initial program 87.9%
Taylor expanded in z around 0 87.9%
Taylor expanded in x around 0 76.0%
associate-/l*76.0%
Simplified76.0%
Taylor expanded in y around 0 41.1%
(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 88.9%
Taylor expanded in y around 0 35.2%
(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 2024170
(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))))