
(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 (/ d t_0) (/ -1.0 (/ 1.0 a)) (* (/ c t_0) b))))
(if (<= d -2.05e+96)
(/ (fma c (/ b d) (- a)) d)
(if (<= d -3e-126)
t_1
(if (<= d 1.65e-137)
(/ (- b (/ (* a d) c)) c)
(if (<= d 3.3e+129) t_1 (/ (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 t_1 = fma((d / t_0), (-1.0 / (1.0 / a)), ((c / t_0) * b));
double tmp;
if (d <= -2.05e+96) {
tmp = fma(c, (b / d), -a) / d;
} else if (d <= -3e-126) {
tmp = t_1;
} else if (d <= 1.65e-137) {
tmp = (b - ((a * d) / c)) / c;
} else if (d <= 3.3e+129) {
tmp = t_1;
} else {
tmp = fma((c / d), b, -a) / d;
}
return tmp;
}
function code(a, b, c, d) t_0 = fma(d, d, Float64(c * c)) t_1 = fma(Float64(d / t_0), Float64(-1.0 / Float64(1.0 / a)), Float64(Float64(c / t_0) * b)) tmp = 0.0 if (d <= -2.05e+96) tmp = Float64(fma(c, Float64(b / d), Float64(-a)) / d); elseif (d <= -3e-126) tmp = t_1; elseif (d <= 1.65e-137) tmp = Float64(Float64(b - Float64(Float64(a * d) / c)) / c); elseif (d <= 3.3e+129) tmp = t_1; 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]}, Block[{t$95$1 = N[(N[(d / t$95$0), $MachinePrecision] * N[(-1.0 / N[(1.0 / a), $MachinePrecision]), $MachinePrecision] + N[(N[(c / t$95$0), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -2.05e+96], N[(N[(c * N[(b / d), $MachinePrecision] + (-a)), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, -3e-126], t$95$1, If[LessEqual[d, 1.65e-137], N[(N[(b - N[(N[(a * d), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 3.3e+129], t$95$1, 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)\\
t_1 := \mathsf{fma}\left(\frac{d}{t\_0}, \frac{-1}{\frac{1}{a}}, \frac{c}{t\_0} \cdot b\right)\\
\mathbf{if}\;d \leq -2.05 \cdot 10^{+96}:\\
\;\;\;\;\frac{\mathsf{fma}\left(c, \frac{b}{d}, -a\right)}{d}\\
\mathbf{elif}\;d \leq -3 \cdot 10^{-126}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d \leq 1.65 \cdot 10^{-137}:\\
\;\;\;\;\frac{b - \frac{a \cdot d}{c}}{c}\\
\mathbf{elif}\;d \leq 3.3 \cdot 10^{+129}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{c}{d}, b, -a\right)}{d}\\
\end{array}
\end{array}
if d < -2.04999999999999999e96Initial program 30.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
lower-/.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6481.8
Applied rewrites81.8%
Applied rewrites90.1%
if -2.04999999999999999e96 < d < -3.0000000000000002e-126 or 1.6500000000000001e-137 < d < 3.2999999999999999e129Initial program 75.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
distribute-lft-neg-inN/A
lower-*.f64N/A
Applied rewrites80.9%
lift-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
lift-neg.f64N/A
neg-mul-1N/A
*-commutativeN/A
div-invN/A
times-fracN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6484.8
Applied rewrites84.8%
if -3.0000000000000002e-126 < d < 1.6500000000000001e-137Initial program 73.8%
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 3.2999999999999999e129 < d Initial program 23.8%
Taylor expanded in c around inf
lower-/.f6413.3
Applied rewrites13.3%
Taylor expanded in d around inf
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.1
Applied rewrites94.1%
Final simplification89.4%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (fma d d (* c c))))
(if (<= d -1.25e+57)
(/ (fma c (/ b d) (- a)) d)
(if (<= d -1.28e-79)
(/ (fma (- d) a (* c b)) t_0)
(if (<= d 3.6e-147)
(/ (- b (/ (* a d) c)) c)
(if (<= d 3.3e+128)
(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 <= -1.25e+57) {
tmp = fma(c, (b / d), -a) / d;
} else if (d <= -1.28e-79) {
tmp = fma(-d, a, (c * b)) / t_0;
} else if (d <= 3.6e-147) {
tmp = (b - ((a * d) / c)) / c;
} else if (d <= 3.3e+128) {
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 <= -1.25e+57) tmp = Float64(fma(c, Float64(b / d), Float64(-a)) / d); elseif (d <= -1.28e-79) tmp = Float64(fma(Float64(-d), a, Float64(c * b)) / t_0); elseif (d <= 3.6e-147) tmp = Float64(Float64(b - Float64(Float64(a * d) / c)) / c); elseif (d <= 3.3e+128) 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, -1.25e+57], N[(N[(c * N[(b / d), $MachinePrecision] + (-a)), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, -1.28e-79], N[(N[((-d) * a + N[(c * b), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision], If[LessEqual[d, 3.6e-147], N[(N[(b - N[(N[(a * d), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 3.3e+128], 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 -1.25 \cdot 10^{+57}:\\
\;\;\;\;\frac{\mathsf{fma}\left(c, \frac{b}{d}, -a\right)}{d}\\
\mathbf{elif}\;d \leq -1.28 \cdot 10^{-79}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-d, a, c \cdot b\right)}{t\_0}\\
\mathbf{elif}\;d \leq 3.6 \cdot 10^{-147}:\\
\;\;\;\;\frac{b - \frac{a \cdot d}{c}}{c}\\
\mathbf{elif}\;d \leq 3.3 \cdot 10^{+128}:\\
\;\;\;\;\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 < -1.24999999999999993e57Initial program 33.0%
Taylor expanded in c around 0
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
unpow2N/A
associate-/r*N/A
div-subN/A
lower-/.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6481.3
Applied rewrites81.3%
Applied rewrites88.7%
if -1.24999999999999993e57 < d < -1.28e-79Initial program 84.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.f6484.2
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6484.2
Applied rewrites84.2%
if -1.28e-79 < d < 3.60000000000000012e-147Initial program 70.6%
Taylor expanded in c around inf
lower-/.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6488.6
Applied rewrites88.6%
if 3.60000000000000012e-147 < d < 3.3000000000000001e128Initial program 78.4%
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
distribute-lft-neg-inN/A
lower-*.f64N/A
Applied rewrites85.8%
if 3.3000000000000001e128 < d Initial program 23.8%
Taylor expanded in c around inf
lower-/.f6413.3
Applied rewrites13.3%
Taylor expanded in d around inf
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.1
Applied rewrites94.1%
Final simplification88.2%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (fma c c (* d d))) (t_1 (/ (- a) d)))
(if (<= d -2.4e+142)
t_1
(if (<= d -0.0175)
(/ (- (* c b) (* a d)) (* d d))
(if (<= d 5.8e-274)
(/ b c)
(if (<= d 4.7e-76)
(/ (fma (- d) a (* c b)) (* c c))
(if (<= d 1.2e+33)
(* (/ d t_0) (- a))
(if (<= d 1.65e+99) (* (/ b t_0) c) t_1))))))))
double code(double a, double b, double c, double d) {
double t_0 = fma(c, c, (d * d));
double t_1 = -a / d;
double tmp;
if (d <= -2.4e+142) {
tmp = t_1;
} else if (d <= -0.0175) {
tmp = ((c * b) - (a * d)) / (d * d);
} else if (d <= 5.8e-274) {
tmp = b / c;
} else if (d <= 4.7e-76) {
tmp = fma(-d, a, (c * b)) / (c * c);
} else if (d <= 1.2e+33) {
tmp = (d / t_0) * -a;
} else if (d <= 1.65e+99) {
tmp = (b / t_0) * c;
} else {
tmp = t_1;
}
return tmp;
}
function code(a, b, c, d) t_0 = fma(c, c, Float64(d * d)) t_1 = Float64(Float64(-a) / d) tmp = 0.0 if (d <= -2.4e+142) tmp = t_1; elseif (d <= -0.0175) tmp = Float64(Float64(Float64(c * b) - Float64(a * d)) / Float64(d * d)); elseif (d <= 5.8e-274) tmp = Float64(b / c); elseif (d <= 4.7e-76) tmp = Float64(fma(Float64(-d), a, Float64(c * b)) / Float64(c * c)); elseif (d <= 1.2e+33) tmp = Float64(Float64(d / t_0) * Float64(-a)); elseif (d <= 1.65e+99) tmp = Float64(Float64(b / t_0) * c); else tmp = t_1; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[((-a) / d), $MachinePrecision]}, If[LessEqual[d, -2.4e+142], t$95$1, If[LessEqual[d, -0.0175], N[(N[(N[(c * b), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(d * d), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 5.8e-274], N[(b / c), $MachinePrecision], If[LessEqual[d, 4.7e-76], N[(N[((-d) * a + N[(c * b), $MachinePrecision]), $MachinePrecision] / N[(c * c), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.2e+33], N[(N[(d / t$95$0), $MachinePrecision] * (-a)), $MachinePrecision], If[LessEqual[d, 1.65e+99], N[(N[(b / t$95$0), $MachinePrecision] * c), $MachinePrecision], t$95$1]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(c, c, d \cdot d\right)\\
t_1 := \frac{-a}{d}\\
\mathbf{if}\;d \leq -2.4 \cdot 10^{+142}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d \leq -0.0175:\\
\;\;\;\;\frac{c \cdot b - a \cdot d}{d \cdot d}\\
\mathbf{elif}\;d \leq 5.8 \cdot 10^{-274}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{elif}\;d \leq 4.7 \cdot 10^{-76}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-d, a, c \cdot b\right)}{c \cdot c}\\
\mathbf{elif}\;d \leq 1.2 \cdot 10^{+33}:\\
\;\;\;\;\frac{d}{t\_0} \cdot \left(-a\right)\\
\mathbf{elif}\;d \leq 1.65 \cdot 10^{+99}:\\
\;\;\;\;\frac{b}{t\_0} \cdot c\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if d < -2.3999999999999999e142 or 1.65e99 < d Initial program 23.2%
Taylor expanded in c around 0
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6479.7
Applied rewrites79.7%
if -2.3999999999999999e142 < d < -0.017500000000000002Initial program 81.0%
Taylor expanded in c around 0
unpow2N/A
lower-*.f6462.8
Applied rewrites62.8%
if -0.017500000000000002 < d < 5.79999999999999952e-274Initial program 71.2%
Taylor expanded in c around inf
lower-/.f6474.1
Applied rewrites74.1%
if 5.79999999999999952e-274 < d < 4.7000000000000002e-76Initial program 80.9%
Taylor expanded in c around inf
unpow2N/A
lower-*.f6478.7
Applied rewrites78.7%
lift--.f64N/A
lift-*.f64N/A
*-commutativeN/A
cancel-sign-sub-invN/A
lift-neg.f64N/A
+-commutativeN/A
lift-fma.f6478.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6478.7
Applied rewrites78.7%
if 4.7000000000000002e-76 < d < 1.2e33Initial program 73.6%
Taylor expanded in b around 0
associate-/l*N/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
unpow2N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6456.9
Applied rewrites56.9%
if 1.2e33 < d < 1.65e99Initial program 74.0%
Taylor expanded in b around inf
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6472.1
Applied rewrites72.1%
Final simplification73.8%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (fma c c (* d d))) (t_1 (/ (- a) d)) (t_2 (- (* c b) (* a d))))
(if (<= d -2.4e+142)
t_1
(if (<= d -0.0175)
(/ t_2 (* d d))
(if (<= d 5.8e-274)
(/ b c)
(if (<= d 4.7e-76)
(/ t_2 (* c c))
(if (<= d 1.2e+33)
(* (/ d t_0) (- a))
(if (<= d 1.65e+99) (* (/ b t_0) c) t_1))))))))
double code(double a, double b, double c, double d) {
double t_0 = fma(c, c, (d * d));
double t_1 = -a / d;
double t_2 = (c * b) - (a * d);
double tmp;
if (d <= -2.4e+142) {
tmp = t_1;
} else if (d <= -0.0175) {
tmp = t_2 / (d * d);
} else if (d <= 5.8e-274) {
tmp = b / c;
} else if (d <= 4.7e-76) {
tmp = t_2 / (c * c);
} else if (d <= 1.2e+33) {
tmp = (d / t_0) * -a;
} else if (d <= 1.65e+99) {
tmp = (b / t_0) * c;
} else {
tmp = t_1;
}
return tmp;
}
function code(a, b, c, d) t_0 = fma(c, c, Float64(d * d)) t_1 = Float64(Float64(-a) / d) t_2 = Float64(Float64(c * b) - Float64(a * d)) tmp = 0.0 if (d <= -2.4e+142) tmp = t_1; elseif (d <= -0.0175) tmp = Float64(t_2 / Float64(d * d)); elseif (d <= 5.8e-274) tmp = Float64(b / c); elseif (d <= 4.7e-76) tmp = Float64(t_2 / Float64(c * c)); elseif (d <= 1.2e+33) tmp = Float64(Float64(d / t_0) * Float64(-a)); elseif (d <= 1.65e+99) tmp = Float64(Float64(b / t_0) * c); else tmp = t_1; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[((-a) / d), $MachinePrecision]}, Block[{t$95$2 = N[(N[(c * b), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -2.4e+142], t$95$1, If[LessEqual[d, -0.0175], N[(t$95$2 / N[(d * d), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 5.8e-274], N[(b / c), $MachinePrecision], If[LessEqual[d, 4.7e-76], N[(t$95$2 / N[(c * c), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.2e+33], N[(N[(d / t$95$0), $MachinePrecision] * (-a)), $MachinePrecision], If[LessEqual[d, 1.65e+99], N[(N[(b / t$95$0), $MachinePrecision] * c), $MachinePrecision], t$95$1]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(c, c, d \cdot d\right)\\
t_1 := \frac{-a}{d}\\
t_2 := c \cdot b - a \cdot d\\
\mathbf{if}\;d \leq -2.4 \cdot 10^{+142}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d \leq -0.0175:\\
\;\;\;\;\frac{t\_2}{d \cdot d}\\
\mathbf{elif}\;d \leq 5.8 \cdot 10^{-274}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{elif}\;d \leq 4.7 \cdot 10^{-76}:\\
\;\;\;\;\frac{t\_2}{c \cdot c}\\
\mathbf{elif}\;d \leq 1.2 \cdot 10^{+33}:\\
\;\;\;\;\frac{d}{t\_0} \cdot \left(-a\right)\\
\mathbf{elif}\;d \leq 1.65 \cdot 10^{+99}:\\
\;\;\;\;\frac{b}{t\_0} \cdot c\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if d < -2.3999999999999999e142 or 1.65e99 < d Initial program 23.2%
Taylor expanded in c around 0
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6479.7
Applied rewrites79.7%
if -2.3999999999999999e142 < d < -0.017500000000000002Initial program 81.0%
Taylor expanded in c around 0
unpow2N/A
lower-*.f6462.8
Applied rewrites62.8%
if -0.017500000000000002 < d < 5.79999999999999952e-274Initial program 71.2%
Taylor expanded in c around inf
lower-/.f6474.1
Applied rewrites74.1%
if 5.79999999999999952e-274 < d < 4.7000000000000002e-76Initial program 80.9%
Taylor expanded in c around inf
unpow2N/A
lower-*.f6478.7
Applied rewrites78.7%
if 4.7000000000000002e-76 < d < 1.2e33Initial program 73.6%
Taylor expanded in b around 0
associate-/l*N/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
unpow2N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6456.9
Applied rewrites56.9%
if 1.2e33 < d < 1.65e99Initial program 74.0%
Taylor expanded in b around inf
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6472.1
Applied rewrites72.1%
Final simplification73.8%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (fma c c (* d d))) (t_1 (/ (- a) d)) (t_2 (* (/ d t_0) (- a))))
(if (<= d -3.4e+115)
t_1
(if (<= d -4.8e-18)
t_2
(if (<= d 5.8e-274)
(/ b c)
(if (<= d 4.7e-76)
(/ (- (* c b) (* a d)) (* c c))
(if (<= d 1.2e+33)
t_2
(if (<= d 1.65e+99) (* (/ b t_0) c) t_1))))))))
double code(double a, double b, double c, double d) {
double t_0 = fma(c, c, (d * d));
double t_1 = -a / d;
double t_2 = (d / t_0) * -a;
double tmp;
if (d <= -3.4e+115) {
tmp = t_1;
} else if (d <= -4.8e-18) {
tmp = t_2;
} else if (d <= 5.8e-274) {
tmp = b / c;
} else if (d <= 4.7e-76) {
tmp = ((c * b) - (a * d)) / (c * c);
} else if (d <= 1.2e+33) {
tmp = t_2;
} else if (d <= 1.65e+99) {
tmp = (b / t_0) * c;
} else {
tmp = t_1;
}
return tmp;
}
function code(a, b, c, d) t_0 = fma(c, c, Float64(d * d)) t_1 = Float64(Float64(-a) / d) t_2 = Float64(Float64(d / t_0) * Float64(-a)) tmp = 0.0 if (d <= -3.4e+115) tmp = t_1; elseif (d <= -4.8e-18) tmp = t_2; elseif (d <= 5.8e-274) tmp = Float64(b / c); elseif (d <= 4.7e-76) tmp = Float64(Float64(Float64(c * b) - Float64(a * d)) / Float64(c * c)); elseif (d <= 1.2e+33) tmp = t_2; elseif (d <= 1.65e+99) tmp = Float64(Float64(b / t_0) * c); else tmp = t_1; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[((-a) / d), $MachinePrecision]}, Block[{t$95$2 = N[(N[(d / t$95$0), $MachinePrecision] * (-a)), $MachinePrecision]}, If[LessEqual[d, -3.4e+115], t$95$1, If[LessEqual[d, -4.8e-18], t$95$2, If[LessEqual[d, 5.8e-274], N[(b / c), $MachinePrecision], If[LessEqual[d, 4.7e-76], N[(N[(N[(c * b), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(c * c), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.2e+33], t$95$2, If[LessEqual[d, 1.65e+99], N[(N[(b / t$95$0), $MachinePrecision] * c), $MachinePrecision], t$95$1]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(c, c, d \cdot d\right)\\
t_1 := \frac{-a}{d}\\
t_2 := \frac{d}{t\_0} \cdot \left(-a\right)\\
\mathbf{if}\;d \leq -3.4 \cdot 10^{+115}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d \leq -4.8 \cdot 10^{-18}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;d \leq 5.8 \cdot 10^{-274}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{elif}\;d \leq 4.7 \cdot 10^{-76}:\\
\;\;\;\;\frac{c \cdot b - a \cdot d}{c \cdot c}\\
\mathbf{elif}\;d \leq 1.2 \cdot 10^{+33}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;d \leq 1.65 \cdot 10^{+99}:\\
\;\;\;\;\frac{b}{t\_0} \cdot c\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if d < -3.4000000000000001e115 or 1.65e99 < d Initial program 25.1%
Taylor expanded in c around 0
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6479.1
Applied rewrites79.1%
if -3.4000000000000001e115 < d < -4.79999999999999988e-18 or 4.7000000000000002e-76 < d < 1.2e33Initial program 78.5%
Taylor expanded in b around 0
associate-/l*N/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
unpow2N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6457.9
Applied rewrites57.9%
if -4.79999999999999988e-18 < d < 5.79999999999999952e-274Initial program 69.5%
Taylor expanded in c around inf
lower-/.f6475.4
Applied rewrites75.4%
if 5.79999999999999952e-274 < d < 4.7000000000000002e-76Initial program 80.9%
Taylor expanded in c around inf
unpow2N/A
lower-*.f6478.7
Applied rewrites78.7%
if 1.2e33 < d < 1.65e99Initial program 74.0%
Taylor expanded in b around inf
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6472.1
Applied rewrites72.1%
Final simplification73.5%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (fma (- d) a (* c b)) (fma d d (* c c)))))
(if (<= d -1.25e+57)
(/ (fma c (/ b d) (- a)) d)
(if (<= d -1.28e-79)
t_0
(if (<= d 4e-73)
(/ (- b (/ (* a d) c)) c)
(if (<= d 1.12e+123) t_0 (/ (fma (/ c d) b (- a)) d)))))))
double code(double a, double b, double c, double d) {
double t_0 = fma(-d, a, (c * b)) / fma(d, d, (c * c));
double tmp;
if (d <= -1.25e+57) {
tmp = fma(c, (b / d), -a) / d;
} else if (d <= -1.28e-79) {
tmp = t_0;
} else if (d <= 4e-73) {
tmp = (b - ((a * d) / c)) / c;
} else if (d <= 1.12e+123) {
tmp = t_0;
} else {
tmp = fma((c / d), b, -a) / d;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(fma(Float64(-d), a, Float64(c * b)) / fma(d, d, Float64(c * c))) tmp = 0.0 if (d <= -1.25e+57) tmp = Float64(fma(c, Float64(b / d), Float64(-a)) / d); elseif (d <= -1.28e-79) tmp = t_0; elseif (d <= 4e-73) tmp = Float64(Float64(b - Float64(Float64(a * d) / c)) / c); elseif (d <= 1.12e+123) tmp = t_0; 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[(N[((-d) * a + N[(c * b), $MachinePrecision]), $MachinePrecision] / N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -1.25e+57], N[(N[(c * N[(b / d), $MachinePrecision] + (-a)), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, -1.28e-79], t$95$0, If[LessEqual[d, 4e-73], N[(N[(b - N[(N[(a * d), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 1.12e+123], t$95$0, N[(N[(N[(c / d), $MachinePrecision] * b + (-a)), $MachinePrecision] / d), $MachinePrecision]]]]]]
\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)}\\
\mathbf{if}\;d \leq -1.25 \cdot 10^{+57}:\\
\;\;\;\;\frac{\mathsf{fma}\left(c, \frac{b}{d}, -a\right)}{d}\\
\mathbf{elif}\;d \leq -1.28 \cdot 10^{-79}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 4 \cdot 10^{-73}:\\
\;\;\;\;\frac{b - \frac{a \cdot d}{c}}{c}\\
\mathbf{elif}\;d \leq 1.12 \cdot 10^{+123}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{c}{d}, b, -a\right)}{d}\\
\end{array}
\end{array}
if d < -1.24999999999999993e57Initial program 33.0%
Taylor expanded in c around 0
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
unpow2N/A
associate-/r*N/A
div-subN/A
lower-/.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6481.3
Applied rewrites81.3%
Applied rewrites88.7%
if -1.24999999999999993e57 < d < -1.28e-79 or 3.99999999999999999e-73 < d < 1.12e123Initial program 79.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.f6479.8
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6479.8
Applied rewrites79.8%
if -1.28e-79 < d < 3.99999999999999999e-73Initial program 72.9%
Taylor expanded in c around inf
lower-/.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6487.8
Applied rewrites87.8%
if 1.12e123 < d Initial program 23.8%
Taylor expanded in c around inf
lower-/.f6413.3
Applied rewrites13.3%
Taylor expanded in d around inf
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.1
Applied rewrites94.1%
Final simplification86.7%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- a) d)))
(if (<= d -2.4e+142)
t_0
(if (<= d -3.9)
(/ (- (* c b) (* a d)) (* d d))
(if (<= d 1.65e+99) (/ (- 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 <= -2.4e+142) {
tmp = t_0;
} else if (d <= -3.9) {
tmp = ((c * b) - (a * d)) / (d * d);
} else if (d <= 1.65e+99) {
tmp = (b - ((a * d) / c)) / c;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: tmp
t_0 = -a / d
if (d <= (-2.4d+142)) then
tmp = t_0
else if (d <= (-3.9d0)) then
tmp = ((c * b) - (a * d)) / (d * d)
else if (d <= 1.65d+99) then
tmp = (b - ((a * d) / c)) / c
else
tmp = t_0
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = -a / d;
double tmp;
if (d <= -2.4e+142) {
tmp = t_0;
} else if (d <= -3.9) {
tmp = ((c * b) - (a * d)) / (d * d);
} else if (d <= 1.65e+99) {
tmp = (b - ((a * d) / c)) / c;
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b, c, d): t_0 = -a / d tmp = 0 if d <= -2.4e+142: tmp = t_0 elif d <= -3.9: tmp = ((c * b) - (a * d)) / (d * d) elif d <= 1.65e+99: 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 <= -2.4e+142) tmp = t_0; elseif (d <= -3.9) tmp = Float64(Float64(Float64(c * b) - Float64(a * d)) / Float64(d * d)); elseif (d <= 1.65e+99) tmp = Float64(Float64(b - Float64(Float64(a * d) / c)) / c); else tmp = t_0; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = -a / d; tmp = 0.0; if (d <= -2.4e+142) tmp = t_0; elseif (d <= -3.9) tmp = ((c * b) - (a * d)) / (d * d); elseif (d <= 1.65e+99) tmp = (b - ((a * d) / c)) / c; else tmp = t_0; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[((-a) / d), $MachinePrecision]}, If[LessEqual[d, -2.4e+142], t$95$0, If[LessEqual[d, -3.9], N[(N[(N[(c * b), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(d * d), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.65e+99], 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{-a}{d}\\
\mathbf{if}\;d \leq -2.4 \cdot 10^{+142}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq -3.9:\\
\;\;\;\;\frac{c \cdot b - a \cdot d}{d \cdot d}\\
\mathbf{elif}\;d \leq 1.65 \cdot 10^{+99}:\\
\;\;\;\;\frac{b - \frac{a \cdot d}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d < -2.3999999999999999e142 or 1.65e99 < d Initial program 23.2%
Taylor expanded in c around 0
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6479.7
Applied rewrites79.7%
if -2.3999999999999999e142 < d < -3.89999999999999991Initial program 81.0%
Taylor expanded in c around 0
unpow2N/A
lower-*.f6462.8
Applied rewrites62.8%
if -3.89999999999999991 < d < 1.65e99Initial program 74.6%
Taylor expanded in c around inf
lower-/.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6479.0
Applied rewrites79.0%
Final simplification77.6%
(FPCore (a b c d)
:precision binary64
(if (<= c -1.8e+30)
(/ b c)
(if (<= c 1.92e-140)
(/ (- a) d)
(if (<= c 2.6e+92) (/ (* c b) (fma d d (* c c))) (/ b c)))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -1.8e+30) {
tmp = b / c;
} else if (c <= 1.92e-140) {
tmp = -a / d;
} else if (c <= 2.6e+92) {
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 <= -1.8e+30) tmp = Float64(b / c); elseif (c <= 1.92e-140) tmp = Float64(Float64(-a) / d); elseif (c <= 2.6e+92) 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, -1.8e+30], N[(b / c), $MachinePrecision], If[LessEqual[c, 1.92e-140], N[((-a) / d), $MachinePrecision], If[LessEqual[c, 2.6e+92], 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 -1.8 \cdot 10^{+30}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{elif}\;c \leq 1.92 \cdot 10^{-140}:\\
\;\;\;\;\frac{-a}{d}\\
\mathbf{elif}\;c \leq 2.6 \cdot 10^{+92}:\\
\;\;\;\;\frac{c \cdot b}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if c < -1.8000000000000001e30 or 2.5999999999999999e92 < c Initial program 44.8%
Taylor expanded in c around inf
lower-/.f6470.9
Applied rewrites70.9%
if -1.8000000000000001e30 < c < 1.9200000000000001e-140Initial program 64.3%
Taylor expanded in c around 0
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6467.9
Applied rewrites67.9%
if 1.9200000000000001e-140 < c < 2.5999999999999999e92Initial program 82.1%
Taylor expanded in c around inf
lower-*.f6465.5
Applied rewrites65.5%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-fma.f6465.5
Applied rewrites65.5%
Final simplification68.6%
(FPCore (a b c d) :precision binary64 (if (<= d -3.9) (/ (fma c (/ b d) (- a)) d) (if (<= d 7.5e+120) (/ (- b (/ (* a d) c)) c) (/ (fma (/ c d) b (- a)) d))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -3.9) {
tmp = fma(c, (b / d), -a) / d;
} else if (d <= 7.5e+120) {
tmp = (b - ((a * d) / c)) / c;
} else {
tmp = fma((c / d), b, -a) / d;
}
return tmp;
}
function code(a, b, c, d) tmp = 0.0 if (d <= -3.9) tmp = Float64(fma(c, Float64(b / d), Float64(-a)) / d); elseif (d <= 7.5e+120) tmp = Float64(Float64(b - Float64(Float64(a * d) / c)) / c); else tmp = Float64(fma(Float64(c / d), b, Float64(-a)) / d); end return tmp end
code[a_, b_, c_, d_] := If[LessEqual[d, -3.9], N[(N[(c * N[(b / d), $MachinePrecision] + (-a)), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, 7.5e+120], N[(N[(b - N[(N[(a * d), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], N[(N[(N[(c / d), $MachinePrecision] * b + (-a)), $MachinePrecision] / d), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -3.9:\\
\;\;\;\;\frac{\mathsf{fma}\left(c, \frac{b}{d}, -a\right)}{d}\\
\mathbf{elif}\;d \leq 7.5 \cdot 10^{+120}:\\
\;\;\;\;\frac{b - \frac{a \cdot d}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{c}{d}, b, -a\right)}{d}\\
\end{array}
\end{array}
if d < -3.89999999999999991Initial program 43.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
lower-/.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6476.6
Applied rewrites76.6%
Applied rewrites82.5%
if -3.89999999999999991 < d < 7.5000000000000006e120Initial program 74.7%
Taylor expanded in c around inf
lower-/.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6479.2
Applied rewrites79.2%
if 7.5000000000000006e120 < d Initial program 23.8%
Taylor expanded in c around inf
lower-/.f6413.3
Applied rewrites13.3%
Taylor expanded in d around inf
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.1
Applied rewrites94.1%
(FPCore (a b c d) :precision binary64 (let* ((t_0 (/ (fma c (/ b d) (- a)) d))) (if (<= d -3.9) t_0 (if (<= d 7.2e+98) (/ (- b (/ (* a d) c)) c) t_0))))
double code(double a, double b, double c, double d) {
double t_0 = fma(c, (b / d), -a) / d;
double tmp;
if (d <= -3.9) {
tmp = t_0;
} else if (d <= 7.2e+98) {
tmp = (b - ((a * d) / c)) / c;
} else {
tmp = t_0;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(fma(c, Float64(b / d), Float64(-a)) / d) tmp = 0.0 if (d <= -3.9) tmp = t_0; elseif (d <= 7.2e+98) 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[(c * N[(b / d), $MachinePrecision] + (-a)), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -3.9], t$95$0, If[LessEqual[d, 7.2e+98], 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(c, \frac{b}{d}, -a\right)}{d}\\
\mathbf{if}\;d \leq -3.9:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 7.2 \cdot 10^{+98}:\\
\;\;\;\;\frac{b - \frac{a \cdot d}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d < -3.89999999999999991 or 7.19999999999999962e98 < d Initial program 37.9%
Taylor expanded in c around 0
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
unpow2N/A
associate-/r*N/A
div-subN/A
lower-/.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6480.5
Applied rewrites80.5%
Applied rewrites86.4%
if -3.89999999999999991 < d < 7.19999999999999962e98Initial program 74.6%
Taylor expanded in c around inf
lower-/.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6479.0
Applied rewrites79.0%
(FPCore (a b c d) :precision binary64 (let* ((t_0 (/ (- (/ (* c b) d) a) d))) (if (<= d -3.9) t_0 (if (<= d 7.5e+120) (/ (- b (/ (* a d) c)) c) t_0))))
double code(double a, double b, double c, double d) {
double t_0 = (((c * b) / d) - a) / d;
double tmp;
if (d <= -3.9) {
tmp = t_0;
} else if (d <= 7.5e+120) {
tmp = (b - ((a * d) / c)) / c;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: tmp
t_0 = (((c * b) / d) - a) / d
if (d <= (-3.9d0)) then
tmp = t_0
else if (d <= 7.5d+120) then
tmp = (b - ((a * d) / c)) / c
else
tmp = t_0
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = (((c * b) / d) - a) / d;
double tmp;
if (d <= -3.9) {
tmp = t_0;
} else if (d <= 7.5e+120) {
tmp = (b - ((a * d) / c)) / c;
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b, c, d): t_0 = (((c * b) / d) - a) / d tmp = 0 if d <= -3.9: tmp = t_0 elif d <= 7.5e+120: tmp = (b - ((a * d) / c)) / c else: tmp = t_0 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(Float64(Float64(c * b) / d) - a) / d) tmp = 0.0 if (d <= -3.9) tmp = t_0; elseif (d <= 7.5e+120) tmp = Float64(Float64(b - Float64(Float64(a * d) / c)) / c); else tmp = t_0; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (((c * b) / d) - a) / d; tmp = 0.0; if (d <= -3.9) tmp = t_0; elseif (d <= 7.5e+120) tmp = (b - ((a * d) / c)) / c; else tmp = t_0; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(N[(c * b), $MachinePrecision] / d), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -3.9], t$95$0, If[LessEqual[d, 7.5e+120], 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{\frac{c \cdot b}{d} - a}{d}\\
\mathbf{if}\;d \leq -3.9:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 7.5 \cdot 10^{+120}:\\
\;\;\;\;\frac{b - \frac{a \cdot d}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d < -3.89999999999999991 or 7.5000000000000006e120 < d Initial program 37.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
lower-/.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6480.4
Applied rewrites80.4%
if -3.89999999999999991 < d < 7.5000000000000006e120Initial program 74.7%
Taylor expanded in c around inf
lower-/.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6479.2
Applied rewrites79.2%
Final simplification79.6%
(FPCore (a b c d) :precision binary64 (let* ((t_0 (/ (- a) d))) (if (<= d -3.1e+21) t_0 (if (<= d 1.65e+99) (/ b c) t_0))))
double code(double a, double b, double c, double d) {
double t_0 = -a / d;
double tmp;
if (d <= -3.1e+21) {
tmp = t_0;
} else if (d <= 1.65e+99) {
tmp = b / c;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: tmp
t_0 = -a / d
if (d <= (-3.1d+21)) then
tmp = t_0
else if (d <= 1.65d+99) then
tmp = b / c
else
tmp = t_0
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = -a / d;
double tmp;
if (d <= -3.1e+21) {
tmp = t_0;
} else if (d <= 1.65e+99) {
tmp = b / c;
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b, c, d): t_0 = -a / d tmp = 0 if d <= -3.1e+21: tmp = t_0 elif d <= 1.65e+99: 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 <= -3.1e+21) tmp = t_0; elseif (d <= 1.65e+99) tmp = Float64(b / c); else tmp = t_0; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = -a / d; tmp = 0.0; if (d <= -3.1e+21) tmp = t_0; elseif (d <= 1.65e+99) tmp = b / c; else tmp = t_0; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[((-a) / d), $MachinePrecision]}, If[LessEqual[d, -3.1e+21], t$95$0, If[LessEqual[d, 1.65e+99], N[(b / c), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-a}{d}\\
\mathbf{if}\;d \leq -3.1 \cdot 10^{+21}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 1.65 \cdot 10^{+99}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d < -3.1e21 or 1.65e99 < d Initial program 35.7%
Taylor expanded in c around 0
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6471.9
Applied rewrites71.9%
if -3.1e21 < d < 1.65e99Initial program 74.8%
Taylor expanded in c around inf
lower-/.f6463.6
Applied rewrites63.6%
(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 60.0%
Taylor expanded in c around inf
lower-/.f6445.0
Applied rewrites45.0%
(FPCore (a b c d) :precision binary64 (if (< (fabs d) (fabs c)) (/ (- b (* a (/ d c))) (+ c (* d (/ d c)))) (/ (+ (- a) (* b (/ c d))) (+ d (* c (/ c d))))))
double code(double a, double b, double c, double d) {
double tmp;
if (fabs(d) < fabs(c)) {
tmp = (b - (a * (d / c))) / (c + (d * (d / c)));
} else {
tmp = (-a + (b * (c / d))) / (d + (c * (c / d)));
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (abs(d) < abs(c)) then
tmp = (b - (a * (d / c))) / (c + (d * (d / c)))
else
tmp = (-a + (b * (c / d))) / (d + (c * (c / d)))
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (Math.abs(d) < Math.abs(c)) {
tmp = (b - (a * (d / c))) / (c + (d * (d / c)));
} else {
tmp = (-a + (b * (c / d))) / (d + (c * (c / d)));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if math.fabs(d) < math.fabs(c): tmp = (b - (a * (d / c))) / (c + (d * (d / c))) else: tmp = (-a + (b * (c / d))) / (d + (c * (c / d))) return tmp
function code(a, b, c, d) tmp = 0.0 if (abs(d) < abs(c)) tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / Float64(c + Float64(d * Float64(d / c)))); else tmp = Float64(Float64(Float64(-a) + Float64(b * Float64(c / d))) / Float64(d + Float64(c * Float64(c / d)))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (abs(d) < abs(c)) tmp = (b - (a * (d / c))) / (c + (d * (d / c))); else tmp = (-a + (b * (c / d))) / (d + (c * (c / d))); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Less[N[Abs[d], $MachinePrecision], N[Abs[c], $MachinePrecision]], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(c + N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[((-a) + N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(d + N[(c * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left|d\right| < \left|c\right|:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c + d \cdot \frac{d}{c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-a\right) + b \cdot \frac{c}{d}}{d + c \cdot \frac{c}{d}}\\
\end{array}
\end{array}
herbie shell --seed 2024240
(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))))