
(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 14 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b c d) :precision binary64 (/ (- (* b c) (* a d)) (+ (* c c) (* d d))))
double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = ((b * c) - (a * d)) / ((c * c) + (d * d))
end function
public static double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
def code(a, b, c, d): return ((b * c) - (a * d)) / ((c * c) + (d * d))
function code(a, b, c, d) return Float64(Float64(Float64(b * c) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d))) end
function tmp = code(a, b, c, d) tmp = ((b * c) - (a * d)) / ((c * c) + (d * d)); end
code[a_, b_, c_, d_] := N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}
\end{array}
(FPCore (a b c d) :precision binary64 (fma (/ c (hypot c d)) (/ b (hypot c d)) (* (/ d (hypot c d)) (/ (- a) (hypot c d)))))
double code(double a, double b, double c, double d) {
return fma((c / hypot(c, d)), (b / hypot(c, d)), ((d / hypot(c, d)) * (-a / hypot(c, d))));
}
function code(a, b, c, d) return fma(Float64(c / hypot(c, d)), Float64(b / hypot(c, d)), Float64(Float64(d / hypot(c, d)) * Float64(Float64(-a) / hypot(c, d)))) end
code[a_, b_, c_, d_] := N[(N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] + N[(N[(d / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[((-a) / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, \frac{d}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{-a}{\mathsf{hypot}\left(c, d\right)}\right)
\end{array}
Initial program 62.2%
div-sub59.8%
sub-neg59.8%
*-commutative59.8%
add-sqr-sqrt59.8%
times-frac62.1%
fma-def62.1%
hypot-def62.1%
hypot-def74.9%
associate-/l*79.6%
add-sqr-sqrt79.6%
pow279.6%
hypot-def79.6%
Applied egg-rr79.6%
div-inv79.5%
clear-num79.6%
add-sqr-sqrt41.4%
sqrt-unprod54.1%
sqr-neg54.1%
sqrt-unprod24.0%
add-sqr-sqrt50.5%
div-inv50.5%
associate-*l*49.6%
*-commutative49.6%
div-inv49.6%
unpow249.6%
times-frac52.1%
add-sqr-sqrt25.4%
sqrt-unprod61.5%
sqr-neg61.5%
sqrt-unprod51.4%
add-sqr-sqrt98.8%
Applied egg-rr98.8%
Final simplification98.8%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ c (hypot c d))) (t_1 (/ b (hypot c d))))
(if (<= d -3.7e+161)
(fma t_0 t_1 (/ (- a) d))
(if (<= d 5e+140)
(fma t_0 t_1 (/ (- a) (/ (pow (hypot c d) 2.0) d)))
(/ (- (* b (/ c d)) a) (hypot c d))))))
double code(double a, double b, double c, double d) {
double t_0 = c / hypot(c, d);
double t_1 = b / hypot(c, d);
double tmp;
if (d <= -3.7e+161) {
tmp = fma(t_0, t_1, (-a / d));
} else if (d <= 5e+140) {
tmp = fma(t_0, t_1, (-a / (pow(hypot(c, d), 2.0) / d)));
} else {
tmp = ((b * (c / d)) - a) / hypot(c, d);
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(c / hypot(c, d)) t_1 = Float64(b / hypot(c, d)) tmp = 0.0 if (d <= -3.7e+161) tmp = fma(t_0, t_1, Float64(Float64(-a) / d)); elseif (d <= 5e+140) tmp = fma(t_0, t_1, Float64(Float64(-a) / Float64((hypot(c, d) ^ 2.0) / d))); else tmp = Float64(Float64(Float64(b * Float64(c / d)) - a) / hypot(c, d)); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -3.7e+161], N[(t$95$0 * t$95$1 + N[((-a) / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 5e+140], N[(t$95$0 * t$95$1 + N[((-a) / N[(N[Power[N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision], 2.0], $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $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)}\\
\mathbf{if}\;d \leq -3.7 \cdot 10^{+161}:\\
\;\;\;\;\mathsf{fma}\left(t_0, t_1, \frac{-a}{d}\right)\\
\mathbf{elif}\;d \leq 5 \cdot 10^{+140}:\\
\;\;\;\;\mathsf{fma}\left(t_0, t_1, \frac{-a}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{d}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot \frac{c}{d} - a}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\end{array}
if d < -3.69999999999999979e161Initial program 34.7%
div-sub34.7%
sub-neg34.7%
*-commutative34.7%
add-sqr-sqrt34.7%
times-frac34.8%
fma-def34.8%
hypot-def34.8%
hypot-def42.7%
associate-/l*47.3%
add-sqr-sqrt47.3%
pow247.3%
hypot-def47.3%
Applied egg-rr47.3%
Taylor expanded in c around 0 87.0%
if -3.69999999999999979e161 < d < 5.00000000000000008e140Initial program 72.5%
div-sub69.3%
sub-neg69.3%
*-commutative69.3%
add-sqr-sqrt69.3%
times-frac72.3%
fma-def72.3%
hypot-def72.3%
hypot-def86.8%
associate-/l*92.1%
add-sqr-sqrt92.1%
pow292.1%
hypot-def92.1%
Applied egg-rr92.1%
if 5.00000000000000008e140 < d Initial program 33.6%
*-un-lft-identity33.6%
add-sqr-sqrt33.6%
times-frac33.6%
hypot-def33.6%
hypot-def55.5%
Applied egg-rr55.5%
Taylor expanded in c around 0 84.8%
neg-mul-184.8%
+-commutative84.8%
unsub-neg84.8%
associate-/l*96.8%
Simplified96.8%
expm1-log1p-u87.5%
expm1-udef38.4%
associate-*l/38.4%
*-un-lft-identity38.4%
div-inv38.4%
clear-num38.4%
Applied egg-rr38.4%
expm1-def87.8%
expm1-log1p97.1%
Simplified97.1%
Final simplification92.0%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ 1.0 (hypot c d)))
(t_1 (- (* c b) (* d a)))
(t_2 (/ t_1 (+ (* c c) (* d d)))))
(if (<= t_2 (- INFINITY))
(- (* t_0 (/ c (/ (hypot c d) b))) (* d (/ a (pow (hypot c d) 2.0))))
(if (<= t_2 5e+200)
(* t_0 (/ t_1 (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 = 1.0 / hypot(c, d);
double t_1 = (c * b) - (d * a);
double t_2 = t_1 / ((c * c) + (d * d));
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = (t_0 * (c / (hypot(c, d) / b))) - (d * (a / pow(hypot(c, d), 2.0)));
} else if (t_2 <= 5e+200) {
tmp = t_0 * (t_1 / 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(1.0 / hypot(c, d)) t_1 = Float64(Float64(c * b) - Float64(d * a)) t_2 = Float64(t_1 / Float64(Float64(c * c) + Float64(d * d))) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = Float64(Float64(t_0 * Float64(c / Float64(hypot(c, d) / b))) - Float64(d * Float64(a / (hypot(c, d) ^ 2.0)))); elseif (t_2 <= 5e+200) tmp = Float64(t_0 * Float64(t_1 / 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[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], N[(N[(t$95$0 * N[(c / N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(d * N[(a / N[Power[N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 5e+200], N[(t$95$0 * N[(t$95$1 / 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 := \frac{1}{\mathsf{hypot}\left(c, d\right)}\\
t_1 := c \cdot b - d \cdot a\\
t_2 := \frac{t_1}{c \cdot c + d \cdot d}\\
\mathbf{if}\;t_2 \leq -\infty:\\
\;\;\;\;t_0 \cdot \frac{c}{\frac{\mathsf{hypot}\left(c, d\right)}{b}} - d \cdot \frac{a}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\\
\mathbf{elif}\;t_2 \leq 5 \cdot 10^{+200}:\\
\;\;\;\;t_0 \cdot \frac{t_1}{\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))) < -inf.0Initial program 52.7%
div-sub33.6%
sub-neg33.6%
*-un-lft-identity33.6%
add-sqr-sqrt33.6%
times-frac33.6%
fma-def33.6%
hypot-def33.6%
hypot-def52.4%
associate-/l*69.8%
add-sqr-sqrt69.8%
pow269.8%
hypot-def69.8%
Applied egg-rr69.8%
fma-neg69.8%
*-commutative69.8%
associate-/l*93.5%
associate-/r/93.5%
*-commutative93.5%
Simplified93.5%
if -inf.0 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 5.00000000000000019e200Initial program 83.9%
*-un-lft-identity83.9%
add-sqr-sqrt83.9%
times-frac83.8%
hypot-def83.8%
hypot-def98.9%
Applied egg-rr98.9%
if 5.00000000000000019e200 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 16.4%
div-sub12.3%
sub-neg12.3%
*-commutative12.3%
add-sqr-sqrt12.3%
times-frac14.8%
fma-def14.8%
hypot-def14.8%
hypot-def43.1%
associate-/l*55.1%
add-sqr-sqrt55.1%
pow255.1%
hypot-def55.1%
Applied egg-rr55.1%
Taylor expanded in c around 0 72.8%
Final simplification90.9%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (- (* c b) (* d a))) (t_1 (/ t_0 (+ (* c c) (* d d)))))
(if (or (<= t_1 (- INFINITY)) (not (<= t_1 5e+200)))
(fma (/ c (hypot c d)) (/ b (hypot c d)) (/ (- a) d))
(* (/ 1.0 (hypot c d)) (/ t_0 (hypot c d))))))
double code(double a, double b, double c, double d) {
double t_0 = (c * b) - (d * a);
double t_1 = t_0 / ((c * c) + (d * d));
double tmp;
if ((t_1 <= -((double) INFINITY)) || !(t_1 <= 5e+200)) {
tmp = fma((c / hypot(c, d)), (b / hypot(c, d)), (-a / d));
} else {
tmp = (1.0 / hypot(c, d)) * (t_0 / hypot(c, d));
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(c * b) - Float64(d * a)) t_1 = Float64(t_0 / Float64(Float64(c * c) + Float64(d * d))) tmp = 0.0 if ((t_1 <= Float64(-Inf)) || !(t_1 <= 5e+200)) tmp = fma(Float64(c / hypot(c, d)), Float64(b / hypot(c, d)), Float64(Float64(-a) / d)); else tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(t_0 / hypot(c, d))); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, (-Infinity)], N[Not[LessEqual[t$95$1, 5e+200]], $MachinePrecision]], N[(N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] + N[((-a) / d), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := c \cdot b - d \cdot a\\
t_1 := \frac{t_0}{c \cdot c + d \cdot d}\\
\mathbf{if}\;t_1 \leq -\infty \lor \neg \left(t_1 \leq 5 \cdot 10^{+200}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, \frac{-a}{d}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{t_0}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\end{array}
if (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < -inf.0 or 5.00000000000000019e200 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 22.8%
div-sub16.1%
sub-neg16.1%
*-commutative16.1%
add-sqr-sqrt16.1%
times-frac22.3%
fma-def22.3%
hypot-def22.3%
hypot-def48.9%
associate-/l*61.9%
add-sqr-sqrt61.9%
pow261.9%
hypot-def61.9%
Applied egg-rr61.9%
Taylor expanded in c around 0 75.5%
if -inf.0 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 5.00000000000000019e200Initial program 83.9%
*-un-lft-identity83.9%
add-sqr-sqrt83.9%
times-frac83.8%
hypot-def83.8%
hypot-def98.9%
Applied egg-rr98.9%
Final simplification90.6%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (- (* c b) (* d a))))
(if (<= (/ t_0 (+ (* c c) (* d d))) 1e+230)
(* (/ 1.0 (hypot c d)) (/ t_0 (hypot c d)))
(* (/ 1.0 d) (- (/ b (/ d c)) a)))))
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+230) {
tmp = (1.0 / hypot(c, d)) * (t_0 / hypot(c, d));
} else {
tmp = (1.0 / d) * ((b / (d / c)) - a);
}
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+230) {
tmp = (1.0 / Math.hypot(c, d)) * (t_0 / Math.hypot(c, d));
} else {
tmp = (1.0 / d) * ((b / (d / c)) - a);
}
return tmp;
}
def code(a, b, c, d): t_0 = (c * b) - (d * a) tmp = 0 if (t_0 / ((c * c) + (d * d))) <= 1e+230: tmp = (1.0 / math.hypot(c, d)) * (t_0 / math.hypot(c, d)) else: tmp = (1.0 / d) * ((b / (d / c)) - a) 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+230) tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(t_0 / hypot(c, d))); else tmp = Float64(Float64(1.0 / d) * Float64(Float64(b / Float64(d / c)) - a)); 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+230) tmp = (1.0 / hypot(c, d)) * (t_0 / hypot(c, d)); else tmp = (1.0 / d) * ((b / (d / c)) - a); 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+230], 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[(1.0 / d), $MachinePrecision] * N[(N[(b / N[(d / c), $MachinePrecision]), $MachinePrecision] - a), $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^{+230}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{t_0}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{d} \cdot \left(\frac{b}{\frac{d}{c}} - a\right)\\
\end{array}
\end{array}
if (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 1.0000000000000001e230Initial program 81.3%
*-un-lft-identity81.3%
add-sqr-sqrt81.3%
times-frac81.3%
hypot-def81.3%
hypot-def95.4%
Applied egg-rr95.4%
if 1.0000000000000001e230 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 14.2%
*-un-lft-identity14.2%
add-sqr-sqrt14.2%
times-frac14.2%
hypot-def14.2%
hypot-def18.9%
Applied egg-rr18.9%
Taylor expanded in c around 0 23.1%
neg-mul-123.1%
+-commutative23.1%
unsub-neg23.1%
associate-/l*31.4%
Simplified31.4%
Taylor expanded in c around 0 61.8%
Final simplification85.8%
(FPCore (a b c d)
:precision binary64
(if (<= c -3.4e+29)
(- (/ b c) (/ d (* c (/ c a))))
(if (<= c 1.2e-133)
(* (/ 1.0 d) (- (/ b (/ d c)) a))
(if (<= c 1.7e+42)
(* (- (* c b) (* d a)) (pow (hypot c d) -2.0))
(- (/ b c) (* (/ d c) (/ a c)))))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -3.4e+29) {
tmp = (b / c) - (d / (c * (c / a)));
} else if (c <= 1.2e-133) {
tmp = (1.0 / d) * ((b / (d / c)) - a);
} else if (c <= 1.7e+42) {
tmp = ((c * b) - (d * a)) * pow(hypot(c, d), -2.0);
} else {
tmp = (b / c) - ((d / c) * (a / c));
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -3.4e+29) {
tmp = (b / c) - (d / (c * (c / a)));
} else if (c <= 1.2e-133) {
tmp = (1.0 / d) * ((b / (d / c)) - a);
} else if (c <= 1.7e+42) {
tmp = ((c * b) - (d * a)) * Math.pow(Math.hypot(c, d), -2.0);
} else {
tmp = (b / c) - ((d / c) * (a / c));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -3.4e+29: tmp = (b / c) - (d / (c * (c / a))) elif c <= 1.2e-133: tmp = (1.0 / d) * ((b / (d / c)) - a) elif c <= 1.7e+42: tmp = ((c * b) - (d * a)) * math.pow(math.hypot(c, d), -2.0) else: tmp = (b / c) - ((d / c) * (a / c)) return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -3.4e+29) tmp = Float64(Float64(b / c) - Float64(d / Float64(c * Float64(c / a)))); elseif (c <= 1.2e-133) tmp = Float64(Float64(1.0 / d) * Float64(Float64(b / Float64(d / c)) - a)); elseif (c <= 1.7e+42) tmp = Float64(Float64(Float64(c * b) - Float64(d * a)) * (hypot(c, d) ^ -2.0)); else tmp = Float64(Float64(b / c) - Float64(Float64(d / c) * Float64(a / c))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -3.4e+29) tmp = (b / c) - (d / (c * (c / a))); elseif (c <= 1.2e-133) tmp = (1.0 / d) * ((b / (d / c)) - a); elseif (c <= 1.7e+42) tmp = ((c * b) - (d * a)) * (hypot(c, d) ^ -2.0); else tmp = (b / c) - ((d / c) * (a / c)); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -3.4e+29], N[(N[(b / c), $MachinePrecision] - N[(d / N[(c * N[(c / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.2e-133], N[(N[(1.0 / d), $MachinePrecision] * N[(N[(b / N[(d / c), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.7e+42], N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] * N[Power[N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision], -2.0], $MachinePrecision]), $MachinePrecision], N[(N[(b / c), $MachinePrecision] - N[(N[(d / c), $MachinePrecision] * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -3.4 \cdot 10^{+29}:\\
\;\;\;\;\frac{b}{c} - \frac{d}{c \cdot \frac{c}{a}}\\
\mathbf{elif}\;c \leq 1.2 \cdot 10^{-133}:\\
\;\;\;\;\frac{1}{d} \cdot \left(\frac{b}{\frac{d}{c}} - a\right)\\
\mathbf{elif}\;c \leq 1.7 \cdot 10^{+42}:\\
\;\;\;\;\left(c \cdot b - d \cdot a\right) \cdot {\left(\mathsf{hypot}\left(c, d\right)\right)}^{-2}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c} - \frac{d}{c} \cdot \frac{a}{c}\\
\end{array}
\end{array}
if c < -3.39999999999999981e29Initial program 44.2%
Taylor expanded in c around inf 70.4%
+-commutative70.4%
mul-1-neg70.4%
unsub-neg70.4%
associate-/l*68.8%
associate-/r/70.6%
Simplified70.6%
*-un-lft-identity70.6%
unpow270.6%
times-frac77.7%
Applied egg-rr77.7%
associate-*l/77.7%
*-lft-identity77.7%
Simplified77.7%
*-commutative77.7%
clear-num77.7%
un-div-inv77.7%
div-inv77.7%
clear-num77.8%
Applied egg-rr77.8%
if -3.39999999999999981e29 < c < 1.2e-133Initial program 69.8%
*-un-lft-identity69.8%
add-sqr-sqrt69.8%
times-frac69.7%
hypot-def69.7%
hypot-def81.7%
Applied egg-rr81.7%
Taylor expanded in c around 0 47.8%
neg-mul-147.8%
+-commutative47.8%
unsub-neg47.8%
associate-/l*49.7%
Simplified49.7%
Taylor expanded in c around 0 85.5%
if 1.2e-133 < c < 1.69999999999999988e42Initial program 86.2%
clear-num86.2%
associate-/r/86.0%
add-sqr-sqrt86.0%
pow286.0%
hypot-def86.0%
Applied egg-rr86.0%
expm1-log1p-u84.2%
expm1-udef38.8%
pow-flip38.8%
metadata-eval38.8%
Applied egg-rr38.8%
expm1-def84.4%
expm1-log1p86.4%
Simplified86.4%
if 1.69999999999999988e42 < c Initial program 49.4%
Taylor expanded in c around inf 73.5%
+-commutative73.5%
mul-1-neg73.5%
unsub-neg73.5%
associate-/l*75.8%
associate-/r/75.8%
Simplified75.8%
*-un-lft-identity75.8%
unpow275.8%
times-frac82.5%
Applied egg-rr82.5%
associate-*l/82.5%
*-lft-identity82.5%
Simplified82.5%
associate-*l/85.6%
clear-num85.6%
Applied egg-rr85.6%
associate-/r/85.6%
*-commutative85.6%
associate-*r/85.6%
*-rgt-identity85.6%
associate-*r/85.7%
Simplified85.7%
Final simplification84.1%
(FPCore (a b c d)
:precision binary64
(if (<= c -3.4e+29)
(- (/ b c) (/ d (* c (/ c a))))
(if (<= c 1.15e-131)
(* (/ 1.0 d) (- (/ b (/ d c)) a))
(if (<= c 2.6e+44)
(/ (fma (- d) a (* c b)) (+ (* c c) (* d d)))
(- (/ b c) (* (/ d c) (/ a c)))))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -3.4e+29) {
tmp = (b / c) - (d / (c * (c / a)));
} else if (c <= 1.15e-131) {
tmp = (1.0 / d) * ((b / (d / c)) - a);
} else if (c <= 2.6e+44) {
tmp = fma(-d, a, (c * b)) / ((c * c) + (d * d));
} else {
tmp = (b / c) - ((d / c) * (a / c));
}
return tmp;
}
function code(a, b, c, d) tmp = 0.0 if (c <= -3.4e+29) tmp = Float64(Float64(b / c) - Float64(d / Float64(c * Float64(c / a)))); elseif (c <= 1.15e-131) tmp = Float64(Float64(1.0 / d) * Float64(Float64(b / Float64(d / c)) - a)); elseif (c <= 2.6e+44) tmp = Float64(fma(Float64(-d), a, Float64(c * b)) / Float64(Float64(c * c) + Float64(d * d))); else tmp = Float64(Float64(b / c) - Float64(Float64(d / c) * Float64(a / c))); end return tmp end
code[a_, b_, c_, d_] := If[LessEqual[c, -3.4e+29], N[(N[(b / c), $MachinePrecision] - N[(d / N[(c * N[(c / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.15e-131], N[(N[(1.0 / d), $MachinePrecision] * N[(N[(b / N[(d / c), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 2.6e+44], N[(N[((-d) * a + N[(c * b), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b / c), $MachinePrecision] - N[(N[(d / c), $MachinePrecision] * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -3.4 \cdot 10^{+29}:\\
\;\;\;\;\frac{b}{c} - \frac{d}{c \cdot \frac{c}{a}}\\
\mathbf{elif}\;c \leq 1.15 \cdot 10^{-131}:\\
\;\;\;\;\frac{1}{d} \cdot \left(\frac{b}{\frac{d}{c}} - a\right)\\
\mathbf{elif}\;c \leq 2.6 \cdot 10^{+44}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-d, a, c \cdot b\right)}{c \cdot c + d \cdot d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c} - \frac{d}{c} \cdot \frac{a}{c}\\
\end{array}
\end{array}
if c < -3.39999999999999981e29Initial program 44.2%
Taylor expanded in c around inf 70.4%
+-commutative70.4%
mul-1-neg70.4%
unsub-neg70.4%
associate-/l*68.8%
associate-/r/70.6%
Simplified70.6%
*-un-lft-identity70.6%
unpow270.6%
times-frac77.7%
Applied egg-rr77.7%
associate-*l/77.7%
*-lft-identity77.7%
Simplified77.7%
*-commutative77.7%
clear-num77.7%
un-div-inv77.7%
div-inv77.7%
clear-num77.8%
Applied egg-rr77.8%
if -3.39999999999999981e29 < c < 1.15000000000000011e-131Initial program 70.1%
*-un-lft-identity70.1%
add-sqr-sqrt70.1%
times-frac70.0%
hypot-def70.0%
hypot-def81.9%
Applied egg-rr81.9%
Taylor expanded in c around 0 48.3%
neg-mul-148.3%
+-commutative48.3%
unsub-neg48.3%
associate-/l*50.1%
Simplified50.1%
Taylor expanded in c around 0 85.7%
if 1.15000000000000011e-131 < c < 2.5999999999999999e44Initial program 85.9%
sub-neg85.9%
+-commutative85.9%
*-commutative85.9%
distribute-lft-neg-in85.9%
fma-def85.9%
Applied egg-rr85.9%
if 2.5999999999999999e44 < c Initial program 49.4%
Taylor expanded in c around inf 73.5%
+-commutative73.5%
mul-1-neg73.5%
unsub-neg73.5%
associate-/l*75.8%
associate-/r/75.8%
Simplified75.8%
*-un-lft-identity75.8%
unpow275.8%
times-frac82.5%
Applied egg-rr82.5%
associate-*l/82.5%
*-lft-identity82.5%
Simplified82.5%
associate-*l/85.6%
clear-num85.6%
Applied egg-rr85.6%
associate-/r/85.6%
*-commutative85.6%
associate-*r/85.6%
*-rgt-identity85.6%
associate-*r/85.7%
Simplified85.7%
Final simplification84.1%
(FPCore (a b c d)
:precision binary64
(if (<= c -1.25e+29)
(- (/ b c) (/ d (* c (/ c a))))
(if (<= c 6.5e-131)
(* (/ 1.0 d) (- (/ b (/ d c)) a))
(if (<= c 1.06e+40)
(/ (- (* c b) (* d a)) (+ (* c c) (* d d)))
(- (/ b c) (* (/ d c) (/ a c)))))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -1.25e+29) {
tmp = (b / c) - (d / (c * (c / a)));
} else if (c <= 6.5e-131) {
tmp = (1.0 / d) * ((b / (d / c)) - a);
} else if (c <= 1.06e+40) {
tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
} else {
tmp = (b / c) - ((d / c) * (a / 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 <= (-1.25d+29)) then
tmp = (b / c) - (d / (c * (c / a)))
else if (c <= 6.5d-131) then
tmp = (1.0d0 / d) * ((b / (d / c)) - a)
else if (c <= 1.06d+40) then
tmp = ((c * b) - (d * a)) / ((c * c) + (d * d))
else
tmp = (b / c) - ((d / c) * (a / c))
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -1.25e+29) {
tmp = (b / c) - (d / (c * (c / a)));
} else if (c <= 6.5e-131) {
tmp = (1.0 / d) * ((b / (d / c)) - a);
} else if (c <= 1.06e+40) {
tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
} else {
tmp = (b / c) - ((d / c) * (a / c));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -1.25e+29: tmp = (b / c) - (d / (c * (c / a))) elif c <= 6.5e-131: tmp = (1.0 / d) * ((b / (d / c)) - a) elif c <= 1.06e+40: tmp = ((c * b) - (d * a)) / ((c * c) + (d * d)) else: tmp = (b / c) - ((d / c) * (a / c)) return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -1.25e+29) tmp = Float64(Float64(b / c) - Float64(d / Float64(c * Float64(c / a)))); elseif (c <= 6.5e-131) tmp = Float64(Float64(1.0 / d) * Float64(Float64(b / Float64(d / c)) - a)); elseif (c <= 1.06e+40) tmp = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d))); else tmp = Float64(Float64(b / c) - Float64(Float64(d / c) * Float64(a / c))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -1.25e+29) tmp = (b / c) - (d / (c * (c / a))); elseif (c <= 6.5e-131) tmp = (1.0 / d) * ((b / (d / c)) - a); elseif (c <= 1.06e+40) tmp = ((c * b) - (d * a)) / ((c * c) + (d * d)); else tmp = (b / c) - ((d / c) * (a / c)); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -1.25e+29], N[(N[(b / c), $MachinePrecision] - N[(d / N[(c * N[(c / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 6.5e-131], N[(N[(1.0 / d), $MachinePrecision] * N[(N[(b / N[(d / c), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.06e+40], N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b / c), $MachinePrecision] - N[(N[(d / c), $MachinePrecision] * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.25 \cdot 10^{+29}:\\
\;\;\;\;\frac{b}{c} - \frac{d}{c \cdot \frac{c}{a}}\\
\mathbf{elif}\;c \leq 6.5 \cdot 10^{-131}:\\
\;\;\;\;\frac{1}{d} \cdot \left(\frac{b}{\frac{d}{c}} - a\right)\\
\mathbf{elif}\;c \leq 1.06 \cdot 10^{+40}:\\
\;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c} - \frac{d}{c} \cdot \frac{a}{c}\\
\end{array}
\end{array}
if c < -1.25e29Initial program 44.2%
Taylor expanded in c around inf 70.4%
+-commutative70.4%
mul-1-neg70.4%
unsub-neg70.4%
associate-/l*68.8%
associate-/r/70.6%
Simplified70.6%
*-un-lft-identity70.6%
unpow270.6%
times-frac77.7%
Applied egg-rr77.7%
associate-*l/77.7%
*-lft-identity77.7%
Simplified77.7%
*-commutative77.7%
clear-num77.7%
un-div-inv77.7%
div-inv77.7%
clear-num77.8%
Applied egg-rr77.8%
if -1.25e29 < c < 6.5000000000000002e-131Initial program 70.1%
*-un-lft-identity70.1%
add-sqr-sqrt70.1%
times-frac70.0%
hypot-def70.0%
hypot-def81.9%
Applied egg-rr81.9%
Taylor expanded in c around 0 48.3%
neg-mul-148.3%
+-commutative48.3%
unsub-neg48.3%
associate-/l*50.1%
Simplified50.1%
Taylor expanded in c around 0 85.7%
if 6.5000000000000002e-131 < c < 1.05999999999999996e40Initial program 85.9%
if 1.05999999999999996e40 < c Initial program 49.4%
Taylor expanded in c around inf 73.5%
+-commutative73.5%
mul-1-neg73.5%
unsub-neg73.5%
associate-/l*75.8%
associate-/r/75.8%
Simplified75.8%
*-un-lft-identity75.8%
unpow275.8%
times-frac82.5%
Applied egg-rr82.5%
associate-*l/82.5%
*-lft-identity82.5%
Simplified82.5%
associate-*l/85.6%
clear-num85.6%
Applied egg-rr85.6%
associate-/r/85.6%
*-commutative85.6%
associate-*r/85.6%
*-rgt-identity85.6%
associate-*r/85.7%
Simplified85.7%
Final simplification84.1%
(FPCore (a b c d) :precision binary64 (if (or (<= c -1.45e+29) (not (<= c 2.4e+20))) (/ (- b (* d (/ a c))) c) (* (/ 1.0 d) (- (/ b (/ d c)) a))))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -1.45e+29) || !(c <= 2.4e+20)) {
tmp = (b - (d * (a / c))) / c;
} else {
tmp = (1.0 / d) * ((b / (d / c)) - a);
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if ((c <= (-1.45d+29)) .or. (.not. (c <= 2.4d+20))) then
tmp = (b - (d * (a / c))) / c
else
tmp = (1.0d0 / d) * ((b / (d / c)) - a)
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -1.45e+29) || !(c <= 2.4e+20)) {
tmp = (b - (d * (a / c))) / c;
} else {
tmp = (1.0 / d) * ((b / (d / c)) - a);
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -1.45e+29) or not (c <= 2.4e+20): tmp = (b - (d * (a / c))) / c else: tmp = (1.0 / d) * ((b / (d / c)) - a) return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -1.45e+29) || !(c <= 2.4e+20)) tmp = Float64(Float64(b - Float64(d * Float64(a / c))) / c); else tmp = Float64(Float64(1.0 / d) * Float64(Float64(b / Float64(d / c)) - a)); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((c <= -1.45e+29) || ~((c <= 2.4e+20))) tmp = (b - (d * (a / c))) / c; else tmp = (1.0 / d) * ((b / (d / c)) - a); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -1.45e+29], N[Not[LessEqual[c, 2.4e+20]], $MachinePrecision]], N[(N[(b - N[(d * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], N[(N[(1.0 / d), $MachinePrecision] * N[(N[(b / N[(d / c), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.45 \cdot 10^{+29} \lor \neg \left(c \leq 2.4 \cdot 10^{+20}\right):\\
\;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{d} \cdot \left(\frac{b}{\frac{d}{c}} - a\right)\\
\end{array}
\end{array}
if c < -1.45e29 or 2.4e20 < c Initial program 48.4%
Taylor expanded in c around inf 71.3%
+-commutative71.3%
mul-1-neg71.3%
unsub-neg71.3%
associate-/l*71.7%
associate-/r/72.5%
Simplified72.5%
*-un-lft-identity72.5%
unpow272.5%
times-frac79.0%
Applied egg-rr79.0%
associate-*l/79.0%
*-lft-identity79.0%
Simplified79.0%
associate-*l/80.5%
sub-div80.5%
Applied egg-rr80.5%
if -1.45e29 < c < 2.4e20Initial program 74.2%
*-un-lft-identity74.2%
add-sqr-sqrt74.2%
times-frac74.1%
hypot-def74.1%
hypot-def84.2%
Applied egg-rr84.2%
Taylor expanded in c around 0 49.3%
neg-mul-149.3%
+-commutative49.3%
unsub-neg49.3%
associate-/l*50.7%
Simplified50.7%
Taylor expanded in c around 0 82.4%
Final simplification81.5%
(FPCore (a b c d) :precision binary64 (if (or (<= c -1.5e+29) (not (<= c 9.5e+18))) (- (/ b c) (* (/ d c) (/ a c))) (* (/ 1.0 d) (- (/ b (/ d c)) a))))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -1.5e+29) || !(c <= 9.5e+18)) {
tmp = (b / c) - ((d / c) * (a / c));
} else {
tmp = (1.0 / d) * ((b / (d / c)) - a);
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if ((c <= (-1.5d+29)) .or. (.not. (c <= 9.5d+18))) then
tmp = (b / c) - ((d / c) * (a / c))
else
tmp = (1.0d0 / d) * ((b / (d / c)) - a)
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -1.5e+29) || !(c <= 9.5e+18)) {
tmp = (b / c) - ((d / c) * (a / c));
} else {
tmp = (1.0 / d) * ((b / (d / c)) - a);
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -1.5e+29) or not (c <= 9.5e+18): tmp = (b / c) - ((d / c) * (a / c)) else: tmp = (1.0 / d) * ((b / (d / c)) - a) return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -1.5e+29) || !(c <= 9.5e+18)) tmp = Float64(Float64(b / c) - Float64(Float64(d / c) * Float64(a / c))); else tmp = Float64(Float64(1.0 / d) * Float64(Float64(b / Float64(d / c)) - a)); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((c <= -1.5e+29) || ~((c <= 9.5e+18))) tmp = (b / c) - ((d / c) * (a / c)); else tmp = (1.0 / d) * ((b / (d / c)) - a); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -1.5e+29], N[Not[LessEqual[c, 9.5e+18]], $MachinePrecision]], N[(N[(b / c), $MachinePrecision] - N[(N[(d / c), $MachinePrecision] * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / d), $MachinePrecision] * N[(N[(b / N[(d / c), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.5 \cdot 10^{+29} \lor \neg \left(c \leq 9.5 \cdot 10^{+18}\right):\\
\;\;\;\;\frac{b}{c} - \frac{d}{c} \cdot \frac{a}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{d} \cdot \left(\frac{b}{\frac{d}{c}} - a\right)\\
\end{array}
\end{array}
if c < -1.5e29 or 9.5e18 < c Initial program 48.4%
Taylor expanded in c around inf 71.3%
+-commutative71.3%
mul-1-neg71.3%
unsub-neg71.3%
associate-/l*71.7%
associate-/r/72.5%
Simplified72.5%
*-un-lft-identity72.5%
unpow272.5%
times-frac79.0%
Applied egg-rr79.0%
associate-*l/79.0%
*-lft-identity79.0%
Simplified79.0%
associate-*l/80.5%
clear-num80.5%
Applied egg-rr80.5%
associate-/r/80.5%
*-commutative80.5%
associate-*r/80.5%
*-rgt-identity80.5%
associate-*r/80.6%
Simplified80.6%
if -1.5e29 < c < 9.5e18Initial program 74.2%
*-un-lft-identity74.2%
add-sqr-sqrt74.2%
times-frac74.1%
hypot-def74.1%
hypot-def84.2%
Applied egg-rr84.2%
Taylor expanded in c around 0 49.3%
neg-mul-149.3%
+-commutative49.3%
unsub-neg49.3%
associate-/l*50.7%
Simplified50.7%
Taylor expanded in c around 0 82.4%
Final simplification81.6%
(FPCore (a b c d)
:precision binary64
(if (<= c -1.35e+29)
(- (/ b c) (/ d (* c (/ c a))))
(if (<= c 2e+19)
(* (/ 1.0 d) (- (/ b (/ d c)) a))
(- (/ b c) (* (/ d c) (/ a c))))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -1.35e+29) {
tmp = (b / c) - (d / (c * (c / a)));
} else if (c <= 2e+19) {
tmp = (1.0 / d) * ((b / (d / c)) - a);
} else {
tmp = (b / c) - ((d / c) * (a / 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 <= (-1.35d+29)) then
tmp = (b / c) - (d / (c * (c / a)))
else if (c <= 2d+19) then
tmp = (1.0d0 / d) * ((b / (d / c)) - a)
else
tmp = (b / c) - ((d / c) * (a / c))
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -1.35e+29) {
tmp = (b / c) - (d / (c * (c / a)));
} else if (c <= 2e+19) {
tmp = (1.0 / d) * ((b / (d / c)) - a);
} else {
tmp = (b / c) - ((d / c) * (a / c));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -1.35e+29: tmp = (b / c) - (d / (c * (c / a))) elif c <= 2e+19: tmp = (1.0 / d) * ((b / (d / c)) - a) else: tmp = (b / c) - ((d / c) * (a / c)) return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -1.35e+29) tmp = Float64(Float64(b / c) - Float64(d / Float64(c * Float64(c / a)))); elseif (c <= 2e+19) tmp = Float64(Float64(1.0 / d) * Float64(Float64(b / Float64(d / c)) - a)); else tmp = Float64(Float64(b / c) - Float64(Float64(d / c) * Float64(a / c))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -1.35e+29) tmp = (b / c) - (d / (c * (c / a))); elseif (c <= 2e+19) tmp = (1.0 / d) * ((b / (d / c)) - a); else tmp = (b / c) - ((d / c) * (a / c)); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -1.35e+29], N[(N[(b / c), $MachinePrecision] - N[(d / N[(c * N[(c / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 2e+19], N[(N[(1.0 / d), $MachinePrecision] * N[(N[(b / N[(d / c), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], N[(N[(b / c), $MachinePrecision] - N[(N[(d / c), $MachinePrecision] * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.35 \cdot 10^{+29}:\\
\;\;\;\;\frac{b}{c} - \frac{d}{c \cdot \frac{c}{a}}\\
\mathbf{elif}\;c \leq 2 \cdot 10^{+19}:\\
\;\;\;\;\frac{1}{d} \cdot \left(\frac{b}{\frac{d}{c}} - a\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c} - \frac{d}{c} \cdot \frac{a}{c}\\
\end{array}
\end{array}
if c < -1.35e29Initial program 44.2%
Taylor expanded in c around inf 70.4%
+-commutative70.4%
mul-1-neg70.4%
unsub-neg70.4%
associate-/l*68.8%
associate-/r/70.6%
Simplified70.6%
*-un-lft-identity70.6%
unpow270.6%
times-frac77.7%
Applied egg-rr77.7%
associate-*l/77.7%
*-lft-identity77.7%
Simplified77.7%
*-commutative77.7%
clear-num77.7%
un-div-inv77.7%
div-inv77.7%
clear-num77.8%
Applied egg-rr77.8%
if -1.35e29 < c < 2e19Initial program 74.2%
*-un-lft-identity74.2%
add-sqr-sqrt74.2%
times-frac74.1%
hypot-def74.1%
hypot-def84.2%
Applied egg-rr84.2%
Taylor expanded in c around 0 49.3%
neg-mul-149.3%
+-commutative49.3%
unsub-neg49.3%
associate-/l*50.7%
Simplified50.7%
Taylor expanded in c around 0 82.4%
if 2e19 < c Initial program 51.8%
Taylor expanded in c around inf 72.0%
+-commutative72.0%
mul-1-neg72.0%
unsub-neg72.0%
associate-/l*74.0%
associate-/r/74.0%
Simplified74.0%
*-un-lft-identity74.0%
unpow274.0%
times-frac80.0%
Applied egg-rr80.0%
associate-*l/80.1%
*-lft-identity80.1%
Simplified80.1%
associate-*l/82.8%
clear-num82.8%
Applied egg-rr82.8%
associate-/r/82.8%
*-commutative82.8%
associate-*r/82.8%
*-rgt-identity82.8%
associate-*r/82.9%
Simplified82.9%
Final simplification81.6%
(FPCore (a b c d) :precision binary64 (if (or (<= d -6.8e+108) (not (<= d 55.0))) (/ (- a) d) (/ (- b (* d (/ a c))) c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -6.8e+108) || !(d <= 55.0)) {
tmp = -a / d;
} else {
tmp = (b - (d * (a / 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 <= (-6.8d+108)) .or. (.not. (d <= 55.0d0))) then
tmp = -a / d
else
tmp = (b - (d * (a / c))) / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -6.8e+108) || !(d <= 55.0)) {
tmp = -a / d;
} else {
tmp = (b - (d * (a / c))) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -6.8e+108) or not (d <= 55.0): tmp = -a / d else: tmp = (b - (d * (a / c))) / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -6.8e+108) || !(d <= 55.0)) tmp = Float64(Float64(-a) / d); else tmp = Float64(Float64(b - Float64(d * Float64(a / c))) / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -6.8e+108) || ~((d <= 55.0))) tmp = -a / d; else tmp = (b - (d * (a / c))) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -6.8e+108], N[Not[LessEqual[d, 55.0]], $MachinePrecision]], N[((-a) / d), $MachinePrecision], N[(N[(b - N[(d * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -6.8 \cdot 10^{+108} \lor \neg \left(d \leq 55\right):\\
\;\;\;\;\frac{-a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\
\end{array}
\end{array}
if d < -6.79999999999999992e108 or 55 < d Initial program 48.3%
Taylor expanded in c around 0 73.0%
associate-*r/73.0%
neg-mul-173.0%
Simplified73.0%
if -6.79999999999999992e108 < d < 55Initial program 74.4%
Taylor expanded in c around inf 73.4%
+-commutative73.4%
mul-1-neg73.4%
unsub-neg73.4%
associate-/l*75.1%
associate-/r/72.5%
Simplified72.5%
*-un-lft-identity72.5%
unpow272.5%
times-frac75.3%
Applied egg-rr75.3%
associate-*l/75.3%
*-lft-identity75.3%
Simplified75.3%
associate-*l/78.9%
sub-div79.0%
Applied egg-rr79.0%
Final simplification76.2%
(FPCore (a b c d) :precision binary64 (if (or (<= c -2.6e+32) (not (<= c 2.1e+18))) (/ b c) (/ (- a) d)))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -2.6e+32) || !(c <= 2.1e+18)) {
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+32)) .or. (.not. (c <= 2.1d+18))) 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+32) || !(c <= 2.1e+18)) {
tmp = b / c;
} else {
tmp = -a / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -2.6e+32) or not (c <= 2.1e+18): tmp = b / c else: tmp = -a / d return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -2.6e+32) || !(c <= 2.1e+18)) tmp = Float64(b / c); else tmp = Float64(Float64(-a) / d); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((c <= -2.6e+32) || ~((c <= 2.1e+18))) tmp = b / c; else tmp = -a / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -2.6e+32], N[Not[LessEqual[c, 2.1e+18]], $MachinePrecision]], N[(b / c), $MachinePrecision], N[((-a) / d), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -2.6 \cdot 10^{+32} \lor \neg \left(c \leq 2.1 \cdot 10^{+18}\right):\\
\;\;\;\;\frac{b}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{-a}{d}\\
\end{array}
\end{array}
if c < -2.6000000000000002e32 or 2.1e18 < c Initial program 47.6%
Taylor expanded in c around inf 69.5%
if -2.6000000000000002e32 < c < 2.1e18Initial program 74.5%
Taylor expanded in c around 0 69.3%
associate-*r/69.3%
neg-mul-169.3%
Simplified69.3%
Final simplification69.4%
(FPCore (a b c d) :precision binary64 (/ b c))
double code(double a, double b, double c, double d) {
return b / c;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = b / c
end function
public static double code(double a, double b, double c, double d) {
return b / c;
}
def code(a, b, c, d): return b / c
function code(a, b, c, d) return Float64(b / c) end
function tmp = code(a, b, c, d) tmp = b / c; end
code[a_, b_, c_, d_] := N[(b / c), $MachinePrecision]
\begin{array}{l}
\\
\frac{b}{c}
\end{array}
Initial program 62.2%
Taylor expanded in c around inf 40.6%
Final simplification40.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 2023312
(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))))