
(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))))
(if (<= d -4.9e+60)
(* (/ (fma (pow a -1.0) (* (/ b d) c) -1.0) d) a)
(if (<= d -2.35e-160)
(/ (fma (- d) a (* c b)) t_0)
(if (<= d 2.15e-181)
(/ (- b (/ (* a d) c)) c)
(if (<= d 5.8e+137)
(fma (/ c t_0) b (* (/ a t_0) (- d)))
(/ (fma (/ c d) b (- a)) d)))))))
double code(double a, double b, double c, double d) {
double t_0 = fma(d, d, (c * c));
double tmp;
if (d <= -4.9e+60) {
tmp = (fma(pow(a, -1.0), ((b / d) * c), -1.0) / d) * a;
} else if (d <= -2.35e-160) {
tmp = fma(-d, a, (c * b)) / t_0;
} else if (d <= 2.15e-181) {
tmp = (b - ((a * d) / c)) / c;
} else if (d <= 5.8e+137) {
tmp = fma((c / t_0), b, ((a / t_0) * -d));
} else {
tmp = fma((c / d), b, -a) / d;
}
return tmp;
}
function code(a, b, c, d) t_0 = fma(d, d, Float64(c * c)) tmp = 0.0 if (d <= -4.9e+60) tmp = Float64(Float64(fma((a ^ -1.0), Float64(Float64(b / d) * c), -1.0) / d) * a); elseif (d <= -2.35e-160) tmp = Float64(fma(Float64(-d), a, Float64(c * b)) / t_0); elseif (d <= 2.15e-181) tmp = Float64(Float64(b - Float64(Float64(a * d) / c)) / c); elseif (d <= 5.8e+137) tmp = fma(Float64(c / t_0), b, Float64(Float64(a / t_0) * Float64(-d))); else tmp = Float64(fma(Float64(c / d), b, Float64(-a)) / 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, -4.9e+60], N[(N[(N[(N[Power[a, -1.0], $MachinePrecision] * N[(N[(b / d), $MachinePrecision] * c), $MachinePrecision] + -1.0), $MachinePrecision] / d), $MachinePrecision] * a), $MachinePrecision], If[LessEqual[d, -2.35e-160], N[(N[((-d) * a + N[(c * b), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision], If[LessEqual[d, 2.15e-181], N[(N[(b - N[(N[(a * d), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 5.8e+137], N[(N[(c / t$95$0), $MachinePrecision] * b + N[(N[(a / t$95$0), $MachinePrecision] * (-d)), $MachinePrecision]), $MachinePrecision], N[(N[(N[(c / d), $MachinePrecision] * b + (-a)), $MachinePrecision] / d), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(d, d, c \cdot c\right)\\
\mathbf{if}\;d \leq -4.9 \cdot 10^{+60}:\\
\;\;\;\;\frac{\mathsf{fma}\left({a}^{-1}, \frac{b}{d} \cdot c, -1\right)}{d} \cdot a\\
\mathbf{elif}\;d \leq -2.35 \cdot 10^{-160}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-d, a, c \cdot b\right)}{t\_0}\\
\mathbf{elif}\;d \leq 2.15 \cdot 10^{-181}:\\
\;\;\;\;\frac{b - \frac{a \cdot d}{c}}{c}\\
\mathbf{elif}\;d \leq 5.8 \cdot 10^{+137}:\\
\;\;\;\;\mathsf{fma}\left(\frac{c}{t\_0}, b, \frac{a}{t\_0} \cdot \left(-d\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{c}{d}, b, -a\right)}{d}\\
\end{array}
\end{array}
if d < -4.9000000000000003e60Initial program 39.3%
Taylor expanded in a around inf
*-commutativeN/A
mul-1-negN/A
neg-sub0N/A
associate-+l-N/A
unsub-negN/A
mul-1-negN/A
+-commutativeN/A
neg-sub0N/A
lower-*.f64N/A
Applied rewrites47.2%
Taylor expanded in c around 0
Applied rewrites73.1%
Applied rewrites81.1%
if -4.9000000000000003e60 < d < -2.3499999999999999e-160Initial program 92.2%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f6492.2
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6492.2
Applied rewrites92.2%
if -2.3499999999999999e-160 < d < 2.15e-181Initial program 70.3%
Taylor expanded in c around inf
lower-/.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6492.6
Applied rewrites92.6%
if 2.15e-181 < d < 5.79999999999999969e137Initial program 79.7%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sub-negN/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
Applied rewrites87.1%
if 5.79999999999999969e137 < d Initial program 30.0%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f6430.0
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6430.0
Applied rewrites30.0%
Taylor expanded in d around inf
lower-/.f64N/A
Applied rewrites94.3%
Taylor expanded in c around 0
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
unpow2N/A
associate-/r*N/A
div-subN/A
unsub-negN/A
mul-1-negN/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
associate-*l/N/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6494.3
Applied rewrites94.3%
Final simplification88.7%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (fma d d (* c c))))
(if (<= d -4.9e+60)
(* (/ (fma (/ (- c) -1.0) (/ (/ b d) a) -1.0) d) a)
(if (<= d -2.35e-160)
(/ (fma (- d) a (* c b)) t_0)
(if (<= d 2.15e-181)
(/ (- b (/ (* a d) c)) c)
(if (<= d 5.8e+137)
(fma (/ c t_0) b (* (/ a t_0) (- d)))
(/ (fma (/ c d) b (- a)) d)))))))
double code(double a, double b, double c, double d) {
double t_0 = fma(d, d, (c * c));
double tmp;
if (d <= -4.9e+60) {
tmp = (fma((-c / -1.0), ((b / d) / a), -1.0) / d) * a;
} else if (d <= -2.35e-160) {
tmp = fma(-d, a, (c * b)) / t_0;
} else if (d <= 2.15e-181) {
tmp = (b - ((a * d) / c)) / c;
} else if (d <= 5.8e+137) {
tmp = fma((c / t_0), b, ((a / t_0) * -d));
} else {
tmp = fma((c / d), b, -a) / d;
}
return tmp;
}
function code(a, b, c, d) t_0 = fma(d, d, Float64(c * c)) tmp = 0.0 if (d <= -4.9e+60) tmp = Float64(Float64(fma(Float64(Float64(-c) / -1.0), Float64(Float64(b / d) / a), -1.0) / d) * a); elseif (d <= -2.35e-160) tmp = Float64(fma(Float64(-d), a, Float64(c * b)) / t_0); elseif (d <= 2.15e-181) tmp = Float64(Float64(b - Float64(Float64(a * d) / c)) / c); elseif (d <= 5.8e+137) tmp = fma(Float64(c / t_0), b, Float64(Float64(a / t_0) * Float64(-d))); else tmp = Float64(fma(Float64(c / d), b, Float64(-a)) / 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, -4.9e+60], N[(N[(N[(N[((-c) / -1.0), $MachinePrecision] * N[(N[(b / d), $MachinePrecision] / a), $MachinePrecision] + -1.0), $MachinePrecision] / d), $MachinePrecision] * a), $MachinePrecision], If[LessEqual[d, -2.35e-160], N[(N[((-d) * a + N[(c * b), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision], If[LessEqual[d, 2.15e-181], N[(N[(b - N[(N[(a * d), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 5.8e+137], N[(N[(c / t$95$0), $MachinePrecision] * b + N[(N[(a / t$95$0), $MachinePrecision] * (-d)), $MachinePrecision]), $MachinePrecision], N[(N[(N[(c / d), $MachinePrecision] * b + (-a)), $MachinePrecision] / d), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(d, d, c \cdot c\right)\\
\mathbf{if}\;d \leq -4.9 \cdot 10^{+60}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{-c}{-1}, \frac{\frac{b}{d}}{a}, -1\right)}{d} \cdot a\\
\mathbf{elif}\;d \leq -2.35 \cdot 10^{-160}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-d, a, c \cdot b\right)}{t\_0}\\
\mathbf{elif}\;d \leq 2.15 \cdot 10^{-181}:\\
\;\;\;\;\frac{b - \frac{a \cdot d}{c}}{c}\\
\mathbf{elif}\;d \leq 5.8 \cdot 10^{+137}:\\
\;\;\;\;\mathsf{fma}\left(\frac{c}{t\_0}, b, \frac{a}{t\_0} \cdot \left(-d\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{c}{d}, b, -a\right)}{d}\\
\end{array}
\end{array}
if d < -4.9000000000000003e60Initial program 39.3%
Taylor expanded in a around inf
*-commutativeN/A
mul-1-negN/A
neg-sub0N/A
associate-+l-N/A
unsub-negN/A
mul-1-negN/A
+-commutativeN/A
neg-sub0N/A
lower-*.f64N/A
Applied rewrites47.2%
Taylor expanded in c around 0
Applied rewrites73.1%
Applied rewrites79.4%
if -4.9000000000000003e60 < d < -2.3499999999999999e-160Initial program 92.2%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f6492.2
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6492.2
Applied rewrites92.2%
if -2.3499999999999999e-160 < d < 2.15e-181Initial program 70.3%
Taylor expanded in c around inf
lower-/.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6492.6
Applied rewrites92.6%
if 2.15e-181 < d < 5.79999999999999969e137Initial program 79.7%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sub-negN/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
Applied rewrites87.1%
if 5.79999999999999969e137 < d Initial program 30.0%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f6430.0
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6430.0
Applied rewrites30.0%
Taylor expanded in d around inf
lower-/.f64N/A
Applied rewrites94.3%
Taylor expanded in c around 0
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
unpow2N/A
associate-/r*N/A
div-subN/A
unsub-negN/A
mul-1-negN/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
associate-*l/N/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6494.3
Applied rewrites94.3%
Final simplification88.3%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (fma d d (* c c))))
(if (<= d -4.9e+60)
(* (/ (fma (/ (- c) -1.0) (/ (/ b d) a) -1.0) d) a)
(if (<= d -2.35e-160)
(/ (fma (- d) a (* c b)) t_0)
(if (<= d 2.6e-115)
(/ (- b (/ (* a d) c)) c)
(if (<= d 5.6e+93)
(* (/ -1.0 t_0) (fma (- b) c (* a d)))
(/ (fma (/ c d) b (- a)) d)))))))
double code(double a, double b, double c, double d) {
double t_0 = fma(d, d, (c * c));
double tmp;
if (d <= -4.9e+60) {
tmp = (fma((-c / -1.0), ((b / d) / a), -1.0) / d) * a;
} else if (d <= -2.35e-160) {
tmp = fma(-d, a, (c * b)) / t_0;
} else if (d <= 2.6e-115) {
tmp = (b - ((a * d) / c)) / c;
} else if (d <= 5.6e+93) {
tmp = (-1.0 / t_0) * fma(-b, c, (a * d));
} else {
tmp = fma((c / d), b, -a) / d;
}
return tmp;
}
function code(a, b, c, d) t_0 = fma(d, d, Float64(c * c)) tmp = 0.0 if (d <= -4.9e+60) tmp = Float64(Float64(fma(Float64(Float64(-c) / -1.0), Float64(Float64(b / d) / a), -1.0) / d) * a); elseif (d <= -2.35e-160) tmp = Float64(fma(Float64(-d), a, Float64(c * b)) / t_0); elseif (d <= 2.6e-115) tmp = Float64(Float64(b - Float64(Float64(a * d) / c)) / c); elseif (d <= 5.6e+93) tmp = Float64(Float64(-1.0 / t_0) * fma(Float64(-b), c, Float64(a * d))); else tmp = Float64(fma(Float64(c / d), b, Float64(-a)) / 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, -4.9e+60], N[(N[(N[(N[((-c) / -1.0), $MachinePrecision] * N[(N[(b / d), $MachinePrecision] / a), $MachinePrecision] + -1.0), $MachinePrecision] / d), $MachinePrecision] * a), $MachinePrecision], If[LessEqual[d, -2.35e-160], N[(N[((-d) * a + N[(c * b), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision], If[LessEqual[d, 2.6e-115], N[(N[(b - N[(N[(a * d), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 5.6e+93], N[(N[(-1.0 / t$95$0), $MachinePrecision] * N[((-b) * c + N[(a * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(c / d), $MachinePrecision] * b + (-a)), $MachinePrecision] / d), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(d, d, c \cdot c\right)\\
\mathbf{if}\;d \leq -4.9 \cdot 10^{+60}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{-c}{-1}, \frac{\frac{b}{d}}{a}, -1\right)}{d} \cdot a\\
\mathbf{elif}\;d \leq -2.35 \cdot 10^{-160}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-d, a, c \cdot b\right)}{t\_0}\\
\mathbf{elif}\;d \leq 2.6 \cdot 10^{-115}:\\
\;\;\;\;\frac{b - \frac{a \cdot d}{c}}{c}\\
\mathbf{elif}\;d \leq 5.6 \cdot 10^{+93}:\\
\;\;\;\;\frac{-1}{t\_0} \cdot \mathsf{fma}\left(-b, c, a \cdot d\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{c}{d}, b, -a\right)}{d}\\
\end{array}
\end{array}
if d < -4.9000000000000003e60Initial program 39.3%
Taylor expanded in a around inf
*-commutativeN/A
mul-1-negN/A
neg-sub0N/A
associate-+l-N/A
unsub-negN/A
mul-1-negN/A
+-commutativeN/A
neg-sub0N/A
lower-*.f64N/A
Applied rewrites47.2%
Taylor expanded in c around 0
Applied rewrites73.1%
Applied rewrites79.4%
if -4.9000000000000003e60 < d < -2.3499999999999999e-160Initial program 92.2%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f6492.2
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6492.2
Applied rewrites92.2%
if -2.3499999999999999e-160 < d < 2.60000000000000004e-115Initial program 73.2%
Taylor expanded in c around inf
lower-/.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6492.5
Applied rewrites92.5%
if 2.60000000000000004e-115 < d < 5.59999999999999978e93Initial program 87.6%
lift-/.f64N/A
frac-2negN/A
div-invN/A
lower-*.f64N/A
lift--.f64N/A
sub-negN/A
distribute-neg-inN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
remove-double-negN/A
lower-fma.f64N/A
lower-neg.f64N/A
neg-mul-1N/A
associate-/r*N/A
metadata-evalN/A
lower-/.f6487.6
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6487.6
Applied rewrites87.6%
if 5.59999999999999978e93 < d Initial program 35.1%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f6435.1
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6435.1
Applied rewrites35.1%
Taylor expanded in d around inf
lower-/.f64N/A
Applied rewrites86.7%
Taylor expanded in c around 0
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
unpow2N/A
associate-/r*N/A
div-subN/A
unsub-negN/A
mul-1-negN/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
associate-*l/N/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6486.8
Applied rewrites86.8%
Final simplification87.7%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (fma d d (* c c))) (t_1 (/ (fma (/ c d) b (- a)) d)))
(if (<= d -4.9e+60)
t_1
(if (<= d -2.35e-160)
(/ (fma (- d) a (* c b)) t_0)
(if (<= d 2.6e-115)
(/ (- b (/ (* a d) c)) c)
(if (<= d 5.6e+93) (* (/ -1.0 t_0) (fma (- b) c (* a d))) t_1))))))
double code(double a, double b, double c, double d) {
double t_0 = fma(d, d, (c * c));
double t_1 = fma((c / d), b, -a) / d;
double tmp;
if (d <= -4.9e+60) {
tmp = t_1;
} else if (d <= -2.35e-160) {
tmp = fma(-d, a, (c * b)) / t_0;
} else if (d <= 2.6e-115) {
tmp = (b - ((a * d) / c)) / c;
} else if (d <= 5.6e+93) {
tmp = (-1.0 / t_0) * fma(-b, c, (a * d));
} else {
tmp = t_1;
}
return tmp;
}
function code(a, b, c, d) t_0 = fma(d, d, Float64(c * c)) t_1 = Float64(fma(Float64(c / d), b, Float64(-a)) / d) tmp = 0.0 if (d <= -4.9e+60) tmp = t_1; elseif (d <= -2.35e-160) tmp = Float64(fma(Float64(-d), a, Float64(c * b)) / t_0); elseif (d <= 2.6e-115) tmp = Float64(Float64(b - Float64(Float64(a * d) / c)) / c); elseif (d <= 5.6e+93) tmp = Float64(Float64(-1.0 / t_0) * fma(Float64(-b), c, Float64(a * 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[(c / d), $MachinePrecision] * b + (-a)), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -4.9e+60], t$95$1, If[LessEqual[d, -2.35e-160], N[(N[((-d) * a + N[(c * b), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision], If[LessEqual[d, 2.6e-115], N[(N[(b - N[(N[(a * d), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 5.6e+93], N[(N[(-1.0 / t$95$0), $MachinePrecision] * N[((-b) * c + N[(a * 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{\mathsf{fma}\left(\frac{c}{d}, b, -a\right)}{d}\\
\mathbf{if}\;d \leq -4.9 \cdot 10^{+60}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d \leq -2.35 \cdot 10^{-160}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-d, a, c \cdot b\right)}{t\_0}\\
\mathbf{elif}\;d \leq 2.6 \cdot 10^{-115}:\\
\;\;\;\;\frac{b - \frac{a \cdot d}{c}}{c}\\
\mathbf{elif}\;d \leq 5.6 \cdot 10^{+93}:\\
\;\;\;\;\frac{-1}{t\_0} \cdot \mathsf{fma}\left(-b, c, a \cdot d\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if d < -4.9000000000000003e60 or 5.59999999999999978e93 < d Initial program 37.5%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f6437.5
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6437.5
Applied rewrites37.5%
Taylor expanded in d around inf
lower-/.f64N/A
Applied rewrites81.8%
Taylor expanded in c around 0
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
unpow2N/A
associate-/r*N/A
div-subN/A
unsub-negN/A
mul-1-negN/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
associate-*l/N/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6482.1
Applied rewrites82.1%
if -4.9000000000000003e60 < d < -2.3499999999999999e-160Initial program 92.2%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f6492.2
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6492.2
Applied rewrites92.2%
if -2.3499999999999999e-160 < d < 2.60000000000000004e-115Initial program 73.2%
Taylor expanded in c around inf
lower-/.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6492.5
Applied rewrites92.5%
if 2.60000000000000004e-115 < d < 5.59999999999999978e93Initial program 87.6%
lift-/.f64N/A
frac-2negN/A
div-invN/A
lower-*.f64N/A
lift--.f64N/A
sub-negN/A
distribute-neg-inN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
remove-double-negN/A
lower-fma.f64N/A
lower-neg.f64N/A
neg-mul-1N/A
associate-/r*N/A
metadata-evalN/A
lower-/.f6487.6
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6487.6
Applied rewrites87.6%
Final simplification87.5%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (fma (- d) a (* c b)) (fma d d (* c c))))
(t_1 (/ (fma (/ c d) b (- a)) d)))
(if (<= d -4.9e+60)
t_1
(if (<= d -2.35e-160)
t_0
(if (<= d 2.6e-115)
(/ (- b (/ (* a d) c)) c)
(if (<= d 5.6e+93) t_0 t_1))))))
double code(double a, double b, double c, double d) {
double t_0 = fma(-d, a, (c * b)) / fma(d, d, (c * c));
double t_1 = fma((c / d), b, -a) / d;
double tmp;
if (d <= -4.9e+60) {
tmp = t_1;
} else if (d <= -2.35e-160) {
tmp = t_0;
} else if (d <= 2.6e-115) {
tmp = (b - ((a * d) / c)) / c;
} else if (d <= 5.6e+93) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(fma(Float64(-d), a, Float64(c * b)) / fma(d, d, Float64(c * c))) t_1 = Float64(fma(Float64(c / d), b, Float64(-a)) / d) tmp = 0.0 if (d <= -4.9e+60) tmp = t_1; elseif (d <= -2.35e-160) tmp = t_0; elseif (d <= 2.6e-115) tmp = Float64(Float64(b - Float64(Float64(a * d) / c)) / c); elseif (d <= 5.6e+93) tmp = t_0; else tmp = t_1; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[((-d) * a + N[(c * b), $MachinePrecision]), $MachinePrecision] / N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(c / d), $MachinePrecision] * b + (-a)), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -4.9e+60], t$95$1, If[LessEqual[d, -2.35e-160], t$95$0, If[LessEqual[d, 2.6e-115], N[(N[(b - N[(N[(a * d), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 5.6e+93], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\mathsf{fma}\left(-d, a, c \cdot b\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\
t_1 := \frac{\mathsf{fma}\left(\frac{c}{d}, b, -a\right)}{d}\\
\mathbf{if}\;d \leq -4.9 \cdot 10^{+60}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d \leq -2.35 \cdot 10^{-160}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 2.6 \cdot 10^{-115}:\\
\;\;\;\;\frac{b - \frac{a \cdot d}{c}}{c}\\
\mathbf{elif}\;d \leq 5.6 \cdot 10^{+93}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if d < -4.9000000000000003e60 or 5.59999999999999978e93 < d Initial program 37.5%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f6437.5
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6437.5
Applied rewrites37.5%
Taylor expanded in d around inf
lower-/.f64N/A
Applied rewrites81.8%
Taylor expanded in c around 0
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
unpow2N/A
associate-/r*N/A
div-subN/A
unsub-negN/A
mul-1-negN/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
associate-*l/N/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6482.1
Applied rewrites82.1%
if -4.9000000000000003e60 < d < -2.3499999999999999e-160 or 2.60000000000000004e-115 < d < 5.59999999999999978e93Initial program 89.8%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f6489.8
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6489.8
Applied rewrites89.8%
if -2.3499999999999999e-160 < d < 2.60000000000000004e-115Initial program 73.2%
Taylor expanded in c around inf
lower-/.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6492.5
Applied rewrites92.5%
Final simplification87.5%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- a) d)) (t_1 (- (* c b) (* a d))))
(if (<= d -2.2e+29)
t_0
(if (<= d -4.4e-66)
(/ t_1 (* d d))
(if (<= d 3.4e-34)
(/ t_1 (* c c))
(if (<= d 2.8e+46) (* (/ c (fma c c (* d d))) b) t_0))))))
double code(double a, double b, double c, double d) {
double t_0 = -a / d;
double t_1 = (c * b) - (a * d);
double tmp;
if (d <= -2.2e+29) {
tmp = t_0;
} else if (d <= -4.4e-66) {
tmp = t_1 / (d * d);
} else if (d <= 3.4e-34) {
tmp = t_1 / (c * c);
} else if (d <= 2.8e+46) {
tmp = (c / fma(c, c, (d * d))) * b;
} else {
tmp = t_0;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(-a) / d) t_1 = Float64(Float64(c * b) - Float64(a * d)) tmp = 0.0 if (d <= -2.2e+29) tmp = t_0; elseif (d <= -4.4e-66) tmp = Float64(t_1 / Float64(d * d)); elseif (d <= 3.4e-34) tmp = Float64(t_1 / Float64(c * c)); elseif (d <= 2.8e+46) tmp = Float64(Float64(c / fma(c, c, Float64(d * d))) * b); else tmp = t_0; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[((-a) / d), $MachinePrecision]}, Block[{t$95$1 = N[(N[(c * b), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -2.2e+29], t$95$0, If[LessEqual[d, -4.4e-66], N[(t$95$1 / N[(d * d), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 3.4e-34], N[(t$95$1 / N[(c * c), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.8e+46], N[(N[(c / N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision], t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-a}{d}\\
t_1 := c \cdot b - a \cdot d\\
\mathbf{if}\;d \leq -2.2 \cdot 10^{+29}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq -4.4 \cdot 10^{-66}:\\
\;\;\;\;\frac{t\_1}{d \cdot d}\\
\mathbf{elif}\;d \leq 3.4 \cdot 10^{-34}:\\
\;\;\;\;\frac{t\_1}{c \cdot c}\\
\mathbf{elif}\;d \leq 2.8 \cdot 10^{+46}:\\
\;\;\;\;\frac{c}{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot b\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d < -2.2000000000000001e29 or 2.80000000000000018e46 < d Initial program 43.2%
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.9
Applied rewrites73.9%
if -2.2000000000000001e29 < d < -4.4000000000000002e-66Initial program 88.8%
Taylor expanded in c around 0
unpow2N/A
lower-*.f6475.9
Applied rewrites75.9%
if -4.4000000000000002e-66 < d < 3.4000000000000001e-34Initial program 80.9%
Taylor expanded in c around inf
unpow2N/A
lower-*.f6468.0
Applied rewrites68.0%
if 3.4000000000000001e-34 < d < 2.80000000000000018e46Initial program 76.6%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f6476.6
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6476.6
Applied rewrites76.6%
Taylor expanded in a around 0
*-commutativeN/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6465.9
Applied rewrites65.9%
Final simplification71.0%
(FPCore (a b c d)
:precision binary64
(if (<= c -2.9e+82)
(/ b c)
(if (<= c -2.1e-22)
(/ (- (* c b) (* a d)) (* c c))
(if (<= c 46000.0) (/ (fma (/ c d) b (- a)) d) (/ b c)))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -2.9e+82) {
tmp = b / c;
} else if (c <= -2.1e-22) {
tmp = ((c * b) - (a * d)) / (c * c);
} else if (c <= 46000.0) {
tmp = fma((c / d), b, -a) / d;
} else {
tmp = b / c;
}
return tmp;
}
function code(a, b, c, d) tmp = 0.0 if (c <= -2.9e+82) tmp = Float64(b / c); elseif (c <= -2.1e-22) tmp = Float64(Float64(Float64(c * b) - Float64(a * d)) / Float64(c * c)); elseif (c <= 46000.0) tmp = Float64(fma(Float64(c / d), b, Float64(-a)) / d); else tmp = Float64(b / c); end return tmp end
code[a_, b_, c_, d_] := If[LessEqual[c, -2.9e+82], N[(b / c), $MachinePrecision], If[LessEqual[c, -2.1e-22], N[(N[(N[(c * b), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(c * c), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 46000.0], N[(N[(N[(c / d), $MachinePrecision] * b + (-a)), $MachinePrecision] / d), $MachinePrecision], N[(b / c), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -2.9 \cdot 10^{+82}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{elif}\;c \leq -2.1 \cdot 10^{-22}:\\
\;\;\;\;\frac{c \cdot b - a \cdot d}{c \cdot c}\\
\mathbf{elif}\;c \leq 46000:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{c}{d}, b, -a\right)}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if c < -2.9000000000000001e82 or 46000 < c Initial program 44.8%
Taylor expanded in c around inf
lower-/.f6469.4
Applied rewrites69.4%
if -2.9000000000000001e82 < c < -2.10000000000000008e-22Initial program 74.4%
Taylor expanded in c around inf
unpow2N/A
lower-*.f6466.3
Applied rewrites66.3%
if -2.10000000000000008e-22 < c < 46000Initial program 76.1%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f6476.1
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6476.1
Applied rewrites76.1%
Taylor expanded in d around inf
lower-/.f64N/A
Applied rewrites82.2%
Taylor expanded in c around 0
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
unpow2N/A
associate-/r*N/A
div-subN/A
unsub-negN/A
mul-1-negN/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
associate-*l/N/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6484.1
Applied rewrites84.1%
Final simplification76.8%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- a) d)))
(if (<= d -2.1e-52)
t_0
(if (<= d 3.4e-34)
(/ (- (* c b) (* a d)) (* c c))
(if (<= d 2.8e+46) (* (/ c (fma c c (* d d))) b) t_0)))))
double code(double a, double b, double c, double d) {
double t_0 = -a / d;
double tmp;
if (d <= -2.1e-52) {
tmp = t_0;
} else if (d <= 3.4e-34) {
tmp = ((c * b) - (a * d)) / (c * c);
} else if (d <= 2.8e+46) {
tmp = (c / fma(c, c, (d * d))) * b;
} else {
tmp = t_0;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(-a) / d) tmp = 0.0 if (d <= -2.1e-52) tmp = t_0; elseif (d <= 3.4e-34) tmp = Float64(Float64(Float64(c * b) - Float64(a * d)) / Float64(c * c)); elseif (d <= 2.8e+46) tmp = Float64(Float64(c / fma(c, c, Float64(d * d))) * b); else tmp = t_0; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[((-a) / d), $MachinePrecision]}, If[LessEqual[d, -2.1e-52], t$95$0, If[LessEqual[d, 3.4e-34], N[(N[(N[(c * b), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(c * c), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.8e+46], N[(N[(c / N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-a}{d}\\
\mathbf{if}\;d \leq -2.1 \cdot 10^{-52}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 3.4 \cdot 10^{-34}:\\
\;\;\;\;\frac{c \cdot b - a \cdot d}{c \cdot c}\\
\mathbf{elif}\;d \leq 2.8 \cdot 10^{+46}:\\
\;\;\;\;\frac{c}{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot b\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d < -2.0999999999999999e-52 or 2.80000000000000018e46 < d Initial program 48.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.f6470.3
Applied rewrites70.3%
if -2.0999999999999999e-52 < d < 3.4000000000000001e-34Initial program 81.0%
Taylor expanded in c around inf
unpow2N/A
lower-*.f6467.4
Applied rewrites67.4%
if 3.4000000000000001e-34 < d < 2.80000000000000018e46Initial program 76.6%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f6476.6
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6476.6
Applied rewrites76.6%
Taylor expanded in a around 0
*-commutativeN/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6465.9
Applied rewrites65.9%
Final simplification68.8%
(FPCore (a b c d)
:precision binary64
(if (<= c -2.7e-22)
(/ b c)
(if (<= c 1.45e-86)
(/ (- a) d)
(if (<= c 1.1e+38) (/ (* c b) (fma d d (* c c))) (/ b c)))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -2.7e-22) {
tmp = b / c;
} else if (c <= 1.45e-86) {
tmp = -a / d;
} else if (c <= 1.1e+38) {
tmp = (c * b) / fma(d, d, (c * c));
} else {
tmp = b / c;
}
return tmp;
}
function code(a, b, c, d) tmp = 0.0 if (c <= -2.7e-22) tmp = Float64(b / c); elseif (c <= 1.45e-86) tmp = Float64(Float64(-a) / d); elseif (c <= 1.1e+38) tmp = Float64(Float64(c * b) / fma(d, d, Float64(c * c))); else tmp = Float64(b / c); end return tmp end
code[a_, b_, c_, d_] := If[LessEqual[c, -2.7e-22], N[(b / c), $MachinePrecision], If[LessEqual[c, 1.45e-86], N[((-a) / d), $MachinePrecision], If[LessEqual[c, 1.1e+38], N[(N[(c * b), $MachinePrecision] / N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(b / c), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -2.7 \cdot 10^{-22}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{elif}\;c \leq 1.45 \cdot 10^{-86}:\\
\;\;\;\;\frac{-a}{d}\\
\mathbf{elif}\;c \leq 1.1 \cdot 10^{+38}:\\
\;\;\;\;\frac{c \cdot b}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if c < -2.7000000000000002e-22 or 1.10000000000000003e38 < c Initial program 46.0%
Taylor expanded in c around inf
lower-/.f6465.7
Applied rewrites65.7%
if -2.7000000000000002e-22 < c < 1.45e-86Initial program 74.5%
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.f6471.7
Applied rewrites71.7%
if 1.45e-86 < c < 1.10000000000000003e38Initial program 89.0%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f6489.0
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6489.0
Applied rewrites89.0%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f6460.9
Applied rewrites60.9%
Final simplification67.7%
(FPCore (a b c d)
:precision binary64
(if (<= c -2.7e-22)
(/ b c)
(if (<= c 1.45e-86)
(/ (- a) d)
(if (<= c 1.65e+103) (* (/ c (fma c c (* d d))) b) (/ b c)))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -2.7e-22) {
tmp = b / c;
} else if (c <= 1.45e-86) {
tmp = -a / d;
} else if (c <= 1.65e+103) {
tmp = (c / fma(c, c, (d * d))) * b;
} else {
tmp = b / c;
}
return tmp;
}
function code(a, b, c, d) tmp = 0.0 if (c <= -2.7e-22) tmp = Float64(b / c); elseif (c <= 1.45e-86) tmp = Float64(Float64(-a) / d); elseif (c <= 1.65e+103) tmp = Float64(Float64(c / fma(c, c, Float64(d * d))) * b); else tmp = Float64(b / c); end return tmp end
code[a_, b_, c_, d_] := If[LessEqual[c, -2.7e-22], N[(b / c), $MachinePrecision], If[LessEqual[c, 1.45e-86], N[((-a) / d), $MachinePrecision], If[LessEqual[c, 1.65e+103], N[(N[(c / N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision], N[(b / c), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -2.7 \cdot 10^{-22}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{elif}\;c \leq 1.45 \cdot 10^{-86}:\\
\;\;\;\;\frac{-a}{d}\\
\mathbf{elif}\;c \leq 1.65 \cdot 10^{+103}:\\
\;\;\;\;\frac{c}{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot b\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if c < -2.7000000000000002e-22 or 1.65000000000000004e103 < c Initial program 44.0%
Taylor expanded in c around inf
lower-/.f6465.8
Applied rewrites65.8%
if -2.7000000000000002e-22 < c < 1.45e-86Initial program 74.5%
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.f6471.7
Applied rewrites71.7%
if 1.45e-86 < c < 1.65000000000000004e103Initial program 82.7%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f6482.7
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6482.7
Applied rewrites82.7%
Taylor expanded in a around 0
*-commutativeN/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6461.9
Applied rewrites61.9%
Final simplification67.7%
(FPCore (a b c d) :precision binary64 (let* ((t_0 (/ (fma (/ c d) b (- a)) d))) (if (<= d -2.4e-58) t_0 (if (<= d 4.5e+62) (/ (- b (/ (* a d) c)) c) t_0))))
double code(double a, double b, double c, double d) {
double t_0 = fma((c / d), b, -a) / d;
double tmp;
if (d <= -2.4e-58) {
tmp = t_0;
} else if (d <= 4.5e+62) {
tmp = (b - ((a * d) / c)) / c;
} else {
tmp = t_0;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(fma(Float64(c / d), b, Float64(-a)) / d) tmp = 0.0 if (d <= -2.4e-58) tmp = t_0; elseif (d <= 4.5e+62) tmp = Float64(Float64(b - Float64(Float64(a * d) / c)) / c); else tmp = t_0; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(c / d), $MachinePrecision] * b + (-a)), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -2.4e-58], t$95$0, If[LessEqual[d, 4.5e+62], N[(N[(b - N[(N[(a * d), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\mathsf{fma}\left(\frac{c}{d}, b, -a\right)}{d}\\
\mathbf{if}\;d \leq -2.4 \cdot 10^{-58}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 4.5 \cdot 10^{+62}:\\
\;\;\;\;\frac{b - \frac{a \cdot d}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d < -2.4000000000000001e-58 or 4.49999999999999999e62 < d Initial program 48.3%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f6448.3
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6448.3
Applied rewrites48.3%
Taylor expanded in d around inf
lower-/.f64N/A
Applied rewrites79.6%
Taylor expanded in c around 0
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
unpow2N/A
associate-/r*N/A
div-subN/A
unsub-negN/A
mul-1-negN/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
associate-*l/N/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6479.9
Applied rewrites79.9%
if -2.4000000000000001e-58 < d < 4.49999999999999999e62Initial program 79.9%
Taylor expanded in c around inf
lower-/.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6479.4
Applied rewrites79.4%
(FPCore (a b c d) :precision binary64 (if (<= c -2.7e-22) (/ b c) (if (<= c 11200.0) (/ (- a) d) (/ b c))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -2.7e-22) {
tmp = b / c;
} else if (c <= 11200.0) {
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 <= (-2.7d-22)) then
tmp = b / c
else if (c <= 11200.0d0) 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 <= -2.7e-22) {
tmp = b / c;
} else if (c <= 11200.0) {
tmp = -a / d;
} else {
tmp = b / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -2.7e-22: tmp = b / c elif c <= 11200.0: tmp = -a / d else: tmp = b / c return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -2.7e-22) tmp = Float64(b / c); elseif (c <= 11200.0) 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 <= -2.7e-22) tmp = b / c; elseif (c <= 11200.0) tmp = -a / d; else tmp = b / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -2.7e-22], N[(b / c), $MachinePrecision], If[LessEqual[c, 11200.0], N[((-a) / d), $MachinePrecision], N[(b / c), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -2.7 \cdot 10^{-22}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{elif}\;c \leq 11200:\\
\;\;\;\;\frac{-a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if c < -2.7000000000000002e-22 or 11200 < c Initial program 50.4%
Taylor expanded in c around inf
lower-/.f6464.9
Applied rewrites64.9%
if -2.7000000000000002e-22 < c < 11200Initial program 76.1%
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.f6466.5
Applied rewrites66.5%
Final simplification65.7%
(FPCore (a b c d) :precision binary64 (/ b c))
double code(double a, double b, double c, double d) {
return b / c;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = b / c
end function
public static double code(double a, double b, double c, double d) {
return b / c;
}
def code(a, b, c, d): return b / c
function code(a, b, c, d) return Float64(b / c) end
function tmp = code(a, b, c, d) tmp = b / c; end
code[a_, b_, c_, d_] := N[(b / c), $MachinePrecision]
\begin{array}{l}
\\
\frac{b}{c}
\end{array}
Initial program 63.9%
Taylor expanded in c around inf
lower-/.f6439.6
Applied rewrites39.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 2024332
(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))))