
(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)) (* a (/ (/ d (hypot d c)) (- (hypot d c))))))
double code(double a, double b, double c, double d) {
return fma((c / hypot(c, d)), (b / hypot(c, d)), (a * ((d / hypot(d, c)) / -hypot(d, c))));
}
function code(a, b, c, d) return fma(Float64(c / hypot(c, d)), Float64(b / hypot(c, d)), Float64(a * Float64(Float64(d / hypot(d, c)) / Float64(-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[(a * N[(N[(d / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision] / (-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)}, a \cdot \frac{\frac{d}{\mathsf{hypot}\left(d, c\right)}}{-\mathsf{hypot}\left(d, c\right)}\right)
\end{array}
Initial program 62.6%
fma-neg62.6%
distribute-rgt-neg-out62.6%
+-commutative62.6%
fma-define62.6%
Simplified62.6%
distribute-rgt-neg-out62.6%
fma-neg62.6%
fma-undefine62.6%
+-commutative62.6%
div-sub58.6%
*-commutative58.6%
add-sqr-sqrt58.6%
times-frac60.3%
fma-neg60.3%
hypot-define60.3%
hypot-define73.7%
associate-/l*76.7%
add-sqr-sqrt76.7%
pow276.7%
Applied egg-rr76.7%
*-un-lft-identity76.7%
unpow276.7%
times-frac95.5%
Applied egg-rr95.5%
associate-*l/95.5%
*-lft-identity95.5%
hypot-undefine76.7%
unpow276.7%
unpow276.7%
+-commutative76.7%
unpow276.7%
unpow276.7%
hypot-define95.5%
hypot-undefine76.7%
unpow276.7%
unpow276.7%
+-commutative76.7%
unpow276.7%
unpow276.7%
hypot-define95.5%
Simplified95.5%
Final simplification95.5%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ c (hypot c d)))
(t_1 (/ b (hypot c d)))
(t_2 (fma t_0 t_1 (* a (/ d (- (pow (hypot c d) 2.0))))))
(t_3 (fma t_0 t_1 (/ a (- d)))))
(if (<= d -5.5e+111)
t_3
(if (<= d -1.6e-120)
t_2
(if (<= d 1.6e-168)
(/ (- b (/ (* d a) c)) c)
(if (<= d 6.9e+136) t_2 t_3))))))
double code(double a, double b, double c, double d) {
double t_0 = c / hypot(c, d);
double t_1 = b / hypot(c, d);
double t_2 = fma(t_0, t_1, (a * (d / -pow(hypot(c, d), 2.0))));
double t_3 = fma(t_0, t_1, (a / -d));
double tmp;
if (d <= -5.5e+111) {
tmp = t_3;
} else if (d <= -1.6e-120) {
tmp = t_2;
} else if (d <= 1.6e-168) {
tmp = (b - ((d * a) / c)) / c;
} else if (d <= 6.9e+136) {
tmp = t_2;
} else {
tmp = t_3;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(c / hypot(c, d)) t_1 = Float64(b / hypot(c, d)) t_2 = fma(t_0, t_1, Float64(a * Float64(d / Float64(-(hypot(c, d) ^ 2.0))))) t_3 = fma(t_0, t_1, Float64(a / Float64(-d))) tmp = 0.0 if (d <= -5.5e+111) tmp = t_3; elseif (d <= -1.6e-120) tmp = t_2; elseif (d <= 1.6e-168) tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c); elseif (d <= 6.9e+136) tmp = t_2; else tmp = t_3; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$0 * t$95$1 + N[(a * N[(d / (-N[Power[N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision], 2.0], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$0 * t$95$1 + N[(a / (-d)), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -5.5e+111], t$95$3, If[LessEqual[d, -1.6e-120], t$95$2, If[LessEqual[d, 1.6e-168], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 6.9e+136], t$95$2, t$95$3]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c}{\mathsf{hypot}\left(c, d\right)}\\
t_1 := \frac{b}{\mathsf{hypot}\left(c, d\right)}\\
t_2 := \mathsf{fma}\left(t\_0, t\_1, a \cdot \frac{d}{-{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\right)\\
t_3 := \mathsf{fma}\left(t\_0, t\_1, \frac{a}{-d}\right)\\
\mathbf{if}\;d \leq -5.5 \cdot 10^{+111}:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;d \leq -1.6 \cdot 10^{-120}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;d \leq 1.6 \cdot 10^{-168}:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\
\mathbf{elif}\;d \leq 6.9 \cdot 10^{+136}:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;t\_3\\
\end{array}
\end{array}
if d < -5.4999999999999998e111 or 6.9e136 < d Initial program 36.2%
fma-neg36.2%
distribute-rgt-neg-out36.2%
+-commutative36.2%
fma-define36.2%
Simplified36.2%
distribute-rgt-neg-out36.2%
fma-neg36.2%
fma-undefine36.2%
+-commutative36.2%
div-sub36.2%
*-commutative36.2%
add-sqr-sqrt36.2%
times-frac36.5%
fma-neg36.5%
hypot-define36.5%
hypot-define45.1%
associate-/l*50.0%
add-sqr-sqrt50.0%
pow250.0%
Applied egg-rr50.0%
Taylor expanded in d around inf 96.4%
if -5.4999999999999998e111 < d < -1.6e-120 or 1.60000000000000003e-168 < d < 6.9e136Initial program 77.8%
fma-neg77.8%
distribute-rgt-neg-out77.8%
+-commutative77.8%
fma-define77.8%
Simplified77.8%
distribute-rgt-neg-out77.8%
fma-neg77.8%
fma-undefine77.8%
+-commutative77.8%
div-sub76.9%
*-commutative76.9%
add-sqr-sqrt76.9%
times-frac77.5%
fma-neg77.5%
hypot-define77.5%
hypot-define90.1%
associate-/l*94.7%
add-sqr-sqrt94.7%
pow294.7%
Applied egg-rr94.7%
if -1.6e-120 < d < 1.60000000000000003e-168Initial program 68.4%
fma-neg68.4%
distribute-rgt-neg-out68.4%
+-commutative68.4%
fma-define68.4%
Simplified68.4%
Taylor expanded in c around inf 91.8%
associate-*r/91.8%
neg-mul-191.8%
distribute-lft-neg-in91.8%
Simplified91.8%
Final simplification94.4%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (fma (/ c (hypot c d)) (/ b (hypot c d)) (/ a (- d)))))
(if (<= d -1.55e-34)
t_0
(if (<= d 4.8e-117)
(/ (- b (/ (* d a) c)) c)
(if (<= d 1e+29) (/ (- (* c b) (* d a)) (+ (* c c) (* d d))) t_0)))))
double code(double a, double b, double c, double d) {
double t_0 = fma((c / hypot(c, d)), (b / hypot(c, d)), (a / -d));
double tmp;
if (d <= -1.55e-34) {
tmp = t_0;
} else if (d <= 4.8e-117) {
tmp = (b - ((d * a) / c)) / c;
} else if (d <= 1e+29) {
tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
} else {
tmp = t_0;
}
return tmp;
}
function code(a, b, c, d) t_0 = fma(Float64(c / hypot(c, d)), Float64(b / hypot(c, d)), Float64(a / Float64(-d))) tmp = 0.0 if (d <= -1.55e-34) tmp = t_0; elseif (d <= 4.8e-117) tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c); elseif (d <= 1e+29) tmp = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d))); else tmp = t_0; 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[(a / (-d)), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -1.55e-34], t$95$0, If[LessEqual[d, 4.8e-117], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 1e+29], N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\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{a}{-d}\right)\\
\mathbf{if}\;d \leq -1.55 \cdot 10^{-34}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 4.8 \cdot 10^{-117}:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\
\mathbf{elif}\;d \leq 10^{+29}:\\
\;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d < -1.5499999999999999e-34 or 9.99999999999999914e28 < d Initial program 50.8%
fma-neg50.8%
distribute-rgt-neg-out50.8%
+-commutative50.8%
fma-define50.8%
Simplified50.8%
distribute-rgt-neg-out50.8%
fma-neg50.8%
fma-undefine50.8%
+-commutative50.8%
div-sub50.8%
*-commutative50.8%
add-sqr-sqrt50.9%
times-frac52.7%
fma-neg52.7%
hypot-define52.7%
hypot-define61.9%
associate-/l*67.3%
add-sqr-sqrt67.3%
pow267.3%
Applied egg-rr67.3%
Taylor expanded in d around inf 91.4%
if -1.5499999999999999e-34 < d < 4.80000000000000028e-117Initial program 68.9%
fma-neg68.9%
distribute-rgt-neg-out68.9%
+-commutative68.9%
fma-define68.9%
Simplified68.9%
Taylor expanded in c around inf 91.0%
associate-*r/91.0%
neg-mul-191.0%
distribute-lft-neg-in91.0%
Simplified91.0%
if 4.80000000000000028e-117 < d < 9.99999999999999914e28Initial program 87.6%
Final simplification90.8%
(FPCore (a b c d)
:precision binary64
(if (<= d -3.1e-12)
(fma (/ c (hypot c d)) (/ b (- d)) (/ a (- d)))
(if (<= d 1.7e-113)
(/ (- b (/ (* d a) c)) c)
(if (<= d 1.8e+29)
(/ (- (* c b) (* d a)) (+ (* c c) (* d d)))
(- (* b (/ (/ c d) d)) (/ a d))))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -3.1e-12) {
tmp = fma((c / hypot(c, d)), (b / -d), (a / -d));
} else if (d <= 1.7e-113) {
tmp = (b - ((d * a) / c)) / c;
} else if (d <= 1.8e+29) {
tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
} else {
tmp = (b * ((c / d) / d)) - (a / d);
}
return tmp;
}
function code(a, b, c, d) tmp = 0.0 if (d <= -3.1e-12) tmp = fma(Float64(c / hypot(c, d)), Float64(b / Float64(-d)), Float64(a / Float64(-d))); elseif (d <= 1.7e-113) tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c); elseif (d <= 1.8e+29) tmp = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d))); else tmp = Float64(Float64(b * Float64(Float64(c / d) / d)) - Float64(a / d)); end return tmp end
code[a_, b_, c_, d_] := If[LessEqual[d, -3.1e-12], N[(N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b / (-d)), $MachinePrecision] + N[(a / (-d)), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.7e-113], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 1.8e+29], N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b * N[(N[(c / d), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -3.1 \cdot 10^{-12}:\\
\;\;\;\;\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{-d}, \frac{a}{-d}\right)\\
\mathbf{elif}\;d \leq 1.7 \cdot 10^{-113}:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\
\mathbf{elif}\;d \leq 1.8 \cdot 10^{+29}:\\
\;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{else}:\\
\;\;\;\;b \cdot \frac{\frac{c}{d}}{d} - \frac{a}{d}\\
\end{array}
\end{array}
if d < -3.1000000000000001e-12Initial program 46.1%
fma-neg46.1%
distribute-rgt-neg-out46.1%
+-commutative46.1%
fma-define46.2%
Simplified46.2%
distribute-rgt-neg-out46.2%
fma-neg46.2%
fma-undefine46.1%
+-commutative46.1%
div-sub46.1%
*-commutative46.1%
add-sqr-sqrt46.2%
times-frac49.4%
fma-neg49.4%
hypot-define49.4%
hypot-define62.1%
associate-/l*64.3%
add-sqr-sqrt64.3%
pow264.3%
Applied egg-rr64.3%
Taylor expanded in d around inf 91.3%
Taylor expanded in d around -inf 84.2%
associate-*r/84.2%
neg-mul-184.2%
Simplified84.2%
if -3.1000000000000001e-12 < d < 1.7000000000000001e-113Initial program 69.4%
fma-neg69.4%
distribute-rgt-neg-out69.4%
+-commutative69.4%
fma-define69.4%
Simplified69.4%
Taylor expanded in c around inf 89.4%
associate-*r/89.4%
neg-mul-189.4%
distribute-lft-neg-in89.4%
Simplified89.4%
if 1.7000000000000001e-113 < d < 1.79999999999999988e29Initial program 87.6%
if 1.79999999999999988e29 < d Initial program 54.2%
fma-neg54.2%
distribute-rgt-neg-out54.2%
+-commutative54.2%
fma-define54.1%
Simplified54.1%
distribute-rgt-neg-out54.1%
fma-neg54.1%
fma-undefine54.2%
+-commutative54.2%
div-sub54.2%
*-commutative54.2%
add-sqr-sqrt54.2%
times-frac54.4%
fma-neg54.4%
hypot-define54.4%
hypot-define58.0%
associate-/l*68.0%
add-sqr-sqrt68.0%
pow268.0%
Applied egg-rr68.0%
Taylor expanded in c around 0 89.6%
associate-/l*89.7%
Simplified89.7%
*-un-lft-identity89.7%
unpow289.7%
times-frac89.9%
Applied egg-rr89.9%
associate-*l/89.9%
*-lft-identity89.9%
Simplified89.9%
Final simplification87.9%
(FPCore (a b c d)
:precision binary64
(if (<= d -5e-10)
(/ (- (* c (/ b d)) a) d)
(if (<= d 1.2e-117)
(/ (- b (/ (* d a) c)) c)
(if (<= d 1.8e+29)
(/ (- (* c b) (* d a)) (+ (* c c) (* d d)))
(- (* b (/ (/ c d) d)) (/ a d))))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -5e-10) {
tmp = ((c * (b / d)) - a) / d;
} else if (d <= 1.2e-117) {
tmp = (b - ((d * a) / c)) / c;
} else if (d <= 1.8e+29) {
tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
} else {
tmp = (b * ((c / d) / 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 <= (-5d-10)) then
tmp = ((c * (b / d)) - a) / d
else if (d <= 1.2d-117) then
tmp = (b - ((d * a) / c)) / c
else if (d <= 1.8d+29) then
tmp = ((c * b) - (d * a)) / ((c * c) + (d * d))
else
tmp = (b * ((c / d) / 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 <= -5e-10) {
tmp = ((c * (b / d)) - a) / d;
} else if (d <= 1.2e-117) {
tmp = (b - ((d * a) / c)) / c;
} else if (d <= 1.8e+29) {
tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
} else {
tmp = (b * ((c / d) / d)) - (a / d);
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -5e-10: tmp = ((c * (b / d)) - a) / d elif d <= 1.2e-117: tmp = (b - ((d * a) / c)) / c elif d <= 1.8e+29: tmp = ((c * b) - (d * a)) / ((c * c) + (d * d)) else: tmp = (b * ((c / d) / d)) - (a / d) return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -5e-10) tmp = Float64(Float64(Float64(c * Float64(b / d)) - a) / d); elseif (d <= 1.2e-117) tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c); elseif (d <= 1.8e+29) tmp = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d))); else tmp = Float64(Float64(b * Float64(Float64(c / d) / d)) - Float64(a / d)); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= -5e-10) tmp = ((c * (b / d)) - a) / d; elseif (d <= 1.2e-117) tmp = (b - ((d * a) / c)) / c; elseif (d <= 1.8e+29) tmp = ((c * b) - (d * a)) / ((c * c) + (d * d)); else tmp = (b * ((c / d) / d)) - (a / d); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -5e-10], N[(N[(N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, 1.2e-117], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 1.8e+29], N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b * N[(N[(c / d), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -5 \cdot 10^{-10}:\\
\;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\
\mathbf{elif}\;d \leq 1.2 \cdot 10^{-117}:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\
\mathbf{elif}\;d \leq 1.8 \cdot 10^{+29}:\\
\;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{else}:\\
\;\;\;\;b \cdot \frac{\frac{c}{d}}{d} - \frac{a}{d}\\
\end{array}
\end{array}
if d < -5.00000000000000031e-10Initial program 46.1%
fma-neg46.1%
distribute-rgt-neg-out46.1%
+-commutative46.1%
fma-define46.2%
Simplified46.2%
Taylor expanded in c around 0 75.1%
+-commutative75.1%
mul-1-neg75.1%
unsub-neg75.1%
unpow275.1%
associate-/r*76.7%
div-sub76.7%
*-commutative76.7%
associate-/l*83.9%
Simplified83.9%
if -5.00000000000000031e-10 < d < 1.20000000000000007e-117Initial program 69.4%
fma-neg69.4%
distribute-rgt-neg-out69.4%
+-commutative69.4%
fma-define69.4%
Simplified69.4%
Taylor expanded in c around inf 89.4%
associate-*r/89.4%
neg-mul-189.4%
distribute-lft-neg-in89.4%
Simplified89.4%
if 1.20000000000000007e-117 < d < 1.79999999999999988e29Initial program 87.6%
if 1.79999999999999988e29 < d Initial program 54.2%
fma-neg54.2%
distribute-rgt-neg-out54.2%
+-commutative54.2%
fma-define54.1%
Simplified54.1%
distribute-rgt-neg-out54.1%
fma-neg54.1%
fma-undefine54.2%
+-commutative54.2%
div-sub54.2%
*-commutative54.2%
add-sqr-sqrt54.2%
times-frac54.4%
fma-neg54.4%
hypot-define54.4%
hypot-define58.0%
associate-/l*68.0%
add-sqr-sqrt68.0%
pow268.0%
Applied egg-rr68.0%
Taylor expanded in c around 0 89.6%
associate-/l*89.7%
Simplified89.7%
*-un-lft-identity89.7%
unpow289.7%
times-frac89.9%
Applied egg-rr89.9%
associate-*l/89.9%
*-lft-identity89.9%
Simplified89.9%
Final simplification87.8%
(FPCore (a b c d)
:precision binary64
(if (<= d -5.5e-9)
(/ (- (* c (/ b d)) a) d)
(if (<= d 1.02e-7)
(/ (- b (/ (* d a) c)) c)
(- (* b (/ (/ c d) d)) (/ a d)))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -5.5e-9) {
tmp = ((c * (b / d)) - a) / d;
} else if (d <= 1.02e-7) {
tmp = (b - ((d * a) / c)) / c;
} else {
tmp = (b * ((c / d) / 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 <= (-5.5d-9)) then
tmp = ((c * (b / d)) - a) / d
else if (d <= 1.02d-7) then
tmp = (b - ((d * a) / c)) / c
else
tmp = (b * ((c / d) / 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 <= -5.5e-9) {
tmp = ((c * (b / d)) - a) / d;
} else if (d <= 1.02e-7) {
tmp = (b - ((d * a) / c)) / c;
} else {
tmp = (b * ((c / d) / d)) - (a / d);
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -5.5e-9: tmp = ((c * (b / d)) - a) / d elif d <= 1.02e-7: tmp = (b - ((d * a) / c)) / c else: tmp = (b * ((c / d) / d)) - (a / d) return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -5.5e-9) tmp = Float64(Float64(Float64(c * Float64(b / d)) - a) / d); elseif (d <= 1.02e-7) tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c); else tmp = Float64(Float64(b * Float64(Float64(c / d) / d)) - Float64(a / d)); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= -5.5e-9) tmp = ((c * (b / d)) - a) / d; elseif (d <= 1.02e-7) tmp = (b - ((d * a) / c)) / c; else tmp = (b * ((c / d) / d)) - (a / d); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -5.5e-9], N[(N[(N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, 1.02e-7], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], N[(N[(b * N[(N[(c / d), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -5.5 \cdot 10^{-9}:\\
\;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\
\mathbf{elif}\;d \leq 1.02 \cdot 10^{-7}:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;b \cdot \frac{\frac{c}{d}}{d} - \frac{a}{d}\\
\end{array}
\end{array}
if d < -5.4999999999999996e-9Initial program 46.1%
fma-neg46.1%
distribute-rgt-neg-out46.1%
+-commutative46.1%
fma-define46.2%
Simplified46.2%
Taylor expanded in c around 0 75.1%
+-commutative75.1%
mul-1-neg75.1%
unsub-neg75.1%
unpow275.1%
associate-/r*76.7%
div-sub76.7%
*-commutative76.7%
associate-/l*83.9%
Simplified83.9%
if -5.4999999999999996e-9 < d < 1.02e-7Initial program 72.0%
fma-neg72.0%
distribute-rgt-neg-out72.0%
+-commutative72.0%
fma-define72.0%
Simplified72.0%
Taylor expanded in c around inf 84.6%
associate-*r/84.6%
neg-mul-184.6%
distribute-lft-neg-in84.6%
Simplified84.6%
if 1.02e-7 < d Initial program 60.8%
fma-neg60.8%
distribute-rgt-neg-out60.8%
+-commutative60.8%
fma-define60.8%
Simplified60.8%
distribute-rgt-neg-out60.8%
fma-neg60.8%
fma-undefine60.8%
+-commutative60.8%
div-sub60.8%
*-commutative60.8%
add-sqr-sqrt60.8%
times-frac61.0%
fma-neg61.0%
hypot-define61.0%
hypot-define64.1%
associate-/l*72.6%
add-sqr-sqrt72.6%
pow272.6%
Applied egg-rr72.6%
Taylor expanded in c around 0 87.9%
associate-/l*88.1%
Simplified88.1%
*-un-lft-identity88.1%
unpow288.1%
times-frac88.2%
Applied egg-rr88.2%
associate-*l/88.2%
*-lft-identity88.2%
Simplified88.2%
Final simplification85.3%
(FPCore (a b c d) :precision binary64 (if (or (<= d -5.8e-11) (not (<= d 5.2e-8))) (/ (- (* c (/ b d)) a) d) (/ (- b (/ (* d a) c)) c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -5.8e-11) || !(d <= 5.2e-8)) {
tmp = ((c * (b / d)) - 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 <= (-5.8d-11)) .or. (.not. (d <= 5.2d-8))) then
tmp = ((c * (b / d)) - 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 <= -5.8e-11) || !(d <= 5.2e-8)) {
tmp = ((c * (b / d)) - a) / d;
} else {
tmp = (b - ((d * a) / c)) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -5.8e-11) or not (d <= 5.2e-8): tmp = ((c * (b / d)) - a) / d else: tmp = (b - ((d * a) / c)) / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -5.8e-11) || !(d <= 5.2e-8)) tmp = Float64(Float64(Float64(c * Float64(b / d)) - a) / d); else tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -5.8e-11) || ~((d <= 5.2e-8))) tmp = ((c * (b / d)) - a) / d; else tmp = (b - ((d * a) / c)) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -5.8e-11], N[Not[LessEqual[d, 5.2e-8]], $MachinePrecision]], N[(N[(N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -5.8 \cdot 10^{-11} \lor \neg \left(d \leq 5.2 \cdot 10^{-8}\right):\\
\;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\
\end{array}
\end{array}
if d < -5.8e-11 or 5.2000000000000002e-8 < d Initial program 53.1%
fma-neg53.1%
distribute-rgt-neg-out53.1%
+-commutative53.1%
fma-define53.1%
Simplified53.1%
Taylor expanded in c around 0 81.2%
+-commutative81.2%
mul-1-neg81.2%
unsub-neg81.2%
unpow281.2%
associate-/r*82.1%
div-sub82.1%
*-commutative82.1%
associate-/l*85.9%
Simplified85.9%
if -5.8e-11 < d < 5.2000000000000002e-8Initial program 72.0%
fma-neg72.0%
distribute-rgt-neg-out72.0%
+-commutative72.0%
fma-define72.0%
Simplified72.0%
Taylor expanded in c around inf 84.6%
associate-*r/84.6%
neg-mul-184.6%
distribute-lft-neg-in84.6%
Simplified84.6%
Final simplification85.3%
(FPCore (a b c d) :precision binary64 (if (or (<= d -1.4e-9) (not (<= d 4.8e-8))) (/ (- (* c (/ b d)) a) d) (/ (- b (* a (/ d c))) c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -1.4e-9) || !(d <= 4.8e-8)) {
tmp = ((c * (b / 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 ((d <= (-1.4d-9)) .or. (.not. (d <= 4.8d-8))) then
tmp = ((c * (b / 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 ((d <= -1.4e-9) || !(d <= 4.8e-8)) {
tmp = ((c * (b / d)) - a) / d;
} else {
tmp = (b - (a * (d / c))) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -1.4e-9) or not (d <= 4.8e-8): tmp = ((c * (b / d)) - a) / d else: tmp = (b - (a * (d / c))) / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -1.4e-9) || !(d <= 4.8e-8)) tmp = Float64(Float64(Float64(c * Float64(b / 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 ((d <= -1.4e-9) || ~((d <= 4.8e-8))) tmp = ((c * (b / d)) - a) / d; else tmp = (b - (a * (d / c))) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -1.4e-9], N[Not[LessEqual[d, 4.8e-8]], $MachinePrecision]], N[(N[(N[(c * N[(b / 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}\;d \leq -1.4 \cdot 10^{-9} \lor \neg \left(d \leq 4.8 \cdot 10^{-8}\right):\\
\;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\
\end{array}
\end{array}
if d < -1.39999999999999992e-9 or 4.79999999999999997e-8 < d Initial program 53.1%
fma-neg53.1%
distribute-rgt-neg-out53.1%
+-commutative53.1%
fma-define53.1%
Simplified53.1%
Taylor expanded in c around 0 81.2%
+-commutative81.2%
mul-1-neg81.2%
unsub-neg81.2%
unpow281.2%
associate-/r*82.1%
div-sub82.1%
*-commutative82.1%
associate-/l*85.9%
Simplified85.9%
if -1.39999999999999992e-9 < d < 4.79999999999999997e-8Initial program 72.0%
fma-neg72.0%
distribute-rgt-neg-out72.0%
+-commutative72.0%
fma-define72.0%
Simplified72.0%
Taylor expanded in c around inf 84.6%
mul-1-neg84.6%
unsub-neg84.6%
associate-/l*83.5%
Simplified83.5%
Final simplification84.7%
(FPCore (a b c d) :precision binary64 (if (or (<= d -8.2e-11) (not (<= d 5.5e-8))) (/ (- (* b (/ c d)) a) d) (/ (- b (* a (/ d c))) c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -8.2e-11) || !(d <= 5.5e-8)) {
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 ((d <= (-8.2d-11)) .or. (.not. (d <= 5.5d-8))) 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 ((d <= -8.2e-11) || !(d <= 5.5e-8)) {
tmp = ((b * (c / d)) - a) / d;
} else {
tmp = (b - (a * (d / c))) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -8.2e-11) or not (d <= 5.5e-8): 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 ((d <= -8.2e-11) || !(d <= 5.5e-8)) 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 ((d <= -8.2e-11) || ~((d <= 5.5e-8))) tmp = ((b * (c / d)) - a) / d; else tmp = (b - (a * (d / c))) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -8.2e-11], N[Not[LessEqual[d, 5.5e-8]], $MachinePrecision]], 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}\;d \leq -8.2 \cdot 10^{-11} \lor \neg \left(d \leq 5.5 \cdot 10^{-8}\right):\\
\;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\
\end{array}
\end{array}
if d < -8.2000000000000001e-11 or 5.5000000000000003e-8 < d Initial program 53.1%
fma-neg53.1%
distribute-rgt-neg-out53.1%
+-commutative53.1%
fma-define53.1%
Simplified53.1%
distribute-rgt-neg-out53.1%
fma-neg53.1%
fma-undefine53.1%
+-commutative53.1%
div-sub53.1%
*-commutative53.1%
add-sqr-sqrt53.2%
times-frac54.9%
fma-neg54.9%
hypot-define54.9%
hypot-define63.1%
associate-/l*68.3%
add-sqr-sqrt68.3%
pow268.3%
Applied egg-rr68.3%
Taylor expanded in d around inf 82.1%
associate-/l*85.2%
Simplified85.2%
if -8.2000000000000001e-11 < d < 5.5000000000000003e-8Initial program 72.0%
fma-neg72.0%
distribute-rgt-neg-out72.0%
+-commutative72.0%
fma-define72.0%
Simplified72.0%
Taylor expanded in c around inf 84.6%
mul-1-neg84.6%
unsub-neg84.6%
associate-/l*83.5%
Simplified83.5%
Final simplification84.4%
(FPCore (a b c d) :precision binary64 (if (or (<= d -5.6e-10) (not (<= d 3.4e-7))) (/ a (- d)) (/ (- b (* a (/ d c))) c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -5.6e-10) || !(d <= 3.4e-7)) {
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 <= (-5.6d-10)) .or. (.not. (d <= 3.4d-7))) 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 <= -5.6e-10) || !(d <= 3.4e-7)) {
tmp = a / -d;
} else {
tmp = (b - (a * (d / c))) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -5.6e-10) or not (d <= 3.4e-7): tmp = a / -d else: tmp = (b - (a * (d / c))) / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -5.6e-10) || !(d <= 3.4e-7)) tmp = Float64(a / Float64(-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 <= -5.6e-10) || ~((d <= 3.4e-7))) tmp = a / -d; else tmp = (b - (a * (d / c))) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -5.6e-10], N[Not[LessEqual[d, 3.4e-7]], $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 -5.6 \cdot 10^{-10} \lor \neg \left(d \leq 3.4 \cdot 10^{-7}\right):\\
\;\;\;\;\frac{a}{-d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\
\end{array}
\end{array}
if d < -5.60000000000000031e-10 or 3.39999999999999974e-7 < d Initial program 53.1%
fma-neg53.1%
distribute-rgt-neg-out53.1%
+-commutative53.1%
fma-define53.1%
Simplified53.1%
Taylor expanded in c around 0 71.0%
associate-*r/71.0%
neg-mul-171.0%
Simplified71.0%
if -5.60000000000000031e-10 < d < 3.39999999999999974e-7Initial program 72.0%
fma-neg72.0%
distribute-rgt-neg-out72.0%
+-commutative72.0%
fma-define72.0%
Simplified72.0%
Taylor expanded in c around inf 84.6%
mul-1-neg84.6%
unsub-neg84.6%
associate-/l*83.5%
Simplified83.5%
Final simplification77.3%
(FPCore (a b c d) :precision binary64 (if (or (<= d -1.1e-12) (not (<= d 2.3e-68))) (/ a (- d)) (/ b c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -1.1e-12) || !(d <= 2.3e-68)) {
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.1d-12)) .or. (.not. (d <= 2.3d-68))) 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.1e-12) || !(d <= 2.3e-68)) {
tmp = a / -d;
} else {
tmp = b / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -1.1e-12) or not (d <= 2.3e-68): tmp = a / -d else: tmp = b / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -1.1e-12) || !(d <= 2.3e-68)) 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 <= -1.1e-12) || ~((d <= 2.3e-68))) tmp = a / -d; else tmp = b / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -1.1e-12], N[Not[LessEqual[d, 2.3e-68]], $MachinePrecision]], N[(a / (-d)), $MachinePrecision], N[(b / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.1 \cdot 10^{-12} \lor \neg \left(d \leq 2.3 \cdot 10^{-68}\right):\\
\;\;\;\;\frac{a}{-d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if d < -1.09999999999999996e-12 or 2.29999999999999997e-68 < d Initial program 55.9%
fma-neg55.9%
distribute-rgt-neg-out55.9%
+-commutative55.9%
fma-define55.9%
Simplified55.9%
Taylor expanded in c around 0 67.4%
associate-*r/67.4%
neg-mul-167.4%
Simplified67.4%
if -1.09999999999999996e-12 < d < 2.29999999999999997e-68Initial program 71.0%
fma-neg71.0%
distribute-rgt-neg-out71.0%
+-commutative71.0%
fma-define71.0%
Simplified71.0%
Taylor expanded in c around inf 64.4%
Final simplification66.1%
(FPCore (a b c d) :precision binary64 (if (or (<= d -8e+104) (not (<= d 1.55e+104))) (/ a d) (/ b c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -8e+104) || !(d <= 1.55e+104)) {
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 <= (-8d+104)) .or. (.not. (d <= 1.55d+104))) 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 <= -8e+104) || !(d <= 1.55e+104)) {
tmp = a / d;
} else {
tmp = b / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -8e+104) or not (d <= 1.55e+104): tmp = a / d else: tmp = b / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -8e+104) || !(d <= 1.55e+104)) 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 <= -8e+104) || ~((d <= 1.55e+104))) tmp = a / d; else tmp = b / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -8e+104], N[Not[LessEqual[d, 1.55e+104]], $MachinePrecision]], N[(a / d), $MachinePrecision], N[(b / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -8 \cdot 10^{+104} \lor \neg \left(d \leq 1.55 \cdot 10^{+104}\right):\\
\;\;\;\;\frac{a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if d < -8e104 or 1.55000000000000008e104 < d Initial program 38.5%
fma-neg38.5%
distribute-rgt-neg-out38.5%
+-commutative38.5%
fma-define38.4%
Simplified38.4%
Taylor expanded in c around 0 80.6%
associate-*r/80.6%
neg-mul-180.6%
Simplified80.6%
neg-sub080.6%
sub-neg80.6%
add-sqr-sqrt32.8%
sqrt-unprod36.5%
sqr-neg36.5%
sqrt-unprod13.9%
add-sqr-sqrt25.2%
Applied egg-rr25.2%
+-lft-identity25.2%
Simplified25.2%
if -8e104 < d < 1.55000000000000008e104Initial program 74.1%
fma-neg74.1%
distribute-rgt-neg-out74.1%
+-commutative74.1%
fma-define74.1%
Simplified74.1%
Taylor expanded in c around inf 50.6%
Final simplification42.4%
(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.6%
fma-neg62.6%
distribute-rgt-neg-out62.6%
+-commutative62.6%
fma-define62.6%
Simplified62.6%
Taylor expanded in c around 0 44.7%
associate-*r/44.7%
neg-mul-144.7%
Simplified44.7%
neg-sub044.7%
sub-neg44.7%
add-sqr-sqrt17.2%
sqrt-unprod19.4%
sqr-neg19.4%
sqrt-unprod5.8%
add-sqr-sqrt10.6%
Applied egg-rr10.6%
+-lft-identity10.6%
Simplified10.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 2024132
(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))))