
(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
(let* ((t_0 (fma d d (* c c))) (t_1 (fma (/ c t_0) b (* (- d) (/ a t_0)))))
(if (<= c -2.6e+118)
(/ (- b (* a (/ d c))) c)
(if (<= c -4.6e-65)
t_1
(if (<= c 8.2e-105)
(/ (- (/ (* c b) d) a) d)
(if (<= c 8e+112)
t_1
(fma
(fma
(- (* (/ a (pow c 4.0)) d) (/ b (pow c 3.0)))
d
(/ (/ (- a) c) c))
d
(/ b c))))))))
double code(double a, double b, double c, double d) {
double t_0 = fma(d, d, (c * c));
double t_1 = fma((c / t_0), b, (-d * (a / t_0)));
double tmp;
if (c <= -2.6e+118) {
tmp = (b - (a * (d / c))) / c;
} else if (c <= -4.6e-65) {
tmp = t_1;
} else if (c <= 8.2e-105) {
tmp = (((c * b) / d) - a) / d;
} else if (c <= 8e+112) {
tmp = t_1;
} else {
tmp = fma(fma((((a / pow(c, 4.0)) * d) - (b / pow(c, 3.0))), d, ((-a / c) / c)), d, (b / c));
}
return tmp;
}
function code(a, b, c, d) t_0 = fma(d, d, Float64(c * c)) t_1 = fma(Float64(c / t_0), b, Float64(Float64(-d) * Float64(a / t_0))) tmp = 0.0 if (c <= -2.6e+118) tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c); elseif (c <= -4.6e-65) tmp = t_1; elseif (c <= 8.2e-105) tmp = Float64(Float64(Float64(Float64(c * b) / d) - a) / d); elseif (c <= 8e+112) tmp = t_1; else tmp = fma(fma(Float64(Float64(Float64(a / (c ^ 4.0)) * d) - Float64(b / (c ^ 3.0))), d, Float64(Float64(Float64(-a) / c) / c)), d, Float64(b / c)); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(c / t$95$0), $MachinePrecision] * b + N[((-d) * N[(a / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -2.6e+118], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[c, -4.6e-65], t$95$1, If[LessEqual[c, 8.2e-105], N[(N[(N[(N[(c * b), $MachinePrecision] / d), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 8e+112], t$95$1, N[(N[(N[(N[(N[(a / N[Power[c, 4.0], $MachinePrecision]), $MachinePrecision] * d), $MachinePrecision] - N[(b / N[Power[c, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * d + N[(N[((-a) / c), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] * d + N[(b / c), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(d, d, c \cdot c\right)\\
t_1 := \mathsf{fma}\left(\frac{c}{t\_0}, b, \left(-d\right) \cdot \frac{a}{t\_0}\right)\\
\mathbf{if}\;c \leq -2.6 \cdot 10^{+118}:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\
\mathbf{elif}\;c \leq -4.6 \cdot 10^{-65}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;c \leq 8.2 \cdot 10^{-105}:\\
\;\;\;\;\frac{\frac{c \cdot b}{d} - a}{d}\\
\mathbf{elif}\;c \leq 8 \cdot 10^{+112}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\frac{a}{{c}^{4}} \cdot d - \frac{b}{{c}^{3}}, d, \frac{\frac{-a}{c}}{c}\right), d, \frac{b}{c}\right)\\
\end{array}
\end{array}
if c < -2.60000000000000016e118Initial program 40.3%
Taylor expanded in c around inf
lower-/.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6473.6
Applied rewrites73.6%
Applied rewrites83.4%
if -2.60000000000000016e118 < c < -4.5999999999999999e-65 or 8.20000000000000061e-105 < c < 7.9999999999999994e112Initial program 76.6%
Applied rewrites81.4%
if -4.5999999999999999e-65 < c < 8.20000000000000061e-105Initial program 70.4%
Taylor expanded in c around 0
+-commutativeN/A
fp-cancel-sign-sub-invN/A
unpow2N/A
associate-/r*N/A
metadata-evalN/A
*-lft-identityN/A
div-subN/A
lower-/.f64N/A
lower--.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6493.2
Applied rewrites93.2%
if 7.9999999999999994e112 < c Initial program 31.2%
Taylor expanded in d around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites91.5%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (fma d d (* c c))))
(if (<= d -5.8e+122)
(/ (- (* b (/ c d)) a) d)
(if (<= d -3e-83)
(fma (/ c t_0) b (* (- d) (/ a t_0)))
(if (<= d 6.6e-99)
(/ (- b (/ (* d a) c)) c)
(if (<= d 7.5e+42)
(/ (- (* b c) (* a d)) (fma c c (* d d)))
(/
(fma
(fma (/ c d) (/ c d) -1.0)
a
(* (- b) (- (pow (/ c d) 3.0) (/ c d))))
d)))))))
double code(double a, double b, double c, double d) {
double t_0 = fma(d, d, (c * c));
double tmp;
if (d <= -5.8e+122) {
tmp = ((b * (c / d)) - a) / d;
} else if (d <= -3e-83) {
tmp = fma((c / t_0), b, (-d * (a / t_0)));
} else if (d <= 6.6e-99) {
tmp = (b - ((d * a) / c)) / c;
} else if (d <= 7.5e+42) {
tmp = ((b * c) - (a * d)) / fma(c, c, (d * d));
} else {
tmp = fma(fma((c / d), (c / d), -1.0), a, (-b * (pow((c / d), 3.0) - (c / d)))) / d;
}
return tmp;
}
function code(a, b, c, d) t_0 = fma(d, d, Float64(c * c)) tmp = 0.0 if (d <= -5.8e+122) tmp = Float64(Float64(Float64(b * Float64(c / d)) - a) / d); elseif (d <= -3e-83) tmp = fma(Float64(c / t_0), b, Float64(Float64(-d) * Float64(a / t_0))); elseif (d <= 6.6e-99) tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c); elseif (d <= 7.5e+42) tmp = Float64(Float64(Float64(b * c) - Float64(a * d)) / fma(c, c, Float64(d * d))); else tmp = Float64(fma(fma(Float64(c / d), Float64(c / d), -1.0), a, Float64(Float64(-b) * Float64((Float64(c / d) ^ 3.0) - Float64(c / d)))) / d); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -5.8e+122], N[(N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, -3e-83], N[(N[(c / t$95$0), $MachinePrecision] * b + N[((-d) * N[(a / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 6.6e-99], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 7.5e+42], N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(c / d), $MachinePrecision] * N[(c / d), $MachinePrecision] + -1.0), $MachinePrecision] * a + N[((-b) * N[(N[Power[N[(c / d), $MachinePrecision], 3.0], $MachinePrecision] - N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(d, d, c \cdot c\right)\\
\mathbf{if}\;d \leq -5.8 \cdot 10^{+122}:\\
\;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\
\mathbf{elif}\;d \leq -3 \cdot 10^{-83}:\\
\;\;\;\;\mathsf{fma}\left(\frac{c}{t\_0}, b, \left(-d\right) \cdot \frac{a}{t\_0}\right)\\
\mathbf{elif}\;d \leq 6.6 \cdot 10^{-99}:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\
\mathbf{elif}\;d \leq 7.5 \cdot 10^{+42}:\\
\;\;\;\;\frac{b \cdot c - a \cdot d}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{c}{d}, \frac{c}{d}, -1\right), a, \left(-b\right) \cdot \left({\left(\frac{c}{d}\right)}^{3} - \frac{c}{d}\right)\right)}{d}\\
\end{array}
\end{array}
if d < -5.8000000000000002e122Initial program 29.9%
Taylor expanded in c around 0
+-commutativeN/A
fp-cancel-sign-sub-invN/A
unpow2N/A
associate-/r*N/A
metadata-evalN/A
*-lft-identityN/A
div-subN/A
lower-/.f64N/A
lower--.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6475.3
Applied rewrites75.3%
Applied rewrites81.1%
if -5.8000000000000002e122 < d < -3.0000000000000001e-83Initial program 79.6%
Applied rewrites82.7%
if -3.0000000000000001e-83 < d < 6.59999999999999973e-99Initial program 71.7%
Taylor expanded in c around inf
lower-/.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6491.2
Applied rewrites91.2%
if 6.59999999999999973e-99 < d < 7.50000000000000041e42Initial program 86.0%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6486.1
Applied rewrites86.1%
if 7.50000000000000041e42 < d Initial program 39.6%
Taylor expanded in d around inf
Applied rewrites87.8%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (fma d d (* c c))) (t_1 (/ (- (* b (/ c d)) a) d)))
(if (<= d -5.8e+122)
t_1
(if (<= d -3e-83)
(fma (/ c t_0) b (* (- d) (/ a t_0)))
(if (<= d 6.6e-99)
(/ (- b (/ (* d a) c)) c)
(if (<= d 7.5e+42) (/ (- (* b c) (* a d)) (fma c c (* d d))) t_1))))))
double code(double a, double b, double c, double d) {
double t_0 = fma(d, d, (c * c));
double t_1 = ((b * (c / d)) - a) / d;
double tmp;
if (d <= -5.8e+122) {
tmp = t_1;
} else if (d <= -3e-83) {
tmp = fma((c / t_0), b, (-d * (a / t_0)));
} else if (d <= 6.6e-99) {
tmp = (b - ((d * a) / c)) / c;
} else if (d <= 7.5e+42) {
tmp = ((b * c) - (a * d)) / fma(c, c, (d * d));
} else {
tmp = t_1;
}
return tmp;
}
function code(a, b, c, d) t_0 = fma(d, d, Float64(c * c)) t_1 = Float64(Float64(Float64(b * Float64(c / d)) - a) / d) tmp = 0.0 if (d <= -5.8e+122) tmp = t_1; elseif (d <= -3e-83) tmp = fma(Float64(c / t_0), b, Float64(Float64(-d) * Float64(a / t_0))); elseif (d <= 6.6e-99) tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c); elseif (d <= 7.5e+42) tmp = Float64(Float64(Float64(b * c) - Float64(a * d)) / fma(c, c, Float64(d * d))); else tmp = t_1; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -5.8e+122], t$95$1, If[LessEqual[d, -3e-83], N[(N[(c / t$95$0), $MachinePrecision] * b + N[((-d) * N[(a / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 6.6e-99], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 7.5e+42], N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(d, d, c \cdot c\right)\\
t_1 := \frac{b \cdot \frac{c}{d} - a}{d}\\
\mathbf{if}\;d \leq -5.8 \cdot 10^{+122}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d \leq -3 \cdot 10^{-83}:\\
\;\;\;\;\mathsf{fma}\left(\frac{c}{t\_0}, b, \left(-d\right) \cdot \frac{a}{t\_0}\right)\\
\mathbf{elif}\;d \leq 6.6 \cdot 10^{-99}:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\
\mathbf{elif}\;d \leq 7.5 \cdot 10^{+42}:\\
\;\;\;\;\frac{b \cdot c - a \cdot d}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if d < -5.8000000000000002e122 or 7.50000000000000041e42 < d Initial program 35.7%
Taylor expanded in c around 0
+-commutativeN/A
fp-cancel-sign-sub-invN/A
unpow2N/A
associate-/r*N/A
metadata-evalN/A
*-lft-identityN/A
div-subN/A
lower-/.f64N/A
lower--.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6480.3
Applied rewrites80.3%
Applied rewrites85.1%
if -5.8000000000000002e122 < d < -3.0000000000000001e-83Initial program 79.6%
Applied rewrites82.7%
if -3.0000000000000001e-83 < d < 6.59999999999999973e-99Initial program 71.7%
Taylor expanded in c around inf
lower-/.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6491.2
Applied rewrites91.2%
if 6.59999999999999973e-99 < d < 7.50000000000000041e42Initial program 86.0%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6486.1
Applied rewrites86.1%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* b c) (* a d)) (fma c c (* d d))))
(t_1 (/ (- (* b (/ c d)) a) d)))
(if (<= d -2.5e+116)
t_1
(if (<= d -3.3e-83)
t_0
(if (<= d 6.6e-99)
(/ (- b (/ (* d a) c)) c)
(if (<= d 7.5e+42) t_0 t_1))))))
double code(double a, double b, double c, double d) {
double t_0 = ((b * c) - (a * d)) / fma(c, c, (d * d));
double t_1 = ((b * (c / d)) - a) / d;
double tmp;
if (d <= -2.5e+116) {
tmp = t_1;
} else if (d <= -3.3e-83) {
tmp = t_0;
} else if (d <= 6.6e-99) {
tmp = (b - ((d * a) / c)) / c;
} else if (d <= 7.5e+42) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(Float64(b * c) - Float64(a * d)) / fma(c, c, Float64(d * d))) t_1 = Float64(Float64(Float64(b * Float64(c / d)) - a) / d) tmp = 0.0 if (d <= -2.5e+116) tmp = t_1; elseif (d <= -3.3e-83) tmp = t_0; elseif (d <= 6.6e-99) tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c); elseif (d <= 7.5e+42) tmp = t_0; else tmp = t_1; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(c * c + 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.5e+116], t$95$1, If[LessEqual[d, -3.3e-83], t$95$0, If[LessEqual[d, 6.6e-99], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 7.5e+42], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b \cdot c - a \cdot d}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\
t_1 := \frac{b \cdot \frac{c}{d} - a}{d}\\
\mathbf{if}\;d \leq -2.5 \cdot 10^{+116}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d \leq -3.3 \cdot 10^{-83}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 6.6 \cdot 10^{-99}:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\
\mathbf{elif}\;d \leq 7.5 \cdot 10^{+42}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if d < -2.50000000000000013e116 or 7.50000000000000041e42 < d Initial program 36.4%
Taylor expanded in c around 0
+-commutativeN/A
fp-cancel-sign-sub-invN/A
unpow2N/A
associate-/r*N/A
metadata-evalN/A
*-lft-identityN/A
div-subN/A
lower-/.f64N/A
lower--.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6480.5
Applied rewrites80.5%
Applied rewrites85.2%
if -2.50000000000000013e116 < d < -3.2999999999999999e-83 or 6.59999999999999973e-99 < d < 7.50000000000000041e42Initial program 82.1%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6482.1
Applied rewrites82.1%
if -3.2999999999999999e-83 < d < 6.59999999999999973e-99Initial program 71.7%
Taylor expanded in c around inf
lower-/.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6491.2
Applied rewrites91.2%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- a) d)))
(if (<= d -1.75e+83)
t_0
(if (<= d -1e-58)
(/ (fma (- a) d (* c b)) (* d d))
(if (<= d 1720.0) (/ (- b (/ (* d a) c)) c) t_0)))))
double code(double a, double b, double c, double d) {
double t_0 = -a / d;
double tmp;
if (d <= -1.75e+83) {
tmp = t_0;
} else if (d <= -1e-58) {
tmp = fma(-a, d, (c * b)) / (d * d);
} else if (d <= 1720.0) {
tmp = (b - ((d * a) / c)) / c;
} else {
tmp = t_0;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(-a) / d) tmp = 0.0 if (d <= -1.75e+83) tmp = t_0; elseif (d <= -1e-58) tmp = Float64(fma(Float64(-a), d, Float64(c * b)) / Float64(d * d)); elseif (d <= 1720.0) tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c); else tmp = t_0; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[((-a) / d), $MachinePrecision]}, If[LessEqual[d, -1.75e+83], t$95$0, If[LessEqual[d, -1e-58], N[(N[((-a) * d + N[(c * b), $MachinePrecision]), $MachinePrecision] / N[(d * d), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1720.0], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-a}{d}\\
\mathbf{if}\;d \leq -1.75 \cdot 10^{+83}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq -1 \cdot 10^{-58}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-a, d, c \cdot b\right)}{d \cdot d}\\
\mathbf{elif}\;d \leq 1720:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d < -1.74999999999999989e83 or 1720 < d Initial program 43.8%
Taylor expanded in c around 0
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6473.5
Applied rewrites73.5%
if -1.74999999999999989e83 < d < -1e-58Initial program 82.1%
Taylor expanded in c around 0
unpow2N/A
lower-*.f6461.4
Applied rewrites61.4%
lift--.f64N/A
lift-*.f64N/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
distribute-lft-neg-inN/A
+-commutativeN/A
*-commutativeN/A
distribute-lft-neg-inN/A
lift-neg.f64N/A
lower-fma.f6461.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f6461.6
Applied rewrites61.6%
if -1e-58 < d < 1720Initial program 74.3%
Taylor expanded in c around inf
lower-/.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6485.6
Applied rewrites85.6%
Final simplification77.9%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- a) d)))
(if (<= d -1.75e+83)
t_0
(if (<= d -1e-58)
(/ (fma (- a) d (* c b)) (* d d))
(if (<= d 1720.0) (/ (- b (* a (/ d c))) c) t_0)))))
double code(double a, double b, double c, double d) {
double t_0 = -a / d;
double tmp;
if (d <= -1.75e+83) {
tmp = t_0;
} else if (d <= -1e-58) {
tmp = fma(-a, d, (c * b)) / (d * d);
} else if (d <= 1720.0) {
tmp = (b - (a * (d / c))) / c;
} else {
tmp = t_0;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(-a) / d) tmp = 0.0 if (d <= -1.75e+83) tmp = t_0; elseif (d <= -1e-58) tmp = Float64(fma(Float64(-a), d, Float64(c * b)) / Float64(d * d)); elseif (d <= 1720.0) tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c); else tmp = t_0; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[((-a) / d), $MachinePrecision]}, If[LessEqual[d, -1.75e+83], t$95$0, If[LessEqual[d, -1e-58], N[(N[((-a) * d + N[(c * b), $MachinePrecision]), $MachinePrecision] / N[(d * d), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1720.0], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-a}{d}\\
\mathbf{if}\;d \leq -1.75 \cdot 10^{+83}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq -1 \cdot 10^{-58}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-a, d, c \cdot b\right)}{d \cdot d}\\
\mathbf{elif}\;d \leq 1720:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d < -1.74999999999999989e83 or 1720 < d Initial program 43.8%
Taylor expanded in c around 0
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6473.5
Applied rewrites73.5%
if -1.74999999999999989e83 < d < -1e-58Initial program 82.1%
Taylor expanded in c around 0
unpow2N/A
lower-*.f6461.4
Applied rewrites61.4%
lift--.f64N/A
lift-*.f64N/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
distribute-lft-neg-inN/A
+-commutativeN/A
*-commutativeN/A
distribute-lft-neg-inN/A
lift-neg.f64N/A
lower-fma.f6461.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f6461.6
Applied rewrites61.6%
if -1e-58 < d < 1720Initial program 74.3%
Taylor expanded in c around inf
lower-/.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6485.6
Applied rewrites85.6%
Applied rewrites84.6%
Final simplification77.5%
(FPCore (a b c d) :precision binary64 (if (or (<= c -1.3e+15) (not (<= c 6.2e+16))) (/ (- b (* a (/ d c))) c) (/ (- (/ (* c b) d) a) d)))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -1.3e+15) || !(c <= 6.2e+16)) {
tmp = (b - (a * (d / 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 ((c <= (-1.3d+15)) .or. (.not. (c <= 6.2d+16))) then
tmp = (b - (a * (d / 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 ((c <= -1.3e+15) || !(c <= 6.2e+16)) {
tmp = (b - (a * (d / c))) / c;
} else {
tmp = (((c * b) / d) - a) / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -1.3e+15) or not (c <= 6.2e+16): tmp = (b - (a * (d / c))) / c else: tmp = (((c * b) / d) - a) / d return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -1.3e+15) || !(c <= 6.2e+16)) tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c); else tmp = Float64(Float64(Float64(Float64(c * b) / d) - a) / d); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((c <= -1.3e+15) || ~((c <= 6.2e+16))) tmp = (b - (a * (d / c))) / c; else tmp = (((c * b) / d) - a) / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -1.3e+15], N[Not[LessEqual[c, 6.2e+16]], $MachinePrecision]], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], N[(N[(N[(N[(c * b), $MachinePrecision] / d), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.3 \cdot 10^{+15} \lor \neg \left(c \leq 6.2 \cdot 10^{+16}\right):\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{c \cdot b}{d} - a}{d}\\
\end{array}
\end{array}
if c < -1.3e15 or 6.2e16 < c Initial program 49.5%
Taylor expanded in c around inf
lower-/.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6473.1
Applied rewrites73.1%
Applied rewrites78.5%
if -1.3e15 < c < 6.2e16Initial program 73.1%
Taylor expanded in c around 0
+-commutativeN/A
fp-cancel-sign-sub-invN/A
unpow2N/A
associate-/r*N/A
metadata-evalN/A
*-lft-identityN/A
div-subN/A
lower-/.f64N/A
lower--.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6483.0
Applied rewrites83.0%
Final simplification81.0%
(FPCore (a b c d) :precision binary64 (if (or (<= d -1.9e-76) (not (<= d 1650.0))) (/ (- (* b (/ c d)) a) d) (/ (- b (/ (* d a) c)) c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -1.9e-76) || !(d <= 1650.0)) {
tmp = ((b * (c / 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 <= (-1.9d-76)) .or. (.not. (d <= 1650.0d0))) then
tmp = ((b * (c / 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 <= -1.9e-76) || !(d <= 1650.0)) {
tmp = ((b * (c / d)) - a) / d;
} else {
tmp = (b - ((d * a) / c)) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -1.9e-76) or not (d <= 1650.0): tmp = ((b * (c / d)) - a) / d else: tmp = (b - ((d * a) / c)) / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -1.9e-76) || !(d <= 1650.0)) tmp = Float64(Float64(Float64(b * Float64(c / 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 <= -1.9e-76) || ~((d <= 1650.0))) tmp = ((b * (c / d)) - a) / d; else tmp = (b - ((d * a) / c)) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -1.9e-76], N[Not[LessEqual[d, 1650.0]], $MachinePrecision]], N[(N[(N[(b * N[(c / 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 -1.9 \cdot 10^{-76} \lor \neg \left(d \leq 1650\right):\\
\;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\
\end{array}
\end{array}
if d < -1.9000000000000001e-76 or 1650 < d Initial program 52.4%
Taylor expanded in c around 0
+-commutativeN/A
fp-cancel-sign-sub-invN/A
unpow2N/A
associate-/r*N/A
metadata-evalN/A
*-lft-identityN/A
div-subN/A
lower-/.f64N/A
lower--.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6473.6
Applied rewrites73.6%
Applied rewrites76.1%
if -1.9000000000000001e-76 < d < 1650Initial program 73.9%
Taylor expanded in c around inf
lower-/.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6486.2
Applied rewrites86.2%
Final simplification80.8%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- a) d)))
(if (<= d -1.75e+83)
t_0
(if (<= d -2.7e-59)
(/ (fma (- a) d (* c b)) (* d d))
(if (<= d 9.2e-9) (/ b c) t_0)))))
double code(double a, double b, double c, double d) {
double t_0 = -a / d;
double tmp;
if (d <= -1.75e+83) {
tmp = t_0;
} else if (d <= -2.7e-59) {
tmp = fma(-a, d, (c * b)) / (d * d);
} else if (d <= 9.2e-9) {
tmp = b / c;
} else {
tmp = t_0;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(-a) / d) tmp = 0.0 if (d <= -1.75e+83) tmp = t_0; elseif (d <= -2.7e-59) tmp = Float64(fma(Float64(-a), d, Float64(c * b)) / Float64(d * d)); elseif (d <= 9.2e-9) tmp = Float64(b / c); else tmp = t_0; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[((-a) / d), $MachinePrecision]}, If[LessEqual[d, -1.75e+83], t$95$0, If[LessEqual[d, -2.7e-59], N[(N[((-a) * d + N[(c * b), $MachinePrecision]), $MachinePrecision] / N[(d * d), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 9.2e-9], N[(b / c), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-a}{d}\\
\mathbf{if}\;d \leq -1.75 \cdot 10^{+83}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq -2.7 \cdot 10^{-59}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-a, d, c \cdot b\right)}{d \cdot d}\\
\mathbf{elif}\;d \leq 9.2 \cdot 10^{-9}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d < -1.74999999999999989e83 or 9.1999999999999997e-9 < d Initial program 43.9%
Taylor expanded in c around 0
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6473.1
Applied rewrites73.1%
if -1.74999999999999989e83 < d < -2.6999999999999999e-59Initial program 82.1%
Taylor expanded in c around 0
unpow2N/A
lower-*.f6461.4
Applied rewrites61.4%
lift--.f64N/A
lift-*.f64N/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
distribute-lft-neg-inN/A
+-commutativeN/A
*-commutativeN/A
distribute-lft-neg-inN/A
lift-neg.f64N/A
lower-fma.f6461.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f6461.6
Applied rewrites61.6%
if -2.6999999999999999e-59 < d < 9.1999999999999997e-9Initial program 74.7%
Taylor expanded in c around inf
lower-/.f6473.6
Applied rewrites73.6%
Final simplification72.1%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- a) d)))
(if (<= d -4.8e+121)
t_0
(if (<= d -2.2e-64)
(* (- a) (/ d (fma d d (* c c))))
(if (<= d 9.2e-9) (/ b c) t_0)))))
double code(double a, double b, double c, double d) {
double t_0 = -a / d;
double tmp;
if (d <= -4.8e+121) {
tmp = t_0;
} else if (d <= -2.2e-64) {
tmp = -a * (d / fma(d, d, (c * c)));
} else if (d <= 9.2e-9) {
tmp = b / c;
} else {
tmp = t_0;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(-a) / d) tmp = 0.0 if (d <= -4.8e+121) tmp = t_0; elseif (d <= -2.2e-64) tmp = Float64(Float64(-a) * Float64(d / fma(d, d, Float64(c * c)))); elseif (d <= 9.2e-9) tmp = Float64(b / c); else tmp = t_0; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[((-a) / d), $MachinePrecision]}, If[LessEqual[d, -4.8e+121], t$95$0, If[LessEqual[d, -2.2e-64], N[((-a) * N[(d / N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 9.2e-9], N[(b / c), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-a}{d}\\
\mathbf{if}\;d \leq -4.8 \cdot 10^{+121}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq -2.2 \cdot 10^{-64}:\\
\;\;\;\;\left(-a\right) \cdot \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\
\mathbf{elif}\;d \leq 9.2 \cdot 10^{-9}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d < -4.8e121 or 9.1999999999999997e-9 < d Initial program 42.3%
Taylor expanded in c around 0
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6474.7
Applied rewrites74.7%
if -4.8e121 < d < -2.2e-64Initial program 77.9%
Taylor expanded in a around inf
associate-/l*N/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
+-commutativeN/A
unpow2N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6459.6
Applied rewrites59.6%
if -2.2e-64 < d < 9.1999999999999997e-9Initial program 74.7%
Taylor expanded in c around inf
lower-/.f6473.6
Applied rewrites73.6%
Final simplification72.1%
(FPCore (a b c d) :precision binary64 (if (or (<= d -3.5e-59) (not (<= d 9.2e-9))) (/ (- a) d) (/ b c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -3.5e-59) || !(d <= 9.2e-9)) {
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 <= (-3.5d-59)) .or. (.not. (d <= 9.2d-9))) 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 <= -3.5e-59) || !(d <= 9.2e-9)) {
tmp = -a / d;
} else {
tmp = b / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -3.5e-59) or not (d <= 9.2e-9): tmp = -a / d else: tmp = b / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -3.5e-59) || !(d <= 9.2e-9)) tmp = Float64(Float64(-a) / d); else tmp = Float64(b / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -3.5e-59) || ~((d <= 9.2e-9))) tmp = -a / d; else tmp = b / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -3.5e-59], N[Not[LessEqual[d, 9.2e-9]], $MachinePrecision]], N[((-a) / d), $MachinePrecision], N[(b / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -3.5 \cdot 10^{-59} \lor \neg \left(d \leq 9.2 \cdot 10^{-9}\right):\\
\;\;\;\;\frac{-a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if d < -3.5000000000000001e-59 or 9.1999999999999997e-9 < d Initial program 51.7%
Taylor expanded in c around 0
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6465.2
Applied rewrites65.2%
if -3.5000000000000001e-59 < d < 9.1999999999999997e-9Initial program 74.7%
Taylor expanded in c around inf
lower-/.f6473.6
Applied rewrites73.6%
Final simplification69.1%
(FPCore (a b c d) :precision binary64 (if (or (<= d -5.7e+160) (not (<= d 8.1e+192))) (/ a d) (/ b c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -5.7e+160) || !(d <= 8.1e+192)) {
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 <= (-5.7d+160)) .or. (.not. (d <= 8.1d+192))) 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 <= -5.7e+160) || !(d <= 8.1e+192)) {
tmp = a / d;
} else {
tmp = b / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -5.7e+160) or not (d <= 8.1e+192): tmp = a / d else: tmp = b / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -5.7e+160) || !(d <= 8.1e+192)) 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 <= -5.7e+160) || ~((d <= 8.1e+192))) tmp = a / d; else tmp = b / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -5.7e+160], N[Not[LessEqual[d, 8.1e+192]], $MachinePrecision]], N[(a / d), $MachinePrecision], N[(b / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -5.7 \cdot 10^{+160} \lor \neg \left(d \leq 8.1 \cdot 10^{+192}\right):\\
\;\;\;\;\frac{a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if d < -5.6999999999999999e160 or 8.10000000000000019e192 < d Initial program 28.2%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6428.2
Applied rewrites28.2%
Taylor expanded in c around 0
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6483.2
Applied rewrites83.2%
Applied rewrites61.6%
Applied rewrites29.5%
if -5.6999999999999999e160 < d < 8.10000000000000019e192Initial program 72.6%
Taylor expanded in c around inf
lower-/.f6454.7
Applied rewrites54.7%
Final simplification48.9%
(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%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6462.4
Applied rewrites62.4%
Taylor expanded in c around 0
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6445.0
Applied rewrites45.0%
Applied rewrites29.2%
Applied rewrites10.7%
(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 2024339
(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))))