
(FPCore (a b c d) :precision binary64 (/ (- (* b c) (* a d)) (+ (* c c) (* d d))))
double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = ((b * c) - (a * d)) / ((c * c) + (d * d))
end function
public static double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
def code(a, b, c, d): return ((b * c) - (a * d)) / ((c * c) + (d * d))
function code(a, b, c, d) return Float64(Float64(Float64(b * c) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d))) end
function tmp = code(a, b, c, d) tmp = ((b * c) - (a * d)) / ((c * c) + (d * d)); end
code[a_, b_, c_, d_] := N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b c d) :precision binary64 (/ (- (* b c) (* a d)) (+ (* c c) (* d d))))
double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = ((b * c) - (a * d)) / ((c * c) + (d * d))
end function
public static double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
def code(a, b, c, d): return ((b * c) - (a * d)) / ((c * c) + (d * d))
function code(a, b, c, d) return Float64(Float64(Float64(b * c) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d))) end
function tmp = code(a, b, c, d) tmp = ((b * c) - (a * d)) / ((c * c) + (d * d)); end
code[a_, b_, c_, d_] := N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}
\end{array}
(FPCore (a b c d) :precision binary64 (fma (/ c (hypot c d)) (/ b (hypot c d)) (/ (/ (- d) (hypot c d)) (/ (hypot c d) a))))
double code(double a, double b, double c, double d) {
return fma((c / hypot(c, d)), (b / hypot(c, d)), ((-d / hypot(c, d)) / (hypot(c, d) / a)));
}
function code(a, b, c, d) return fma(Float64(c / hypot(c, d)), Float64(b / hypot(c, d)), Float64(Float64(Float64(-d) / hypot(c, d)) / Float64(hypot(c, d) / a))) 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[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / a), $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{-d}{\mathsf{hypot}\left(c, d\right)}}{\frac{\mathsf{hypot}\left(c, d\right)}{a}}\right)
\end{array}
Initial program 63.5%
div-sub61.7%
sub-neg61.7%
*-commutative61.7%
add-sqr-sqrt61.7%
times-frac62.5%
fma-def62.5%
hypot-def62.5%
hypot-def75.1%
associate-/l*79.5%
add-sqr-sqrt79.4%
pow279.4%
hypot-def79.4%
Applied egg-rr79.4%
associate-/r/78.1%
*-commutative78.1%
associate-*r/75.1%
unpow275.1%
times-frac96.2%
Applied egg-rr96.2%
clear-num96.0%
un-div-inv96.3%
Applied egg-rr96.3%
Final simplification96.3%
(FPCore (a b c d) :precision binary64 (fma (/ c (hypot c d)) (/ b (hypot c d)) (* (/ a (hypot c d)) (/ (- d) (hypot c 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)) * (-d / hypot(c, d))));
}
function code(a, b, c, d) return fma(Float64(c / hypot(c, d)), Float64(b / hypot(c, d)), Float64(Float64(a / hypot(c, d)) * Float64(Float64(-d) / 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[(a / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[((-d) / 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{a}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{-d}{\mathsf{hypot}\left(c, d\right)}\right)
\end{array}
Initial program 63.5%
div-sub61.7%
sub-neg61.7%
*-commutative61.7%
add-sqr-sqrt61.7%
times-frac62.5%
fma-def62.5%
hypot-def62.5%
hypot-def75.1%
associate-/l*79.5%
add-sqr-sqrt79.4%
pow279.4%
hypot-def79.4%
Applied egg-rr79.4%
associate-/r/78.1%
*-commutative78.1%
associate-*r/75.1%
unpow275.1%
times-frac96.2%
Applied egg-rr96.2%
Final simplification96.2%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (- (* c b) (* d a))))
(if (<= (/ t_0 (+ (* c c) (* d d))) 5e+90)
(/ (/ t_0 (hypot c d)) (hypot c d))
(-
(* (/ 1.0 (hypot c d)) (/ c (/ (hypot c d) b)))
(* d (/ (/ a (hypot c d)) (hypot c d)))))))
double code(double a, double b, double c, double d) {
double t_0 = (c * b) - (d * a);
double tmp;
if ((t_0 / ((c * c) + (d * d))) <= 5e+90) {
tmp = (t_0 / hypot(c, d)) / hypot(c, d);
} else {
tmp = ((1.0 / hypot(c, d)) * (c / (hypot(c, d) / b))) - (d * ((a / hypot(c, d)) / hypot(c, d)));
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = (c * b) - (d * a);
double tmp;
if ((t_0 / ((c * c) + (d * d))) <= 5e+90) {
tmp = (t_0 / Math.hypot(c, d)) / Math.hypot(c, d);
} else {
tmp = ((1.0 / Math.hypot(c, d)) * (c / (Math.hypot(c, d) / b))) - (d * ((a / Math.hypot(c, d)) / Math.hypot(c, d)));
}
return tmp;
}
def code(a, b, c, d): t_0 = (c * b) - (d * a) tmp = 0 if (t_0 / ((c * c) + (d * d))) <= 5e+90: tmp = (t_0 / math.hypot(c, d)) / math.hypot(c, d) else: tmp = ((1.0 / math.hypot(c, d)) * (c / (math.hypot(c, d) / b))) - (d * ((a / math.hypot(c, d)) / math.hypot(c, d))) return tmp
function code(a, b, c, d) t_0 = Float64(Float64(c * b) - Float64(d * a)) tmp = 0.0 if (Float64(t_0 / Float64(Float64(c * c) + Float64(d * d))) <= 5e+90) tmp = Float64(Float64(t_0 / hypot(c, d)) / hypot(c, d)); else tmp = Float64(Float64(Float64(1.0 / hypot(c, d)) * Float64(c / Float64(hypot(c, d) / b))) - Float64(d * Float64(Float64(a / hypot(c, d)) / hypot(c, d)))); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (c * b) - (d * a); tmp = 0.0; if ((t_0 / ((c * c) + (d * d))) <= 5e+90) tmp = (t_0 / hypot(c, d)) / hypot(c, d); else tmp = ((1.0 / hypot(c, d)) * (c / (hypot(c, d) / b))) - (d * ((a / hypot(c, d)) / hypot(c, d))); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$0 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 5e+90], N[(N[(t$95$0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(c / N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(d * N[(N[(a / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $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 5 \cdot 10^{+90}:\\
\;\;\;\;\frac{\frac{t_0}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{c}{\frac{\mathsf{hypot}\left(c, d\right)}{b}} - d \cdot \frac{\frac{a}{\mathsf{hypot}\left(c, d\right)}}{\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))) < 5.0000000000000004e90Initial program 81.9%
*-un-lft-identity81.9%
add-sqr-sqrt81.9%
times-frac81.8%
hypot-def81.8%
hypot-def96.9%
Applied egg-rr96.9%
associate-*l/97.1%
*-un-lft-identity97.1%
*-commutative97.1%
*-commutative97.1%
Applied egg-rr97.1%
if 5.0000000000000004e90 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 21.5%
div-sub19.8%
sub-neg19.8%
*-un-lft-identity19.8%
add-sqr-sqrt19.8%
times-frac19.8%
fma-def19.8%
hypot-def19.9%
hypot-def22.0%
associate-/l*29.3%
add-sqr-sqrt29.3%
pow229.3%
hypot-def29.3%
Applied egg-rr29.3%
fma-neg28.0%
*-commutative28.0%
associate-/l*62.8%
associate-/r/62.8%
*-commutative62.8%
Simplified62.8%
*-un-lft-identity62.8%
unpow262.8%
times-frac83.8%
Applied egg-rr83.8%
associate-*l/83.9%
*-lft-identity83.9%
Simplified83.9%
Final simplification93.1%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (- (* c b) (* d a))))
(if (<= (/ t_0 (+ (* c c) (* d d))) 1e+254)
(/ (/ t_0 (hypot c d)) (hypot c d))
(fma (/ c (hypot c d)) (/ b (hypot c d)) (/ (- a) d)))))
double code(double a, double b, double c, double d) {
double t_0 = (c * b) - (d * a);
double tmp;
if ((t_0 / ((c * c) + (d * d))) <= 1e+254) {
tmp = (t_0 / hypot(c, d)) / hypot(c, d);
} else {
tmp = fma((c / hypot(c, d)), (b / hypot(c, d)), (-a / d));
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(c * b) - Float64(d * a)) tmp = 0.0 if (Float64(t_0 / Float64(Float64(c * c) + Float64(d * d))) <= 1e+254) tmp = Float64(Float64(t_0 / hypot(c, d)) / hypot(c, d)); else tmp = fma(Float64(c / hypot(c, d)), Float64(b / hypot(c, d)), Float64(Float64(-a) / d)); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$0 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1e+254], N[(N[(t$95$0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision], N[(N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] + N[((-a) / d), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := c \cdot b - d \cdot a\\
\mathbf{if}\;\frac{t_0}{c \cdot c + d \cdot d} \leq 10^{+254}:\\
\;\;\;\;\frac{\frac{t_0}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, \frac{-a}{d}\right)\\
\end{array}
\end{array}
if (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 9.9999999999999994e253Initial program 82.7%
*-un-lft-identity82.7%
add-sqr-sqrt82.7%
times-frac82.7%
hypot-def82.7%
hypot-def97.0%
Applied egg-rr97.0%
associate-*l/97.3%
*-un-lft-identity97.3%
*-commutative97.3%
*-commutative97.3%
Applied egg-rr97.3%
if 9.9999999999999994e253 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 11.4%
div-sub9.4%
sub-neg9.4%
*-commutative9.4%
add-sqr-sqrt9.4%
times-frac16.3%
fma-def16.3%
hypot-def16.3%
hypot-def45.6%
associate-/l*58.1%
add-sqr-sqrt58.1%
pow258.1%
hypot-def58.1%
Applied egg-rr58.1%
Taylor expanded in c around 0 67.8%
Final simplification89.3%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (- (* c b) (* d a))) (t_1 (/ t_0 (+ (* c c) (* d d)))))
(if (<= t_1 1e+254)
(/ (/ t_0 (hypot c d)) (hypot c d))
(if (<= t_1 INFINITY)
(fabs (/ (+ a (* c (/ b d))) (hypot d c)))
(/ (- b (* d (/ a c))) c)))))
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 <= 1e+254) {
tmp = (t_0 / hypot(c, d)) / hypot(c, d);
} else if (t_1 <= ((double) INFINITY)) {
tmp = fabs(((a + (c * (b / d))) / hypot(d, c)));
} else {
tmp = (b - (d * (a / c))) / c;
}
return tmp;
}
public static 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 <= 1e+254) {
tmp = (t_0 / Math.hypot(c, d)) / Math.hypot(c, d);
} else if (t_1 <= Double.POSITIVE_INFINITY) {
tmp = Math.abs(((a + (c * (b / d))) / Math.hypot(d, c)));
} else {
tmp = (b - (d * (a / c))) / c;
}
return tmp;
}
def code(a, b, c, d): t_0 = (c * b) - (d * a) t_1 = t_0 / ((c * c) + (d * d)) tmp = 0 if t_1 <= 1e+254: tmp = (t_0 / math.hypot(c, d)) / math.hypot(c, d) elif t_1 <= math.inf: tmp = math.fabs(((a + (c * (b / d))) / math.hypot(d, c))) else: tmp = (b - (d * (a / c))) / c 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 <= 1e+254) tmp = Float64(Float64(t_0 / hypot(c, d)) / hypot(c, d)); elseif (t_1 <= Inf) tmp = abs(Float64(Float64(a + Float64(c * Float64(b / d))) / hypot(d, c))); else tmp = Float64(Float64(b - Float64(d * Float64(a / c))) / c); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (c * b) - (d * a); t_1 = t_0 / ((c * c) + (d * d)); tmp = 0.0; if (t_1 <= 1e+254) tmp = (t_0 / hypot(c, d)) / hypot(c, d); elseif (t_1 <= Inf) tmp = abs(((a + (c * (b / d))) / hypot(d, c))); else tmp = (b - (d * (a / c))) / c; end tmp_2 = 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[LessEqual[t$95$1, 1e+254], N[(N[(t$95$0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[Abs[N[(N[(a + N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[(b - N[(d * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $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 10^{+254}:\\
\;\;\;\;\frac{\frac{t_0}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;t_1 \leq \infty:\\
\;\;\;\;\left|\frac{a + c \cdot \frac{b}{d}}{\mathsf{hypot}\left(d, c\right)}\right|\\
\mathbf{else}:\\
\;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\
\end{array}
\end{array}
if (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 9.9999999999999994e253Initial program 82.7%
*-un-lft-identity82.7%
add-sqr-sqrt82.7%
times-frac82.7%
hypot-def82.7%
hypot-def97.0%
Applied egg-rr97.0%
associate-*l/97.3%
*-un-lft-identity97.3%
*-commutative97.3%
*-commutative97.3%
Applied egg-rr97.3%
if 9.9999999999999994e253 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < +inf.0Initial program 35.7%
*-un-lft-identity35.7%
add-sqr-sqrt35.7%
times-frac35.7%
hypot-def35.7%
hypot-def58.2%
Applied egg-rr58.2%
Taylor expanded in c around 0 42.9%
neg-mul-142.9%
+-commutative42.9%
unsub-neg42.9%
*-commutative42.9%
Simplified42.9%
add-sqr-sqrt42.8%
sqrt-unprod46.1%
pow246.1%
associate-*l/46.2%
*-un-lft-identity46.2%
sub-neg46.2%
add-sqr-sqrt32.8%
sqrt-unprod37.5%
sqr-neg37.5%
sqrt-unprod13.3%
add-sqr-sqrt46.2%
Applied egg-rr46.2%
unpow246.2%
rem-sqrt-square75.6%
+-commutative75.6%
associate-*r/78.6%
hypot-def61.5%
unpow261.5%
unpow261.5%
+-commutative61.5%
unpow261.5%
unpow261.5%
hypot-def78.6%
Simplified78.6%
if +inf.0 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 0.0%
Taylor expanded in c around inf 43.5%
+-commutative43.5%
mul-1-neg43.5%
unsub-neg43.5%
associate-/l*48.8%
associate-/r/48.8%
Simplified48.8%
*-un-lft-identity48.8%
unpow248.8%
times-frac56.8%
Applied egg-rr56.8%
associate-*l/56.8%
*-lft-identity56.8%
Simplified56.8%
associate-*l/57.2%
sub-div57.3%
Applied egg-rr57.3%
Final simplification88.3%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* c b) (* d a)) (+ (* c c) (* d d)))))
(if (<= c -1.55e+95)
(- (/ b c) (/ (/ a c) (/ c d)))
(if (<= c -4.2e-100)
t_0
(if (<= c 3.1e-145)
(* (/ 1.0 d) (- (/ (* c b) d) a))
(if (<= c 3.4e+80)
t_0
(* (/ 1.0 (hypot c d)) (- b (/ a (/ c d))))))))))
double code(double a, double b, double c, double d) {
double t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
double tmp;
if (c <= -1.55e+95) {
tmp = (b / c) - ((a / c) / (c / d));
} else if (c <= -4.2e-100) {
tmp = t_0;
} else if (c <= 3.1e-145) {
tmp = (1.0 / d) * (((c * b) / d) - a);
} else if (c <= 3.4e+80) {
tmp = t_0;
} else {
tmp = (1.0 / hypot(c, d)) * (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)) / ((c * c) + (d * d));
double tmp;
if (c <= -1.55e+95) {
tmp = (b / c) - ((a / c) / (c / d));
} else if (c <= -4.2e-100) {
tmp = t_0;
} else if (c <= 3.1e-145) {
tmp = (1.0 / d) * (((c * b) / d) - a);
} else if (c <= 3.4e+80) {
tmp = t_0;
} else {
tmp = (1.0 / Math.hypot(c, d)) * (b - (a / (c / d)));
}
return tmp;
}
def code(a, b, c, d): t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d)) tmp = 0 if c <= -1.55e+95: tmp = (b / c) - ((a / c) / (c / d)) elif c <= -4.2e-100: tmp = t_0 elif c <= 3.1e-145: tmp = (1.0 / d) * (((c * b) / d) - a) elif c <= 3.4e+80: tmp = t_0 else: tmp = (1.0 / math.hypot(c, d)) * (b - (a / (c / d))) return tmp
function code(a, b, c, d) t_0 = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d))) tmp = 0.0 if (c <= -1.55e+95) tmp = Float64(Float64(b / c) - Float64(Float64(a / c) / Float64(c / d))); elseif (c <= -4.2e-100) tmp = t_0; elseif (c <= 3.1e-145) tmp = Float64(Float64(1.0 / d) * Float64(Float64(Float64(c * b) / d) - a)); elseif (c <= 3.4e+80) tmp = t_0; else tmp = Float64(Float64(1.0 / hypot(c, d)) * 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)) / ((c * c) + (d * d)); tmp = 0.0; if (c <= -1.55e+95) tmp = (b / c) - ((a / c) / (c / d)); elseif (c <= -4.2e-100) tmp = t_0; elseif (c <= 3.1e-145) tmp = (1.0 / d) * (((c * b) / d) - a); elseif (c <= 3.4e+80) tmp = t_0; else tmp = (1.0 / hypot(c, d)) * (b - (a / (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[c, -1.55e+95], N[(N[(b / c), $MachinePrecision] - N[(N[(a / c), $MachinePrecision] / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -4.2e-100], t$95$0, If[LessEqual[c, 3.1e-145], N[(N[(1.0 / d), $MachinePrecision] * N[(N[(N[(c * b), $MachinePrecision] / d), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 3.4e+80], t$95$0, N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b - N[(a / N[(c / d), $MachinePrecision]), $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}\;c \leq -1.55 \cdot 10^{+95}:\\
\;\;\;\;\frac{b}{c} - \frac{\frac{a}{c}}{\frac{c}{d}}\\
\mathbf{elif}\;c \leq -4.2 \cdot 10^{-100}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 3.1 \cdot 10^{-145}:\\
\;\;\;\;\frac{1}{d} \cdot \left(\frac{c \cdot b}{d} - a\right)\\
\mathbf{elif}\;c \leq 3.4 \cdot 10^{+80}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(b - \frac{a}{\frac{c}{d}}\right)\\
\end{array}
\end{array}
if c < -1.5500000000000001e95Initial program 49.8%
Taylor expanded in c around inf 84.3%
+-commutative84.3%
mul-1-neg84.3%
unsub-neg84.3%
associate-/l*84.9%
associate-/r/87.5%
Simplified87.5%
*-un-lft-identity87.5%
unpow287.5%
times-frac92.3%
Applied egg-rr92.3%
associate-*l/92.4%
*-lft-identity92.4%
Simplified92.4%
associate-*l/94.8%
Applied egg-rr94.8%
associate-/l*94.9%
Simplified94.9%
if -1.5500000000000001e95 < c < -4.20000000000000019e-100 or 3.1e-145 < c < 3.39999999999999992e80Initial program 86.4%
if -4.20000000000000019e-100 < c < 3.1e-145Initial program 59.3%
*-un-lft-identity59.3%
add-sqr-sqrt59.3%
times-frac59.3%
hypot-def59.3%
hypot-def75.8%
Applied egg-rr75.8%
Taylor expanded in c around 0 47.2%
neg-mul-147.2%
+-commutative47.2%
unsub-neg47.2%
*-commutative47.2%
Simplified47.2%
Taylor expanded in c around 0 88.7%
if 3.39999999999999992e80 < c Initial program 31.2%
*-un-lft-identity31.2%
add-sqr-sqrt31.2%
times-frac31.2%
hypot-def31.2%
hypot-def50.0%
Applied egg-rr50.0%
Taylor expanded in c around inf 83.3%
mul-1-neg83.3%
unsub-neg83.3%
associate-/l*88.7%
Simplified88.7%
Final simplification88.7%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* c b) (* d a)) (+ (* c c) (* d d)))))
(if (<= c -2.8e+91)
(- (/ b c) (/ (/ a c) (/ c d)))
(if (<= c -4.2e-100)
t_0
(if (<= c 2.8e-146)
(* (/ 1.0 d) (- (/ (* c b) d) a))
(if (<= c 4.3e+80) t_0 (/ (- b (* d (/ a c))) c)))))))
double code(double a, double b, double c, double d) {
double t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
double tmp;
if (c <= -2.8e+91) {
tmp = (b / c) - ((a / c) / (c / d));
} else if (c <= -4.2e-100) {
tmp = t_0;
} else if (c <= 2.8e-146) {
tmp = (1.0 / d) * (((c * b) / d) - a);
} else if (c <= 4.3e+80) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d))
if (c <= (-2.8d+91)) then
tmp = (b / c) - ((a / c) / (c / d))
else if (c <= (-4.2d-100)) then
tmp = t_0
else if (c <= 2.8d-146) then
tmp = (1.0d0 / d) * (((c * b) / d) - a)
else if (c <= 4.3d+80) then
tmp = t_0
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 t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
double tmp;
if (c <= -2.8e+91) {
tmp = (b / c) - ((a / c) / (c / d));
} else if (c <= -4.2e-100) {
tmp = t_0;
} else if (c <= 2.8e-146) {
tmp = (1.0 / d) * (((c * b) / d) - a);
} else if (c <= 4.3e+80) {
tmp = t_0;
} else {
tmp = (b - (d * (a / c))) / c;
}
return tmp;
}
def code(a, b, c, d): t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d)) tmp = 0 if c <= -2.8e+91: tmp = (b / c) - ((a / c) / (c / d)) elif c <= -4.2e-100: tmp = t_0 elif c <= 2.8e-146: tmp = (1.0 / d) * (((c * b) / d) - a) elif c <= 4.3e+80: tmp = t_0 else: tmp = (b - (d * (a / c))) / c return tmp
function code(a, b, c, d) t_0 = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d))) tmp = 0.0 if (c <= -2.8e+91) tmp = Float64(Float64(b / c) - Float64(Float64(a / c) / Float64(c / d))); elseif (c <= -4.2e-100) tmp = t_0; elseif (c <= 2.8e-146) tmp = Float64(Float64(1.0 / d) * Float64(Float64(Float64(c * b) / d) - a)); elseif (c <= 4.3e+80) tmp = t_0; else tmp = Float64(Float64(b - Float64(d * Float64(a / c))) / c); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d)); tmp = 0.0; if (c <= -2.8e+91) tmp = (b / c) - ((a / c) / (c / d)); elseif (c <= -4.2e-100) tmp = t_0; elseif (c <= 2.8e-146) tmp = (1.0 / d) * (((c * b) / d) - a); elseif (c <= 4.3e+80) tmp = t_0; else tmp = (b - (d * (a / c))) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -2.8e+91], N[(N[(b / c), $MachinePrecision] - N[(N[(a / c), $MachinePrecision] / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -4.2e-100], t$95$0, If[LessEqual[c, 2.8e-146], N[(N[(1.0 / d), $MachinePrecision] * N[(N[(N[(c * b), $MachinePrecision] / d), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 4.3e+80], t$95$0, N[(N[(b - N[(d * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{if}\;c \leq -2.8 \cdot 10^{+91}:\\
\;\;\;\;\frac{b}{c} - \frac{\frac{a}{c}}{\frac{c}{d}}\\
\mathbf{elif}\;c \leq -4.2 \cdot 10^{-100}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 2.8 \cdot 10^{-146}:\\
\;\;\;\;\frac{1}{d} \cdot \left(\frac{c \cdot b}{d} - a\right)\\
\mathbf{elif}\;c \leq 4.3 \cdot 10^{+80}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\
\end{array}
\end{array}
if c < -2.7999999999999999e91Initial program 49.8%
Taylor expanded in c around inf 84.3%
+-commutative84.3%
mul-1-neg84.3%
unsub-neg84.3%
associate-/l*84.9%
associate-/r/87.5%
Simplified87.5%
*-un-lft-identity87.5%
unpow287.5%
times-frac92.3%
Applied egg-rr92.3%
associate-*l/92.4%
*-lft-identity92.4%
Simplified92.4%
associate-*l/94.8%
Applied egg-rr94.8%
associate-/l*94.9%
Simplified94.9%
if -2.7999999999999999e91 < c < -4.20000000000000019e-100 or 2.80000000000000003e-146 < c < 4.30000000000000004e80Initial program 86.4%
if -4.20000000000000019e-100 < c < 2.80000000000000003e-146Initial program 59.3%
*-un-lft-identity59.3%
add-sqr-sqrt59.3%
times-frac59.3%
hypot-def59.3%
hypot-def75.8%
Applied egg-rr75.8%
Taylor expanded in c around 0 47.2%
neg-mul-147.2%
+-commutative47.2%
unsub-neg47.2%
*-commutative47.2%
Simplified47.2%
Taylor expanded in c around 0 88.7%
if 4.30000000000000004e80 < c Initial program 31.2%
Taylor expanded in c around inf 77.8%
+-commutative77.8%
mul-1-neg77.8%
unsub-neg77.8%
associate-/l*79.9%
associate-/r/80.8%
Simplified80.8%
*-un-lft-identity80.8%
unpow280.8%
times-frac84.4%
Applied egg-rr84.4%
associate-*l/84.4%
*-lft-identity84.4%
Simplified84.4%
associate-*l/87.9%
sub-div87.9%
Applied egg-rr87.9%
Final simplification88.6%
(FPCore (a b c d) :precision binary64 (if (or (<= c -6.5e+48) (not (<= c 7.5e+79))) (/ (- b (* d (/ a c))) c) (* (/ 1.0 d) (- (/ (* c b) d) a))))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -6.5e+48) || !(c <= 7.5e+79)) {
tmp = (b - (d * (a / c))) / c;
} else {
tmp = (1.0 / d) * (((c * b) / d) - 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 <= (-6.5d+48)) .or. (.not. (c <= 7.5d+79))) then
tmp = (b - (d * (a / c))) / c
else
tmp = (1.0d0 / d) * (((c * b) / d) - a)
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -6.5e+48) || !(c <= 7.5e+79)) {
tmp = (b - (d * (a / c))) / c;
} else {
tmp = (1.0 / d) * (((c * b) / d) - a);
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -6.5e+48) or not (c <= 7.5e+79): tmp = (b - (d * (a / c))) / c else: tmp = (1.0 / d) * (((c * b) / d) - a) return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -6.5e+48) || !(c <= 7.5e+79)) tmp = Float64(Float64(b - Float64(d * Float64(a / c))) / c); else tmp = Float64(Float64(1.0 / d) * Float64(Float64(Float64(c * b) / d) - a)); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((c <= -6.5e+48) || ~((c <= 7.5e+79))) tmp = (b - (d * (a / c))) / c; else tmp = (1.0 / d) * (((c * b) / d) - a); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -6.5e+48], N[Not[LessEqual[c, 7.5e+79]], $MachinePrecision]], N[(N[(b - N[(d * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], N[(N[(1.0 / d), $MachinePrecision] * N[(N[(N[(c * b), $MachinePrecision] / d), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -6.5 \cdot 10^{+48} \lor \neg \left(c \leq 7.5 \cdot 10^{+79}\right):\\
\;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{d} \cdot \left(\frac{c \cdot b}{d} - a\right)\\
\end{array}
\end{array}
if c < -6.49999999999999972e48 or 7.49999999999999967e79 < c Initial program 46.3%
Taylor expanded in c around inf 80.0%
+-commutative80.0%
mul-1-neg80.0%
unsub-neg80.0%
associate-/l*81.2%
associate-/r/82.7%
Simplified82.7%
*-un-lft-identity82.7%
unpow282.7%
times-frac86.4%
Applied egg-rr86.4%
associate-*l/86.4%
*-lft-identity86.4%
Simplified86.4%
associate-*l/89.1%
sub-div89.1%
Applied egg-rr89.1%
if -6.49999999999999972e48 < c < 7.49999999999999967e79Initial program 72.7%
*-un-lft-identity72.7%
add-sqr-sqrt72.6%
times-frac72.6%
hypot-def72.6%
hypot-def84.3%
Applied egg-rr84.3%
Taylor expanded in c around 0 44.7%
neg-mul-144.7%
+-commutative44.7%
unsub-neg44.7%
*-commutative44.7%
Simplified44.7%
Taylor expanded in c around 0 78.3%
Final simplification82.1%
(FPCore (a b c d) :precision binary64 (if (or (<= d -1.05e+47) (not (<= d 2.4e+62))) (/ (- a) d) (/ (- b (* d (/ a c))) c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -1.05e+47) || !(d <= 2.4e+62)) {
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 <= (-1.05d+47)) .or. (.not. (d <= 2.4d+62))) 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 <= -1.05e+47) || !(d <= 2.4e+62)) {
tmp = -a / d;
} else {
tmp = (b - (d * (a / c))) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -1.05e+47) or not (d <= 2.4e+62): tmp = -a / d else: tmp = (b - (d * (a / c))) / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -1.05e+47) || !(d <= 2.4e+62)) 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 <= -1.05e+47) || ~((d <= 2.4e+62))) tmp = -a / d; else tmp = (b - (d * (a / c))) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -1.05e+47], N[Not[LessEqual[d, 2.4e+62]], $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 -1.05 \cdot 10^{+47} \lor \neg \left(d \leq 2.4 \cdot 10^{+62}\right):\\
\;\;\;\;\frac{-a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\
\end{array}
\end{array}
if d < -1.05e47 or 2.4e62 < d Initial program 50.0%
Taylor expanded in c around 0 77.0%
associate-*r/77.0%
neg-mul-177.0%
Simplified77.0%
if -1.05e47 < d < 2.4e62Initial program 72.7%
Taylor expanded in c around inf 65.3%
+-commutative65.3%
mul-1-neg65.3%
unsub-neg65.3%
associate-/l*64.5%
associate-/r/64.1%
Simplified64.1%
*-un-lft-identity64.1%
unpow264.1%
times-frac67.2%
Applied egg-rr67.2%
associate-*l/67.2%
*-lft-identity67.2%
Simplified67.2%
associate-*l/70.8%
sub-div74.1%
Applied egg-rr74.1%
Final simplification75.3%
(FPCore (a b c d) :precision binary64 (if (or (<= d -2.5e+46) (not (<= d 4.1e+58))) (/ (- a) d) (/ b c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -2.5e+46) || !(d <= 4.1e+58)) {
tmp = -a / d;
} else {
tmp = b / c;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if ((d <= (-2.5d+46)) .or. (.not. (d <= 4.1d+58))) then
tmp = -a / d
else
tmp = b / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -2.5e+46) || !(d <= 4.1e+58)) {
tmp = -a / d;
} else {
tmp = b / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -2.5e+46) or not (d <= 4.1e+58): tmp = -a / d else: tmp = b / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -2.5e+46) || !(d <= 4.1e+58)) tmp = Float64(Float64(-a) / d); else tmp = Float64(b / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -2.5e+46) || ~((d <= 4.1e+58))) tmp = -a / d; else tmp = b / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -2.5e+46], N[Not[LessEqual[d, 4.1e+58]], $MachinePrecision]], N[((-a) / d), $MachinePrecision], N[(b / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -2.5 \cdot 10^{+46} \lor \neg \left(d \leq 4.1 \cdot 10^{+58}\right):\\
\;\;\;\;\frac{-a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if d < -2.5000000000000001e46 or 4.1e58 < d Initial program 50.0%
Taylor expanded in c around 0 77.0%
associate-*r/77.0%
neg-mul-177.0%
Simplified77.0%
if -2.5000000000000001e46 < d < 4.1e58Initial program 72.7%
Taylor expanded in c around inf 61.4%
Final simplification67.7%
(FPCore (a b c d) :precision binary64 (if (or (<= d -3.7e+259) (not (<= d 2.25e+176))) (/ b d) (/ b c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -3.7e+259) || !(d <= 2.25e+176)) {
tmp = b / d;
} else {
tmp = b / c;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if ((d <= (-3.7d+259)) .or. (.not. (d <= 2.25d+176))) then
tmp = b / d
else
tmp = b / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -3.7e+259) || !(d <= 2.25e+176)) {
tmp = b / d;
} else {
tmp = b / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -3.7e+259) or not (d <= 2.25e+176): tmp = b / d else: tmp = b / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -3.7e+259) || !(d <= 2.25e+176)) tmp = Float64(b / d); else tmp = Float64(b / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -3.7e+259) || ~((d <= 2.25e+176))) tmp = b / d; else tmp = b / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -3.7e+259], N[Not[LessEqual[d, 2.25e+176]], $MachinePrecision]], N[(b / d), $MachinePrecision], N[(b / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -3.7 \cdot 10^{+259} \lor \neg \left(d \leq 2.25 \cdot 10^{+176}\right):\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if d < -3.70000000000000015e259 or 2.25000000000000002e176 < d Initial program 53.4%
*-un-lft-identity53.4%
add-sqr-sqrt53.4%
times-frac53.4%
hypot-def53.4%
hypot-def66.7%
Applied egg-rr66.7%
Taylor expanded in c around 0 82.2%
neg-mul-182.2%
+-commutative82.2%
unsub-neg82.2%
*-commutative82.2%
Simplified82.2%
Taylor expanded in c around inf 45.0%
if -3.70000000000000015e259 < d < 2.25000000000000002e176Initial program 65.3%
Taylor expanded in c around inf 49.3%
Final simplification48.6%
(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.5%
*-un-lft-identity63.5%
add-sqr-sqrt63.5%
times-frac63.4%
hypot-def63.5%
hypot-def76.4%
Applied egg-rr76.4%
Taylor expanded in c around 0 30.2%
neg-mul-130.2%
Simplified30.2%
Taylor expanded in c around -inf 11.2%
Final simplification11.2%
(FPCore (a b c d) :precision binary64 (/ b c))
double code(double a, double b, double c, double d) {
return b / c;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = b / c
end function
public static double code(double a, double b, double c, double d) {
return b / c;
}
def code(a, b, c, d): return b / c
function code(a, b, c, d) return Float64(b / c) end
function tmp = code(a, b, c, d) tmp = b / c; end
code[a_, b_, c_, d_] := N[(b / c), $MachinePrecision]
\begin{array}{l}
\\
\frac{b}{c}
\end{array}
Initial program 63.5%
Taylor expanded in c around inf 43.6%
Final simplification43.6%
(FPCore (a b c d) :precision binary64 (if (< (fabs d) (fabs c)) (/ (- b (* a (/ d c))) (+ c (* d (/ d c)))) (/ (+ (- a) (* b (/ c d))) (+ d (* c (/ c d))))))
double code(double a, double b, double c, double d) {
double tmp;
if (fabs(d) < fabs(c)) {
tmp = (b - (a * (d / c))) / (c + (d * (d / c)));
} else {
tmp = (-a + (b * (c / d))) / (d + (c * (c / d)));
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (abs(d) < abs(c)) then
tmp = (b - (a * (d / c))) / (c + (d * (d / c)))
else
tmp = (-a + (b * (c / d))) / (d + (c * (c / d)))
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (Math.abs(d) < Math.abs(c)) {
tmp = (b - (a * (d / c))) / (c + (d * (d / c)));
} else {
tmp = (-a + (b * (c / d))) / (d + (c * (c / d)));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if math.fabs(d) < math.fabs(c): tmp = (b - (a * (d / c))) / (c + (d * (d / c))) else: tmp = (-a + (b * (c / d))) / (d + (c * (c / d))) return tmp
function code(a, b, c, d) tmp = 0.0 if (abs(d) < abs(c)) tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / Float64(c + Float64(d * Float64(d / c)))); else tmp = Float64(Float64(Float64(-a) + Float64(b * Float64(c / d))) / Float64(d + Float64(c * Float64(c / d)))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (abs(d) < abs(c)) tmp = (b - (a * (d / c))) / (c + (d * (d / c))); else tmp = (-a + (b * (c / d))) / (d + (c * (c / d))); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Less[N[Abs[d], $MachinePrecision], N[Abs[c], $MachinePrecision]], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(c + N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[((-a) + N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(d + N[(c * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left|d\right| < \left|c\right|:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c + d \cdot \frac{d}{c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-a\right) + b \cdot \frac{c}{d}}{d + c \cdot \frac{c}{d}}\\
\end{array}
\end{array}
herbie shell --seed 2024019
(FPCore (a b c d)
:name "Complex division, imag part"
:precision binary64
:herbie-target
(if (< (fabs d) (fabs c)) (/ (- b (* a (/ d c))) (+ c (* d (/ d c)))) (/ (+ (- a) (* b (/ c d))) (+ d (* c (/ c d)))))
(/ (- (* b c) (* a d)) (+ (* c c) (* d d))))