
(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 15 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 (* (/ 1.0 (hypot c d)) (- (* (/ c (hypot c d)) b) (/ d (/ (hypot c d) a)))))
double code(double a, double b, double c, double d) {
return (1.0 / hypot(c, d)) * (((c / hypot(c, d)) * b) - (d / (hypot(c, d) / a)));
}
public static double code(double a, double b, double c, double d) {
return (1.0 / Math.hypot(c, d)) * (((c / Math.hypot(c, d)) * b) - (d / (Math.hypot(c, d) / a)));
}
def code(a, b, c, d): return (1.0 / math.hypot(c, d)) * (((c / math.hypot(c, d)) * b) - (d / (math.hypot(c, d) / a)))
function code(a, b, c, d) return Float64(Float64(1.0 / hypot(c, d)) * Float64(Float64(Float64(c / hypot(c, d)) * b) - Float64(d / Float64(hypot(c, d) / a)))) end
function tmp = code(a, b, c, d) tmp = (1.0 / hypot(c, d)) * (((c / hypot(c, d)) * b) - (d / (hypot(c, d) / a))); end
code[a_, b_, c_, d_] := N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision] - N[(d / N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(\frac{c}{\mathsf{hypot}\left(c, d\right)} \cdot b - \frac{d}{\frac{\mathsf{hypot}\left(c, d\right)}{a}}\right)
\end{array}
Initial program 60.8%
*-un-lft-identity60.8%
add-sqr-sqrt60.8%
times-frac60.8%
hypot-def60.8%
hypot-def77.6%
Applied egg-rr77.6%
div-sub77.6%
*-commutative77.6%
*-commutative77.6%
Applied egg-rr77.6%
associate-/l*86.8%
associate-/l*97.3%
Simplified97.3%
associate-/r/98.4%
Applied egg-rr98.4%
Final simplification98.4%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (- (* c b) (* d a))))
(if (<= (/ t_0 (+ (* c c) (* d d))) 5e+280)
(* (/ 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))) <= 5e+280) {
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))) <= 5e+280) 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], 5e+280], 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 5 \cdot 10^{+280}:\\
\;\;\;\;\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))) < 5.0000000000000002e280Initial program 76.2%
*-un-lft-identity76.2%
add-sqr-sqrt76.2%
times-frac76.2%
hypot-def76.2%
hypot-def96.4%
Applied egg-rr96.4%
if 5.0000000000000002e280 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 13.6%
div-sub10.0%
sub-neg10.0%
*-commutative10.0%
add-sqr-sqrt10.0%
times-frac17.5%
fma-def17.5%
hypot-def17.5%
hypot-def51.1%
associate-/l*61.8%
add-sqr-sqrt61.8%
pow261.8%
hypot-def61.8%
Applied egg-rr61.8%
Taylor expanded in c around 0 72.6%
Final simplification90.6%
(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))) 4e+263)
(* t_0 (/ t_1 (hypot c d)))
(* t_0 (- (* (/ c (hypot c d)) b) a)))))
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))) <= 4e+263) {
tmp = t_0 * (t_1 / hypot(c, d));
} else {
tmp = t_0 * (((c / hypot(c, d)) * b) - a);
}
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))) <= 4e+263) {
tmp = t_0 * (t_1 / Math.hypot(c, d));
} else {
tmp = t_0 * (((c / Math.hypot(c, d)) * b) - a);
}
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))) <= 4e+263: tmp = t_0 * (t_1 / math.hypot(c, d)) else: tmp = t_0 * (((c / math.hypot(c, d)) * b) - a) 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))) <= 4e+263) tmp = Float64(t_0 * Float64(t_1 / hypot(c, d))); else tmp = Float64(t_0 * Float64(Float64(Float64(c / hypot(c, d)) * b) - a)); 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))) <= 4e+263) tmp = t_0 * (t_1 / hypot(c, d)); else tmp = t_0 * (((c / hypot(c, d)) * b) - a); 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], 4e+263], N[(t$95$0 * N[(t$95$1 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(N[(N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision] - a), $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 4 \cdot 10^{+263}:\\
\;\;\;\;t\_0 \cdot \frac{t\_1}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \left(\frac{c}{\mathsf{hypot}\left(c, d\right)} \cdot b - a\right)\\
\end{array}
\end{array}
if (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 4.00000000000000006e263Initial program 76.1%
*-un-lft-identity76.1%
add-sqr-sqrt76.1%
times-frac76.0%
hypot-def76.1%
hypot-def96.4%
Applied egg-rr96.4%
if 4.00000000000000006e263 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 14.9%
*-un-lft-identity14.9%
add-sqr-sqrt14.9%
times-frac14.9%
hypot-def14.9%
hypot-def21.0%
Applied egg-rr21.0%
div-sub21.0%
*-commutative21.0%
*-commutative21.0%
Applied egg-rr21.0%
associate-/l*60.2%
associate-/l*97.9%
Simplified97.9%
associate-/r/98.0%
Applied egg-rr98.0%
Taylor expanded in d around inf 66.1%
Final simplification88.8%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ 1.0 (hypot c d))))
(if (<= d -3.45e+130)
(* t_0 (- a (/ b (/ d c))))
(if (<= d -2.5e-165)
(/ (- (* c b) (* d a)) (+ (* c c) (* d d)))
(if (<= d 2.8e-90)
(* (/ -1.0 c) (- (/ a (/ c d)) b))
(* t_0 (- (* (/ c (hypot c d)) b) a)))))))
double code(double a, double b, double c, double d) {
double t_0 = 1.0 / hypot(c, d);
double tmp;
if (d <= -3.45e+130) {
tmp = t_0 * (a - (b / (d / c)));
} else if (d <= -2.5e-165) {
tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
} else if (d <= 2.8e-90) {
tmp = (-1.0 / c) * ((a / (c / d)) - b);
} else {
tmp = t_0 * (((c / hypot(c, d)) * b) - a);
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = 1.0 / Math.hypot(c, d);
double tmp;
if (d <= -3.45e+130) {
tmp = t_0 * (a - (b / (d / c)));
} else if (d <= -2.5e-165) {
tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
} else if (d <= 2.8e-90) {
tmp = (-1.0 / c) * ((a / (c / d)) - b);
} else {
tmp = t_0 * (((c / Math.hypot(c, d)) * b) - a);
}
return tmp;
}
def code(a, b, c, d): t_0 = 1.0 / math.hypot(c, d) tmp = 0 if d <= -3.45e+130: tmp = t_0 * (a - (b / (d / c))) elif d <= -2.5e-165: tmp = ((c * b) - (d * a)) / ((c * c) + (d * d)) elif d <= 2.8e-90: tmp = (-1.0 / c) * ((a / (c / d)) - b) else: tmp = t_0 * (((c / math.hypot(c, d)) * b) - a) return tmp
function code(a, b, c, d) t_0 = Float64(1.0 / hypot(c, d)) tmp = 0.0 if (d <= -3.45e+130) tmp = Float64(t_0 * Float64(a - Float64(b / Float64(d / c)))); elseif (d <= -2.5e-165) tmp = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d))); elseif (d <= 2.8e-90) tmp = Float64(Float64(-1.0 / c) * Float64(Float64(a / Float64(c / d)) - b)); else tmp = Float64(t_0 * Float64(Float64(Float64(c / hypot(c, d)) * b) - a)); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = 1.0 / hypot(c, d); tmp = 0.0; if (d <= -3.45e+130) tmp = t_0 * (a - (b / (d / c))); elseif (d <= -2.5e-165) tmp = ((c * b) - (d * a)) / ((c * c) + (d * d)); elseif (d <= 2.8e-90) tmp = (-1.0 / c) * ((a / (c / d)) - b); else tmp = t_0 * (((c / hypot(c, d)) * b) - a); 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]}, If[LessEqual[d, -3.45e+130], N[(t$95$0 * N[(a - N[(b / N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -2.5e-165], N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.8e-90], N[(N[(-1.0 / c), $MachinePrecision] * N[(N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(N[(N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{if}\;d \leq -3.45 \cdot 10^{+130}:\\
\;\;\;\;t\_0 \cdot \left(a - \frac{b}{\frac{d}{c}}\right)\\
\mathbf{elif}\;d \leq -2.5 \cdot 10^{-165}:\\
\;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;d \leq 2.8 \cdot 10^{-90}:\\
\;\;\;\;\frac{-1}{c} \cdot \left(\frac{a}{\frac{c}{d}} - b\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \left(\frac{c}{\mathsf{hypot}\left(c, d\right)} \cdot b - a\right)\\
\end{array}
\end{array}
if d < -3.4500000000000001e130Initial program 32.7%
*-un-lft-identity32.7%
add-sqr-sqrt32.7%
times-frac32.8%
hypot-def32.8%
hypot-def58.0%
Applied egg-rr58.0%
Taylor expanded in d around -inf 83.6%
mul-1-neg83.6%
unsub-neg83.6%
associate-/l*86.3%
Simplified86.3%
if -3.4500000000000001e130 < d < -2.4999999999999999e-165Initial program 81.7%
if -2.4999999999999999e-165 < d < 2.7999999999999999e-90Initial program 73.4%
*-un-lft-identity73.4%
add-sqr-sqrt73.4%
times-frac73.4%
hypot-def73.4%
hypot-def88.2%
Applied egg-rr88.2%
Taylor expanded in c around -inf 55.2%
+-commutative55.2%
mul-1-neg55.2%
unsub-neg55.2%
associate-/l*56.3%
Simplified56.3%
Taylor expanded in c around -inf 93.9%
if 2.7999999999999999e-90 < d Initial program 45.0%
*-un-lft-identity45.0%
add-sqr-sqrt45.0%
times-frac45.0%
hypot-def45.0%
hypot-def67.4%
Applied egg-rr67.4%
div-sub67.4%
*-commutative67.4%
*-commutative67.4%
Applied egg-rr67.4%
associate-/l*84.9%
associate-/l*98.7%
Simplified98.7%
associate-/r/97.5%
Applied egg-rr97.5%
Taylor expanded in d around inf 85.5%
Final simplification87.3%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ 1.0 (hypot c d))) (t_1 (/ b (/ d c))))
(if (<= d -4.8e+130)
(* t_0 (- a t_1))
(if (<= d -2.5e-165)
(/ (- (* c b) (* d a)) (+ (* c c) (* d d)))
(if (<= d 9.2e+22)
(* (/ -1.0 c) (- (/ a (/ c d)) b))
(* t_0 (- t_1 a)))))))
double code(double a, double b, double c, double d) {
double t_0 = 1.0 / hypot(c, d);
double t_1 = b / (d / c);
double tmp;
if (d <= -4.8e+130) {
tmp = t_0 * (a - t_1);
} else if (d <= -2.5e-165) {
tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
} else if (d <= 9.2e+22) {
tmp = (-1.0 / c) * ((a / (c / d)) - b);
} else {
tmp = t_0 * (t_1 - a);
}
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 = b / (d / c);
double tmp;
if (d <= -4.8e+130) {
tmp = t_0 * (a - t_1);
} else if (d <= -2.5e-165) {
tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
} else if (d <= 9.2e+22) {
tmp = (-1.0 / c) * ((a / (c / d)) - b);
} else {
tmp = t_0 * (t_1 - a);
}
return tmp;
}
def code(a, b, c, d): t_0 = 1.0 / math.hypot(c, d) t_1 = b / (d / c) tmp = 0 if d <= -4.8e+130: tmp = t_0 * (a - t_1) elif d <= -2.5e-165: tmp = ((c * b) - (d * a)) / ((c * c) + (d * d)) elif d <= 9.2e+22: tmp = (-1.0 / c) * ((a / (c / d)) - b) else: tmp = t_0 * (t_1 - a) return tmp
function code(a, b, c, d) t_0 = Float64(1.0 / hypot(c, d)) t_1 = Float64(b / Float64(d / c)) tmp = 0.0 if (d <= -4.8e+130) tmp = Float64(t_0 * Float64(a - t_1)); elseif (d <= -2.5e-165) tmp = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d))); elseif (d <= 9.2e+22) tmp = Float64(Float64(-1.0 / c) * Float64(Float64(a / Float64(c / d)) - b)); else tmp = Float64(t_0 * Float64(t_1 - a)); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = 1.0 / hypot(c, d); t_1 = b / (d / c); tmp = 0.0; if (d <= -4.8e+130) tmp = t_0 * (a - t_1); elseif (d <= -2.5e-165) tmp = ((c * b) - (d * a)) / ((c * c) + (d * d)); elseif (d <= 9.2e+22) tmp = (-1.0 / c) * ((a / (c / d)) - b); else tmp = t_0 * (t_1 - a); 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[(b / N[(d / c), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -4.8e+130], N[(t$95$0 * N[(a - t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -2.5e-165], N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 9.2e+22], N[(N[(-1.0 / c), $MachinePrecision] * N[(N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(t$95$1 - a), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\mathsf{hypot}\left(c, d\right)}\\
t_1 := \frac{b}{\frac{d}{c}}\\
\mathbf{if}\;d \leq -4.8 \cdot 10^{+130}:\\
\;\;\;\;t\_0 \cdot \left(a - t\_1\right)\\
\mathbf{elif}\;d \leq -2.5 \cdot 10^{-165}:\\
\;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;d \leq 9.2 \cdot 10^{+22}:\\
\;\;\;\;\frac{-1}{c} \cdot \left(\frac{a}{\frac{c}{d}} - b\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \left(t\_1 - a\right)\\
\end{array}
\end{array}
if d < -4.80000000000000048e130Initial program 32.7%
*-un-lft-identity32.7%
add-sqr-sqrt32.7%
times-frac32.8%
hypot-def32.8%
hypot-def58.0%
Applied egg-rr58.0%
Taylor expanded in d around -inf 83.6%
mul-1-neg83.6%
unsub-neg83.6%
associate-/l*86.3%
Simplified86.3%
if -4.80000000000000048e130 < d < -2.4999999999999999e-165Initial program 81.7%
if -2.4999999999999999e-165 < d < 9.2000000000000008e22Initial program 71.4%
*-un-lft-identity71.4%
add-sqr-sqrt71.4%
times-frac71.3%
hypot-def71.3%
hypot-def85.9%
Applied egg-rr85.9%
Taylor expanded in c around -inf 53.2%
+-commutative53.2%
mul-1-neg53.2%
unsub-neg53.2%
associate-/l*54.1%
Simplified54.1%
Taylor expanded in c around -inf 89.9%
if 9.2000000000000008e22 < d Initial program 40.9%
*-un-lft-identity40.9%
add-sqr-sqrt40.9%
times-frac41.0%
hypot-def41.0%
hypot-def65.7%
Applied egg-rr65.7%
Taylor expanded in c around 0 71.3%
+-commutative71.3%
mul-1-neg71.3%
unsub-neg71.3%
associate-/l*78.7%
Simplified78.7%
Final simplification84.8%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (- (* c (/ b (pow d 2.0))) (/ a d))))
(if (<= d -3.4e+130)
t_0
(if (<= d -2.5e-165)
(/ (- (* c b) (* d a)) (+ (* c c) (* d d)))
(if (<= d 2.4e+24) (* (/ -1.0 c) (- (/ a (/ c d)) b)) t_0)))))
double code(double a, double b, double c, double d) {
double t_0 = (c * (b / pow(d, 2.0))) - (a / d);
double tmp;
if (d <= -3.4e+130) {
tmp = t_0;
} else if (d <= -2.5e-165) {
tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
} else if (d <= 2.4e+24) {
tmp = (-1.0 / c) * ((a / (c / d)) - b);
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: tmp
t_0 = (c * (b / (d ** 2.0d0))) - (a / d)
if (d <= (-3.4d+130)) then
tmp = t_0
else if (d <= (-2.5d-165)) then
tmp = ((c * b) - (d * a)) / ((c * c) + (d * d))
else if (d <= 2.4d+24) then
tmp = ((-1.0d0) / c) * ((a / (c / d)) - b)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = (c * (b / Math.pow(d, 2.0))) - (a / d);
double tmp;
if (d <= -3.4e+130) {
tmp = t_0;
} else if (d <= -2.5e-165) {
tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
} else if (d <= 2.4e+24) {
tmp = (-1.0 / c) * ((a / (c / d)) - b);
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b, c, d): t_0 = (c * (b / math.pow(d, 2.0))) - (a / d) tmp = 0 if d <= -3.4e+130: tmp = t_0 elif d <= -2.5e-165: tmp = ((c * b) - (d * a)) / ((c * c) + (d * d)) elif d <= 2.4e+24: tmp = (-1.0 / c) * ((a / (c / d)) - b) else: tmp = t_0 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(c * Float64(b / (d ^ 2.0))) - Float64(a / d)) tmp = 0.0 if (d <= -3.4e+130) tmp = t_0; elseif (d <= -2.5e-165) tmp = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d))); elseif (d <= 2.4e+24) tmp = Float64(Float64(-1.0 / c) * Float64(Float64(a / Float64(c / d)) - b)); else tmp = t_0; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (c * (b / (d ^ 2.0))) - (a / d); tmp = 0.0; if (d <= -3.4e+130) tmp = t_0; elseif (d <= -2.5e-165) tmp = ((c * b) - (d * a)) / ((c * c) + (d * d)); elseif (d <= 2.4e+24) tmp = (-1.0 / c) * ((a / (c / d)) - b); else tmp = t_0; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c * N[(b / N[Power[d, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -3.4e+130], t$95$0, If[LessEqual[d, -2.5e-165], N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.4e+24], N[(N[(-1.0 / c), $MachinePrecision] * N[(N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := c \cdot \frac{b}{{d}^{2}} - \frac{a}{d}\\
\mathbf{if}\;d \leq -3.4 \cdot 10^{+130}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq -2.5 \cdot 10^{-165}:\\
\;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;d \leq 2.4 \cdot 10^{+24}:\\
\;\;\;\;\frac{-1}{c} \cdot \left(\frac{a}{\frac{c}{d}} - b\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d < -3.4000000000000001e130 or 2.4000000000000001e24 < d Initial program 37.4%
Taylor expanded in c around 0 71.5%
+-commutative71.5%
mul-1-neg71.5%
unsub-neg71.5%
associate-/l*72.9%
associate-/r/74.2%
Simplified74.2%
if -3.4000000000000001e130 < d < -2.4999999999999999e-165Initial program 81.7%
if -2.4999999999999999e-165 < d < 2.4000000000000001e24Initial program 71.4%
*-un-lft-identity71.4%
add-sqr-sqrt71.4%
times-frac71.3%
hypot-def71.3%
hypot-def85.9%
Applied egg-rr85.9%
Taylor expanded in c around -inf 53.2%
+-commutative53.2%
mul-1-neg53.2%
unsub-neg53.2%
associate-/l*54.1%
Simplified54.1%
Taylor expanded in c around -inf 89.9%
Final simplification81.8%
(FPCore (a b c d)
:precision binary64
(if (<= d -7.5e+130)
(* (/ 1.0 (hypot c d)) (- a (/ b (/ d c))))
(if (<= d -2.5e-165)
(/ (- (* c b) (* d a)) (+ (* c c) (* d d)))
(if (<= d 1.6e+23)
(* (/ -1.0 c) (- (/ a (/ c d)) b))
(- (* c (/ b (pow d 2.0))) (/ a d))))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -7.5e+130) {
tmp = (1.0 / hypot(c, d)) * (a - (b / (d / c)));
} else if (d <= -2.5e-165) {
tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
} else if (d <= 1.6e+23) {
tmp = (-1.0 / c) * ((a / (c / d)) - b);
} else {
tmp = (c * (b / pow(d, 2.0))) - (a / d);
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double tmp;
if (d <= -7.5e+130) {
tmp = (1.0 / Math.hypot(c, d)) * (a - (b / (d / c)));
} else if (d <= -2.5e-165) {
tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
} else if (d <= 1.6e+23) {
tmp = (-1.0 / c) * ((a / (c / d)) - b);
} else {
tmp = (c * (b / Math.pow(d, 2.0))) - (a / d);
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -7.5e+130: tmp = (1.0 / math.hypot(c, d)) * (a - (b / (d / c))) elif d <= -2.5e-165: tmp = ((c * b) - (d * a)) / ((c * c) + (d * d)) elif d <= 1.6e+23: tmp = (-1.0 / c) * ((a / (c / d)) - b) else: tmp = (c * (b / math.pow(d, 2.0))) - (a / d) return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -7.5e+130) tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(a - Float64(b / Float64(d / c)))); elseif (d <= -2.5e-165) tmp = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d))); elseif (d <= 1.6e+23) tmp = Float64(Float64(-1.0 / c) * Float64(Float64(a / Float64(c / d)) - b)); else tmp = Float64(Float64(c * Float64(b / (d ^ 2.0))) - Float64(a / d)); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= -7.5e+130) tmp = (1.0 / hypot(c, d)) * (a - (b / (d / c))); elseif (d <= -2.5e-165) tmp = ((c * b) - (d * a)) / ((c * c) + (d * d)); elseif (d <= 1.6e+23) tmp = (-1.0 / c) * ((a / (c / d)) - b); else tmp = (c * (b / (d ^ 2.0))) - (a / d); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -7.5e+130], N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(a - N[(b / N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -2.5e-165], N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.6e+23], N[(N[(-1.0 / c), $MachinePrecision] * N[(N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision], N[(N[(c * N[(b / N[Power[d, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -7.5 \cdot 10^{+130}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(a - \frac{b}{\frac{d}{c}}\right)\\
\mathbf{elif}\;d \leq -2.5 \cdot 10^{-165}:\\
\;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;d \leq 1.6 \cdot 10^{+23}:\\
\;\;\;\;\frac{-1}{c} \cdot \left(\frac{a}{\frac{c}{d}} - b\right)\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{b}{{d}^{2}} - \frac{a}{d}\\
\end{array}
\end{array}
if d < -7.5000000000000003e130Initial program 32.7%
*-un-lft-identity32.7%
add-sqr-sqrt32.7%
times-frac32.8%
hypot-def32.8%
hypot-def58.0%
Applied egg-rr58.0%
Taylor expanded in d around -inf 83.6%
mul-1-neg83.6%
unsub-neg83.6%
associate-/l*86.3%
Simplified86.3%
if -7.5000000000000003e130 < d < -2.4999999999999999e-165Initial program 81.7%
if -2.4999999999999999e-165 < d < 1.6e23Initial program 71.4%
*-un-lft-identity71.4%
add-sqr-sqrt71.4%
times-frac71.3%
hypot-def71.3%
hypot-def85.9%
Applied egg-rr85.9%
Taylor expanded in c around -inf 53.2%
+-commutative53.2%
mul-1-neg53.2%
unsub-neg53.2%
associate-/l*54.1%
Simplified54.1%
Taylor expanded in c around -inf 89.9%
if 1.6e23 < d Initial program 40.9%
Taylor expanded in c around 0 64.3%
+-commutative64.3%
mul-1-neg64.3%
unsub-neg64.3%
associate-/l*66.2%
associate-/r/68.5%
Simplified68.5%
Final simplification82.5%
(FPCore (a b c d)
:precision binary64
(if (<= d -9e+130)
(/ (- a) d)
(if (<= d -2.5e-165)
(/ (- (* c b) (* d a)) (+ (* c c) (* d d)))
(if (<= d 2.2e+24)
(* (/ -1.0 c) (- (/ a (/ c d)) b))
(/ (- a) (hypot c d))))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -9e+130) {
tmp = -a / d;
} else if (d <= -2.5e-165) {
tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
} else if (d <= 2.2e+24) {
tmp = (-1.0 / c) * ((a / (c / d)) - b);
} else {
tmp = -a / hypot(c, d);
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double tmp;
if (d <= -9e+130) {
tmp = -a / d;
} else if (d <= -2.5e-165) {
tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
} else if (d <= 2.2e+24) {
tmp = (-1.0 / c) * ((a / (c / d)) - b);
} else {
tmp = -a / Math.hypot(c, d);
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -9e+130: tmp = -a / d elif d <= -2.5e-165: tmp = ((c * b) - (d * a)) / ((c * c) + (d * d)) elif d <= 2.2e+24: tmp = (-1.0 / c) * ((a / (c / d)) - b) else: tmp = -a / math.hypot(c, d) return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -9e+130) tmp = Float64(Float64(-a) / d); elseif (d <= -2.5e-165) tmp = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d))); elseif (d <= 2.2e+24) tmp = Float64(Float64(-1.0 / c) * Float64(Float64(a / Float64(c / d)) - b)); else tmp = Float64(Float64(-a) / hypot(c, d)); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= -9e+130) tmp = -a / d; elseif (d <= -2.5e-165) tmp = ((c * b) - (d * a)) / ((c * c) + (d * d)); elseif (d <= 2.2e+24) tmp = (-1.0 / c) * ((a / (c / d)) - b); else tmp = -a / hypot(c, d); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -9e+130], N[((-a) / d), $MachinePrecision], If[LessEqual[d, -2.5e-165], N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.2e+24], N[(N[(-1.0 / c), $MachinePrecision] * N[(N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision], N[((-a) / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -9 \cdot 10^{+130}:\\
\;\;\;\;\frac{-a}{d}\\
\mathbf{elif}\;d \leq -2.5 \cdot 10^{-165}:\\
\;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;d \leq 2.2 \cdot 10^{+24}:\\
\;\;\;\;\frac{-1}{c} \cdot \left(\frac{a}{\frac{c}{d}} - b\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{-a}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\end{array}
if d < -9.00000000000000078e130Initial program 32.7%
Taylor expanded in c around 0 77.5%
associate-*r/77.5%
neg-mul-177.5%
Simplified77.5%
if -9.00000000000000078e130 < d < -2.4999999999999999e-165Initial program 81.7%
if -2.4999999999999999e-165 < d < 2.20000000000000002e24Initial program 71.4%
*-un-lft-identity71.4%
add-sqr-sqrt71.4%
times-frac71.3%
hypot-def71.3%
hypot-def85.9%
Applied egg-rr85.9%
Taylor expanded in c around -inf 53.2%
+-commutative53.2%
mul-1-neg53.2%
unsub-neg53.2%
associate-/l*54.1%
Simplified54.1%
Taylor expanded in c around -inf 89.9%
if 2.20000000000000002e24 < d Initial program 40.9%
*-un-lft-identity40.9%
add-sqr-sqrt40.9%
times-frac41.0%
hypot-def41.0%
hypot-def65.7%
Applied egg-rr65.7%
Taylor expanded in c around 0 66.3%
mul-1-neg66.3%
Simplified66.3%
associate-*l/66.4%
*-un-lft-identity66.4%
neg-sub066.4%
div-sub66.4%
Applied egg-rr66.4%
div066.4%
neg-sub066.4%
distribute-frac-neg66.4%
Simplified66.4%
Final simplification80.6%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (* (/ -1.0 c) (- (/ a (/ c d)) b))))
(if (<= c -5.7e-68)
t_0
(if (<= c 3.5e-26)
(/ (- a) d)
(if (<= c 2.9e+18) (/ (* c b) (+ (* c c) (* d d))) t_0)))))
double code(double a, double b, double c, double d) {
double t_0 = (-1.0 / c) * ((a / (c / d)) - b);
double tmp;
if (c <= -5.7e-68) {
tmp = t_0;
} else if (c <= 3.5e-26) {
tmp = -a / d;
} else if (c <= 2.9e+18) {
tmp = (c * b) / ((c * c) + (d * d));
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: tmp
t_0 = ((-1.0d0) / c) * ((a / (c / d)) - b)
if (c <= (-5.7d-68)) then
tmp = t_0
else if (c <= 3.5d-26) then
tmp = -a / d
else if (c <= 2.9d+18) then
tmp = (c * b) / ((c * c) + (d * d))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = (-1.0 / c) * ((a / (c / d)) - b);
double tmp;
if (c <= -5.7e-68) {
tmp = t_0;
} else if (c <= 3.5e-26) {
tmp = -a / d;
} else if (c <= 2.9e+18) {
tmp = (c * b) / ((c * c) + (d * d));
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b, c, d): t_0 = (-1.0 / c) * ((a / (c / d)) - b) tmp = 0 if c <= -5.7e-68: tmp = t_0 elif c <= 3.5e-26: tmp = -a / d elif c <= 2.9e+18: tmp = (c * b) / ((c * c) + (d * d)) else: tmp = t_0 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(-1.0 / c) * Float64(Float64(a / Float64(c / d)) - b)) tmp = 0.0 if (c <= -5.7e-68) tmp = t_0; elseif (c <= 3.5e-26) tmp = Float64(Float64(-a) / d); elseif (c <= 2.9e+18) tmp = Float64(Float64(c * b) / Float64(Float64(c * c) + Float64(d * d))); else tmp = t_0; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (-1.0 / c) * ((a / (c / d)) - b); tmp = 0.0; if (c <= -5.7e-68) tmp = t_0; elseif (c <= 3.5e-26) tmp = -a / d; elseif (c <= 2.9e+18) tmp = (c * b) / ((c * c) + (d * d)); else tmp = t_0; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(-1.0 / c), $MachinePrecision] * N[(N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -5.7e-68], t$95$0, If[LessEqual[c, 3.5e-26], N[((-a) / d), $MachinePrecision], If[LessEqual[c, 2.9e+18], N[(N[(c * b), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-1}{c} \cdot \left(\frac{a}{\frac{c}{d}} - b\right)\\
\mathbf{if}\;c \leq -5.7 \cdot 10^{-68}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq 3.5 \cdot 10^{-26}:\\
\;\;\;\;\frac{-a}{d}\\
\mathbf{elif}\;c \leq 2.9 \cdot 10^{+18}:\\
\;\;\;\;\frac{c \cdot b}{c \cdot c + d \cdot d}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if c < -5.7000000000000002e-68 or 2.9e18 < c Initial program 49.9%
*-un-lft-identity49.9%
add-sqr-sqrt49.9%
times-frac49.9%
hypot-def49.9%
hypot-def67.9%
Applied egg-rr67.9%
Taylor expanded in c around -inf 51.7%
+-commutative51.7%
mul-1-neg51.7%
unsub-neg51.7%
associate-/l*54.8%
Simplified54.8%
Taylor expanded in c around -inf 75.3%
if -5.7000000000000002e-68 < c < 3.49999999999999985e-26Initial program 71.1%
Taylor expanded in c around 0 71.4%
associate-*r/71.4%
neg-mul-171.4%
Simplified71.4%
if 3.49999999999999985e-26 < c < 2.9e18Initial program 99.6%
Taylor expanded in b around inf 99.6%
*-commutative99.6%
Simplified99.6%
Final simplification74.2%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- a) d)))
(if (<= d -1.28e+131)
t_0
(if (<= d -2.5e-165)
(/ (- (* c b) (* d a)) (+ (* c c) (* d d)))
(if (<= d 1.05e+25) (* (/ -1.0 c) (- (/ a (/ c d)) b)) t_0)))))
double code(double a, double b, double c, double d) {
double t_0 = -a / d;
double tmp;
if (d <= -1.28e+131) {
tmp = t_0;
} else if (d <= -2.5e-165) {
tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
} else if (d <= 1.05e+25) {
tmp = (-1.0 / c) * ((a / (c / d)) - b);
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: tmp
t_0 = -a / d
if (d <= (-1.28d+131)) then
tmp = t_0
else if (d <= (-2.5d-165)) then
tmp = ((c * b) - (d * a)) / ((c * c) + (d * d))
else if (d <= 1.05d+25) then
tmp = ((-1.0d0) / c) * ((a / (c / d)) - b)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = -a / d;
double tmp;
if (d <= -1.28e+131) {
tmp = t_0;
} else if (d <= -2.5e-165) {
tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
} else if (d <= 1.05e+25) {
tmp = (-1.0 / c) * ((a / (c / d)) - b);
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b, c, d): t_0 = -a / d tmp = 0 if d <= -1.28e+131: tmp = t_0 elif d <= -2.5e-165: tmp = ((c * b) - (d * a)) / ((c * c) + (d * d)) elif d <= 1.05e+25: tmp = (-1.0 / c) * ((a / (c / d)) - b) else: tmp = t_0 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(-a) / d) tmp = 0.0 if (d <= -1.28e+131) tmp = t_0; elseif (d <= -2.5e-165) tmp = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d))); elseif (d <= 1.05e+25) tmp = Float64(Float64(-1.0 / c) * Float64(Float64(a / Float64(c / d)) - b)); else tmp = t_0; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = -a / d; tmp = 0.0; if (d <= -1.28e+131) tmp = t_0; elseif (d <= -2.5e-165) tmp = ((c * b) - (d * a)) / ((c * c) + (d * d)); elseif (d <= 1.05e+25) tmp = (-1.0 / c) * ((a / (c / d)) - b); else tmp = t_0; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[((-a) / d), $MachinePrecision]}, If[LessEqual[d, -1.28e+131], t$95$0, If[LessEqual[d, -2.5e-165], N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.05e+25], N[(N[(-1.0 / c), $MachinePrecision] * N[(N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-a}{d}\\
\mathbf{if}\;d \leq -1.28 \cdot 10^{+131}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq -2.5 \cdot 10^{-165}:\\
\;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;d \leq 1.05 \cdot 10^{+25}:\\
\;\;\;\;\frac{-1}{c} \cdot \left(\frac{a}{\frac{c}{d}} - b\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d < -1.28e131 or 1.05e25 < d Initial program 37.4%
Taylor expanded in c around 0 70.1%
associate-*r/70.1%
neg-mul-170.1%
Simplified70.1%
if -1.28e131 < d < -2.4999999999999999e-165Initial program 81.7%
if -2.4999999999999999e-165 < d < 1.05e25Initial program 71.4%
*-un-lft-identity71.4%
add-sqr-sqrt71.4%
times-frac71.3%
hypot-def71.3%
hypot-def85.9%
Applied egg-rr85.9%
Taylor expanded in c around -inf 53.2%
+-commutative53.2%
mul-1-neg53.2%
unsub-neg53.2%
associate-/l*54.1%
Simplified54.1%
Taylor expanded in c around -inf 89.9%
Final simplification80.2%
(FPCore (a b c d) :precision binary64 (if (or (<= d -1e+45) (not (<= d 9.5e+24))) (/ (- a) d) (* (/ -1.0 c) (- (/ a (/ c d)) b))))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -1e+45) || !(d <= 9.5e+24)) {
tmp = -a / d;
} else {
tmp = (-1.0 / c) * ((a / (c / d)) - b);
}
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 <= (-1d+45)) .or. (.not. (d <= 9.5d+24))) then
tmp = -a / d
else
tmp = ((-1.0d0) / c) * ((a / (c / d)) - b)
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -1e+45) || !(d <= 9.5e+24)) {
tmp = -a / d;
} else {
tmp = (-1.0 / c) * ((a / (c / d)) - b);
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -1e+45) or not (d <= 9.5e+24): tmp = -a / d else: tmp = (-1.0 / c) * ((a / (c / d)) - b) return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -1e+45) || !(d <= 9.5e+24)) tmp = Float64(Float64(-a) / d); else tmp = Float64(Float64(-1.0 / c) * Float64(Float64(a / Float64(c / d)) - b)); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -1e+45) || ~((d <= 9.5e+24))) tmp = -a / d; else tmp = (-1.0 / c) * ((a / (c / d)) - b); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -1e+45], N[Not[LessEqual[d, 9.5e+24]], $MachinePrecision]], N[((-a) / d), $MachinePrecision], N[(N[(-1.0 / c), $MachinePrecision] * N[(N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -1 \cdot 10^{+45} \lor \neg \left(d \leq 9.5 \cdot 10^{+24}\right):\\
\;\;\;\;\frac{-a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{c} \cdot \left(\frac{a}{\frac{c}{d}} - b\right)\\
\end{array}
\end{array}
if d < -9.9999999999999993e44 or 9.5000000000000001e24 < d Initial program 44.3%
Taylor expanded in c around 0 65.3%
associate-*r/65.3%
neg-mul-165.3%
Simplified65.3%
if -9.9999999999999993e44 < d < 9.5000000000000001e24Initial program 74.9%
*-un-lft-identity74.9%
add-sqr-sqrt74.9%
times-frac74.8%
hypot-def74.8%
hypot-def87.4%
Applied egg-rr87.4%
Taylor expanded in c around -inf 48.6%
+-commutative48.6%
mul-1-neg48.6%
unsub-neg48.6%
associate-/l*49.2%
Simplified49.2%
Taylor expanded in c around -inf 80.7%
Final simplification73.6%
(FPCore (a b c d) :precision binary64 (if (or (<= c -2e+45) (not (<= c 4.2e-28))) (/ b c) (/ (- a) d)))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -2e+45) || !(c <= 4.2e-28)) {
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 <= (-2d+45)) .or. (.not. (c <= 4.2d-28))) 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 <= -2e+45) || !(c <= 4.2e-28)) {
tmp = b / c;
} else {
tmp = -a / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -2e+45) or not (c <= 4.2e-28): tmp = b / c else: tmp = -a / d return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -2e+45) || !(c <= 4.2e-28)) 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 <= -2e+45) || ~((c <= 4.2e-28))) tmp = b / c; else tmp = -a / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -2e+45], N[Not[LessEqual[c, 4.2e-28]], $MachinePrecision]], N[(b / c), $MachinePrecision], N[((-a) / d), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -2 \cdot 10^{+45} \lor \neg \left(c \leq 4.2 \cdot 10^{-28}\right):\\
\;\;\;\;\frac{b}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{-a}{d}\\
\end{array}
\end{array}
if c < -1.9999999999999999e45 or 4.20000000000000013e-28 < c Initial program 48.6%
Taylor expanded in c around inf 68.5%
if -1.9999999999999999e45 < c < 4.20000000000000013e-28Initial program 71.1%
Taylor expanded in c around 0 65.4%
associate-*r/65.4%
neg-mul-165.4%
Simplified65.4%
Final simplification66.8%
(FPCore (a b c d) :precision binary64 (if (or (<= d -7.5e+48) (not (<= d 4.5e+112))) (/ a d) (/ a c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -7.5e+48) || !(d <= 4.5e+112)) {
tmp = a / d;
} else {
tmp = 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 ((d <= (-7.5d+48)) .or. (.not. (d <= 4.5d+112))) then
tmp = a / d
else
tmp = a / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -7.5e+48) || !(d <= 4.5e+112)) {
tmp = a / d;
} else {
tmp = a / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -7.5e+48) or not (d <= 4.5e+112): tmp = a / d else: tmp = a / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -7.5e+48) || !(d <= 4.5e+112)) tmp = Float64(a / d); else tmp = Float64(a / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -7.5e+48) || ~((d <= 4.5e+112))) tmp = a / d; else tmp = a / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -7.5e+48], N[Not[LessEqual[d, 4.5e+112]], $MachinePrecision]], N[(a / d), $MachinePrecision], N[(a / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -7.5 \cdot 10^{+48} \lor \neg \left(d \leq 4.5 \cdot 10^{+112}\right):\\
\;\;\;\;\frac{a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c}\\
\end{array}
\end{array}
if d < -7.5000000000000006e48 or 4.4999999999999999e112 < d Initial program 39.7%
*-un-lft-identity39.7%
add-sqr-sqrt39.7%
times-frac39.8%
hypot-def39.8%
hypot-def63.2%
Applied egg-rr63.2%
Taylor expanded in c around 0 36.6%
mul-1-neg36.6%
Simplified36.6%
Taylor expanded in d around -inf 17.8%
if -7.5000000000000006e48 < d < 4.4999999999999999e112Initial program 74.5%
*-un-lft-identity74.5%
add-sqr-sqrt74.5%
times-frac74.4%
hypot-def74.4%
hypot-def86.9%
Applied egg-rr86.9%
Taylor expanded in c around -inf 45.5%
+-commutative45.5%
mul-1-neg45.5%
unsub-neg45.5%
associate-/l*46.7%
Simplified46.7%
Taylor expanded in c around 0 12.2%
Final simplification14.4%
(FPCore (a b c d) :precision binary64 (if (<= d -9e+131) (/ a d) (/ b c)))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -9e+131) {
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 <= (-9d+131)) 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 <= -9e+131) {
tmp = a / d;
} else {
tmp = b / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -9e+131: tmp = a / d else: tmp = b / c return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -9e+131) tmp = 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 <= -9e+131) tmp = a / d; else tmp = b / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -9e+131], N[(a / d), $MachinePrecision], N[(b / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -9 \cdot 10^{+131}:\\
\;\;\;\;\frac{a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if d < -9.00000000000000039e131Initial program 33.4%
*-un-lft-identity33.4%
add-sqr-sqrt33.4%
times-frac33.5%
hypot-def33.5%
hypot-def59.4%
Applied egg-rr59.4%
Taylor expanded in c around 0 22.5%
mul-1-neg22.5%
Simplified22.5%
Taylor expanded in d around -inf 22.5%
if -9.00000000000000039e131 < d Initial program 66.0%
Taylor expanded in c around inf 50.1%
Final simplification45.7%
(FPCore (a b c d) :precision binary64 (/ a c))
double code(double a, double b, double c, double d) {
return a / 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 = a / c
end function
public static double code(double a, double b, double c, double d) {
return a / c;
}
def code(a, b, c, d): return a / c
function code(a, b, c, d) return Float64(a / c) end
function tmp = code(a, b, c, d) tmp = a / c; end
code[a_, b_, c_, d_] := N[(a / c), $MachinePrecision]
\begin{array}{l}
\\
\frac{a}{c}
\end{array}
Initial program 60.8%
*-un-lft-identity60.8%
add-sqr-sqrt60.8%
times-frac60.8%
hypot-def60.8%
hypot-def77.6%
Applied egg-rr77.6%
Taylor expanded in c around -inf 33.1%
+-commutative33.1%
mul-1-neg33.1%
unsub-neg33.1%
associate-/l*35.0%
Simplified35.0%
Taylor expanded in c around 0 9.4%
Final simplification9.4%
(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 2024027
(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))))