
(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 9 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 -2e-280) (not (<= t_0 1e-285)))
t_0
(* z (- -1.0 (/ x y))))))
double code(double x, double y, double z) {
double t_0 = (x + y) / (1.0 - (y / z));
double tmp;
if ((t_0 <= -2e-280) || !(t_0 <= 1e-285)) {
tmp = t_0;
} else {
tmp = z * (-1.0 - (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 <= (-2d-280)) .or. (.not. (t_0 <= 1d-285))) then
tmp = t_0
else
tmp = z * ((-1.0d0) - (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 <= -2e-280) || !(t_0 <= 1e-285)) {
tmp = t_0;
} else {
tmp = z * (-1.0 - (x / y));
}
return tmp;
}
def code(x, y, z): t_0 = (x + y) / (1.0 - (y / z)) tmp = 0 if (t_0 <= -2e-280) or not (t_0 <= 1e-285): tmp = t_0 else: tmp = z * (-1.0 - (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 <= -2e-280) || !(t_0 <= 1e-285)) tmp = t_0; else tmp = Float64(z * Float64(-1.0 - Float64(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 <= -2e-280) || ~((t_0 <= 1e-285))) tmp = t_0; else tmp = z * (-1.0 - (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, -2e-280], N[Not[LessEqual[t$95$0, 1e-285]], $MachinePrecision]], t$95$0, N[(z * N[(-1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x + y}{1 - \frac{y}{z}}\\
\mathbf{if}\;t\_0 \leq -2 \cdot 10^{-280} \lor \neg \left(t\_0 \leq 10^{-285}\right):\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(-1 - \frac{x}{y}\right)\\
\end{array}
\end{array}
if (/.f64 (+.f64 x y) (-.f64 1 (/.f64 y z))) < -1.9999999999999999e-280 or 1.00000000000000007e-285 < (/.f64 (+.f64 x y) (-.f64 1 (/.f64 y z))) Initial program 99.8%
if -1.9999999999999999e-280 < (/.f64 (+.f64 x y) (-.f64 1 (/.f64 y z))) < 1.00000000000000007e-285Initial program 16.1%
Taylor expanded in z around 0 90.7%
mul-1-neg90.7%
associate-/l*99.8%
distribute-neg-frac99.8%
+-commutative99.8%
Simplified99.8%
Taylor expanded in y around 0 95.6%
mul-1-neg95.6%
unsub-neg95.6%
mul-1-neg95.6%
associate-/l*90.5%
associate-/r/100.0%
Simplified100.0%
Taylor expanded in z around 0 100.0%
neg-mul-1100.0%
distribute-rgt-neg-in100.0%
distribute-neg-in100.0%
metadata-eval100.0%
sub-neg100.0%
Simplified100.0%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- 1.0 (/ y z))))
(if (<= y -3.4e+124)
(/ (- z) (/ y (+ x y)))
(if (<= y -1.35e+33)
(/ y t_0)
(if (<= y -4.7e-101)
(/ x t_0)
(if (<= y 2.6e+61)
(* (+ x y) (+ 1.0 (/ y z)))
(* z (- -1.0 (/ x y)))))))))
double code(double x, double y, double z) {
double t_0 = 1.0 - (y / z);
double tmp;
if (y <= -3.4e+124) {
tmp = -z / (y / (x + y));
} else if (y <= -1.35e+33) {
tmp = y / t_0;
} else if (y <= -4.7e-101) {
tmp = x / t_0;
} else if (y <= 2.6e+61) {
tmp = (x + y) * (1.0 + (y / z));
} else {
tmp = z * (-1.0 - (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 = 1.0d0 - (y / z)
if (y <= (-3.4d+124)) then
tmp = -z / (y / (x + y))
else if (y <= (-1.35d+33)) then
tmp = y / t_0
else if (y <= (-4.7d-101)) then
tmp = x / t_0
else if (y <= 2.6d+61) then
tmp = (x + y) * (1.0d0 + (y / z))
else
tmp = z * ((-1.0d0) - (x / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = 1.0 - (y / z);
double tmp;
if (y <= -3.4e+124) {
tmp = -z / (y / (x + y));
} else if (y <= -1.35e+33) {
tmp = y / t_0;
} else if (y <= -4.7e-101) {
tmp = x / t_0;
} else if (y <= 2.6e+61) {
tmp = (x + y) * (1.0 + (y / z));
} else {
tmp = z * (-1.0 - (x / y));
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 - (y / z) tmp = 0 if y <= -3.4e+124: tmp = -z / (y / (x + y)) elif y <= -1.35e+33: tmp = y / t_0 elif y <= -4.7e-101: tmp = x / t_0 elif y <= 2.6e+61: tmp = (x + y) * (1.0 + (y / z)) else: tmp = z * (-1.0 - (x / y)) return tmp
function code(x, y, z) t_0 = Float64(1.0 - Float64(y / z)) tmp = 0.0 if (y <= -3.4e+124) tmp = Float64(Float64(-z) / Float64(y / Float64(x + y))); elseif (y <= -1.35e+33) tmp = Float64(y / t_0); elseif (y <= -4.7e-101) tmp = Float64(x / t_0); elseif (y <= 2.6e+61) tmp = Float64(Float64(x + y) * Float64(1.0 + Float64(y / z))); else tmp = Float64(z * Float64(-1.0 - Float64(x / y))); end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 - (y / z); tmp = 0.0; if (y <= -3.4e+124) tmp = -z / (y / (x + y)); elseif (y <= -1.35e+33) tmp = y / t_0; elseif (y <= -4.7e-101) tmp = x / t_0; elseif (y <= 2.6e+61) tmp = (x + y) * (1.0 + (y / z)); else tmp = z * (-1.0 - (x / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -3.4e+124], N[((-z) / N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -1.35e+33], N[(y / t$95$0), $MachinePrecision], If[LessEqual[y, -4.7e-101], N[(x / t$95$0), $MachinePrecision], If[LessEqual[y, 2.6e+61], N[(N[(x + y), $MachinePrecision] * N[(1.0 + N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z * N[(-1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{y}{z}\\
\mathbf{if}\;y \leq -3.4 \cdot 10^{+124}:\\
\;\;\;\;\frac{-z}{\frac{y}{x + y}}\\
\mathbf{elif}\;y \leq -1.35 \cdot 10^{+33}:\\
\;\;\;\;\frac{y}{t\_0}\\
\mathbf{elif}\;y \leq -4.7 \cdot 10^{-101}:\\
\;\;\;\;\frac{x}{t\_0}\\
\mathbf{elif}\;y \leq 2.6 \cdot 10^{+61}:\\
\;\;\;\;\left(x + y\right) \cdot \left(1 + \frac{y}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(-1 - \frac{x}{y}\right)\\
\end{array}
\end{array}
if y < -3.4e124Initial program 75.5%
Taylor expanded in z around 0 65.7%
mul-1-neg65.7%
associate-/l*88.9%
distribute-neg-frac88.9%
+-commutative88.9%
Simplified88.9%
if -3.4e124 < y < -1.34999999999999996e33Initial program 85.7%
Taylor expanded in x around 0 70.7%
if -1.34999999999999996e33 < y < -4.6999999999999999e-101Initial program 96.4%
Taylor expanded in x around inf 79.3%
if -4.6999999999999999e-101 < y < 2.59999999999999973e61Initial program 99.1%
Taylor expanded in z around inf 79.8%
associate-+r+79.8%
*-lft-identity79.8%
associate-/l*77.3%
associate-/r/80.8%
distribute-rgt-in80.8%
+-commutative80.8%
Simplified80.8%
if 2.59999999999999973e61 < y Initial program 84.3%
Taylor expanded in z around 0 60.0%
mul-1-neg60.0%
associate-/l*72.4%
distribute-neg-frac72.4%
+-commutative72.4%
Simplified72.4%
Taylor expanded in y around 0 70.7%
mul-1-neg70.7%
unsub-neg70.7%
mul-1-neg70.7%
associate-/l*70.8%
associate-/r/72.5%
Simplified72.5%
Taylor expanded in z around 0 72.5%
neg-mul-172.5%
distribute-rgt-neg-in72.5%
distribute-neg-in72.5%
metadata-eval72.5%
sub-neg72.5%
Simplified72.5%
Final simplification79.9%
(FPCore (x y z)
:precision binary64
(if (or (<= y -7.5e+123)
(not (or (<= y -8e+26) (and (not (<= y -7e-8)) (<= y 3.8e+60)))))
(* z (- -1.0 (/ x y)))
(+ x y)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -7.5e+123) || !((y <= -8e+26) || (!(y <= -7e-8) && (y <= 3.8e+60)))) {
tmp = z * (-1.0 - (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 <= (-7.5d+123)) .or. (.not. (y <= (-8d+26)) .or. (.not. (y <= (-7d-8))) .and. (y <= 3.8d+60))) then
tmp = z * ((-1.0d0) - (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 <= -7.5e+123) || !((y <= -8e+26) || (!(y <= -7e-8) && (y <= 3.8e+60)))) {
tmp = z * (-1.0 - (x / y));
} else {
tmp = x + y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -7.5e+123) or not ((y <= -8e+26) or (not (y <= -7e-8) and (y <= 3.8e+60))): tmp = z * (-1.0 - (x / y)) else: tmp = x + y return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -7.5e+123) || !((y <= -8e+26) || (!(y <= -7e-8) && (y <= 3.8e+60)))) tmp = Float64(z * Float64(-1.0 - Float64(x / y))); else tmp = Float64(x + y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -7.5e+123) || ~(((y <= -8e+26) || (~((y <= -7e-8)) && (y <= 3.8e+60))))) tmp = z * (-1.0 - (x / y)); else tmp = x + y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -7.5e+123], N[Not[Or[LessEqual[y, -8e+26], And[N[Not[LessEqual[y, -7e-8]], $MachinePrecision], LessEqual[y, 3.8e+60]]]], $MachinePrecision]], N[(z * N[(-1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7.5 \cdot 10^{+123} \lor \neg \left(y \leq -8 \cdot 10^{+26} \lor \neg \left(y \leq -7 \cdot 10^{-8}\right) \land y \leq 3.8 \cdot 10^{+60}\right):\\
\;\;\;\;z \cdot \left(-1 - \frac{x}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
\end{array}
if y < -7.4999999999999999e123 or -8.00000000000000038e26 < y < -7.00000000000000048e-8 or 3.80000000000000009e60 < y Initial program 80.7%
Taylor expanded in z around 0 64.0%
mul-1-neg64.0%
associate-/l*80.3%
distribute-neg-frac80.3%
+-commutative80.3%
Simplified80.3%
Taylor expanded in y around 0 76.9%
mul-1-neg76.9%
unsub-neg76.9%
mul-1-neg76.9%
associate-/l*79.4%
associate-/r/80.2%
Simplified80.2%
Taylor expanded in z around 0 80.3%
neg-mul-180.3%
distribute-rgt-neg-in80.3%
distribute-neg-in80.3%
metadata-eval80.3%
sub-neg80.3%
Simplified80.3%
if -7.4999999999999999e123 < y < -8.00000000000000038e26 or -7.00000000000000048e-8 < y < 3.80000000000000009e60Initial program 98.0%
Taylor expanded in z around inf 78.7%
+-commutative78.7%
Simplified78.7%
Final simplification79.4%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- 1.0 (/ y z))) (t_1 (* z (- -1.0 (/ x y)))))
(if (<= y -3.2e+125)
t_1
(if (<= y -6.5e+33)
(/ y t_0)
(if (<= y -1.2e-107) (/ x t_0) (if (<= y 2.45e+58) (+ x y) t_1))))))
double code(double x, double y, double z) {
double t_0 = 1.0 - (y / z);
double t_1 = z * (-1.0 - (x / y));
double tmp;
if (y <= -3.2e+125) {
tmp = t_1;
} else if (y <= -6.5e+33) {
tmp = y / t_0;
} else if (y <= -1.2e-107) {
tmp = x / t_0;
} else if (y <= 2.45e+58) {
tmp = x + y;
} else {
tmp = t_1;
}
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) :: t_1
real(8) :: tmp
t_0 = 1.0d0 - (y / z)
t_1 = z * ((-1.0d0) - (x / y))
if (y <= (-3.2d+125)) then
tmp = t_1
else if (y <= (-6.5d+33)) then
tmp = y / t_0
else if (y <= (-1.2d-107)) then
tmp = x / t_0
else if (y <= 2.45d+58) then
tmp = x + y
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = 1.0 - (y / z);
double t_1 = z * (-1.0 - (x / y));
double tmp;
if (y <= -3.2e+125) {
tmp = t_1;
} else if (y <= -6.5e+33) {
tmp = y / t_0;
} else if (y <= -1.2e-107) {
tmp = x / t_0;
} else if (y <= 2.45e+58) {
tmp = x + y;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 - (y / z) t_1 = z * (-1.0 - (x / y)) tmp = 0 if y <= -3.2e+125: tmp = t_1 elif y <= -6.5e+33: tmp = y / t_0 elif y <= -1.2e-107: tmp = x / t_0 elif y <= 2.45e+58: tmp = x + y else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(1.0 - Float64(y / z)) t_1 = Float64(z * Float64(-1.0 - Float64(x / y))) tmp = 0.0 if (y <= -3.2e+125) tmp = t_1; elseif (y <= -6.5e+33) tmp = Float64(y / t_0); elseif (y <= -1.2e-107) tmp = Float64(x / t_0); elseif (y <= 2.45e+58) tmp = Float64(x + y); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 - (y / z); t_1 = z * (-1.0 - (x / y)); tmp = 0.0; if (y <= -3.2e+125) tmp = t_1; elseif (y <= -6.5e+33) tmp = y / t_0; elseif (y <= -1.2e-107) tmp = x / t_0; elseif (y <= 2.45e+58) tmp = x + y; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(z * N[(-1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -3.2e+125], t$95$1, If[LessEqual[y, -6.5e+33], N[(y / t$95$0), $MachinePrecision], If[LessEqual[y, -1.2e-107], N[(x / t$95$0), $MachinePrecision], If[LessEqual[y, 2.45e+58], N[(x + y), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{y}{z}\\
t_1 := z \cdot \left(-1 - \frac{x}{y}\right)\\
\mathbf{if}\;y \leq -3.2 \cdot 10^{+125}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq -6.5 \cdot 10^{+33}:\\
\;\;\;\;\frac{y}{t\_0}\\
\mathbf{elif}\;y \leq -1.2 \cdot 10^{-107}:\\
\;\;\;\;\frac{x}{t\_0}\\
\mathbf{elif}\;y \leq 2.45 \cdot 10^{+58}:\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -3.19999999999999983e125 or 2.45000000000000009e58 < y Initial program 80.1%
Taylor expanded in z around 0 62.7%
mul-1-neg62.7%
associate-/l*80.3%
distribute-neg-frac80.3%
+-commutative80.3%
Simplified80.3%
Taylor expanded in y around 0 76.6%
mul-1-neg76.6%
unsub-neg76.6%
mul-1-neg76.6%
associate-/l*79.4%
associate-/r/80.2%
Simplified80.2%
Taylor expanded in z around 0 80.2%
neg-mul-180.2%
distribute-rgt-neg-in80.2%
distribute-neg-in80.2%
metadata-eval80.2%
sub-neg80.2%
Simplified80.2%
if -3.19999999999999983e125 < y < -6.49999999999999993e33Initial program 85.7%
Taylor expanded in x around 0 70.7%
if -6.49999999999999993e33 < y < -1.19999999999999997e-107Initial program 96.5%
Taylor expanded in x around inf 79.9%
if -1.19999999999999997e-107 < y < 2.45000000000000009e58Initial program 99.1%
Taylor expanded in z around inf 80.5%
+-commutative80.5%
Simplified80.5%
Final simplification79.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- 1.0 (/ y z))))
(if (<= y -6e+125)
(/ (- z) (/ y (+ x y)))
(if (<= y -2.3e+33)
(/ y t_0)
(if (<= y -8.6e-108)
(/ x t_0)
(if (<= y 2.4e+61) (+ x y) (* z (- -1.0 (/ x y)))))))))
double code(double x, double y, double z) {
double t_0 = 1.0 - (y / z);
double tmp;
if (y <= -6e+125) {
tmp = -z / (y / (x + y));
} else if (y <= -2.3e+33) {
tmp = y / t_0;
} else if (y <= -8.6e-108) {
tmp = x / t_0;
} else if (y <= 2.4e+61) {
tmp = x + y;
} else {
tmp = z * (-1.0 - (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 = 1.0d0 - (y / z)
if (y <= (-6d+125)) then
tmp = -z / (y / (x + y))
else if (y <= (-2.3d+33)) then
tmp = y / t_0
else if (y <= (-8.6d-108)) then
tmp = x / t_0
else if (y <= 2.4d+61) then
tmp = x + y
else
tmp = z * ((-1.0d0) - (x / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = 1.0 - (y / z);
double tmp;
if (y <= -6e+125) {
tmp = -z / (y / (x + y));
} else if (y <= -2.3e+33) {
tmp = y / t_0;
} else if (y <= -8.6e-108) {
tmp = x / t_0;
} else if (y <= 2.4e+61) {
tmp = x + y;
} else {
tmp = z * (-1.0 - (x / y));
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 - (y / z) tmp = 0 if y <= -6e+125: tmp = -z / (y / (x + y)) elif y <= -2.3e+33: tmp = y / t_0 elif y <= -8.6e-108: tmp = x / t_0 elif y <= 2.4e+61: tmp = x + y else: tmp = z * (-1.0 - (x / y)) return tmp
function code(x, y, z) t_0 = Float64(1.0 - Float64(y / z)) tmp = 0.0 if (y <= -6e+125) tmp = Float64(Float64(-z) / Float64(y / Float64(x + y))); elseif (y <= -2.3e+33) tmp = Float64(y / t_0); elseif (y <= -8.6e-108) tmp = Float64(x / t_0); elseif (y <= 2.4e+61) tmp = Float64(x + y); else tmp = Float64(z * Float64(-1.0 - Float64(x / y))); end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 - (y / z); tmp = 0.0; if (y <= -6e+125) tmp = -z / (y / (x + y)); elseif (y <= -2.3e+33) tmp = y / t_0; elseif (y <= -8.6e-108) tmp = x / t_0; elseif (y <= 2.4e+61) tmp = x + y; else tmp = z * (-1.0 - (x / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -6e+125], N[((-z) / N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -2.3e+33], N[(y / t$95$0), $MachinePrecision], If[LessEqual[y, -8.6e-108], N[(x / t$95$0), $MachinePrecision], If[LessEqual[y, 2.4e+61], N[(x + y), $MachinePrecision], N[(z * N[(-1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{y}{z}\\
\mathbf{if}\;y \leq -6 \cdot 10^{+125}:\\
\;\;\;\;\frac{-z}{\frac{y}{x + y}}\\
\mathbf{elif}\;y \leq -2.3 \cdot 10^{+33}:\\
\;\;\;\;\frac{y}{t\_0}\\
\mathbf{elif}\;y \leq -8.6 \cdot 10^{-108}:\\
\;\;\;\;\frac{x}{t\_0}\\
\mathbf{elif}\;y \leq 2.4 \cdot 10^{+61}:\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(-1 - \frac{x}{y}\right)\\
\end{array}
\end{array}
if y < -6.0000000000000003e125Initial program 75.5%
Taylor expanded in z around 0 65.7%
mul-1-neg65.7%
associate-/l*88.9%
distribute-neg-frac88.9%
+-commutative88.9%
Simplified88.9%
if -6.0000000000000003e125 < y < -2.30000000000000011e33Initial program 85.7%
Taylor expanded in x around 0 70.7%
if -2.30000000000000011e33 < y < -8.6000000000000001e-108Initial program 96.5%
Taylor expanded in x around inf 79.9%
if -8.6000000000000001e-108 < y < 2.3999999999999999e61Initial program 99.1%
Taylor expanded in z around inf 80.5%
+-commutative80.5%
Simplified80.5%
if 2.3999999999999999e61 < y Initial program 84.3%
Taylor expanded in z around 0 60.0%
mul-1-neg60.0%
associate-/l*72.4%
distribute-neg-frac72.4%
+-commutative72.4%
Simplified72.4%
Taylor expanded in y around 0 70.7%
mul-1-neg70.7%
unsub-neg70.7%
mul-1-neg70.7%
associate-/l*70.8%
associate-/r/72.5%
Simplified72.5%
Taylor expanded in z around 0 72.5%
neg-mul-172.5%
distribute-rgt-neg-in72.5%
distribute-neg-in72.5%
metadata-eval72.5%
sub-neg72.5%
Simplified72.5%
Final simplification79.8%
(FPCore (x y z) :precision binary64 (if (<= y -1.12e+126) (- z) (if (<= y -1.35e+43) y (if (<= y 2.5e+62) x (- z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.12e+126) {
tmp = -z;
} else if (y <= -1.35e+43) {
tmp = y;
} else if (y <= 2.5e+62) {
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 <= (-1.12d+126)) then
tmp = -z
else if (y <= (-1.35d+43)) then
tmp = y
else if (y <= 2.5d+62) 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 <= -1.12e+126) {
tmp = -z;
} else if (y <= -1.35e+43) {
tmp = y;
} else if (y <= 2.5e+62) {
tmp = x;
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.12e+126: tmp = -z elif y <= -1.35e+43: tmp = y elif y <= 2.5e+62: tmp = x else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.12e+126) tmp = Float64(-z); elseif (y <= -1.35e+43) tmp = y; elseif (y <= 2.5e+62) tmp = x; else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.12e+126) tmp = -z; elseif (y <= -1.35e+43) tmp = y; elseif (y <= 2.5e+62) tmp = x; else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.12e+126], (-z), If[LessEqual[y, -1.35e+43], y, If[LessEqual[y, 2.5e+62], x, (-z)]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.12 \cdot 10^{+126}:\\
\;\;\;\;-z\\
\mathbf{elif}\;y \leq -1.35 \cdot 10^{+43}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 2.5 \cdot 10^{+62}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if y < -1.12e126 or 2.50000000000000014e62 < y Initial program 79.7%
Taylor expanded in y around inf 70.2%
mul-1-neg70.2%
Simplified70.2%
if -1.12e126 < y < -1.3500000000000001e43Initial program 86.7%
Taylor expanded in x around 0 66.0%
Taylor expanded in y around 0 58.4%
if -1.3500000000000001e43 < y < 2.50000000000000014e62Initial program 98.6%
Taylor expanded in y around 0 60.5%
Final simplification64.3%
(FPCore (x y z) :precision binary64 (if (or (<= y -7.5e+123) (not (<= y 1.8e+113))) (- z) (+ x y)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -7.5e+123) || !(y <= 1.8e+113)) {
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 <= (-7.5d+123)) .or. (.not. (y <= 1.8d+113))) 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 <= -7.5e+123) || !(y <= 1.8e+113)) {
tmp = -z;
} else {
tmp = x + y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -7.5e+123) or not (y <= 1.8e+113): tmp = -z else: tmp = x + y return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -7.5e+123) || !(y <= 1.8e+113)) tmp = Float64(-z); else tmp = Float64(x + y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -7.5e+123) || ~((y <= 1.8e+113))) tmp = -z; else tmp = x + y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -7.5e+123], N[Not[LessEqual[y, 1.8e+113]], $MachinePrecision]], (-z), N[(x + y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7.5 \cdot 10^{+123} \lor \neg \left(y \leq 1.8 \cdot 10^{+113}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
\end{array}
if y < -7.4999999999999999e123 or 1.79999999999999996e113 < y Initial program 78.1%
Taylor expanded in y around inf 74.5%
mul-1-neg74.5%
Simplified74.5%
if -7.4999999999999999e123 < y < 1.79999999999999996e113Initial program 97.1%
Taylor expanded in z around inf 72.5%
+-commutative72.5%
Simplified72.5%
Final simplification73.2%
(FPCore (x y z) :precision binary64 (if (<= x -1.45e-96) x (if (<= x 1.3e-52) y x)))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.45e-96) {
tmp = x;
} else if (x <= 1.3e-52) {
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.45d-96)) then
tmp = x
else if (x <= 1.3d-52) 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.45e-96) {
tmp = x;
} else if (x <= 1.3e-52) {
tmp = y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1.45e-96: tmp = x elif x <= 1.3e-52: tmp = y else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if (x <= -1.45e-96) tmp = x; elseif (x <= 1.3e-52) tmp = y; else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -1.45e-96) tmp = x; elseif (x <= 1.3e-52) tmp = y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1.45e-96], x, If[LessEqual[x, 1.3e-52], y, x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.45 \cdot 10^{-96}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 1.3 \cdot 10^{-52}:\\
\;\;\;\;y\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -1.44999999999999997e-96 or 1.2999999999999999e-52 < x Initial program 90.0%
Taylor expanded in y around 0 52.5%
if -1.44999999999999997e-96 < x < 1.2999999999999999e-52Initial program 90.9%
Taylor expanded in x around 0 77.1%
Taylor expanded in y around 0 37.7%
Final simplification47.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 90.3%
Taylor expanded in y around 0 37.2%
Final simplification37.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 2024026
(FPCore (x y z)
:name "Graphics.Rendering.Chart.Backend.Diagrams:calcFontMetrics from Chart-diagrams-1.5.1, A"
:precision binary64
:herbie-target
(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))))