
(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
(let* ((t_0 (/ b (hypot c d))) (t_1 (/ c (hypot c d))))
(if (or (<= d -8e+120) (not (<= d 7.5e+86)))
(fma t_1 t_0 (/ a (- d)))
(fma t_1 t_0 (* (/ d (pow (hypot c d) 2.0)) (- a))))))
double code(double a, double b, double c, double d) {
double t_0 = b / hypot(c, d);
double t_1 = c / hypot(c, d);
double tmp;
if ((d <= -8e+120) || !(d <= 7.5e+86)) {
tmp = fma(t_1, t_0, (a / -d));
} else {
tmp = fma(t_1, t_0, ((d / pow(hypot(c, d), 2.0)) * -a));
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(b / hypot(c, d)) t_1 = Float64(c / hypot(c, d)) tmp = 0.0 if ((d <= -8e+120) || !(d <= 7.5e+86)) tmp = fma(t_1, t_0, Float64(a / Float64(-d))); else tmp = fma(t_1, t_0, Float64(Float64(d / (hypot(c, d) ^ 2.0)) * Float64(-a))); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[d, -8e+120], N[Not[LessEqual[d, 7.5e+86]], $MachinePrecision]], N[(t$95$1 * t$95$0 + N[(a / (-d)), $MachinePrecision]), $MachinePrecision], N[(t$95$1 * t$95$0 + N[(N[(d / N[Power[N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * (-a)), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b}{\mathsf{hypot}\left(c, d\right)}\\
t_1 := \frac{c}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{if}\;d \leq -8 \cdot 10^{+120} \lor \neg \left(d \leq 7.5 \cdot 10^{+86}\right):\\
\;\;\;\;\mathsf{fma}\left(t\_1, t\_0, \frac{a}{-d}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t\_1, t\_0, \frac{d}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}} \cdot \left(-a\right)\right)\\
\end{array}
\end{array}
if d < -7.9999999999999998e120 or 7.4999999999999997e86 < d Initial program 44.3%
div-sub44.3%
*-commutative44.3%
add-sqr-sqrt44.3%
times-frac43.9%
fma-neg43.9%
hypot-define43.9%
hypot-define52.1%
associate-/l*62.3%
add-sqr-sqrt62.3%
pow262.3%
hypot-define62.3%
Applied egg-rr62.3%
Taylor expanded in d around inf 97.0%
if -7.9999999999999998e120 < d < 7.4999999999999997e86Initial program 74.9%
div-sub71.2%
*-commutative71.2%
add-sqr-sqrt71.2%
times-frac74.9%
fma-neg74.9%
hypot-define74.9%
hypot-define89.2%
associate-/l*91.4%
add-sqr-sqrt91.4%
pow291.4%
hypot-define91.4%
Applied egg-rr91.4%
Final simplification93.2%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ 1.0 (hypot c d)))
(t_1 (- (* c b) (* d a)))
(t_2 (/ t_1 (+ (* c c) (* d d))))
(t_3 (/ c (hypot c d)))
(t_4 (/ a (- d))))
(if (<= t_2 (- INFINITY))
(fma t_0 (* t_3 b) t_4)
(if (<= t_2 5e+193)
(* t_0 (/ t_1 (hypot c d)))
(fma t_3 (/ b (hypot c d)) t_4)))))
double code(double a, double b, double c, double d) {
double t_0 = 1.0 / hypot(c, d);
double t_1 = (c * b) - (d * a);
double t_2 = t_1 / ((c * c) + (d * d));
double t_3 = c / hypot(c, d);
double t_4 = a / -d;
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = fma(t_0, (t_3 * b), t_4);
} else if (t_2 <= 5e+193) {
tmp = t_0 * (t_1 / hypot(c, d));
} else {
tmp = fma(t_3, (b / hypot(c, d)), t_4);
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(1.0 / hypot(c, d)) t_1 = Float64(Float64(c * b) - Float64(d * a)) t_2 = Float64(t_1 / Float64(Float64(c * c) + Float64(d * d))) t_3 = Float64(c / hypot(c, d)) t_4 = Float64(a / Float64(-d)) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = fma(t_0, Float64(t_3 * b), t_4); elseif (t_2 <= 5e+193) tmp = Float64(t_0 * Float64(t_1 / hypot(c, d))); else tmp = fma(t_3, Float64(b / hypot(c, d)), t_4); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(a / (-d)), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], N[(t$95$0 * N[(t$95$3 * b), $MachinePrecision] + t$95$4), $MachinePrecision], If[LessEqual[t$95$2, 5e+193], N[(t$95$0 * N[(t$95$1 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$3 * N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] + t$95$4), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\mathsf{hypot}\left(c, d\right)}\\
t_1 := c \cdot b - d \cdot a\\
t_2 := \frac{t\_1}{c \cdot c + d \cdot d}\\
t_3 := \frac{c}{\mathsf{hypot}\left(c, d\right)}\\
t_4 := \frac{a}{-d}\\
\mathbf{if}\;t\_2 \leq -\infty:\\
\;\;\;\;\mathsf{fma}\left(t\_0, t\_3 \cdot b, t\_4\right)\\
\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{+193}:\\
\;\;\;\;t\_0 \cdot \frac{t\_1}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t\_3, \frac{b}{\mathsf{hypot}\left(c, d\right)}, t\_4\right)\\
\end{array}
\end{array}
if (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < -inf.0Initial program 45.3%
div-sub33.9%
*-un-lft-identity33.9%
add-sqr-sqrt33.9%
times-frac33.9%
fma-neg33.9%
hypot-define33.9%
hypot-define34.4%
associate-/l*65.1%
add-sqr-sqrt65.1%
pow265.1%
hypot-define65.1%
Applied egg-rr65.1%
associate-/l*80.0%
associate-*r/49.3%
*-commutative49.3%
Simplified49.3%
Taylor expanded in d around inf 85.4%
if -inf.0 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 4.99999999999999972e193Initial program 84.8%
*-un-lft-identity84.8%
add-sqr-sqrt84.8%
times-frac84.7%
hypot-define84.7%
hypot-define99.0%
Applied egg-rr99.0%
if 4.99999999999999972e193 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 22.9%
div-sub16.9%
*-commutative16.9%
add-sqr-sqrt16.9%
times-frac23.4%
fma-neg23.4%
hypot-define23.5%
hypot-define49.0%
associate-/l*58.6%
add-sqr-sqrt58.6%
pow258.6%
hypot-define58.6%
Applied egg-rr58.6%
Taylor expanded in d around inf 80.5%
Final simplification92.9%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (- (* c b) (* d a))))
(if (<= (/ t_0 (+ (* c c) (* d d))) 5e+193)
(* (/ 1.0 (hypot c d)) (/ t_0 (hypot c d)))
(fma (/ c (hypot c d)) (/ b (hypot c d)) (/ a (- 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))) <= 5e+193) {
tmp = (1.0 / hypot(c, d)) * (t_0 / hypot(c, d));
} else {
tmp = fma((c / hypot(c, d)), (b / hypot(c, d)), (a / -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))) <= 5e+193) tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(t_0 / hypot(c, d))); else tmp = fma(Float64(c / hypot(c, d)), Float64(b / hypot(c, d)), Float64(a / Float64(-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], 5e+193], 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[(N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] + N[(a / (-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 5 \cdot 10^{+193}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{t\_0}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, \frac{a}{-d}\right)\\
\end{array}
\end{array}
if (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 4.99999999999999972e193Initial program 80.8%
*-un-lft-identity80.8%
add-sqr-sqrt80.8%
times-frac80.7%
hypot-define80.7%
hypot-define95.0%
Applied egg-rr95.0%
if 4.99999999999999972e193 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 22.9%
div-sub16.9%
*-commutative16.9%
add-sqr-sqrt16.9%
times-frac23.4%
fma-neg23.4%
hypot-define23.5%
hypot-define49.0%
associate-/l*58.6%
add-sqr-sqrt58.6%
pow258.6%
hypot-define58.6%
Applied egg-rr58.6%
Taylor expanded in d around inf 80.5%
Final simplification91.0%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (- (* c b) (* d a))))
(if (<= (/ t_0 (+ (* c c) (* d d))) 5e+287)
(* (/ 1.0 (hypot c d)) (/ t_0 (hypot c d)))
(/ (- (* c (/ b d)) a) 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))) <= 5e+287) {
tmp = (1.0 / hypot(c, d)) * (t_0 / hypot(c, d));
} else {
tmp = ((c * (b / d)) - a) / d;
}
return tmp;
}
public static 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))) <= 5e+287) {
tmp = (1.0 / Math.hypot(c, d)) * (t_0 / Math.hypot(c, d));
} else {
tmp = ((c * (b / d)) - a) / d;
}
return tmp;
}
def code(a, b, c, d): t_0 = (c * b) - (d * a) tmp = 0 if (t_0 / ((c * c) + (d * d))) <= 5e+287: tmp = (1.0 / math.hypot(c, d)) * (t_0 / math.hypot(c, d)) else: tmp = ((c * (b / d)) - a) / 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))) <= 5e+287) tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(t_0 / hypot(c, d))); else tmp = Float64(Float64(Float64(c * Float64(b / d)) - a) / d); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (c * b) - (d * a); tmp = 0.0; if ((t_0 / ((c * c) + (d * d))) <= 5e+287) tmp = (1.0 / hypot(c, d)) * (t_0 / hypot(c, d)); else tmp = ((c * (b / d)) - a) / d; end tmp_2 = 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], 5e+287], 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[(N[(N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $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 5 \cdot 10^{+287}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{t\_0}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\
\end{array}
\end{array}
if (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 5e287Initial program 81.1%
*-un-lft-identity81.1%
add-sqr-sqrt81.1%
times-frac81.0%
hypot-define81.1%
hypot-define95.2%
Applied egg-rr95.2%
if 5e287 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 16.5%
Taylor expanded in c around 0 49.4%
+-commutative49.4%
mul-1-neg49.4%
unsub-neg49.4%
unpow249.4%
associate-/r*59.0%
div-sub59.1%
*-commutative59.1%
associate-/l*68.2%
Simplified68.2%
Final simplification88.4%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* c b) (* d a)) (+ (* c c) (* d d)))))
(if (<= d -2.45e+121)
(/ (- a (* b (/ c d))) (hypot d c))
(if (<= d -1.45e-158)
t_0
(if (<= d 6.2e-104)
(/ (- b (/ (* d a) c)) c)
(if (<= d 4.1e+64) t_0 (/ (- (* c (/ b d)) a) 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 (d <= -2.45e+121) {
tmp = (a - (b * (c / d))) / hypot(d, c);
} else if (d <= -1.45e-158) {
tmp = t_0;
} else if (d <= 6.2e-104) {
tmp = (b - ((d * a) / c)) / c;
} else if (d <= 4.1e+64) {
tmp = t_0;
} else {
tmp = ((c * (b / d)) - a) / d;
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
double tmp;
if (d <= -2.45e+121) {
tmp = (a - (b * (c / d))) / Math.hypot(d, c);
} else if (d <= -1.45e-158) {
tmp = t_0;
} else if (d <= 6.2e-104) {
tmp = (b - ((d * a) / c)) / c;
} else if (d <= 4.1e+64) {
tmp = t_0;
} else {
tmp = ((c * (b / d)) - a) / d;
}
return tmp;
}
def code(a, b, c, d): t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d)) tmp = 0 if d <= -2.45e+121: tmp = (a - (b * (c / d))) / math.hypot(d, c) elif d <= -1.45e-158: tmp = t_0 elif d <= 6.2e-104: tmp = (b - ((d * a) / c)) / c elif d <= 4.1e+64: tmp = t_0 else: tmp = ((c * (b / d)) - a) / 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 (d <= -2.45e+121) tmp = Float64(Float64(a - Float64(b * Float64(c / d))) / hypot(d, c)); elseif (d <= -1.45e-158) tmp = t_0; elseif (d <= 6.2e-104) tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c); elseif (d <= 4.1e+64) tmp = t_0; else tmp = Float64(Float64(Float64(c * Float64(b / d)) - a) / d); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d)); tmp = 0.0; if (d <= -2.45e+121) tmp = (a - (b * (c / d))) / hypot(d, c); elseif (d <= -1.45e-158) tmp = t_0; elseif (d <= 6.2e-104) tmp = (b - ((d * a) / c)) / c; elseif (d <= 4.1e+64) tmp = t_0; else tmp = ((c * (b / d)) - a) / d; end tmp_2 = 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[LessEqual[d, -2.45e+121], N[(N[(a - N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -1.45e-158], t$95$0, If[LessEqual[d, 6.2e-104], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 4.1e+64], t$95$0, N[(N[(N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{if}\;d \leq -2.45 \cdot 10^{+121}:\\
\;\;\;\;\frac{a - b \cdot \frac{c}{d}}{\mathsf{hypot}\left(d, c\right)}\\
\mathbf{elif}\;d \leq -1.45 \cdot 10^{-158}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 6.2 \cdot 10^{-104}:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\
\mathbf{elif}\;d \leq 4.1 \cdot 10^{+64}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\
\end{array}
\end{array}
if d < -2.4499999999999999e121Initial program 52.6%
*-un-lft-identity52.6%
add-sqr-sqrt52.6%
times-frac52.5%
hypot-define52.5%
hypot-define66.4%
Applied egg-rr66.4%
Taylor expanded in d around -inf 87.0%
mul-1-neg87.0%
unsub-neg87.0%
associate-/l*90.3%
Simplified90.3%
sub-neg90.3%
distribute-lft-in90.3%
distribute-rgt-neg-in90.3%
Applied egg-rr90.3%
*-commutative90.3%
associate-*r/90.5%
*-rgt-identity90.5%
*-commutative90.5%
associate-*r/90.5%
*-rgt-identity90.5%
distribute-rgt-neg-out90.5%
distribute-frac-neg90.5%
sub-neg90.5%
div-sub90.5%
hypot-undefine60.4%
unpow260.4%
unpow260.4%
+-commutative60.4%
unpow260.4%
unpow260.4%
hypot-define90.5%
Simplified90.5%
if -2.4499999999999999e121 < d < -1.4499999999999999e-158 or 6.19999999999999951e-104 < d < 4.09999999999999978e64Initial program 78.2%
if -1.4499999999999999e-158 < d < 6.19999999999999951e-104Initial program 72.3%
div-sub64.1%
*-commutative64.1%
add-sqr-sqrt64.1%
times-frac68.3%
fma-neg68.3%
hypot-define68.3%
hypot-define85.0%
associate-/l*85.3%
add-sqr-sqrt85.3%
pow285.3%
hypot-define85.3%
Applied egg-rr85.3%
Taylor expanded in c around inf 92.2%
mul-1-neg92.2%
associate-*r/91.1%
sub-neg91.1%
associate-*r/92.2%
Simplified92.2%
if 4.09999999999999978e64 < d Initial program 40.6%
Taylor expanded in c around 0 81.3%
+-commutative81.3%
mul-1-neg81.3%
unsub-neg81.3%
unpow281.3%
associate-/r*80.2%
div-sub80.2%
*-commutative80.2%
associate-/l*90.2%
Simplified90.2%
Final simplification86.6%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* c b) (* d a)) (+ (* c c) (* d d)))))
(if (<= d -1.4e+121)
(- (* b (/ c (pow d 2.0))) (/ a d))
(if (<= d -1.5e-158)
t_0
(if (<= d 5.5e-106)
(/ (- b (/ (* d a) c)) c)
(if (<= d 1.52e+59) t_0 (/ (- (* c (/ b d)) a) 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 (d <= -1.4e+121) {
tmp = (b * (c / pow(d, 2.0))) - (a / d);
} else if (d <= -1.5e-158) {
tmp = t_0;
} else if (d <= 5.5e-106) {
tmp = (b - ((d * a) / c)) / c;
} else if (d <= 1.52e+59) {
tmp = t_0;
} else {
tmp = ((c * (b / d)) - a) / 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) :: t_0
real(8) :: tmp
t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d))
if (d <= (-1.4d+121)) then
tmp = (b * (c / (d ** 2.0d0))) - (a / d)
else if (d <= (-1.5d-158)) then
tmp = t_0
else if (d <= 5.5d-106) then
tmp = (b - ((d * a) / c)) / c
else if (d <= 1.52d+59) then
tmp = t_0
else
tmp = ((c * (b / d)) - a) / d
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
double tmp;
if (d <= -1.4e+121) {
tmp = (b * (c / Math.pow(d, 2.0))) - (a / d);
} else if (d <= -1.5e-158) {
tmp = t_0;
} else if (d <= 5.5e-106) {
tmp = (b - ((d * a) / c)) / c;
} else if (d <= 1.52e+59) {
tmp = t_0;
} else {
tmp = ((c * (b / d)) - a) / d;
}
return tmp;
}
def code(a, b, c, d): t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d)) tmp = 0 if d <= -1.4e+121: tmp = (b * (c / math.pow(d, 2.0))) - (a / d) elif d <= -1.5e-158: tmp = t_0 elif d <= 5.5e-106: tmp = (b - ((d * a) / c)) / c elif d <= 1.52e+59: tmp = t_0 else: tmp = ((c * (b / d)) - a) / 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 (d <= -1.4e+121) tmp = Float64(Float64(b * Float64(c / (d ^ 2.0))) - Float64(a / d)); elseif (d <= -1.5e-158) tmp = t_0; elseif (d <= 5.5e-106) tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c); elseif (d <= 1.52e+59) tmp = t_0; else tmp = Float64(Float64(Float64(c * Float64(b / d)) - a) / d); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d)); tmp = 0.0; if (d <= -1.4e+121) tmp = (b * (c / (d ^ 2.0))) - (a / d); elseif (d <= -1.5e-158) tmp = t_0; elseif (d <= 5.5e-106) tmp = (b - ((d * a) / c)) / c; elseif (d <= 1.52e+59) tmp = t_0; else tmp = ((c * (b / d)) - a) / d; end tmp_2 = 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[LessEqual[d, -1.4e+121], N[(N[(b * N[(c / N[Power[d, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -1.5e-158], t$95$0, If[LessEqual[d, 5.5e-106], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 1.52e+59], t$95$0, N[(N[(N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{if}\;d \leq -1.4 \cdot 10^{+121}:\\
\;\;\;\;b \cdot \frac{c}{{d}^{2}} - \frac{a}{d}\\
\mathbf{elif}\;d \leq -1.5 \cdot 10^{-158}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 5.5 \cdot 10^{-106}:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\
\mathbf{elif}\;d \leq 1.52 \cdot 10^{+59}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\
\end{array}
\end{array}
if d < -1.40000000000000003e121Initial program 52.6%
div-sub52.5%
*-commutative52.5%
add-sqr-sqrt52.5%
times-frac52.9%
fma-neg52.9%
hypot-define52.9%
hypot-define59.5%
associate-/l*67.1%
add-sqr-sqrt67.1%
pow267.1%
hypot-define67.1%
Applied egg-rr67.1%
Taylor expanded in c around 0 89.8%
associate-/l*90.0%
Simplified90.0%
if -1.40000000000000003e121 < d < -1.5e-158 or 5.5000000000000001e-106 < d < 1.5199999999999999e59Initial program 78.2%
if -1.5e-158 < d < 5.5000000000000001e-106Initial program 72.3%
div-sub64.1%
*-commutative64.1%
add-sqr-sqrt64.1%
times-frac68.3%
fma-neg68.3%
hypot-define68.3%
hypot-define85.0%
associate-/l*85.3%
add-sqr-sqrt85.3%
pow285.3%
hypot-define85.3%
Applied egg-rr85.3%
Taylor expanded in c around inf 92.2%
mul-1-neg92.2%
associate-*r/91.1%
sub-neg91.1%
associate-*r/92.2%
Simplified92.2%
if 1.5199999999999999e59 < d Initial program 40.6%
Taylor expanded in c around 0 81.3%
+-commutative81.3%
mul-1-neg81.3%
unsub-neg81.3%
unpow281.3%
associate-/r*80.2%
div-sub80.2%
*-commutative80.2%
associate-/l*90.2%
Simplified90.2%
Final simplification86.5%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* c b) (* d a)) (+ (* c c) (* d d))))
(t_1 (/ (- (* c (/ b d)) a) d)))
(if (<= d -2.6e+121)
t_1
(if (<= d -1.5e-158)
t_0
(if (<= d 4.2e-104)
(/ (- b (/ (* d a) c)) c)
(if (<= d 1.95e+64) t_0 t_1))))))
double code(double a, double b, double c, double d) {
double t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
double t_1 = ((c * (b / d)) - a) / d;
double tmp;
if (d <= -2.6e+121) {
tmp = t_1;
} else if (d <= -1.5e-158) {
tmp = t_0;
} else if (d <= 4.2e-104) {
tmp = (b - ((d * a) / c)) / c;
} else if (d <= 1.95e+64) {
tmp = t_0;
} else {
tmp = t_1;
}
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) :: t_1
real(8) :: tmp
t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d))
t_1 = ((c * (b / d)) - a) / d
if (d <= (-2.6d+121)) then
tmp = t_1
else if (d <= (-1.5d-158)) then
tmp = t_0
else if (d <= 4.2d-104) then
tmp = (b - ((d * a) / c)) / c
else if (d <= 1.95d+64) then
tmp = t_0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
double t_1 = ((c * (b / d)) - a) / d;
double tmp;
if (d <= -2.6e+121) {
tmp = t_1;
} else if (d <= -1.5e-158) {
tmp = t_0;
} else if (d <= 4.2e-104) {
tmp = (b - ((d * a) / c)) / c;
} else if (d <= 1.95e+64) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(a, b, c, d): t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d)) t_1 = ((c * (b / d)) - a) / d tmp = 0 if d <= -2.6e+121: tmp = t_1 elif d <= -1.5e-158: tmp = t_0 elif d <= 4.2e-104: tmp = (b - ((d * a) / c)) / c elif d <= 1.95e+64: tmp = t_0 else: tmp = t_1 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))) t_1 = Float64(Float64(Float64(c * Float64(b / d)) - a) / d) tmp = 0.0 if (d <= -2.6e+121) tmp = t_1; elseif (d <= -1.5e-158) tmp = t_0; elseif (d <= 4.2e-104) tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c); elseif (d <= 1.95e+64) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d)); t_1 = ((c * (b / d)) - a) / d; tmp = 0.0; if (d <= -2.6e+121) tmp = t_1; elseif (d <= -1.5e-158) tmp = t_0; elseif (d <= 4.2e-104) tmp = (b - ((d * a) / c)) / c; elseif (d <= 1.95e+64) tmp = t_0; else tmp = t_1; end tmp_2 = 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]}, Block[{t$95$1 = N[(N[(N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -2.6e+121], t$95$1, If[LessEqual[d, -1.5e-158], t$95$0, If[LessEqual[d, 4.2e-104], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 1.95e+64], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
t_1 := \frac{c \cdot \frac{b}{d} - a}{d}\\
\mathbf{if}\;d \leq -2.6 \cdot 10^{+121}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d \leq -1.5 \cdot 10^{-158}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 4.2 \cdot 10^{-104}:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\
\mathbf{elif}\;d \leq 1.95 \cdot 10^{+64}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if d < -2.5999999999999999e121 or 1.9499999999999999e64 < d Initial program 44.6%
Taylor expanded in c around 0 84.1%
+-commutative84.1%
mul-1-neg84.1%
unsub-neg84.1%
unpow284.1%
associate-/r*81.5%
div-sub81.5%
*-commutative81.5%
associate-/l*90.1%
Simplified90.1%
if -2.5999999999999999e121 < d < -1.5e-158 or 4.19999999999999997e-104 < d < 1.9499999999999999e64Initial program 78.2%
if -1.5e-158 < d < 4.19999999999999997e-104Initial program 72.3%
div-sub64.1%
*-commutative64.1%
add-sqr-sqrt64.1%
times-frac68.3%
fma-neg68.3%
hypot-define68.3%
hypot-define85.0%
associate-/l*85.3%
add-sqr-sqrt85.3%
pow285.3%
hypot-define85.3%
Applied egg-rr85.3%
Taylor expanded in c around inf 92.2%
mul-1-neg92.2%
associate-*r/91.1%
sub-neg91.1%
associate-*r/92.2%
Simplified92.2%
Final simplification86.5%
(FPCore (a b c d)
:precision binary64
(if (<= c -1.56e-9)
(/ (- b (* a (/ d c))) c)
(if (<= c 2.05e+38)
(/ (- (/ (* c b) d) a) d)
(/ (* b (- 1.0 (* a (/ d (* c b))))) c))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -1.56e-9) {
tmp = (b - (a * (d / c))) / c;
} else if (c <= 2.05e+38) {
tmp = (((c * b) / d) - a) / d;
} else {
tmp = (b * (1.0 - (a * (d / (c * 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 (c <= (-1.56d-9)) then
tmp = (b - (a * (d / c))) / c
else if (c <= 2.05d+38) then
tmp = (((c * b) / d) - a) / d
else
tmp = (b * (1.0d0 - (a * (d / (c * b))))) / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -1.56e-9) {
tmp = (b - (a * (d / c))) / c;
} else if (c <= 2.05e+38) {
tmp = (((c * b) / d) - a) / d;
} else {
tmp = (b * (1.0 - (a * (d / (c * b))))) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -1.56e-9: tmp = (b - (a * (d / c))) / c elif c <= 2.05e+38: tmp = (((c * b) / d) - a) / d else: tmp = (b * (1.0 - (a * (d / (c * b))))) / c return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -1.56e-9) tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c); elseif (c <= 2.05e+38) tmp = Float64(Float64(Float64(Float64(c * b) / d) - a) / d); else tmp = Float64(Float64(b * Float64(1.0 - Float64(a * Float64(d / Float64(c * b))))) / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -1.56e-9) tmp = (b - (a * (d / c))) / c; elseif (c <= 2.05e+38) tmp = (((c * b) / d) - a) / d; else tmp = (b * (1.0 - (a * (d / (c * b))))) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -1.56e-9], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[c, 2.05e+38], N[(N[(N[(N[(c * b), $MachinePrecision] / d), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], N[(N[(b * N[(1.0 - N[(a * N[(d / N[(c * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.56 \cdot 10^{-9}:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\
\mathbf{elif}\;c \leq 2.05 \cdot 10^{+38}:\\
\;\;\;\;\frac{\frac{c \cdot b}{d} - a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot \left(1 - a \cdot \frac{d}{c \cdot b}\right)}{c}\\
\end{array}
\end{array}
if c < -1.56e-9Initial program 60.1%
Taylor expanded in c around inf 80.3%
mul-1-neg80.3%
unsub-neg80.3%
associate-/l*83.4%
Simplified83.4%
if -1.56e-9 < c < 2.0500000000000002e38Initial program 74.9%
Taylor expanded in d around inf 84.9%
if 2.0500000000000002e38 < c Initial program 45.1%
div-sub45.1%
*-commutative45.1%
add-sqr-sqrt45.1%
times-frac49.5%
fma-neg49.5%
hypot-define49.5%
hypot-define79.7%
associate-/l*82.4%
add-sqr-sqrt82.4%
pow282.4%
hypot-define82.4%
Applied egg-rr82.4%
Taylor expanded in c around inf 71.7%
mul-1-neg71.7%
associate-*r/74.0%
sub-neg74.0%
associate-*r/71.7%
Simplified71.7%
Taylor expanded in b around inf 71.4%
mul-1-neg71.4%
unsub-neg71.4%
associate-/l*75.4%
Simplified75.4%
Final simplification82.5%
(FPCore (a b c d) :precision binary64 (if (or (<= c -6.2e-7) (not (<= c 9e-6))) (/ (- b (* a (/ d c))) c) (- (/ (/ (* c b) d) d) (/ a d))))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -6.2e-7) || !(c <= 9e-6)) {
tmp = (b - (a * (d / c))) / c;
} else {
tmp = (((c * b) / d) / d) - (a / 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 ((c <= (-6.2d-7)) .or. (.not. (c <= 9d-6))) then
tmp = (b - (a * (d / c))) / c
else
tmp = (((c * b) / d) / d) - (a / d)
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -6.2e-7) || !(c <= 9e-6)) {
tmp = (b - (a * (d / c))) / c;
} else {
tmp = (((c * b) / d) / d) - (a / d);
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -6.2e-7) or not (c <= 9e-6): tmp = (b - (a * (d / c))) / c else: tmp = (((c * b) / d) / d) - (a / d) return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -6.2e-7) || !(c <= 9e-6)) tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c); else tmp = Float64(Float64(Float64(Float64(c * b) / d) / d) - Float64(a / d)); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((c <= -6.2e-7) || ~((c <= 9e-6))) tmp = (b - (a * (d / c))) / c; else tmp = (((c * b) / d) / d) - (a / d); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -6.2e-7], N[Not[LessEqual[c, 9e-6]], $MachinePrecision]], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], N[(N[(N[(N[(c * b), $MachinePrecision] / d), $MachinePrecision] / d), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -6.2 \cdot 10^{-7} \lor \neg \left(c \leq 9 \cdot 10^{-6}\right):\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{c \cdot b}{d}}{d} - \frac{a}{d}\\
\end{array}
\end{array}
if c < -6.1999999999999999e-7 or 9.00000000000000023e-6 < c Initial program 54.5%
Taylor expanded in c around inf 73.7%
mul-1-neg73.7%
unsub-neg73.7%
associate-/l*76.1%
Simplified76.1%
if -6.1999999999999999e-7 < c < 9.00000000000000023e-6Initial program 75.9%
div-sub70.8%
*-commutative70.8%
add-sqr-sqrt70.8%
times-frac70.5%
fma-neg70.5%
hypot-define70.5%
hypot-define72.1%
associate-/l*78.5%
add-sqr-sqrt78.5%
pow278.5%
hypot-define78.5%
Applied egg-rr78.5%
Taylor expanded in d around inf 88.5%
associate-/l*88.1%
Simplified88.1%
div-sub88.1%
associate-*r/88.5%
Applied egg-rr88.5%
Final simplification82.2%
(FPCore (a b c d) :precision binary64 (if (or (<= c -2.75e-9) (not (<= c 3.2e+35))) (/ (- b (* a (/ d c))) c) (/ (- (/ (* c b) d) a) d)))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -2.75e-9) || !(c <= 3.2e+35)) {
tmp = (b - (a * (d / c))) / c;
} else {
tmp = (((c * b) / d) - a) / 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 ((c <= (-2.75d-9)) .or. (.not. (c <= 3.2d+35))) then
tmp = (b - (a * (d / c))) / c
else
tmp = (((c * b) / d) - a) / d
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -2.75e-9) || !(c <= 3.2e+35)) {
tmp = (b - (a * (d / c))) / c;
} else {
tmp = (((c * b) / d) - a) / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -2.75e-9) or not (c <= 3.2e+35): tmp = (b - (a * (d / c))) / c else: tmp = (((c * b) / d) - a) / d return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -2.75e-9) || !(c <= 3.2e+35)) tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c); else tmp = Float64(Float64(Float64(Float64(c * b) / d) - a) / d); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((c <= -2.75e-9) || ~((c <= 3.2e+35))) tmp = (b - (a * (d / c))) / c; else tmp = (((c * b) / d) - a) / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -2.75e-9], N[Not[LessEqual[c, 3.2e+35]], $MachinePrecision]], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], N[(N[(N[(N[(c * b), $MachinePrecision] / d), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -2.75 \cdot 10^{-9} \lor \neg \left(c \leq 3.2 \cdot 10^{+35}\right):\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{c \cdot b}{d} - a}{d}\\
\end{array}
\end{array}
if c < -2.7499999999999998e-9 or 3.19999999999999983e35 < c Initial program 53.2%
Taylor expanded in c around inf 76.3%
mul-1-neg76.3%
unsub-neg76.3%
associate-/l*79.0%
Simplified79.0%
if -2.7499999999999998e-9 < c < 3.19999999999999983e35Initial program 74.9%
Taylor expanded in d around inf 84.9%
Final simplification82.2%
(FPCore (a b c d) :precision binary64 (if (or (<= c -1.55e-11) (not (<= c 1.4e+34))) (/ (- b (* a (/ d c))) c) (/ (- (* b (/ c d)) a) d)))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -1.55e-11) || !(c <= 1.4e+34)) {
tmp = (b - (a * (d / c))) / c;
} else {
tmp = ((b * (c / d)) - a) / 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 ((c <= (-1.55d-11)) .or. (.not. (c <= 1.4d+34))) then
tmp = (b - (a * (d / c))) / c
else
tmp = ((b * (c / d)) - a) / d
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -1.55e-11) || !(c <= 1.4e+34)) {
tmp = (b - (a * (d / c))) / c;
} else {
tmp = ((b * (c / d)) - a) / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -1.55e-11) or not (c <= 1.4e+34): tmp = (b - (a * (d / c))) / c else: tmp = ((b * (c / d)) - a) / d return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -1.55e-11) || !(c <= 1.4e+34)) tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c); else tmp = Float64(Float64(Float64(b * Float64(c / d)) - a) / d); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((c <= -1.55e-11) || ~((c <= 1.4e+34))) tmp = (b - (a * (d / c))) / c; else tmp = ((b * (c / d)) - a) / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -1.55e-11], N[Not[LessEqual[c, 1.4e+34]], $MachinePrecision]], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], N[(N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.55 \cdot 10^{-11} \lor \neg \left(c \leq 1.4 \cdot 10^{+34}\right):\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\
\end{array}
\end{array}
if c < -1.55000000000000014e-11 or 1.40000000000000004e34 < c Initial program 53.2%
Taylor expanded in c around inf 76.3%
mul-1-neg76.3%
unsub-neg76.3%
associate-/l*79.0%
Simplified79.0%
if -1.55000000000000014e-11 < c < 1.40000000000000004e34Initial program 74.9%
div-sub70.2%
*-commutative70.2%
add-sqr-sqrt70.2%
times-frac70.6%
fma-neg70.6%
hypot-define70.7%
hypot-define72.1%
associate-/l*78.6%
add-sqr-sqrt78.6%
pow278.6%
hypot-define78.6%
Applied egg-rr78.6%
Taylor expanded in d around inf 84.9%
associate-/l*84.5%
Simplified84.5%
Final simplification82.0%
(FPCore (a b c d) :precision binary64 (if (or (<= d -1.05e+66) (not (<= d 1.25e+73))) (/ a (- d)) (/ (- b (* a (/ d c))) c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -1.05e+66) || !(d <= 1.25e+73)) {
tmp = a / -d;
} else {
tmp = (b - (a * (d / c))) / 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 <= (-1.05d+66)) .or. (.not. (d <= 1.25d+73))) then
tmp = a / -d
else
tmp = (b - (a * (d / c))) / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -1.05e+66) || !(d <= 1.25e+73)) {
tmp = a / -d;
} else {
tmp = (b - (a * (d / c))) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -1.05e+66) or not (d <= 1.25e+73): tmp = a / -d else: tmp = (b - (a * (d / c))) / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -1.05e+66) || !(d <= 1.25e+73)) tmp = Float64(a / Float64(-d)); else tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -1.05e+66) || ~((d <= 1.25e+73))) tmp = a / -d; else tmp = (b - (a * (d / c))) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -1.05e+66], N[Not[LessEqual[d, 1.25e+73]], $MachinePrecision]], N[(a / (-d)), $MachinePrecision], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.05 \cdot 10^{+66} \lor \neg \left(d \leq 1.25 \cdot 10^{+73}\right):\\
\;\;\;\;\frac{a}{-d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\
\end{array}
\end{array}
if d < -1.05000000000000003e66 or 1.24999999999999994e73 < d Initial program 50.3%
Taylor expanded in c around 0 79.3%
associate-*r/79.3%
neg-mul-179.3%
Simplified79.3%
if -1.05000000000000003e66 < d < 1.24999999999999994e73Initial program 74.5%
Taylor expanded in c around inf 74.6%
mul-1-neg74.6%
unsub-neg74.6%
associate-/l*74.7%
Simplified74.7%
Final simplification76.5%
(FPCore (a b c d) :precision binary64 (if (or (<= d -1.8e+66) (not (<= d 2.15e-92))) (/ a (- d)) (/ b c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -1.8e+66) || !(d <= 2.15e-92)) {
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 <= (-1.8d+66)) .or. (.not. (d <= 2.15d-92))) 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 <= -1.8e+66) || !(d <= 2.15e-92)) {
tmp = a / -d;
} else {
tmp = b / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -1.8e+66) or not (d <= 2.15e-92): tmp = a / -d else: tmp = b / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -1.8e+66) || !(d <= 2.15e-92)) tmp = Float64(a / Float64(-d)); else tmp = Float64(b / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -1.8e+66) || ~((d <= 2.15e-92))) tmp = a / -d; else tmp = b / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -1.8e+66], N[Not[LessEqual[d, 2.15e-92]], $MachinePrecision]], N[(a / (-d)), $MachinePrecision], N[(b / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.8 \cdot 10^{+66} \lor \neg \left(d \leq 2.15 \cdot 10^{-92}\right):\\
\;\;\;\;\frac{a}{-d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if d < -1.8e66 or 2.15000000000000007e-92 < d Initial program 56.8%
Taylor expanded in c around 0 68.5%
associate-*r/68.5%
neg-mul-168.5%
Simplified68.5%
if -1.8e66 < d < 2.15000000000000007e-92Initial program 73.4%
Taylor expanded in c around inf 71.7%
Final simplification70.1%
(FPCore (a b c d) :precision binary64 (if (or (<= d -1.85e+123) (not (<= d 6.5e+107))) (/ a d) (/ b c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -1.85e+123) || !(d <= 6.5e+107)) {
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 <= (-1.85d+123)) .or. (.not. (d <= 6.5d+107))) 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 <= -1.85e+123) || !(d <= 6.5e+107)) {
tmp = a / d;
} else {
tmp = b / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -1.85e+123) or not (d <= 6.5e+107): tmp = a / d else: tmp = b / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -1.85e+123) || !(d <= 6.5e+107)) tmp = 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 <= -1.85e+123) || ~((d <= 6.5e+107))) tmp = a / d; else tmp = b / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -1.85e+123], N[Not[LessEqual[d, 6.5e+107]], $MachinePrecision]], N[(a / d), $MachinePrecision], N[(b / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.85 \cdot 10^{+123} \lor \neg \left(d \leq 6.5 \cdot 10^{+107}\right):\\
\;\;\;\;\frac{a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if d < -1.84999999999999998e123 or 6.5000000000000006e107 < d Initial program 44.9%
Taylor expanded in c around 0 88.5%
associate-*r/88.5%
neg-mul-188.5%
Simplified88.5%
add-sqr-sqrt32.0%
sqrt-unprod47.2%
sqr-neg47.2%
sqrt-unprod22.9%
add-sqr-sqrt35.6%
*-un-lft-identity35.6%
Applied egg-rr35.6%
*-lft-identity35.6%
Simplified35.6%
if -1.84999999999999998e123 < d < 6.5000000000000006e107Initial program 73.3%
Taylor expanded in c around inf 57.5%
Final simplification51.1%
(FPCore (a b c d) :precision binary64 (/ a d))
double code(double a, double b, double c, double d) {
return a / 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 = a / d
end function
public static double code(double a, double b, double c, double d) {
return a / d;
}
def code(a, b, c, d): return a / d
function code(a, b, c, d) return Float64(a / d) end
function tmp = code(a, b, c, d) tmp = a / d; end
code[a_, b_, c_, d_] := N[(a / d), $MachinePrecision]
\begin{array}{l}
\\
\frac{a}{d}
\end{array}
Initial program 65.0%
Taylor expanded in c around 0 45.0%
associate-*r/45.0%
neg-mul-145.0%
Simplified45.0%
add-sqr-sqrt22.3%
sqrt-unprod27.7%
sqr-neg27.7%
sqrt-unprod7.6%
add-sqr-sqrt12.7%
*-un-lft-identity12.7%
Applied egg-rr12.7%
*-lft-identity12.7%
Simplified12.7%
(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 2024130
(FPCore (a b c d)
:name "Complex division, imag part"
:precision binary64
:alt
(! :herbie-platform default (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))))