
(FPCore (a b c d) :precision binary64 (/ (- (* b c) (* a d)) (+ (* c c) (* d d))))
double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = ((b * c) - (a * d)) / ((c * c) + (d * d))
end function
public static double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
def code(a, b, c, d): return ((b * c) - (a * d)) / ((c * c) + (d * d))
function code(a, b, c, d) return Float64(Float64(Float64(b * c) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d))) end
function tmp = code(a, b, c, d) tmp = ((b * c) - (a * d)) / ((c * c) + (d * d)); end
code[a_, b_, c_, d_] := N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b c d) :precision binary64 (/ (- (* b c) (* a d)) (+ (* c c) (* d d))))
double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = ((b * c) - (a * d)) / ((c * c) + (d * d))
end function
public static double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
def code(a, b, c, d): return ((b * c) - (a * d)) / ((c * c) + (d * d))
function code(a, b, c, d) return Float64(Float64(Float64(b * c) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d))) end
function tmp = code(a, b, c, d) tmp = ((b * c) - (a * d)) / ((c * c) + (d * d)); end
code[a_, b_, c_, d_] := N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}
\end{array}
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ 1.0 (hypot c d))) (t_1 (pow (hypot c d) 2.0)))
(if (<= d -1.4e+72)
(/ (- (/ b (/ d c)) a) d)
(if (<= d -3.4e-134)
(fma t_0 (* c (/ b (hypot c d))) (/ (* a (- d)) t_1))
(if (<= d 5.2e-42)
(/ (- b (/ (* d a) c)) c)
(if (<= d 7.2e+153)
(- (* t_0 (* b (/ c (hypot c d)))) (/ (* d a) t_1))
(/ (- (* c (/ b d)) a) d)))))))
double code(double a, double b, double c, double d) {
double t_0 = 1.0 / hypot(c, d);
double t_1 = pow(hypot(c, d), 2.0);
double tmp;
if (d <= -1.4e+72) {
tmp = ((b / (d / c)) - a) / d;
} else if (d <= -3.4e-134) {
tmp = fma(t_0, (c * (b / hypot(c, d))), ((a * -d) / t_1));
} else if (d <= 5.2e-42) {
tmp = (b - ((d * a) / c)) / c;
} else if (d <= 7.2e+153) {
tmp = (t_0 * (b * (c / hypot(c, d)))) - ((d * a) / t_1);
} else {
tmp = ((c * (b / d)) - a) / d;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(1.0 / hypot(c, d)) t_1 = hypot(c, d) ^ 2.0 tmp = 0.0 if (d <= -1.4e+72) tmp = Float64(Float64(Float64(b / Float64(d / c)) - a) / d); elseif (d <= -3.4e-134) tmp = fma(t_0, Float64(c * Float64(b / hypot(c, d))), Float64(Float64(a * Float64(-d)) / t_1)); elseif (d <= 5.2e-42) tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c); elseif (d <= 7.2e+153) tmp = Float64(Float64(t_0 * Float64(b * Float64(c / hypot(c, d)))) - Float64(Float64(d * a) / t_1)); else tmp = Float64(Float64(Float64(c * Float64(b / d)) - a) / d); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[d, -1.4e+72], N[(N[(N[(b / N[(d / c), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, -3.4e-134], N[(t$95$0 * N[(c * N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(a * (-d)), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 5.2e-42], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 7.2e+153], N[(N[(t$95$0 * N[(b * N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(d * a), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision], N[(N[(N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\mathsf{hypot}\left(c, d\right)}\\
t_1 := {\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}\\
\mathbf{if}\;d \leq -1.4 \cdot 10^{+72}:\\
\;\;\;\;\frac{\frac{b}{\frac{d}{c}} - a}{d}\\
\mathbf{elif}\;d \leq -3.4 \cdot 10^{-134}:\\
\;\;\;\;\mathsf{fma}\left(t\_0, c \cdot \frac{b}{\mathsf{hypot}\left(c, d\right)}, \frac{a \cdot \left(-d\right)}{t\_1}\right)\\
\mathbf{elif}\;d \leq 5.2 \cdot 10^{-42}:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\
\mathbf{elif}\;d \leq 7.2 \cdot 10^{+153}:\\
\;\;\;\;t\_0 \cdot \left(b \cdot \frac{c}{\mathsf{hypot}\left(c, d\right)}\right) - \frac{d \cdot a}{t\_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\
\end{array}
\end{array}
if d < -1.4e72Initial program 40.4%
fmm-def40.4%
distribute-rgt-neg-out40.4%
+-commutative40.4%
fma-define40.4%
Simplified40.4%
distribute-rgt-neg-out40.4%
fmm-def40.4%
fma-undefine40.4%
+-commutative40.4%
div-sub40.4%
*-un-lft-identity40.4%
add-sqr-sqrt40.4%
times-frac40.4%
fmm-def40.4%
hypot-define40.4%
hypot-define47.6%
associate-/l*52.4%
add-sqr-sqrt52.4%
Applied egg-rr52.4%
*-commutative52.4%
associate-/l*58.0%
associate-*r/51.3%
distribute-frac-neg51.3%
*-commutative51.3%
distribute-rgt-neg-in51.3%
Simplified51.3%
Taylor expanded in d around inf 80.1%
+-commutative80.1%
*-commutative80.1%
associate-*r/80.4%
mul-1-neg80.4%
unsub-neg80.4%
associate-*r/80.1%
*-commutative80.1%
associate-/l*80.4%
Simplified80.4%
clear-num80.4%
un-div-inv80.4%
Applied egg-rr80.4%
if -1.4e72 < d < -3.39999999999999977e-134Initial program 81.3%
fmm-def81.4%
distribute-rgt-neg-out81.4%
+-commutative81.4%
fma-define81.4%
Simplified81.4%
distribute-rgt-neg-out81.4%
fmm-def81.3%
fma-undefine81.3%
+-commutative81.3%
div-sub81.3%
*-un-lft-identity81.3%
add-sqr-sqrt81.3%
times-frac81.3%
fmm-def81.3%
hypot-define81.3%
hypot-define83.6%
associate-/l*86.6%
add-sqr-sqrt86.6%
Applied egg-rr86.6%
*-commutative86.6%
associate-/l*92.7%
associate-*r/89.7%
distribute-frac-neg89.7%
*-commutative89.7%
distribute-rgt-neg-in89.7%
Simplified89.7%
if -3.39999999999999977e-134 < d < 5.2e-42Initial program 73.5%
fmm-def73.5%
distribute-rgt-neg-out73.5%
+-commutative73.5%
fma-define73.5%
Simplified73.5%
Taylor expanded in c around inf 94.6%
associate-*r/94.6%
neg-mul-194.6%
distribute-rgt-neg-in94.6%
Simplified94.6%
if 5.2e-42 < d < 7.2000000000000001e153Initial program 75.1%
fmm-def75.1%
distribute-rgt-neg-out75.1%
+-commutative75.1%
fma-define75.1%
Simplified75.1%
distribute-rgt-neg-out75.1%
fmm-def75.1%
fma-undefine75.1%
+-commutative75.1%
div-sub75.1%
*-un-lft-identity75.1%
add-sqr-sqrt75.1%
times-frac75.0%
fmm-def75.0%
hypot-define75.1%
hypot-define79.4%
associate-/l*81.5%
add-sqr-sqrt81.5%
Applied egg-rr81.5%
fmm-undef81.5%
associate-/l*96.4%
associate-*r/94.3%
*-commutative94.3%
Simplified94.3%
if 7.2000000000000001e153 < d Initial program 35.8%
fmm-def35.8%
distribute-rgt-neg-out35.8%
+-commutative35.8%
fma-define35.8%
Simplified35.8%
Taylor expanded in d around -inf 89.6%
mul-1-neg89.6%
distribute-neg-frac289.6%
mul-1-neg89.6%
unsub-neg89.6%
*-commutative89.6%
associate-/l*94.9%
Simplified94.9%
Final simplification91.1%
(FPCore (a b c d)
:precision binary64
(let* ((t_0
(-
(* (/ 1.0 (hypot c d)) (* b (/ c (hypot c d))))
(/ (* d a) (pow (hypot c d) 2.0)))))
(if (<= d -1.25e+72)
(/ (- (/ b (/ d c)) a) d)
(if (<= d -3.1e-134)
t_0
(if (<= d 5.2e-42)
(/ (- b (/ (* d a) c)) c)
(if (<= d 5.8e+153) t_0 (/ (- (* c (/ b d)) a) d)))))))
double code(double a, double b, double c, double d) {
double t_0 = ((1.0 / hypot(c, d)) * (b * (c / hypot(c, d)))) - ((d * a) / pow(hypot(c, d), 2.0));
double tmp;
if (d <= -1.25e+72) {
tmp = ((b / (d / c)) - a) / d;
} else if (d <= -3.1e-134) {
tmp = t_0;
} else if (d <= 5.2e-42) {
tmp = (b - ((d * a) / c)) / c;
} else if (d <= 5.8e+153) {
tmp = t_0;
} else {
tmp = ((c * (b / d)) - a) / d;
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = ((1.0 / Math.hypot(c, d)) * (b * (c / Math.hypot(c, d)))) - ((d * a) / Math.pow(Math.hypot(c, d), 2.0));
double tmp;
if (d <= -1.25e+72) {
tmp = ((b / (d / c)) - a) / d;
} else if (d <= -3.1e-134) {
tmp = t_0;
} else if (d <= 5.2e-42) {
tmp = (b - ((d * a) / c)) / c;
} else if (d <= 5.8e+153) {
tmp = t_0;
} else {
tmp = ((c * (b / d)) - a) / d;
}
return tmp;
}
def code(a, b, c, d): t_0 = ((1.0 / math.hypot(c, d)) * (b * (c / math.hypot(c, d)))) - ((d * a) / math.pow(math.hypot(c, d), 2.0)) tmp = 0 if d <= -1.25e+72: tmp = ((b / (d / c)) - a) / d elif d <= -3.1e-134: tmp = t_0 elif d <= 5.2e-42: tmp = (b - ((d * a) / c)) / c elif d <= 5.8e+153: tmp = t_0 else: tmp = ((c * (b / d)) - a) / d return tmp
function code(a, b, c, d) t_0 = Float64(Float64(Float64(1.0 / hypot(c, d)) * Float64(b * Float64(c / hypot(c, d)))) - Float64(Float64(d * a) / (hypot(c, d) ^ 2.0))) tmp = 0.0 if (d <= -1.25e+72) tmp = Float64(Float64(Float64(b / Float64(d / c)) - a) / d); elseif (d <= -3.1e-134) tmp = t_0; elseif (d <= 5.2e-42) tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c); elseif (d <= 5.8e+153) tmp = t_0; else tmp = Float64(Float64(Float64(c * Float64(b / d)) - a) / d); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((1.0 / hypot(c, d)) * (b * (c / hypot(c, d)))) - ((d * a) / (hypot(c, d) ^ 2.0)); tmp = 0.0; if (d <= -1.25e+72) tmp = ((b / (d / c)) - a) / d; elseif (d <= -3.1e-134) tmp = t_0; elseif (d <= 5.2e-42) tmp = (b - ((d * a) / c)) / c; elseif (d <= 5.8e+153) tmp = t_0; else tmp = ((c * (b / d)) - a) / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b * N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(d * a), $MachinePrecision] / N[Power[N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -1.25e+72], N[(N[(N[(b / N[(d / c), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, -3.1e-134], t$95$0, If[LessEqual[d, 5.2e-42], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 5.8e+153], t$95$0, N[(N[(N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(b \cdot \frac{c}{\mathsf{hypot}\left(c, d\right)}\right) - \frac{d \cdot a}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\\
\mathbf{if}\;d \leq -1.25 \cdot 10^{+72}:\\
\;\;\;\;\frac{\frac{b}{\frac{d}{c}} - a}{d}\\
\mathbf{elif}\;d \leq -3.1 \cdot 10^{-134}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 5.2 \cdot 10^{-42}:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\
\mathbf{elif}\;d \leq 5.8 \cdot 10^{+153}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\
\end{array}
\end{array}
if d < -1.24999999999999998e72Initial program 40.4%
fmm-def40.4%
distribute-rgt-neg-out40.4%
+-commutative40.4%
fma-define40.4%
Simplified40.4%
distribute-rgt-neg-out40.4%
fmm-def40.4%
fma-undefine40.4%
+-commutative40.4%
div-sub40.4%
*-un-lft-identity40.4%
add-sqr-sqrt40.4%
times-frac40.4%
fmm-def40.4%
hypot-define40.4%
hypot-define47.6%
associate-/l*52.4%
add-sqr-sqrt52.4%
Applied egg-rr52.4%
*-commutative52.4%
associate-/l*58.0%
associate-*r/51.3%
distribute-frac-neg51.3%
*-commutative51.3%
distribute-rgt-neg-in51.3%
Simplified51.3%
Taylor expanded in d around inf 80.1%
+-commutative80.1%
*-commutative80.1%
associate-*r/80.4%
mul-1-neg80.4%
unsub-neg80.4%
associate-*r/80.1%
*-commutative80.1%
associate-/l*80.4%
Simplified80.4%
clear-num80.4%
un-div-inv80.4%
Applied egg-rr80.4%
if -1.24999999999999998e72 < d < -3.10000000000000006e-134 or 5.2e-42 < d < 5.80000000000000004e153Initial program 77.5%
fmm-def77.6%
distribute-rgt-neg-out77.6%
+-commutative77.6%
fma-define77.6%
Simplified77.6%
distribute-rgt-neg-out77.6%
fmm-def77.5%
fma-undefine77.5%
+-commutative77.5%
div-sub77.5%
*-un-lft-identity77.5%
add-sqr-sqrt77.5%
times-frac77.5%
fmm-def77.5%
hypot-define77.5%
hypot-define81.0%
associate-/l*83.5%
add-sqr-sqrt83.5%
Applied egg-rr83.5%
fmm-undef83.5%
associate-/l*94.9%
associate-*r/92.4%
*-commutative92.4%
Simplified92.4%
if -3.10000000000000006e-134 < d < 5.2e-42Initial program 73.5%
fmm-def73.5%
distribute-rgt-neg-out73.5%
+-commutative73.5%
fma-define73.5%
Simplified73.5%
Taylor expanded in c around inf 94.6%
associate-*r/94.6%
neg-mul-194.6%
distribute-rgt-neg-in94.6%
Simplified94.6%
if 5.80000000000000004e153 < d Initial program 35.8%
fmm-def35.8%
distribute-rgt-neg-out35.8%
+-commutative35.8%
fma-define35.8%
Simplified35.8%
Taylor expanded in d around -inf 89.6%
mul-1-neg89.6%
distribute-neg-frac289.6%
mul-1-neg89.6%
unsub-neg89.6%
*-commutative89.6%
associate-/l*94.9%
Simplified94.9%
Final simplification91.1%
(FPCore (a b c d)
:precision binary64
(if (<= d -2.1e+71)
(/ (- (/ b (/ d c)) a) d)
(if (<= d -8e-130)
(/ (fma b c (* a (- d))) (fma d d (* c c)))
(if (<= d 6.8e+14) (/ (- b (/ (* d a) c)) c) (/ (- (* c (/ b d)) a) d)))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -2.1e+71) {
tmp = ((b / (d / c)) - a) / d;
} else if (d <= -8e-130) {
tmp = fma(b, c, (a * -d)) / fma(d, d, (c * c));
} else if (d <= 6.8e+14) {
tmp = (b - ((d * a) / c)) / c;
} else {
tmp = ((c * (b / d)) - a) / d;
}
return tmp;
}
function code(a, b, c, d) tmp = 0.0 if (d <= -2.1e+71) tmp = Float64(Float64(Float64(b / Float64(d / c)) - a) / d); elseif (d <= -8e-130) tmp = Float64(fma(b, c, Float64(a * Float64(-d))) / fma(d, d, Float64(c * c))); elseif (d <= 6.8e+14) tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c); else tmp = Float64(Float64(Float64(c * Float64(b / d)) - a) / d); end return tmp end
code[a_, b_, c_, d_] := If[LessEqual[d, -2.1e+71], N[(N[(N[(b / N[(d / c), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, -8e-130], N[(N[(b * c + N[(a * (-d)), $MachinePrecision]), $MachinePrecision] / N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 6.8e+14], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], N[(N[(N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -2.1 \cdot 10^{+71}:\\
\;\;\;\;\frac{\frac{b}{\frac{d}{c}} - a}{d}\\
\mathbf{elif}\;d \leq -8 \cdot 10^{-130}:\\
\;\;\;\;\frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\
\mathbf{elif}\;d \leq 6.8 \cdot 10^{+14}:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\
\end{array}
\end{array}
if d < -2.09999999999999989e71Initial program 40.4%
fmm-def40.4%
distribute-rgt-neg-out40.4%
+-commutative40.4%
fma-define40.4%
Simplified40.4%
distribute-rgt-neg-out40.4%
fmm-def40.4%
fma-undefine40.4%
+-commutative40.4%
div-sub40.4%
*-un-lft-identity40.4%
add-sqr-sqrt40.4%
times-frac40.4%
fmm-def40.4%
hypot-define40.4%
hypot-define47.6%
associate-/l*52.4%
add-sqr-sqrt52.4%
Applied egg-rr52.4%
*-commutative52.4%
associate-/l*58.0%
associate-*r/51.3%
distribute-frac-neg51.3%
*-commutative51.3%
distribute-rgt-neg-in51.3%
Simplified51.3%
Taylor expanded in d around inf 80.1%
+-commutative80.1%
*-commutative80.1%
associate-*r/80.4%
mul-1-neg80.4%
unsub-neg80.4%
associate-*r/80.1%
*-commutative80.1%
associate-/l*80.4%
Simplified80.4%
clear-num80.4%
un-div-inv80.4%
Applied egg-rr80.4%
if -2.09999999999999989e71 < d < -8.0000000000000007e-130Initial program 81.3%
fmm-def81.4%
distribute-rgt-neg-out81.4%
+-commutative81.4%
fma-define81.4%
Simplified81.4%
if -8.0000000000000007e-130 < d < 6.8e14Initial program 71.9%
fmm-def71.9%
distribute-rgt-neg-out71.9%
+-commutative71.9%
fma-define71.9%
Simplified71.9%
Taylor expanded in c around inf 89.0%
associate-*r/89.0%
neg-mul-189.0%
distribute-rgt-neg-in89.0%
Simplified89.0%
if 6.8e14 < d Initial program 55.5%
fmm-def55.5%
distribute-rgt-neg-out55.5%
+-commutative55.5%
fma-define55.5%
Simplified55.5%
Taylor expanded in d around -inf 86.0%
mul-1-neg86.0%
distribute-neg-frac286.0%
mul-1-neg86.0%
unsub-neg86.0%
*-commutative86.0%
associate-/l*90.3%
Simplified90.3%
Final simplification86.7%
(FPCore (a b c d)
:precision binary64
(if (<= d -7.4e+71)
(/ (- (/ b (/ d c)) a) d)
(if (<= d -1.22e-132)
(/ (- (* b c) (* d a)) (+ (* c c) (* d d)))
(if (<= d 2.4e+20) (/ (- b (/ (* d a) c)) c) (/ (- (* c (/ b d)) a) d)))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -7.4e+71) {
tmp = ((b / (d / c)) - a) / d;
} else if (d <= -1.22e-132) {
tmp = ((b * c) - (d * a)) / ((c * c) + (d * d));
} else if (d <= 2.4e+20) {
tmp = (b - ((d * a) / c)) / c;
} else {
tmp = ((c * (b / d)) - 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 (d <= (-7.4d+71)) then
tmp = ((b / (d / c)) - a) / d
else if (d <= (-1.22d-132)) then
tmp = ((b * c) - (d * a)) / ((c * c) + (d * d))
else if (d <= 2.4d+20) then
tmp = (b - ((d * a) / c)) / c
else
tmp = ((c * (b / d)) - a) / d
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (d <= -7.4e+71) {
tmp = ((b / (d / c)) - a) / d;
} else if (d <= -1.22e-132) {
tmp = ((b * c) - (d * a)) / ((c * c) + (d * d));
} else if (d <= 2.4e+20) {
tmp = (b - ((d * a) / c)) / c;
} else {
tmp = ((c * (b / d)) - a) / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -7.4e+71: tmp = ((b / (d / c)) - a) / d elif d <= -1.22e-132: tmp = ((b * c) - (d * a)) / ((c * c) + (d * d)) elif d <= 2.4e+20: tmp = (b - ((d * a) / c)) / c else: tmp = ((c * (b / d)) - a) / d return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -7.4e+71) tmp = Float64(Float64(Float64(b / Float64(d / c)) - a) / d); elseif (d <= -1.22e-132) tmp = Float64(Float64(Float64(b * c) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d))); elseif (d <= 2.4e+20) tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c); else tmp = Float64(Float64(Float64(c * Float64(b / d)) - a) / d); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= -7.4e+71) tmp = ((b / (d / c)) - a) / d; elseif (d <= -1.22e-132) tmp = ((b * c) - (d * a)) / ((c * c) + (d * d)); elseif (d <= 2.4e+20) tmp = (b - ((d * a) / c)) / c; else tmp = ((c * (b / d)) - a) / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -7.4e+71], N[(N[(N[(b / N[(d / c), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, -1.22e-132], N[(N[(N[(b * c), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.4e+20], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], N[(N[(N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -7.4 \cdot 10^{+71}:\\
\;\;\;\;\frac{\frac{b}{\frac{d}{c}} - a}{d}\\
\mathbf{elif}\;d \leq -1.22 \cdot 10^{-132}:\\
\;\;\;\;\frac{b \cdot c - d \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;d \leq 2.4 \cdot 10^{+20}:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\
\end{array}
\end{array}
if d < -7.4e71Initial program 40.4%
fmm-def40.4%
distribute-rgt-neg-out40.4%
+-commutative40.4%
fma-define40.4%
Simplified40.4%
distribute-rgt-neg-out40.4%
fmm-def40.4%
fma-undefine40.4%
+-commutative40.4%
div-sub40.4%
*-un-lft-identity40.4%
add-sqr-sqrt40.4%
times-frac40.4%
fmm-def40.4%
hypot-define40.4%
hypot-define47.6%
associate-/l*52.4%
add-sqr-sqrt52.4%
Applied egg-rr52.4%
*-commutative52.4%
associate-/l*58.0%
associate-*r/51.3%
distribute-frac-neg51.3%
*-commutative51.3%
distribute-rgt-neg-in51.3%
Simplified51.3%
Taylor expanded in d around inf 80.1%
+-commutative80.1%
*-commutative80.1%
associate-*r/80.4%
mul-1-neg80.4%
unsub-neg80.4%
associate-*r/80.1%
*-commutative80.1%
associate-/l*80.4%
Simplified80.4%
clear-num80.4%
un-div-inv80.4%
Applied egg-rr80.4%
if -7.4e71 < d < -1.2200000000000001e-132Initial program 81.3%
if -1.2200000000000001e-132 < d < 2.4e20Initial program 71.9%
fmm-def71.9%
distribute-rgt-neg-out71.9%
+-commutative71.9%
fma-define71.9%
Simplified71.9%
Taylor expanded in c around inf 89.0%
associate-*r/89.0%
neg-mul-189.0%
distribute-rgt-neg-in89.0%
Simplified89.0%
if 2.4e20 < d Initial program 55.5%
fmm-def55.5%
distribute-rgt-neg-out55.5%
+-commutative55.5%
fma-define55.5%
Simplified55.5%
Taylor expanded in d around -inf 86.0%
mul-1-neg86.0%
distribute-neg-frac286.0%
mul-1-neg86.0%
unsub-neg86.0%
*-commutative86.0%
associate-/l*90.3%
Simplified90.3%
Final simplification86.7%
(FPCore (a b c d) :precision binary64 (if (or (<= d -4.5e+114) (not (<= d 6.2e+19))) (/ (- (* b (/ c d)) a) d) (/ (- b (* (/ d c) a)) c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -4.5e+114) || !(d <= 6.2e+19)) {
tmp = ((b * (c / d)) - a) / d;
} else {
tmp = (b - ((d / c) * a)) / c;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if ((d <= (-4.5d+114)) .or. (.not. (d <= 6.2d+19))) then
tmp = ((b * (c / d)) - a) / d
else
tmp = (b - ((d / c) * a)) / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -4.5e+114) || !(d <= 6.2e+19)) {
tmp = ((b * (c / d)) - a) / d;
} else {
tmp = (b - ((d / c) * a)) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -4.5e+114) or not (d <= 6.2e+19): tmp = ((b * (c / d)) - a) / d else: tmp = (b - ((d / c) * a)) / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -4.5e+114) || !(d <= 6.2e+19)) tmp = Float64(Float64(Float64(b * Float64(c / d)) - a) / d); else tmp = Float64(Float64(b - Float64(Float64(d / c) * a)) / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -4.5e+114) || ~((d <= 6.2e+19))) tmp = ((b * (c / d)) - a) / d; else tmp = (b - ((d / c) * a)) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -4.5e+114], N[Not[LessEqual[d, 6.2e+19]], $MachinePrecision]], N[(N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], N[(N[(b - N[(N[(d / c), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -4.5 \cdot 10^{+114} \lor \neg \left(d \leq 6.2 \cdot 10^{+19}\right):\\
\;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - \frac{d}{c} \cdot a}{c}\\
\end{array}
\end{array}
if d < -4.5000000000000001e114 or 6.2e19 < d Initial program 50.0%
fmm-def50.0%
distribute-rgt-neg-out50.0%
+-commutative50.0%
fma-define50.0%
Simplified50.0%
distribute-rgt-neg-out50.0%
fmm-def50.0%
fma-undefine50.0%
+-commutative50.0%
div-sub50.0%
*-un-lft-identity50.0%
add-sqr-sqrt50.0%
times-frac50.0%
fmm-def50.0%
hypot-define50.0%
hypot-define56.9%
associate-/l*59.5%
add-sqr-sqrt59.5%
Applied egg-rr59.5%
*-commutative59.5%
associate-/l*65.6%
associate-*r/62.9%
distribute-frac-neg62.9%
*-commutative62.9%
distribute-rgt-neg-in62.9%
Simplified62.9%
Taylor expanded in d around inf 85.8%
+-commutative85.8%
*-commutative85.8%
associate-*r/88.5%
mul-1-neg88.5%
unsub-neg88.5%
associate-*r/85.8%
*-commutative85.8%
associate-/l*87.2%
Simplified87.2%
if -4.5000000000000001e114 < d < 6.2e19Initial program 71.9%
fmm-def71.9%
distribute-rgt-neg-out71.9%
+-commutative71.9%
fma-define71.9%
Simplified71.9%
distribute-rgt-neg-out71.9%
fmm-def71.9%
fma-undefine71.9%
+-commutative71.9%
div-sub64.7%
*-un-lft-identity64.7%
add-sqr-sqrt64.7%
times-frac64.7%
fmm-def64.7%
hypot-define64.7%
hypot-define76.1%
associate-/l*77.7%
add-sqr-sqrt77.7%
Applied egg-rr77.7%
*-commutative77.7%
associate-/l*85.7%
associate-*r/83.5%
distribute-frac-neg83.5%
*-commutative83.5%
distribute-rgt-neg-in83.5%
Simplified83.5%
Taylor expanded in c around inf 80.7%
mul-1-neg80.7%
sub-neg80.7%
associate-/l*82.0%
Simplified82.0%
Final simplification84.2%
(FPCore (a b c d) :precision binary64 (if (or (<= d -3.1e+62) (not (<= d 1.6e+25))) (/ a (- d)) (/ (- b (* (/ d c) a)) c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -3.1e+62) || !(d <= 1.6e+25)) {
tmp = a / -d;
} else {
tmp = (b - ((d / c) * a)) / c;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if ((d <= (-3.1d+62)) .or. (.not. (d <= 1.6d+25))) then
tmp = a / -d
else
tmp = (b - ((d / c) * a)) / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -3.1e+62) || !(d <= 1.6e+25)) {
tmp = a / -d;
} else {
tmp = (b - ((d / c) * a)) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -3.1e+62) or not (d <= 1.6e+25): tmp = a / -d else: tmp = (b - ((d / c) * a)) / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -3.1e+62) || !(d <= 1.6e+25)) tmp = Float64(a / Float64(-d)); else tmp = Float64(Float64(b - Float64(Float64(d / c) * a)) / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -3.1e+62) || ~((d <= 1.6e+25))) tmp = a / -d; else tmp = (b - ((d / c) * a)) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -3.1e+62], N[Not[LessEqual[d, 1.6e+25]], $MachinePrecision]], N[(a / (-d)), $MachinePrecision], N[(N[(b - N[(N[(d / c), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -3.1 \cdot 10^{+62} \lor \neg \left(d \leq 1.6 \cdot 10^{+25}\right):\\
\;\;\;\;\frac{a}{-d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - \frac{d}{c} \cdot a}{c}\\
\end{array}
\end{array}
if d < -3.10000000000000014e62 or 1.6e25 < d Initial program 49.3%
fmm-def49.3%
distribute-rgt-neg-out49.3%
+-commutative49.3%
fma-define49.3%
Simplified49.3%
Taylor expanded in c around 0 74.5%
associate-*r/74.5%
neg-mul-174.5%
Simplified74.5%
if -3.10000000000000014e62 < d < 1.6e25Initial program 73.8%
fmm-def73.8%
distribute-rgt-neg-out73.8%
+-commutative73.8%
fma-define73.8%
Simplified73.8%
distribute-rgt-neg-out73.8%
fmm-def73.8%
fma-undefine73.8%
+-commutative73.8%
div-sub66.2%
*-un-lft-identity66.2%
add-sqr-sqrt66.2%
times-frac66.2%
fmm-def66.2%
hypot-define66.2%
hypot-define78.3%
associate-/l*79.2%
add-sqr-sqrt79.2%
Applied egg-rr79.2%
*-commutative79.2%
associate-/l*87.0%
associate-*r/86.1%
distribute-frac-neg86.1%
*-commutative86.1%
distribute-rgt-neg-in86.1%
Simplified86.1%
Taylor expanded in c around inf 83.8%
mul-1-neg83.8%
sub-neg83.8%
associate-/l*83.7%
Simplified83.7%
Final simplification79.5%
(FPCore (a b c d) :precision binary64 (if (<= d -2.7e+61) (/ (- (/ b (/ d c)) a) d) (if (<= d 5.5e+16) (/ (- b (/ (* d a) c)) c) (/ (- (* c (/ b d)) a) d))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -2.7e+61) {
tmp = ((b / (d / c)) - a) / d;
} else if (d <= 5.5e+16) {
tmp = (b - ((d * a) / c)) / c;
} else {
tmp = ((c * (b / d)) - 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 (d <= (-2.7d+61)) then
tmp = ((b / (d / c)) - a) / d
else if (d <= 5.5d+16) then
tmp = (b - ((d * a) / c)) / c
else
tmp = ((c * (b / d)) - a) / d
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (d <= -2.7e+61) {
tmp = ((b / (d / c)) - a) / d;
} else if (d <= 5.5e+16) {
tmp = (b - ((d * a) / c)) / c;
} else {
tmp = ((c * (b / d)) - a) / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -2.7e+61: tmp = ((b / (d / c)) - a) / d elif d <= 5.5e+16: tmp = (b - ((d * a) / c)) / c else: tmp = ((c * (b / d)) - a) / d return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -2.7e+61) tmp = Float64(Float64(Float64(b / Float64(d / c)) - a) / d); elseif (d <= 5.5e+16) tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c); else tmp = Float64(Float64(Float64(c * Float64(b / d)) - a) / d); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= -2.7e+61) tmp = ((b / (d / c)) - a) / d; elseif (d <= 5.5e+16) tmp = (b - ((d * a) / c)) / c; else tmp = ((c * (b / d)) - a) / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -2.7e+61], N[(N[(N[(b / N[(d / c), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, 5.5e+16], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], N[(N[(N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -2.7 \cdot 10^{+61}:\\
\;\;\;\;\frac{\frac{b}{\frac{d}{c}} - a}{d}\\
\mathbf{elif}\;d \leq 5.5 \cdot 10^{+16}:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\
\end{array}
\end{array}
if d < -2.7000000000000002e61Initial program 41.5%
fmm-def41.5%
distribute-rgt-neg-out41.5%
+-commutative41.5%
fma-define41.5%
Simplified41.5%
distribute-rgt-neg-out41.5%
fmm-def41.5%
fma-undefine41.5%
+-commutative41.5%
div-sub41.5%
*-un-lft-identity41.5%
add-sqr-sqrt41.5%
times-frac41.5%
fmm-def41.5%
hypot-define41.5%
hypot-define48.6%
associate-/l*53.3%
add-sqr-sqrt53.3%
Applied egg-rr53.3%
*-commutative53.3%
associate-/l*58.7%
associate-*r/52.2%
distribute-frac-neg52.2%
*-commutative52.2%
distribute-rgt-neg-in52.2%
Simplified52.2%
Taylor expanded in d around inf 80.5%
+-commutative80.5%
*-commutative80.5%
associate-*r/80.8%
mul-1-neg80.8%
unsub-neg80.8%
associate-*r/80.5%
*-commutative80.5%
associate-/l*80.8%
Simplified80.8%
clear-num80.8%
un-div-inv80.8%
Applied egg-rr80.8%
if -2.7000000000000002e61 < d < 5.5e16Initial program 73.8%
fmm-def73.8%
distribute-rgt-neg-out73.8%
+-commutative73.8%
fma-define73.8%
Simplified73.8%
Taylor expanded in c around inf 83.8%
associate-*r/83.8%
neg-mul-183.8%
distribute-rgt-neg-in83.8%
Simplified83.8%
if 5.5e16 < d Initial program 55.5%
fmm-def55.5%
distribute-rgt-neg-out55.5%
+-commutative55.5%
fma-define55.5%
Simplified55.5%
Taylor expanded in d around -inf 86.0%
mul-1-neg86.0%
distribute-neg-frac286.0%
mul-1-neg86.0%
unsub-neg86.0%
*-commutative86.0%
associate-/l*90.3%
Simplified90.3%
Final simplification84.8%
(FPCore (a b c d) :precision binary64 (if (<= d -2.7e+61) (/ (- (/ b (/ d c)) a) d) (if (<= d 4.3e+14) (/ (- b (/ (* d a) c)) c) (/ (- (* b (/ c d)) a) d))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -2.7e+61) {
tmp = ((b / (d / c)) - a) / d;
} else if (d <= 4.3e+14) {
tmp = (b - ((d * a) / c)) / c;
} else {
tmp = ((b * (c / d)) - 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 (d <= (-2.7d+61)) then
tmp = ((b / (d / c)) - a) / d
else if (d <= 4.3d+14) then
tmp = (b - ((d * a) / c)) / c
else
tmp = ((b * (c / d)) - a) / d
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (d <= -2.7e+61) {
tmp = ((b / (d / c)) - a) / d;
} else if (d <= 4.3e+14) {
tmp = (b - ((d * a) / c)) / c;
} else {
tmp = ((b * (c / d)) - a) / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -2.7e+61: tmp = ((b / (d / c)) - a) / d elif d <= 4.3e+14: tmp = (b - ((d * a) / c)) / c else: tmp = ((b * (c / d)) - a) / d return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -2.7e+61) tmp = Float64(Float64(Float64(b / Float64(d / c)) - a) / d); elseif (d <= 4.3e+14) tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c); else tmp = Float64(Float64(Float64(b * Float64(c / d)) - a) / d); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= -2.7e+61) tmp = ((b / (d / c)) - a) / d; elseif (d <= 4.3e+14) tmp = (b - ((d * a) / c)) / c; else tmp = ((b * (c / d)) - a) / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -2.7e+61], N[(N[(N[(b / N[(d / c), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, 4.3e+14], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], N[(N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -2.7 \cdot 10^{+61}:\\
\;\;\;\;\frac{\frac{b}{\frac{d}{c}} - a}{d}\\
\mathbf{elif}\;d \leq 4.3 \cdot 10^{+14}:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\
\end{array}
\end{array}
if d < -2.7000000000000002e61Initial program 41.5%
fmm-def41.5%
distribute-rgt-neg-out41.5%
+-commutative41.5%
fma-define41.5%
Simplified41.5%
distribute-rgt-neg-out41.5%
fmm-def41.5%
fma-undefine41.5%
+-commutative41.5%
div-sub41.5%
*-un-lft-identity41.5%
add-sqr-sqrt41.5%
times-frac41.5%
fmm-def41.5%
hypot-define41.5%
hypot-define48.6%
associate-/l*53.3%
add-sqr-sqrt53.3%
Applied egg-rr53.3%
*-commutative53.3%
associate-/l*58.7%
associate-*r/52.2%
distribute-frac-neg52.2%
*-commutative52.2%
distribute-rgt-neg-in52.2%
Simplified52.2%
Taylor expanded in d around inf 80.5%
+-commutative80.5%
*-commutative80.5%
associate-*r/80.8%
mul-1-neg80.8%
unsub-neg80.8%
associate-*r/80.5%
*-commutative80.5%
associate-/l*80.8%
Simplified80.8%
clear-num80.8%
un-div-inv80.8%
Applied egg-rr80.8%
if -2.7000000000000002e61 < d < 4.3e14Initial program 73.8%
fmm-def73.8%
distribute-rgt-neg-out73.8%
+-commutative73.8%
fma-define73.8%
Simplified73.8%
Taylor expanded in c around inf 83.8%
associate-*r/83.8%
neg-mul-183.8%
distribute-rgt-neg-in83.8%
Simplified83.8%
if 4.3e14 < d Initial program 55.5%
fmm-def55.5%
distribute-rgt-neg-out55.5%
+-commutative55.5%
fma-define55.5%
Simplified55.5%
distribute-rgt-neg-out55.5%
fmm-def55.5%
fma-undefine55.5%
+-commutative55.5%
div-sub55.5%
*-un-lft-identity55.5%
add-sqr-sqrt55.5%
times-frac55.5%
fmm-def55.5%
hypot-define55.5%
hypot-define61.4%
associate-/l*63.6%
add-sqr-sqrt63.6%
Applied egg-rr63.6%
*-commutative63.6%
associate-/l*70.9%
associate-*r/68.7%
distribute-frac-neg68.7%
*-commutative68.7%
distribute-rgt-neg-in68.7%
Simplified68.7%
Taylor expanded in d around inf 86.0%
+-commutative86.0%
*-commutative86.0%
associate-*r/90.3%
mul-1-neg90.3%
unsub-neg90.3%
associate-*r/86.0%
*-commutative86.0%
associate-/l*88.1%
Simplified88.1%
Final simplification84.3%
(FPCore (a b c d) :precision binary64 (if (<= d -6e+114) (/ (- (/ b (/ d c)) a) d) (if (<= d 1.9e+15) (/ (- b (* (/ d c) a)) c) (/ (- (* b (/ c d)) a) d))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -6e+114) {
tmp = ((b / (d / c)) - a) / d;
} else if (d <= 1.9e+15) {
tmp = (b - ((d / c) * a)) / c;
} else {
tmp = ((b * (c / d)) - 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 (d <= (-6d+114)) then
tmp = ((b / (d / c)) - a) / d
else if (d <= 1.9d+15) then
tmp = (b - ((d / c) * a)) / c
else
tmp = ((b * (c / d)) - a) / d
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (d <= -6e+114) {
tmp = ((b / (d / c)) - a) / d;
} else if (d <= 1.9e+15) {
tmp = (b - ((d / c) * a)) / c;
} else {
tmp = ((b * (c / d)) - a) / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -6e+114: tmp = ((b / (d / c)) - a) / d elif d <= 1.9e+15: tmp = (b - ((d / c) * a)) / c else: tmp = ((b * (c / d)) - a) / d return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -6e+114) tmp = Float64(Float64(Float64(b / Float64(d / c)) - a) / d); elseif (d <= 1.9e+15) tmp = Float64(Float64(b - Float64(Float64(d / c) * a)) / c); else tmp = Float64(Float64(Float64(b * Float64(c / d)) - a) / d); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= -6e+114) tmp = ((b / (d / c)) - a) / d; elseif (d <= 1.9e+15) tmp = (b - ((d / c) * a)) / c; else tmp = ((b * (c / d)) - a) / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -6e+114], N[(N[(N[(b / N[(d / c), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, 1.9e+15], N[(N[(b - N[(N[(d / c), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], N[(N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -6 \cdot 10^{+114}:\\
\;\;\;\;\frac{\frac{b}{\frac{d}{c}} - a}{d}\\
\mathbf{elif}\;d \leq 1.9 \cdot 10^{+15}:\\
\;\;\;\;\frac{b - \frac{d}{c} \cdot a}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\
\end{array}
\end{array}
if d < -6.0000000000000001e114Initial program 42.0%
fmm-def42.0%
distribute-rgt-neg-out42.0%
+-commutative42.0%
fma-define42.0%
Simplified42.0%
distribute-rgt-neg-out42.0%
fmm-def42.0%
fma-undefine42.0%
+-commutative42.0%
div-sub42.0%
*-un-lft-identity42.0%
add-sqr-sqrt42.0%
times-frac42.0%
fmm-def42.0%
hypot-define42.0%
hypot-define50.2%
associate-/l*53.6%
add-sqr-sqrt53.6%
Applied egg-rr53.6%
*-commutative53.6%
associate-/l*57.9%
associate-*r/54.5%
distribute-frac-neg54.5%
*-commutative54.5%
distribute-rgt-neg-in54.5%
Simplified54.5%
Taylor expanded in d around inf 85.6%
+-commutative85.6%
*-commutative85.6%
associate-*r/85.9%
mul-1-neg85.9%
unsub-neg85.9%
associate-*r/85.6%
*-commutative85.6%
associate-/l*85.9%
Simplified85.9%
clear-num85.9%
un-div-inv85.9%
Applied egg-rr85.9%
if -6.0000000000000001e114 < d < 1.9e15Initial program 71.9%
fmm-def71.9%
distribute-rgt-neg-out71.9%
+-commutative71.9%
fma-define71.9%
Simplified71.9%
distribute-rgt-neg-out71.9%
fmm-def71.9%
fma-undefine71.9%
+-commutative71.9%
div-sub64.7%
*-un-lft-identity64.7%
add-sqr-sqrt64.7%
times-frac64.7%
fmm-def64.7%
hypot-define64.7%
hypot-define76.1%
associate-/l*77.7%
add-sqr-sqrt77.7%
Applied egg-rr77.7%
*-commutative77.7%
associate-/l*85.7%
associate-*r/83.5%
distribute-frac-neg83.5%
*-commutative83.5%
distribute-rgt-neg-in83.5%
Simplified83.5%
Taylor expanded in c around inf 80.7%
mul-1-neg80.7%
sub-neg80.7%
associate-/l*82.0%
Simplified82.0%
if 1.9e15 < d Initial program 55.5%
fmm-def55.5%
distribute-rgt-neg-out55.5%
+-commutative55.5%
fma-define55.5%
Simplified55.5%
distribute-rgt-neg-out55.5%
fmm-def55.5%
fma-undefine55.5%
+-commutative55.5%
div-sub55.5%
*-un-lft-identity55.5%
add-sqr-sqrt55.5%
times-frac55.5%
fmm-def55.5%
hypot-define55.5%
hypot-define61.4%
associate-/l*63.6%
add-sqr-sqrt63.6%
Applied egg-rr63.6%
*-commutative63.6%
associate-/l*70.9%
associate-*r/68.7%
distribute-frac-neg68.7%
*-commutative68.7%
distribute-rgt-neg-in68.7%
Simplified68.7%
Taylor expanded in d around inf 86.0%
+-commutative86.0%
*-commutative86.0%
associate-*r/90.3%
mul-1-neg90.3%
unsub-neg90.3%
associate-*r/86.0%
*-commutative86.0%
associate-/l*88.1%
Simplified88.1%
Final simplification84.2%
(FPCore (a b c d) :precision binary64 (if (or (<= d -2.25e-63) (not (<= d 2.35e+20))) (/ a (- d)) (/ b c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -2.25e-63) || !(d <= 2.35e+20)) {
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.25d-63)) .or. (.not. (d <= 2.35d+20))) 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.25e-63) || !(d <= 2.35e+20)) {
tmp = a / -d;
} else {
tmp = b / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -2.25e-63) or not (d <= 2.35e+20): tmp = a / -d else: tmp = b / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -2.25e-63) || !(d <= 2.35e+20)) tmp = Float64(a / Float64(-d)); else tmp = Float64(b / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -2.25e-63) || ~((d <= 2.35e+20))) tmp = a / -d; else tmp = b / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -2.25e-63], N[Not[LessEqual[d, 2.35e+20]], $MachinePrecision]], N[(a / (-d)), $MachinePrecision], N[(b / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -2.25 \cdot 10^{-63} \lor \neg \left(d \leq 2.35 \cdot 10^{+20}\right):\\
\;\;\;\;\frac{a}{-d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if d < -2.25e-63 or 2.35e20 < d Initial program 53.5%
fmm-def53.5%
distribute-rgt-neg-out53.5%
+-commutative53.5%
fma-define53.5%
Simplified53.5%
Taylor expanded in c around 0 68.0%
associate-*r/68.0%
neg-mul-168.0%
Simplified68.0%
if -2.25e-63 < d < 2.35e20Initial program 73.2%
fmm-def73.2%
distribute-rgt-neg-out73.2%
+-commutative73.2%
fma-define73.2%
Simplified73.2%
Taylor expanded in c around inf 70.4%
Final simplification69.1%
(FPCore (a b c d) :precision binary64 (if (or (<= d -1.85e+212) (not (<= d 7e+75))) (/ a d) (/ b c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -1.85e+212) || !(d <= 7e+75)) {
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 <= (-1.85d+212)) .or. (.not. (d <= 7d+75))) 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 <= -1.85e+212) || !(d <= 7e+75)) {
tmp = a / d;
} else {
tmp = b / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -1.85e+212) or not (d <= 7e+75): tmp = a / d else: tmp = b / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -1.85e+212) || !(d <= 7e+75)) 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 <= -1.85e+212) || ~((d <= 7e+75))) tmp = a / d; else tmp = b / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -1.85e+212], N[Not[LessEqual[d, 7e+75]], $MachinePrecision]], N[(a / d), $MachinePrecision], N[(b / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.85 \cdot 10^{+212} \lor \neg \left(d \leq 7 \cdot 10^{+75}\right):\\
\;\;\;\;\frac{a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if d < -1.8499999999999998e212 or 6.9999999999999997e75 < d Initial program 47.3%
fmm-def47.3%
distribute-rgt-neg-out47.3%
+-commutative47.3%
fma-define47.3%
Simplified47.3%
Taylor expanded in c around 0 78.0%
associate-*r/78.0%
neg-mul-178.0%
Simplified78.0%
add-sqr-sqrt37.7%
sqrt-unprod48.1%
sqr-neg48.1%
sqrt-unprod17.7%
add-sqr-sqrt34.5%
*-un-lft-identity34.5%
Applied egg-rr34.5%
*-lft-identity34.5%
Simplified34.5%
if -1.8499999999999998e212 < d < 6.9999999999999997e75Initial program 68.9%
fmm-def69.0%
distribute-rgt-neg-out69.0%
+-commutative69.0%
fma-define69.0%
Simplified69.0%
Taylor expanded in c around inf 53.8%
Final simplification48.0%
(FPCore (a b c d) :precision binary64 (/ a d))
double code(double a, double b, double c, double d) {
return a / 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 = a / d
end function
public static double code(double a, double b, double c, double d) {
return a / d;
}
def code(a, b, c, d): return a / d
function code(a, b, c, d) return Float64(a / d) end
function tmp = code(a, b, c, d) tmp = a / d; end
code[a_, b_, c_, d_] := N[(a / d), $MachinePrecision]
\begin{array}{l}
\\
\frac{a}{d}
\end{array}
Initial program 62.4%
fmm-def62.4%
distribute-rgt-neg-out62.4%
+-commutative62.4%
fma-define62.4%
Simplified62.4%
Taylor expanded in c around 0 43.1%
associate-*r/43.1%
neg-mul-143.1%
Simplified43.1%
add-sqr-sqrt18.9%
sqrt-unprod22.9%
sqr-neg22.9%
sqrt-unprod7.3%
add-sqr-sqrt13.6%
*-un-lft-identity13.6%
Applied egg-rr13.6%
*-lft-identity13.6%
Simplified13.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 2024169
(FPCore (a b c d)
:name "Complex division, imag part"
:precision binary64
:alt
(! :herbie-platform default (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))))