
(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 11 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 c) (* a d)) (+ (* c c) (* d d)))))
(if (or (<= t_0 -5e+222) (not (<= t_0 2e+271)))
(fma
(/ c (hypot c d))
(/ b (hypot c d))
(* a (/ (/ d (- (hypot d c))) (hypot d c))))
(* (/ 1.0 (hypot c d)) (/ (fma b c (* d (- a))) (hypot c d))))))
double code(double a, double b, double c, double d) {
double t_0 = ((b * c) - (a * d)) / ((c * c) + (d * d));
double tmp;
if ((t_0 <= -5e+222) || !(t_0 <= 2e+271)) {
tmp = fma((c / hypot(c, d)), (b / hypot(c, d)), (a * ((d / -hypot(d, c)) / hypot(d, c))));
} else {
tmp = (1.0 / hypot(c, d)) * (fma(b, c, (d * -a)) / hypot(c, d));
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(Float64(b * c) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d))) tmp = 0.0 if ((t_0 <= -5e+222) || !(t_0 <= 2e+271)) tmp = fma(Float64(c / hypot(c, d)), Float64(b / hypot(c, d)), Float64(a * Float64(Float64(d / Float64(-hypot(d, c))) / hypot(d, c)))); else tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(fma(b, c, Float64(d * Float64(-a))) / hypot(c, d))); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -5e+222], N[Not[LessEqual[t$95$0, 2e+271]], $MachinePrecision]], N[(N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] + N[(a * N[(N[(d / (-N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision])), $MachinePrecision] / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(N[(b * c + N[(d * (-a)), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{+222} \lor \neg \left(t\_0 \leq 2 \cdot 10^{+271}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, a \cdot \frac{\frac{d}{-\mathsf{hypot}\left(d, c\right)}}{\mathsf{hypot}\left(d, c\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{\mathsf{fma}\left(b, c, d \cdot \left(-a\right)\right)}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\end{array}
if (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < -5.00000000000000023e222 or 1.99999999999999991e271 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 33.3%
div-sub24.3%
*-commutative24.3%
add-sqr-sqrt24.3%
times-frac36.3%
fma-neg36.3%
hypot-define36.3%
hypot-define65.2%
associate-/l*74.3%
add-sqr-sqrt74.3%
pow274.3%
hypot-define74.3%
Applied egg-rr74.3%
*-un-lft-identity74.3%
unpow274.3%
times-frac94.1%
hypot-undefine74.2%
+-commutative74.2%
hypot-define94.1%
hypot-undefine74.2%
+-commutative74.2%
hypot-define94.1%
Applied egg-rr94.1%
associate-*l/94.1%
*-lft-identity94.1%
Simplified94.1%
if -5.00000000000000023e222 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 1.99999999999999991e271Initial program 82.4%
*-un-lft-identity82.4%
add-sqr-sqrt82.4%
times-frac82.3%
hypot-define82.3%
fma-neg82.3%
distribute-rgt-neg-in82.3%
hypot-define99.5%
Applied egg-rr99.5%
Final simplification97.9%
(FPCore (a b c d) :precision binary64 (if (<= (/ (- (* b c) (* a d)) (+ (* c c) (* d d))) INFINITY) (* (/ 1.0 (hypot c d)) (/ (fma b c (* d (- a))) (hypot c d))) (* (/ c (hypot c d)) (/ b (hypot c d)))))
double code(double a, double b, double c, double d) {
double tmp;
if ((((b * c) - (a * d)) / ((c * c) + (d * d))) <= ((double) INFINITY)) {
tmp = (1.0 / hypot(c, d)) * (fma(b, c, (d * -a)) / hypot(c, d));
} else {
tmp = (c / hypot(c, d)) * (b / hypot(c, d));
}
return tmp;
}
function code(a, b, c, d) tmp = 0.0 if (Float64(Float64(Float64(b * c) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d))) <= Inf) tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(fma(b, c, Float64(d * Float64(-a))) / hypot(c, d))); else tmp = Float64(Float64(c / hypot(c, d)) * Float64(b / hypot(c, d))); end return tmp end
code[a_, b_, c_, d_] := If[LessEqual[N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / 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[(N[(b * c + N[(d * (-a)), $MachinePrecision]), $MachinePrecision] / 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]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \leq \infty:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{\mathsf{fma}\left(b, c, d \cdot \left(-a\right)\right)}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b}{\mathsf{hypot}\left(c, 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 80.2%
*-un-lft-identity80.2%
add-sqr-sqrt80.2%
times-frac80.2%
hypot-define80.2%
fma-neg80.2%
distribute-rgt-neg-in80.2%
hypot-define95.2%
Applied egg-rr95.2%
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%
*-commutative0.0%
add-sqr-sqrt0.0%
times-frac2.2%
fma-neg2.2%
hypot-define2.2%
hypot-define57.1%
associate-/l*67.2%
add-sqr-sqrt67.2%
pow267.2%
hypot-define67.2%
Applied egg-rr67.2%
Taylor expanded in b around inf 1.0%
associate-/l*3.7%
+-commutative3.7%
unpow23.7%
fma-undefine3.7%
Simplified3.7%
associate-*r/1.0%
clear-num1.0%
fma-undefine1.0%
add-sqr-sqrt1.0%
unpow21.0%
hypot-undefine1.0%
unpow21.0%
hypot-undefine1.0%
pow21.0%
Applied egg-rr1.0%
clear-num1.0%
*-commutative1.0%
unpow21.0%
hypot-undefine1.0%
hypot-undefine1.0%
add-sqr-sqrt1.0%
+-commutative1.0%
add-sqr-sqrt1.0%
hypot-undefine1.0%
hypot-undefine1.0%
frac-times67.2%
Applied egg-rr67.2%
Final simplification90.6%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (fma (/ c (hypot c d)) (/ b (hypot c d)) (/ (- a) d))))
(if (<= d -3.1e-21)
t_0
(if (<= d -8e-193)
(/ (- (* b c) (* a d)) (+ (* c c) (* d d)))
(if (<= d 1.2e-124)
(+ (/ b c) (* (/ (* a d) c) (/ -1.0 c)))
(if (<= d 3.6e+56)
(* (fma b c (* d (- a))) (/ 1.0 (pow (hypot c d) 2.0)))
t_0))))))
double code(double a, double b, double c, double d) {
double t_0 = fma((c / hypot(c, d)), (b / hypot(c, d)), (-a / d));
double tmp;
if (d <= -3.1e-21) {
tmp = t_0;
} else if (d <= -8e-193) {
tmp = ((b * c) - (a * d)) / ((c * c) + (d * d));
} else if (d <= 1.2e-124) {
tmp = (b / c) + (((a * d) / c) * (-1.0 / c));
} else if (d <= 3.6e+56) {
tmp = fma(b, c, (d * -a)) * (1.0 / pow(hypot(c, d), 2.0));
} else {
tmp = t_0;
}
return tmp;
}
function code(a, b, c, d) t_0 = fma(Float64(c / hypot(c, d)), Float64(b / hypot(c, d)), Float64(Float64(-a) / d)) tmp = 0.0 if (d <= -3.1e-21) tmp = t_0; elseif (d <= -8e-193) tmp = Float64(Float64(Float64(b * c) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d))); elseif (d <= 1.2e-124) tmp = Float64(Float64(b / c) + Float64(Float64(Float64(a * d) / c) * Float64(-1.0 / c))); elseif (d <= 3.6e+56) tmp = Float64(fma(b, c, Float64(d * Float64(-a))) * Float64(1.0 / (hypot(c, d) ^ 2.0))); else tmp = t_0; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = 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]}, If[LessEqual[d, -3.1e-21], t$95$0, If[LessEqual[d, -8e-193], N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.2e-124], N[(N[(b / c), $MachinePrecision] + N[(N[(N[(a * d), $MachinePrecision] / c), $MachinePrecision] * N[(-1.0 / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 3.6e+56], N[(N[(b * c + N[(d * (-a)), $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[Power[N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, \frac{-a}{d}\right)\\
\mathbf{if}\;d \leq -3.1 \cdot 10^{-21}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq -8 \cdot 10^{-193}:\\
\;\;\;\;\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;d \leq 1.2 \cdot 10^{-124}:\\
\;\;\;\;\frac{b}{c} + \frac{a \cdot d}{c} \cdot \frac{-1}{c}\\
\mathbf{elif}\;d \leq 3.6 \cdot 10^{+56}:\\
\;\;\;\;\mathsf{fma}\left(b, c, d \cdot \left(-a\right)\right) \cdot \frac{1}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d < -3.0999999999999998e-21 or 3.59999999999999998e56 < d Initial program 50.5%
div-sub50.5%
*-commutative50.5%
add-sqr-sqrt50.5%
times-frac53.4%
fma-neg53.4%
hypot-define53.4%
hypot-define67.0%
associate-/l*73.4%
add-sqr-sqrt73.4%
pow273.4%
hypot-define73.4%
Applied egg-rr73.4%
Taylor expanded in d around inf 89.7%
if -3.0999999999999998e-21 < d < -8.0000000000000004e-193Initial program 85.9%
if -8.0000000000000004e-193 < d < 1.19999999999999996e-124Initial program 72.7%
div-sub63.0%
*-commutative63.0%
add-sqr-sqrt63.0%
times-frac71.2%
fma-neg71.2%
hypot-define71.2%
hypot-define90.7%
associate-/l*86.5%
add-sqr-sqrt86.5%
pow286.5%
hypot-define86.5%
Applied egg-rr86.5%
Taylor expanded in c around inf 89.3%
+-commutative89.3%
mul-1-neg89.3%
unsub-neg89.3%
*-commutative89.3%
Simplified89.3%
*-un-lft-identity89.3%
unpow289.3%
times-frac92.6%
*-commutative92.6%
Applied egg-rr92.6%
if 1.19999999999999996e-124 < d < 3.59999999999999998e56Initial program 85.6%
div-inv85.7%
fma-neg85.7%
distribute-rgt-neg-in85.7%
add-sqr-sqrt85.7%
pow285.7%
hypot-define85.7%
Applied egg-rr85.7%
Final simplification89.2%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* b c) (* a d)) (+ (* c c) (* d d))))
(t_1 (* (/ c (hypot c d)) (/ b (hypot c d)))))
(if (<= c -6.8e+32)
t_1
(if (<= c 2.05e-233)
t_0
(if (<= c 6.2e-204) (/ (- a) d) (if (<= c 5.2e+141) t_0 t_1))))))
double code(double a, double b, double c, double d) {
double t_0 = ((b * c) - (a * d)) / ((c * c) + (d * d));
double t_1 = (c / hypot(c, d)) * (b / hypot(c, d));
double tmp;
if (c <= -6.8e+32) {
tmp = t_1;
} else if (c <= 2.05e-233) {
tmp = t_0;
} else if (c <= 6.2e-204) {
tmp = -a / d;
} else if (c <= 5.2e+141) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = ((b * c) - (a * d)) / ((c * c) + (d * d));
double t_1 = (c / Math.hypot(c, d)) * (b / Math.hypot(c, d));
double tmp;
if (c <= -6.8e+32) {
tmp = t_1;
} else if (c <= 2.05e-233) {
tmp = t_0;
} else if (c <= 6.2e-204) {
tmp = -a / d;
} else if (c <= 5.2e+141) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(a, b, c, d): t_0 = ((b * c) - (a * d)) / ((c * c) + (d * d)) t_1 = (c / math.hypot(c, d)) * (b / math.hypot(c, d)) tmp = 0 if c <= -6.8e+32: tmp = t_1 elif c <= 2.05e-233: tmp = t_0 elif c <= 6.2e-204: tmp = -a / d elif c <= 5.2e+141: tmp = t_0 else: tmp = t_1 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(Float64(b * c) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d))) t_1 = Float64(Float64(c / hypot(c, d)) * Float64(b / hypot(c, d))) tmp = 0.0 if (c <= -6.8e+32) tmp = t_1; elseif (c <= 2.05e-233) tmp = t_0; elseif (c <= 6.2e-204) tmp = Float64(Float64(-a) / d); elseif (c <= 5.2e+141) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((b * c) - (a * d)) / ((c * c) + (d * d)); t_1 = (c / hypot(c, d)) * (b / hypot(c, d)); tmp = 0.0; if (c <= -6.8e+32) tmp = t_1; elseif (c <= 2.05e-233) tmp = t_0; elseif (c <= 6.2e-204) tmp = -a / d; elseif (c <= 5.2e+141) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -6.8e+32], t$95$1, If[LessEqual[c, 2.05e-233], t$95$0, If[LessEqual[c, 6.2e-204], N[((-a) / d), $MachinePrecision], If[LessEqual[c, 5.2e+141], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\\
t_1 := \frac{c}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{if}\;c \leq -6.8 \cdot 10^{+32}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;c \leq 2.05 \cdot 10^{-233}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq 6.2 \cdot 10^{-204}:\\
\;\;\;\;\frac{-a}{d}\\
\mathbf{elif}\;c \leq 5.2 \cdot 10^{+141}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if c < -6.79999999999999957e32 or 5.1999999999999999e141 < c Initial program 41.4%
div-sub41.5%
*-commutative41.5%
add-sqr-sqrt41.5%
times-frac48.7%
fma-neg48.7%
hypot-define48.7%
hypot-define85.4%
associate-/l*88.0%
add-sqr-sqrt88.0%
pow288.0%
hypot-define88.0%
Applied egg-rr88.0%
Taylor expanded in b around inf 37.7%
associate-/l*45.1%
+-commutative45.1%
unpow245.1%
fma-undefine45.1%
Simplified45.1%
associate-*r/37.7%
clear-num37.6%
fma-undefine37.6%
add-sqr-sqrt37.6%
unpow237.6%
hypot-undefine37.6%
unpow237.6%
hypot-undefine37.6%
pow237.6%
Applied egg-rr37.6%
clear-num37.7%
*-commutative37.7%
unpow237.7%
hypot-undefine37.7%
hypot-undefine37.7%
add-sqr-sqrt37.7%
+-commutative37.7%
add-sqr-sqrt37.7%
hypot-undefine37.7%
hypot-undefine37.7%
frac-times85.8%
Applied egg-rr85.8%
if -6.79999999999999957e32 < c < 2.0500000000000002e-233 or 6.1999999999999998e-204 < c < 5.1999999999999999e141Initial program 83.4%
if 2.0500000000000002e-233 < c < 6.1999999999999998e-204Initial program 46.4%
Taylor expanded in c around 0 100.0%
associate-*r/100.0%
neg-mul-1100.0%
Simplified100.0%
Final simplification84.9%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* b c) (* a d)) (+ (* c c) (* d d))))
(t_1 (/ b (hypot c d)))
(t_2 (* (/ c (hypot c d)) t_1)))
(if (<= c -2e+31)
t_2
(if (<= c -5.5e-189)
t_0
(if (<= c 8e-188)
(fma (/ c d) t_1 (/ (- a) d))
(if (<= c 6.5e+141) t_0 t_2))))))
double code(double a, double b, double c, double d) {
double t_0 = ((b * c) - (a * d)) / ((c * c) + (d * d));
double t_1 = b / hypot(c, d);
double t_2 = (c / hypot(c, d)) * t_1;
double tmp;
if (c <= -2e+31) {
tmp = t_2;
} else if (c <= -5.5e-189) {
tmp = t_0;
} else if (c <= 8e-188) {
tmp = fma((c / d), t_1, (-a / d));
} else if (c <= 6.5e+141) {
tmp = t_0;
} else {
tmp = t_2;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(Float64(b * c) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d))) t_1 = Float64(b / hypot(c, d)) t_2 = Float64(Float64(c / hypot(c, d)) * t_1) tmp = 0.0 if (c <= -2e+31) tmp = t_2; elseif (c <= -5.5e-189) tmp = t_0; elseif (c <= 8e-188) tmp = fma(Float64(c / d), t_1, Float64(Float64(-a) / d)); elseif (c <= 6.5e+141) tmp = t_0; else tmp = t_2; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]}, If[LessEqual[c, -2e+31], t$95$2, If[LessEqual[c, -5.5e-189], t$95$0, If[LessEqual[c, 8e-188], N[(N[(c / d), $MachinePrecision] * t$95$1 + N[((-a) / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 6.5e+141], t$95$0, t$95$2]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\\
t_1 := \frac{b}{\mathsf{hypot}\left(c, d\right)}\\
t_2 := \frac{c}{\mathsf{hypot}\left(c, d\right)} \cdot t\_1\\
\mathbf{if}\;c \leq -2 \cdot 10^{+31}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;c \leq -5.5 \cdot 10^{-189}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq 8 \cdot 10^{-188}:\\
\;\;\;\;\mathsf{fma}\left(\frac{c}{d}, t\_1, \frac{-a}{d}\right)\\
\mathbf{elif}\;c \leq 6.5 \cdot 10^{+141}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if c < -1.9999999999999999e31 or 6.50000000000000053e141 < c Initial program 41.4%
div-sub41.5%
*-commutative41.5%
add-sqr-sqrt41.5%
times-frac48.7%
fma-neg48.7%
hypot-define48.7%
hypot-define85.4%
associate-/l*88.0%
add-sqr-sqrt88.0%
pow288.0%
hypot-define88.0%
Applied egg-rr88.0%
Taylor expanded in b around inf 37.7%
associate-/l*45.1%
+-commutative45.1%
unpow245.1%
fma-undefine45.1%
Simplified45.1%
associate-*r/37.7%
clear-num37.6%
fma-undefine37.6%
add-sqr-sqrt37.6%
unpow237.6%
hypot-undefine37.6%
unpow237.6%
hypot-undefine37.6%
pow237.6%
Applied egg-rr37.6%
clear-num37.7%
*-commutative37.7%
unpow237.7%
hypot-undefine37.7%
hypot-undefine37.7%
add-sqr-sqrt37.7%
+-commutative37.7%
add-sqr-sqrt37.7%
hypot-undefine37.7%
hypot-undefine37.7%
frac-times85.8%
Applied egg-rr85.8%
if -1.9999999999999999e31 < c < -5.4999999999999999e-189 or 7.9999999999999996e-188 < c < 6.50000000000000053e141Initial program 84.8%
if -5.4999999999999999e-189 < c < 7.9999999999999996e-188Initial program 75.2%
div-sub64.8%
*-commutative64.8%
add-sqr-sqrt64.8%
times-frac60.3%
fma-neg60.3%
hypot-define60.3%
hypot-define60.4%
associate-/l*65.7%
add-sqr-sqrt65.7%
pow265.7%
hypot-define65.7%
Applied egg-rr65.7%
Taylor expanded in d around inf 87.1%
Taylor expanded in c around 0 85.3%
Final simplification85.3%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* b c) (* a d)) (+ (* c c) (* d d))))
(t_1 (- (/ b c) (* (/ d c) (/ a c)))))
(if (<= c -3.1e+54)
t_1
(if (<= c 2.7e-234)
t_0
(if (<= c 3.6e-203) (/ (- a) d) (if (<= c 6.6e+139) t_0 t_1))))))
double code(double a, double b, double c, double d) {
double t_0 = ((b * c) - (a * d)) / ((c * c) + (d * d));
double t_1 = (b / c) - ((d / c) * (a / c));
double tmp;
if (c <= -3.1e+54) {
tmp = t_1;
} else if (c <= 2.7e-234) {
tmp = t_0;
} else if (c <= 3.6e-203) {
tmp = -a / d;
} else if (c <= 6.6e+139) {
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 = ((b * c) - (a * d)) / ((c * c) + (d * d))
t_1 = (b / c) - ((d / c) * (a / c))
if (c <= (-3.1d+54)) then
tmp = t_1
else if (c <= 2.7d-234) then
tmp = t_0
else if (c <= 3.6d-203) then
tmp = -a / d
else if (c <= 6.6d+139) 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 = ((b * c) - (a * d)) / ((c * c) + (d * d));
double t_1 = (b / c) - ((d / c) * (a / c));
double tmp;
if (c <= -3.1e+54) {
tmp = t_1;
} else if (c <= 2.7e-234) {
tmp = t_0;
} else if (c <= 3.6e-203) {
tmp = -a / d;
} else if (c <= 6.6e+139) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(a, b, c, d): t_0 = ((b * c) - (a * d)) / ((c * c) + (d * d)) t_1 = (b / c) - ((d / c) * (a / c)) tmp = 0 if c <= -3.1e+54: tmp = t_1 elif c <= 2.7e-234: tmp = t_0 elif c <= 3.6e-203: tmp = -a / d elif c <= 6.6e+139: tmp = t_0 else: tmp = t_1 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(Float64(b * c) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d))) t_1 = Float64(Float64(b / c) - Float64(Float64(d / c) * Float64(a / c))) tmp = 0.0 if (c <= -3.1e+54) tmp = t_1; elseif (c <= 2.7e-234) tmp = t_0; elseif (c <= 3.6e-203) tmp = Float64(Float64(-a) / d); elseif (c <= 6.6e+139) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((b * c) - (a * d)) / ((c * c) + (d * d)); t_1 = (b / c) - ((d / c) * (a / c)); tmp = 0.0; if (c <= -3.1e+54) tmp = t_1; elseif (c <= 2.7e-234) tmp = t_0; elseif (c <= 3.6e-203) tmp = -a / d; elseif (c <= 6.6e+139) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(b / c), $MachinePrecision] - N[(N[(d / c), $MachinePrecision] * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -3.1e+54], t$95$1, If[LessEqual[c, 2.7e-234], t$95$0, If[LessEqual[c, 3.6e-203], N[((-a) / d), $MachinePrecision], If[LessEqual[c, 6.6e+139], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\\
t_1 := \frac{b}{c} - \frac{d}{c} \cdot \frac{a}{c}\\
\mathbf{if}\;c \leq -3.1 \cdot 10^{+54}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;c \leq 2.7 \cdot 10^{-234}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq 3.6 \cdot 10^{-203}:\\
\;\;\;\;\frac{-a}{d}\\
\mathbf{elif}\;c \leq 6.6 \cdot 10^{+139}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if c < -3.0999999999999999e54 or 6.6000000000000003e139 < c Initial program 40.0%
div-sub40.0%
*-commutative40.0%
add-sqr-sqrt40.0%
times-frac47.7%
fma-neg47.7%
hypot-define47.7%
hypot-define85.4%
associate-/l*87.0%
add-sqr-sqrt87.0%
pow287.0%
hypot-define87.0%
Applied egg-rr87.0%
Taylor expanded in c around inf 78.9%
+-commutative78.9%
mul-1-neg78.9%
unsub-neg78.9%
*-commutative78.9%
Simplified78.9%
unpow278.9%
times-frac84.8%
Applied egg-rr84.8%
if -3.0999999999999999e54 < c < 2.7000000000000002e-234 or 3.59999999999999979e-203 < c < 6.6000000000000003e139Initial program 82.9%
if 2.7000000000000002e-234 < c < 3.59999999999999979e-203Initial program 46.4%
Taylor expanded in c around 0 100.0%
associate-*r/100.0%
neg-mul-1100.0%
Simplified100.0%
Final simplification84.1%
(FPCore (a b c d) :precision binary64 (if (or (<= c -1.12e-107) (not (<= c 3.5e-62))) (- (/ b c) (* (/ d c) (/ a c))) (/ (- a) d)))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -1.12e-107) || !(c <= 3.5e-62)) {
tmp = (b / c) - ((d / c) * (a / c));
} else {
tmp = -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.12d-107)) .or. (.not. (c <= 3.5d-62))) then
tmp = (b / c) - ((d / c) * (a / c))
else
tmp = -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.12e-107) || !(c <= 3.5e-62)) {
tmp = (b / c) - ((d / c) * (a / c));
} else {
tmp = -a / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -1.12e-107) or not (c <= 3.5e-62): tmp = (b / c) - ((d / c) * (a / c)) else: tmp = -a / d return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -1.12e-107) || !(c <= 3.5e-62)) tmp = Float64(Float64(b / c) - Float64(Float64(d / c) * Float64(a / c))); else tmp = Float64(Float64(-a) / d); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((c <= -1.12e-107) || ~((c <= 3.5e-62))) tmp = (b / c) - ((d / c) * (a / c)); else tmp = -a / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -1.12e-107], N[Not[LessEqual[c, 3.5e-62]], $MachinePrecision]], N[(N[(b / c), $MachinePrecision] - N[(N[(d / c), $MachinePrecision] * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-a) / d), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.12 \cdot 10^{-107} \lor \neg \left(c \leq 3.5 \cdot 10^{-62}\right):\\
\;\;\;\;\frac{b}{c} - \frac{d}{c} \cdot \frac{a}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{-a}{d}\\
\end{array}
\end{array}
if c < -1.12e-107 or 3.5000000000000001e-62 < c Initial program 59.1%
div-sub59.1%
*-commutative59.1%
add-sqr-sqrt59.1%
times-frac64.0%
fma-neg64.0%
hypot-define64.0%
hypot-define86.6%
associate-/l*86.9%
add-sqr-sqrt86.9%
pow286.9%
hypot-define86.9%
Applied egg-rr86.9%
Taylor expanded in c around inf 70.8%
+-commutative70.8%
mul-1-neg70.8%
unsub-neg70.8%
*-commutative70.8%
Simplified70.8%
unpow270.8%
times-frac71.9%
Applied egg-rr71.9%
if -1.12e-107 < c < 3.5000000000000001e-62Initial program 79.8%
Taylor expanded in c around 0 74.3%
associate-*r/74.3%
neg-mul-174.3%
Simplified74.3%
Final simplification72.8%
(FPCore (a b c d) :precision binary64 (if (<= c -1.1e-107) (+ (/ b c) (* (/ (* a d) c) (/ -1.0 c))) (if (<= c 2.15e-60) (/ (- a) d) (- (/ b c) (* (/ d c) (/ a c))))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -1.1e-107) {
tmp = (b / c) + (((a * d) / c) * (-1.0 / c));
} else if (c <= 2.15e-60) {
tmp = -a / d;
} else {
tmp = (b / c) - ((d / c) * (a / 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.1d-107)) then
tmp = (b / c) + (((a * d) / c) * ((-1.0d0) / c))
else if (c <= 2.15d-60) then
tmp = -a / d
else
tmp = (b / c) - ((d / c) * (a / c))
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -1.1e-107) {
tmp = (b / c) + (((a * d) / c) * (-1.0 / c));
} else if (c <= 2.15e-60) {
tmp = -a / d;
} else {
tmp = (b / c) - ((d / c) * (a / c));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -1.1e-107: tmp = (b / c) + (((a * d) / c) * (-1.0 / c)) elif c <= 2.15e-60: tmp = -a / d else: tmp = (b / c) - ((d / c) * (a / c)) return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -1.1e-107) tmp = Float64(Float64(b / c) + Float64(Float64(Float64(a * d) / c) * Float64(-1.0 / c))); elseif (c <= 2.15e-60) tmp = Float64(Float64(-a) / d); else tmp = Float64(Float64(b / c) - Float64(Float64(d / c) * Float64(a / c))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -1.1e-107) tmp = (b / c) + (((a * d) / c) * (-1.0 / c)); elseif (c <= 2.15e-60) tmp = -a / d; else tmp = (b / c) - ((d / c) * (a / c)); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -1.1e-107], N[(N[(b / c), $MachinePrecision] + N[(N[(N[(a * d), $MachinePrecision] / c), $MachinePrecision] * N[(-1.0 / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 2.15e-60], N[((-a) / d), $MachinePrecision], N[(N[(b / c), $MachinePrecision] - N[(N[(d / c), $MachinePrecision] * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.1 \cdot 10^{-107}:\\
\;\;\;\;\frac{b}{c} + \frac{a \cdot d}{c} \cdot \frac{-1}{c}\\
\mathbf{elif}\;c \leq 2.15 \cdot 10^{-60}:\\
\;\;\;\;\frac{-a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c} - \frac{d}{c} \cdot \frac{a}{c}\\
\end{array}
\end{array}
if c < -1.10000000000000006e-107Initial program 62.1%
div-sub62.1%
*-commutative62.1%
add-sqr-sqrt62.1%
times-frac69.2%
fma-neg69.2%
hypot-define69.2%
hypot-define88.2%
associate-/l*86.6%
add-sqr-sqrt86.6%
pow286.6%
hypot-define86.6%
Applied egg-rr86.6%
Taylor expanded in c around inf 71.7%
+-commutative71.7%
mul-1-neg71.7%
unsub-neg71.7%
*-commutative71.7%
Simplified71.7%
*-un-lft-identity71.7%
unpow271.7%
times-frac72.8%
*-commutative72.8%
Applied egg-rr72.8%
if -1.10000000000000006e-107 < c < 2.15e-60Initial program 79.8%
Taylor expanded in c around 0 74.3%
associate-*r/74.3%
neg-mul-174.3%
Simplified74.3%
if 2.15e-60 < c Initial program 55.3%
div-sub55.3%
*-commutative55.3%
add-sqr-sqrt55.3%
times-frac57.5%
fma-neg57.5%
hypot-define57.5%
hypot-define84.5%
associate-/l*87.3%
add-sqr-sqrt87.3%
pow287.3%
hypot-define87.3%
Applied egg-rr87.3%
Taylor expanded in c around inf 69.6%
+-commutative69.6%
mul-1-neg69.6%
unsub-neg69.6%
*-commutative69.6%
Simplified69.6%
unpow269.6%
times-frac75.4%
Applied egg-rr75.4%
Final simplification74.1%
(FPCore (a b c d) :precision binary64 (if (or (<= c -2.6e-82) (not (<= c 1.12e-7))) (/ b c) (/ (- a) d)))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -2.6e-82) || !(c <= 1.12e-7)) {
tmp = b / c;
} else {
tmp = -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.6d-82)) .or. (.not. (c <= 1.12d-7))) then
tmp = b / c
else
tmp = -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.6e-82) || !(c <= 1.12e-7)) {
tmp = b / c;
} else {
tmp = -a / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -2.6e-82) or not (c <= 1.12e-7): tmp = b / c else: tmp = -a / d return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -2.6e-82) || !(c <= 1.12e-7)) tmp = Float64(b / c); else tmp = Float64(Float64(-a) / d); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((c <= -2.6e-82) || ~((c <= 1.12e-7))) tmp = b / c; else tmp = -a / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -2.6e-82], N[Not[LessEqual[c, 1.12e-7]], $MachinePrecision]], N[(b / c), $MachinePrecision], N[((-a) / d), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -2.6 \cdot 10^{-82} \lor \neg \left(c \leq 1.12 \cdot 10^{-7}\right):\\
\;\;\;\;\frac{b}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{-a}{d}\\
\end{array}
\end{array}
if c < -2.6e-82 or 1.12e-7 < c Initial program 55.2%
Taylor expanded in c around inf 65.6%
if -2.6e-82 < c < 1.12e-7Initial program 81.7%
Taylor expanded in c around 0 69.6%
associate-*r/69.6%
neg-mul-169.6%
Simplified69.6%
Final simplification67.3%
(FPCore (a b c d) :precision binary64 (if (or (<= d -1.22e+154) (not (<= d 6.2e+167))) (/ a d) (/ b c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -1.22e+154) || !(d <= 6.2e+167)) {
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.22d+154)) .or. (.not. (d <= 6.2d+167))) 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.22e+154) || !(d <= 6.2e+167)) {
tmp = a / d;
} else {
tmp = b / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -1.22e+154) or not (d <= 6.2e+167): tmp = a / d else: tmp = b / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -1.22e+154) || !(d <= 6.2e+167)) 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.22e+154) || ~((d <= 6.2e+167))) tmp = a / d; else tmp = b / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -1.22e+154], N[Not[LessEqual[d, 6.2e+167]], $MachinePrecision]], N[(a / d), $MachinePrecision], N[(b / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.22 \cdot 10^{+154} \lor \neg \left(d \leq 6.2 \cdot 10^{+167}\right):\\
\;\;\;\;\frac{a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if d < -1.22e154 or 6.1999999999999999e167 < d Initial program 37.4%
sub-neg37.4%
flip-+22.9%
pow222.9%
distribute-rgt-neg-in22.9%
distribute-rgt-neg-in22.9%
distribute-rgt-neg-in22.9%
Applied egg-rr22.9%
Applied egg-rr43.5%
associate-*l/43.5%
*-lft-identity43.5%
Simplified43.5%
Taylor expanded in c around 0 58.5%
associate-/l*65.0%
Simplified65.0%
Taylor expanded in c around 0 36.4%
if -1.22e154 < d < 6.1999999999999999e167Initial program 76.5%
Taylor expanded in c around inf 52.4%
Final simplification48.6%
(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 67.0%
sub-neg67.0%
flip-+48.3%
pow248.3%
distribute-rgt-neg-in48.3%
distribute-rgt-neg-in48.3%
distribute-rgt-neg-in48.3%
Applied egg-rr48.3%
Applied egg-rr46.5%
associate-*l/46.6%
*-lft-identity46.6%
Simplified46.6%
Taylor expanded in c around 0 34.7%
associate-/l*36.3%
Simplified36.3%
Taylor expanded in c around 0 11.5%
Final simplification11.5%
(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 2024046
(FPCore (a b c d)
:name "Complex division, imag part"
:precision binary64
:alt
(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))))