
(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)) (/ (/ (- a) (hypot c d)) (/ (hypot c d) d))))
double code(double a, double b, double c, double d) {
return fma((c / hypot(c, d)), (b / hypot(c, d)), ((-a / hypot(c, d)) / (hypot(c, d) / d)));
}
function code(a, b, c, d) return fma(Float64(c / hypot(c, d)), Float64(b / hypot(c, d)), Float64(Float64(Float64(-a) / hypot(c, d)) / Float64(hypot(c, d) / 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[((-a) / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] / N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / d), $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{\frac{-a}{\mathsf{hypot}\left(c, d\right)}}{\frac{\mathsf{hypot}\left(c, d\right)}{d}}\right)
\end{array}
Initial program 63.1%
div-sub62.3%
sub-neg62.3%
*-commutative62.3%
add-sqr-sqrt62.3%
times-frac63.4%
fma-def63.4%
hypot-def63.5%
hypot-def76.5%
associate-/l*79.2%
add-sqr-sqrt79.2%
pow279.2%
hypot-def79.2%
Applied egg-rr79.2%
div-inv79.1%
unpow279.1%
associate-*l*95.3%
Applied egg-rr95.3%
*-un-lft-identity95.3%
times-frac98.4%
un-div-inv98.4%
associate-/l*83.7%
*-commutative83.7%
*-un-lft-identity83.7%
times-frac98.1%
/-rgt-identity98.1%
Applied egg-rr98.1%
associate-*r*98.2%
associate-/r/98.2%
associate-*l/98.2%
*-lft-identity98.2%
Simplified98.2%
Final simplification98.2%
(FPCore (a b c d) :precision binary64 (* (/ 1.0 (hypot c d)) (- (/ c (/ (hypot c d) b)) (* d (/ a (hypot c d))))))
double code(double a, double b, double c, double d) {
return (1.0 / hypot(c, d)) * ((c / (hypot(c, d) / b)) - (d * (a / hypot(c, d))));
}
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 * (a / Math.hypot(c, d))));
}
def code(a, b, c, d): return (1.0 / math.hypot(c, d)) * ((c / (math.hypot(c, d) / b)) - (d * (a / math.hypot(c, d))))
function code(a, b, c, d) return Float64(Float64(1.0 / hypot(c, d)) * Float64(Float64(c / Float64(hypot(c, d) / b)) - Float64(d * Float64(a / hypot(c, d))))) end
function tmp = code(a, b, c, d) tmp = (1.0 / hypot(c, d)) * ((c / (hypot(c, d) / b)) - (d * (a / hypot(c, d)))); end
code[a_, b_, c_, d_] := N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(N[(c / N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision] - N[(d * N[(a / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(\frac{c}{\frac{\mathsf{hypot}\left(c, d\right)}{b}} - d \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}\right)
\end{array}
Initial program 63.1%
*-un-lft-identity63.1%
add-sqr-sqrt63.1%
times-frac63.1%
hypot-def63.1%
hypot-def76.1%
Applied egg-rr76.1%
div-sub76.1%
*-commutative76.1%
associate-/l*83.3%
*-commutative83.3%
*-un-lft-identity83.3%
times-frac97.7%
/-rgt-identity97.7%
Applied egg-rr97.7%
Final simplification97.7%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (- (* c b) (* d a))))
(if (<= (/ t_0 (+ (* c c) (* d d))) 1e+277)
(* (/ 1.0 (hypot c d)) (/ t_0 (hypot c d)))
(* (/ 1.0 c) (- b (/ a (/ c d)))))))
double code(double a, double b, double c, double d) {
double t_0 = (c * b) - (d * a);
double tmp;
if ((t_0 / ((c * c) + (d * d))) <= 1e+277) {
tmp = (1.0 / hypot(c, d)) * (t_0 / hypot(c, d));
} else {
tmp = (1.0 / c) * (b - (a / (c / d)));
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = (c * b) - (d * a);
double tmp;
if ((t_0 / ((c * c) + (d * d))) <= 1e+277) {
tmp = (1.0 / Math.hypot(c, d)) * (t_0 / Math.hypot(c, d));
} else {
tmp = (1.0 / c) * (b - (a / (c / d)));
}
return tmp;
}
def code(a, b, c, d): t_0 = (c * b) - (d * a) tmp = 0 if (t_0 / ((c * c) + (d * d))) <= 1e+277: tmp = (1.0 / math.hypot(c, d)) * (t_0 / math.hypot(c, d)) else: tmp = (1.0 / c) * (b - (a / (c / d))) return tmp
function code(a, b, c, d) t_0 = Float64(Float64(c * b) - Float64(d * a)) tmp = 0.0 if (Float64(t_0 / Float64(Float64(c * c) + Float64(d * d))) <= 1e+277) tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(t_0 / hypot(c, d))); else tmp = Float64(Float64(1.0 / c) * Float64(b - Float64(a / Float64(c / d)))); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (c * b) - (d * a); tmp = 0.0; if ((t_0 / ((c * c) + (d * d))) <= 1e+277) tmp = (1.0 / hypot(c, d)) * (t_0 / hypot(c, d)); else tmp = (1.0 / c) * (b - (a / (c / d))); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$0 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1e+277], 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 / c), $MachinePrecision] * N[(b - N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision]), $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^{+277}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{t_0}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{c} \cdot \left(b - \frac{a}{\frac{c}{d}}\right)\\
\end{array}
\end{array}
if (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 1e277Initial program 81.9%
*-un-lft-identity81.9%
add-sqr-sqrt81.9%
times-frac81.8%
hypot-def81.8%
hypot-def97.5%
Applied egg-rr97.5%
if 1e277 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 13.3%
*-un-lft-identity13.3%
add-sqr-sqrt13.3%
times-frac13.3%
hypot-def13.3%
hypot-def19.3%
Applied egg-rr19.3%
Taylor expanded in c around inf 21.5%
mul-1-neg21.5%
unsub-neg21.5%
associate-/l*27.3%
Simplified27.3%
Taylor expanded in c around inf 58.6%
Final simplification86.8%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ 1.0 (hypot c d))) (t_1 (/ b (/ d c))))
(if (<= d -4.8e-39)
(* t_0 (- a t_1))
(if (<= d 3.3e-153)
(* (/ 1.0 c) (- b (/ a (/ c d))))
(if (<= d 2.45e+135)
(/ (- (* c b) (* d a)) (+ (* c c) (* d d)))
(* 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-39) {
tmp = t_0 * (a - t_1);
} else if (d <= 3.3e-153) {
tmp = (1.0 / c) * (b - (a / (c / d)));
} else if (d <= 2.45e+135) {
tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
} 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-39) {
tmp = t_0 * (a - t_1);
} else if (d <= 3.3e-153) {
tmp = (1.0 / c) * (b - (a / (c / d)));
} else if (d <= 2.45e+135) {
tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
} 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-39: tmp = t_0 * (a - t_1) elif d <= 3.3e-153: tmp = (1.0 / c) * (b - (a / (c / d))) elif d <= 2.45e+135: tmp = ((c * b) - (d * a)) / ((c * c) + (d * d)) 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-39) tmp = Float64(t_0 * Float64(a - t_1)); elseif (d <= 3.3e-153) tmp = Float64(Float64(1.0 / c) * Float64(b - Float64(a / Float64(c / d)))); elseif (d <= 2.45e+135) tmp = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d))); 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-39) tmp = t_0 * (a - t_1); elseif (d <= 3.3e-153) tmp = (1.0 / c) * (b - (a / (c / d))); elseif (d <= 2.45e+135) tmp = ((c * b) - (d * a)) / ((c * c) + (d * d)); 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-39], N[(t$95$0 * N[(a - t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 3.3e-153], N[(N[(1.0 / c), $MachinePrecision] * N[(b - N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.45e+135], N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $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^{-39}:\\
\;\;\;\;t_0 \cdot \left(a - t_1\right)\\
\mathbf{elif}\;d \leq 3.3 \cdot 10^{-153}:\\
\;\;\;\;\frac{1}{c} \cdot \left(b - \frac{a}{\frac{c}{d}}\right)\\
\mathbf{elif}\;d \leq 2.45 \cdot 10^{+135}:\\
\;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot \left(t_1 - a\right)\\
\end{array}
\end{array}
if d < -4.80000000000000031e-39Initial program 50.2%
*-un-lft-identity50.2%
add-sqr-sqrt50.2%
times-frac50.1%
hypot-def50.1%
hypot-def70.6%
Applied egg-rr70.6%
Taylor expanded in d around -inf 72.7%
mul-1-neg72.7%
unsub-neg72.7%
associate-/l*75.7%
Simplified75.7%
if -4.80000000000000031e-39 < d < 3.29999999999999988e-153Initial program 69.4%
*-un-lft-identity69.4%
add-sqr-sqrt69.4%
times-frac69.4%
hypot-def69.5%
hypot-def81.6%
Applied egg-rr81.6%
Taylor expanded in c around inf 51.2%
mul-1-neg51.2%
unsub-neg51.2%
associate-/l*51.2%
Simplified51.2%
Taylor expanded in c around inf 92.2%
if 3.29999999999999988e-153 < d < 2.4500000000000001e135Initial program 87.3%
if 2.4500000000000001e135 < d Initial program 40.3%
*-un-lft-identity40.3%
add-sqr-sqrt40.3%
times-frac40.3%
hypot-def40.3%
hypot-def51.2%
Applied egg-rr51.2%
Taylor expanded in c around 0 81.4%
+-commutative81.4%
neg-mul-181.4%
unsub-neg81.4%
associate-/l*87.0%
Simplified87.0%
Final simplification85.4%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* c b) (* d a)) (+ (* c c) (* d d)))))
(if (<= d -1.25e+52)
(* a (/ 1.0 (hypot c d)))
(if (<= d -5e-128)
t_0
(if (<= d 1.6e-148)
(* (/ 1.0 c) (- b (/ a (/ c d))))
(if (<= d 5.8e+151) t_0 (* a (/ -1.0 (hypot c d)))))))))
double code(double a, double b, double c, double d) {
double t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
double tmp;
if (d <= -1.25e+52) {
tmp = a * (1.0 / hypot(c, d));
} else if (d <= -5e-128) {
tmp = t_0;
} else if (d <= 1.6e-148) {
tmp = (1.0 / c) * (b - (a / (c / d)));
} else if (d <= 5.8e+151) {
tmp = t_0;
} else {
tmp = a * (-1.0 / hypot(c, d));
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
double tmp;
if (d <= -1.25e+52) {
tmp = a * (1.0 / Math.hypot(c, d));
} else if (d <= -5e-128) {
tmp = t_0;
} else if (d <= 1.6e-148) {
tmp = (1.0 / c) * (b - (a / (c / d)));
} else if (d <= 5.8e+151) {
tmp = t_0;
} else {
tmp = a * (-1.0 / Math.hypot(c, d));
}
return tmp;
}
def code(a, b, c, d): t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d)) tmp = 0 if d <= -1.25e+52: tmp = a * (1.0 / math.hypot(c, d)) elif d <= -5e-128: tmp = t_0 elif d <= 1.6e-148: tmp = (1.0 / c) * (b - (a / (c / d))) elif d <= 5.8e+151: tmp = t_0 else: tmp = a * (-1.0 / math.hypot(c, d)) return tmp
function code(a, b, c, d) t_0 = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d))) tmp = 0.0 if (d <= -1.25e+52) tmp = Float64(a * Float64(1.0 / hypot(c, d))); elseif (d <= -5e-128) tmp = t_0; elseif (d <= 1.6e-148) tmp = Float64(Float64(1.0 / c) * Float64(b - Float64(a / Float64(c / d)))); elseif (d <= 5.8e+151) tmp = t_0; else tmp = Float64(a * Float64(-1.0 / hypot(c, d))); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d)); tmp = 0.0; if (d <= -1.25e+52) tmp = a * (1.0 / hypot(c, d)); elseif (d <= -5e-128) tmp = t_0; elseif (d <= 1.6e-148) tmp = (1.0 / c) * (b - (a / (c / d))); elseif (d <= 5.8e+151) tmp = t_0; else tmp = a * (-1.0 / hypot(c, d)); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -1.25e+52], N[(a * N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -5e-128], t$95$0, If[LessEqual[d, 1.6e-148], N[(N[(1.0 / c), $MachinePrecision] * N[(b - N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 5.8e+151], t$95$0, N[(a * N[(-1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{if}\;d \leq -1.25 \cdot 10^{+52}:\\
\;\;\;\;a \cdot \frac{1}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;d \leq -5 \cdot 10^{-128}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 1.6 \cdot 10^{-148}:\\
\;\;\;\;\frac{1}{c} \cdot \left(b - \frac{a}{\frac{c}{d}}\right)\\
\mathbf{elif}\;d \leq 5.8 \cdot 10^{+151}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;a \cdot \frac{-1}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\end{array}
if d < -1.25e52Initial program 39.4%
*-un-lft-identity39.4%
add-sqr-sqrt39.4%
times-frac39.3%
hypot-def39.3%
hypot-def62.5%
Applied egg-rr62.5%
Taylor expanded in d around -inf 73.2%
if -1.25e52 < d < -5.0000000000000001e-128 or 1.59999999999999997e-148 < d < 5.80000000000000036e151Initial program 86.1%
if -5.0000000000000001e-128 < d < 1.59999999999999997e-148Initial program 65.6%
*-un-lft-identity65.6%
add-sqr-sqrt65.6%
times-frac65.6%
hypot-def65.7%
hypot-def78.3%
Applied egg-rr78.3%
Taylor expanded in c around inf 52.7%
mul-1-neg52.7%
unsub-neg52.7%
associate-/l*52.6%
Simplified52.6%
Taylor expanded in c around inf 95.5%
if 5.80000000000000036e151 < d Initial program 38.0%
*-un-lft-identity38.0%
add-sqr-sqrt38.0%
times-frac38.0%
hypot-def38.0%
hypot-def49.9%
Applied egg-rr49.9%
Taylor expanded in c around 0 83.5%
neg-mul-183.5%
Simplified83.5%
Final simplification85.2%
(FPCore (a b c d)
:precision binary64
(if (<= d -2.2e-36)
(* (/ 1.0 (hypot c d)) (- a (/ b (/ d c))))
(if (<= d 6.2e-153)
(* (/ 1.0 c) (- b (/ a (/ c d))))
(if (<= d 1.8e+152)
(/ (- (* c b) (* d a)) (+ (* c c) (* d d)))
(* a (/ -1.0 (hypot c d)))))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -2.2e-36) {
tmp = (1.0 / hypot(c, d)) * (a - (b / (d / c)));
} else if (d <= 6.2e-153) {
tmp = (1.0 / c) * (b - (a / (c / d)));
} else if (d <= 1.8e+152) {
tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
} else {
tmp = a * (-1.0 / hypot(c, d));
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double tmp;
if (d <= -2.2e-36) {
tmp = (1.0 / Math.hypot(c, d)) * (a - (b / (d / c)));
} else if (d <= 6.2e-153) {
tmp = (1.0 / c) * (b - (a / (c / d)));
} else if (d <= 1.8e+152) {
tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
} else {
tmp = a * (-1.0 / Math.hypot(c, d));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -2.2e-36: tmp = (1.0 / math.hypot(c, d)) * (a - (b / (d / c))) elif d <= 6.2e-153: tmp = (1.0 / c) * (b - (a / (c / d))) elif d <= 1.8e+152: tmp = ((c * b) - (d * a)) / ((c * c) + (d * d)) else: tmp = a * (-1.0 / math.hypot(c, d)) return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -2.2e-36) tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(a - Float64(b / Float64(d / c)))); elseif (d <= 6.2e-153) tmp = Float64(Float64(1.0 / c) * Float64(b - Float64(a / Float64(c / d)))); elseif (d <= 1.8e+152) tmp = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d))); else tmp = Float64(a * Float64(-1.0 / hypot(c, d))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= -2.2e-36) tmp = (1.0 / hypot(c, d)) * (a - (b / (d / c))); elseif (d <= 6.2e-153) tmp = (1.0 / c) * (b - (a / (c / d))); elseif (d <= 1.8e+152) tmp = ((c * b) - (d * a)) / ((c * c) + (d * d)); else tmp = a * (-1.0 / hypot(c, d)); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -2.2e-36], 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, 6.2e-153], N[(N[(1.0 / c), $MachinePrecision] * N[(b - N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.8e+152], N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a * N[(-1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -2.2 \cdot 10^{-36}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(a - \frac{b}{\frac{d}{c}}\right)\\
\mathbf{elif}\;d \leq 6.2 \cdot 10^{-153}:\\
\;\;\;\;\frac{1}{c} \cdot \left(b - \frac{a}{\frac{c}{d}}\right)\\
\mathbf{elif}\;d \leq 1.8 \cdot 10^{+152}:\\
\;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{else}:\\
\;\;\;\;a \cdot \frac{-1}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\end{array}
if d < -2.1999999999999999e-36Initial program 50.2%
*-un-lft-identity50.2%
add-sqr-sqrt50.2%
times-frac50.1%
hypot-def50.1%
hypot-def70.6%
Applied egg-rr70.6%
Taylor expanded in d around -inf 72.7%
mul-1-neg72.7%
unsub-neg72.7%
associate-/l*75.7%
Simplified75.7%
if -2.1999999999999999e-36 < d < 6.1999999999999999e-153Initial program 69.4%
*-un-lft-identity69.4%
add-sqr-sqrt69.4%
times-frac69.4%
hypot-def69.5%
hypot-def81.6%
Applied egg-rr81.6%
Taylor expanded in c around inf 51.2%
mul-1-neg51.2%
unsub-neg51.2%
associate-/l*51.2%
Simplified51.2%
Taylor expanded in c around inf 92.2%
if 6.1999999999999999e-153 < d < 1.7999999999999999e152Initial program 86.2%
if 1.7999999999999999e152 < d Initial program 38.0%
*-un-lft-identity38.0%
add-sqr-sqrt38.0%
times-frac38.0%
hypot-def38.0%
hypot-def49.9%
Applied egg-rr49.9%
Taylor expanded in c around 0 83.5%
neg-mul-183.5%
Simplified83.5%
Final simplification84.7%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* c b) (* d a)) (+ (* c c) (* d d)))))
(if (<= d -1.25e+52)
(* a (/ 1.0 (hypot c d)))
(if (<= d -4.2e-128)
t_0
(if (<= d 6.5e-150)
(* (/ 1.0 c) (- b (/ a (/ c d))))
(if (<= d 2.1e+152) t_0 (/ (- a) d)))))))
double code(double a, double b, double c, double d) {
double t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
double tmp;
if (d <= -1.25e+52) {
tmp = a * (1.0 / hypot(c, d));
} else if (d <= -4.2e-128) {
tmp = t_0;
} else if (d <= 6.5e-150) {
tmp = (1.0 / c) * (b - (a / (c / d)));
} else if (d <= 2.1e+152) {
tmp = t_0;
} else {
tmp = -a / d;
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
double tmp;
if (d <= -1.25e+52) {
tmp = a * (1.0 / Math.hypot(c, d));
} else if (d <= -4.2e-128) {
tmp = t_0;
} else if (d <= 6.5e-150) {
tmp = (1.0 / c) * (b - (a / (c / d)));
} else if (d <= 2.1e+152) {
tmp = t_0;
} else {
tmp = -a / d;
}
return tmp;
}
def code(a, b, c, d): t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d)) tmp = 0 if d <= -1.25e+52: tmp = a * (1.0 / math.hypot(c, d)) elif d <= -4.2e-128: tmp = t_0 elif d <= 6.5e-150: tmp = (1.0 / c) * (b - (a / (c / d))) elif d <= 2.1e+152: tmp = t_0 else: tmp = -a / d return tmp
function code(a, b, c, d) t_0 = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d))) tmp = 0.0 if (d <= -1.25e+52) tmp = Float64(a * Float64(1.0 / hypot(c, d))); elseif (d <= -4.2e-128) tmp = t_0; elseif (d <= 6.5e-150) tmp = Float64(Float64(1.0 / c) * Float64(b - Float64(a / Float64(c / d)))); elseif (d <= 2.1e+152) tmp = t_0; else tmp = Float64(Float64(-a) / d); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d)); tmp = 0.0; if (d <= -1.25e+52) tmp = a * (1.0 / hypot(c, d)); elseif (d <= -4.2e-128) tmp = t_0; elseif (d <= 6.5e-150) tmp = (1.0 / c) * (b - (a / (c / d))); elseif (d <= 2.1e+152) tmp = t_0; else tmp = -a / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -1.25e+52], N[(a * N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -4.2e-128], t$95$0, If[LessEqual[d, 6.5e-150], N[(N[(1.0 / c), $MachinePrecision] * N[(b - N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.1e+152], t$95$0, N[((-a) / d), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{if}\;d \leq -1.25 \cdot 10^{+52}:\\
\;\;\;\;a \cdot \frac{1}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;d \leq -4.2 \cdot 10^{-128}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 6.5 \cdot 10^{-150}:\\
\;\;\;\;\frac{1}{c} \cdot \left(b - \frac{a}{\frac{c}{d}}\right)\\
\mathbf{elif}\;d \leq 2.1 \cdot 10^{+152}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{-a}{d}\\
\end{array}
\end{array}
if d < -1.25e52Initial program 39.4%
*-un-lft-identity39.4%
add-sqr-sqrt39.4%
times-frac39.3%
hypot-def39.3%
hypot-def62.5%
Applied egg-rr62.5%
Taylor expanded in d around -inf 73.2%
if -1.25e52 < d < -4.2000000000000002e-128 or 6.49999999999999997e-150 < d < 2.1000000000000002e152Initial program 86.1%
if -4.2000000000000002e-128 < d < 6.49999999999999997e-150Initial program 65.6%
*-un-lft-identity65.6%
add-sqr-sqrt65.6%
times-frac65.6%
hypot-def65.7%
hypot-def78.3%
Applied egg-rr78.3%
Taylor expanded in c around inf 52.7%
mul-1-neg52.7%
unsub-neg52.7%
associate-/l*52.6%
Simplified52.6%
Taylor expanded in c around inf 95.5%
if 2.1000000000000002e152 < d Initial program 38.0%
Taylor expanded in c around 0 83.4%
associate-*r/83.4%
neg-mul-183.4%
Simplified83.4%
Final simplification85.2%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- a) d)) (t_1 (/ (- (* c b) (* d a)) (+ (* c c) (* d d)))))
(if (<= d -1.2e+52)
t_0
(if (<= d -9.5e-131)
t_1
(if (<= d 4.4e-149)
(* (/ 1.0 c) (- b (/ a (/ c d))))
(if (<= d 8e+151) t_1 t_0))))))
double code(double a, double b, double c, double d) {
double t_0 = -a / d;
double t_1 = ((c * b) - (d * a)) / ((c * c) + (d * d));
double tmp;
if (d <= -1.2e+52) {
tmp = t_0;
} else if (d <= -9.5e-131) {
tmp = t_1;
} else if (d <= 4.4e-149) {
tmp = (1.0 / c) * (b - (a / (c / d)));
} else if (d <= 8e+151) {
tmp = t_1;
} 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) :: t_1
real(8) :: tmp
t_0 = -a / d
t_1 = ((c * b) - (d * a)) / ((c * c) + (d * d))
if (d <= (-1.2d+52)) then
tmp = t_0
else if (d <= (-9.5d-131)) then
tmp = t_1
else if (d <= 4.4d-149) then
tmp = (1.0d0 / c) * (b - (a / (c / d)))
else if (d <= 8d+151) then
tmp = t_1
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 t_1 = ((c * b) - (d * a)) / ((c * c) + (d * d));
double tmp;
if (d <= -1.2e+52) {
tmp = t_0;
} else if (d <= -9.5e-131) {
tmp = t_1;
} else if (d <= 4.4e-149) {
tmp = (1.0 / c) * (b - (a / (c / d)));
} else if (d <= 8e+151) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b, c, d): t_0 = -a / d t_1 = ((c * b) - (d * a)) / ((c * c) + (d * d)) tmp = 0 if d <= -1.2e+52: tmp = t_0 elif d <= -9.5e-131: tmp = t_1 elif d <= 4.4e-149: tmp = (1.0 / c) * (b - (a / (c / d))) elif d <= 8e+151: tmp = t_1 else: tmp = t_0 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(-a) / d) t_1 = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d))) tmp = 0.0 if (d <= -1.2e+52) tmp = t_0; elseif (d <= -9.5e-131) tmp = t_1; elseif (d <= 4.4e-149) tmp = Float64(Float64(1.0 / c) * Float64(b - Float64(a / Float64(c / d)))); elseif (d <= 8e+151) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = -a / d; t_1 = ((c * b) - (d * a)) / ((c * c) + (d * d)); tmp = 0.0; if (d <= -1.2e+52) tmp = t_0; elseif (d <= -9.5e-131) tmp = t_1; elseif (d <= 4.4e-149) tmp = (1.0 / c) * (b - (a / (c / d))); elseif (d <= 8e+151) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[((-a) / d), $MachinePrecision]}, Block[{t$95$1 = 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.2e+52], t$95$0, If[LessEqual[d, -9.5e-131], t$95$1, If[LessEqual[d, 4.4e-149], N[(N[(1.0 / c), $MachinePrecision] * N[(b - N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 8e+151], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-a}{d}\\
t_1 := \frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{if}\;d \leq -1.2 \cdot 10^{+52}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq -9.5 \cdot 10^{-131}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d \leq 4.4 \cdot 10^{-149}:\\
\;\;\;\;\frac{1}{c} \cdot \left(b - \frac{a}{\frac{c}{d}}\right)\\
\mathbf{elif}\;d \leq 8 \cdot 10^{+151}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if d < -1.2e52 or 8.00000000000000014e151 < d Initial program 38.9%
Taylor expanded in c around 0 75.9%
associate-*r/75.9%
neg-mul-175.9%
Simplified75.9%
if -1.2e52 < d < -9.4999999999999996e-131 or 4.3999999999999996e-149 < d < 8.00000000000000014e151Initial program 86.1%
if -9.4999999999999996e-131 < d < 4.3999999999999996e-149Initial program 65.6%
*-un-lft-identity65.6%
add-sqr-sqrt65.6%
times-frac65.6%
hypot-def65.7%
hypot-def78.3%
Applied egg-rr78.3%
Taylor expanded in c around inf 52.7%
mul-1-neg52.7%
unsub-neg52.7%
associate-/l*52.6%
Simplified52.6%
Taylor expanded in c around inf 95.5%
Final simplification84.8%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- a) d)))
(if (<= d -2.4e-36)
t_0
(if (<= d 7.5e-19)
(* (/ 1.0 c) (- b (/ a (/ c d))))
(if (<= d 1.65e+121) (/ (* d (- a)) (+ (* c c) (* d d))) t_0)))))
double code(double a, double b, double c, double d) {
double t_0 = -a / d;
double tmp;
if (d <= -2.4e-36) {
tmp = t_0;
} else if (d <= 7.5e-19) {
tmp = (1.0 / c) * (b - (a / (c / d)));
} else if (d <= 1.65e+121) {
tmp = (d * -a) / ((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 = -a / d
if (d <= (-2.4d-36)) then
tmp = t_0
else if (d <= 7.5d-19) then
tmp = (1.0d0 / c) * (b - (a / (c / d)))
else if (d <= 1.65d+121) then
tmp = (d * -a) / ((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 = -a / d;
double tmp;
if (d <= -2.4e-36) {
tmp = t_0;
} else if (d <= 7.5e-19) {
tmp = (1.0 / c) * (b - (a / (c / d)));
} else if (d <= 1.65e+121) {
tmp = (d * -a) / ((c * c) + (d * d));
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b, c, d): t_0 = -a / d tmp = 0 if d <= -2.4e-36: tmp = t_0 elif d <= 7.5e-19: tmp = (1.0 / c) * (b - (a / (c / d))) elif d <= 1.65e+121: tmp = (d * -a) / ((c * c) + (d * d)) else: tmp = t_0 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(-a) / d) tmp = 0.0 if (d <= -2.4e-36) tmp = t_0; elseif (d <= 7.5e-19) tmp = Float64(Float64(1.0 / c) * Float64(b - Float64(a / Float64(c / d)))); elseif (d <= 1.65e+121) tmp = Float64(Float64(d * Float64(-a)) / 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 = -a / d; tmp = 0.0; if (d <= -2.4e-36) tmp = t_0; elseif (d <= 7.5e-19) tmp = (1.0 / c) * (b - (a / (c / d))); elseif (d <= 1.65e+121) tmp = (d * -a) / ((c * c) + (d * d)); 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, -2.4e-36], t$95$0, If[LessEqual[d, 7.5e-19], N[(N[(1.0 / c), $MachinePrecision] * N[(b - N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.65e+121], N[(N[(d * (-a)), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-a}{d}\\
\mathbf{if}\;d \leq -2.4 \cdot 10^{-36}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 7.5 \cdot 10^{-19}:\\
\;\;\;\;\frac{1}{c} \cdot \left(b - \frac{a}{\frac{c}{d}}\right)\\
\mathbf{elif}\;d \leq 1.65 \cdot 10^{+121}:\\
\;\;\;\;\frac{d \cdot \left(-a\right)}{c \cdot c + d \cdot d}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if d < -2.4e-36 or 1.6499999999999999e121 < d Initial program 48.2%
Taylor expanded in c around 0 73.4%
associate-*r/73.4%
neg-mul-173.4%
Simplified73.4%
if -2.4e-36 < d < 7.49999999999999957e-19Initial program 74.4%
*-un-lft-identity74.4%
add-sqr-sqrt74.4%
times-frac74.5%
hypot-def74.5%
hypot-def84.7%
Applied egg-rr84.7%
Taylor expanded in c around inf 52.6%
mul-1-neg52.6%
unsub-neg52.6%
associate-/l*52.6%
Simplified52.6%
Taylor expanded in c around inf 87.9%
if 7.49999999999999957e-19 < d < 1.6499999999999999e121Initial program 81.8%
Taylor expanded in b around 0 70.7%
associate-*r*70.7%
neg-mul-170.7%
*-commutative70.7%
Simplified70.7%
Final simplification79.4%
(FPCore (a b c d) :precision binary64 (if (or (<= d -1.1e-36) (not (<= d 1.45e-16))) (/ (- a) d) (* (/ 1.0 c) (- b (/ a (/ c d))))))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -1.1e-36) || !(d <= 1.45e-16)) {
tmp = -a / d;
} else {
tmp = (1.0 / c) * (b - (a / (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 ((d <= (-1.1d-36)) .or. (.not. (d <= 1.45d-16))) then
tmp = -a / d
else
tmp = (1.0d0 / c) * (b - (a / (c / d)))
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -1.1e-36) || !(d <= 1.45e-16)) {
tmp = -a / d;
} else {
tmp = (1.0 / c) * (b - (a / (c / d)));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -1.1e-36) or not (d <= 1.45e-16): tmp = -a / d else: tmp = (1.0 / c) * (b - (a / (c / d))) return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -1.1e-36) || !(d <= 1.45e-16)) tmp = Float64(Float64(-a) / d); else tmp = Float64(Float64(1.0 / c) * Float64(b - Float64(a / Float64(c / d)))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -1.1e-36) || ~((d <= 1.45e-16))) tmp = -a / d; else tmp = (1.0 / c) * (b - (a / (c / d))); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -1.1e-36], N[Not[LessEqual[d, 1.45e-16]], $MachinePrecision]], N[((-a) / d), $MachinePrecision], N[(N[(1.0 / c), $MachinePrecision] * N[(b - N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.1 \cdot 10^{-36} \lor \neg \left(d \leq 1.45 \cdot 10^{-16}\right):\\
\;\;\;\;\frac{-a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{c} \cdot \left(b - \frac{a}{\frac{c}{d}}\right)\\
\end{array}
\end{array}
if d < -1.1e-36 or 1.4499999999999999e-16 < d Initial program 54.5%
Taylor expanded in c around 0 69.8%
associate-*r/69.8%
neg-mul-169.8%
Simplified69.8%
if -1.1e-36 < d < 1.4499999999999999e-16Initial program 74.4%
*-un-lft-identity74.4%
add-sqr-sqrt74.4%
times-frac74.5%
hypot-def74.5%
hypot-def84.7%
Applied egg-rr84.7%
Taylor expanded in c around inf 52.6%
mul-1-neg52.6%
unsub-neg52.6%
associate-/l*52.6%
Simplified52.6%
Taylor expanded in c around inf 87.9%
Final simplification77.6%
(FPCore (a b c d) :precision binary64 (if (or (<= d -9.5e-39) (not (<= d 3.35e-18))) (/ (- a) d) (/ b c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -9.5e-39) || !(d <= 3.35e-18)) {
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 <= (-9.5d-39)) .or. (.not. (d <= 3.35d-18))) 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 <= -9.5e-39) || !(d <= 3.35e-18)) {
tmp = -a / d;
} else {
tmp = b / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -9.5e-39) or not (d <= 3.35e-18): tmp = -a / d else: tmp = b / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -9.5e-39) || !(d <= 3.35e-18)) tmp = Float64(Float64(-a) / d); else tmp = Float64(b / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -9.5e-39) || ~((d <= 3.35e-18))) tmp = -a / d; else tmp = b / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -9.5e-39], N[Not[LessEqual[d, 3.35e-18]], $MachinePrecision]], N[((-a) / d), $MachinePrecision], N[(b / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -9.5 \cdot 10^{-39} \lor \neg \left(d \leq 3.35 \cdot 10^{-18}\right):\\
\;\;\;\;\frac{-a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if d < -9.4999999999999999e-39 or 3.3499999999999999e-18 < d Initial program 54.5%
Taylor expanded in c around 0 69.8%
associate-*r/69.8%
neg-mul-169.8%
Simplified69.8%
if -9.4999999999999999e-39 < d < 3.3499999999999999e-18Initial program 74.4%
Taylor expanded in c around inf 68.6%
Final simplification69.3%
(FPCore (a b c d) :precision binary64 (if (<= d 6.6e+136) (/ b c) (/ b d)))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= 6.6e+136) {
tmp = b / c;
} else {
tmp = b / d;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (d <= 6.6d+136) then
tmp = b / c
else
tmp = b / d
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (d <= 6.6e+136) {
tmp = b / c;
} else {
tmp = b / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= 6.6e+136: tmp = b / c else: tmp = b / d return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= 6.6e+136) tmp = Float64(b / c); else tmp = Float64(b / d); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= 6.6e+136) tmp = b / c; else tmp = b / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, 6.6e+136], N[(b / c), $MachinePrecision], N[(b / d), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq 6.6 \cdot 10^{+136}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d}\\
\end{array}
\end{array}
if d < 6.59999999999999984e136Initial program 67.1%
Taylor expanded in c around inf 46.4%
if 6.59999999999999984e136 < d Initial program 40.3%
*-un-lft-identity40.3%
add-sqr-sqrt40.3%
times-frac40.3%
hypot-def40.3%
hypot-def51.2%
Applied egg-rr51.2%
Taylor expanded in c around -inf 27.2%
neg-mul-127.2%
Simplified27.2%
Taylor expanded in d around -inf 25.1%
Final simplification43.2%
(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 63.1%
*-un-lft-identity63.1%
add-sqr-sqrt63.1%
times-frac63.1%
hypot-def63.1%
hypot-def76.1%
Applied egg-rr76.1%
Taylor expanded in c around inf 32.6%
mul-1-neg32.6%
unsub-neg32.6%
associate-/l*34.2%
Simplified34.2%
Taylor expanded in d around -inf 9.9%
Final simplification9.9%
(FPCore (a b c d) :precision binary64 (/ b c))
double code(double a, double b, double c, double d) {
return b / c;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = b / c
end function
public static double code(double a, double b, double c, double d) {
return b / c;
}
def code(a, b, c, d): return b / c
function code(a, b, c, d) return Float64(b / c) end
function tmp = code(a, b, c, d) tmp = b / c; end
code[a_, b_, c_, d_] := N[(b / c), $MachinePrecision]
\begin{array}{l}
\\
\frac{b}{c}
\end{array}
Initial program 63.1%
Taylor expanded in c around inf 41.6%
Final simplification41.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 2023300
(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))))