
(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 12 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 (/ 1.0 (hypot c d))) (t_1 (- (* b c) (* a d))))
(if (<= (/ t_1 (+ (* c c) (* d d))) INFINITY)
(* t_0 (/ t_1 (hypot c d)))
(fma t_0 (/ b (/ (hypot c d) c)) (/ (- a) d)))))
double code(double a, double b, double c, double d) {
double t_0 = 1.0 / hypot(c, d);
double t_1 = (b * c) - (a * d);
double tmp;
if ((t_1 / ((c * c) + (d * d))) <= ((double) INFINITY)) {
tmp = t_0 * (t_1 / hypot(c, d));
} else {
tmp = fma(t_0, (b / (hypot(c, d) / c)), (-a / d));
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(1.0 / hypot(c, d)) t_1 = Float64(Float64(b * c) - Float64(a * d)) tmp = 0.0 if (Float64(t_1 / Float64(Float64(c * c) + Float64(d * d))) <= Inf) tmp = Float64(t_0 * Float64(t_1 / hypot(c, d))); else tmp = fma(t_0, Float64(b / Float64(hypot(c, d) / c)), Float64(Float64(-a) / d)); 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[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$1 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(t$95$0 * N[(t$95$1 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(b / N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] + N[((-a) / d), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\mathsf{hypot}\left(c, d\right)}\\
t_1 := b \cdot c - a \cdot d\\
\mathbf{if}\;\frac{t_1}{c \cdot c + d \cdot d} \leq \infty:\\
\;\;\;\;t_0 \cdot \frac{t_1}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t_0, \frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{c}}, \frac{-a}{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 77.1%
*-un-lft-identity77.1%
add-sqr-sqrt77.1%
times-frac77.2%
hypot-def77.2%
hypot-def94.7%
Applied egg-rr94.7%
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%
*-un-lft-identity0.0%
add-sqr-sqrt0.0%
times-frac0.0%
fma-def0.0%
hypot-def0.0%
hypot-def1.3%
add-sqr-sqrt1.3%
pow21.3%
hypot-def1.3%
Applied egg-rr1.3%
associate-/l*49.6%
distribute-neg-frac49.6%
distribute-rgt-neg-out49.6%
Simplified49.6%
Taylor expanded in d around inf 74.2%
associate-*r/74.2%
neg-mul-174.2%
Simplified74.2%
Final simplification90.7%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (- (* b c) (* a d))))
(if (<= (/ t_0 (+ (* c c) (* d d))) INFINITY)
(* (/ 1.0 (hypot c d)) (/ t_0 (hypot c d)))
(- (* b (/ 1.0 c)) (* (/ d c) (/ a c))))))
double code(double a, double b, double c, double d) {
double t_0 = (b * c) - (a * d);
double tmp;
if ((t_0 / ((c * c) + (d * d))) <= ((double) INFINITY)) {
tmp = (1.0 / hypot(c, d)) * (t_0 / hypot(c, d));
} else {
tmp = (b * (1.0 / c)) - ((d / c) * (a / c));
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = (b * c) - (a * d);
double tmp;
if ((t_0 / ((c * c) + (d * d))) <= Double.POSITIVE_INFINITY) {
tmp = (1.0 / Math.hypot(c, d)) * (t_0 / Math.hypot(c, d));
} else {
tmp = (b * (1.0 / c)) - ((d / c) * (a / c));
}
return tmp;
}
def code(a, b, c, d): t_0 = (b * c) - (a * d) tmp = 0 if (t_0 / ((c * c) + (d * d))) <= math.inf: tmp = (1.0 / math.hypot(c, d)) * (t_0 / math.hypot(c, d)) else: tmp = (b * (1.0 / c)) - ((d / c) * (a / c)) return tmp
function code(a, b, c, d) t_0 = Float64(Float64(b * c) - Float64(a * d)) 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(b * Float64(1.0 / c)) - Float64(Float64(d / c) * Float64(a / c))); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (b * c) - (a * d); tmp = 0.0; if ((t_0 / ((c * c) + (d * d))) <= Inf) tmp = (1.0 / hypot(c, d)) * (t_0 / hypot(c, d)); else tmp = (b * (1.0 / c)) - ((d / c) * (a / c)); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(b * c), $MachinePrecision] - N[(a * d), $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[(N[(b * N[(1.0 / c), $MachinePrecision]), $MachinePrecision] - N[(N[(d / c), $MachinePrecision] * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := b \cdot c - a \cdot d\\
\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}:\\
\;\;\;\;b \cdot \frac{1}{c} - \frac{d}{c} \cdot \frac{a}{c}\\
\end{array}
\end{array}
if (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < +inf.0Initial program 77.1%
*-un-lft-identity77.1%
add-sqr-sqrt77.1%
times-frac77.2%
hypot-def77.2%
hypot-def94.7%
Applied egg-rr94.7%
if +inf.0 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 0.0%
Taylor expanded in c around inf 41.6%
+-commutative41.6%
mul-1-neg41.6%
unsub-neg41.6%
*-commutative41.6%
associate-/l*44.3%
Simplified44.3%
div-inv44.1%
fma-neg44.1%
div-inv44.1%
clear-num44.1%
Applied egg-rr44.1%
fma-udef44.1%
unsub-neg44.1%
associate-*r/41.3%
*-commutative41.3%
Simplified41.3%
*-commutative41.3%
unpow241.3%
times-frac49.7%
Applied egg-rr49.7%
Final simplification86.0%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (- (* b c) (* a d)))
(t_1 (/ 1.0 (hypot c d)))
(t_2 (* a (/ d c))))
(if (<= c -2.6e+41)
(* t_1 (- t_2 b))
(if (<= c -1.25e-135)
(/ t_0 (+ (* c c) (* d d)))
(if (<= c 7.4e-247)
(- (/ b (/ (pow d 2.0) c)) (/ a d))
(if (<= c 3.1e+86)
(* t_0 (/ 1.0 (pow (hypot c d) 2.0)))
(* t_1 (- b t_2))))))))
double code(double a, double b, double c, double d) {
double t_0 = (b * c) - (a * d);
double t_1 = 1.0 / hypot(c, d);
double t_2 = a * (d / c);
double tmp;
if (c <= -2.6e+41) {
tmp = t_1 * (t_2 - b);
} else if (c <= -1.25e-135) {
tmp = t_0 / ((c * c) + (d * d));
} else if (c <= 7.4e-247) {
tmp = (b / (pow(d, 2.0) / c)) - (a / d);
} else if (c <= 3.1e+86) {
tmp = t_0 * (1.0 / pow(hypot(c, d), 2.0));
} else {
tmp = t_1 * (b - t_2);
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = (b * c) - (a * d);
double t_1 = 1.0 / Math.hypot(c, d);
double t_2 = a * (d / c);
double tmp;
if (c <= -2.6e+41) {
tmp = t_1 * (t_2 - b);
} else if (c <= -1.25e-135) {
tmp = t_0 / ((c * c) + (d * d));
} else if (c <= 7.4e-247) {
tmp = (b / (Math.pow(d, 2.0) / c)) - (a / d);
} else if (c <= 3.1e+86) {
tmp = t_0 * (1.0 / Math.pow(Math.hypot(c, d), 2.0));
} else {
tmp = t_1 * (b - t_2);
}
return tmp;
}
def code(a, b, c, d): t_0 = (b * c) - (a * d) t_1 = 1.0 / math.hypot(c, d) t_2 = a * (d / c) tmp = 0 if c <= -2.6e+41: tmp = t_1 * (t_2 - b) elif c <= -1.25e-135: tmp = t_0 / ((c * c) + (d * d)) elif c <= 7.4e-247: tmp = (b / (math.pow(d, 2.0) / c)) - (a / d) elif c <= 3.1e+86: tmp = t_0 * (1.0 / math.pow(math.hypot(c, d), 2.0)) else: tmp = t_1 * (b - t_2) return tmp
function code(a, b, c, d) t_0 = Float64(Float64(b * c) - Float64(a * d)) t_1 = Float64(1.0 / hypot(c, d)) t_2 = Float64(a * Float64(d / c)) tmp = 0.0 if (c <= -2.6e+41) tmp = Float64(t_1 * Float64(t_2 - b)); elseif (c <= -1.25e-135) tmp = Float64(t_0 / Float64(Float64(c * c) + Float64(d * d))); elseif (c <= 7.4e-247) tmp = Float64(Float64(b / Float64((d ^ 2.0) / c)) - Float64(a / d)); elseif (c <= 3.1e+86) tmp = Float64(t_0 * Float64(1.0 / (hypot(c, d) ^ 2.0))); else tmp = Float64(t_1 * Float64(b - t_2)); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (b * c) - (a * d); t_1 = 1.0 / hypot(c, d); t_2 = a * (d / c); tmp = 0.0; if (c <= -2.6e+41) tmp = t_1 * (t_2 - b); elseif (c <= -1.25e-135) tmp = t_0 / ((c * c) + (d * d)); elseif (c <= 7.4e-247) tmp = (b / ((d ^ 2.0) / c)) - (a / d); elseif (c <= 3.1e+86) tmp = t_0 * (1.0 / (hypot(c, d) ^ 2.0)); else tmp = t_1 * (b - t_2); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -2.6e+41], N[(t$95$1 * N[(t$95$2 - b), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -1.25e-135], N[(t$95$0 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 7.4e-247], N[(N[(b / N[(N[Power[d, 2.0], $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 3.1e+86], N[(t$95$0 * N[(1.0 / N[Power[N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 * N[(b - t$95$2), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := b \cdot c - a \cdot d\\
t_1 := \frac{1}{\mathsf{hypot}\left(c, d\right)}\\
t_2 := a \cdot \frac{d}{c}\\
\mathbf{if}\;c \leq -2.6 \cdot 10^{+41}:\\
\;\;\;\;t_1 \cdot \left(t_2 - b\right)\\
\mathbf{elif}\;c \leq -1.25 \cdot 10^{-135}:\\
\;\;\;\;\frac{t_0}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;c \leq 7.4 \cdot 10^{-247}:\\
\;\;\;\;\frac{b}{\frac{{d}^{2}}{c}} - \frac{a}{d}\\
\mathbf{elif}\;c \leq 3.1 \cdot 10^{+86}:\\
\;\;\;\;t_0 \cdot \frac{1}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\\
\mathbf{else}:\\
\;\;\;\;t_1 \cdot \left(b - t_2\right)\\
\end{array}
\end{array}
if c < -2.6000000000000001e41Initial program 42.7%
*-un-lft-identity42.7%
add-sqr-sqrt42.7%
times-frac42.7%
hypot-def42.7%
hypot-def67.4%
Applied egg-rr67.4%
Taylor expanded in c around -inf 80.7%
+-commutative80.7%
neg-mul-180.7%
unsub-neg80.7%
associate-*r/82.5%
Simplified82.5%
if -2.6000000000000001e41 < c < -1.25000000000000005e-135Initial program 90.4%
if -1.25000000000000005e-135 < c < 7.40000000000000021e-247Initial program 67.3%
Taylor expanded in c around 0 89.5%
+-commutative89.5%
mul-1-neg89.5%
unsub-neg89.5%
associate-/l*87.4%
Simplified87.4%
if 7.40000000000000021e-247 < c < 3.1000000000000002e86Initial program 82.1%
clear-num81.3%
associate-/r/82.2%
add-sqr-sqrt82.1%
pow282.1%
hypot-def82.1%
Applied egg-rr82.1%
if 3.1000000000000002e86 < c Initial program 35.4%
*-un-lft-identity35.4%
add-sqr-sqrt35.4%
times-frac35.5%
hypot-def35.5%
hypot-def61.1%
Applied egg-rr61.1%
Taylor expanded in c around inf 78.2%
mul-1-neg78.2%
unsub-neg78.2%
associate-*r/84.1%
Simplified84.1%
Final simplification84.5%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (- (* b c) (* a d)))
(t_1 (/ 1.0 (hypot c d)))
(t_2 (* a (/ d c))))
(if (<= c -1.6e+41)
(* t_1 (- t_2 b))
(if (<= c -7.8e-138)
(/ t_0 (+ (* c c) (* d d)))
(if (<= c 1.8e-252)
(- (/ b (/ (pow d 2.0) c)) (/ a d))
(if (<= c 6.5e+86) (/ t_0 (fma c c (* d d))) (* t_1 (- b t_2))))))))
double code(double a, double b, double c, double d) {
double t_0 = (b * c) - (a * d);
double t_1 = 1.0 / hypot(c, d);
double t_2 = a * (d / c);
double tmp;
if (c <= -1.6e+41) {
tmp = t_1 * (t_2 - b);
} else if (c <= -7.8e-138) {
tmp = t_0 / ((c * c) + (d * d));
} else if (c <= 1.8e-252) {
tmp = (b / (pow(d, 2.0) / c)) - (a / d);
} else if (c <= 6.5e+86) {
tmp = t_0 / fma(c, c, (d * d));
} else {
tmp = t_1 * (b - t_2);
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(b * c) - Float64(a * d)) t_1 = Float64(1.0 / hypot(c, d)) t_2 = Float64(a * Float64(d / c)) tmp = 0.0 if (c <= -1.6e+41) tmp = Float64(t_1 * Float64(t_2 - b)); elseif (c <= -7.8e-138) tmp = Float64(t_0 / Float64(Float64(c * c) + Float64(d * d))); elseif (c <= 1.8e-252) tmp = Float64(Float64(b / Float64((d ^ 2.0) / c)) - Float64(a / d)); elseif (c <= 6.5e+86) tmp = Float64(t_0 / fma(c, c, Float64(d * d))); else tmp = Float64(t_1 * Float64(b - t_2)); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -1.6e+41], N[(t$95$1 * N[(t$95$2 - b), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -7.8e-138], N[(t$95$0 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.8e-252], N[(N[(b / N[(N[Power[d, 2.0], $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 6.5e+86], N[(t$95$0 / N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 * N[(b - t$95$2), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := b \cdot c - a \cdot d\\
t_1 := \frac{1}{\mathsf{hypot}\left(c, d\right)}\\
t_2 := a \cdot \frac{d}{c}\\
\mathbf{if}\;c \leq -1.6 \cdot 10^{+41}:\\
\;\;\;\;t_1 \cdot \left(t_2 - b\right)\\
\mathbf{elif}\;c \leq -7.8 \cdot 10^{-138}:\\
\;\;\;\;\frac{t_0}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;c \leq 1.8 \cdot 10^{-252}:\\
\;\;\;\;\frac{b}{\frac{{d}^{2}}{c}} - \frac{a}{d}\\
\mathbf{elif}\;c \leq 6.5 \cdot 10^{+86}:\\
\;\;\;\;\frac{t_0}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\
\mathbf{else}:\\
\;\;\;\;t_1 \cdot \left(b - t_2\right)\\
\end{array}
\end{array}
if c < -1.60000000000000005e41Initial program 42.7%
*-un-lft-identity42.7%
add-sqr-sqrt42.7%
times-frac42.7%
hypot-def42.7%
hypot-def67.4%
Applied egg-rr67.4%
Taylor expanded in c around -inf 80.7%
+-commutative80.7%
neg-mul-180.7%
unsub-neg80.7%
associate-*r/82.5%
Simplified82.5%
if -1.60000000000000005e41 < c < -7.7999999999999999e-138Initial program 90.4%
if -7.7999999999999999e-138 < c < 1.80000000000000011e-252Initial program 67.3%
Taylor expanded in c around 0 89.5%
+-commutative89.5%
mul-1-neg89.5%
unsub-neg89.5%
associate-/l*87.4%
Simplified87.4%
if 1.80000000000000011e-252 < c < 6.49999999999999996e86Initial program 82.1%
fma-def82.1%
Simplified82.1%
if 6.49999999999999996e86 < c Initial program 35.4%
*-un-lft-identity35.4%
add-sqr-sqrt35.4%
times-frac35.5%
hypot-def35.5%
hypot-def61.1%
Applied egg-rr61.1%
Taylor expanded in c around inf 78.2%
mul-1-neg78.2%
unsub-neg78.2%
associate-*r/84.1%
Simplified84.1%
Final simplification84.5%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* b c) (* a d)) (+ (* c c) (* d d)))))
(if (<= c -7.5e+125)
(- (* b (/ 1.0 c)) (* (/ d c) (/ a c)))
(if (<= c -5e-139)
t_0
(if (<= c 7.5e-247)
(- (/ b (/ (pow d 2.0) c)) (/ a d))
(if (<= c 5.4e+86)
t_0
(* (/ 1.0 (hypot c d)) (- b (* a (/ d c))))))))))
double code(double a, double b, double c, double d) {
double t_0 = ((b * c) - (a * d)) / ((c * c) + (d * d));
double tmp;
if (c <= -7.5e+125) {
tmp = (b * (1.0 / c)) - ((d / c) * (a / c));
} else if (c <= -5e-139) {
tmp = t_0;
} else if (c <= 7.5e-247) {
tmp = (b / (pow(d, 2.0) / c)) - (a / d);
} else if (c <= 5.4e+86) {
tmp = t_0;
} else {
tmp = (1.0 / hypot(c, d)) * (b - (a * (d / c)));
}
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 tmp;
if (c <= -7.5e+125) {
tmp = (b * (1.0 / c)) - ((d / c) * (a / c));
} else if (c <= -5e-139) {
tmp = t_0;
} else if (c <= 7.5e-247) {
tmp = (b / (Math.pow(d, 2.0) / c)) - (a / d);
} else if (c <= 5.4e+86) {
tmp = t_0;
} else {
tmp = (1.0 / Math.hypot(c, d)) * (b - (a * (d / c)));
}
return tmp;
}
def code(a, b, c, d): t_0 = ((b * c) - (a * d)) / ((c * c) + (d * d)) tmp = 0 if c <= -7.5e+125: tmp = (b * (1.0 / c)) - ((d / c) * (a / c)) elif c <= -5e-139: tmp = t_0 elif c <= 7.5e-247: tmp = (b / (math.pow(d, 2.0) / c)) - (a / d) elif c <= 5.4e+86: tmp = t_0 else: tmp = (1.0 / math.hypot(c, d)) * (b - (a * (d / c))) 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 (c <= -7.5e+125) tmp = Float64(Float64(b * Float64(1.0 / c)) - Float64(Float64(d / c) * Float64(a / c))); elseif (c <= -5e-139) tmp = t_0; elseif (c <= 7.5e-247) tmp = Float64(Float64(b / Float64((d ^ 2.0) / c)) - Float64(a / d)); elseif (c <= 5.4e+86) tmp = t_0; else tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(b - Float64(a * Float64(d / c)))); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((b * c) - (a * d)) / ((c * c) + (d * d)); tmp = 0.0; if (c <= -7.5e+125) tmp = (b * (1.0 / c)) - ((d / c) * (a / c)); elseif (c <= -5e-139) tmp = t_0; elseif (c <= 7.5e-247) tmp = (b / ((d ^ 2.0) / c)) - (a / d); elseif (c <= 5.4e+86) tmp = t_0; else tmp = (1.0 / hypot(c, d)) * (b - (a * (d / c))); 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]}, If[LessEqual[c, -7.5e+125], N[(N[(b * N[(1.0 / c), $MachinePrecision]), $MachinePrecision] - N[(N[(d / c), $MachinePrecision] * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -5e-139], t$95$0, If[LessEqual[c, 7.5e-247], N[(N[(b / N[(N[Power[d, 2.0], $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 5.4e+86], t$95$0, N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b - N[(a * N[(d / c), $MachinePrecision]), $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}\;c \leq -7.5 \cdot 10^{+125}:\\
\;\;\;\;b \cdot \frac{1}{c} - \frac{d}{c} \cdot \frac{a}{c}\\
\mathbf{elif}\;c \leq -5 \cdot 10^{-139}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 7.5 \cdot 10^{-247}:\\
\;\;\;\;\frac{b}{\frac{{d}^{2}}{c}} - \frac{a}{d}\\
\mathbf{elif}\;c \leq 5.4 \cdot 10^{+86}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(b - a \cdot \frac{d}{c}\right)\\
\end{array}
\end{array}
if c < -7.5000000000000006e125Initial program 31.2%
Taylor expanded in c around inf 73.7%
+-commutative73.7%
mul-1-neg73.7%
unsub-neg73.7%
*-commutative73.7%
associate-/l*71.9%
Simplified71.9%
div-inv71.7%
fma-neg71.7%
div-inv71.7%
clear-num71.7%
Applied egg-rr71.7%
fma-udef71.7%
unsub-neg71.7%
associate-*r/73.5%
*-commutative73.5%
Simplified73.5%
*-commutative73.5%
unpow273.5%
times-frac84.9%
Applied egg-rr84.9%
if -7.5000000000000006e125 < c < -5.00000000000000034e-139 or 7.5e-247 < c < 5.40000000000000036e86Initial program 83.4%
if -5.00000000000000034e-139 < c < 7.5e-247Initial program 67.3%
Taylor expanded in c around 0 89.5%
+-commutative89.5%
mul-1-neg89.5%
unsub-neg89.5%
associate-/l*87.4%
Simplified87.4%
if 5.40000000000000036e86 < c Initial program 35.4%
*-un-lft-identity35.4%
add-sqr-sqrt35.4%
times-frac35.5%
hypot-def35.5%
hypot-def61.1%
Applied egg-rr61.1%
Taylor expanded in c around inf 78.2%
mul-1-neg78.2%
unsub-neg78.2%
associate-*r/84.1%
Simplified84.1%
Final simplification84.5%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* b c) (* a d)) (+ (* c c) (* d d))))
(t_1 (/ 1.0 (hypot c d)))
(t_2 (* a (/ d c))))
(if (<= c -3e+41)
(* t_1 (- t_2 b))
(if (<= c -1.2e-135)
t_0
(if (<= c 7.5e-247)
(- (/ b (/ (pow d 2.0) c)) (/ a d))
(if (<= c 7e+86) t_0 (* t_1 (- b 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 = 1.0 / hypot(c, d);
double t_2 = a * (d / c);
double tmp;
if (c <= -3e+41) {
tmp = t_1 * (t_2 - b);
} else if (c <= -1.2e-135) {
tmp = t_0;
} else if (c <= 7.5e-247) {
tmp = (b / (pow(d, 2.0) / c)) - (a / d);
} else if (c <= 7e+86) {
tmp = t_0;
} else {
tmp = t_1 * (b - t_2);
}
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 = 1.0 / Math.hypot(c, d);
double t_2 = a * (d / c);
double tmp;
if (c <= -3e+41) {
tmp = t_1 * (t_2 - b);
} else if (c <= -1.2e-135) {
tmp = t_0;
} else if (c <= 7.5e-247) {
tmp = (b / (Math.pow(d, 2.0) / c)) - (a / d);
} else if (c <= 7e+86) {
tmp = t_0;
} else {
tmp = t_1 * (b - t_2);
}
return tmp;
}
def code(a, b, c, d): t_0 = ((b * c) - (a * d)) / ((c * c) + (d * d)) t_1 = 1.0 / math.hypot(c, d) t_2 = a * (d / c) tmp = 0 if c <= -3e+41: tmp = t_1 * (t_2 - b) elif c <= -1.2e-135: tmp = t_0 elif c <= 7.5e-247: tmp = (b / (math.pow(d, 2.0) / c)) - (a / d) elif c <= 7e+86: tmp = t_0 else: tmp = t_1 * (b - 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(1.0 / hypot(c, d)) t_2 = Float64(a * Float64(d / c)) tmp = 0.0 if (c <= -3e+41) tmp = Float64(t_1 * Float64(t_2 - b)); elseif (c <= -1.2e-135) tmp = t_0; elseif (c <= 7.5e-247) tmp = Float64(Float64(b / Float64((d ^ 2.0) / c)) - Float64(a / d)); elseif (c <= 7e+86) tmp = t_0; else tmp = Float64(t_1 * Float64(b - t_2)); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((b * c) - (a * d)) / ((c * c) + (d * d)); t_1 = 1.0 / hypot(c, d); t_2 = a * (d / c); tmp = 0.0; if (c <= -3e+41) tmp = t_1 * (t_2 - b); elseif (c <= -1.2e-135) tmp = t_0; elseif (c <= 7.5e-247) tmp = (b / ((d ^ 2.0) / c)) - (a / d); elseif (c <= 7e+86) tmp = t_0; else tmp = t_1 * (b - t_2); 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[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -3e+41], N[(t$95$1 * N[(t$95$2 - b), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -1.2e-135], t$95$0, If[LessEqual[c, 7.5e-247], N[(N[(b / N[(N[Power[d, 2.0], $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 7e+86], t$95$0, N[(t$95$1 * N[(b - t$95$2), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\\
t_1 := \frac{1}{\mathsf{hypot}\left(c, d\right)}\\
t_2 := a \cdot \frac{d}{c}\\
\mathbf{if}\;c \leq -3 \cdot 10^{+41}:\\
\;\;\;\;t_1 \cdot \left(t_2 - b\right)\\
\mathbf{elif}\;c \leq -1.2 \cdot 10^{-135}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 7.5 \cdot 10^{-247}:\\
\;\;\;\;\frac{b}{\frac{{d}^{2}}{c}} - \frac{a}{d}\\
\mathbf{elif}\;c \leq 7 \cdot 10^{+86}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1 \cdot \left(b - t_2\right)\\
\end{array}
\end{array}
if c < -2.9999999999999998e41Initial program 42.7%
*-un-lft-identity42.7%
add-sqr-sqrt42.7%
times-frac42.7%
hypot-def42.7%
hypot-def67.4%
Applied egg-rr67.4%
Taylor expanded in c around -inf 80.7%
+-commutative80.7%
neg-mul-180.7%
unsub-neg80.7%
associate-*r/82.5%
Simplified82.5%
if -2.9999999999999998e41 < c < -1.1999999999999999e-135 or 7.5e-247 < c < 7.00000000000000038e86Initial program 84.7%
if -1.1999999999999999e-135 < c < 7.5e-247Initial program 67.3%
Taylor expanded in c around 0 89.5%
+-commutative89.5%
mul-1-neg89.5%
unsub-neg89.5%
associate-/l*87.4%
Simplified87.4%
if 7.00000000000000038e86 < c Initial program 35.4%
*-un-lft-identity35.4%
add-sqr-sqrt35.4%
times-frac35.5%
hypot-def35.5%
hypot-def61.1%
Applied egg-rr61.1%
Taylor expanded in c around inf 78.2%
mul-1-neg78.2%
unsub-neg78.2%
associate-*r/84.1%
Simplified84.1%
Final simplification84.5%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* b c) (* a d)) (+ (* c c) (* d d))))
(t_1 (- (* b (/ 1.0 c)) (* (/ d c) (/ a c)))))
(if (<= c -7e+125)
t_1
(if (<= c -1.9e-137)
t_0
(if (<= c 3.1e-248)
(- (/ b (/ (pow d 2.0) c)) (/ a d))
(if (<= c 4.8e+86) 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 * (1.0 / c)) - ((d / c) * (a / c));
double tmp;
if (c <= -7e+125) {
tmp = t_1;
} else if (c <= -1.9e-137) {
tmp = t_0;
} else if (c <= 3.1e-248) {
tmp = (b / (pow(d, 2.0) / c)) - (a / d);
} else if (c <= 4.8e+86) {
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 * (1.0d0 / c)) - ((d / c) * (a / c))
if (c <= (-7d+125)) then
tmp = t_1
else if (c <= (-1.9d-137)) then
tmp = t_0
else if (c <= 3.1d-248) then
tmp = (b / ((d ** 2.0d0) / c)) - (a / d)
else if (c <= 4.8d+86) 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 * (1.0 / c)) - ((d / c) * (a / c));
double tmp;
if (c <= -7e+125) {
tmp = t_1;
} else if (c <= -1.9e-137) {
tmp = t_0;
} else if (c <= 3.1e-248) {
tmp = (b / (Math.pow(d, 2.0) / c)) - (a / d);
} else if (c <= 4.8e+86) {
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 * (1.0 / c)) - ((d / c) * (a / c)) tmp = 0 if c <= -7e+125: tmp = t_1 elif c <= -1.9e-137: tmp = t_0 elif c <= 3.1e-248: tmp = (b / (math.pow(d, 2.0) / c)) - (a / d) elif c <= 4.8e+86: 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 * Float64(1.0 / c)) - Float64(Float64(d / c) * Float64(a / c))) tmp = 0.0 if (c <= -7e+125) tmp = t_1; elseif (c <= -1.9e-137) tmp = t_0; elseif (c <= 3.1e-248) tmp = Float64(Float64(b / Float64((d ^ 2.0) / c)) - Float64(a / d)); elseif (c <= 4.8e+86) 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 * (1.0 / c)) - ((d / c) * (a / c)); tmp = 0.0; if (c <= -7e+125) tmp = t_1; elseif (c <= -1.9e-137) tmp = t_0; elseif (c <= 3.1e-248) tmp = (b / ((d ^ 2.0) / c)) - (a / d); elseif (c <= 4.8e+86) 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 * N[(1.0 / c), $MachinePrecision]), $MachinePrecision] - N[(N[(d / c), $MachinePrecision] * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -7e+125], t$95$1, If[LessEqual[c, -1.9e-137], t$95$0, If[LessEqual[c, 3.1e-248], N[(N[(b / N[(N[Power[d, 2.0], $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 4.8e+86], 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 := b \cdot \frac{1}{c} - \frac{d}{c} \cdot \frac{a}{c}\\
\mathbf{if}\;c \leq -7 \cdot 10^{+125}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;c \leq -1.9 \cdot 10^{-137}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 3.1 \cdot 10^{-248}:\\
\;\;\;\;\frac{b}{\frac{{d}^{2}}{c}} - \frac{a}{d}\\
\mathbf{elif}\;c \leq 4.8 \cdot 10^{+86}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if c < -7.00000000000000023e125 or 4.8000000000000001e86 < c Initial program 33.6%
Taylor expanded in c around inf 74.2%
+-commutative74.2%
mul-1-neg74.2%
unsub-neg74.2%
*-commutative74.2%
associate-/l*73.7%
Simplified73.7%
div-inv73.5%
fma-neg73.5%
div-inv73.5%
clear-num73.5%
Applied egg-rr73.5%
fma-udef73.5%
unsub-neg73.5%
associate-*r/73.9%
*-commutative73.9%
Simplified73.9%
*-commutative73.9%
unpow273.9%
times-frac84.3%
Applied egg-rr84.3%
if -7.00000000000000023e125 < c < -1.89999999999999999e-137 or 3.1000000000000002e-248 < c < 4.8000000000000001e86Initial program 83.4%
if -1.89999999999999999e-137 < c < 3.1000000000000002e-248Initial program 67.3%
Taylor expanded in c around 0 89.5%
+-commutative89.5%
mul-1-neg89.5%
unsub-neg89.5%
associate-/l*87.4%
Simplified87.4%
Final simplification84.4%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* b c) (* a d)) (+ (* c c) (* d d))))
(t_1 (- (* b (/ 1.0 c)) (* (/ d c) (/ a c)))))
(if (<= c -1.3e+127)
t_1
(if (<= c -3e-139)
t_0
(if (<= c -7.4e-304) (/ (- a) d) (if (<= c 7e+86) 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 * (1.0 / c)) - ((d / c) * (a / c));
double tmp;
if (c <= -1.3e+127) {
tmp = t_1;
} else if (c <= -3e-139) {
tmp = t_0;
} else if (c <= -7.4e-304) {
tmp = -a / d;
} else if (c <= 7e+86) {
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 * (1.0d0 / c)) - ((d / c) * (a / c))
if (c <= (-1.3d+127)) then
tmp = t_1
else if (c <= (-3d-139)) then
tmp = t_0
else if (c <= (-7.4d-304)) then
tmp = -a / d
else if (c <= 7d+86) 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 * (1.0 / c)) - ((d / c) * (a / c));
double tmp;
if (c <= -1.3e+127) {
tmp = t_1;
} else if (c <= -3e-139) {
tmp = t_0;
} else if (c <= -7.4e-304) {
tmp = -a / d;
} else if (c <= 7e+86) {
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 * (1.0 / c)) - ((d / c) * (a / c)) tmp = 0 if c <= -1.3e+127: tmp = t_1 elif c <= -3e-139: tmp = t_0 elif c <= -7.4e-304: tmp = -a / d elif c <= 7e+86: 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 * Float64(1.0 / c)) - Float64(Float64(d / c) * Float64(a / c))) tmp = 0.0 if (c <= -1.3e+127) tmp = t_1; elseif (c <= -3e-139) tmp = t_0; elseif (c <= -7.4e-304) tmp = Float64(Float64(-a) / d); elseif (c <= 7e+86) 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 * (1.0 / c)) - ((d / c) * (a / c)); tmp = 0.0; if (c <= -1.3e+127) tmp = t_1; elseif (c <= -3e-139) tmp = t_0; elseif (c <= -7.4e-304) tmp = -a / d; elseif (c <= 7e+86) 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 * N[(1.0 / c), $MachinePrecision]), $MachinePrecision] - N[(N[(d / c), $MachinePrecision] * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -1.3e+127], t$95$1, If[LessEqual[c, -3e-139], t$95$0, If[LessEqual[c, -7.4e-304], N[((-a) / d), $MachinePrecision], If[LessEqual[c, 7e+86], 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 := b \cdot \frac{1}{c} - \frac{d}{c} \cdot \frac{a}{c}\\
\mathbf{if}\;c \leq -1.3 \cdot 10^{+127}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;c \leq -3 \cdot 10^{-139}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq -7.4 \cdot 10^{-304}:\\
\;\;\;\;\frac{-a}{d}\\
\mathbf{elif}\;c \leq 7 \cdot 10^{+86}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if c < -1.3000000000000001e127 or 7.00000000000000038e86 < c Initial program 33.6%
Taylor expanded in c around inf 74.2%
+-commutative74.2%
mul-1-neg74.2%
unsub-neg74.2%
*-commutative74.2%
associate-/l*73.7%
Simplified73.7%
div-inv73.5%
fma-neg73.5%
div-inv73.5%
clear-num73.5%
Applied egg-rr73.5%
fma-udef73.5%
unsub-neg73.5%
associate-*r/73.9%
*-commutative73.9%
Simplified73.9%
*-commutative73.9%
unpow273.9%
times-frac84.3%
Applied egg-rr84.3%
if -1.3000000000000001e127 < c < -2.9999999999999999e-139 or -7.4000000000000006e-304 < c < 7.00000000000000038e86Initial program 83.9%
if -2.9999999999999999e-139 < c < -7.4000000000000006e-304Initial program 60.8%
Taylor expanded in c around 0 86.4%
associate-*r/86.4%
neg-mul-186.4%
Simplified86.4%
Final simplification84.4%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (* b c) (+ (* c c) (* d d))))
(t_1 (- (* b (/ 1.0 c)) (* (/ d c) (/ a c)))))
(if (<= c -1.2e+37)
t_1
(if (<= c -1.45e-136)
t_0
(if (<= c 6.3e-55) (/ (- a) d) (if (<= c 1.9e+86) t_0 t_1))))))
double code(double a, double b, double c, double d) {
double t_0 = (b * c) / ((c * c) + (d * d));
double t_1 = (b * (1.0 / c)) - ((d / c) * (a / c));
double tmp;
if (c <= -1.2e+37) {
tmp = t_1;
} else if (c <= -1.45e-136) {
tmp = t_0;
} else if (c <= 6.3e-55) {
tmp = -a / d;
} else if (c <= 1.9e+86) {
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) / ((c * c) + (d * d))
t_1 = (b * (1.0d0 / c)) - ((d / c) * (a / c))
if (c <= (-1.2d+37)) then
tmp = t_1
else if (c <= (-1.45d-136)) then
tmp = t_0
else if (c <= 6.3d-55) then
tmp = -a / d
else if (c <= 1.9d+86) 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) / ((c * c) + (d * d));
double t_1 = (b * (1.0 / c)) - ((d / c) * (a / c));
double tmp;
if (c <= -1.2e+37) {
tmp = t_1;
} else if (c <= -1.45e-136) {
tmp = t_0;
} else if (c <= 6.3e-55) {
tmp = -a / d;
} else if (c <= 1.9e+86) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(a, b, c, d): t_0 = (b * c) / ((c * c) + (d * d)) t_1 = (b * (1.0 / c)) - ((d / c) * (a / c)) tmp = 0 if c <= -1.2e+37: tmp = t_1 elif c <= -1.45e-136: tmp = t_0 elif c <= 6.3e-55: tmp = -a / d elif c <= 1.9e+86: tmp = t_0 else: tmp = t_1 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(b * c) / Float64(Float64(c * c) + Float64(d * d))) t_1 = Float64(Float64(b * Float64(1.0 / c)) - Float64(Float64(d / c) * Float64(a / c))) tmp = 0.0 if (c <= -1.2e+37) tmp = t_1; elseif (c <= -1.45e-136) tmp = t_0; elseif (c <= 6.3e-55) tmp = Float64(Float64(-a) / d); elseif (c <= 1.9e+86) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (b * c) / ((c * c) + (d * d)); t_1 = (b * (1.0 / c)) - ((d / c) * (a / c)); tmp = 0.0; if (c <= -1.2e+37) tmp = t_1; elseif (c <= -1.45e-136) tmp = t_0; elseif (c <= 6.3e-55) tmp = -a / d; elseif (c <= 1.9e+86) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(b * c), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(b * N[(1.0 / c), $MachinePrecision]), $MachinePrecision] - N[(N[(d / c), $MachinePrecision] * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -1.2e+37], t$95$1, If[LessEqual[c, -1.45e-136], t$95$0, If[LessEqual[c, 6.3e-55], N[((-a) / d), $MachinePrecision], If[LessEqual[c, 1.9e+86], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b \cdot c}{c \cdot c + d \cdot d}\\
t_1 := b \cdot \frac{1}{c} - \frac{d}{c} \cdot \frac{a}{c}\\
\mathbf{if}\;c \leq -1.2 \cdot 10^{+37}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;c \leq -1.45 \cdot 10^{-136}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 6.3 \cdot 10^{-55}:\\
\;\;\;\;\frac{-a}{d}\\
\mathbf{elif}\;c \leq 1.9 \cdot 10^{+86}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if c < -1.2e37 or 1.89999999999999989e86 < c Initial program 39.2%
Taylor expanded in c around inf 74.3%
+-commutative74.3%
mul-1-neg74.3%
unsub-neg74.3%
*-commutative74.3%
associate-/l*73.9%
Simplified73.9%
div-inv73.6%
fma-neg73.6%
div-inv73.7%
clear-num73.6%
Applied egg-rr73.6%
fma-udef73.6%
unsub-neg73.6%
associate-*r/74.0%
*-commutative74.0%
Simplified74.0%
*-commutative74.0%
unpow274.0%
times-frac82.9%
Applied egg-rr82.9%
if -1.2e37 < c < -1.44999999999999997e-136 or 6.2999999999999997e-55 < c < 1.89999999999999989e86Initial program 87.7%
Taylor expanded in b around inf 64.9%
*-commutative64.9%
Simplified64.9%
if -1.44999999999999997e-136 < c < 6.2999999999999997e-55Initial program 72.6%
Taylor expanded in c around 0 76.5%
associate-*r/76.5%
neg-mul-176.5%
Simplified76.5%
Final simplification76.3%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (* b c) (+ (* c c) (* d d)))))
(if (<= c -3e+41)
(/ b c)
(if (<= c -1.26e-135)
t_0
(if (<= c 1.5e-56) (/ (- a) d) (if (<= c 5.4e+86) t_0 (/ b c)))))))
double code(double a, double b, double c, double d) {
double t_0 = (b * c) / ((c * c) + (d * d));
double tmp;
if (c <= -3e+41) {
tmp = b / c;
} else if (c <= -1.26e-135) {
tmp = t_0;
} else if (c <= 1.5e-56) {
tmp = -a / d;
} else if (c <= 5.4e+86) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = (b * c) / ((c * c) + (d * d))
if (c <= (-3d+41)) then
tmp = b / c
else if (c <= (-1.26d-135)) then
tmp = t_0
else if (c <= 1.5d-56) then
tmp = -a / d
else if (c <= 5.4d+86) then
tmp = t_0
else
tmp = b / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = (b * c) / ((c * c) + (d * d));
double tmp;
if (c <= -3e+41) {
tmp = b / c;
} else if (c <= -1.26e-135) {
tmp = t_0;
} else if (c <= 1.5e-56) {
tmp = -a / d;
} else if (c <= 5.4e+86) {
tmp = t_0;
} else {
tmp = b / c;
}
return tmp;
}
def code(a, b, c, d): t_0 = (b * c) / ((c * c) + (d * d)) tmp = 0 if c <= -3e+41: tmp = b / c elif c <= -1.26e-135: tmp = t_0 elif c <= 1.5e-56: tmp = -a / d elif c <= 5.4e+86: tmp = t_0 else: tmp = b / c return tmp
function code(a, b, c, d) t_0 = Float64(Float64(b * c) / Float64(Float64(c * c) + Float64(d * d))) tmp = 0.0 if (c <= -3e+41) tmp = Float64(b / c); elseif (c <= -1.26e-135) tmp = t_0; elseif (c <= 1.5e-56) tmp = Float64(Float64(-a) / d); elseif (c <= 5.4e+86) tmp = t_0; else tmp = Float64(b / c); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (b * c) / ((c * c) + (d * d)); tmp = 0.0; if (c <= -3e+41) tmp = b / c; elseif (c <= -1.26e-135) tmp = t_0; elseif (c <= 1.5e-56) tmp = -a / d; elseif (c <= 5.4e+86) tmp = t_0; else tmp = b / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(b * c), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -3e+41], N[(b / c), $MachinePrecision], If[LessEqual[c, -1.26e-135], t$95$0, If[LessEqual[c, 1.5e-56], N[((-a) / d), $MachinePrecision], If[LessEqual[c, 5.4e+86], t$95$0, N[(b / c), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b \cdot c}{c \cdot c + d \cdot d}\\
\mathbf{if}\;c \leq -3 \cdot 10^{+41}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{elif}\;c \leq -1.26 \cdot 10^{-135}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 1.5 \cdot 10^{-56}:\\
\;\;\;\;\frac{-a}{d}\\
\mathbf{elif}\;c \leq 5.4 \cdot 10^{+86}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if c < -2.9999999999999998e41 or 5.40000000000000036e86 < c Initial program 39.2%
Taylor expanded in c around inf 72.2%
if -2.9999999999999998e41 < c < -1.2600000000000001e-135 or 1.49999999999999995e-56 < c < 5.40000000000000036e86Initial program 87.7%
Taylor expanded in b around inf 64.9%
*-commutative64.9%
Simplified64.9%
if -1.2600000000000001e-135 < c < 1.49999999999999995e-56Initial program 72.6%
Taylor expanded in c around 0 76.5%
associate-*r/76.5%
neg-mul-176.5%
Simplified76.5%
Final simplification71.7%
(FPCore (a b c d) :precision binary64 (if (or (<= c -4.5e-17) (not (<= c 1.22e-9))) (/ b c) (/ (- a) d)))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -4.5e-17) || !(c <= 1.22e-9)) {
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 <= (-4.5d-17)) .or. (.not. (c <= 1.22d-9))) 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 <= -4.5e-17) || !(c <= 1.22e-9)) {
tmp = b / c;
} else {
tmp = -a / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -4.5e-17) or not (c <= 1.22e-9): tmp = b / c else: tmp = -a / d return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -4.5e-17) || !(c <= 1.22e-9)) 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 <= -4.5e-17) || ~((c <= 1.22e-9))) tmp = b / c; else tmp = -a / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -4.5e-17], N[Not[LessEqual[c, 1.22e-9]], $MachinePrecision]], N[(b / c), $MachinePrecision], N[((-a) / d), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -4.5 \cdot 10^{-17} \lor \neg \left(c \leq 1.22 \cdot 10^{-9}\right):\\
\;\;\;\;\frac{b}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{-a}{d}\\
\end{array}
\end{array}
if c < -4.49999999999999978e-17 or 1.2199999999999999e-9 < c Initial program 49.1%
Taylor expanded in c around inf 67.5%
if -4.49999999999999978e-17 < c < 1.2199999999999999e-9Initial program 78.0%
Taylor expanded in c around 0 67.4%
associate-*r/67.4%
neg-mul-167.4%
Simplified67.4%
Final simplification67.4%
(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 62.1%
Taylor expanded in c around inf 46.2%
Final simplification46.2%
(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 2023314
(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))))