
(FPCore (a b c d) :precision binary64 (/ (- (* b c) (* a d)) (+ (* c c) (* d d))))
double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = ((b * c) - (a * d)) / ((c * c) + (d * d))
end function
public static double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
def code(a, b, c, d): return ((b * c) - (a * d)) / ((c * c) + (d * d))
function code(a, b, c, d) return Float64(Float64(Float64(b * c) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d))) end
function tmp = code(a, b, c, d) tmp = ((b * c) - (a * d)) / ((c * c) + (d * d)); end
code[a_, b_, c_, d_] := N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 14 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b c d) :precision binary64 (/ (- (* b c) (* a d)) (+ (* c c) (* d d))))
double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = ((b * c) - (a * d)) / ((c * c) + (d * d))
end function
public static double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
def code(a, b, c, d): return ((b * c) - (a * d)) / ((c * c) + (d * d))
function code(a, b, c, d) return Float64(Float64(Float64(b * c) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d))) end
function tmp = code(a, b, c, d) tmp = ((b * c) - (a * d)) / ((c * c) + (d * d)); end
code[a_, b_, c_, d_] := N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}
\end{array}
(FPCore (a b c d) :precision binary64 (fma (/ c (hypot c d)) (/ b (hypot c d)) (* (/ d (hypot d c)) (/ (- a) (hypot d c)))))
double code(double a, double b, double c, double d) {
return fma((c / hypot(c, d)), (b / hypot(c, d)), ((d / hypot(d, c)) * (-a / hypot(d, c))));
}
function code(a, b, c, d) return fma(Float64(c / hypot(c, d)), Float64(b / hypot(c, d)), Float64(Float64(d / hypot(d, c)) * Float64(Float64(-a) / hypot(d, c)))) 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[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision] * N[((-a) / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, \frac{d}{\mathsf{hypot}\left(d, c\right)} \cdot \frac{-a}{\mathsf{hypot}\left(d, c\right)}\right)
\end{array}
Initial program 61.8%
fma-define61.8%
Simplified61.8%
fma-define61.8%
div-sub58.6%
*-commutative58.6%
fma-define58.6%
add-sqr-sqrt58.6%
times-frac60.8%
fma-neg60.8%
fma-define60.8%
hypot-define60.8%
fma-define60.8%
hypot-define76.4%
fma-define76.4%
add-sqr-sqrt76.3%
pow276.3%
Applied egg-rr76.3%
add-sqr-sqrt57.7%
sqrt-unprod61.5%
sqr-neg61.5%
sqrt-unprod47.7%
add-sqr-sqrt54.1%
distribute-neg-frac54.1%
distribute-rgt-neg-out54.1%
*-un-lft-identity54.1%
unpow254.1%
times-frac58.2%
*-commutative58.2%
add-sqr-sqrt27.4%
sqrt-unprod61.0%
sqr-neg61.0%
sqrt-prod46.4%
add-sqr-sqrt87.3%
Applied egg-rr87.3%
associate-*l/87.4%
*-lft-identity87.4%
associate-/l*97.3%
associate-*l/96.7%
hypot-undefine78.5%
unpow278.5%
unpow278.5%
+-commutative78.5%
unpow278.5%
unpow278.5%
hypot-define96.7%
hypot-undefine78.5%
unpow278.5%
unpow278.5%
+-commutative78.5%
unpow278.5%
unpow278.5%
hypot-define96.7%
Simplified96.7%
Final simplification96.7%
(FPCore (a b c d)
:precision binary64
(let* ((t_0
(fma
(/ c (hypot c d))
(/ b (hypot c d))
(/ (* d (- a)) (pow (hypot c d) 2.0))))
(t_1 (/ (- (* b (/ c d)) a) d)))
(if (<= d -9e+118)
t_1
(if (<= d -1.45e-112)
t_0
(if (<= d 4.8e-194)
(/ (- b (/ (* d a) c)) c)
(if (<= d 4.8e+117) t_0 t_1))))))
double code(double a, double b, double c, double d) {
double t_0 = fma((c / hypot(c, d)), (b / hypot(c, d)), ((d * -a) / pow(hypot(c, d), 2.0)));
double t_1 = ((b * (c / d)) - a) / d;
double tmp;
if (d <= -9e+118) {
tmp = t_1;
} else if (d <= -1.45e-112) {
tmp = t_0;
} else if (d <= 4.8e-194) {
tmp = (b - ((d * a) / c)) / c;
} else if (d <= 4.8e+117) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
function code(a, b, c, d) t_0 = fma(Float64(c / hypot(c, d)), Float64(b / hypot(c, d)), Float64(Float64(d * Float64(-a)) / (hypot(c, d) ^ 2.0))) t_1 = Float64(Float64(Float64(b * Float64(c / d)) - a) / d) tmp = 0.0 if (d <= -9e+118) tmp = t_1; elseif (d <= -1.45e-112) tmp = t_0; elseif (d <= 4.8e-194) tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c); elseif (d <= 4.8e+117) tmp = t_0; else tmp = t_1; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] + N[(N[(d * (-a)), $MachinePrecision] / N[Power[N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -9e+118], t$95$1, If[LessEqual[d, -1.45e-112], t$95$0, If[LessEqual[d, 4.8e-194], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 4.8e+117], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, \frac{d \cdot \left(-a\right)}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\right)\\
t_1 := \frac{b \cdot \frac{c}{d} - a}{d}\\
\mathbf{if}\;d \leq -9 \cdot 10^{+118}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d \leq -1.45 \cdot 10^{-112}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 4.8 \cdot 10^{-194}:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\
\mathbf{elif}\;d \leq 4.8 \cdot 10^{+117}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if d < -9.00000000000000004e118 or 4.7999999999999998e117 < d Initial program 36.2%
fma-define36.2%
Simplified36.2%
Taylor expanded in c around 0 78.3%
+-commutative78.3%
mul-1-neg78.3%
unsub-neg78.3%
unpow278.3%
associate-/r*84.4%
div-sub84.4%
associate-/l*89.0%
Simplified89.0%
if -9.00000000000000004e118 < d < -1.44999999999999996e-112 or 4.8e-194 < d < 4.7999999999999998e117Initial program 76.5%
fma-define76.5%
Simplified76.5%
fma-define76.5%
div-sub76.5%
*-commutative76.5%
fma-define76.5%
add-sqr-sqrt76.5%
times-frac78.6%
fma-neg78.6%
fma-define78.6%
hypot-define78.6%
fma-define78.6%
hypot-define94.1%
fma-define94.1%
add-sqr-sqrt94.1%
pow294.1%
Applied egg-rr94.1%
if -1.44999999999999996e-112 < d < 4.8e-194Initial program 62.5%
fma-define62.5%
Simplified62.5%
Taylor expanded in c around inf 91.7%
associate-*r/91.7%
neg-mul-191.7%
distribute-rgt-neg-in91.7%
Simplified91.7%
Final simplification92.1%
(FPCore (a b c d)
:precision binary64
(let* ((t_0
(-
(* (/ 1.0 (hypot d c)) (* c (/ b (hypot d c))))
(/ (* d a) (pow (hypot d c) 2.0))))
(t_1 (/ (- (* b (/ c d)) a) d)))
(if (<= d -6.5e+113)
t_1
(if (<= d -1.45e-112)
t_0
(if (<= d 3.5e-164)
(/ (- b (/ (* d a) c)) c)
(if (<= d 5.2e+119) t_0 t_1))))))
double code(double a, double b, double c, double d) {
double t_0 = ((1.0 / hypot(d, c)) * (c * (b / hypot(d, c)))) - ((d * a) / pow(hypot(d, c), 2.0));
double t_1 = ((b * (c / d)) - a) / d;
double tmp;
if (d <= -6.5e+113) {
tmp = t_1;
} else if (d <= -1.45e-112) {
tmp = t_0;
} else if (d <= 3.5e-164) {
tmp = (b - ((d * a) / c)) / c;
} else if (d <= 5.2e+119) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = ((1.0 / Math.hypot(d, c)) * (c * (b / Math.hypot(d, c)))) - ((d * a) / Math.pow(Math.hypot(d, c), 2.0));
double t_1 = ((b * (c / d)) - a) / d;
double tmp;
if (d <= -6.5e+113) {
tmp = t_1;
} else if (d <= -1.45e-112) {
tmp = t_0;
} else if (d <= 3.5e-164) {
tmp = (b - ((d * a) / c)) / c;
} else if (d <= 5.2e+119) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(a, b, c, d): t_0 = ((1.0 / math.hypot(d, c)) * (c * (b / math.hypot(d, c)))) - ((d * a) / math.pow(math.hypot(d, c), 2.0)) t_1 = ((b * (c / d)) - a) / d tmp = 0 if d <= -6.5e+113: tmp = t_1 elif d <= -1.45e-112: tmp = t_0 elif d <= 3.5e-164: tmp = (b - ((d * a) / c)) / c elif d <= 5.2e+119: tmp = t_0 else: tmp = t_1 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(Float64(1.0 / hypot(d, c)) * Float64(c * Float64(b / hypot(d, c)))) - Float64(Float64(d * a) / (hypot(d, c) ^ 2.0))) t_1 = Float64(Float64(Float64(b * Float64(c / d)) - a) / d) tmp = 0.0 if (d <= -6.5e+113) tmp = t_1; elseif (d <= -1.45e-112) tmp = t_0; elseif (d <= 3.5e-164) tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c); elseif (d <= 5.2e+119) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((1.0 / hypot(d, c)) * (c * (b / hypot(d, c)))) - ((d * a) / (hypot(d, c) ^ 2.0)); t_1 = ((b * (c / d)) - a) / d; tmp = 0.0; if (d <= -6.5e+113) tmp = t_1; elseif (d <= -1.45e-112) tmp = t_0; elseif (d <= 3.5e-164) tmp = (b - ((d * a) / c)) / c; elseif (d <= 5.2e+119) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(1.0 / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision] * N[(c * N[(b / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(d * a), $MachinePrecision] / N[Power[N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -6.5e+113], t$95$1, If[LessEqual[d, -1.45e-112], t$95$0, If[LessEqual[d, 3.5e-164], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 5.2e+119], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\mathsf{hypot}\left(d, c\right)} \cdot \left(c \cdot \frac{b}{\mathsf{hypot}\left(d, c\right)}\right) - \frac{d \cdot a}{{\left(\mathsf{hypot}\left(d, c\right)\right)}^{2}}\\
t_1 := \frac{b \cdot \frac{c}{d} - a}{d}\\
\mathbf{if}\;d \leq -6.5 \cdot 10^{+113}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d \leq -1.45 \cdot 10^{-112}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 3.5 \cdot 10^{-164}:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\
\mathbf{elif}\;d \leq 5.2 \cdot 10^{+119}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if d < -6.5000000000000001e113 or 5.2e119 < d Initial program 36.2%
fma-define36.2%
Simplified36.2%
Taylor expanded in c around 0 78.3%
+-commutative78.3%
mul-1-neg78.3%
unsub-neg78.3%
unpow278.3%
associate-/r*84.4%
div-sub84.4%
associate-/l*89.0%
Simplified89.0%
if -6.5000000000000001e113 < d < -1.44999999999999996e-112 or 3.5e-164 < d < 5.2e119Initial program 77.7%
fma-define77.7%
Simplified77.7%
fma-define77.7%
div-sub77.7%
*-un-lft-identity77.7%
fma-define77.7%
add-sqr-sqrt77.7%
times-frac77.7%
fma-neg77.7%
fma-define77.7%
hypot-define77.7%
fma-define77.7%
hypot-define84.7%
fma-define84.8%
add-sqr-sqrt84.7%
pow284.7%
Applied egg-rr84.7%
fma-undefine84.7%
unsub-neg84.7%
Simplified94.4%
if -1.44999999999999996e-112 < d < 3.5e-164Initial program 62.1%
fma-define62.1%
Simplified62.1%
Taylor expanded in c around inf 91.2%
associate-*r/91.2%
neg-mul-191.2%
distribute-rgt-neg-in91.2%
Simplified91.2%
Final simplification92.0%
(FPCore (a b c d)
:precision binary64
(if (<= c -1.95e+87)
(/ (- b (/ (* d a) c)) c)
(if (<= c -8.8e-162)
(/ (fma b c (* d (- a))) (fma d d (* c c)))
(if (<= c 1e+31)
(/ (- (* b (/ c d)) a) d)
(fma
1.0
(/ b (hypot c d))
(* (/ d (hypot d c)) (/ (- a) (hypot d c))))))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -1.95e+87) {
tmp = (b - ((d * a) / c)) / c;
} else if (c <= -8.8e-162) {
tmp = fma(b, c, (d * -a)) / fma(d, d, (c * c));
} else if (c <= 1e+31) {
tmp = ((b * (c / d)) - a) / d;
} else {
tmp = fma(1.0, (b / hypot(c, d)), ((d / hypot(d, c)) * (-a / hypot(d, c))));
}
return tmp;
}
function code(a, b, c, d) tmp = 0.0 if (c <= -1.95e+87) tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c); elseif (c <= -8.8e-162) tmp = Float64(fma(b, c, Float64(d * Float64(-a))) / fma(d, d, Float64(c * c))); elseif (c <= 1e+31) tmp = Float64(Float64(Float64(b * Float64(c / d)) - a) / d); else tmp = fma(1.0, Float64(b / hypot(c, d)), Float64(Float64(d / hypot(d, c)) * Float64(Float64(-a) / hypot(d, c)))); end return tmp end
code[a_, b_, c_, d_] := If[LessEqual[c, -1.95e+87], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[c, -8.8e-162], N[(N[(b * c + N[(d * (-a)), $MachinePrecision]), $MachinePrecision] / N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1e+31], N[(N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], N[(1.0 * N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] + N[(N[(d / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision] * N[((-a) / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.95 \cdot 10^{+87}:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\
\mathbf{elif}\;c \leq -8.8 \cdot 10^{-162}:\\
\;\;\;\;\frac{\mathsf{fma}\left(b, c, d \cdot \left(-a\right)\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\
\mathbf{elif}\;c \leq 10^{+31}:\\
\;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(1, \frac{b}{\mathsf{hypot}\left(c, d\right)}, \frac{d}{\mathsf{hypot}\left(d, c\right)} \cdot \frac{-a}{\mathsf{hypot}\left(d, c\right)}\right)\\
\end{array}
\end{array}
if c < -1.9500000000000001e87Initial program 38.7%
fma-define38.7%
Simplified38.7%
Taylor expanded in c around inf 85.8%
associate-*r/85.8%
neg-mul-185.8%
distribute-rgt-neg-in85.8%
Simplified85.8%
if -1.9500000000000001e87 < c < -8.7999999999999997e-162Initial program 72.1%
fma-neg72.2%
distribute-rgt-neg-out72.2%
+-commutative72.2%
fma-define72.2%
Simplified72.2%
if -8.7999999999999997e-162 < c < 9.9999999999999996e30Initial program 72.4%
fma-define72.4%
Simplified72.4%
Taylor expanded in c around 0 78.5%
+-commutative78.5%
mul-1-neg78.5%
unsub-neg78.5%
unpow278.5%
associate-/r*83.5%
div-sub85.3%
associate-/l*86.9%
Simplified86.9%
if 9.9999999999999996e30 < c Initial program 50.4%
fma-define50.5%
Simplified50.5%
fma-define50.4%
div-sub50.4%
*-commutative50.4%
fma-define50.4%
add-sqr-sqrt50.4%
times-frac54.9%
fma-neg54.9%
fma-define54.9%
hypot-define54.9%
fma-define54.9%
hypot-define82.6%
fma-define82.7%
add-sqr-sqrt82.6%
pow282.6%
Applied egg-rr82.6%
add-sqr-sqrt74.8%
sqrt-unprod75.7%
sqr-neg75.7%
sqrt-unprod67.2%
add-sqr-sqrt75.1%
distribute-neg-frac75.1%
distribute-rgt-neg-out75.1%
*-un-lft-identity75.1%
unpow275.1%
times-frac75.0%
*-commutative75.0%
add-sqr-sqrt33.4%
sqrt-unprod71.2%
sqr-neg71.2%
sqrt-prod52.9%
add-sqr-sqrt88.4%
Applied egg-rr88.4%
associate-*l/88.4%
*-lft-identity88.4%
associate-/l*99.8%
associate-*l/99.8%
hypot-undefine83.2%
unpow283.2%
unpow283.2%
+-commutative83.2%
unpow283.2%
unpow283.2%
hypot-define99.8%
hypot-undefine83.2%
unpow283.2%
unpow283.2%
+-commutative83.2%
unpow283.2%
unpow283.2%
hypot-define99.8%
Simplified99.8%
Taylor expanded in c around inf 90.6%
Final simplification85.0%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* b (/ c d)) a) d)))
(if (<= d -2.95e+113)
t_0
(if (<= d -2.15e-112)
(/ (- (* c b) (* d a)) (fma c c (* d d)))
(if (<= d 1.1e-120)
(/ (- b (/ (* d a) c)) c)
(if (<= d 3e+67) (/ (fma b c (* d (- a))) (fma d d (* c c))) t_0))))))
double code(double a, double b, double c, double d) {
double t_0 = ((b * (c / d)) - a) / d;
double tmp;
if (d <= -2.95e+113) {
tmp = t_0;
} else if (d <= -2.15e-112) {
tmp = ((c * b) - (d * a)) / fma(c, c, (d * d));
} else if (d <= 1.1e-120) {
tmp = (b - ((d * a) / c)) / c;
} else if (d <= 3e+67) {
tmp = fma(b, c, (d * -a)) / fma(d, d, (c * c));
} else {
tmp = t_0;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(Float64(b * Float64(c / d)) - a) / d) tmp = 0.0 if (d <= -2.95e+113) tmp = t_0; elseif (d <= -2.15e-112) tmp = Float64(Float64(Float64(c * b) - Float64(d * a)) / fma(c, c, Float64(d * d))); elseif (d <= 1.1e-120) tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c); elseif (d <= 3e+67) tmp = Float64(fma(b, c, Float64(d * Float64(-a))) / fma(d, d, Float64(c * c))); else tmp = t_0; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -2.95e+113], t$95$0, If[LessEqual[d, -2.15e-112], N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.1e-120], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 3e+67], N[(N[(b * c + N[(d * (-a)), $MachinePrecision]), $MachinePrecision] / N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b \cdot \frac{c}{d} - a}{d}\\
\mathbf{if}\;d \leq -2.95 \cdot 10^{+113}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq -2.15 \cdot 10^{-112}:\\
\;\;\;\;\frac{c \cdot b - d \cdot a}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\
\mathbf{elif}\;d \leq 1.1 \cdot 10^{-120}:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\
\mathbf{elif}\;d \leq 3 \cdot 10^{+67}:\\
\;\;\;\;\frac{\mathsf{fma}\left(b, c, d \cdot \left(-a\right)\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d < -2.95000000000000011e113 or 3.0000000000000001e67 < d Initial program 39.3%
fma-define39.3%
Simplified39.3%
Taylor expanded in c around 0 75.0%
+-commutative75.0%
mul-1-neg75.0%
unsub-neg75.0%
unpow275.0%
associate-/r*80.4%
div-sub80.4%
associate-/l*85.6%
Simplified85.6%
if -2.95000000000000011e113 < d < -2.1499999999999999e-112Initial program 90.3%
fma-define90.4%
Simplified90.4%
if -2.1499999999999999e-112 < d < 1.10000000000000006e-120Initial program 61.8%
fma-define61.8%
Simplified61.8%
Taylor expanded in c around inf 90.3%
associate-*r/90.3%
neg-mul-190.3%
distribute-rgt-neg-in90.3%
Simplified90.3%
if 1.10000000000000006e-120 < d < 3.0000000000000001e67Initial program 74.6%
fma-neg74.6%
distribute-rgt-neg-out74.6%
+-commutative74.6%
fma-define74.6%
Simplified74.6%
Final simplification86.0%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (- (* c b) (* d a))) (t_1 (/ (- (* b (/ c d)) a) d)))
(if (<= d -4.5e+115)
t_1
(if (<= d -1.75e-112)
(/ t_0 (fma c c (* d d)))
(if (<= d 9e-121)
(/ (- b (/ (* d a) c)) c)
(if (<= d 2.6e+66) (/ t_0 (+ (* c c) (* d d))) t_1))))))
double code(double a, double b, double c, double d) {
double t_0 = (c * b) - (d * a);
double t_1 = ((b * (c / d)) - a) / d;
double tmp;
if (d <= -4.5e+115) {
tmp = t_1;
} else if (d <= -1.75e-112) {
tmp = t_0 / fma(c, c, (d * d));
} else if (d <= 9e-121) {
tmp = (b - ((d * a) / c)) / c;
} else if (d <= 2.6e+66) {
tmp = t_0 / ((c * c) + (d * d));
} else {
tmp = t_1;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(c * b) - Float64(d * a)) t_1 = Float64(Float64(Float64(b * Float64(c / d)) - a) / d) tmp = 0.0 if (d <= -4.5e+115) tmp = t_1; elseif (d <= -1.75e-112) tmp = Float64(t_0 / fma(c, c, Float64(d * d))); elseif (d <= 9e-121) tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c); elseif (d <= 2.6e+66) tmp = Float64(t_0 / Float64(Float64(c * c) + Float64(d * d))); else tmp = t_1; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -4.5e+115], t$95$1, If[LessEqual[d, -1.75e-112], N[(t$95$0 / N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 9e-121], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 2.6e+66], N[(t$95$0 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := c \cdot b - d \cdot a\\
t_1 := \frac{b \cdot \frac{c}{d} - a}{d}\\
\mathbf{if}\;d \leq -4.5 \cdot 10^{+115}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d \leq -1.75 \cdot 10^{-112}:\\
\;\;\;\;\frac{t\_0}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\
\mathbf{elif}\;d \leq 9 \cdot 10^{-121}:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\
\mathbf{elif}\;d \leq 2.6 \cdot 10^{+66}:\\
\;\;\;\;\frac{t\_0}{c \cdot c + d \cdot d}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if d < -4.49999999999999963e115 or 2.60000000000000012e66 < d Initial program 39.3%
fma-define39.3%
Simplified39.3%
Taylor expanded in c around 0 75.0%
+-commutative75.0%
mul-1-neg75.0%
unsub-neg75.0%
unpow275.0%
associate-/r*80.4%
div-sub80.4%
associate-/l*85.6%
Simplified85.6%
if -4.49999999999999963e115 < d < -1.74999999999999997e-112Initial program 90.3%
fma-define90.4%
Simplified90.4%
if -1.74999999999999997e-112 < d < 9.0000000000000007e-121Initial program 61.8%
fma-define61.8%
Simplified61.8%
Taylor expanded in c around inf 90.3%
associate-*r/90.3%
neg-mul-190.3%
distribute-rgt-neg-in90.3%
Simplified90.3%
if 9.0000000000000007e-121 < d < 2.60000000000000012e66Initial program 74.6%
Final simplification86.0%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* c b) (* d a)) (+ (* c c) (* d d))))
(t_1 (/ (- (* b (/ c d)) a) d)))
(if (<= d -2.9e+113)
t_1
(if (<= d -6.8e-112)
t_0
(if (<= d 1.55e-121)
(/ (- b (/ (* d a) c)) c)
(if (<= d 3e+67) t_0 t_1))))))
double code(double a, double b, double c, double d) {
double t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
double t_1 = ((b * (c / d)) - a) / d;
double tmp;
if (d <= -2.9e+113) {
tmp = t_1;
} else if (d <= -6.8e-112) {
tmp = t_0;
} else if (d <= 1.55e-121) {
tmp = (b - ((d * a) / c)) / c;
} else if (d <= 3e+67) {
tmp = t_0;
} else {
tmp = t_1;
}
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 = ((c * b) - (d * a)) / ((c * c) + (d * d))
t_1 = ((b * (c / d)) - a) / d
if (d <= (-2.9d+113)) then
tmp = t_1
else if (d <= (-6.8d-112)) then
tmp = t_0
else if (d <= 1.55d-121) then
tmp = (b - ((d * a) / c)) / c
else if (d <= 3d+67) then
tmp = t_0
else
tmp = t_1
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 t_1 = ((b * (c / d)) - a) / d;
double tmp;
if (d <= -2.9e+113) {
tmp = t_1;
} else if (d <= -6.8e-112) {
tmp = t_0;
} else if (d <= 1.55e-121) {
tmp = (b - ((d * a) / c)) / c;
} else if (d <= 3e+67) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(a, b, c, d): t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d)) t_1 = ((b * (c / d)) - a) / d tmp = 0 if d <= -2.9e+113: tmp = t_1 elif d <= -6.8e-112: tmp = t_0 elif d <= 1.55e-121: tmp = (b - ((d * a) / c)) / c elif d <= 3e+67: tmp = t_0 else: tmp = t_1 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))) t_1 = Float64(Float64(Float64(b * Float64(c / d)) - a) / d) tmp = 0.0 if (d <= -2.9e+113) tmp = t_1; elseif (d <= -6.8e-112) tmp = t_0; elseif (d <= 1.55e-121) tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c); elseif (d <= 3e+67) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d)); t_1 = ((b * (c / d)) - a) / d; tmp = 0.0; if (d <= -2.9e+113) tmp = t_1; elseif (d <= -6.8e-112) tmp = t_0; elseif (d <= 1.55e-121) tmp = (b - ((d * a) / c)) / c; elseif (d <= 3e+67) tmp = t_0; else tmp = t_1; 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]}, Block[{t$95$1 = N[(N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -2.9e+113], t$95$1, If[LessEqual[d, -6.8e-112], t$95$0, If[LessEqual[d, 1.55e-121], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 3e+67], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
t_1 := \frac{b \cdot \frac{c}{d} - a}{d}\\
\mathbf{if}\;d \leq -2.9 \cdot 10^{+113}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d \leq -6.8 \cdot 10^{-112}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 1.55 \cdot 10^{-121}:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\
\mathbf{elif}\;d \leq 3 \cdot 10^{+67}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if d < -2.89999999999999984e113 or 3.0000000000000001e67 < d Initial program 39.3%
fma-define39.3%
Simplified39.3%
Taylor expanded in c around 0 75.0%
+-commutative75.0%
mul-1-neg75.0%
unsub-neg75.0%
unpow275.0%
associate-/r*80.4%
div-sub80.4%
associate-/l*85.6%
Simplified85.6%
if -2.89999999999999984e113 < d < -6.7999999999999996e-112 or 1.5499999999999999e-121 < d < 3.0000000000000001e67Initial program 82.1%
if -6.7999999999999996e-112 < d < 1.5499999999999999e-121Initial program 61.8%
fma-define61.8%
Simplified61.8%
Taylor expanded in c around inf 90.3%
associate-*r/90.3%
neg-mul-190.3%
distribute-rgt-neg-in90.3%
Simplified90.3%
Final simplification86.0%
(FPCore (a b c d) :precision binary64 (if (or (<= c -1e+86) (not (<= c 1.1e+31))) (/ (- b (* a (/ d c))) c) (/ (- (* b (/ c d)) a) d)))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -1e+86) || !(c <= 1.1e+31)) {
tmp = (b - (a * (d / 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 ((c <= (-1d+86)) .or. (.not. (c <= 1.1d+31))) then
tmp = (b - (a * (d / 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 ((c <= -1e+86) || !(c <= 1.1e+31)) {
tmp = (b - (a * (d / c))) / c;
} else {
tmp = ((b * (c / d)) - a) / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -1e+86) or not (c <= 1.1e+31): tmp = (b - (a * (d / c))) / c else: tmp = ((b * (c / d)) - a) / d return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -1e+86) || !(c <= 1.1e+31)) tmp = Float64(Float64(b - Float64(a * Float64(d / 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 ((c <= -1e+86) || ~((c <= 1.1e+31))) tmp = (b - (a * (d / c))) / c; else tmp = ((b * (c / d)) - a) / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -1e+86], N[Not[LessEqual[c, 1.1e+31]], $MachinePrecision]], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $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}\;c \leq -1 \cdot 10^{+86} \lor \neg \left(c \leq 1.1 \cdot 10^{+31}\right):\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\
\end{array}
\end{array}
if c < -1e86 or 1.10000000000000005e31 < c Initial program 45.4%
fma-define45.4%
Simplified45.4%
Taylor expanded in c around inf 80.4%
mul-1-neg80.4%
unsub-neg80.4%
associate-/l*82.7%
Simplified82.7%
if -1e86 < c < 1.10000000000000005e31Initial program 72.2%
fma-define72.2%
Simplified72.2%
Taylor expanded in c around 0 71.7%
+-commutative71.7%
mul-1-neg71.7%
unsub-neg71.7%
unpow271.7%
associate-/r*76.4%
div-sub77.8%
associate-/l*79.6%
Simplified79.6%
Final simplification80.8%
(FPCore (a b c d) :precision binary64 (if (or (<= d -1.55e+24) (not (<= d 1.2e+86))) (/ (- a) d) (/ (- b (* a (/ d c))) c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -1.55e+24) || !(d <= 1.2e+86)) {
tmp = -a / d;
} else {
tmp = (b - (a * (d / 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.55d+24)) .or. (.not. (d <= 1.2d+86))) then
tmp = -a / d
else
tmp = (b - (a * (d / 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.55e+24) || !(d <= 1.2e+86)) {
tmp = -a / d;
} else {
tmp = (b - (a * (d / c))) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -1.55e+24) or not (d <= 1.2e+86): tmp = -a / d else: tmp = (b - (a * (d / c))) / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -1.55e+24) || !(d <= 1.2e+86)) tmp = Float64(Float64(-a) / d); else tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -1.55e+24) || ~((d <= 1.2e+86))) tmp = -a / d; else tmp = (b - (a * (d / c))) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -1.55e+24], N[Not[LessEqual[d, 1.2e+86]], $MachinePrecision]], N[((-a) / d), $MachinePrecision], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.55 \cdot 10^{+24} \lor \neg \left(d \leq 1.2 \cdot 10^{+86}\right):\\
\;\;\;\;\frac{-a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\
\end{array}
\end{array}
if d < -1.55000000000000005e24 or 1.2e86 < d Initial program 48.9%
fma-define48.9%
Simplified48.9%
Taylor expanded in c around 0 68.0%
associate-*r/68.0%
neg-mul-168.0%
Simplified68.0%
if -1.55000000000000005e24 < d < 1.2e86Initial program 69.1%
fma-define69.1%
Simplified69.1%
Taylor expanded in c around inf 72.8%
mul-1-neg72.8%
unsub-neg72.8%
associate-/l*72.6%
Simplified72.6%
Final simplification70.9%
(FPCore (a b c d) :precision binary64 (if (<= c -2.05e+86) (/ (- b (/ (* d a) c)) c) (if (<= c 1e+31) (/ (- (* b (/ c d)) a) d) (/ (- b (* a (/ d c))) c))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -2.05e+86) {
tmp = (b - ((d * a) / c)) / c;
} else if (c <= 1e+31) {
tmp = ((b * (c / d)) - a) / d;
} else {
tmp = (b - (a * (d / 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 (c <= (-2.05d+86)) then
tmp = (b - ((d * a) / c)) / c
else if (c <= 1d+31) then
tmp = ((b * (c / d)) - a) / d
else
tmp = (b - (a * (d / c))) / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -2.05e+86) {
tmp = (b - ((d * a) / c)) / c;
} else if (c <= 1e+31) {
tmp = ((b * (c / d)) - a) / d;
} else {
tmp = (b - (a * (d / c))) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -2.05e+86: tmp = (b - ((d * a) / c)) / c elif c <= 1e+31: tmp = ((b * (c / d)) - a) / d else: tmp = (b - (a * (d / c))) / c return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -2.05e+86) tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c); elseif (c <= 1e+31) tmp = Float64(Float64(Float64(b * Float64(c / d)) - a) / d); else tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -2.05e+86) tmp = (b - ((d * a) / c)) / c; elseif (c <= 1e+31) tmp = ((b * (c / d)) - a) / d; else tmp = (b - (a * (d / c))) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -2.05e+86], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[c, 1e+31], N[(N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -2.05 \cdot 10^{+86}:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\
\mathbf{elif}\;c \leq 10^{+31}:\\
\;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\
\end{array}
\end{array}
if c < -2.05e86Initial program 40.0%
fma-define40.0%
Simplified40.0%
Taylor expanded in c around inf 86.1%
associate-*r/86.1%
neg-mul-186.1%
distribute-rgt-neg-in86.1%
Simplified86.1%
if -2.05e86 < c < 9.9999999999999996e30Initial program 72.2%
fma-define72.2%
Simplified72.2%
Taylor expanded in c around 0 71.7%
+-commutative71.7%
mul-1-neg71.7%
unsub-neg71.7%
unpow271.7%
associate-/r*76.4%
div-sub77.8%
associate-/l*79.6%
Simplified79.6%
if 9.9999999999999996e30 < c Initial program 50.4%
fma-define50.5%
Simplified50.5%
Taylor expanded in c around inf 75.1%
mul-1-neg75.1%
unsub-neg75.1%
associate-/l*82.6%
Simplified82.6%
Final simplification81.4%
(FPCore (a b c d) :precision binary64 (if (or (<= c -2.45e+33) (not (<= c 1.45e+43))) (/ b c) (/ (- a) d)))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -2.45e+33) || !(c <= 1.45e+43)) {
tmp = b / c;
} else {
tmp = -a / d;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if ((c <= (-2.45d+33)) .or. (.not. (c <= 1.45d+43))) then
tmp = b / c
else
tmp = -a / d
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -2.45e+33) || !(c <= 1.45e+43)) {
tmp = b / c;
} else {
tmp = -a / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -2.45e+33) or not (c <= 1.45e+43): tmp = b / c else: tmp = -a / d return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -2.45e+33) || !(c <= 1.45e+43)) tmp = Float64(b / c); else tmp = Float64(Float64(-a) / d); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((c <= -2.45e+33) || ~((c <= 1.45e+43))) tmp = b / c; else tmp = -a / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -2.45e+33], N[Not[LessEqual[c, 1.45e+43]], $MachinePrecision]], N[(b / c), $MachinePrecision], N[((-a) / d), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -2.45 \cdot 10^{+33} \lor \neg \left(c \leq 1.45 \cdot 10^{+43}\right):\\
\;\;\;\;\frac{b}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{-a}{d}\\
\end{array}
\end{array}
if c < -2.45000000000000007e33 or 1.4500000000000001e43 < c Initial program 47.3%
fma-define47.3%
Simplified47.3%
Taylor expanded in c around inf 69.9%
if -2.45000000000000007e33 < c < 1.4500000000000001e43Initial program 72.1%
fma-define72.1%
Simplified72.1%
Taylor expanded in c around 0 59.0%
associate-*r/59.0%
neg-mul-159.0%
Simplified59.0%
Final simplification63.5%
(FPCore (a b c d) :precision binary64 (if (<= c -4.7e+41) (/ 1.0 (/ c b)) (if (<= c 1.35e+42) (/ (- a) d) (/ b c))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -4.7e+41) {
tmp = 1.0 / (c / b);
} else if (c <= 1.35e+42) {
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 (c <= (-4.7d+41)) then
tmp = 1.0d0 / (c / b)
else if (c <= 1.35d+42) 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 (c <= -4.7e+41) {
tmp = 1.0 / (c / b);
} else if (c <= 1.35e+42) {
tmp = -a / d;
} else {
tmp = b / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -4.7e+41: tmp = 1.0 / (c / b) elif c <= 1.35e+42: tmp = -a / d else: tmp = b / c return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -4.7e+41) tmp = Float64(1.0 / Float64(c / b)); elseif (c <= 1.35e+42) 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 (c <= -4.7e+41) tmp = 1.0 / (c / b); elseif (c <= 1.35e+42) tmp = -a / d; else tmp = b / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -4.7e+41], N[(1.0 / N[(c / b), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.35e+42], N[((-a) / d), $MachinePrecision], N[(b / c), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -4.7 \cdot 10^{+41}:\\
\;\;\;\;\frac{1}{\frac{c}{b}}\\
\mathbf{elif}\;c \leq 1.35 \cdot 10^{+42}:\\
\;\;\;\;\frac{-a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if c < -4.70000000000000001e41Initial program 44.6%
fma-define44.6%
Simplified44.6%
Taylor expanded in c around inf 73.8%
clear-num74.4%
inv-pow74.4%
Applied egg-rr74.4%
unpow-174.4%
Simplified74.4%
if -4.70000000000000001e41 < c < 1.35e42Initial program 72.1%
fma-define72.1%
Simplified72.1%
Taylor expanded in c around 0 59.0%
associate-*r/59.0%
neg-mul-159.0%
Simplified59.0%
if 1.35e42 < c Initial program 50.5%
fma-define50.5%
Simplified50.5%
Taylor expanded in c around inf 65.4%
(FPCore (a b c d) :precision binary64 (if (<= d -8.2e+119) (/ a d) (/ b c)))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -8.2e+119) {
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 <= (-8.2d+119)) 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 <= -8.2e+119) {
tmp = a / d;
} else {
tmp = b / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -8.2e+119: tmp = a / d else: tmp = b / c return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -8.2e+119) 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 <= -8.2e+119) tmp = a / d; else tmp = b / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -8.2e+119], N[(a / d), $MachinePrecision], N[(b / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -8.2 \cdot 10^{+119}:\\
\;\;\;\;\frac{a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if d < -8.1999999999999994e119Initial program 38.9%
fma-define38.9%
Simplified38.9%
Taylor expanded in c around 0 80.1%
associate-*r/80.1%
neg-mul-180.1%
Simplified80.1%
add-sqr-sqrt35.9%
sqrt-unprod38.8%
sqr-neg38.8%
sqrt-unprod18.9%
add-sqr-sqrt29.2%
*-un-lft-identity29.2%
Applied egg-rr29.2%
*-lft-identity29.2%
Simplified29.2%
if -8.1999999999999994e119 < d Initial program 65.6%
fma-define65.6%
Simplified65.6%
Taylor expanded in c around inf 48.3%
(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 61.8%
fma-define61.8%
Simplified61.8%
Taylor expanded in c around 0 40.4%
associate-*r/40.4%
neg-mul-140.4%
Simplified40.4%
add-sqr-sqrt19.1%
sqrt-unprod19.0%
sqr-neg19.0%
sqrt-unprod4.9%
add-sqr-sqrt11.0%
*-un-lft-identity11.0%
Applied egg-rr11.0%
*-lft-identity11.0%
Simplified11.0%
(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 2024139
(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))))