
(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 13 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 (sqrt (hypot d c))))
(fma
(/ c (hypot c d))
(/ b (hypot c d))
(* (/ (* a (/ d (hypot d c))) t_0) (/ -1.0 t_0)))))
double code(double a, double b, double c, double d) {
double t_0 = sqrt(hypot(d, c));
return fma((c / hypot(c, d)), (b / hypot(c, d)), (((a * (d / hypot(d, c))) / t_0) * (-1.0 / t_0)));
}
function code(a, b, c, d) t_0 = sqrt(hypot(d, c)) return fma(Float64(c / hypot(c, d)), Float64(b / hypot(c, d)), Float64(Float64(Float64(a * Float64(d / hypot(d, c))) / t_0) * Float64(-1.0 / t_0))) end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[Sqrt[N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]], $MachinePrecision]}, N[(N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] + N[(N[(N[(a * N[(d / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision] * N[(-1.0 / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\mathsf{hypot}\left(d, c\right)}\\
\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, \frac{a \cdot \frac{d}{\mathsf{hypot}\left(d, c\right)}}{t\_0} \cdot \frac{-1}{t\_0}\right)
\end{array}
\end{array}
Initial program 61.5%
div-sub59.4%
*-commutative59.4%
add-sqr-sqrt59.4%
times-frac62.2%
fma-neg62.2%
hypot-define62.2%
hypot-define78.5%
associate-/l*81.6%
add-sqr-sqrt81.6%
pow281.6%
hypot-define81.6%
Applied egg-rr81.6%
associate-*r/78.5%
unpow278.5%
associate-/r*86.7%
*-commutative86.7%
hypot-undefine78.6%
pow278.6%
+-commutative78.6%
pow278.6%
hypot-define86.7%
hypot-undefine78.6%
pow278.6%
+-commutative78.6%
pow278.6%
hypot-define86.7%
Applied egg-rr86.7%
*-un-lft-identity86.7%
add-sqr-sqrt86.6%
times-frac86.6%
associate-/l*96.3%
Applied egg-rr96.3%
associate-*r/86.6%
associate-*l/97.2%
*-commutative97.2%
Simplified97.2%
Final simplification97.2%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ c (hypot c d)))
(t_1 (/ b (hypot c d)))
(t_2 (sqrt (hypot d c))))
(if (<= d -3.2e+119)
(/ (* d (/ (- a) (hypot d c))) (hypot d c))
(if (<= d 2.26e+105)
(fma t_0 t_1 (/ (/ (* d a) (hypot d c)) (- (hypot d c))))
(fma t_0 t_1 (* (/ a t_2) (/ -1.0 t_2)))))))
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 = sqrt(hypot(d, c));
double tmp;
if (d <= -3.2e+119) {
tmp = (d * (-a / hypot(d, c))) / hypot(d, c);
} else if (d <= 2.26e+105) {
tmp = fma(t_0, t_1, (((d * a) / hypot(d, c)) / -hypot(d, c)));
} else {
tmp = fma(t_0, t_1, ((a / t_2) * (-1.0 / t_2)));
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(c / hypot(c, d)) t_1 = Float64(b / hypot(c, d)) t_2 = sqrt(hypot(d, c)) tmp = 0.0 if (d <= -3.2e+119) tmp = Float64(Float64(d * Float64(Float64(-a) / hypot(d, c))) / hypot(d, c)); elseif (d <= 2.26e+105) tmp = fma(t_0, t_1, Float64(Float64(Float64(d * a) / hypot(d, c)) / Float64(-hypot(d, c)))); else tmp = fma(t_0, t_1, Float64(Float64(a / t_2) * Float64(-1.0 / t_2))); 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[Sqrt[N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[d, -3.2e+119], N[(N[(d * N[((-a) / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.26e+105], N[(t$95$0 * t$95$1 + N[(N[(N[(d * a), $MachinePrecision] / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision] / (-N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision])), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * t$95$1 + N[(N[(a / t$95$2), $MachinePrecision] * N[(-1.0 / t$95$2), $MachinePrecision]), $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 := \sqrt{\mathsf{hypot}\left(d, c\right)}\\
\mathbf{if}\;d \leq -3.2 \cdot 10^{+119}:\\
\;\;\;\;\frac{d \cdot \frac{-a}{\mathsf{hypot}\left(d, c\right)}}{\mathsf{hypot}\left(d, c\right)}\\
\mathbf{elif}\;d \leq 2.26 \cdot 10^{+105}:\\
\;\;\;\;\mathsf{fma}\left(t\_0, t\_1, \frac{\frac{d \cdot a}{\mathsf{hypot}\left(d, c\right)}}{-\mathsf{hypot}\left(d, c\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t\_0, t\_1, \frac{a}{t\_2} \cdot \frac{-1}{t\_2}\right)\\
\end{array}
\end{array}
if d < -3.19999999999999989e119Initial program 26.7%
div-sub26.7%
*-commutative26.7%
add-sqr-sqrt26.7%
times-frac26.9%
fma-neg26.9%
hypot-define26.9%
hypot-define33.0%
associate-/l*40.5%
add-sqr-sqrt40.5%
pow240.5%
hypot-define40.5%
Applied egg-rr40.5%
Taylor expanded in b around 0 26.9%
associate-*r/26.9%
*-commutative26.9%
rem-square-sqrt26.9%
+-commutative26.9%
unpow226.9%
unpow226.9%
hypot-undefine26.9%
+-commutative26.9%
unpow226.9%
unpow226.9%
hypot-undefine26.9%
unpow226.9%
associate-/l*26.9%
neg-mul-126.9%
distribute-frac-neg226.9%
associate-/l*34.4%
Simplified34.4%
associate-*r/26.9%
unpow226.9%
hypot-undefine26.9%
hypot-undefine26.9%
add-sqr-sqrt26.9%
+-commutative26.9%
distribute-frac-neg226.9%
+-commutative26.9%
add-sqr-sqrt26.9%
hypot-undefine26.9%
hypot-undefine26.9%
associate-/l/48.5%
distribute-neg-frac248.5%
associate-/l*92.5%
Applied egg-rr92.5%
if -3.19999999999999989e119 < d < 2.2600000000000001e105Initial program 72.5%
div-sub69.6%
*-commutative69.6%
add-sqr-sqrt69.6%
times-frac72.9%
fma-neg72.9%
hypot-define72.9%
hypot-define90.9%
associate-/l*92.1%
add-sqr-sqrt92.1%
pow292.1%
hypot-define92.1%
Applied egg-rr92.1%
associate-*r/90.9%
unpow290.9%
associate-/r*95.3%
*-commutative95.3%
hypot-undefine91.0%
pow291.0%
+-commutative91.0%
pow291.0%
hypot-define95.3%
hypot-undefine91.0%
pow291.0%
+-commutative91.0%
pow291.0%
hypot-define95.3%
Applied egg-rr95.3%
if 2.2600000000000001e105 < d Initial program 37.5%
div-sub37.5%
*-commutative37.5%
add-sqr-sqrt37.5%
times-frac40.5%
fma-neg40.5%
hypot-define40.5%
hypot-define57.3%
associate-/l*65.9%
add-sqr-sqrt65.9%
pow265.9%
hypot-define65.9%
Applied egg-rr65.9%
associate-*r/57.3%
unpow257.3%
associate-/r*72.5%
*-commutative72.5%
hypot-undefine57.3%
pow257.3%
+-commutative57.3%
pow257.3%
hypot-define72.5%
hypot-undefine57.3%
pow257.3%
+-commutative57.3%
pow257.3%
hypot-define72.5%
Applied egg-rr72.5%
*-un-lft-identity72.5%
add-sqr-sqrt72.4%
times-frac72.3%
associate-/l*99.4%
Applied egg-rr99.4%
associate-*r/72.3%
associate-*l/99.4%
*-commutative99.4%
Simplified99.4%
Taylor expanded in d around inf 97.5%
Final simplification95.3%
(FPCore (a b c d)
:precision binary64
(if (<= d -1.55e+118)
(/ (* d (/ (- a) (hypot d c))) (hypot d c))
(if (<= d 1.15e+173)
(fma
(/ c (hypot c d))
(/ b (hypot c d))
(/ (/ (* d a) (hypot d c)) (- (hypot d c))))
(fma (* c (/ 1.0 d)) (/ b d) (/ a (- d))))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -1.55e+118) {
tmp = (d * (-a / hypot(d, c))) / hypot(d, c);
} else if (d <= 1.15e+173) {
tmp = fma((c / hypot(c, d)), (b / hypot(c, d)), (((d * a) / hypot(d, c)) / -hypot(d, c)));
} else {
tmp = fma((c * (1.0 / d)), (b / d), (a / -d));
}
return tmp;
}
function code(a, b, c, d) tmp = 0.0 if (d <= -1.55e+118) tmp = Float64(Float64(d * Float64(Float64(-a) / hypot(d, c))) / hypot(d, c)); elseif (d <= 1.15e+173) tmp = fma(Float64(c / hypot(c, d)), Float64(b / hypot(c, d)), Float64(Float64(Float64(d * a) / hypot(d, c)) / Float64(-hypot(d, c)))); else tmp = fma(Float64(c * Float64(1.0 / d)), Float64(b / d), Float64(a / Float64(-d))); end return tmp end
code[a_, b_, c_, d_] := If[LessEqual[d, -1.55e+118], N[(N[(d * N[((-a) / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.15e+173], N[(N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] + N[(N[(N[(d * a), $MachinePrecision] / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision] / (-N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision])), $MachinePrecision]), $MachinePrecision], N[(N[(c * N[(1.0 / d), $MachinePrecision]), $MachinePrecision] * N[(b / d), $MachinePrecision] + N[(a / (-d)), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.55 \cdot 10^{+118}:\\
\;\;\;\;\frac{d \cdot \frac{-a}{\mathsf{hypot}\left(d, c\right)}}{\mathsf{hypot}\left(d, c\right)}\\
\mathbf{elif}\;d \leq 1.15 \cdot 10^{+173}:\\
\;\;\;\;\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, \frac{\frac{d \cdot a}{\mathsf{hypot}\left(d, c\right)}}{-\mathsf{hypot}\left(d, c\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(c \cdot \frac{1}{d}, \frac{b}{d}, \frac{a}{-d}\right)\\
\end{array}
\end{array}
if d < -1.54999999999999993e118Initial program 26.7%
div-sub26.7%
*-commutative26.7%
add-sqr-sqrt26.7%
times-frac26.9%
fma-neg26.9%
hypot-define26.9%
hypot-define33.0%
associate-/l*40.5%
add-sqr-sqrt40.5%
pow240.5%
hypot-define40.5%
Applied egg-rr40.5%
Taylor expanded in b around 0 26.9%
associate-*r/26.9%
*-commutative26.9%
rem-square-sqrt26.9%
+-commutative26.9%
unpow226.9%
unpow226.9%
hypot-undefine26.9%
+-commutative26.9%
unpow226.9%
unpow226.9%
hypot-undefine26.9%
unpow226.9%
associate-/l*26.9%
neg-mul-126.9%
distribute-frac-neg226.9%
associate-/l*34.4%
Simplified34.4%
associate-*r/26.9%
unpow226.9%
hypot-undefine26.9%
hypot-undefine26.9%
add-sqr-sqrt26.9%
+-commutative26.9%
distribute-frac-neg226.9%
+-commutative26.9%
add-sqr-sqrt26.9%
hypot-undefine26.9%
hypot-undefine26.9%
associate-/l/48.5%
distribute-neg-frac248.5%
associate-/l*92.5%
Applied egg-rr92.5%
if -1.54999999999999993e118 < d < 1.14999999999999997e173Initial program 71.3%
div-sub68.5%
*-commutative68.5%
add-sqr-sqrt68.5%
times-frac72.2%
fma-neg72.2%
hypot-define72.2%
hypot-define90.3%
associate-/l*91.9%
add-sqr-sqrt91.9%
pow291.9%
hypot-define91.9%
Applied egg-rr91.9%
associate-*r/90.3%
unpow290.3%
associate-/r*95.0%
*-commutative95.0%
hypot-undefine90.4%
pow290.4%
+-commutative90.4%
pow290.4%
hypot-define95.0%
hypot-undefine90.4%
pow290.4%
+-commutative90.4%
pow290.4%
hypot-define95.0%
Applied egg-rr95.0%
if 1.14999999999999997e173 < d Initial program 34.7%
Taylor expanded in c around 0 70.4%
+-commutative70.4%
mul-1-neg70.4%
unsub-neg70.4%
*-commutative70.4%
associate-/l*76.7%
Simplified76.7%
*-un-lft-identity76.7%
pow276.7%
times-frac89.8%
Applied egg-rr89.8%
associate-*r*96.8%
fma-neg96.8%
Applied egg-rr96.8%
Final simplification94.9%
(FPCore (a b c d)
:precision binary64
(if (<= d -1.75e+121)
(/ (* d (/ (- a) (hypot d c))) (hypot d c))
(if (<= d 9e+141)
(fma
(/ c (hypot c d))
(/ b (hypot c d))
(* (/ d (pow (hypot c d) 2.0)) (- a)))
(fma (* c (/ 1.0 d)) (/ b d) (/ a (- d))))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -1.75e+121) {
tmp = (d * (-a / hypot(d, c))) / hypot(d, c);
} else if (d <= 9e+141) {
tmp = fma((c / hypot(c, d)), (b / hypot(c, d)), ((d / pow(hypot(c, d), 2.0)) * -a));
} else {
tmp = fma((c * (1.0 / d)), (b / d), (a / -d));
}
return tmp;
}
function code(a, b, c, d) tmp = 0.0 if (d <= -1.75e+121) tmp = Float64(Float64(d * Float64(Float64(-a) / hypot(d, c))) / hypot(d, c)); elseif (d <= 9e+141) tmp = fma(Float64(c / hypot(c, d)), Float64(b / hypot(c, d)), Float64(Float64(d / (hypot(c, d) ^ 2.0)) * Float64(-a))); else tmp = fma(Float64(c * Float64(1.0 / d)), Float64(b / d), Float64(a / Float64(-d))); end return tmp end
code[a_, b_, c_, d_] := If[LessEqual[d, -1.75e+121], N[(N[(d * N[((-a) / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 9e+141], 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[Power[N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * (-a)), $MachinePrecision]), $MachinePrecision], N[(N[(c * N[(1.0 / d), $MachinePrecision]), $MachinePrecision] * N[(b / d), $MachinePrecision] + N[(a / (-d)), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.75 \cdot 10^{+121}:\\
\;\;\;\;\frac{d \cdot \frac{-a}{\mathsf{hypot}\left(d, c\right)}}{\mathsf{hypot}\left(d, c\right)}\\
\mathbf{elif}\;d \leq 9 \cdot 10^{+141}:\\
\;\;\;\;\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, \frac{d}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}} \cdot \left(-a\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(c \cdot \frac{1}{d}, \frac{b}{d}, \frac{a}{-d}\right)\\
\end{array}
\end{array}
if d < -1.75e121Initial program 27.5%
div-sub27.5%
*-commutative27.5%
add-sqr-sqrt27.5%
times-frac27.6%
fma-neg27.6%
hypot-define27.6%
hypot-define33.9%
associate-/l*38.6%
add-sqr-sqrt38.6%
pow238.6%
hypot-define38.6%
Applied egg-rr38.6%
Taylor expanded in b around 0 27.6%
associate-*r/27.6%
*-commutative27.6%
rem-square-sqrt27.6%
+-commutative27.6%
unpow227.6%
unpow227.6%
hypot-undefine27.6%
+-commutative27.6%
unpow227.6%
unpow227.6%
hypot-undefine27.6%
unpow227.6%
associate-/l*27.6%
neg-mul-127.6%
distribute-frac-neg227.6%
associate-/l*32.3%
Simplified32.3%
associate-*r/27.6%
unpow227.6%
hypot-undefine27.6%
hypot-undefine27.6%
add-sqr-sqrt27.6%
+-commutative27.6%
distribute-frac-neg227.6%
+-commutative27.6%
add-sqr-sqrt27.6%
hypot-undefine27.6%
hypot-undefine27.6%
associate-/l/49.9%
distribute-neg-frac249.9%
associate-/l*92.3%
Applied egg-rr92.3%
if -1.75e121 < d < 9.0000000000000003e141Initial program 71.2%
div-sub68.4%
*-commutative68.4%
add-sqr-sqrt68.4%
times-frac72.1%
fma-neg72.1%
hypot-define72.1%
hypot-define90.2%
associate-/l*92.3%
add-sqr-sqrt92.3%
pow292.3%
hypot-define92.3%
Applied egg-rr92.3%
if 9.0000000000000003e141 < d Initial program 38.6%
Taylor expanded in c around 0 71.9%
+-commutative71.9%
mul-1-neg71.9%
unsub-neg71.9%
*-commutative71.9%
associate-/l*77.3%
Simplified77.3%
*-un-lft-identity77.3%
pow277.3%
times-frac88.5%
Applied egg-rr88.5%
associate-*r*94.7%
fma-neg94.7%
Applied egg-rr94.7%
Final simplification92.6%
(FPCore (a b c d) :precision binary64 (if (<= (/ (- (* c b) (* d a)) (+ (* c c) (* d d))) INFINITY) (* (/ 1.0 (hypot c d)) (/ (fma b c (* d (- a))) (hypot c d))) (/ (* b (/ c (hypot d c))) (hypot d c))))
double code(double a, double b, double c, double d) {
double tmp;
if ((((c * b) - (d * a)) / ((c * c) + (d * d))) <= ((double) INFINITY)) {
tmp = (1.0 / hypot(c, d)) * (fma(b, c, (d * -a)) / hypot(c, d));
} else {
tmp = (b * (c / hypot(d, c))) / hypot(d, c);
}
return tmp;
}
function code(a, b, c, d) tmp = 0.0 if (Float64(Float64(Float64(c * b) - Float64(d * a)) / 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(b * Float64(c / hypot(d, c))) / hypot(d, c)); end return tmp end
code[a_, b_, c_, d_] := If[LessEqual[N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $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[(b * N[(c / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{c \cdot b - d \cdot a}{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{b \cdot \frac{c}{\mathsf{hypot}\left(d, c\right)}}{\mathsf{hypot}\left(d, c\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.1%
hypot-define77.1%
fma-neg77.1%
distribute-rgt-neg-in77.1%
hypot-define94.0%
Applied egg-rr94.0%
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 b around inf 1.5%
associate-/l*4.2%
+-commutative4.2%
unpow24.2%
fma-undefine4.2%
Simplified4.2%
associate-*r/1.5%
*-commutative1.5%
add-sqr-sqrt1.5%
sqrt-div0.6%
fma-undefine0.6%
+-commutative0.6%
pow20.6%
hypot-undefine0.6%
sqrt-div0.6%
fma-undefine0.6%
+-commutative0.6%
pow20.6%
hypot-undefine1.2%
times-frac0.6%
add-sqr-sqrt1.5%
frac-times59.6%
associate-*r/59.5%
Applied egg-rr59.5%
Final simplification87.0%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (* b (/ c (hypot d c))) (hypot d c))))
(if (<= c -3.1e+37)
t_0
(if (<= c -8.4e-126)
(/ (- (* c b) (* d a)) (+ (* c c) (* d d)))
(if (<= c 5.4e+26) (- (/ (/ (* c b) d) d) (/ a d)) t_0)))))
double code(double a, double b, double c, double d) {
double t_0 = (b * (c / hypot(d, c))) / hypot(d, c);
double tmp;
if (c <= -3.1e+37) {
tmp = t_0;
} else if (c <= -8.4e-126) {
tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
} else if (c <= 5.4e+26) {
tmp = (((c * b) / d) / d) - (a / d);
} else {
tmp = t_0;
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = (b * (c / Math.hypot(d, c))) / Math.hypot(d, c);
double tmp;
if (c <= -3.1e+37) {
tmp = t_0;
} else if (c <= -8.4e-126) {
tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
} else if (c <= 5.4e+26) {
tmp = (((c * b) / d) / d) - (a / d);
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b, c, d): t_0 = (b * (c / math.hypot(d, c))) / math.hypot(d, c) tmp = 0 if c <= -3.1e+37: tmp = t_0 elif c <= -8.4e-126: tmp = ((c * b) - (d * a)) / ((c * c) + (d * d)) elif c <= 5.4e+26: tmp = (((c * b) / d) / d) - (a / d) else: tmp = t_0 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(b * Float64(c / hypot(d, c))) / hypot(d, c)) tmp = 0.0 if (c <= -3.1e+37) tmp = t_0; elseif (c <= -8.4e-126) tmp = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d))); elseif (c <= 5.4e+26) tmp = Float64(Float64(Float64(Float64(c * b) / d) / d) - Float64(a / d)); else tmp = t_0; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (b * (c / hypot(d, c))) / hypot(d, c); tmp = 0.0; if (c <= -3.1e+37) tmp = t_0; elseif (c <= -8.4e-126) tmp = ((c * b) - (d * a)) / ((c * c) + (d * d)); elseif (c <= 5.4e+26) tmp = (((c * b) / d) / d) - (a / d); else tmp = t_0; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(b * N[(c / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -3.1e+37], t$95$0, If[LessEqual[c, -8.4e-126], 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, 5.4e+26], N[(N[(N[(N[(c * b), $MachinePrecision] / d), $MachinePrecision] / d), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b \cdot \frac{c}{\mathsf{hypot}\left(d, c\right)}}{\mathsf{hypot}\left(d, c\right)}\\
\mathbf{if}\;c \leq -3.1 \cdot 10^{+37}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq -8.4 \cdot 10^{-126}:\\
\;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;c \leq 5.4 \cdot 10^{+26}:\\
\;\;\;\;\frac{\frac{c \cdot b}{d}}{d} - \frac{a}{d}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if c < -3.1000000000000002e37 or 5.4e26 < c Initial program 47.6%
Taylor expanded in b around inf 44.2%
associate-/l*49.0%
+-commutative49.0%
unpow249.0%
fma-undefine49.0%
Simplified49.0%
associate-*r/44.2%
*-commutative44.2%
add-sqr-sqrt30.7%
sqrt-div18.8%
fma-undefine18.8%
+-commutative18.8%
pow218.8%
hypot-undefine18.8%
sqrt-div18.8%
fma-undefine18.8%
+-commutative18.8%
pow218.8%
hypot-undefine25.7%
times-frac18.8%
add-sqr-sqrt44.2%
frac-times82.9%
associate-*r/82.9%
Applied egg-rr82.9%
if -3.1000000000000002e37 < c < -8.3999999999999994e-126Initial program 82.6%
if -8.3999999999999994e-126 < c < 5.4e26Initial program 72.9%
Taylor expanded in c around 0 81.7%
+-commutative81.7%
mul-1-neg81.7%
unsub-neg81.7%
*-commutative81.7%
associate-/l*81.0%
Simplified81.0%
pow281.0%
associate-*r/81.7%
associate-/r*88.3%
Applied egg-rr88.3%
Final simplification85.0%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (- (/ b c) (* a (/ d (pow c 2.0))))))
(if (<= c -5e+69)
t_0
(if (<= c -8e-126)
(/ (- (* c b) (* d a)) (+ (* c c) (* d d)))
(if (<= c 5.4e+46) (- (/ (/ (* c b) d) d) (/ a d)) t_0)))))
double code(double a, double b, double c, double d) {
double t_0 = (b / c) - (a * (d / pow(c, 2.0)));
double tmp;
if (c <= -5e+69) {
tmp = t_0;
} else if (c <= -8e-126) {
tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
} else if (c <= 5.4e+46) {
tmp = (((c * b) / d) / d) - (a / d);
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: tmp
t_0 = (b / c) - (a * (d / (c ** 2.0d0)))
if (c <= (-5d+69)) then
tmp = t_0
else if (c <= (-8d-126)) then
tmp = ((c * b) - (d * a)) / ((c * c) + (d * d))
else if (c <= 5.4d+46) then
tmp = (((c * b) / d) / d) - (a / d)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = (b / c) - (a * (d / Math.pow(c, 2.0)));
double tmp;
if (c <= -5e+69) {
tmp = t_0;
} else if (c <= -8e-126) {
tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
} else if (c <= 5.4e+46) {
tmp = (((c * b) / d) / d) - (a / d);
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b, c, d): t_0 = (b / c) - (a * (d / math.pow(c, 2.0))) tmp = 0 if c <= -5e+69: tmp = t_0 elif c <= -8e-126: tmp = ((c * b) - (d * a)) / ((c * c) + (d * d)) elif c <= 5.4e+46: tmp = (((c * b) / d) / d) - (a / d) else: tmp = t_0 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(b / c) - Float64(a * Float64(d / (c ^ 2.0)))) tmp = 0.0 if (c <= -5e+69) tmp = t_0; elseif (c <= -8e-126) tmp = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d))); elseif (c <= 5.4e+46) tmp = Float64(Float64(Float64(Float64(c * b) / d) / d) - Float64(a / d)); else tmp = t_0; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (b / c) - (a * (d / (c ^ 2.0))); tmp = 0.0; if (c <= -5e+69) tmp = t_0; elseif (c <= -8e-126) tmp = ((c * b) - (d * a)) / ((c * c) + (d * d)); elseif (c <= 5.4e+46) tmp = (((c * b) / d) / d) - (a / d); else tmp = t_0; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(b / c), $MachinePrecision] - N[(a * N[(d / N[Power[c, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -5e+69], t$95$0, If[LessEqual[c, -8e-126], 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, 5.4e+46], N[(N[(N[(N[(c * b), $MachinePrecision] / d), $MachinePrecision] / d), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b}{c} - a \cdot \frac{d}{{c}^{2}}\\
\mathbf{if}\;c \leq -5 \cdot 10^{+69}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq -8 \cdot 10^{-126}:\\
\;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;c \leq 5.4 \cdot 10^{+46}:\\
\;\;\;\;\frac{\frac{c \cdot b}{d}}{d} - \frac{a}{d}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if c < -5.00000000000000036e69 or 5.4000000000000003e46 < c Initial program 46.1%
Taylor expanded in c around inf 78.2%
+-commutative78.2%
mul-1-neg78.2%
unsub-neg78.2%
associate-/l*77.8%
Simplified77.8%
if -5.00000000000000036e69 < c < -7.9999999999999996e-126Initial program 78.4%
if -7.9999999999999996e-126 < c < 5.4000000000000003e46Initial program 73.2%
Taylor expanded in c around 0 81.9%
+-commutative81.9%
mul-1-neg81.9%
unsub-neg81.9%
*-commutative81.9%
associate-/l*81.2%
Simplified81.2%
pow281.2%
associate-*r/81.9%
associate-/r*88.4%
Applied egg-rr88.4%
Final simplification82.1%
(FPCore (a b c d)
:precision binary64
(if (<= c -3.4e+65)
(/ b c)
(if (<= c -2.75e-9)
(- (* c (/ (/ b d) d)) (/ a d))
(if (or (<= c -1.2e-98) (not (<= c 1.25e+44)))
(/ b c)
(- (/ (/ (* c b) d) d) (/ a d))))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -3.4e+65) {
tmp = b / c;
} else if (c <= -2.75e-9) {
tmp = (c * ((b / d) / d)) - (a / d);
} else if ((c <= -1.2e-98) || !(c <= 1.25e+44)) {
tmp = b / c;
} else {
tmp = (((c * b) / d) / d) - (a / d);
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (c <= (-3.4d+65)) then
tmp = b / c
else if (c <= (-2.75d-9)) then
tmp = (c * ((b / d) / d)) - (a / d)
else if ((c <= (-1.2d-98)) .or. (.not. (c <= 1.25d+44))) then
tmp = b / c
else
tmp = (((c * b) / d) / d) - (a / d)
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -3.4e+65) {
tmp = b / c;
} else if (c <= -2.75e-9) {
tmp = (c * ((b / d) / d)) - (a / d);
} else if ((c <= -1.2e-98) || !(c <= 1.25e+44)) {
tmp = b / c;
} else {
tmp = (((c * b) / d) / d) - (a / d);
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -3.4e+65: tmp = b / c elif c <= -2.75e-9: tmp = (c * ((b / d) / d)) - (a / d) elif (c <= -1.2e-98) or not (c <= 1.25e+44): tmp = b / c else: tmp = (((c * b) / d) / d) - (a / d) return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -3.4e+65) tmp = Float64(b / c); elseif (c <= -2.75e-9) tmp = Float64(Float64(c * Float64(Float64(b / d) / d)) - Float64(a / d)); elseif ((c <= -1.2e-98) || !(c <= 1.25e+44)) tmp = Float64(b / c); else tmp = Float64(Float64(Float64(Float64(c * b) / d) / d) - Float64(a / d)); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -3.4e+65) tmp = b / c; elseif (c <= -2.75e-9) tmp = (c * ((b / d) / d)) - (a / d); elseif ((c <= -1.2e-98) || ~((c <= 1.25e+44))) tmp = b / c; else tmp = (((c * b) / d) / d) - (a / d); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -3.4e+65], N[(b / c), $MachinePrecision], If[LessEqual[c, -2.75e-9], N[(N[(c * N[(N[(b / d), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[c, -1.2e-98], N[Not[LessEqual[c, 1.25e+44]], $MachinePrecision]], N[(b / c), $MachinePrecision], N[(N[(N[(N[(c * b), $MachinePrecision] / d), $MachinePrecision] / d), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -3.4 \cdot 10^{+65}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{elif}\;c \leq -2.75 \cdot 10^{-9}:\\
\;\;\;\;c \cdot \frac{\frac{b}{d}}{d} - \frac{a}{d}\\
\mathbf{elif}\;c \leq -1.2 \cdot 10^{-98} \lor \neg \left(c \leq 1.25 \cdot 10^{+44}\right):\\
\;\;\;\;\frac{b}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{c \cdot b}{d}}{d} - \frac{a}{d}\\
\end{array}
\end{array}
if c < -3.3999999999999999e65 or -2.7499999999999998e-9 < c < -1.20000000000000002e-98 or 1.2499999999999999e44 < c Initial program 50.3%
Taylor expanded in c around inf 74.2%
if -3.3999999999999999e65 < c < -2.7499999999999998e-9Initial program 69.2%
Taylor expanded in c around 0 51.8%
+-commutative51.8%
mul-1-neg51.8%
unsub-neg51.8%
*-commutative51.8%
associate-/l*63.8%
Simplified63.8%
*-un-lft-identity63.8%
pow263.8%
times-frac63.8%
Applied egg-rr63.8%
associate-*l/63.8%
*-un-lft-identity63.8%
Applied egg-rr63.8%
if -1.20000000000000002e-98 < c < 1.2499999999999999e44Initial program 74.4%
Taylor expanded in c around 0 80.0%
+-commutative80.0%
mul-1-neg80.0%
unsub-neg80.0%
*-commutative80.0%
associate-/l*79.4%
Simplified79.4%
pow279.4%
associate-*r/80.0%
associate-/r*86.3%
Applied egg-rr86.3%
Final simplification78.5%
(FPCore (a b c d)
:precision binary64
(if (<= c -4.6e+65)
(/ b c)
(if (<= c -1.08e-7)
(- (* c (/ (/ b d) d)) (/ a d))
(if (<= c -1.05e-98)
(/ (* c b) (+ (* c c) (* d d)))
(if (<= c 7.8e+45) (- (/ (/ (* c b) d) d) (/ a d)) (/ b c))))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -4.6e+65) {
tmp = b / c;
} else if (c <= -1.08e-7) {
tmp = (c * ((b / d) / d)) - (a / d);
} else if (c <= -1.05e-98) {
tmp = (c * b) / ((c * c) + (d * d));
} else if (c <= 7.8e+45) {
tmp = (((c * b) / d) / 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 <= (-4.6d+65)) then
tmp = b / c
else if (c <= (-1.08d-7)) then
tmp = (c * ((b / d) / d)) - (a / d)
else if (c <= (-1.05d-98)) then
tmp = (c * b) / ((c * c) + (d * d))
else if (c <= 7.8d+45) then
tmp = (((c * b) / d) / 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 <= -4.6e+65) {
tmp = b / c;
} else if (c <= -1.08e-7) {
tmp = (c * ((b / d) / d)) - (a / d);
} else if (c <= -1.05e-98) {
tmp = (c * b) / ((c * c) + (d * d));
} else if (c <= 7.8e+45) {
tmp = (((c * b) / d) / d) - (a / d);
} else {
tmp = b / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -4.6e+65: tmp = b / c elif c <= -1.08e-7: tmp = (c * ((b / d) / d)) - (a / d) elif c <= -1.05e-98: tmp = (c * b) / ((c * c) + (d * d)) elif c <= 7.8e+45: tmp = (((c * b) / d) / d) - (a / d) else: tmp = b / c return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -4.6e+65) tmp = Float64(b / c); elseif (c <= -1.08e-7) tmp = Float64(Float64(c * Float64(Float64(b / d) / d)) - Float64(a / d)); elseif (c <= -1.05e-98) tmp = Float64(Float64(c * b) / Float64(Float64(c * c) + Float64(d * d))); elseif (c <= 7.8e+45) tmp = Float64(Float64(Float64(Float64(c * b) / d) / d) - 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 <= -4.6e+65) tmp = b / c; elseif (c <= -1.08e-7) tmp = (c * ((b / d) / d)) - (a / d); elseif (c <= -1.05e-98) tmp = (c * b) / ((c * c) + (d * d)); elseif (c <= 7.8e+45) tmp = (((c * b) / d) / d) - (a / d); else tmp = b / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -4.6e+65], N[(b / c), $MachinePrecision], If[LessEqual[c, -1.08e-7], N[(N[(c * N[(N[(b / d), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -1.05e-98], N[(N[(c * b), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 7.8e+45], N[(N[(N[(N[(c * b), $MachinePrecision] / d), $MachinePrecision] / d), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], N[(b / c), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -4.6 \cdot 10^{+65}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{elif}\;c \leq -1.08 \cdot 10^{-7}:\\
\;\;\;\;c \cdot \frac{\frac{b}{d}}{d} - \frac{a}{d}\\
\mathbf{elif}\;c \leq -1.05 \cdot 10^{-98}:\\
\;\;\;\;\frac{c \cdot b}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;c \leq 7.8 \cdot 10^{+45}:\\
\;\;\;\;\frac{\frac{c \cdot b}{d}}{d} - \frac{a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if c < -4.6e65 or 7.7999999999999999e45 < c Initial program 46.1%
Taylor expanded in c around inf 76.1%
if -4.6e65 < c < -1.08000000000000001e-7Initial program 69.2%
Taylor expanded in c around 0 51.8%
+-commutative51.8%
mul-1-neg51.8%
unsub-neg51.8%
*-commutative51.8%
associate-/l*63.8%
Simplified63.8%
*-un-lft-identity63.8%
pow263.8%
times-frac63.8%
Applied egg-rr63.8%
associate-*l/63.8%
*-un-lft-identity63.8%
Applied egg-rr63.8%
if -1.08000000000000001e-7 < c < -1.04999999999999996e-98Initial program 80.9%
Taylor expanded in b around inf 62.5%
*-commutative62.5%
Simplified62.5%
if -1.04999999999999996e-98 < c < 7.7999999999999999e45Initial program 74.4%
Taylor expanded in c around 0 80.0%
+-commutative80.0%
mul-1-neg80.0%
unsub-neg80.0%
*-commutative80.0%
associate-/l*79.4%
Simplified79.4%
pow279.4%
associate-*r/80.0%
associate-/r*86.3%
Applied egg-rr86.3%
Final simplification78.7%
(FPCore (a b c d)
:precision binary64
(if (<= c -2.25e+106)
(/ b c)
(if (<= c -1.9e-127)
(/ (- (* c b) (* d a)) (+ (* c c) (* d d)))
(if (<= c 7.8e+47) (- (/ (/ (* c b) d) d) (/ a d)) (/ b c)))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -2.25e+106) {
tmp = b / c;
} else if (c <= -1.9e-127) {
tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
} else if (c <= 7.8e+47) {
tmp = (((c * b) / d) / 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 <= (-2.25d+106)) then
tmp = b / c
else if (c <= (-1.9d-127)) then
tmp = ((c * b) - (d * a)) / ((c * c) + (d * d))
else if (c <= 7.8d+47) then
tmp = (((c * b) / d) / 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 <= -2.25e+106) {
tmp = b / c;
} else if (c <= -1.9e-127) {
tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
} else if (c <= 7.8e+47) {
tmp = (((c * b) / d) / d) - (a / d);
} else {
tmp = b / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -2.25e+106: tmp = b / c elif c <= -1.9e-127: tmp = ((c * b) - (d * a)) / ((c * c) + (d * d)) elif c <= 7.8e+47: tmp = (((c * b) / d) / d) - (a / d) else: tmp = b / c return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -2.25e+106) tmp = Float64(b / c); elseif (c <= -1.9e-127) tmp = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d))); elseif (c <= 7.8e+47) tmp = Float64(Float64(Float64(Float64(c * b) / d) / d) - 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.25e+106) tmp = b / c; elseif (c <= -1.9e-127) tmp = ((c * b) - (d * a)) / ((c * c) + (d * d)); elseif (c <= 7.8e+47) tmp = (((c * b) / d) / d) - (a / d); else tmp = b / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -2.25e+106], N[(b / c), $MachinePrecision], If[LessEqual[c, -1.9e-127], 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, 7.8e+47], N[(N[(N[(N[(c * b), $MachinePrecision] / d), $MachinePrecision] / d), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], N[(b / c), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -2.25 \cdot 10^{+106}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{elif}\;c \leq -1.9 \cdot 10^{-127}:\\
\;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;c \leq 7.8 \cdot 10^{+47}:\\
\;\;\;\;\frac{\frac{c \cdot b}{d}}{d} - \frac{a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if c < -2.2499999999999998e106 or 7.8000000000000005e47 < c Initial program 43.4%
Taylor expanded in c around inf 76.1%
if -2.2499999999999998e106 < c < -1.90000000000000001e-127Initial program 78.5%
if -1.90000000000000001e-127 < c < 7.8000000000000005e47Initial program 73.2%
Taylor expanded in c around 0 81.9%
+-commutative81.9%
mul-1-neg81.9%
unsub-neg81.9%
*-commutative81.9%
associate-/l*81.2%
Simplified81.2%
pow281.2%
associate-*r/81.9%
associate-/r*88.4%
Applied egg-rr88.4%
Final simplification81.4%
(FPCore (a b c d)
:precision binary64
(if (or (<= c -2.6e+46)
(and (not (<= c -7.5e-5)) (or (<= c -1.2e-98) (not (<= c 1.25e+44)))))
(/ b c)
(/ a (- d))))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -2.6e+46) || (!(c <= -7.5e-5) && ((c <= -1.2e-98) || !(c <= 1.25e+44)))) {
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+46)) .or. (.not. (c <= (-7.5d-5))) .and. (c <= (-1.2d-98)) .or. (.not. (c <= 1.25d+44))) 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+46) || (!(c <= -7.5e-5) && ((c <= -1.2e-98) || !(c <= 1.25e+44)))) {
tmp = b / c;
} else {
tmp = a / -d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -2.6e+46) or (not (c <= -7.5e-5) and ((c <= -1.2e-98) or not (c <= 1.25e+44))): tmp = b / c else: tmp = a / -d return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -2.6e+46) || (!(c <= -7.5e-5) && ((c <= -1.2e-98) || !(c <= 1.25e+44)))) tmp = Float64(b / c); else tmp = Float64(a / Float64(-d)); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((c <= -2.6e+46) || (~((c <= -7.5e-5)) && ((c <= -1.2e-98) || ~((c <= 1.25e+44))))) tmp = b / c; else tmp = a / -d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -2.6e+46], And[N[Not[LessEqual[c, -7.5e-5]], $MachinePrecision], Or[LessEqual[c, -1.2e-98], N[Not[LessEqual[c, 1.25e+44]], $MachinePrecision]]]], N[(b / c), $MachinePrecision], N[(a / (-d)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -2.6 \cdot 10^{+46} \lor \neg \left(c \leq -7.5 \cdot 10^{-5}\right) \land \left(c \leq -1.2 \cdot 10^{-98} \lor \neg \left(c \leq 1.25 \cdot 10^{+44}\right)\right):\\
\;\;\;\;\frac{b}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{-d}\\
\end{array}
\end{array}
if c < -2.60000000000000013e46 or -7.49999999999999934e-5 < c < -1.20000000000000002e-98 or 1.2499999999999999e44 < c Initial program 51.4%
Taylor expanded in c around inf 72.8%
if -2.60000000000000013e46 < c < -7.49999999999999934e-5 or -1.20000000000000002e-98 < c < 1.2499999999999999e44Initial program 73.8%
Taylor expanded in c around 0 67.3%
associate-*r/67.3%
neg-mul-167.3%
Simplified67.3%
Final simplification70.3%
(FPCore (a b c d) :precision binary64 (if (or (<= c -2.1e+68) (not (<= c 2.6e+47))) (/ b c) (- (* c (/ (/ b d) d)) (/ a d))))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -2.1e+68) || !(c <= 2.6e+47)) {
tmp = b / c;
} else {
tmp = (c * ((b / d) / d)) - (a / d);
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if ((c <= (-2.1d+68)) .or. (.not. (c <= 2.6d+47))) then
tmp = b / c
else
tmp = (c * ((b / d) / d)) - (a / d)
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -2.1e+68) || !(c <= 2.6e+47)) {
tmp = b / c;
} else {
tmp = (c * ((b / d) / d)) - (a / d);
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -2.1e+68) or not (c <= 2.6e+47): tmp = b / c else: tmp = (c * ((b / d) / d)) - (a / d) return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -2.1e+68) || !(c <= 2.6e+47)) tmp = Float64(b / c); else tmp = Float64(Float64(c * Float64(Float64(b / d) / d)) - Float64(a / d)); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((c <= -2.1e+68) || ~((c <= 2.6e+47))) tmp = b / c; else tmp = (c * ((b / d) / d)) - (a / d); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -2.1e+68], N[Not[LessEqual[c, 2.6e+47]], $MachinePrecision]], N[(b / c), $MachinePrecision], N[(N[(c * N[(N[(b / d), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -2.1 \cdot 10^{+68} \lor \neg \left(c \leq 2.6 \cdot 10^{+47}\right):\\
\;\;\;\;\frac{b}{c}\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{\frac{b}{d}}{d} - \frac{a}{d}\\
\end{array}
\end{array}
if c < -2.10000000000000001e68 or 2.60000000000000003e47 < c Initial program 46.1%
Taylor expanded in c around inf 76.1%
if -2.10000000000000001e68 < c < 2.60000000000000003e47Initial program 74.6%
Taylor expanded in c around 0 71.5%
+-commutative71.5%
mul-1-neg71.5%
unsub-neg71.5%
*-commutative71.5%
associate-/l*72.4%
Simplified72.4%
*-un-lft-identity72.4%
pow272.4%
times-frac73.1%
Applied egg-rr73.1%
associate-*l/73.1%
*-un-lft-identity73.1%
Applied egg-rr73.1%
Final simplification74.5%
(FPCore (a b c d) :precision binary64 (/ b c))
double code(double a, double b, double c, double d) {
return b / c;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = b / c
end function
public static double code(double a, double b, double c, double d) {
return b / c;
}
def code(a, b, c, d): return b / c
function code(a, b, c, d) return Float64(b / c) end
function tmp = code(a, b, c, d) tmp = b / c; end
code[a_, b_, c_, d_] := N[(b / c), $MachinePrecision]
\begin{array}{l}
\\
\frac{b}{c}
\end{array}
Initial program 61.5%
Taylor expanded in c around inf 46.8%
Final simplification46.8%
(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 2024053
(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))))