
(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
(if (or (<= a -7.4e+33) (not (<= a 5e+46)))
(* (/ (- (* b (/ c a)) d) (hypot d c)) (/ a (hypot d c)))
(fma
(/ c (hypot c d))
(/ b (hypot c d))
(* a (/ (- d) (pow (hypot c d) 2.0))))))
double code(double a, double b, double c, double d) {
double tmp;
if ((a <= -7.4e+33) || !(a <= 5e+46)) {
tmp = (((b * (c / a)) - d) / hypot(d, c)) * (a / hypot(d, c));
} else {
tmp = fma((c / hypot(c, d)), (b / hypot(c, d)), (a * (-d / pow(hypot(c, d), 2.0))));
}
return tmp;
}
function code(a, b, c, d) tmp = 0.0 if ((a <= -7.4e+33) || !(a <= 5e+46)) tmp = Float64(Float64(Float64(Float64(b * Float64(c / a)) - d) / hypot(d, c)) * Float64(a / hypot(d, c))); else tmp = fma(Float64(c / hypot(c, d)), Float64(b / hypot(c, d)), Float64(a * Float64(Float64(-d) / (hypot(c, d) ^ 2.0)))); end return tmp end
code[a_, b_, c_, d_] := If[Or[LessEqual[a, -7.4e+33], N[Not[LessEqual[a, 5e+46]], $MachinePrecision]], N[(N[(N[(N[(b * N[(c / a), $MachinePrecision]), $MachinePrecision] - d), $MachinePrecision] / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision] * N[(a / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] + N[(a * N[((-d) / N[Power[N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -7.4 \cdot 10^{+33} \lor \neg \left(a \leq 5 \cdot 10^{+46}\right):\\
\;\;\;\;\frac{b \cdot \frac{c}{a} - d}{\mathsf{hypot}\left(d, c\right)} \cdot \frac{a}{\mathsf{hypot}\left(d, c\right)}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, a \cdot \frac{-d}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\right)\\
\end{array}
\end{array}
if a < -7.3999999999999997e33 or 5.0000000000000002e46 < a Initial program 57.4%
Taylor expanded in a around inf 57.4%
*-commutative57.4%
add-sqr-sqrt57.4%
hypot-undefine57.4%
hypot-undefine57.4%
times-frac92.1%
associate-/l*96.9%
hypot-undefine60.1%
+-commutative60.1%
hypot-define96.9%
hypot-undefine60.1%
+-commutative60.1%
hypot-define96.9%
Applied egg-rr96.9%
if -7.3999999999999997e33 < a < 5.0000000000000002e46Initial program 72.2%
div-sub71.3%
*-commutative71.3%
fma-define71.3%
add-sqr-sqrt71.3%
times-frac74.8%
fma-neg74.8%
fma-define74.8%
hypot-define74.9%
fma-define74.9%
hypot-define91.0%
associate-/l*91.9%
fma-define91.9%
add-sqr-sqrt91.9%
pow291.9%
Applied egg-rr91.9%
Final simplification93.8%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (- (* b c) (* a d))))
(if (<= (/ t_0 (+ (* c c) (* d d))) 1e+211)
(/ (/ t_0 (hypot d c)) (hypot d c))
(/ (* (/ a (hypot d c)) (fma b (/ c a) (- d))) (hypot d 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))) <= 1e+211) {
tmp = (t_0 / hypot(d, c)) / hypot(d, c);
} else {
tmp = ((a / hypot(d, c)) * fma(b, (c / a), -d)) / hypot(d, 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))) <= 1e+211) tmp = Float64(Float64(t_0 / hypot(d, c)) / hypot(d, c)); else tmp = Float64(Float64(Float64(a / hypot(d, c)) * fma(b, Float64(c / a), Float64(-d))) / hypot(d, c)); end return 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], 1e+211], N[(N[(t$95$0 / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision] / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision], N[(N[(N[(a / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b * N[(c / a), $MachinePrecision] + (-d)), $MachinePrecision]), $MachinePrecision] / N[Sqrt[d ^ 2 + c ^ 2], $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 10^{+211}:\\
\;\;\;\;\frac{\frac{t\_0}{\mathsf{hypot}\left(d, c\right)}}{\mathsf{hypot}\left(d, c\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{a}{\mathsf{hypot}\left(d, c\right)} \cdot \mathsf{fma}\left(b, \frac{c}{a}, -d\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))) < 9.9999999999999996e210Initial program 80.1%
fma-neg80.1%
distribute-rgt-neg-out80.1%
+-commutative80.1%
fma-define80.1%
Simplified80.1%
distribute-rgt-neg-out80.1%
fma-neg80.1%
Applied egg-rr80.1%
*-un-lft-identity80.1%
fma-undefine80.1%
+-commutative80.1%
add-sqr-sqrt80.1%
hypot-undefine80.1%
hypot-undefine80.1%
times-frac96.2%
hypot-undefine80.0%
+-commutative80.0%
hypot-define96.2%
*-commutative96.2%
fma-neg96.2%
*-commutative96.2%
hypot-undefine80.0%
+-commutative80.0%
hypot-define96.2%
Applied egg-rr96.2%
associate-*l/96.3%
*-lft-identity96.3%
fma-undefine96.3%
*-commutative96.3%
unsub-neg96.3%
*-commutative96.3%
Simplified96.3%
if 9.9999999999999996e210 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 20.9%
Taylor expanded in a around inf 20.9%
*-commutative20.9%
add-sqr-sqrt20.9%
hypot-undefine20.9%
hypot-undefine20.9%
times-frac60.1%
associate-/l*69.9%
hypot-undefine22.4%
+-commutative22.4%
hypot-define69.9%
hypot-undefine22.4%
+-commutative22.4%
hypot-define69.9%
Applied egg-rr69.9%
associate-*l/71.5%
fma-neg71.4%
Applied egg-rr71.4%
Final simplification90.6%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (- (* b c) (* a d))))
(if (<= (/ t_0 (+ (* c c) (* d d))) 2e+293)
(/ (/ t_0 (hypot d c)) (hypot d c))
(* (/ (- (* b (/ c a)) d) (hypot d c)) (/ a (hypot d 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))) <= 2e+293) {
tmp = (t_0 / hypot(d, c)) / hypot(d, c);
} else {
tmp = (((b * (c / a)) - d) / hypot(d, c)) * (a / hypot(d, 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))) <= 2e+293) {
tmp = (t_0 / Math.hypot(d, c)) / Math.hypot(d, c);
} else {
tmp = (((b * (c / a)) - d) / Math.hypot(d, c)) * (a / Math.hypot(d, c));
}
return tmp;
}
def code(a, b, c, d): t_0 = (b * c) - (a * d) tmp = 0 if (t_0 / ((c * c) + (d * d))) <= 2e+293: tmp = (t_0 / math.hypot(d, c)) / math.hypot(d, c) else: tmp = (((b * (c / a)) - d) / math.hypot(d, c)) * (a / math.hypot(d, 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))) <= 2e+293) tmp = Float64(Float64(t_0 / hypot(d, c)) / hypot(d, c)); else tmp = Float64(Float64(Float64(Float64(b * Float64(c / a)) - d) / hypot(d, c)) * Float64(a / hypot(d, 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))) <= 2e+293) tmp = (t_0 / hypot(d, c)) / hypot(d, c); else tmp = (((b * (c / a)) - d) / hypot(d, c)) * (a / hypot(d, 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], 2e+293], N[(N[(t$95$0 / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision] / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(b * N[(c / a), $MachinePrecision]), $MachinePrecision] - d), $MachinePrecision] / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision] * N[(a / N[Sqrt[d ^ 2 + c ^ 2], $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 2 \cdot 10^{+293}:\\
\;\;\;\;\frac{\frac{t\_0}{\mathsf{hypot}\left(d, c\right)}}{\mathsf{hypot}\left(d, c\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot \frac{c}{a} - d}{\mathsf{hypot}\left(d, c\right)} \cdot \frac{a}{\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))) < 1.9999999999999998e293Initial program 80.6%
fma-neg80.6%
distribute-rgt-neg-out80.6%
+-commutative80.6%
fma-define80.6%
Simplified80.6%
distribute-rgt-neg-out80.6%
fma-neg80.6%
Applied egg-rr80.6%
*-un-lft-identity80.6%
fma-undefine80.6%
+-commutative80.6%
add-sqr-sqrt80.6%
hypot-undefine80.6%
hypot-undefine80.6%
times-frac96.3%
hypot-undefine80.5%
+-commutative80.5%
hypot-define96.3%
*-commutative96.3%
fma-neg96.3%
*-commutative96.3%
hypot-undefine80.5%
+-commutative80.5%
hypot-define96.3%
Applied egg-rr96.3%
associate-*l/96.4%
*-lft-identity96.4%
fma-undefine96.4%
*-commutative96.4%
unsub-neg96.4%
*-commutative96.4%
Simplified96.4%
if 1.9999999999999998e293 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 13.6%
Taylor expanded in a around inf 13.6%
*-commutative13.6%
add-sqr-sqrt13.6%
hypot-undefine13.6%
hypot-undefine13.6%
times-frac58.0%
associate-/l*68.8%
hypot-undefine16.9%
+-commutative16.9%
hypot-define68.8%
hypot-undefine16.9%
+-commutative16.9%
hypot-define68.8%
Applied egg-rr68.8%
Final simplification90.6%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (- (* b c) (* a d))))
(if (<= (/ t_0 (+ (* c c) (* d d))) INFINITY)
(/ (/ t_0 (hypot d c)) (hypot d c))
(/ (- (* b (/ c d)) a) d))))
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 = (t_0 / hypot(d, c)) / hypot(d, c);
} else {
tmp = ((b * (c / d)) - a) / d;
}
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 = (t_0 / Math.hypot(d, c)) / Math.hypot(d, c);
} else {
tmp = ((b * (c / d)) - a) / d;
}
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 = (t_0 / math.hypot(d, c)) / math.hypot(d, c) else: tmp = ((b * (c / d)) - a) / d 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(t_0 / hypot(d, c)) / hypot(d, c)); else tmp = Float64(Float64(Float64(b * Float64(c / d)) - a) / d); 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 = (t_0 / hypot(d, c)) / hypot(d, c); else tmp = ((b * (c / d)) - a) / d; 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[(t$95$0 / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision] / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision], N[(N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $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{\frac{t\_0}{\mathsf{hypot}\left(d, c\right)}}{\mathsf{hypot}\left(d, c\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\
\end{array}
\end{array}
if (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < +inf.0Initial program 79.5%
fma-neg79.5%
distribute-rgt-neg-out79.5%
+-commutative79.5%
fma-define79.5%
Simplified79.5%
distribute-rgt-neg-out79.5%
fma-neg79.5%
Applied egg-rr79.5%
*-un-lft-identity79.5%
fma-undefine79.5%
+-commutative79.5%
add-sqr-sqrt79.5%
hypot-undefine79.5%
hypot-undefine79.5%
times-frac95.7%
hypot-undefine79.4%
+-commutative79.4%
hypot-define95.7%
*-commutative95.7%
fma-neg95.7%
*-commutative95.7%
hypot-undefine79.4%
+-commutative79.4%
hypot-define95.7%
Applied egg-rr95.7%
associate-*l/95.8%
*-lft-identity95.8%
fma-undefine95.8%
*-commutative95.8%
unsub-neg95.8%
*-commutative95.8%
Simplified95.8%
if +inf.0 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 0.0%
fma-neg0.0%
distribute-rgt-neg-out0.0%
+-commutative0.0%
fma-define0.0%
Simplified0.0%
distribute-rgt-neg-out0.0%
fma-neg0.0%
Applied egg-rr0.0%
*-un-lft-identity0.0%
fma-undefine0.0%
+-commutative0.0%
add-sqr-sqrt0.0%
hypot-undefine0.0%
hypot-undefine0.0%
times-frac2.7%
hypot-undefine0.0%
+-commutative0.0%
hypot-define2.7%
*-commutative2.7%
fma-neg2.8%
*-commutative2.8%
hypot-undefine0.0%
+-commutative0.0%
hypot-define2.8%
Applied egg-rr2.8%
associate-*l/2.8%
*-lft-identity2.8%
fma-undefine2.7%
*-commutative2.7%
unsub-neg2.7%
*-commutative2.7%
Simplified2.7%
Taylor expanded in c around 0 41.5%
+-commutative41.5%
mul-1-neg41.5%
unsub-neg41.5%
*-rgt-identity41.5%
unpow241.5%
times-frac44.4%
*-commutative44.4%
associate-*r/58.6%
associate-*r/58.6%
associate-*r/44.4%
*-commutative44.4%
*-rgt-identity44.4%
*-commutative44.4%
associate-*r/58.6%
associate-*r/44.4%
*-commutative44.4%
div-sub44.4%
associate-/l*58.6%
Simplified58.6%
Final simplification89.7%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* b c) (* a d)) (+ (* c c) (* d d)))))
(if (<= d -2.26e+86)
(/ (- (* c (/ b d)) a) d)
(if (<= d -1.25e-159)
t_0
(if (<= d 5.8e-47)
(/ (- b (/ a (/ c d))) c)
(if (<= d 1.3e+47) t_0 (/ (- (* b (/ c d)) a) (hypot 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 (d <= -2.26e+86) {
tmp = ((c * (b / d)) - a) / d;
} else if (d <= -1.25e-159) {
tmp = t_0;
} else if (d <= 5.8e-47) {
tmp = (b - (a / (c / d))) / c;
} else if (d <= 1.3e+47) {
tmp = t_0;
} else {
tmp = ((b * (c / d)) - a) / hypot(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 (d <= -2.26e+86) {
tmp = ((c * (b / d)) - a) / d;
} else if (d <= -1.25e-159) {
tmp = t_0;
} else if (d <= 5.8e-47) {
tmp = (b - (a / (c / d))) / c;
} else if (d <= 1.3e+47) {
tmp = t_0;
} else {
tmp = ((b * (c / d)) - a) / Math.hypot(d, c);
}
return tmp;
}
def code(a, b, c, d): t_0 = ((b * c) - (a * d)) / ((c * c) + (d * d)) tmp = 0 if d <= -2.26e+86: tmp = ((c * (b / d)) - a) / d elif d <= -1.25e-159: tmp = t_0 elif d <= 5.8e-47: tmp = (b - (a / (c / d))) / c elif d <= 1.3e+47: tmp = t_0 else: tmp = ((b * (c / d)) - a) / math.hypot(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 (d <= -2.26e+86) tmp = Float64(Float64(Float64(c * Float64(b / d)) - a) / d); elseif (d <= -1.25e-159) tmp = t_0; elseif (d <= 5.8e-47) tmp = Float64(Float64(b - Float64(a / Float64(c / d))) / c); elseif (d <= 1.3e+47) tmp = t_0; else tmp = Float64(Float64(Float64(b * Float64(c / d)) - a) / hypot(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 (d <= -2.26e+86) tmp = ((c * (b / d)) - a) / d; elseif (d <= -1.25e-159) tmp = t_0; elseif (d <= 5.8e-47) tmp = (b - (a / (c / d))) / c; elseif (d <= 1.3e+47) tmp = t_0; else tmp = ((b * (c / d)) - a) / hypot(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[d, -2.26e+86], N[(N[(N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, -1.25e-159], t$95$0, If[LessEqual[d, 5.8e-47], N[(N[(b - N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 1.3e+47], t$95$0, N[(N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / N[Sqrt[d ^ 2 + c ^ 2], $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}\;d \leq -2.26 \cdot 10^{+86}:\\
\;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\
\mathbf{elif}\;d \leq -1.25 \cdot 10^{-159}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 5.8 \cdot 10^{-47}:\\
\;\;\;\;\frac{b - \frac{a}{\frac{c}{d}}}{c}\\
\mathbf{elif}\;d \leq 1.3 \cdot 10^{+47}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot \frac{c}{d} - a}{\mathsf{hypot}\left(d, c\right)}\\
\end{array}
\end{array}
if d < -2.26e86Initial program 43.7%
Taylor expanded in c around 0 72.4%
+-commutative72.4%
mul-1-neg72.4%
unsub-neg72.4%
unpow272.4%
associate-/r*78.3%
div-sub78.3%
*-commutative78.3%
associate-/l*88.3%
Simplified88.3%
if -2.26e86 < d < -1.25000000000000008e-159 or 5.8000000000000001e-47 < d < 1.30000000000000002e47Initial program 87.9%
if -1.25000000000000008e-159 < d < 5.8000000000000001e-47Initial program 75.0%
Taylor expanded in c around inf 90.2%
remove-double-neg90.2%
mul-1-neg90.2%
neg-mul-190.2%
distribute-lft-in90.2%
distribute-lft-in90.2%
mul-1-neg90.2%
unsub-neg90.2%
neg-mul-190.2%
mul-1-neg90.2%
remove-double-neg90.2%
associate-/l*90.2%
Simplified90.2%
clear-num90.2%
un-div-inv90.3%
Applied egg-rr90.3%
if 1.30000000000000002e47 < d Initial program 38.3%
fma-neg38.3%
distribute-rgt-neg-out38.3%
+-commutative38.3%
fma-define38.3%
Simplified38.3%
distribute-rgt-neg-out38.3%
fma-neg38.3%
Applied egg-rr38.3%
*-un-lft-identity38.3%
fma-undefine38.3%
+-commutative38.3%
add-sqr-sqrt38.3%
hypot-undefine38.3%
hypot-undefine38.3%
times-frac68.7%
hypot-undefine38.2%
+-commutative38.2%
hypot-define68.7%
*-commutative68.7%
fma-neg68.8%
*-commutative68.8%
hypot-undefine38.2%
+-commutative38.2%
hypot-define68.8%
Applied egg-rr68.8%
associate-*l/69.0%
*-lft-identity69.0%
fma-undefine68.9%
*-commutative68.9%
unsub-neg68.9%
*-commutative68.9%
Simplified68.9%
Taylor expanded in c around 0 75.4%
+-commutative75.4%
mul-1-neg75.4%
sub-neg75.4%
associate-/l*80.2%
Simplified80.2%
Final simplification87.5%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (- (* b c) (* a d))))
(if (<= d -1.9e+85)
(/ (- (* c (/ b d)) a) d)
(if (<= d -1.95e-159)
(/ t_0 (fma c c (* d d)))
(if (<= d 3.75e-47)
(/ (- b (/ a (/ c d))) c)
(if (<= d 1.7e+47)
(/ t_0 (+ (* c c) (* d d)))
(/ (- (* b (/ c d)) a) (hypot d c))))))))
double code(double a, double b, double c, double d) {
double t_0 = (b * c) - (a * d);
double tmp;
if (d <= -1.9e+85) {
tmp = ((c * (b / d)) - a) / d;
} else if (d <= -1.95e-159) {
tmp = t_0 / fma(c, c, (d * d));
} else if (d <= 3.75e-47) {
tmp = (b - (a / (c / d))) / c;
} else if (d <= 1.7e+47) {
tmp = t_0 / ((c * c) + (d * d));
} else {
tmp = ((b * (c / d)) - a) / hypot(d, c);
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(b * c) - Float64(a * d)) tmp = 0.0 if (d <= -1.9e+85) tmp = Float64(Float64(Float64(c * Float64(b / d)) - a) / d); elseif (d <= -1.95e-159) tmp = Float64(t_0 / fma(c, c, Float64(d * d))); elseif (d <= 3.75e-47) tmp = Float64(Float64(b - Float64(a / Float64(c / d))) / c); elseif (d <= 1.7e+47) tmp = Float64(t_0 / Float64(Float64(c * c) + Float64(d * d))); else tmp = Float64(Float64(Float64(b * Float64(c / d)) - a) / hypot(d, c)); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -1.9e+85], N[(N[(N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, -1.95e-159], N[(t$95$0 / N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 3.75e-47], N[(N[(b - N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 1.7e+47], N[(t$95$0 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := b \cdot c - a \cdot d\\
\mathbf{if}\;d \leq -1.9 \cdot 10^{+85}:\\
\;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\
\mathbf{elif}\;d \leq -1.95 \cdot 10^{-159}:\\
\;\;\;\;\frac{t\_0}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\
\mathbf{elif}\;d \leq 3.75 \cdot 10^{-47}:\\
\;\;\;\;\frac{b - \frac{a}{\frac{c}{d}}}{c}\\
\mathbf{elif}\;d \leq 1.7 \cdot 10^{+47}:\\
\;\;\;\;\frac{t\_0}{c \cdot c + d \cdot d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot \frac{c}{d} - a}{\mathsf{hypot}\left(d, c\right)}\\
\end{array}
\end{array}
if d < -1.89999999999999996e85Initial program 43.7%
Taylor expanded in c around 0 72.4%
+-commutative72.4%
mul-1-neg72.4%
unsub-neg72.4%
unpow272.4%
associate-/r*78.3%
div-sub78.3%
*-commutative78.3%
associate-/l*88.3%
Simplified88.3%
if -1.89999999999999996e85 < d < -1.94999999999999988e-159Initial program 90.2%
fma-define90.2%
Simplified90.2%
if -1.94999999999999988e-159 < d < 3.74999999999999984e-47Initial program 75.0%
Taylor expanded in c around inf 90.2%
remove-double-neg90.2%
mul-1-neg90.2%
neg-mul-190.2%
distribute-lft-in90.2%
distribute-lft-in90.2%
mul-1-neg90.2%
unsub-neg90.2%
neg-mul-190.2%
mul-1-neg90.2%
remove-double-neg90.2%
associate-/l*90.2%
Simplified90.2%
clear-num90.2%
un-div-inv90.3%
Applied egg-rr90.3%
if 3.74999999999999984e-47 < d < 1.6999999999999999e47Initial program 82.6%
if 1.6999999999999999e47 < d Initial program 38.3%
fma-neg38.3%
distribute-rgt-neg-out38.3%
+-commutative38.3%
fma-define38.3%
Simplified38.3%
distribute-rgt-neg-out38.3%
fma-neg38.3%
Applied egg-rr38.3%
*-un-lft-identity38.3%
fma-undefine38.3%
+-commutative38.3%
add-sqr-sqrt38.3%
hypot-undefine38.3%
hypot-undefine38.3%
times-frac68.7%
hypot-undefine38.2%
+-commutative38.2%
hypot-define68.7%
*-commutative68.7%
fma-neg68.8%
*-commutative68.8%
hypot-undefine38.2%
+-commutative38.2%
hypot-define68.8%
Applied egg-rr68.8%
associate-*l/69.0%
*-lft-identity69.0%
fma-undefine68.9%
*-commutative68.9%
unsub-neg68.9%
*-commutative68.9%
Simplified68.9%
Taylor expanded in c around 0 75.4%
+-commutative75.4%
mul-1-neg75.4%
sub-neg75.4%
associate-/l*80.2%
Simplified80.2%
Final simplification87.5%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* b c) (* a d)) (+ (* c c) (* d d))))
(t_1 (/ (- (* c (/ b d)) a) d)))
(if (<= d -2.35e+86)
t_1
(if (<= d -1.3e-159)
t_0
(if (<= d 3.75e-47)
(/ (- b (/ a (/ c d))) c)
(if (<= d 2e+146) t_0 t_1))))))
double code(double a, double b, double c, double d) {
double t_0 = ((b * c) - (a * d)) / ((c * c) + (d * d));
double t_1 = ((c * (b / d)) - a) / d;
double tmp;
if (d <= -2.35e+86) {
tmp = t_1;
} else if (d <= -1.3e-159) {
tmp = t_0;
} else if (d <= 3.75e-47) {
tmp = (b - (a / (c / d))) / c;
} else if (d <= 2e+146) {
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 = ((c * (b / d)) - a) / d
if (d <= (-2.35d+86)) then
tmp = t_1
else if (d <= (-1.3d-159)) then
tmp = t_0
else if (d <= 3.75d-47) then
tmp = (b - (a / (c / d))) / c
else if (d <= 2d+146) 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 = ((c * (b / d)) - a) / d;
double tmp;
if (d <= -2.35e+86) {
tmp = t_1;
} else if (d <= -1.3e-159) {
tmp = t_0;
} else if (d <= 3.75e-47) {
tmp = (b - (a / (c / d))) / c;
} else if (d <= 2e+146) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(a, b, c, d): t_0 = ((b * c) - (a * d)) / ((c * c) + (d * d)) t_1 = ((c * (b / d)) - a) / d tmp = 0 if d <= -2.35e+86: tmp = t_1 elif d <= -1.3e-159: tmp = t_0 elif d <= 3.75e-47: tmp = (b - (a / (c / d))) / c elif d <= 2e+146: 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(Float64(c * Float64(b / d)) - a) / d) tmp = 0.0 if (d <= -2.35e+86) tmp = t_1; elseif (d <= -1.3e-159) tmp = t_0; elseif (d <= 3.75e-47) tmp = Float64(Float64(b - Float64(a / Float64(c / d))) / c); elseif (d <= 2e+146) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((b * c) - (a * d)) / ((c * c) + (d * d)); t_1 = ((c * (b / d)) - a) / d; tmp = 0.0; if (d <= -2.35e+86) tmp = t_1; elseif (d <= -1.3e-159) tmp = t_0; elseif (d <= 3.75e-47) tmp = (b - (a / (c / d))) / c; elseif (d <= 2e+146) 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[(N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -2.35e+86], t$95$1, If[LessEqual[d, -1.3e-159], t$95$0, If[LessEqual[d, 3.75e-47], N[(N[(b - N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 2e+146], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\\
t_1 := \frac{c \cdot \frac{b}{d} - a}{d}\\
\mathbf{if}\;d \leq -2.35 \cdot 10^{+86}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d \leq -1.3 \cdot 10^{-159}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 3.75 \cdot 10^{-47}:\\
\;\;\;\;\frac{b - \frac{a}{\frac{c}{d}}}{c}\\
\mathbf{elif}\;d \leq 2 \cdot 10^{+146}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if d < -2.3500000000000001e86 or 1.99999999999999987e146 < d Initial program 37.6%
Taylor expanded in c around 0 70.2%
+-commutative70.2%
mul-1-neg70.2%
unsub-neg70.2%
unpow270.2%
associate-/r*78.6%
div-sub78.6%
*-commutative78.6%
associate-/l*87.3%
Simplified87.3%
if -2.3500000000000001e86 < d < -1.2999999999999999e-159 or 3.74999999999999984e-47 < d < 1.99999999999999987e146Initial program 84.1%
if -1.2999999999999999e-159 < d < 3.74999999999999984e-47Initial program 75.0%
Taylor expanded in c around inf 90.2%
remove-double-neg90.2%
mul-1-neg90.2%
neg-mul-190.2%
distribute-lft-in90.2%
distribute-lft-in90.2%
mul-1-neg90.2%
unsub-neg90.2%
neg-mul-190.2%
mul-1-neg90.2%
remove-double-neg90.2%
associate-/l*90.2%
Simplified90.2%
clear-num90.2%
un-div-inv90.3%
Applied egg-rr90.3%
Final simplification87.2%
(FPCore (a b c d)
:precision binary64
(if (or (<= c -3.6e+63)
(and (not (<= c -1.7e+19))
(or (<= c -2.3e-109) (not (<= c 1.45e+37)))))
(/ b c)
(/ a (- d))))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -3.6e+63) || (!(c <= -1.7e+19) && ((c <= -2.3e-109) || !(c <= 1.45e+37)))) {
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 <= (-3.6d+63)) .or. (.not. (c <= (-1.7d+19))) .and. (c <= (-2.3d-109)) .or. (.not. (c <= 1.45d+37))) 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 <= -3.6e+63) || (!(c <= -1.7e+19) && ((c <= -2.3e-109) || !(c <= 1.45e+37)))) {
tmp = b / c;
} else {
tmp = a / -d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -3.6e+63) or (not (c <= -1.7e+19) and ((c <= -2.3e-109) or not (c <= 1.45e+37))): tmp = b / c else: tmp = a / -d return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -3.6e+63) || (!(c <= -1.7e+19) && ((c <= -2.3e-109) || !(c <= 1.45e+37)))) 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 <= -3.6e+63) || (~((c <= -1.7e+19)) && ((c <= -2.3e-109) || ~((c <= 1.45e+37))))) tmp = b / c; else tmp = a / -d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -3.6e+63], And[N[Not[LessEqual[c, -1.7e+19]], $MachinePrecision], Or[LessEqual[c, -2.3e-109], N[Not[LessEqual[c, 1.45e+37]], $MachinePrecision]]]], N[(b / c), $MachinePrecision], N[(a / (-d)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -3.6 \cdot 10^{+63} \lor \neg \left(c \leq -1.7 \cdot 10^{+19}\right) \land \left(c \leq -2.3 \cdot 10^{-109} \lor \neg \left(c \leq 1.45 \cdot 10^{+37}\right)\right):\\
\;\;\;\;\frac{b}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{-d}\\
\end{array}
\end{array}
if c < -3.59999999999999999e63 or -1.7e19 < c < -2.3000000000000001e-109 or 1.44999999999999989e37 < c Initial program 63.7%
Taylor expanded in c around inf 66.7%
if -3.59999999999999999e63 < c < -1.7e19 or -2.3000000000000001e-109 < c < 1.44999999999999989e37Initial program 69.7%
Taylor expanded in c around 0 70.6%
associate-*r/70.6%
neg-mul-170.6%
Simplified70.6%
Final simplification68.5%
(FPCore (a b c d) :precision binary64 (if (or (<= d -4.05e-20) (not (<= d 3e+14))) (/ a (- d)) (/ (- b (* a (/ d c))) c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -4.05e-20) || !(d <= 3e+14)) {
tmp = a / -d;
} else {
tmp = (b - (a * (d / c))) / c;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if ((d <= (-4.05d-20)) .or. (.not. (d <= 3d+14))) then
tmp = a / -d
else
tmp = (b - (a * (d / c))) / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -4.05e-20) || !(d <= 3e+14)) {
tmp = a / -d;
} else {
tmp = (b - (a * (d / c))) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -4.05e-20) or not (d <= 3e+14): tmp = a / -d else: tmp = (b - (a * (d / c))) / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -4.05e-20) || !(d <= 3e+14)) tmp = Float64(a / Float64(-d)); else tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -4.05e-20) || ~((d <= 3e+14))) tmp = a / -d; else tmp = (b - (a * (d / c))) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -4.05e-20], N[Not[LessEqual[d, 3e+14]], $MachinePrecision]], N[(a / (-d)), $MachinePrecision], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -4.05 \cdot 10^{-20} \lor \neg \left(d \leq 3 \cdot 10^{+14}\right):\\
\;\;\;\;\frac{a}{-d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\
\end{array}
\end{array}
if d < -4.05000000000000024e-20 or 3e14 < d Initial program 53.6%
Taylor expanded in c around 0 65.8%
associate-*r/65.8%
neg-mul-165.8%
Simplified65.8%
if -4.05000000000000024e-20 < d < 3e14Initial program 79.5%
Taylor expanded in c around inf 83.1%
remove-double-neg83.1%
mul-1-neg83.1%
neg-mul-183.1%
distribute-lft-in83.1%
distribute-lft-in83.1%
mul-1-neg83.1%
unsub-neg83.1%
neg-mul-183.1%
mul-1-neg83.1%
remove-double-neg83.1%
associate-/l*83.1%
Simplified83.1%
Final simplification74.4%
(FPCore (a b c d) :precision binary64 (if (or (<= d -4.2e-20) (not (<= d 3.6e-30))) (/ (- (* b (/ c d)) a) d) (/ (- b (* a (/ d c))) c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -4.2e-20) || !(d <= 3.6e-30)) {
tmp = ((b * (c / d)) - a) / d;
} else {
tmp = (b - (a * (d / c))) / c;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if ((d <= (-4.2d-20)) .or. (.not. (d <= 3.6d-30))) then
tmp = ((b * (c / d)) - a) / d
else
tmp = (b - (a * (d / c))) / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -4.2e-20) || !(d <= 3.6e-30)) {
tmp = ((b * (c / d)) - a) / d;
} else {
tmp = (b - (a * (d / c))) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -4.2e-20) or not (d <= 3.6e-30): tmp = ((b * (c / d)) - a) / d else: tmp = (b - (a * (d / c))) / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -4.2e-20) || !(d <= 3.6e-30)) tmp = Float64(Float64(Float64(b * Float64(c / d)) - a) / d); else tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -4.2e-20) || ~((d <= 3.6e-30))) tmp = ((b * (c / d)) - a) / d; else tmp = (b - (a * (d / c))) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -4.2e-20], N[Not[LessEqual[d, 3.6e-30]], $MachinePrecision]], N[(N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -4.2 \cdot 10^{-20} \lor \neg \left(d \leq 3.6 \cdot 10^{-30}\right):\\
\;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\
\end{array}
\end{array}
if d < -4.1999999999999998e-20 or 3.6000000000000003e-30 < d Initial program 56.5%
fma-neg56.5%
distribute-rgt-neg-out56.5%
+-commutative56.5%
fma-define56.5%
Simplified56.5%
distribute-rgt-neg-out56.5%
fma-neg56.5%
Applied egg-rr56.5%
*-un-lft-identity56.5%
fma-undefine56.5%
+-commutative56.5%
add-sqr-sqrt56.4%
hypot-undefine56.5%
hypot-undefine56.5%
times-frac71.7%
hypot-undefine56.4%
+-commutative56.4%
hypot-define71.7%
*-commutative71.7%
fma-neg71.7%
*-commutative71.7%
hypot-undefine56.4%
+-commutative56.4%
hypot-define71.7%
Applied egg-rr71.7%
associate-*l/71.9%
*-lft-identity71.9%
fma-undefine71.8%
*-commutative71.8%
unsub-neg71.8%
*-commutative71.8%
Simplified71.8%
Taylor expanded in c around 0 65.4%
+-commutative65.4%
mul-1-neg65.4%
unsub-neg65.4%
*-rgt-identity65.4%
unpow265.4%
times-frac70.1%
*-commutative70.1%
associate-*r/75.0%
associate-*r/75.0%
associate-*r/70.1%
*-commutative70.1%
*-rgt-identity70.1%
*-commutative70.1%
associate-*r/75.0%
associate-*r/70.1%
*-commutative70.1%
div-sub70.1%
associate-/l*74.4%
Simplified74.4%
if -4.1999999999999998e-20 < d < 3.6000000000000003e-30Initial program 78.8%
Taylor expanded in c around inf 87.0%
remove-double-neg87.0%
mul-1-neg87.0%
neg-mul-187.0%
distribute-lft-in87.0%
distribute-lft-in87.0%
mul-1-neg87.0%
unsub-neg87.0%
neg-mul-187.0%
mul-1-neg87.0%
remove-double-neg87.0%
associate-/l*87.0%
Simplified87.0%
Final simplification80.0%
(FPCore (a b c d) :precision binary64 (if (<= d -3.5e-20) (/ (- (* c (/ b d)) a) d) (if (<= d 2.7e-30) (/ (- b (* a (/ d c))) c) (/ (- (* b (/ c d)) a) d))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -3.5e-20) {
tmp = ((c * (b / d)) - a) / d;
} else if (d <= 2.7e-30) {
tmp = (b - (a * (d / c))) / c;
} else {
tmp = ((b * (c / d)) - a) / d;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (d <= (-3.5d-20)) then
tmp = ((c * (b / d)) - a) / d
else if (d <= 2.7d-30) then
tmp = (b - (a * (d / c))) / c
else
tmp = ((b * (c / d)) - a) / d
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (d <= -3.5e-20) {
tmp = ((c * (b / d)) - a) / d;
} else if (d <= 2.7e-30) {
tmp = (b - (a * (d / c))) / c;
} else {
tmp = ((b * (c / d)) - a) / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -3.5e-20: tmp = ((c * (b / d)) - a) / d elif d <= 2.7e-30: tmp = (b - (a * (d / c))) / c else: tmp = ((b * (c / d)) - a) / d return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -3.5e-20) tmp = Float64(Float64(Float64(c * Float64(b / d)) - a) / d); elseif (d <= 2.7e-30) tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c); else tmp = Float64(Float64(Float64(b * Float64(c / d)) - a) / d); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= -3.5e-20) tmp = ((c * (b / d)) - a) / d; elseif (d <= 2.7e-30) tmp = (b - (a * (d / c))) / c; else tmp = ((b * (c / d)) - a) / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -3.5e-20], N[(N[(N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, 2.7e-30], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], N[(N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -3.5 \cdot 10^{-20}:\\
\;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\
\mathbf{elif}\;d \leq 2.7 \cdot 10^{-30}:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\
\end{array}
\end{array}
if d < -3.50000000000000003e-20Initial program 60.7%
Taylor expanded in c around 0 68.6%
+-commutative68.6%
mul-1-neg68.6%
unsub-neg68.6%
unpow268.6%
associate-/r*72.3%
div-sub72.3%
*-commutative72.3%
associate-/l*78.6%
Simplified78.6%
if -3.50000000000000003e-20 < d < 2.69999999999999987e-30Initial program 78.8%
Taylor expanded in c around inf 87.0%
remove-double-neg87.0%
mul-1-neg87.0%
neg-mul-187.0%
distribute-lft-in87.0%
distribute-lft-in87.0%
mul-1-neg87.0%
unsub-neg87.0%
neg-mul-187.0%
mul-1-neg87.0%
remove-double-neg87.0%
associate-/l*87.0%
Simplified87.0%
if 2.69999999999999987e-30 < d Initial program 51.3%
fma-neg51.3%
distribute-rgt-neg-out51.3%
+-commutative51.3%
fma-define51.3%
Simplified51.3%
distribute-rgt-neg-out51.3%
fma-neg51.3%
Applied egg-rr51.3%
*-un-lft-identity51.3%
fma-undefine51.3%
+-commutative51.3%
add-sqr-sqrt51.3%
hypot-undefine51.3%
hypot-undefine51.3%
times-frac73.8%
hypot-undefine51.2%
+-commutative51.2%
hypot-define73.8%
*-commutative73.8%
fma-neg73.9%
*-commutative73.9%
hypot-undefine51.2%
+-commutative51.2%
hypot-define73.9%
Applied egg-rr73.9%
associate-*l/74.0%
*-lft-identity74.0%
fma-undefine74.0%
*-commutative74.0%
unsub-neg74.0%
*-commutative74.0%
Simplified74.0%
Taylor expanded in c around 0 61.5%
+-commutative61.5%
mul-1-neg61.5%
unsub-neg61.5%
*-rgt-identity61.5%
unpow261.5%
times-frac67.4%
*-commutative67.4%
associate-*r/70.7%
associate-*r/70.7%
associate-*r/67.5%
*-commutative67.5%
*-rgt-identity67.5%
*-commutative67.5%
associate-*r/70.7%
associate-*r/67.5%
*-commutative67.5%
div-sub67.5%
associate-/l*70.7%
Simplified70.7%
Final simplification80.4%
(FPCore (a b c d) :precision binary64 (if (<= d -1.18e+191) (/ b d) (/ b c)))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -1.18e+191) {
tmp = b / d;
} else {
tmp = b / c;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (d <= (-1.18d+191)) then
tmp = b / d
else
tmp = b / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (d <= -1.18e+191) {
tmp = b / d;
} else {
tmp = b / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -1.18e+191: tmp = b / d else: tmp = b / c return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -1.18e+191) tmp = Float64(b / d); else tmp = Float64(b / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= -1.18e+191) tmp = b / d; else tmp = b / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -1.18e+191], N[(b / d), $MachinePrecision], N[(b / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.18 \cdot 10^{+191}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if d < -1.17999999999999994e191Initial program 48.6%
fma-neg48.6%
distribute-rgt-neg-out48.6%
+-commutative48.6%
fma-define48.6%
Simplified48.6%
distribute-rgt-neg-out48.6%
fma-neg48.6%
Applied egg-rr48.6%
*-un-lft-identity48.6%
fma-undefine48.6%
+-commutative48.6%
add-sqr-sqrt48.6%
hypot-undefine48.6%
hypot-undefine48.6%
times-frac67.5%
hypot-undefine48.6%
+-commutative48.6%
hypot-define67.5%
*-commutative67.5%
fma-neg67.5%
*-commutative67.5%
hypot-undefine48.6%
+-commutative48.6%
hypot-define67.5%
Applied egg-rr67.5%
associate-*l/67.5%
*-lft-identity67.5%
fma-undefine67.5%
*-commutative67.5%
unsub-neg67.5%
*-commutative67.5%
Simplified67.5%
Taylor expanded in c around 0 48.8%
+-commutative48.8%
mul-1-neg48.8%
sub-neg48.8%
associate-/l*49.0%
Simplified49.0%
Taylor expanded in c around inf 29.1%
if -1.17999999999999994e191 < d Initial program 68.5%
Taylor expanded in c around inf 48.4%
Final simplification46.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 66.4%
Taylor expanded in c around inf 44.0%
Final simplification44.0%
(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 2024055
(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))))