
(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 (fma (/ c (hypot c d)) (/ b (hypot c d)) (/ (/ (- d) (/ (hypot c d) a)) (hypot c d))))
double code(double a, double b, double c, double d) {
return fma((c / hypot(c, d)), (b / hypot(c, d)), ((-d / (hypot(c, d) / a)) / hypot(c, d)));
}
function code(a, b, c, d) return fma(Float64(c / hypot(c, d)), Float64(b / hypot(c, d)), Float64(Float64(Float64(-d) / Float64(hypot(c, d) / a)) / hypot(c, d))) end
code[a_, b_, c_, d_] := N[(N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] + N[(N[((-d) / N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, \frac{\frac{-d}{\frac{\mathsf{hypot}\left(c, d\right)}{a}}}{\mathsf{hypot}\left(c, d\right)}\right)
\end{array}
Initial program 60.9%
div-sub57.7%
*-commutative57.7%
add-sqr-sqrt57.7%
times-frac60.8%
fma-neg60.8%
hypot-def60.8%
hypot-def73.0%
associate-/l*78.6%
add-sqr-sqrt78.6%
pow278.6%
hypot-def78.6%
Applied egg-rr78.6%
unpow278.6%
add-sqr-sqrt38.4%
hypot-udef38.4%
hypot-udef38.4%
add-sqr-sqrt38.4%
+-commutative38.4%
fma-udef38.4%
sqrt-prod53.3%
sqr-neg53.3%
sqrt-unprod27.1%
add-sqr-sqrt53.7%
associate-/l*51.0%
*-un-lft-identity51.0%
fma-udef51.0%
+-commutative51.0%
add-sqr-sqrt51.0%
hypot-udef51.0%
hypot-udef51.0%
times-frac53.3%
Applied egg-rr84.5%
associate-*l/84.5%
*-lft-identity84.5%
associate-/l*98.0%
Simplified98.0%
Final simplification98.0%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ c (hypot c d)))
(t_1 (/ b (hypot c d)))
(t_2 (fma t_0 t_1 (/ (- a) (/ (pow (hypot c d) 2.0) d)))))
(if (<= d -1.35e+154)
(/ (- (* c (/ b d)) a) d)
(if (<= d -1.4e-163)
t_2
(if (<= d 3e-196)
(- (/ b c) (* (/ d c) (/ a c)))
(if (<= d 5e+123) t_2 (fma t_0 t_1 (/ (- a) d))))))))
double code(double a, double b, double c, double d) {
double t_0 = c / hypot(c, d);
double t_1 = b / hypot(c, d);
double t_2 = fma(t_0, t_1, (-a / (pow(hypot(c, d), 2.0) / d)));
double tmp;
if (d <= -1.35e+154) {
tmp = ((c * (b / d)) - a) / d;
} else if (d <= -1.4e-163) {
tmp = t_2;
} else if (d <= 3e-196) {
tmp = (b / c) - ((d / c) * (a / c));
} else if (d <= 5e+123) {
tmp = t_2;
} else {
tmp = fma(t_0, t_1, (-a / d));
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(c / hypot(c, d)) t_1 = Float64(b / hypot(c, d)) t_2 = fma(t_0, t_1, Float64(Float64(-a) / Float64((hypot(c, d) ^ 2.0) / d))) tmp = 0.0 if (d <= -1.35e+154) tmp = Float64(Float64(Float64(c * Float64(b / d)) - a) / d); elseif (d <= -1.4e-163) tmp = t_2; elseif (d <= 3e-196) tmp = Float64(Float64(b / c) - Float64(Float64(d / c) * Float64(a / c))); elseif (d <= 5e+123) tmp = t_2; else tmp = fma(t_0, t_1, Float64(Float64(-a) / d)); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$0 * t$95$1 + N[((-a) / N[(N[Power[N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision], 2.0], $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -1.35e+154], N[(N[(N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, -1.4e-163], t$95$2, If[LessEqual[d, 3e-196], N[(N[(b / c), $MachinePrecision] - N[(N[(d / c), $MachinePrecision] * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 5e+123], t$95$2, N[(t$95$0 * t$95$1 + N[((-a) / d), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c}{\mathsf{hypot}\left(c, d\right)}\\
t_1 := \frac{b}{\mathsf{hypot}\left(c, d\right)}\\
t_2 := \mathsf{fma}\left(t_0, t_1, \frac{-a}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{d}}\right)\\
\mathbf{if}\;d \leq -1.35 \cdot 10^{+154}:\\
\;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\
\mathbf{elif}\;d \leq -1.4 \cdot 10^{-163}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;d \leq 3 \cdot 10^{-196}:\\
\;\;\;\;\frac{b}{c} - \frac{d}{c} \cdot \frac{a}{c}\\
\mathbf{elif}\;d \leq 5 \cdot 10^{+123}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t_0, t_1, \frac{-a}{d}\right)\\
\end{array}
\end{array}
if d < -1.35000000000000003e154Initial program 25.0%
div-sub25.0%
*-commutative25.0%
add-sqr-sqrt25.0%
times-frac25.1%
fma-neg25.1%
hypot-def25.1%
hypot-def31.2%
associate-/l*35.7%
add-sqr-sqrt35.7%
pow235.7%
hypot-def35.7%
Applied egg-rr35.7%
Taylor expanded in c around 0 84.4%
+-commutative84.4%
mul-1-neg84.4%
unsub-neg84.4%
unpow284.4%
times-frac91.3%
Simplified91.3%
associate-*r/94.3%
sub-div94.3%
Applied egg-rr94.3%
if -1.35000000000000003e154 < d < -1.4e-163 or 3e-196 < d < 4.99999999999999974e123Initial program 71.5%
div-sub70.0%
*-commutative70.0%
add-sqr-sqrt70.0%
times-frac72.9%
fma-neg72.9%
hypot-def72.9%
hypot-def83.9%
associate-/l*92.9%
add-sqr-sqrt92.9%
pow292.9%
hypot-def92.9%
Applied egg-rr92.9%
if -1.4e-163 < d < 3e-196Initial program 65.2%
Taylor expanded in c around inf 84.0%
+-commutative84.0%
mul-1-neg84.0%
unsub-neg84.0%
*-commutative84.0%
unpow284.0%
times-frac93.9%
Simplified93.9%
if 4.99999999999999974e123 < d Initial program 47.3%
div-sub47.3%
*-commutative47.3%
add-sqr-sqrt47.3%
times-frac47.2%
fma-neg47.2%
hypot-def47.2%
hypot-def52.3%
associate-/l*56.2%
add-sqr-sqrt56.2%
pow256.2%
hypot-def56.2%
Applied egg-rr56.2%
Taylor expanded in c around 0 100.0%
Final simplification94.3%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (- (* c b) (* d a))) (t_1 (/ t_0 (+ (* c c) (* d d)))))
(if (or (<= t_1 -2e+237) (not (<= t_1 1e+301)))
(fma (/ c (hypot c d)) (/ b (hypot c d)) (/ (- a) d))
(* (/ 1.0 (hypot c d)) (/ t_0 (hypot c d))))))
double code(double a, double b, double c, double d) {
double t_0 = (c * b) - (d * a);
double t_1 = t_0 / ((c * c) + (d * d));
double tmp;
if ((t_1 <= -2e+237) || !(t_1 <= 1e+301)) {
tmp = fma((c / hypot(c, d)), (b / hypot(c, d)), (-a / d));
} else {
tmp = (1.0 / hypot(c, d)) * (t_0 / hypot(c, d));
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(c * b) - Float64(d * a)) t_1 = Float64(t_0 / Float64(Float64(c * c) + Float64(d * d))) tmp = 0.0 if ((t_1 <= -2e+237) || !(t_1 <= 1e+301)) tmp = fma(Float64(c / hypot(c, d)), Float64(b / hypot(c, d)), Float64(Float64(-a) / d)); else tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(t_0 / hypot(c, d))); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -2e+237], N[Not[LessEqual[t$95$1, 1e+301]], $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], 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]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := c \cdot b - d \cdot a\\
t_1 := \frac{t_0}{c \cdot c + d \cdot d}\\
\mathbf{if}\;t_1 \leq -2 \cdot 10^{+237} \lor \neg \left(t_1 \leq 10^{+301}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, \frac{-a}{d}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{t_0}{\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))) < -1.99999999999999988e237 or 1.00000000000000005e301 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 26.3%
div-sub16.9%
*-commutative16.9%
add-sqr-sqrt16.9%
times-frac26.5%
fma-neg26.5%
hypot-def26.5%
hypot-def48.5%
associate-/l*65.0%
add-sqr-sqrt65.0%
pow265.0%
hypot-def65.0%
Applied egg-rr65.0%
Taylor expanded in c around 0 73.5%
if -1.99999999999999988e237 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 1.00000000000000005e301Initial program 79.0%
*-un-lft-identity79.0%
add-sqr-sqrt79.0%
times-frac78.9%
hypot-def78.9%
hypot-def98.4%
Applied egg-rr98.4%
Final simplification89.8%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (* (/ 1.0 (hypot c d)) (/ (- (* c b) (* d a)) (hypot c d)))))
(if (<= d -2.2e+75)
(/ (- (* c (/ b d)) a) d)
(if (<= d -8.2e-229)
t_0
(if (<= d 9.6e-125)
(- (/ b c) (* (/ d c) (/ a c)))
(if (<= d 7e+189) t_0 (- (* (/ b d) (/ c d)) (/ a d))))))))
double code(double a, double b, double c, double d) {
double t_0 = (1.0 / hypot(c, d)) * (((c * b) - (d * a)) / hypot(c, d));
double tmp;
if (d <= -2.2e+75) {
tmp = ((c * (b / d)) - a) / d;
} else if (d <= -8.2e-229) {
tmp = t_0;
} else if (d <= 9.6e-125) {
tmp = (b / c) - ((d / c) * (a / c));
} else if (d <= 7e+189) {
tmp = t_0;
} else {
tmp = ((b / d) * (c / d)) - (a / d);
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = (1.0 / Math.hypot(c, d)) * (((c * b) - (d * a)) / Math.hypot(c, d));
double tmp;
if (d <= -2.2e+75) {
tmp = ((c * (b / d)) - a) / d;
} else if (d <= -8.2e-229) {
tmp = t_0;
} else if (d <= 9.6e-125) {
tmp = (b / c) - ((d / c) * (a / c));
} else if (d <= 7e+189) {
tmp = t_0;
} else {
tmp = ((b / d) * (c / d)) - (a / d);
}
return tmp;
}
def code(a, b, c, d): t_0 = (1.0 / math.hypot(c, d)) * (((c * b) - (d * a)) / math.hypot(c, d)) tmp = 0 if d <= -2.2e+75: tmp = ((c * (b / d)) - a) / d elif d <= -8.2e-229: tmp = t_0 elif d <= 9.6e-125: tmp = (b / c) - ((d / c) * (a / c)) elif d <= 7e+189: tmp = t_0 else: tmp = ((b / d) * (c / d)) - (a / d) return tmp
function code(a, b, c, d) t_0 = Float64(Float64(1.0 / hypot(c, d)) * Float64(Float64(Float64(c * b) - Float64(d * a)) / hypot(c, d))) tmp = 0.0 if (d <= -2.2e+75) tmp = Float64(Float64(Float64(c * Float64(b / d)) - a) / d); elseif (d <= -8.2e-229) tmp = t_0; elseif (d <= 9.6e-125) tmp = Float64(Float64(b / c) - Float64(Float64(d / c) * Float64(a / c))); elseif (d <= 7e+189) tmp = t_0; else tmp = Float64(Float64(Float64(b / d) * Float64(c / d)) - Float64(a / d)); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (1.0 / hypot(c, d)) * (((c * b) - (d * a)) / hypot(c, d)); tmp = 0.0; if (d <= -2.2e+75) tmp = ((c * (b / d)) - a) / d; elseif (d <= -8.2e-229) tmp = t_0; elseif (d <= 9.6e-125) tmp = (b / c) - ((d / c) * (a / c)); elseif (d <= 7e+189) tmp = t_0; else tmp = ((b / d) * (c / d)) - (a / d); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -2.2e+75], N[(N[(N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, -8.2e-229], t$95$0, If[LessEqual[d, 9.6e-125], N[(N[(b / c), $MachinePrecision] - N[(N[(d / c), $MachinePrecision] * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 7e+189], t$95$0, N[(N[(N[(b / d), $MachinePrecision] * N[(c / d), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{c \cdot b - d \cdot a}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{if}\;d \leq -2.2 \cdot 10^{+75}:\\
\;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\
\mathbf{elif}\;d \leq -8.2 \cdot 10^{-229}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 9.6 \cdot 10^{-125}:\\
\;\;\;\;\frac{b}{c} - \frac{d}{c} \cdot \frac{a}{c}\\
\mathbf{elif}\;d \leq 7 \cdot 10^{+189}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d} \cdot \frac{c}{d} - \frac{a}{d}\\
\end{array}
\end{array}
if d < -2.20000000000000012e75Initial program 38.8%
div-sub38.8%
*-commutative38.8%
add-sqr-sqrt38.8%
times-frac38.8%
fma-neg38.8%
hypot-def38.8%
hypot-def42.7%
associate-/l*59.2%
add-sqr-sqrt59.2%
pow259.2%
hypot-def59.2%
Applied egg-rr59.2%
Taylor expanded in c around 0 85.7%
+-commutative85.7%
mul-1-neg85.7%
unsub-neg85.7%
unpow285.7%
times-frac92.2%
Simplified92.2%
associate-*r/94.0%
sub-div94.0%
Applied egg-rr94.0%
if -2.20000000000000012e75 < d < -8.1999999999999999e-229 or 9.6000000000000005e-125 < d < 6.99999999999999991e189Initial program 71.6%
*-un-lft-identity71.6%
add-sqr-sqrt71.6%
times-frac71.6%
hypot-def71.6%
hypot-def84.3%
Applied egg-rr84.3%
if -8.1999999999999999e-229 < d < 9.6000000000000005e-125Initial program 64.4%
Taylor expanded in c around inf 87.0%
+-commutative87.0%
mul-1-neg87.0%
unsub-neg87.0%
*-commutative87.0%
unpow287.0%
times-frac95.3%
Simplified95.3%
if 6.99999999999999991e189 < d Initial program 45.4%
div-sub45.4%
*-commutative45.4%
add-sqr-sqrt45.4%
times-frac45.4%
fma-neg45.4%
hypot-def45.4%
hypot-def45.4%
associate-/l*47.1%
add-sqr-sqrt47.1%
pow247.1%
hypot-def47.1%
Applied egg-rr47.1%
Taylor expanded in c around 0 85.2%
+-commutative85.2%
mul-1-neg85.2%
unsub-neg85.2%
unpow285.2%
times-frac100.0%
Simplified100.0%
Final simplification90.4%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (- (* c b) (* d a))))
(if (<= d -4e+76)
(/ (- (* c (/ b d)) a) d)
(if (<= d -9e-229)
(/ 1.0 (* (hypot c d) (/ (hypot c d) t_0)))
(if (<= d 6.2e-125)
(- (/ b c) (* (/ d c) (/ a c)))
(if (<= d 7e+189)
(* (/ 1.0 (hypot c d)) (/ t_0 (hypot c d)))
(- (* (/ b d) (/ c d)) (/ a d))))))))
double code(double a, double b, double c, double d) {
double t_0 = (c * b) - (d * a);
double tmp;
if (d <= -4e+76) {
tmp = ((c * (b / d)) - a) / d;
} else if (d <= -9e-229) {
tmp = 1.0 / (hypot(c, d) * (hypot(c, d) / t_0));
} else if (d <= 6.2e-125) {
tmp = (b / c) - ((d / c) * (a / c));
} else if (d <= 7e+189) {
tmp = (1.0 / hypot(c, d)) * (t_0 / hypot(c, d));
} else {
tmp = ((b / d) * (c / 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 (d <= -4e+76) {
tmp = ((c * (b / d)) - a) / d;
} else if (d <= -9e-229) {
tmp = 1.0 / (Math.hypot(c, d) * (Math.hypot(c, d) / t_0));
} else if (d <= 6.2e-125) {
tmp = (b / c) - ((d / c) * (a / c));
} else if (d <= 7e+189) {
tmp = (1.0 / Math.hypot(c, d)) * (t_0 / Math.hypot(c, d));
} else {
tmp = ((b / d) * (c / d)) - (a / d);
}
return tmp;
}
def code(a, b, c, d): t_0 = (c * b) - (d * a) tmp = 0 if d <= -4e+76: tmp = ((c * (b / d)) - a) / d elif d <= -9e-229: tmp = 1.0 / (math.hypot(c, d) * (math.hypot(c, d) / t_0)) elif d <= 6.2e-125: tmp = (b / c) - ((d / c) * (a / c)) elif d <= 7e+189: tmp = (1.0 / math.hypot(c, d)) * (t_0 / math.hypot(c, d)) else: tmp = ((b / d) * (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 (d <= -4e+76) tmp = Float64(Float64(Float64(c * Float64(b / d)) - a) / d); elseif (d <= -9e-229) tmp = Float64(1.0 / Float64(hypot(c, d) * Float64(hypot(c, d) / t_0))); elseif (d <= 6.2e-125) tmp = Float64(Float64(b / c) - Float64(Float64(d / c) * Float64(a / c))); elseif (d <= 7e+189) tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(t_0 / hypot(c, d))); else tmp = Float64(Float64(Float64(b / d) * Float64(c / d)) - Float64(a / d)); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (c * b) - (d * a); tmp = 0.0; if (d <= -4e+76) tmp = ((c * (b / d)) - a) / d; elseif (d <= -9e-229) tmp = 1.0 / (hypot(c, d) * (hypot(c, d) / t_0)); elseif (d <= 6.2e-125) tmp = (b / c) - ((d / c) * (a / c)); elseif (d <= 7e+189) tmp = (1.0 / hypot(c, d)) * (t_0 / hypot(c, d)); else tmp = ((b / d) * (c / 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[d, -4e+76], N[(N[(N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, -9e-229], N[(1.0 / N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] * N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 6.2e-125], N[(N[(b / c), $MachinePrecision] - N[(N[(d / c), $MachinePrecision] * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 7e+189], 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[(b / d), $MachinePrecision] * N[(c / d), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := c \cdot b - d \cdot a\\
\mathbf{if}\;d \leq -4 \cdot 10^{+76}:\\
\;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\
\mathbf{elif}\;d \leq -9 \cdot 10^{-229}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right) \cdot \frac{\mathsf{hypot}\left(c, d\right)}{t_0}}\\
\mathbf{elif}\;d \leq 6.2 \cdot 10^{-125}:\\
\;\;\;\;\frac{b}{c} - \frac{d}{c} \cdot \frac{a}{c}\\
\mathbf{elif}\;d \leq 7 \cdot 10^{+189}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{t_0}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d} \cdot \frac{c}{d} - \frac{a}{d}\\
\end{array}
\end{array}
if d < -4.0000000000000002e76Initial program 38.8%
div-sub38.8%
*-commutative38.8%
add-sqr-sqrt38.8%
times-frac38.8%
fma-neg38.8%
hypot-def38.8%
hypot-def42.7%
associate-/l*59.2%
add-sqr-sqrt59.2%
pow259.2%
hypot-def59.2%
Applied egg-rr59.2%
Taylor expanded in c around 0 85.7%
+-commutative85.7%
mul-1-neg85.7%
unsub-neg85.7%
unpow285.7%
times-frac92.2%
Simplified92.2%
associate-*r/94.0%
sub-div94.0%
Applied egg-rr94.0%
if -4.0000000000000002e76 < d < -9.0000000000000004e-229Initial program 71.0%
*-un-lft-identity71.0%
add-sqr-sqrt71.0%
times-frac70.9%
hypot-def70.9%
hypot-def83.6%
Applied egg-rr83.6%
clear-num83.6%
frac-times83.6%
metadata-eval83.6%
Applied egg-rr83.6%
if -9.0000000000000004e-229 < d < 6.20000000000000026e-125Initial program 64.4%
Taylor expanded in c around inf 87.0%
+-commutative87.0%
mul-1-neg87.0%
unsub-neg87.0%
*-commutative87.0%
unpow287.0%
times-frac95.3%
Simplified95.3%
if 6.20000000000000026e-125 < d < 6.99999999999999991e189Initial program 72.3%
*-un-lft-identity72.3%
add-sqr-sqrt72.3%
times-frac72.2%
hypot-def72.3%
hypot-def85.0%
Applied egg-rr85.0%
if 6.99999999999999991e189 < d Initial program 45.4%
div-sub45.4%
*-commutative45.4%
add-sqr-sqrt45.4%
times-frac45.4%
fma-neg45.4%
hypot-def45.4%
hypot-def45.4%
associate-/l*47.1%
add-sqr-sqrt47.1%
pow247.1%
hypot-def47.1%
Applied egg-rr47.1%
Taylor expanded in c around 0 85.2%
+-commutative85.2%
mul-1-neg85.2%
unsub-neg85.2%
unpow285.2%
times-frac100.0%
Simplified100.0%
Final simplification90.4%
(FPCore (a b c d)
:precision binary64
(if (<= c -9e+23)
(* (/ 1.0 (hypot c d)) (- (/ a (/ c d)) b))
(if (<= c -1.7e-88)
(- (/ c (/ (pow (hypot c d) 2.0) b)) (/ a d))
(if (<= c -5.5e-198)
(/ (- (* c b) (* d a)) (+ (* c c) (* d d)))
(if (<= c 3.35e-78)
(- (* (/ b d) (/ c d)) (/ a d))
(- (/ b c) (* (/ d c) (/ a c))))))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -9e+23) {
tmp = (1.0 / hypot(c, d)) * ((a / (c / d)) - b);
} else if (c <= -1.7e-88) {
tmp = (c / (pow(hypot(c, d), 2.0) / b)) - (a / d);
} else if (c <= -5.5e-198) {
tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
} else if (c <= 3.35e-78) {
tmp = ((b / d) * (c / d)) - (a / d);
} else {
tmp = (b / c) - ((d / c) * (a / c));
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -9e+23) {
tmp = (1.0 / Math.hypot(c, d)) * ((a / (c / d)) - b);
} else if (c <= -1.7e-88) {
tmp = (c / (Math.pow(Math.hypot(c, d), 2.0) / b)) - (a / d);
} else if (c <= -5.5e-198) {
tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
} else if (c <= 3.35e-78) {
tmp = ((b / d) * (c / d)) - (a / d);
} else {
tmp = (b / c) - ((d / c) * (a / c));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -9e+23: tmp = (1.0 / math.hypot(c, d)) * ((a / (c / d)) - b) elif c <= -1.7e-88: tmp = (c / (math.pow(math.hypot(c, d), 2.0) / b)) - (a / d) elif c <= -5.5e-198: tmp = ((c * b) - (d * a)) / ((c * c) + (d * d)) elif c <= 3.35e-78: tmp = ((b / d) * (c / d)) - (a / d) else: tmp = (b / c) - ((d / c) * (a / c)) return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -9e+23) tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(Float64(a / Float64(c / d)) - b)); elseif (c <= -1.7e-88) tmp = Float64(Float64(c / Float64((hypot(c, d) ^ 2.0) / b)) - Float64(a / d)); elseif (c <= -5.5e-198) tmp = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d))); elseif (c <= 3.35e-78) tmp = Float64(Float64(Float64(b / d) * Float64(c / d)) - 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 <= -9e+23) tmp = (1.0 / hypot(c, d)) * ((a / (c / d)) - b); elseif (c <= -1.7e-88) tmp = (c / ((hypot(c, d) ^ 2.0) / b)) - (a / d); elseif (c <= -5.5e-198) tmp = ((c * b) - (d * a)) / ((c * c) + (d * d)); elseif (c <= 3.35e-78) tmp = ((b / d) * (c / d)) - (a / d); else tmp = (b / c) - ((d / c) * (a / c)); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -9e+23], N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -1.7e-88], N[(N[(c / N[(N[Power[N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision], 2.0], $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -5.5e-198], N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 3.35e-78], N[(N[(N[(b / d), $MachinePrecision] * N[(c / d), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $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 -9 \cdot 10^{+23}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(\frac{a}{\frac{c}{d}} - b\right)\\
\mathbf{elif}\;c \leq -1.7 \cdot 10^{-88}:\\
\;\;\;\;\frac{c}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{b}} - \frac{a}{d}\\
\mathbf{elif}\;c \leq -5.5 \cdot 10^{-198}:\\
\;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;c \leq 3.35 \cdot 10^{-78}:\\
\;\;\;\;\frac{b}{d} \cdot \frac{c}{d} - \frac{a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c} - \frac{d}{c} \cdot \frac{a}{c}\\
\end{array}
\end{array}
if c < -8.99999999999999958e23Initial program 48.7%
*-un-lft-identity48.7%
add-sqr-sqrt48.7%
times-frac48.8%
hypot-def48.8%
hypot-def63.2%
Applied egg-rr63.2%
Taylor expanded in c around -inf 71.7%
neg-mul-171.7%
+-commutative71.7%
unsub-neg71.7%
associate-/l*76.6%
Simplified76.6%
if -8.99999999999999958e23 < c < -1.69999999999999987e-88Initial program 63.7%
div-sub63.7%
*-commutative63.7%
add-sqr-sqrt63.7%
times-frac64.0%
fma-neg64.0%
hypot-def64.0%
hypot-def64.0%
associate-/l*71.8%
add-sqr-sqrt71.7%
pow271.7%
hypot-def71.7%
Applied egg-rr71.7%
Taylor expanded in c around 0 93.6%
fma-udef93.6%
unsub-neg93.6%
frac-times93.3%
pow293.3%
Applied egg-rr93.3%
associate-/l*93.4%
Simplified93.4%
if -1.69999999999999987e-88 < c < -5.5000000000000001e-198Initial program 89.1%
if -5.5000000000000001e-198 < c < 3.34999999999999997e-78Initial program 63.4%
div-sub53.2%
*-commutative53.2%
add-sqr-sqrt53.2%
times-frac52.5%
fma-neg52.5%
hypot-def52.5%
hypot-def55.3%
associate-/l*64.9%
add-sqr-sqrt64.9%
pow264.9%
hypot-def64.9%
Applied egg-rr64.9%
Taylor expanded in c around 0 89.1%
+-commutative89.1%
mul-1-neg89.1%
unsub-neg89.1%
unpow289.1%
times-frac94.7%
Simplified94.7%
if 3.34999999999999997e-78 < c Initial program 57.4%
Taylor expanded in c around inf 76.8%
+-commutative76.8%
mul-1-neg76.8%
unsub-neg76.8%
*-commutative76.8%
unpow276.8%
times-frac82.2%
Simplified82.2%
Final simplification86.2%
(FPCore (a b c d)
:precision binary64
(if (<= c -1.1e+21)
(* (/ 1.0 (hypot c d)) (- (/ a (/ c d)) b))
(if (<= c 5.6e-81)
(/ (- (* c (/ b d)) a) d)
(- (/ b c) (* (/ d c) (/ a c))))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -1.1e+21) {
tmp = (1.0 / hypot(c, d)) * ((a / (c / d)) - b);
} else if (c <= 5.6e-81) {
tmp = ((c * (b / d)) - a) / d;
} else {
tmp = (b / c) - ((d / c) * (a / c));
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -1.1e+21) {
tmp = (1.0 / Math.hypot(c, d)) * ((a / (c / d)) - b);
} else if (c <= 5.6e-81) {
tmp = ((c * (b / d)) - a) / d;
} else {
tmp = (b / c) - ((d / c) * (a / c));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -1.1e+21: tmp = (1.0 / math.hypot(c, d)) * ((a / (c / d)) - b) elif c <= 5.6e-81: tmp = ((c * (b / d)) - 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+21) tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(Float64(a / Float64(c / d)) - b)); elseif (c <= 5.6e-81) tmp = Float64(Float64(Float64(c * Float64(b / d)) - 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+21) tmp = (1.0 / hypot(c, d)) * ((a / (c / d)) - b); elseif (c <= 5.6e-81) tmp = ((c * (b / d)) - 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+21], N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 5.6e-81], N[(N[(N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / 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^{+21}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(\frac{a}{\frac{c}{d}} - b\right)\\
\mathbf{elif}\;c \leq 5.6 \cdot 10^{-81}:\\
\;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c} - \frac{d}{c} \cdot \frac{a}{c}\\
\end{array}
\end{array}
if c < -1.1e21Initial program 48.7%
*-un-lft-identity48.7%
add-sqr-sqrt48.7%
times-frac48.8%
hypot-def48.8%
hypot-def63.2%
Applied egg-rr63.2%
Taylor expanded in c around -inf 71.7%
neg-mul-171.7%
+-commutative71.7%
unsub-neg71.7%
associate-/l*76.6%
Simplified76.6%
if -1.1e21 < c < 5.5999999999999998e-81Initial program 68.9%
div-sub62.2%
*-commutative62.2%
add-sqr-sqrt62.2%
times-frac62.6%
fma-neg62.6%
hypot-def62.6%
hypot-def64.3%
associate-/l*71.4%
add-sqr-sqrt71.4%
pow271.4%
hypot-def71.4%
Applied egg-rr71.4%
Taylor expanded in c around 0 83.0%
+-commutative83.0%
mul-1-neg83.0%
unsub-neg83.0%
unpow283.0%
times-frac86.3%
Simplified86.3%
associate-*r/87.1%
sub-div87.9%
Applied egg-rr87.9%
if 5.5999999999999998e-81 < c Initial program 57.4%
Taylor expanded in c around inf 76.8%
+-commutative76.8%
mul-1-neg76.8%
unsub-neg76.8%
*-commutative76.8%
unpow276.8%
times-frac82.2%
Simplified82.2%
Final simplification83.6%
(FPCore (a b c d) :precision binary64 (if (or (<= c -1.3e+22) (not (<= c 5.6e-81))) (- (/ b c) (* (/ d c) (/ a c))) (/ (- (* c (/ b d)) a) d)))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -1.3e+22) || !(c <= 5.6e-81)) {
tmp = (b / c) - ((d / c) * (a / 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 <= (-1.3d+22)) .or. (.not. (c <= 5.6d-81))) then
tmp = (b / c) - ((d / c) * (a / 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 <= -1.3e+22) || !(c <= 5.6e-81)) {
tmp = (b / c) - ((d / c) * (a / c));
} else {
tmp = ((c * (b / d)) - a) / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -1.3e+22) or not (c <= 5.6e-81): tmp = (b / c) - ((d / c) * (a / c)) else: tmp = ((c * (b / d)) - a) / d return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -1.3e+22) || !(c <= 5.6e-81)) tmp = Float64(Float64(b / c) - Float64(Float64(d / c) * Float64(a / c))); else tmp = Float64(Float64(Float64(c * Float64(b / d)) - a) / d); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((c <= -1.3e+22) || ~((c <= 5.6e-81))) tmp = (b / c) - ((d / c) * (a / c)); else tmp = ((c * (b / d)) - a) / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -1.3e+22], N[Not[LessEqual[c, 5.6e-81]], $MachinePrecision]], N[(N[(b / c), $MachinePrecision] - N[(N[(d / c), $MachinePrecision] * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.3 \cdot 10^{+22} \lor \neg \left(c \leq 5.6 \cdot 10^{-81}\right):\\
\;\;\;\;\frac{b}{c} - \frac{d}{c} \cdot \frac{a}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\
\end{array}
\end{array}
if c < -1.3e22 or 5.5999999999999998e-81 < c Initial program 53.4%
Taylor expanded in c around inf 73.3%
+-commutative73.3%
mul-1-neg73.3%
unsub-neg73.3%
*-commutative73.3%
unpow273.3%
times-frac79.5%
Simplified79.5%
if -1.3e22 < c < 5.5999999999999998e-81Initial program 68.9%
div-sub62.2%
*-commutative62.2%
add-sqr-sqrt62.2%
times-frac62.6%
fma-neg62.6%
hypot-def62.6%
hypot-def64.3%
associate-/l*71.4%
add-sqr-sqrt71.4%
pow271.4%
hypot-def71.4%
Applied egg-rr71.4%
Taylor expanded in c around 0 83.0%
+-commutative83.0%
mul-1-neg83.0%
unsub-neg83.0%
unpow283.0%
times-frac86.3%
Simplified86.3%
associate-*r/87.1%
sub-div87.9%
Applied egg-rr87.9%
Final simplification83.6%
(FPCore (a b c d) :precision binary64 (if (<= c -9.6e+24) (/ b c) (if (<= c 4e-19) (/ (- (* c (/ b d)) a) d) (/ b c))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -9.6e+24) {
tmp = b / c;
} else if (c <= 4e-19) {
tmp = ((c * (b / d)) - 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 (c <= (-9.6d+24)) then
tmp = b / c
else if (c <= 4d-19) then
tmp = ((c * (b / d)) - 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 (c <= -9.6e+24) {
tmp = b / c;
} else if (c <= 4e-19) {
tmp = ((c * (b / d)) - a) / d;
} else {
tmp = b / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -9.6e+24: tmp = b / c elif c <= 4e-19: tmp = ((c * (b / d)) - a) / d else: tmp = b / c return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -9.6e+24) tmp = Float64(b / c); elseif (c <= 4e-19) tmp = Float64(Float64(Float64(c * Float64(b / d)) - a) / d); else tmp = Float64(b / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -9.6e+24) tmp = b / c; elseif (c <= 4e-19) tmp = ((c * (b / d)) - a) / d; else tmp = b / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -9.6e+24], N[(b / c), $MachinePrecision], If[LessEqual[c, 4e-19], N[(N[(N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], N[(b / c), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -9.6 \cdot 10^{+24}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{elif}\;c \leq 4 \cdot 10^{-19}:\\
\;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if c < -9.6000000000000003e24 or 3.9999999999999999e-19 < c Initial program 51.2%
Taylor expanded in c around inf 72.7%
if -9.6000000000000003e24 < c < 3.9999999999999999e-19Initial program 69.4%
div-sub63.4%
*-commutative63.4%
add-sqr-sqrt63.4%
times-frac63.8%
fma-neg63.8%
hypot-def63.8%
hypot-def65.3%
associate-/l*72.5%
add-sqr-sqrt72.5%
pow272.5%
hypot-def72.5%
Applied egg-rr72.5%
Taylor expanded in c around 0 79.6%
+-commutative79.6%
mul-1-neg79.6%
unsub-neg79.6%
unpow279.6%
times-frac82.6%
Simplified82.6%
associate-*r/83.3%
sub-div84.1%
Applied egg-rr84.1%
Final simplification78.7%
(FPCore (a b c d) :precision binary64 (if (<= c -2.7e+24) (/ b c) (if (<= c 3.6e-78) (/ (- a) d) (/ b c))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -2.7e+24) {
tmp = b / c;
} else if (c <= 3.6e-78) {
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 (c <= (-2.7d+24)) then
tmp = b / c
else if (c <= 3.6d-78) 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 (c <= -2.7e+24) {
tmp = b / c;
} else if (c <= 3.6e-78) {
tmp = -a / d;
} else {
tmp = b / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -2.7e+24: tmp = b / c elif c <= 3.6e-78: tmp = -a / d else: tmp = b / c return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -2.7e+24) tmp = Float64(b / c); elseif (c <= 3.6e-78) tmp = Float64(Float64(-a) / d); else tmp = Float64(b / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -2.7e+24) tmp = b / c; elseif (c <= 3.6e-78) tmp = -a / d; else tmp = b / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -2.7e+24], N[(b / c), $MachinePrecision], If[LessEqual[c, 3.6e-78], N[((-a) / d), $MachinePrecision], N[(b / c), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -2.7 \cdot 10^{+24}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{elif}\;c \leq 3.6 \cdot 10^{-78}:\\
\;\;\;\;\frac{-a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if c < -2.7e24 or 3.6000000000000002e-78 < c Initial program 53.0%
Taylor expanded in c around inf 70.5%
if -2.7e24 < c < 3.6000000000000002e-78Initial program 69.1%
Taylor expanded in c around 0 70.2%
associate-*r/70.2%
neg-mul-170.2%
Simplified70.2%
Final simplification70.4%
(FPCore (a b c d) :precision binary64 (if (<= d -3.4e+158) (/ a d) (if (<= d 9e+189) (/ b c) (/ a d))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -3.4e+158) {
tmp = a / d;
} else if (d <= 9e+189) {
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 (d <= (-3.4d+158)) then
tmp = a / d
else if (d <= 9d+189) 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 (d <= -3.4e+158) {
tmp = a / d;
} else if (d <= 9e+189) {
tmp = b / c;
} else {
tmp = a / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -3.4e+158: tmp = a / d elif d <= 9e+189: tmp = b / c else: tmp = a / d return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -3.4e+158) tmp = Float64(a / d); elseif (d <= 9e+189) tmp = Float64(b / c); else tmp = Float64(a / d); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= -3.4e+158) tmp = a / d; elseif (d <= 9e+189) tmp = b / c; else tmp = a / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -3.4e+158], N[(a / d), $MachinePrecision], If[LessEqual[d, 9e+189], N[(b / c), $MachinePrecision], N[(a / d), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -3.4 \cdot 10^{+158}:\\
\;\;\;\;\frac{a}{d}\\
\mathbf{elif}\;d \leq 9 \cdot 10^{+189}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{d}\\
\end{array}
\end{array}
if d < -3.3999999999999999e158 or 8.99999999999999947e189 < d Initial program 35.6%
prod-diff35.6%
*-commutative35.6%
fma-def35.6%
associate-+l+35.6%
distribute-rgt-neg-in35.6%
fma-def35.6%
*-commutative35.6%
fma-udef35.6%
distribute-lft-neg-in35.6%
*-commutative35.6%
distribute-rgt-neg-in35.6%
fma-def35.6%
Applied egg-rr35.6%
Taylor expanded in c around 0 35.6%
distribute-lft1-in35.6%
metadata-eval35.6%
*-commutative35.6%
neg-mul-135.6%
distribute-rgt-neg-in35.6%
unpow235.6%
Simplified35.6%
times-frac93.8%
distribute-neg-frac93.8%
*-inverses93.8%
*-un-lft-identity93.8%
add-sqr-sqrt67.9%
sqrt-unprod59.5%
sqr-neg59.5%
sqrt-unprod35.3%
add-sqr-sqrt36.4%
clear-num36.4%
inv-pow36.4%
Applied egg-rr36.4%
unpow-136.4%
Simplified36.4%
Taylor expanded in d around 0 36.4%
if -3.3999999999999999e158 < d < 8.99999999999999947e189Initial program 67.9%
Taylor expanded in c around inf 53.2%
Final simplification49.5%
(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 60.9%
prod-diff60.7%
*-commutative60.7%
fma-def60.7%
associate-+l+60.7%
distribute-rgt-neg-in60.7%
fma-def60.6%
*-commutative60.6%
fma-udef60.7%
distribute-lft-neg-in60.7%
*-commutative60.7%
distribute-rgt-neg-in60.7%
fma-def60.6%
Applied egg-rr60.6%
Taylor expanded in c around 0 28.1%
distribute-lft1-in28.3%
metadata-eval28.3%
*-commutative28.3%
neg-mul-128.3%
distribute-rgt-neg-in28.3%
unpow228.3%
Simplified28.3%
times-frac45.2%
distribute-neg-frac45.2%
*-inverses45.2%
*-un-lft-identity45.2%
add-sqr-sqrt26.9%
sqrt-unprod23.5%
sqr-neg23.5%
sqrt-unprod9.2%
add-sqr-sqrt10.3%
clear-num10.3%
inv-pow10.3%
Applied egg-rr10.3%
unpow-110.3%
Simplified10.3%
Taylor expanded in d around 0 10.3%
Final simplification10.3%
(FPCore (a b c d) :precision binary64 (if (< (fabs d) (fabs c)) (/ (- b (* a (/ d c))) (+ c (* d (/ d c)))) (/ (+ (- a) (* b (/ c d))) (+ d (* c (/ c d))))))
double code(double a, double b, double c, double d) {
double tmp;
if (fabs(d) < fabs(c)) {
tmp = (b - (a * (d / c))) / (c + (d * (d / c)));
} else {
tmp = (-a + (b * (c / d))) / (d + (c * (c / d)));
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (abs(d) < abs(c)) then
tmp = (b - (a * (d / c))) / (c + (d * (d / c)))
else
tmp = (-a + (b * (c / d))) / (d + (c * (c / d)))
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (Math.abs(d) < Math.abs(c)) {
tmp = (b - (a * (d / c))) / (c + (d * (d / c)));
} else {
tmp = (-a + (b * (c / d))) / (d + (c * (c / d)));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if math.fabs(d) < math.fabs(c): tmp = (b - (a * (d / c))) / (c + (d * (d / c))) else: tmp = (-a + (b * (c / d))) / (d + (c * (c / d))) return tmp
function code(a, b, c, d) tmp = 0.0 if (abs(d) < abs(c)) tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / Float64(c + Float64(d * Float64(d / c)))); else tmp = Float64(Float64(Float64(-a) + Float64(b * Float64(c / d))) / Float64(d + Float64(c * Float64(c / d)))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (abs(d) < abs(c)) tmp = (b - (a * (d / c))) / (c + (d * (d / c))); else tmp = (-a + (b * (c / d))) / (d + (c * (c / d))); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Less[N[Abs[d], $MachinePrecision], N[Abs[c], $MachinePrecision]], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(c + N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[((-a) + N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(d + N[(c * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left|d\right| < \left|c\right|:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c + d \cdot \frac{d}{c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-a\right) + b \cdot \frac{c}{d}}{d + c \cdot \frac{c}{d}}\\
\end{array}
\end{array}
herbie shell --seed 2023287
(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))))