
(FPCore (a b c d) :precision binary64 (/ (- (* b c) (* a d)) (+ (* c c) (* d d))))
double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = ((b * c) - (a * d)) / ((c * c) + (d * d))
end function
public static double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
def code(a, b, c, d): return ((b * c) - (a * d)) / ((c * c) + (d * d))
function code(a, b, c, d) return Float64(Float64(Float64(b * c) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d))) end
function tmp = code(a, b, c, d) tmp = ((b * c) - (a * d)) / ((c * c) + (d * d)); end
code[a_, b_, c_, d_] := N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b c d) :precision binary64 (/ (- (* b c) (* a d)) (+ (* c c) (* d d))))
double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = ((b * c) - (a * d)) / ((c * c) + (d * d))
end function
public static double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
def code(a, b, c, d): return ((b * c) - (a * d)) / ((c * c) + (d * d))
function code(a, b, c, d) return Float64(Float64(Float64(b * c) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d))) end
function tmp = code(a, b, c, d) tmp = ((b * c) - (a * d)) / ((c * c) + (d * d)); end
code[a_, b_, c_, d_] := N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}
\end{array}
(FPCore (a b c d) :precision binary64 (/ (- (* (/ c (hypot c d)) b) (* d (/ a (hypot c d)))) (hypot c d)))
double code(double a, double b, double c, double d) {
return (((c / hypot(c, d)) * b) - (d * (a / hypot(c, d)))) / hypot(c, d);
}
public static double code(double a, double b, double c, double d) {
return (((c / Math.hypot(c, d)) * b) - (d * (a / Math.hypot(c, d)))) / Math.hypot(c, d);
}
def code(a, b, c, d): return (((c / math.hypot(c, d)) * b) - (d * (a / math.hypot(c, d)))) / math.hypot(c, d)
function code(a, b, c, d) return Float64(Float64(Float64(Float64(c / hypot(c, d)) * b) - Float64(d * Float64(a / hypot(c, d)))) / hypot(c, d)) end
function tmp = code(a, b, c, d) tmp = (((c / hypot(c, d)) * b) - (d * (a / hypot(c, d)))) / hypot(c, d); end
code[a_, b_, c_, d_] := N[(N[(N[(N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision] - N[(d * N[(a / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{c}{\mathsf{hypot}\left(c, d\right)} \cdot b - d \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}
\end{array}
Initial program 63.5%
div-sub61.7%
sub-neg61.7%
*-un-lft-identity61.7%
add-sqr-sqrt61.7%
times-frac61.7%
fma-def61.7%
hypot-def61.7%
hypot-def67.5%
associate-/l*70.6%
add-sqr-sqrt70.6%
pow270.6%
hypot-def70.6%
Applied egg-rr70.6%
fma-neg69.8%
*-commutative69.8%
associate-/l*79.4%
associate-/r/78.1%
*-commutative78.1%
Simplified78.1%
*-un-lft-identity78.1%
unpow278.1%
times-frac85.6%
Applied egg-rr85.6%
associate-*l/85.6%
*-lft-identity85.6%
Simplified85.6%
associate-*l/85.7%
*-un-lft-identity85.7%
associate-*r/96.6%
sub-div97.0%
associate-/r/99.2%
Applied egg-rr99.2%
Final simplification99.2%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (- (* c b) (* d a))))
(if (<= (/ t_0 (+ (* c c) (* d d))) 1e+254)
(* (/ 1.0 (hypot c d)) (/ t_0 (hypot c d)))
(fma (/ c (hypot c d)) (/ b (hypot c d)) (/ (- a) d)))))
double code(double a, double b, double c, double d) {
double t_0 = (c * b) - (d * a);
double tmp;
if ((t_0 / ((c * c) + (d * d))) <= 1e+254) {
tmp = (1.0 / hypot(c, d)) * (t_0 / hypot(c, d));
} else {
tmp = fma((c / hypot(c, d)), (b / hypot(c, d)), (-a / d));
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(c * b) - Float64(d * a)) tmp = 0.0 if (Float64(t_0 / Float64(Float64(c * c) + Float64(d * d))) <= 1e+254) tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(t_0 / hypot(c, d))); else tmp = fma(Float64(c / hypot(c, d)), Float64(b / hypot(c, d)), Float64(Float64(-a) / d)); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$0 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1e+254], N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] + N[((-a) / d), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := c \cdot b - d \cdot a\\
\mathbf{if}\;\frac{t_0}{c \cdot c + d \cdot d} \leq 10^{+254}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{t_0}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, \frac{-a}{d}\right)\\
\end{array}
\end{array}
if (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 9.9999999999999994e253Initial program 82.7%
*-un-lft-identity82.7%
add-sqr-sqrt82.7%
times-frac82.7%
hypot-def82.7%
hypot-def97.0%
Applied egg-rr97.0%
if 9.9999999999999994e253 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 11.4%
div-sub9.4%
sub-neg9.4%
*-commutative9.4%
add-sqr-sqrt9.4%
times-frac16.3%
fma-def16.3%
hypot-def16.3%
hypot-def45.6%
associate-/l*58.1%
add-sqr-sqrt58.1%
pow258.1%
hypot-def58.1%
Applied egg-rr58.1%
Taylor expanded in c around 0 67.8%
Final simplification89.2%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* c b) (* d a)) (+ (* c c) (* d d)))))
(if (<= c -1.55e+95)
(fma -1.0 (* (/ d c) (/ a c)) (/ b c))
(if (<= c -4.2e-100)
t_0
(if (<= c 3.1e-145)
(* (/ 1.0 d) (- (* c (/ b d)) a))
(if (<= c 3.9e-66)
t_0
(if (<= c 1.2e+41)
(- (* c (/ (/ b d) d)) (/ a d))
(/ (- b (/ d (/ (hypot c d) a))) (hypot c d)))))))))
double code(double a, double b, double c, double d) {
double t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
double tmp;
if (c <= -1.55e+95) {
tmp = fma(-1.0, ((d / c) * (a / c)), (b / c));
} else if (c <= -4.2e-100) {
tmp = t_0;
} else if (c <= 3.1e-145) {
tmp = (1.0 / d) * ((c * (b / d)) - a);
} else if (c <= 3.9e-66) {
tmp = t_0;
} else if (c <= 1.2e+41) {
tmp = (c * ((b / d) / d)) - (a / d);
} else {
tmp = (b - (d / (hypot(c, d) / a))) / hypot(c, d);
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d))) tmp = 0.0 if (c <= -1.55e+95) tmp = fma(-1.0, Float64(Float64(d / c) * Float64(a / c)), Float64(b / c)); elseif (c <= -4.2e-100) tmp = t_0; elseif (c <= 3.1e-145) tmp = Float64(Float64(1.0 / d) * Float64(Float64(c * Float64(b / d)) - a)); elseif (c <= 3.9e-66) tmp = t_0; elseif (c <= 1.2e+41) tmp = Float64(Float64(c * Float64(Float64(b / d) / d)) - Float64(a / d)); else tmp = Float64(Float64(b - Float64(d / Float64(hypot(c, d) / a))) / hypot(c, d)); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = 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, -1.55e+95], N[(-1.0 * N[(N[(d / c), $MachinePrecision] * N[(a / c), $MachinePrecision]), $MachinePrecision] + N[(b / c), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -4.2e-100], t$95$0, If[LessEqual[c, 3.1e-145], N[(N[(1.0 / d), $MachinePrecision] * N[(N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 3.9e-66], t$95$0, If[LessEqual[c, 1.2e+41], N[(N[(c * N[(N[(b / d), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], N[(N[(b - N[(d / N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{if}\;c \leq -1.55 \cdot 10^{+95}:\\
\;\;\;\;\mathsf{fma}\left(-1, \frac{d}{c} \cdot \frac{a}{c}, \frac{b}{c}\right)\\
\mathbf{elif}\;c \leq -4.2 \cdot 10^{-100}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 3.1 \cdot 10^{-145}:\\
\;\;\;\;\frac{1}{d} \cdot \left(c \cdot \frac{b}{d} - a\right)\\
\mathbf{elif}\;c \leq 3.9 \cdot 10^{-66}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 1.2 \cdot 10^{+41}:\\
\;\;\;\;c \cdot \frac{\frac{b}{d}}{d} - \frac{a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - \frac{d}{\frac{\mathsf{hypot}\left(c, d\right)}{a}}}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\end{array}
if c < -1.5500000000000001e95Initial program 49.8%
Taylor expanded in c around inf 84.3%
fma-def84.3%
associate-/l*84.9%
Simplified84.9%
clear-num84.9%
inv-pow84.9%
Applied egg-rr84.9%
unpow-184.9%
associate-/l/84.3%
*-commutative84.3%
Simplified84.3%
clear-num84.3%
unpow284.3%
times-frac94.8%
Applied egg-rr94.8%
if -1.5500000000000001e95 < c < -4.20000000000000019e-100 or 3.1e-145 < c < 3.89999999999999983e-66Initial program 93.2%
if -4.20000000000000019e-100 < c < 3.1e-145Initial program 59.3%
Taylor expanded in c around 0 76.6%
+-commutative76.6%
mul-1-neg76.6%
unsub-neg76.6%
associate-/l*76.8%
associate-/r/71.0%
Simplified71.0%
*-un-lft-identity71.0%
unpow271.0%
times-frac74.5%
Applied egg-rr74.5%
associate-*l*81.6%
fma-neg81.6%
Applied egg-rr81.6%
fma-udef81.6%
*-lft-identity81.6%
associate-*l/81.3%
distribute-rgt-neg-in81.3%
distribute-lft-out81.3%
*-commutative81.3%
Simplified81.3%
if 3.89999999999999983e-66 < c < 1.2000000000000001e41Initial program 62.6%
Taylor expanded in c around 0 68.2%
+-commutative68.2%
mul-1-neg68.2%
unsub-neg68.2%
associate-/l*68.2%
associate-/r/68.1%
Simplified68.1%
*-un-lft-identity68.1%
unpow268.1%
times-frac76.3%
Applied egg-rr76.3%
associate-*l/76.3%
*-lft-identity76.3%
Simplified76.3%
if 1.2000000000000001e41 < c Initial program 43.5%
div-sub43.5%
sub-neg43.5%
*-un-lft-identity43.5%
add-sqr-sqrt43.5%
times-frac43.4%
fma-def43.4%
hypot-def43.4%
hypot-def54.9%
associate-/l*52.7%
add-sqr-sqrt52.7%
pow252.7%
hypot-def52.7%
Applied egg-rr52.7%
fma-neg52.7%
*-commutative52.7%
associate-/l*84.3%
associate-/r/86.8%
*-commutative86.8%
Simplified86.8%
Taylor expanded in c around -inf 28.6%
mul-1-neg28.6%
Simplified28.6%
associate-*l/28.6%
*-un-lft-identity28.6%
associate-*r/28.2%
unpow228.2%
frac-times36.2%
associate-*l/38.1%
sub-div38.1%
add-sqr-sqrt22.6%
sqrt-unprod55.3%
sqr-neg55.3%
sqrt-unprod46.4%
add-sqr-sqrt92.5%
clear-num92.5%
un-div-inv92.5%
Applied egg-rr92.5%
Final simplification87.9%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (- (* c b) (* d a))))
(if (<= (/ t_0 (+ (* c c) (* d d))) 1e+254)
(* (/ 1.0 (hypot c d)) (/ t_0 (hypot c d)))
(/ (- b (/ d (/ (hypot c d) a))) (hypot c d)))))
double code(double a, double b, double c, double d) {
double t_0 = (c * b) - (d * a);
double tmp;
if ((t_0 / ((c * c) + (d * d))) <= 1e+254) {
tmp = (1.0 / hypot(c, d)) * (t_0 / hypot(c, d));
} else {
tmp = (b - (d / (hypot(c, d) / a))) / hypot(c, d);
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = (c * b) - (d * a);
double tmp;
if ((t_0 / ((c * c) + (d * d))) <= 1e+254) {
tmp = (1.0 / Math.hypot(c, d)) * (t_0 / Math.hypot(c, d));
} else {
tmp = (b - (d / (Math.hypot(c, d) / a))) / Math.hypot(c, d);
}
return tmp;
}
def code(a, b, c, d): t_0 = (c * b) - (d * a) tmp = 0 if (t_0 / ((c * c) + (d * d))) <= 1e+254: tmp = (1.0 / math.hypot(c, d)) * (t_0 / math.hypot(c, d)) else: tmp = (b - (d / (math.hypot(c, d) / a))) / math.hypot(c, d) return tmp
function code(a, b, c, d) t_0 = Float64(Float64(c * b) - Float64(d * a)) tmp = 0.0 if (Float64(t_0 / Float64(Float64(c * c) + Float64(d * d))) <= 1e+254) tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(t_0 / hypot(c, d))); else tmp = Float64(Float64(b - Float64(d / Float64(hypot(c, d) / a))) / hypot(c, d)); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (c * b) - (d * a); tmp = 0.0; if ((t_0 / ((c * c) + (d * d))) <= 1e+254) tmp = (1.0 / hypot(c, d)) * (t_0 / hypot(c, d)); else tmp = (b - (d / (hypot(c, d) / a))) / hypot(c, d); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$0 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1e+254], N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b - N[(d / N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := c \cdot b - d \cdot a\\
\mathbf{if}\;\frac{t_0}{c \cdot c + d \cdot d} \leq 10^{+254}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{t_0}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - \frac{d}{\frac{\mathsf{hypot}\left(c, d\right)}{a}}}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\end{array}
if (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 9.9999999999999994e253Initial program 82.7%
*-un-lft-identity82.7%
add-sqr-sqrt82.7%
times-frac82.7%
hypot-def82.7%
hypot-def97.0%
Applied egg-rr97.0%
if 9.9999999999999994e253 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 11.4%
div-sub9.4%
sub-neg9.4%
*-un-lft-identity9.4%
add-sqr-sqrt9.4%
times-frac9.4%
fma-def9.4%
hypot-def9.4%
hypot-def11.9%
associate-/l*20.1%
add-sqr-sqrt20.1%
pow220.1%
hypot-def20.1%
Applied egg-rr20.1%
fma-neg18.6%
*-commutative18.6%
associate-/l*57.9%
associate-/r/57.9%
*-commutative57.9%
Simplified57.9%
Taylor expanded in c around -inf 29.7%
mul-1-neg29.7%
Simplified29.7%
associate-*l/29.8%
*-un-lft-identity29.8%
associate-*r/20.1%
unpow220.1%
frac-times58.9%
associate-*l/58.9%
sub-div60.3%
add-sqr-sqrt32.3%
sqrt-unprod52.4%
sqr-neg52.4%
sqrt-unprod37.1%
add-sqr-sqrt66.4%
clear-num66.3%
un-div-inv66.3%
Applied egg-rr66.3%
Final simplification88.8%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ 1.0 (hypot c d))) (t_1 (- (* c b) (* d a))))
(if (<= (/ t_1 (+ (* c c) (* d d))) 1e+254)
(* t_0 (/ t_1 (hypot c d)))
(- (* t_0 (/ c (/ (hypot c d) b))) (/ a d)))))
double code(double a, double b, double c, double d) {
double t_0 = 1.0 / hypot(c, d);
double t_1 = (c * b) - (d * a);
double tmp;
if ((t_1 / ((c * c) + (d * d))) <= 1e+254) {
tmp = t_0 * (t_1 / hypot(c, d));
} else {
tmp = (t_0 * (c / (hypot(c, d) / b))) - (a / d);
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = 1.0 / Math.hypot(c, d);
double t_1 = (c * b) - (d * a);
double tmp;
if ((t_1 / ((c * c) + (d * d))) <= 1e+254) {
tmp = t_0 * (t_1 / Math.hypot(c, d));
} else {
tmp = (t_0 * (c / (Math.hypot(c, d) / b))) - (a / d);
}
return tmp;
}
def code(a, b, c, d): t_0 = 1.0 / math.hypot(c, d) t_1 = (c * b) - (d * a) tmp = 0 if (t_1 / ((c * c) + (d * d))) <= 1e+254: tmp = t_0 * (t_1 / math.hypot(c, d)) else: tmp = (t_0 * (c / (math.hypot(c, d) / b))) - (a / d) return tmp
function code(a, b, c, d) t_0 = Float64(1.0 / hypot(c, d)) t_1 = Float64(Float64(c * b) - Float64(d * a)) tmp = 0.0 if (Float64(t_1 / Float64(Float64(c * c) + Float64(d * d))) <= 1e+254) tmp = Float64(t_0 * Float64(t_1 / hypot(c, d))); else tmp = Float64(Float64(t_0 * Float64(c / Float64(hypot(c, d) / b))) - Float64(a / d)); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = 1.0 / hypot(c, d); t_1 = (c * b) - (d * a); tmp = 0.0; if ((t_1 / ((c * c) + (d * d))) <= 1e+254) tmp = t_0 * (t_1 / hypot(c, d)); else tmp = (t_0 * (c / (hypot(c, d) / b))) - (a / d); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$1 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1e+254], N[(t$95$0 * N[(t$95$1 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 * N[(c / N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\mathsf{hypot}\left(c, d\right)}\\
t_1 := c \cdot b - d \cdot a\\
\mathbf{if}\;\frac{t_1}{c \cdot c + d \cdot d} \leq 10^{+254}:\\
\;\;\;\;t_0 \cdot \frac{t_1}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot \frac{c}{\frac{\mathsf{hypot}\left(c, d\right)}{b}} - \frac{a}{d}\\
\end{array}
\end{array}
if (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 9.9999999999999994e253Initial program 82.7%
*-un-lft-identity82.7%
add-sqr-sqrt82.7%
times-frac82.7%
hypot-def82.7%
hypot-def97.0%
Applied egg-rr97.0%
if 9.9999999999999994e253 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 11.4%
div-sub9.4%
sub-neg9.4%
*-un-lft-identity9.4%
add-sqr-sqrt9.4%
times-frac9.4%
fma-def9.4%
hypot-def9.4%
hypot-def11.9%
associate-/l*20.1%
add-sqr-sqrt20.1%
pow220.1%
hypot-def20.1%
Applied egg-rr20.1%
fma-neg18.6%
*-commutative18.6%
associate-/l*57.9%
associate-/r/57.9%
*-commutative57.9%
Simplified57.9%
*-un-lft-identity57.9%
unpow257.9%
times-frac81.7%
Applied egg-rr81.7%
associate-*l/81.8%
*-lft-identity81.8%
Simplified81.8%
Taylor expanded in d around inf 67.8%
Final simplification89.2%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* c b) (* d a)) (+ (* c c) (* d d))))
(t_1 (fma -1.0 (* (/ d c) (/ a c)) (/ b c))))
(if (<= c -4e+91)
t_1
(if (<= c -5e-100)
t_0
(if (<= c 1.12e-142)
(* (/ 1.0 d) (- (* c (/ b d)) a))
(if (<= c 1.45e+81) t_0 t_1))))))
double code(double a, double b, double c, double d) {
double t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
double t_1 = fma(-1.0, ((d / c) * (a / c)), (b / c));
double tmp;
if (c <= -4e+91) {
tmp = t_1;
} else if (c <= -5e-100) {
tmp = t_0;
} else if (c <= 1.12e-142) {
tmp = (1.0 / d) * ((c * (b / d)) - a);
} else if (c <= 1.45e+81) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d))) t_1 = fma(-1.0, Float64(Float64(d / c) * Float64(a / c)), Float64(b / c)) tmp = 0.0 if (c <= -4e+91) tmp = t_1; elseif (c <= -5e-100) tmp = t_0; elseif (c <= 1.12e-142) tmp = Float64(Float64(1.0 / d) * Float64(Float64(c * Float64(b / d)) - a)); elseif (c <= 1.45e+81) tmp = t_0; else tmp = t_1; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(-1.0 * N[(N[(d / c), $MachinePrecision] * N[(a / c), $MachinePrecision]), $MachinePrecision] + N[(b / c), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -4e+91], t$95$1, If[LessEqual[c, -5e-100], t$95$0, If[LessEqual[c, 1.12e-142], N[(N[(1.0 / d), $MachinePrecision] * N[(N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.45e+81], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
t_1 := \mathsf{fma}\left(-1, \frac{d}{c} \cdot \frac{a}{c}, \frac{b}{c}\right)\\
\mathbf{if}\;c \leq -4 \cdot 10^{+91}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;c \leq -5 \cdot 10^{-100}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 1.12 \cdot 10^{-142}:\\
\;\;\;\;\frac{1}{d} \cdot \left(c \cdot \frac{b}{d} - a\right)\\
\mathbf{elif}\;c \leq 1.45 \cdot 10^{+81}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if c < -4.00000000000000032e91 or 1.45e81 < c Initial program 40.0%
Taylor expanded in c around inf 80.9%
fma-def80.9%
associate-/l*82.3%
Simplified82.3%
clear-num82.3%
inv-pow82.3%
Applied egg-rr82.3%
unpow-182.3%
associate-/l/80.4%
*-commutative80.4%
Simplified80.4%
clear-num80.9%
unpow280.9%
times-frac91.2%
Applied egg-rr91.2%
if -4.00000000000000032e91 < c < -5.0000000000000001e-100 or 1.1199999999999999e-142 < c < 1.45e81Initial program 86.4%
if -5.0000000000000001e-100 < c < 1.1199999999999999e-142Initial program 59.3%
Taylor expanded in c around 0 76.6%
+-commutative76.6%
mul-1-neg76.6%
unsub-neg76.6%
associate-/l*76.8%
associate-/r/71.0%
Simplified71.0%
*-un-lft-identity71.0%
unpow271.0%
times-frac74.5%
Applied egg-rr74.5%
associate-*l*81.6%
fma-neg81.6%
Applied egg-rr81.6%
fma-udef81.6%
*-lft-identity81.6%
associate-*l/81.3%
distribute-rgt-neg-in81.3%
distribute-lft-out81.3%
*-commutative81.3%
Simplified81.3%
Final simplification86.2%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* c b) (* d a)) (+ (* c c) (* d d))))
(t_1 (- (/ b c) (/ d (/ (pow c 2.0) a)))))
(if (<= c -5.5e+88)
t_1
(if (<= c -6e-100)
t_0
(if (<= c 7.2e-146)
(* (/ 1.0 d) (- (* c (/ b d)) a))
(if (<= c 3.5e+80) t_0 t_1))))))
double code(double a, double b, double c, double d) {
double t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
double t_1 = (b / c) - (d / (pow(c, 2.0) / a));
double tmp;
if (c <= -5.5e+88) {
tmp = t_1;
} else if (c <= -6e-100) {
tmp = t_0;
} else if (c <= 7.2e-146) {
tmp = (1.0 / d) * ((c * (b / d)) - a);
} else if (c <= 3.5e+80) {
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 = ((c * b) - (d * a)) / ((c * c) + (d * d))
t_1 = (b / c) - (d / ((c ** 2.0d0) / a))
if (c <= (-5.5d+88)) then
tmp = t_1
else if (c <= (-6d-100)) then
tmp = t_0
else if (c <= 7.2d-146) then
tmp = (1.0d0 / d) * ((c * (b / d)) - a)
else if (c <= 3.5d+80) 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 = ((c * b) - (d * a)) / ((c * c) + (d * d));
double t_1 = (b / c) - (d / (Math.pow(c, 2.0) / a));
double tmp;
if (c <= -5.5e+88) {
tmp = t_1;
} else if (c <= -6e-100) {
tmp = t_0;
} else if (c <= 7.2e-146) {
tmp = (1.0 / d) * ((c * (b / d)) - a);
} else if (c <= 3.5e+80) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(a, b, c, d): t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d)) t_1 = (b / c) - (d / (math.pow(c, 2.0) / a)) tmp = 0 if c <= -5.5e+88: tmp = t_1 elif c <= -6e-100: tmp = t_0 elif c <= 7.2e-146: tmp = (1.0 / d) * ((c * (b / d)) - a) elif c <= 3.5e+80: tmp = t_0 else: tmp = t_1 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d))) t_1 = Float64(Float64(b / c) - Float64(d / Float64((c ^ 2.0) / a))) tmp = 0.0 if (c <= -5.5e+88) tmp = t_1; elseif (c <= -6e-100) tmp = t_0; elseif (c <= 7.2e-146) tmp = Float64(Float64(1.0 / d) * Float64(Float64(c * Float64(b / d)) - a)); elseif (c <= 3.5e+80) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d)); t_1 = (b / c) - (d / ((c ^ 2.0) / a)); tmp = 0.0; if (c <= -5.5e+88) tmp = t_1; elseif (c <= -6e-100) tmp = t_0; elseif (c <= 7.2e-146) tmp = (1.0 / d) * ((c * (b / d)) - a); elseif (c <= 3.5e+80) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(b / c), $MachinePrecision] - N[(d / N[(N[Power[c, 2.0], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -5.5e+88], t$95$1, If[LessEqual[c, -6e-100], t$95$0, If[LessEqual[c, 7.2e-146], N[(N[(1.0 / d), $MachinePrecision] * N[(N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 3.5e+80], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
t_1 := \frac{b}{c} - \frac{d}{\frac{{c}^{2}}{a}}\\
\mathbf{if}\;c \leq -5.5 \cdot 10^{+88}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;c \leq -6 \cdot 10^{-100}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 7.2 \cdot 10^{-146}:\\
\;\;\;\;\frac{1}{d} \cdot \left(c \cdot \frac{b}{d} - a\right)\\
\mathbf{elif}\;c \leq 3.5 \cdot 10^{+80}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if c < -5.5e88 or 3.49999999999999994e80 < c Initial program 40.0%
Taylor expanded in c around inf 80.9%
+-commutative80.9%
mul-1-neg80.9%
unsub-neg80.9%
*-commutative80.9%
associate-/l*83.9%
Simplified83.9%
if -5.5e88 < c < -6.0000000000000001e-100 or 7.19999999999999957e-146 < c < 3.49999999999999994e80Initial program 86.4%
if -6.0000000000000001e-100 < c < 7.19999999999999957e-146Initial program 59.3%
Taylor expanded in c around 0 76.6%
+-commutative76.6%
mul-1-neg76.6%
unsub-neg76.6%
associate-/l*76.8%
associate-/r/71.0%
Simplified71.0%
*-un-lft-identity71.0%
unpow271.0%
times-frac74.5%
Applied egg-rr74.5%
associate-*l*81.6%
fma-neg81.6%
Applied egg-rr81.6%
fma-udef81.6%
*-lft-identity81.6%
associate-*l/81.3%
distribute-rgt-neg-in81.3%
distribute-lft-out81.3%
*-commutative81.3%
Simplified81.3%
Final simplification84.0%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* c b) (* d a)) (+ (* c c) (* d d)))))
(if (<= c -1e+93)
(/ b c)
(if (<= c -7.5e-100)
t_0
(if (<= c 7.5e-143)
(* (/ 1.0 d) (- (* c (/ b d)) a))
(if (<= c 3e+81) t_0 (/ b c)))))))
double code(double a, double b, double c, double d) {
double t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
double tmp;
if (c <= -1e+93) {
tmp = b / c;
} else if (c <= -7.5e-100) {
tmp = t_0;
} else if (c <= 7.5e-143) {
tmp = (1.0 / d) * ((c * (b / d)) - a);
} else if (c <= 3e+81) {
tmp = t_0;
} else {
tmp = b / c;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: tmp
t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d))
if (c <= (-1d+93)) then
tmp = b / c
else if (c <= (-7.5d-100)) then
tmp = t_0
else if (c <= 7.5d-143) then
tmp = (1.0d0 / d) * ((c * (b / d)) - a)
else if (c <= 3d+81) then
tmp = t_0
else
tmp = b / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
double tmp;
if (c <= -1e+93) {
tmp = b / c;
} else if (c <= -7.5e-100) {
tmp = t_0;
} else if (c <= 7.5e-143) {
tmp = (1.0 / d) * ((c * (b / d)) - a);
} else if (c <= 3e+81) {
tmp = t_0;
} else {
tmp = b / c;
}
return tmp;
}
def code(a, b, c, d): t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d)) tmp = 0 if c <= -1e+93: tmp = b / c elif c <= -7.5e-100: tmp = t_0 elif c <= 7.5e-143: tmp = (1.0 / d) * ((c * (b / d)) - a) elif c <= 3e+81: tmp = t_0 else: tmp = b / c return tmp
function code(a, b, c, d) t_0 = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d))) tmp = 0.0 if (c <= -1e+93) tmp = Float64(b / c); elseif (c <= -7.5e-100) tmp = t_0; elseif (c <= 7.5e-143) tmp = Float64(Float64(1.0 / d) * Float64(Float64(c * Float64(b / d)) - a)); elseif (c <= 3e+81) tmp = t_0; else tmp = Float64(b / c); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d)); tmp = 0.0; if (c <= -1e+93) tmp = b / c; elseif (c <= -7.5e-100) tmp = t_0; elseif (c <= 7.5e-143) tmp = (1.0 / d) * ((c * (b / d)) - a); elseif (c <= 3e+81) tmp = t_0; else tmp = b / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = 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, -1e+93], N[(b / c), $MachinePrecision], If[LessEqual[c, -7.5e-100], t$95$0, If[LessEqual[c, 7.5e-143], N[(N[(1.0 / d), $MachinePrecision] * N[(N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 3e+81], t$95$0, N[(b / c), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{if}\;c \leq -1 \cdot 10^{+93}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{elif}\;c \leq -7.5 \cdot 10^{-100}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 7.5 \cdot 10^{-143}:\\
\;\;\;\;\frac{1}{d} \cdot \left(c \cdot \frac{b}{d} - a\right)\\
\mathbf{elif}\;c \leq 3 \cdot 10^{+81}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if c < -1.00000000000000004e93 or 2.99999999999999997e81 < c Initial program 40.0%
Taylor expanded in c around inf 82.3%
if -1.00000000000000004e93 < c < -7.50000000000000015e-100 or 7.5000000000000003e-143 < c < 2.99999999999999997e81Initial program 86.4%
if -7.50000000000000015e-100 < c < 7.5000000000000003e-143Initial program 59.3%
Taylor expanded in c around 0 76.6%
+-commutative76.6%
mul-1-neg76.6%
unsub-neg76.6%
associate-/l*76.8%
associate-/r/71.0%
Simplified71.0%
*-un-lft-identity71.0%
unpow271.0%
times-frac74.5%
Applied egg-rr74.5%
associate-*l*81.6%
fma-neg81.6%
Applied egg-rr81.6%
fma-udef81.6%
*-lft-identity81.6%
associate-*l/81.3%
distribute-rgt-neg-in81.3%
distribute-lft-out81.3%
*-commutative81.3%
Simplified81.3%
Final simplification83.5%
(FPCore (a b c d)
:precision binary64
(if (<= c -8.2e+86)
(/ b c)
(if (<= c -6e-79)
(/ (* c b) (+ (* c c) (* d d)))
(if (<= c 4.5e+80) (* (/ 1.0 d) (- (* c (/ b d)) a)) (/ b c)))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -8.2e+86) {
tmp = b / c;
} else if (c <= -6e-79) {
tmp = (c * b) / ((c * c) + (d * d));
} else if (c <= 4.5e+80) {
tmp = (1.0 / d) * ((c * (b / d)) - a);
} 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 <= (-8.2d+86)) then
tmp = b / c
else if (c <= (-6d-79)) then
tmp = (c * b) / ((c * c) + (d * d))
else if (c <= 4.5d+80) then
tmp = (1.0d0 / d) * ((c * (b / d)) - a)
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 <= -8.2e+86) {
tmp = b / c;
} else if (c <= -6e-79) {
tmp = (c * b) / ((c * c) + (d * d));
} else if (c <= 4.5e+80) {
tmp = (1.0 / d) * ((c * (b / d)) - a);
} else {
tmp = b / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -8.2e+86: tmp = b / c elif c <= -6e-79: tmp = (c * b) / ((c * c) + (d * d)) elif c <= 4.5e+80: tmp = (1.0 / d) * ((c * (b / d)) - a) else: tmp = b / c return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -8.2e+86) tmp = Float64(b / c); elseif (c <= -6e-79) tmp = Float64(Float64(c * b) / Float64(Float64(c * c) + Float64(d * d))); elseif (c <= 4.5e+80) tmp = Float64(Float64(1.0 / d) * Float64(Float64(c * Float64(b / d)) - a)); else tmp = Float64(b / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -8.2e+86) tmp = b / c; elseif (c <= -6e-79) tmp = (c * b) / ((c * c) + (d * d)); elseif (c <= 4.5e+80) tmp = (1.0 / d) * ((c * (b / d)) - a); else tmp = b / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -8.2e+86], N[(b / c), $MachinePrecision], If[LessEqual[c, -6e-79], N[(N[(c * b), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 4.5e+80], N[(N[(1.0 / d), $MachinePrecision] * N[(N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], N[(b / c), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -8.2 \cdot 10^{+86}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{elif}\;c \leq -6 \cdot 10^{-79}:\\
\;\;\;\;\frac{c \cdot b}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;c \leq 4.5 \cdot 10^{+80}:\\
\;\;\;\;\frac{1}{d} \cdot \left(c \cdot \frac{b}{d} - a\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if c < -8.1999999999999998e86 or 4.50000000000000007e80 < c Initial program 40.0%
Taylor expanded in c around inf 82.3%
if -8.1999999999999998e86 < c < -5.99999999999999999e-79Initial program 92.9%
Taylor expanded in b around inf 73.2%
*-commutative73.2%
Simplified73.2%
if -5.99999999999999999e-79 < c < 4.50000000000000007e80Initial program 67.5%
Taylor expanded in c around 0 72.6%
+-commutative72.6%
mul-1-neg72.6%
unsub-neg72.6%
associate-/l*72.7%
associate-/r/69.0%
Simplified69.0%
*-un-lft-identity69.0%
unpow269.0%
times-frac72.6%
Applied egg-rr72.6%
associate-*l*77.1%
fma-neg77.1%
Applied egg-rr77.1%
fma-udef77.1%
*-lft-identity77.1%
associate-*l/76.9%
distribute-rgt-neg-in76.9%
distribute-lft-out76.9%
*-commutative76.9%
Simplified76.9%
Final simplification77.9%
(FPCore (a b c d) :precision binary64 (if (or (<= d -5.9e-21) (not (<= d 1.45e-34))) (- (* c (/ (/ b d) d)) (/ a d)) (/ b c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -5.9e-21) || !(d <= 1.45e-34)) {
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 ((d <= (-5.9d-21)) .or. (.not. (d <= 1.45d-34))) 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 ((d <= -5.9e-21) || !(d <= 1.45e-34)) {
tmp = (c * ((b / d) / d)) - (a / d);
} else {
tmp = b / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -5.9e-21) or not (d <= 1.45e-34): tmp = (c * ((b / d) / d)) - (a / d) else: tmp = b / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -5.9e-21) || !(d <= 1.45e-34)) tmp = Float64(Float64(c * Float64(Float64(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 ((d <= -5.9e-21) || ~((d <= 1.45e-34))) tmp = (c * ((b / d) / d)) - (a / d); else tmp = b / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -5.9e-21], N[Not[LessEqual[d, 1.45e-34]], $MachinePrecision]], N[(N[(c * N[(N[(b / d), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], N[(b / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -5.9 \cdot 10^{-21} \lor \neg \left(d \leq 1.45 \cdot 10^{-34}\right):\\
\;\;\;\;c \cdot \frac{\frac{b}{d}}{d} - \frac{a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if d < -5.9000000000000003e-21 or 1.4500000000000001e-34 < d Initial program 57.4%
Taylor expanded in c around 0 73.7%
+-commutative73.7%
mul-1-neg73.7%
unsub-neg73.7%
associate-/l*75.3%
associate-/r/76.0%
Simplified76.0%
*-un-lft-identity76.0%
unpow276.0%
times-frac78.7%
Applied egg-rr78.7%
associate-*l/78.7%
*-lft-identity78.7%
Simplified78.7%
if -5.9000000000000003e-21 < d < 1.4500000000000001e-34Initial program 70.7%
Taylor expanded in c around inf 68.9%
Final simplification74.2%
(FPCore (a b c d) :precision binary64 (if (or (<= d -5.2e+45) (not (<= d 3.9e+58))) (/ (- a) d) (/ b c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -5.2e+45) || !(d <= 3.9e+58)) {
tmp = -a / d;
} else {
tmp = b / c;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if ((d <= (-5.2d+45)) .or. (.not. (d <= 3.9d+58))) then
tmp = -a / d
else
tmp = b / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -5.2e+45) || !(d <= 3.9e+58)) {
tmp = -a / d;
} else {
tmp = b / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -5.2e+45) or not (d <= 3.9e+58): tmp = -a / d else: tmp = b / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -5.2e+45) || !(d <= 3.9e+58)) tmp = Float64(Float64(-a) / d); else tmp = Float64(b / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -5.2e+45) || ~((d <= 3.9e+58))) tmp = -a / d; else tmp = b / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -5.2e+45], N[Not[LessEqual[d, 3.9e+58]], $MachinePrecision]], N[((-a) / d), $MachinePrecision], N[(b / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -5.2 \cdot 10^{+45} \lor \neg \left(d \leq 3.9 \cdot 10^{+58}\right):\\
\;\;\;\;\frac{-a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if d < -5.20000000000000014e45 or 3.9000000000000001e58 < d Initial program 50.0%
Taylor expanded in c around 0 77.0%
associate-*r/77.0%
neg-mul-177.0%
Simplified77.0%
if -5.20000000000000014e45 < d < 3.9000000000000001e58Initial program 72.7%
Taylor expanded in c around inf 61.4%
Final simplification67.7%
(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 63.5%
Taylor expanded in c around inf 43.6%
Final simplification43.6%
(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 2024019
(FPCore (a b c d)
:name "Complex division, imag part"
:precision binary64
:herbie-target
(if (< (fabs d) (fabs c)) (/ (- b (* a (/ d c))) (+ c (* d (/ d c)))) (/ (+ (- a) (* b (/ c d))) (+ d (* c (/ c d)))))
(/ (- (* b c) (* a d)) (+ (* c c) (* d d))))