
(FPCore (a b c d) :precision binary64 (/ (- (* b c) (* a d)) (+ (* c c) (* d d))))
double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = ((b * c) - (a * d)) / ((c * c) + (d * d))
end function
public static double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
def code(a, b, c, d): return ((b * c) - (a * d)) / ((c * c) + (d * d))
function code(a, b, c, d) return Float64(Float64(Float64(b * c) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d))) end
function tmp = code(a, b, c, d) tmp = ((b * c) - (a * d)) / ((c * c) + (d * d)); end
code[a_, b_, c_, d_] := N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 15 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b c d) :precision binary64 (/ (- (* b c) (* a d)) (+ (* c c) (* d d))))
double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = ((b * c) - (a * d)) / ((c * c) + (d * d))
end function
public static double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
def code(a, b, c, d): return ((b * c) - (a * d)) / ((c * c) + (d * d))
function code(a, b, c, d) return Float64(Float64(Float64(b * c) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d))) end
function tmp = code(a, b, c, d) tmp = ((b * c) - (a * d)) / ((c * c) + (d * d)); end
code[a_, b_, c_, d_] := N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}
\end{array}
(FPCore (a b c d) :precision binary64 (fma (/ c (hypot c d)) (/ b (hypot c d)) (/ (- a) (fma c (/ c d) d))))
double code(double a, double b, double c, double d) {
return fma((c / hypot(c, d)), (b / hypot(c, d)), (-a / fma(c, (c / d), d)));
}
function code(a, b, c, d) return fma(Float64(c / hypot(c, d)), Float64(b / hypot(c, d)), Float64(Float64(-a) / fma(c, Float64(c / d), d))) end
code[a_, b_, c_, d_] := N[(N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] + N[((-a) / N[(c * N[(c / d), $MachinePrecision] + d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, \frac{-a}{\mathsf{fma}\left(c, \frac{c}{d}, d\right)}\right)
\end{array}
Initial program 61.7%
div-sub59.2%
sub-neg59.2%
*-commutative59.2%
add-sqr-sqrt59.2%
times-frac60.3%
fma-def60.3%
hypot-def60.3%
hypot-def74.6%
associate-/l*78.2%
add-sqr-sqrt78.2%
pow278.2%
hypot-def78.2%
Applied egg-rr78.2%
Taylor expanded in c around 0 91.4%
+-commutative91.4%
unpow291.4%
associate-*r/97.2%
fma-def97.2%
Simplified97.2%
Final simplification97.2%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (- (* c b) (* d a))))
(if (<= (/ t_0 (+ (* c c) (* d d))) INFINITY)
(* (/ 1.0 (hypot c d)) (/ t_0 (hypot c d)))
(fma 1.0 (/ b (hypot c d)) (/ (/ (- d) (/ (hypot c d) a)) (hypot c d))))))
double code(double a, double b, double c, double d) {
double t_0 = (c * b) - (d * a);
double tmp;
if ((t_0 / ((c * c) + (d * d))) <= ((double) INFINITY)) {
tmp = (1.0 / hypot(c, d)) * (t_0 / hypot(c, d));
} else {
tmp = fma(1.0, (b / hypot(c, d)), ((-d / (hypot(c, d) / a)) / hypot(c, d)));
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(c * b) - Float64(d * a)) tmp = 0.0 if (Float64(t_0 / Float64(Float64(c * c) + Float64(d * d))) <= Inf) tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(t_0 / hypot(c, d))); else tmp = fma(1.0, Float64(b / hypot(c, d)), Float64(Float64(Float64(-d) / Float64(hypot(c, d) / a)) / hypot(c, d))); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$0 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 * N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] + N[(N[((-d) / N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := c \cdot b - d \cdot a\\
\mathbf{if}\;\frac{t_0}{c \cdot c + d \cdot d} \leq \infty:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{t_0}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(1, \frac{b}{\mathsf{hypot}\left(c, d\right)}, \frac{\frac{-d}{\frac{\mathsf{hypot}\left(c, d\right)}{a}}}{\mathsf{hypot}\left(c, d\right)}\right)\\
\end{array}
\end{array}
if (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < +inf.0Initial program 79.8%
*-un-lft-identity79.8%
add-sqr-sqrt79.8%
times-frac79.9%
hypot-def79.9%
hypot-def94.4%
Applied egg-rr94.4%
if +inf.0 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 0.0%
div-sub0.0%
sub-neg0.0%
*-commutative0.0%
add-sqr-sqrt0.0%
times-frac1.6%
fma-def1.6%
hypot-def1.6%
hypot-def41.4%
associate-/l*46.6%
add-sqr-sqrt46.6%
pow246.6%
hypot-def46.6%
Applied egg-rr46.6%
Applied egg-rr43.1%
associate-*l/43.1%
*-lft-identity43.1%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in c around inf 57.6%
Final simplification86.1%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- a) (fma c (/ c d) d)))
(t_1 (- (/ c (/ (pow d 2.0) b)) (/ a d))))
(if (<= d -5.7e+242)
t_0
(if (<= d -4.8e+192)
(/ (/ (- c) d) (/ (hypot c d) b))
(if (<= d -58000000000.0)
t_1
(if (<= d -4e-33)
(- (/ b c) (* d (/ a (pow c 2.0))))
(if (<= d -2.4e-69)
t_0
(if (<= d -4e-111)
(/ b (* (hypot c d) (/ (hypot c d) c)))
(if (<= d 4.4e-164)
(fma -1.0 (/ a (* c (/ c d))) (/ b c))
(if (<= d 5.5e+45)
(/ (- (* c b) (* d a)) (+ (* c c) (* d d)))
t_1))))))))))
double code(double a, double b, double c, double d) {
double t_0 = -a / fma(c, (c / d), d);
double t_1 = (c / (pow(d, 2.0) / b)) - (a / d);
double tmp;
if (d <= -5.7e+242) {
tmp = t_0;
} else if (d <= -4.8e+192) {
tmp = (-c / d) / (hypot(c, d) / b);
} else if (d <= -58000000000.0) {
tmp = t_1;
} else if (d <= -4e-33) {
tmp = (b / c) - (d * (a / pow(c, 2.0)));
} else if (d <= -2.4e-69) {
tmp = t_0;
} else if (d <= -4e-111) {
tmp = b / (hypot(c, d) * (hypot(c, d) / c));
} else if (d <= 4.4e-164) {
tmp = fma(-1.0, (a / (c * (c / d))), (b / c));
} else if (d <= 5.5e+45) {
tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
} else {
tmp = t_1;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(-a) / fma(c, Float64(c / d), d)) t_1 = Float64(Float64(c / Float64((d ^ 2.0) / b)) - Float64(a / d)) tmp = 0.0 if (d <= -5.7e+242) tmp = t_0; elseif (d <= -4.8e+192) tmp = Float64(Float64(Float64(-c) / d) / Float64(hypot(c, d) / b)); elseif (d <= -58000000000.0) tmp = t_1; elseif (d <= -4e-33) tmp = Float64(Float64(b / c) - Float64(d * Float64(a / (c ^ 2.0)))); elseif (d <= -2.4e-69) tmp = t_0; elseif (d <= -4e-111) tmp = Float64(b / Float64(hypot(c, d) * Float64(hypot(c, d) / c))); elseif (d <= 4.4e-164) tmp = fma(-1.0, Float64(a / Float64(c * Float64(c / d))), Float64(b / c)); elseif (d <= 5.5e+45) tmp = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d))); else tmp = t_1; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[((-a) / N[(c * N[(c / d), $MachinePrecision] + d), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(c / N[(N[Power[d, 2.0], $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -5.7e+242], t$95$0, If[LessEqual[d, -4.8e+192], N[(N[((-c) / d), $MachinePrecision] / N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -58000000000.0], t$95$1, If[LessEqual[d, -4e-33], N[(N[(b / c), $MachinePrecision] - N[(d * N[(a / N[Power[c, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -2.4e-69], t$95$0, If[LessEqual[d, -4e-111], N[(b / N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] * N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 4.4e-164], N[(-1.0 * N[(a / N[(c * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(b / c), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 5.5e+45], N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-a}{\mathsf{fma}\left(c, \frac{c}{d}, d\right)}\\
t_1 := \frac{c}{\frac{{d}^{2}}{b}} - \frac{a}{d}\\
\mathbf{if}\;d \leq -5.7 \cdot 10^{+242}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq -4.8 \cdot 10^{+192}:\\
\;\;\;\;\frac{\frac{-c}{d}}{\frac{\mathsf{hypot}\left(c, d\right)}{b}}\\
\mathbf{elif}\;d \leq -58000000000:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d \leq -4 \cdot 10^{-33}:\\
\;\;\;\;\frac{b}{c} - d \cdot \frac{a}{{c}^{2}}\\
\mathbf{elif}\;d \leq -2.4 \cdot 10^{-69}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq -4 \cdot 10^{-111}:\\
\;\;\;\;\frac{b}{\mathsf{hypot}\left(c, d\right) \cdot \frac{\mathsf{hypot}\left(c, d\right)}{c}}\\
\mathbf{elif}\;d \leq 4.4 \cdot 10^{-164}:\\
\;\;\;\;\mathsf{fma}\left(-1, \frac{a}{c \cdot \frac{c}{d}}, \frac{b}{c}\right)\\
\mathbf{elif}\;d \leq 5.5 \cdot 10^{+45}:\\
\;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if d < -5.7000000000000003e242 or -4.0000000000000002e-33 < d < -2.4000000000000001e-69Initial program 55.7%
div-sub55.7%
sub-neg55.7%
*-commutative55.7%
add-sqr-sqrt55.7%
times-frac55.9%
fma-def55.9%
hypot-def55.9%
hypot-def65.2%
associate-/l*66.8%
add-sqr-sqrt66.8%
pow266.8%
hypot-def66.8%
Applied egg-rr66.8%
Taylor expanded in c around 0 90.7%
+-commutative90.7%
unpow290.7%
associate-*r/99.9%
fma-def99.9%
Simplified99.9%
Taylor expanded in b around 0 81.4%
associate-*r/81.4%
neg-mul-181.4%
+-commutative81.4%
unpow281.4%
associate-*r/90.6%
fma-udef90.6%
Simplified90.6%
if -5.7000000000000003e242 < d < -4.7999999999999996e192Initial program 36.7%
Taylor expanded in b around inf 36.7%
associate-/l*38.9%
associate-/r/38.9%
+-commutative38.9%
unpow238.9%
fma-def38.9%
Simplified38.9%
*-commutative38.9%
associate-*r/36.7%
fma-udef36.7%
add-sqr-sqrt36.7%
+-commutative36.7%
pow236.7%
hypot-udef36.7%
+-commutative36.7%
pow236.7%
hypot-udef36.7%
frac-times100.0%
clear-num99.9%
un-div-inv100.0%
Applied egg-rr100.0%
Taylor expanded in d around -inf 100.0%
associate-*r/100.0%
neg-mul-1100.0%
Simplified100.0%
if -4.7999999999999996e192 < d < -5.8e10 or 5.5000000000000001e45 < d Initial program 45.7%
Taylor expanded in c around 0 78.5%
+-commutative78.5%
mul-1-neg78.5%
unsub-neg78.5%
*-commutative78.5%
associate-/l*83.7%
Simplified83.7%
if -5.8e10 < d < -4.0000000000000002e-33Initial program 46.3%
Taylor expanded in c around inf 73.9%
+-commutative73.9%
mul-1-neg73.9%
unsub-neg73.9%
associate-/l*73.8%
associate-/r/73.8%
Simplified73.8%
if -2.4000000000000001e-69 < d < -4.00000000000000035e-111Initial program 73.1%
Taylor expanded in b around inf 73.1%
associate-/l*86.7%
associate-/r/73.2%
+-commutative73.2%
unpow273.2%
fma-def73.2%
Simplified73.2%
*-commutative73.2%
associate-*r/73.1%
fma-udef73.1%
add-sqr-sqrt73.1%
+-commutative73.1%
pow273.1%
hypot-udef73.1%
+-commutative73.1%
pow273.1%
hypot-udef73.1%
frac-times86.4%
clear-num86.4%
frac-times99.8%
*-un-lft-identity99.8%
Applied egg-rr99.8%
if -4.00000000000000035e-111 < d < 4.39999999999999975e-164Initial program 76.7%
Taylor expanded in c around inf 80.3%
fma-def80.3%
associate-/l*79.5%
Simplified79.5%
div-inv79.4%
pow279.4%
associate-*l*89.5%
Applied egg-rr89.5%
Taylor expanded in c around 0 89.5%
if 4.39999999999999975e-164 < d < 5.5000000000000001e45Initial program 90.3%
Final simplification87.5%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (- (* c b) (* d a))))
(if (<= (/ t_0 (+ (* c c) (* d d))) INFINITY)
(* (/ 1.0 (hypot c d)) (/ t_0 (hypot c d)))
(/ (- a) (fma c (/ c d) d)))))
double code(double a, double b, double c, double d) {
double t_0 = (c * b) - (d * a);
double tmp;
if ((t_0 / ((c * c) + (d * d))) <= ((double) INFINITY)) {
tmp = (1.0 / hypot(c, d)) * (t_0 / hypot(c, d));
} else {
tmp = -a / fma(c, (c / d), d);
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(c * b) - Float64(d * a)) tmp = 0.0 if (Float64(t_0 / Float64(Float64(c * c) + Float64(d * d))) <= Inf) tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(t_0 / hypot(c, d))); else tmp = Float64(Float64(-a) / fma(c, Float64(c / d), d)); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$0 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-a) / N[(c * N[(c / d), $MachinePrecision] + d), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := c \cdot b - d \cdot a\\
\mathbf{if}\;\frac{t_0}{c \cdot c + d \cdot d} \leq \infty:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{t_0}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{-a}{\mathsf{fma}\left(c, \frac{c}{d}, d\right)}\\
\end{array}
\end{array}
if (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < +inf.0Initial program 79.8%
*-un-lft-identity79.8%
add-sqr-sqrt79.8%
times-frac79.9%
hypot-def79.9%
hypot-def94.4%
Applied egg-rr94.4%
if +inf.0 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 0.0%
div-sub0.0%
sub-neg0.0%
*-commutative0.0%
add-sqr-sqrt0.0%
times-frac1.6%
fma-def1.6%
hypot-def1.6%
hypot-def41.4%
associate-/l*46.6%
add-sqr-sqrt46.6%
pow246.6%
hypot-def46.6%
Applied egg-rr46.6%
Taylor expanded in c around 0 87.7%
+-commutative87.7%
unpow287.7%
associate-*r/99.9%
fma-def99.9%
Simplified99.9%
Taylor expanded in b around 0 44.8%
associate-*r/44.8%
neg-mul-144.8%
+-commutative44.8%
unpow244.8%
associate-*r/57.0%
fma-udef57.0%
Simplified57.0%
Final simplification85.9%
(FPCore (a b c d) :precision binary64 (if (or (<= a -3.3e+34) (not (<= a 8.5e-27))) (/ (- a) (fma c (/ c d) d)) (/ (/ b (hypot c d)) (/ (hypot c d) c))))
double code(double a, double b, double c, double d) {
double tmp;
if ((a <= -3.3e+34) || !(a <= 8.5e-27)) {
tmp = -a / fma(c, (c / d), d);
} else {
tmp = (b / hypot(c, d)) / (hypot(c, d) / c);
}
return tmp;
}
function code(a, b, c, d) tmp = 0.0 if ((a <= -3.3e+34) || !(a <= 8.5e-27)) tmp = Float64(Float64(-a) / fma(c, Float64(c / d), d)); else tmp = Float64(Float64(b / hypot(c, d)) / Float64(hypot(c, d) / c)); end return tmp end
code[a_, b_, c_, d_] := If[Or[LessEqual[a, -3.3e+34], N[Not[LessEqual[a, 8.5e-27]], $MachinePrecision]], N[((-a) / N[(c * N[(c / d), $MachinePrecision] + d), $MachinePrecision]), $MachinePrecision], N[(N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] / N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -3.3 \cdot 10^{+34} \lor \neg \left(a \leq 8.5 \cdot 10^{-27}\right):\\
\;\;\;\;\frac{-a}{\mathsf{fma}\left(c, \frac{c}{d}, d\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{b}{\mathsf{hypot}\left(c, d\right)}}{\frac{\mathsf{hypot}\left(c, d\right)}{c}}\\
\end{array}
\end{array}
if a < -3.29999999999999988e34 or 8.50000000000000033e-27 < a Initial program 53.2%
div-sub49.2%
sub-neg49.2%
*-commutative49.2%
add-sqr-sqrt49.2%
times-frac50.2%
fma-def50.2%
hypot-def50.2%
hypot-def57.0%
associate-/l*63.9%
add-sqr-sqrt63.9%
pow263.9%
hypot-def63.9%
Applied egg-rr63.9%
Taylor expanded in c around 0 86.3%
+-commutative86.3%
unpow286.3%
associate-*r/97.0%
fma-def97.0%
Simplified97.0%
Taylor expanded in b around 0 64.6%
associate-*r/64.6%
neg-mul-164.6%
+-commutative64.6%
unpow264.6%
associate-*r/75.1%
fma-udef75.1%
Simplified75.1%
if -3.29999999999999988e34 < a < 8.50000000000000033e-27Initial program 70.3%
Taylor expanded in b around inf 57.7%
associate-/l*58.5%
associate-/r/55.4%
+-commutative55.4%
unpow255.4%
fma-def55.4%
Simplified55.4%
*-commutative55.4%
associate-*r/57.7%
fma-udef57.7%
add-sqr-sqrt57.7%
+-commutative57.7%
pow257.7%
hypot-udef57.7%
+-commutative57.7%
pow257.7%
hypot-udef57.7%
frac-times83.2%
clear-num82.7%
associate-*l/82.7%
*-un-lft-identity82.7%
Applied egg-rr82.7%
Final simplification78.9%
(FPCore (a b c d) :precision binary64 (if (or (<= a -3.5e+31) (not (<= a 4.7e-38))) (/ (- a) (fma c (/ c d) d)) (/ (/ c (hypot c d)) (/ (hypot c d) b))))
double code(double a, double b, double c, double d) {
double tmp;
if ((a <= -3.5e+31) || !(a <= 4.7e-38)) {
tmp = -a / fma(c, (c / d), d);
} else {
tmp = (c / hypot(c, d)) / (hypot(c, d) / b);
}
return tmp;
}
function code(a, b, c, d) tmp = 0.0 if ((a <= -3.5e+31) || !(a <= 4.7e-38)) tmp = Float64(Float64(-a) / fma(c, Float64(c / d), d)); else tmp = Float64(Float64(c / hypot(c, d)) / Float64(hypot(c, d) / b)); end return tmp end
code[a_, b_, c_, d_] := If[Or[LessEqual[a, -3.5e+31], N[Not[LessEqual[a, 4.7e-38]], $MachinePrecision]], N[((-a) / N[(c * N[(c / d), $MachinePrecision] + d), $MachinePrecision]), $MachinePrecision], N[(N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] / N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -3.5 \cdot 10^{+31} \lor \neg \left(a \leq 4.7 \cdot 10^{-38}\right):\\
\;\;\;\;\frac{-a}{\mathsf{fma}\left(c, \frac{c}{d}, d\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{c}{\mathsf{hypot}\left(c, d\right)}}{\frac{\mathsf{hypot}\left(c, d\right)}{b}}\\
\end{array}
\end{array}
if a < -3.5e31 or 4.69999999999999998e-38 < a Initial program 53.9%
div-sub50.0%
sub-neg50.0%
*-commutative50.0%
add-sqr-sqrt50.0%
times-frac51.0%
fma-def51.0%
hypot-def51.0%
hypot-def58.3%
associate-/l*65.0%
add-sqr-sqrt65.0%
pow265.0%
hypot-def65.0%
Applied egg-rr65.0%
Taylor expanded in c around 0 86.7%
+-commutative86.7%
unpow286.7%
associate-*r/97.1%
fma-def97.1%
Simplified97.1%
Taylor expanded in b around 0 64.2%
associate-*r/64.2%
neg-mul-164.2%
+-commutative64.2%
unpow264.2%
associate-*r/74.3%
fma-udef74.3%
Simplified74.3%
if -3.5e31 < a < 4.69999999999999998e-38Initial program 70.2%
Taylor expanded in b around inf 58.8%
associate-/l*59.5%
associate-/r/56.3%
+-commutative56.3%
unpow256.3%
fma-def56.3%
Simplified56.3%
*-commutative56.3%
associate-*r/58.8%
fma-udef58.8%
add-sqr-sqrt58.8%
+-commutative58.8%
pow258.8%
hypot-udef58.8%
+-commutative58.8%
pow258.8%
hypot-udef58.8%
frac-times84.3%
clear-num83.8%
un-div-inv84.6%
Applied egg-rr84.6%
Final simplification79.3%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* c b) (* d a)) (+ (* c c) (* d d)))))
(if (or (<= t_0 -5e-321) (and (not (<= t_0 0.0)) (<= t_0 5e+263)))
t_0
(/ (- a) (fma c (/ c d) d)))))
double code(double a, double b, double c, double d) {
double t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
double tmp;
if ((t_0 <= -5e-321) || (!(t_0 <= 0.0) && (t_0 <= 5e+263))) {
tmp = t_0;
} else {
tmp = -a / fma(c, (c / d), d);
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d))) tmp = 0.0 if ((t_0 <= -5e-321) || (!(t_0 <= 0.0) && (t_0 <= 5e+263))) tmp = t_0; else tmp = Float64(Float64(-a) / fma(c, Float64(c / d), d)); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -5e-321], And[N[Not[LessEqual[t$95$0, 0.0]], $MachinePrecision], LessEqual[t$95$0, 5e+263]]], t$95$0, N[((-a) / N[(c * N[(c / d), $MachinePrecision] + d), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{if}\;t_0 \leq -5 \cdot 10^{-321} \lor \neg \left(t_0 \leq 0\right) \land t_0 \leq 5 \cdot 10^{+263}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{-a}{\mathsf{fma}\left(c, \frac{c}{d}, d\right)}\\
\end{array}
\end{array}
if (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < -4.99994e-321 or -0.0 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 5.00000000000000022e263Initial program 92.1%
if -4.99994e-321 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < -0.0 or 5.00000000000000022e263 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 34.0%
div-sub30.9%
sub-neg30.9%
*-commutative30.9%
add-sqr-sqrt30.9%
times-frac33.7%
fma-def33.7%
hypot-def33.7%
hypot-def59.5%
associate-/l*64.7%
add-sqr-sqrt64.7%
pow264.7%
hypot-def64.7%
Applied egg-rr64.7%
Taylor expanded in c around 0 88.4%
+-commutative88.4%
unpow288.4%
associate-*r/97.9%
fma-def97.9%
Simplified97.9%
Taylor expanded in b around 0 58.9%
associate-*r/58.9%
neg-mul-158.9%
+-commutative58.9%
unpow258.9%
associate-*r/68.2%
fma-udef68.2%
Simplified68.2%
Final simplification79.6%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (- (/ c (/ (pow d 2.0) b)) (/ a d))))
(if (<= d -5.7e+242)
(/ (- a) (fma c (/ c d) d))
(if (<= d -4.8e+192)
(/ (/ (- c) d) (/ (hypot c d) b))
(if (<= d -1000000000000.0)
t_0
(if (<= d 2.1e-164)
(fma -1.0 (/ a (* c (/ c d))) (/ b c))
(if (<= d 5.8e+45)
(/ (- (* c b) (* d a)) (+ (* c c) (* d d)))
t_0)))))))
double code(double a, double b, double c, double d) {
double t_0 = (c / (pow(d, 2.0) / b)) - (a / d);
double tmp;
if (d <= -5.7e+242) {
tmp = -a / fma(c, (c / d), d);
} else if (d <= -4.8e+192) {
tmp = (-c / d) / (hypot(c, d) / b);
} else if (d <= -1000000000000.0) {
tmp = t_0;
} else if (d <= 2.1e-164) {
tmp = fma(-1.0, (a / (c * (c / d))), (b / c));
} else if (d <= 5.8e+45) {
tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
} else {
tmp = t_0;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(c / Float64((d ^ 2.0) / b)) - Float64(a / d)) tmp = 0.0 if (d <= -5.7e+242) tmp = Float64(Float64(-a) / fma(c, Float64(c / d), d)); elseif (d <= -4.8e+192) tmp = Float64(Float64(Float64(-c) / d) / Float64(hypot(c, d) / b)); elseif (d <= -1000000000000.0) tmp = t_0; elseif (d <= 2.1e-164) tmp = fma(-1.0, Float64(a / Float64(c * Float64(c / d))), Float64(b / c)); elseif (d <= 5.8e+45) tmp = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d))); else tmp = t_0; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c / N[(N[Power[d, 2.0], $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -5.7e+242], N[((-a) / N[(c * N[(c / d), $MachinePrecision] + d), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -4.8e+192], N[(N[((-c) / d), $MachinePrecision] / N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -1000000000000.0], t$95$0, If[LessEqual[d, 2.1e-164], N[(-1.0 * N[(a / N[(c * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(b / c), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 5.8e+45], N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c}{\frac{{d}^{2}}{b}} - \frac{a}{d}\\
\mathbf{if}\;d \leq -5.7 \cdot 10^{+242}:\\
\;\;\;\;\frac{-a}{\mathsf{fma}\left(c, \frac{c}{d}, d\right)}\\
\mathbf{elif}\;d \leq -4.8 \cdot 10^{+192}:\\
\;\;\;\;\frac{\frac{-c}{d}}{\frac{\mathsf{hypot}\left(c, d\right)}{b}}\\
\mathbf{elif}\;d \leq -1000000000000:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 2.1 \cdot 10^{-164}:\\
\;\;\;\;\mathsf{fma}\left(-1, \frac{a}{c \cdot \frac{c}{d}}, \frac{b}{c}\right)\\
\mathbf{elif}\;d \leq 5.8 \cdot 10^{+45}:\\
\;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if d < -5.7000000000000003e242Initial program 37.2%
div-sub37.2%
sub-neg37.2%
*-commutative37.2%
add-sqr-sqrt37.2%
times-frac37.2%
fma-def37.2%
hypot-def37.2%
hypot-def37.2%
associate-/l*39.8%
add-sqr-sqrt39.8%
pow239.8%
hypot-def39.8%
Applied egg-rr39.8%
Taylor expanded in c around 0 83.1%
+-commutative83.1%
unpow283.1%
associate-*r/100.0%
fma-def100.0%
Simplified100.0%
Taylor expanded in b around 0 83.1%
associate-*r/83.1%
neg-mul-183.1%
+-commutative83.1%
unpow283.1%
associate-*r/100.0%
fma-udef100.0%
Simplified100.0%
if -5.7000000000000003e242 < d < -4.7999999999999996e192Initial program 36.7%
Taylor expanded in b around inf 36.7%
associate-/l*38.9%
associate-/r/38.9%
+-commutative38.9%
unpow238.9%
fma-def38.9%
Simplified38.9%
*-commutative38.9%
associate-*r/36.7%
fma-udef36.7%
add-sqr-sqrt36.7%
+-commutative36.7%
pow236.7%
hypot-udef36.7%
+-commutative36.7%
pow236.7%
hypot-udef36.7%
frac-times100.0%
clear-num99.9%
un-div-inv100.0%
Applied egg-rr100.0%
Taylor expanded in d around -inf 100.0%
associate-*r/100.0%
neg-mul-1100.0%
Simplified100.0%
if -4.7999999999999996e192 < d < -1e12 or 5.7999999999999994e45 < d Initial program 45.7%
Taylor expanded in c around 0 78.5%
+-commutative78.5%
mul-1-neg78.5%
unsub-neg78.5%
*-commutative78.5%
associate-/l*83.7%
Simplified83.7%
if -1e12 < d < 2.0999999999999999e-164Initial program 73.2%
Taylor expanded in c around inf 76.1%
fma-def76.1%
associate-/l*75.5%
Simplified75.5%
div-inv75.5%
pow275.5%
associate-*l*82.7%
Applied egg-rr82.7%
Taylor expanded in c around 0 82.8%
if 2.0999999999999999e-164 < d < 5.7999999999999994e45Initial program 90.3%
Final simplification85.6%
(FPCore (a b c d)
:precision binary64
(if (<= d -5.7e+242)
(/ (- a) (fma c (/ c d) d))
(if (<= d -4.8e+192)
(/ (/ (- c) d) (/ (hypot c d) b))
(if (or (<= d -1.15e+63) (not (<= d 3.8e+45)))
(- (/ c (/ (pow d 2.0) b)) (/ a d))
(/ (- (* c b) (* d a)) (+ (* c c) (* d d)))))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -5.7e+242) {
tmp = -a / fma(c, (c / d), d);
} else if (d <= -4.8e+192) {
tmp = (-c / d) / (hypot(c, d) / b);
} else if ((d <= -1.15e+63) || !(d <= 3.8e+45)) {
tmp = (c / (pow(d, 2.0) / b)) - (a / d);
} else {
tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
}
return tmp;
}
function code(a, b, c, d) tmp = 0.0 if (d <= -5.7e+242) tmp = Float64(Float64(-a) / fma(c, Float64(c / d), d)); elseif (d <= -4.8e+192) tmp = Float64(Float64(Float64(-c) / d) / Float64(hypot(c, d) / b)); elseif ((d <= -1.15e+63) || !(d <= 3.8e+45)) tmp = Float64(Float64(c / Float64((d ^ 2.0) / b)) - Float64(a / d)); else tmp = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d))); end return tmp end
code[a_, b_, c_, d_] := If[LessEqual[d, -5.7e+242], N[((-a) / N[(c * N[(c / d), $MachinePrecision] + d), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -4.8e+192], N[(N[((-c) / d), $MachinePrecision] / N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[d, -1.15e+63], N[Not[LessEqual[d, 3.8e+45]], $MachinePrecision]], N[(N[(c / N[(N[Power[d, 2.0], $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -5.7 \cdot 10^{+242}:\\
\;\;\;\;\frac{-a}{\mathsf{fma}\left(c, \frac{c}{d}, d\right)}\\
\mathbf{elif}\;d \leq -4.8 \cdot 10^{+192}:\\
\;\;\;\;\frac{\frac{-c}{d}}{\frac{\mathsf{hypot}\left(c, d\right)}{b}}\\
\mathbf{elif}\;d \leq -1.15 \cdot 10^{+63} \lor \neg \left(d \leq 3.8 \cdot 10^{+45}\right):\\
\;\;\;\;\frac{c}{\frac{{d}^{2}}{b}} - \frac{a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
\end{array}
\end{array}
if d < -5.7000000000000003e242Initial program 37.2%
div-sub37.2%
sub-neg37.2%
*-commutative37.2%
add-sqr-sqrt37.2%
times-frac37.2%
fma-def37.2%
hypot-def37.2%
hypot-def37.2%
associate-/l*39.8%
add-sqr-sqrt39.8%
pow239.8%
hypot-def39.8%
Applied egg-rr39.8%
Taylor expanded in c around 0 83.1%
+-commutative83.1%
unpow283.1%
associate-*r/100.0%
fma-def100.0%
Simplified100.0%
Taylor expanded in b around 0 83.1%
associate-*r/83.1%
neg-mul-183.1%
+-commutative83.1%
unpow283.1%
associate-*r/100.0%
fma-udef100.0%
Simplified100.0%
if -5.7000000000000003e242 < d < -4.7999999999999996e192Initial program 36.7%
Taylor expanded in b around inf 36.7%
associate-/l*38.9%
associate-/r/38.9%
+-commutative38.9%
unpow238.9%
fma-def38.9%
Simplified38.9%
*-commutative38.9%
associate-*r/36.7%
fma-udef36.7%
add-sqr-sqrt36.7%
+-commutative36.7%
pow236.7%
hypot-udef36.7%
+-commutative36.7%
pow236.7%
hypot-udef36.7%
frac-times100.0%
clear-num99.9%
un-div-inv100.0%
Applied egg-rr100.0%
Taylor expanded in d around -inf 100.0%
associate-*r/100.0%
neg-mul-1100.0%
Simplified100.0%
if -4.7999999999999996e192 < d < -1.14999999999999997e63 or 3.8000000000000002e45 < d Initial program 42.8%
Taylor expanded in c around 0 78.0%
+-commutative78.0%
mul-1-neg78.0%
unsub-neg78.0%
*-commutative78.0%
associate-/l*83.5%
Simplified83.5%
if -1.14999999999999997e63 < d < 3.8000000000000002e45Initial program 78.5%
Final simplification82.2%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- a) d)))
(if (<= d -190000000.0)
t_0
(if (<= d -1.5e-33)
(/ b c)
(if (<= d -1e-68)
t_0
(if (<= d -1.95e-105)
(/ (* c b) (+ (* c c) (* d d)))
(if (<= d 5.8e-18) (/ b c) t_0)))))))
double code(double a, double b, double c, double d) {
double t_0 = -a / d;
double tmp;
if (d <= -190000000.0) {
tmp = t_0;
} else if (d <= -1.5e-33) {
tmp = b / c;
} else if (d <= -1e-68) {
tmp = t_0;
} else if (d <= -1.95e-105) {
tmp = (c * b) / ((c * c) + (d * d));
} else if (d <= 5.8e-18) {
tmp = b / c;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: tmp
t_0 = -a / d
if (d <= (-190000000.0d0)) then
tmp = t_0
else if (d <= (-1.5d-33)) then
tmp = b / c
else if (d <= (-1d-68)) then
tmp = t_0
else if (d <= (-1.95d-105)) then
tmp = (c * b) / ((c * c) + (d * d))
else if (d <= 5.8d-18) then
tmp = b / c
else
tmp = t_0
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = -a / d;
double tmp;
if (d <= -190000000.0) {
tmp = t_0;
} else if (d <= -1.5e-33) {
tmp = b / c;
} else if (d <= -1e-68) {
tmp = t_0;
} else if (d <= -1.95e-105) {
tmp = (c * b) / ((c * c) + (d * d));
} else if (d <= 5.8e-18) {
tmp = b / c;
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b, c, d): t_0 = -a / d tmp = 0 if d <= -190000000.0: tmp = t_0 elif d <= -1.5e-33: tmp = b / c elif d <= -1e-68: tmp = t_0 elif d <= -1.95e-105: tmp = (c * b) / ((c * c) + (d * d)) elif d <= 5.8e-18: tmp = b / c else: tmp = t_0 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(-a) / d) tmp = 0.0 if (d <= -190000000.0) tmp = t_0; elseif (d <= -1.5e-33) tmp = Float64(b / c); elseif (d <= -1e-68) tmp = t_0; elseif (d <= -1.95e-105) tmp = Float64(Float64(c * b) / Float64(Float64(c * c) + Float64(d * d))); elseif (d <= 5.8e-18) tmp = Float64(b / c); else tmp = t_0; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = -a / d; tmp = 0.0; if (d <= -190000000.0) tmp = t_0; elseif (d <= -1.5e-33) tmp = b / c; elseif (d <= -1e-68) tmp = t_0; elseif (d <= -1.95e-105) tmp = (c * b) / ((c * c) + (d * d)); elseif (d <= 5.8e-18) tmp = b / c; else tmp = t_0; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[((-a) / d), $MachinePrecision]}, If[LessEqual[d, -190000000.0], t$95$0, If[LessEqual[d, -1.5e-33], N[(b / c), $MachinePrecision], If[LessEqual[d, -1e-68], t$95$0, If[LessEqual[d, -1.95e-105], N[(N[(c * b), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 5.8e-18], N[(b / c), $MachinePrecision], t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-a}{d}\\
\mathbf{if}\;d \leq -190000000:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq -1.5 \cdot 10^{-33}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{elif}\;d \leq -1 \cdot 10^{-68}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq -1.95 \cdot 10^{-105}:\\
\;\;\;\;\frac{c \cdot b}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;d \leq 5.8 \cdot 10^{-18}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if d < -1.9e8 or -1.5000000000000001e-33 < d < -1.00000000000000007e-68 or 5.8e-18 < d Initial program 48.8%
Taylor expanded in c around 0 69.7%
associate-*r/69.7%
neg-mul-169.7%
Simplified69.7%
if -1.9e8 < d < -1.5000000000000001e-33 or -1.95e-105 < d < 5.8e-18Initial program 76.8%
Taylor expanded in c around inf 68.3%
if -1.00000000000000007e-68 < d < -1.95e-105Initial program 80.7%
Taylor expanded in b around inf 80.7%
*-commutative80.7%
Simplified80.7%
Final simplification69.3%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- a) d)))
(if (<= d -76000000.0)
t_0
(if (<= d -8.2e-34)
(/ b c)
(if (<= d -3.8e-69)
(/ (* d (- a)) (+ (* c c) (* d d)))
(if (<= d 2.7e-16) (/ b c) t_0))))))
double code(double a, double b, double c, double d) {
double t_0 = -a / d;
double tmp;
if (d <= -76000000.0) {
tmp = t_0;
} else if (d <= -8.2e-34) {
tmp = b / c;
} else if (d <= -3.8e-69) {
tmp = (d * -a) / ((c * c) + (d * d));
} else if (d <= 2.7e-16) {
tmp = b / c;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: tmp
t_0 = -a / d
if (d <= (-76000000.0d0)) then
tmp = t_0
else if (d <= (-8.2d-34)) then
tmp = b / c
else if (d <= (-3.8d-69)) then
tmp = (d * -a) / ((c * c) + (d * d))
else if (d <= 2.7d-16) then
tmp = b / c
else
tmp = t_0
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = -a / d;
double tmp;
if (d <= -76000000.0) {
tmp = t_0;
} else if (d <= -8.2e-34) {
tmp = b / c;
} else if (d <= -3.8e-69) {
tmp = (d * -a) / ((c * c) + (d * d));
} else if (d <= 2.7e-16) {
tmp = b / c;
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b, c, d): t_0 = -a / d tmp = 0 if d <= -76000000.0: tmp = t_0 elif d <= -8.2e-34: tmp = b / c elif d <= -3.8e-69: tmp = (d * -a) / ((c * c) + (d * d)) elif d <= 2.7e-16: tmp = b / c else: tmp = t_0 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(-a) / d) tmp = 0.0 if (d <= -76000000.0) tmp = t_0; elseif (d <= -8.2e-34) tmp = Float64(b / c); elseif (d <= -3.8e-69) tmp = Float64(Float64(d * Float64(-a)) / Float64(Float64(c * c) + Float64(d * d))); elseif (d <= 2.7e-16) tmp = Float64(b / c); else tmp = t_0; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = -a / d; tmp = 0.0; if (d <= -76000000.0) tmp = t_0; elseif (d <= -8.2e-34) tmp = b / c; elseif (d <= -3.8e-69) tmp = (d * -a) / ((c * c) + (d * d)); elseif (d <= 2.7e-16) tmp = b / c; else tmp = t_0; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[((-a) / d), $MachinePrecision]}, If[LessEqual[d, -76000000.0], t$95$0, If[LessEqual[d, -8.2e-34], N[(b / c), $MachinePrecision], If[LessEqual[d, -3.8e-69], N[(N[(d * (-a)), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.7e-16], N[(b / c), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-a}{d}\\
\mathbf{if}\;d \leq -76000000:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq -8.2 \cdot 10^{-34}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{elif}\;d \leq -3.8 \cdot 10^{-69}:\\
\;\;\;\;\frac{d \cdot \left(-a\right)}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;d \leq 2.7 \cdot 10^{-16}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if d < -7.6e7 or 2.69999999999999999e-16 < d Initial program 46.8%
Taylor expanded in c around 0 69.8%
associate-*r/69.8%
neg-mul-169.8%
Simplified69.8%
if -7.6e7 < d < -8.2000000000000007e-34 or -3.7999999999999998e-69 < d < 2.69999999999999999e-16Initial program 77.0%
Taylor expanded in c around inf 68.1%
if -8.2000000000000007e-34 < d < -3.7999999999999998e-69Initial program 78.4%
Taylor expanded in b around 0 78.7%
associate-*r*78.7%
neg-mul-178.7%
*-commutative78.7%
Simplified78.7%
Final simplification69.3%
(FPCore (a b c d) :precision binary64 (if (or (<= d -4.6e+121) (not (<= d 8.2e+107))) (/ (- a) d) (/ (- (* c b) (* d a)) (+ (* c c) (* d d)))))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -4.6e+121) || !(d <= 8.2e+107)) {
tmp = -a / d;
} else {
tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if ((d <= (-4.6d+121)) .or. (.not. (d <= 8.2d+107))) then
tmp = -a / d
else
tmp = ((c * b) - (d * a)) / ((c * c) + (d * d))
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -4.6e+121) || !(d <= 8.2e+107)) {
tmp = -a / d;
} else {
tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -4.6e+121) or not (d <= 8.2e+107): tmp = -a / d else: tmp = ((c * b) - (d * a)) / ((c * c) + (d * d)) return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -4.6e+121) || !(d <= 8.2e+107)) tmp = Float64(Float64(-a) / d); else tmp = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -4.6e+121) || ~((d <= 8.2e+107))) tmp = -a / d; else tmp = ((c * b) - (d * a)) / ((c * c) + (d * d)); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -4.6e+121], N[Not[LessEqual[d, 8.2e+107]], $MachinePrecision]], N[((-a) / d), $MachinePrecision], N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -4.6 \cdot 10^{+121} \lor \neg \left(d \leq 8.2 \cdot 10^{+107}\right):\\
\;\;\;\;\frac{-a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
\end{array}
\end{array}
if d < -4.5999999999999997e121 or 8.1999999999999998e107 < d Initial program 33.6%
Taylor expanded in c around 0 78.8%
associate-*r/78.8%
neg-mul-178.8%
Simplified78.8%
if -4.5999999999999997e121 < d < 8.1999999999999998e107Initial program 77.2%
Final simplification77.8%
(FPCore (a b c d) :precision binary64 (if (or (<= d -1800000.0) (not (<= d 4.1e-19))) (/ (- a) d) (/ b c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -1800000.0) || !(d <= 4.1e-19)) {
tmp = -a / d;
} else {
tmp = b / c;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if ((d <= (-1800000.0d0)) .or. (.not. (d <= 4.1d-19))) then
tmp = -a / d
else
tmp = b / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -1800000.0) || !(d <= 4.1e-19)) {
tmp = -a / d;
} else {
tmp = b / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -1800000.0) or not (d <= 4.1e-19): tmp = -a / d else: tmp = b / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -1800000.0) || !(d <= 4.1e-19)) tmp = Float64(Float64(-a) / d); else tmp = Float64(b / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -1800000.0) || ~((d <= 4.1e-19))) tmp = -a / d; else tmp = b / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -1800000.0], N[Not[LessEqual[d, 4.1e-19]], $MachinePrecision]], N[((-a) / d), $MachinePrecision], N[(b / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -1800000 \lor \neg \left(d \leq 4.1 \cdot 10^{-19}\right):\\
\;\;\;\;\frac{-a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if d < -1.8e6 or 4.09999999999999985e-19 < d Initial program 46.8%
Taylor expanded in c around 0 69.8%
associate-*r/69.8%
neg-mul-169.8%
Simplified69.8%
if -1.8e6 < d < 4.09999999999999985e-19Initial program 77.1%
Taylor expanded in c around inf 65.1%
Final simplification67.5%
(FPCore (a b c d) :precision binary64 (if (<= d 1.4e+143) (/ b c) (/ b d)))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= 1.4e+143) {
tmp = b / c;
} else {
tmp = b / d;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (d <= 1.4d+143) then
tmp = b / c
else
tmp = b / d
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (d <= 1.4e+143) {
tmp = b / c;
} else {
tmp = b / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= 1.4e+143: tmp = b / c else: tmp = b / d return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= 1.4e+143) tmp = Float64(b / c); else tmp = Float64(b / d); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= 1.4e+143) tmp = b / c; else tmp = b / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, 1.4e+143], N[(b / c), $MachinePrecision], N[(b / d), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq 1.4 \cdot 10^{+143}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d}\\
\end{array}
\end{array}
if d < 1.39999999999999999e143Initial program 69.0%
Taylor expanded in c around inf 45.4%
if 1.39999999999999999e143 < d Initial program 28.5%
Taylor expanded in b around inf 27.7%
associate-/l*28.5%
associate-/r/28.5%
+-commutative28.5%
unpow228.5%
fma-def28.5%
Simplified28.5%
*-commutative28.5%
associate-*r/27.7%
fma-udef27.7%
add-sqr-sqrt27.7%
+-commutative27.7%
pow227.7%
hypot-udef27.7%
+-commutative27.7%
pow227.7%
hypot-udef27.7%
frac-times40.9%
clear-num40.9%
un-div-inv40.9%
Applied egg-rr40.9%
Taylor expanded in c around inf 20.2%
Taylor expanded in c around 0 20.2%
Final simplification40.9%
(FPCore (a b c d) :precision binary64 (/ b c))
double code(double a, double b, double c, double d) {
return b / c;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = b / c
end function
public static double code(double a, double b, double c, double d) {
return b / c;
}
def code(a, b, c, d): return b / c
function code(a, b, c, d) return Float64(b / c) end
function tmp = code(a, b, c, d) tmp = b / c; end
code[a_, b_, c_, d_] := N[(b / c), $MachinePrecision]
\begin{array}{l}
\\
\frac{b}{c}
\end{array}
Initial program 61.7%
Taylor expanded in c around inf 38.3%
Final simplification38.3%
(FPCore (a b c d) :precision binary64 (if (< (fabs d) (fabs c)) (/ (- b (* a (/ d c))) (+ c (* d (/ d c)))) (/ (+ (- a) (* b (/ c d))) (+ d (* c (/ c d))))))
double code(double a, double b, double c, double d) {
double tmp;
if (fabs(d) < fabs(c)) {
tmp = (b - (a * (d / c))) / (c + (d * (d / c)));
} else {
tmp = (-a + (b * (c / d))) / (d + (c * (c / d)));
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (abs(d) < abs(c)) then
tmp = (b - (a * (d / c))) / (c + (d * (d / c)))
else
tmp = (-a + (b * (c / d))) / (d + (c * (c / d)))
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (Math.abs(d) < Math.abs(c)) {
tmp = (b - (a * (d / c))) / (c + (d * (d / c)));
} else {
tmp = (-a + (b * (c / d))) / (d + (c * (c / d)));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if math.fabs(d) < math.fabs(c): tmp = (b - (a * (d / c))) / (c + (d * (d / c))) else: tmp = (-a + (b * (c / d))) / (d + (c * (c / d))) return tmp
function code(a, b, c, d) tmp = 0.0 if (abs(d) < abs(c)) tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / Float64(c + Float64(d * Float64(d / c)))); else tmp = Float64(Float64(Float64(-a) + Float64(b * Float64(c / d))) / Float64(d + Float64(c * Float64(c / d)))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (abs(d) < abs(c)) tmp = (b - (a * (d / c))) / (c + (d * (d / c))); else tmp = (-a + (b * (c / d))) / (d + (c * (c / d))); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Less[N[Abs[d], $MachinePrecision], N[Abs[c], $MachinePrecision]], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(c + N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[((-a) + N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(d + N[(c * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left|d\right| < \left|c\right|:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c + d \cdot \frac{d}{c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-a\right) + b \cdot \frac{c}{d}}{d + c \cdot \frac{c}{d}}\\
\end{array}
\end{array}
herbie shell --seed 2024018
(FPCore (a b c d)
:name "Complex division, imag part"
:precision binary64
:herbie-target
(if (< (fabs d) (fabs c)) (/ (- b (* a (/ d c))) (+ c (* d (/ d c)))) (/ (+ (- a) (* b (/ c d))) (+ d (* c (/ c d)))))
(/ (- (* b c) (* a d)) (+ (* c c) (* d d))))