
(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 18 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 (/ a (* c c)) -1.0 (* (/ 0.0 (pow c 3.0)) b)))
(t_1 (/ t_0 c))
(t_2 (/ 0.0 (* c c)))
(t_3 (- 1.0 t_2))
(t_4 (fma t_1 (/ 0.0 c) (/ (* t_3 b) (pow c 3.0)))))
(if (<= c -2.4e-34)
(fma (/ (- a) c) (/ d c) (/ b c))
(if (<= c 2.4e-142)
(/ (fma (/ c d) b (- a)) d)
(if (<= c 1.05e+114)
(/ (- (* b c) (* d a)) (fma d d (* c c)))
(fma
(fma
(-
(fma
(fma
(- b)
(/ (* (- -1.0 t_2) 0.0) (pow c 5.0))
(fma 0.0 (/ t_4 (* c c)) (* (/ t_3 c) t_1)))
d
t_4))
d
t_0)
d
(/ b c)))))))
double code(double a, double b, double c, double d) {
double t_0 = fma((a / (c * c)), -1.0, ((0.0 / pow(c, 3.0)) * b));
double t_1 = t_0 / c;
double t_2 = 0.0 / (c * c);
double t_3 = 1.0 - t_2;
double t_4 = fma(t_1, (0.0 / c), ((t_3 * b) / pow(c, 3.0)));
double tmp;
if (c <= -2.4e-34) {
tmp = fma((-a / c), (d / c), (b / c));
} else if (c <= 2.4e-142) {
tmp = fma((c / d), b, -a) / d;
} else if (c <= 1.05e+114) {
tmp = ((b * c) - (d * a)) / fma(d, d, (c * c));
} else {
tmp = fma(fma(-fma(fma(-b, (((-1.0 - t_2) * 0.0) / pow(c, 5.0)), fma(0.0, (t_4 / (c * c)), ((t_3 / c) * t_1))), d, t_4), d, t_0), d, (b / c));
}
return tmp;
}
function code(a, b, c, d) t_0 = fma(Float64(a / Float64(c * c)), -1.0, Float64(Float64(0.0 / (c ^ 3.0)) * b)) t_1 = Float64(t_0 / c) t_2 = Float64(0.0 / Float64(c * c)) t_3 = Float64(1.0 - t_2) t_4 = fma(t_1, Float64(0.0 / c), Float64(Float64(t_3 * b) / (c ^ 3.0))) tmp = 0.0 if (c <= -2.4e-34) tmp = fma(Float64(Float64(-a) / c), Float64(d / c), Float64(b / c)); elseif (c <= 2.4e-142) tmp = Float64(fma(Float64(c / d), b, Float64(-a)) / d); elseif (c <= 1.05e+114) tmp = Float64(Float64(Float64(b * c) - Float64(d * a)) / fma(d, d, Float64(c * c))); else tmp = fma(fma(Float64(-fma(fma(Float64(-b), Float64(Float64(Float64(-1.0 - t_2) * 0.0) / (c ^ 5.0)), fma(0.0, Float64(t_4 / Float64(c * c)), Float64(Float64(t_3 / c) * t_1))), d, t_4)), d, t_0), d, Float64(b / c)); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(a / N[(c * c), $MachinePrecision]), $MachinePrecision] * -1.0 + N[(N[(0.0 / N[Power[c, 3.0], $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 / c), $MachinePrecision]}, Block[{t$95$2 = N[(0.0 / N[(c * c), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(1.0 - t$95$2), $MachinePrecision]}, Block[{t$95$4 = N[(t$95$1 * N[(0.0 / c), $MachinePrecision] + N[(N[(t$95$3 * b), $MachinePrecision] / N[Power[c, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -2.4e-34], N[(N[((-a) / c), $MachinePrecision] * N[(d / c), $MachinePrecision] + N[(b / c), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 2.4e-142], N[(N[(N[(c / d), $MachinePrecision] * b + (-a)), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 1.05e+114], N[(N[(N[(b * c), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[((-N[(N[((-b) * N[(N[(N[(-1.0 - t$95$2), $MachinePrecision] * 0.0), $MachinePrecision] / N[Power[c, 5.0], $MachinePrecision]), $MachinePrecision] + N[(0.0 * N[(t$95$4 / N[(c * c), $MachinePrecision]), $MachinePrecision] + N[(N[(t$95$3 / c), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * d + t$95$4), $MachinePrecision]) * d + t$95$0), $MachinePrecision] * d + N[(b / c), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\frac{a}{c \cdot c}, -1, \frac{0}{{c}^{3}} \cdot b\right)\\
t_1 := \frac{t\_0}{c}\\
t_2 := \frac{0}{c \cdot c}\\
t_3 := 1 - t\_2\\
t_4 := \mathsf{fma}\left(t\_1, \frac{0}{c}, \frac{t\_3 \cdot b}{{c}^{3}}\right)\\
\mathbf{if}\;c \leq -2.4 \cdot 10^{-34}:\\
\;\;\;\;\mathsf{fma}\left(\frac{-a}{c}, \frac{d}{c}, \frac{b}{c}\right)\\
\mathbf{elif}\;c \leq 2.4 \cdot 10^{-142}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{c}{d}, b, -a\right)}{d}\\
\mathbf{elif}\;c \leq 1.05 \cdot 10^{+114}:\\
\;\;\;\;\frac{b \cdot c - d \cdot a}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-\mathsf{fma}\left(\mathsf{fma}\left(-b, \frac{\left(-1 - t\_2\right) \cdot 0}{{c}^{5}}, \mathsf{fma}\left(0, \frac{t\_4}{c \cdot c}, \frac{t\_3}{c} \cdot t\_1\right)\right), d, t\_4\right), d, t\_0\right), d, \frac{b}{c}\right)\\
\end{array}
\end{array}
if c < -2.39999999999999991e-34Initial program 49.2%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6449.2
Applied rewrites49.2%
Taylor expanded in d around 0
associate-*r/N/A
associate-*r*N/A
unpow2N/A
times-fracN/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
lower-/.f6476.5
Applied rewrites76.5%
if -2.39999999999999991e-34 < c < 2.39999999999999988e-142Initial program 70.4%
Taylor expanded in c around 0
unpow2N/A
lower-*.f6464.3
Applied rewrites64.3%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
frac-2negN/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-outN/A
lift-neg.f64N/A
lift-*.f64N/A
frac-subN/A
lower-/.f64N/A
Applied rewrites32.4%
Taylor expanded in c around inf
lower-/.f64N/A
+-commutativeN/A
mul-1-negN/A
associate-/l*N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f6432.1
Applied rewrites32.1%
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
sub-negN/A
*-commutativeN/A
associate-*l/N/A
mul-1-negN/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6487.9
Applied rewrites87.9%
if 2.39999999999999988e-142 < c < 1.05e114Initial program 79.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6479.8
Applied rewrites79.8%
if 1.05e114 < c Initial program 38.4%
lift-+.f64N/A
flip-+N/A
div-subN/A
sub-negN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
difference-of-squaresN/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-neg.f64N/A
lower-/.f64N/A
Applied rewrites17.1%
Taylor expanded in d around 0
Applied rewrites91.9%
Final simplification83.6%
(FPCore (a b c d)
:precision binary64
(if (<= c -2.4e-34)
(fma (/ (- a) c) (/ d c) (/ b c))
(if (<= c 2.4e-142)
(/ (fma (/ c d) b (- a)) d)
(if (<= c 1.05e+114)
(/ (- (* b c) (* d a)) (fma d d (* c c)))
(fma (- (fma b (/ d (pow c 3.0)) (/ a (* c c)))) d (/ b c))))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -2.4e-34) {
tmp = fma((-a / c), (d / c), (b / c));
} else if (c <= 2.4e-142) {
tmp = fma((c / d), b, -a) / d;
} else if (c <= 1.05e+114) {
tmp = ((b * c) - (d * a)) / fma(d, d, (c * c));
} else {
tmp = fma(-fma(b, (d / pow(c, 3.0)), (a / (c * c))), d, (b / c));
}
return tmp;
}
function code(a, b, c, d) tmp = 0.0 if (c <= -2.4e-34) tmp = fma(Float64(Float64(-a) / c), Float64(d / c), Float64(b / c)); elseif (c <= 2.4e-142) tmp = Float64(fma(Float64(c / d), b, Float64(-a)) / d); elseif (c <= 1.05e+114) tmp = Float64(Float64(Float64(b * c) - Float64(d * a)) / fma(d, d, Float64(c * c))); else tmp = fma(Float64(-fma(b, Float64(d / (c ^ 3.0)), Float64(a / Float64(c * c)))), d, Float64(b / c)); end return tmp end
code[a_, b_, c_, d_] := If[LessEqual[c, -2.4e-34], N[(N[((-a) / c), $MachinePrecision] * N[(d / c), $MachinePrecision] + N[(b / c), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 2.4e-142], N[(N[(N[(c / d), $MachinePrecision] * b + (-a)), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 1.05e+114], N[(N[(N[(b * c), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-N[(b * N[(d / N[Power[c, 3.0], $MachinePrecision]), $MachinePrecision] + N[(a / N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]) * d + N[(b / c), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -2.4 \cdot 10^{-34}:\\
\;\;\;\;\mathsf{fma}\left(\frac{-a}{c}, \frac{d}{c}, \frac{b}{c}\right)\\
\mathbf{elif}\;c \leq 2.4 \cdot 10^{-142}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{c}{d}, b, -a\right)}{d}\\
\mathbf{elif}\;c \leq 1.05 \cdot 10^{+114}:\\
\;\;\;\;\frac{b \cdot c - d \cdot a}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-\mathsf{fma}\left(b, \frac{d}{{c}^{3}}, \frac{a}{c \cdot c}\right), d, \frac{b}{c}\right)\\
\end{array}
\end{array}
if c < -2.39999999999999991e-34Initial program 49.2%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6449.2
Applied rewrites49.2%
Taylor expanded in d around 0
associate-*r/N/A
associate-*r*N/A
unpow2N/A
times-fracN/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
lower-/.f6476.5
Applied rewrites76.5%
if -2.39999999999999991e-34 < c < 2.39999999999999988e-142Initial program 70.4%
Taylor expanded in c around 0
unpow2N/A
lower-*.f6464.3
Applied rewrites64.3%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
frac-2negN/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-outN/A
lift-neg.f64N/A
lift-*.f64N/A
frac-subN/A
lower-/.f64N/A
Applied rewrites32.4%
Taylor expanded in c around inf
lower-/.f64N/A
+-commutativeN/A
mul-1-negN/A
associate-/l*N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f6432.1
Applied rewrites32.1%
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
sub-negN/A
*-commutativeN/A
associate-*l/N/A
mul-1-negN/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6487.9
Applied rewrites87.9%
if 2.39999999999999988e-142 < c < 1.05e114Initial program 79.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6479.8
Applied rewrites79.8%
if 1.05e114 < c Initial program 38.4%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6438.4
Applied rewrites38.4%
Taylor expanded in d around 0
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
mul-1-negN/A
mul-1-negN/A
distribute-neg-outN/A
lower-neg.f64N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-pow.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f6491.9
Applied rewrites91.9%
Final simplification83.6%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- a) d)) (t_1 (* (- d) a)))
(if (<= d -8.6e+58)
t_0
(if (<= d -6.6e-60)
(/ (- (* b c) (* d a)) (* d d))
(if (<= d -1.15e-149)
(/ (fma c b t_1) (* c c))
(if (<= d 9.2e-115)
(/ b c)
(if (<= d 2.6e+89) (/ t_1 (fma d d (* c c))) t_0)))))))
double code(double a, double b, double c, double d) {
double t_0 = -a / d;
double t_1 = -d * a;
double tmp;
if (d <= -8.6e+58) {
tmp = t_0;
} else if (d <= -6.6e-60) {
tmp = ((b * c) - (d * a)) / (d * d);
} else if (d <= -1.15e-149) {
tmp = fma(c, b, t_1) / (c * c);
} else if (d <= 9.2e-115) {
tmp = b / c;
} else if (d <= 2.6e+89) {
tmp = t_1 / fma(d, d, (c * c));
} else {
tmp = t_0;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(-a) / d) t_1 = Float64(Float64(-d) * a) tmp = 0.0 if (d <= -8.6e+58) tmp = t_0; elseif (d <= -6.6e-60) tmp = Float64(Float64(Float64(b * c) - Float64(d * a)) / Float64(d * d)); elseif (d <= -1.15e-149) tmp = Float64(fma(c, b, t_1) / Float64(c * c)); elseif (d <= 9.2e-115) tmp = Float64(b / c); elseif (d <= 2.6e+89) tmp = Float64(t_1 / fma(d, d, Float64(c * c))); 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[((-d) * a), $MachinePrecision]}, If[LessEqual[d, -8.6e+58], t$95$0, If[LessEqual[d, -6.6e-60], N[(N[(N[(b * c), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(d * d), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -1.15e-149], N[(N[(c * b + t$95$1), $MachinePrecision] / N[(c * c), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 9.2e-115], N[(b / c), $MachinePrecision], If[LessEqual[d, 2.6e+89], N[(t$95$1 / N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-a}{d}\\
t_1 := \left(-d\right) \cdot a\\
\mathbf{if}\;d \leq -8.6 \cdot 10^{+58}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq -6.6 \cdot 10^{-60}:\\
\;\;\;\;\frac{b \cdot c - d \cdot a}{d \cdot d}\\
\mathbf{elif}\;d \leq -1.15 \cdot 10^{-149}:\\
\;\;\;\;\frac{\mathsf{fma}\left(c, b, t\_1\right)}{c \cdot c}\\
\mathbf{elif}\;d \leq 9.2 \cdot 10^{-115}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{elif}\;d \leq 2.6 \cdot 10^{+89}:\\
\;\;\;\;\frac{t\_1}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d < -8.59999999999999982e58 or 2.6000000000000001e89 < d Initial program 39.9%
Taylor expanded in c around 0
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6473.5
Applied rewrites73.5%
if -8.59999999999999982e58 < d < -6.5999999999999996e-60Initial program 78.0%
Taylor expanded in c around 0
unpow2N/A
lower-*.f6464.1
Applied rewrites64.1%
if -6.5999999999999996e-60 < d < -1.15e-149Initial program 91.1%
lift--.f64N/A
sub-negN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f6491.2
Applied rewrites91.2%
Taylor expanded in c around inf
unpow2N/A
lower-*.f6479.2
Applied rewrites79.2%
if -1.15e-149 < d < 9.19999999999999938e-115Initial program 74.0%
Taylor expanded in c around inf
lower-/.f6477.1
Applied rewrites77.1%
if 9.19999999999999938e-115 < d < 2.6000000000000001e89Initial program 66.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6466.8
Applied rewrites66.8%
Taylor expanded in c around 0
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6451.0
Applied rewrites51.0%
Final simplification69.8%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- a) d)) (t_1 (- (* b c) (* d a))))
(if (<= d -8.6e+58)
t_0
(if (<= d -6.6e-60)
(/ t_1 (* d d))
(if (<= d -1.15e-149)
(/ t_1 (* c c))
(if (<= d 9.2e-115)
(/ b c)
(if (<= d 2.6e+89) (/ (* (- d) a) (fma d d (* c c))) t_0)))))))
double code(double a, double b, double c, double d) {
double t_0 = -a / d;
double t_1 = (b * c) - (d * a);
double tmp;
if (d <= -8.6e+58) {
tmp = t_0;
} else if (d <= -6.6e-60) {
tmp = t_1 / (d * d);
} else if (d <= -1.15e-149) {
tmp = t_1 / (c * c);
} else if (d <= 9.2e-115) {
tmp = b / c;
} else if (d <= 2.6e+89) {
tmp = (-d * a) / fma(d, d, (c * c));
} else {
tmp = t_0;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(-a) / d) t_1 = Float64(Float64(b * c) - Float64(d * a)) tmp = 0.0 if (d <= -8.6e+58) tmp = t_0; elseif (d <= -6.6e-60) tmp = Float64(t_1 / Float64(d * d)); elseif (d <= -1.15e-149) tmp = Float64(t_1 / Float64(c * c)); elseif (d <= 9.2e-115) tmp = Float64(b / c); elseif (d <= 2.6e+89) tmp = Float64(Float64(Float64(-d) * a) / fma(d, d, Float64(c * c))); else tmp = t_0; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[((-a) / d), $MachinePrecision]}, Block[{t$95$1 = N[(N[(b * c), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -8.6e+58], t$95$0, If[LessEqual[d, -6.6e-60], N[(t$95$1 / N[(d * d), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -1.15e-149], N[(t$95$1 / N[(c * c), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 9.2e-115], N[(b / c), $MachinePrecision], If[LessEqual[d, 2.6e+89], N[(N[((-d) * a), $MachinePrecision] / N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-a}{d}\\
t_1 := b \cdot c - d \cdot a\\
\mathbf{if}\;d \leq -8.6 \cdot 10^{+58}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq -6.6 \cdot 10^{-60}:\\
\;\;\;\;\frac{t\_1}{d \cdot d}\\
\mathbf{elif}\;d \leq -1.15 \cdot 10^{-149}:\\
\;\;\;\;\frac{t\_1}{c \cdot c}\\
\mathbf{elif}\;d \leq 9.2 \cdot 10^{-115}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{elif}\;d \leq 2.6 \cdot 10^{+89}:\\
\;\;\;\;\frac{\left(-d\right) \cdot a}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d < -8.59999999999999982e58 or 2.6000000000000001e89 < d Initial program 39.9%
Taylor expanded in c around 0
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6473.5
Applied rewrites73.5%
if -8.59999999999999982e58 < d < -6.5999999999999996e-60Initial program 78.0%
Taylor expanded in c around 0
unpow2N/A
lower-*.f6464.1
Applied rewrites64.1%
if -6.5999999999999996e-60 < d < -1.15e-149Initial program 91.1%
Taylor expanded in c around inf
unpow2N/A
lower-*.f6479.1
Applied rewrites79.1%
if -1.15e-149 < d < 9.19999999999999938e-115Initial program 74.0%
Taylor expanded in c around inf
lower-/.f6477.1
Applied rewrites77.1%
if 9.19999999999999938e-115 < d < 2.6000000000000001e89Initial program 66.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6466.8
Applied rewrites66.8%
Taylor expanded in c around 0
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6451.0
Applied rewrites51.0%
Final simplification69.8%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (fma (/ (- a) c) (/ d c) (/ b c))))
(if (<= c -2.4e-34)
t_0
(if (<= c 2.4e-142)
(/ (fma (/ c d) b (- a)) d)
(if (<= c 1.45e+75) (/ (- (* b c) (* d a)) (fma d d (* c c))) t_0)))))
double code(double a, double b, double c, double d) {
double t_0 = fma((-a / c), (d / c), (b / c));
double tmp;
if (c <= -2.4e-34) {
tmp = t_0;
} else if (c <= 2.4e-142) {
tmp = fma((c / d), b, -a) / d;
} else if (c <= 1.45e+75) {
tmp = ((b * c) - (d * a)) / fma(d, d, (c * c));
} else {
tmp = t_0;
}
return tmp;
}
function code(a, b, c, d) t_0 = fma(Float64(Float64(-a) / c), Float64(d / c), Float64(b / c)) tmp = 0.0 if (c <= -2.4e-34) tmp = t_0; elseif (c <= 2.4e-142) tmp = Float64(fma(Float64(c / d), b, Float64(-a)) / d); elseif (c <= 1.45e+75) tmp = Float64(Float64(Float64(b * c) - Float64(d * a)) / fma(d, d, Float64(c * c))); else tmp = t_0; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[((-a) / c), $MachinePrecision] * N[(d / c), $MachinePrecision] + N[(b / c), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -2.4e-34], t$95$0, If[LessEqual[c, 2.4e-142], N[(N[(N[(c / d), $MachinePrecision] * b + (-a)), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 1.45e+75], N[(N[(N[(b * c), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\frac{-a}{c}, \frac{d}{c}, \frac{b}{c}\right)\\
\mathbf{if}\;c \leq -2.4 \cdot 10^{-34}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq 2.4 \cdot 10^{-142}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{c}{d}, b, -a\right)}{d}\\
\mathbf{elif}\;c \leq 1.45 \cdot 10^{+75}:\\
\;\;\;\;\frac{b \cdot c - d \cdot a}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if c < -2.39999999999999991e-34 or 1.4499999999999999e75 < c Initial program 47.6%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6447.6
Applied rewrites47.6%
Taylor expanded in d around 0
associate-*r/N/A
associate-*r*N/A
unpow2N/A
times-fracN/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
lower-/.f6482.3
Applied rewrites82.3%
if -2.39999999999999991e-34 < c < 2.39999999999999988e-142Initial program 70.4%
Taylor expanded in c around 0
unpow2N/A
lower-*.f6464.3
Applied rewrites64.3%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
frac-2negN/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-outN/A
lift-neg.f64N/A
lift-*.f64N/A
frac-subN/A
lower-/.f64N/A
Applied rewrites32.4%
Taylor expanded in c around inf
lower-/.f64N/A
+-commutativeN/A
mul-1-negN/A
associate-/l*N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f6432.1
Applied rewrites32.1%
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
sub-negN/A
*-commutativeN/A
associate-*l/N/A
mul-1-negN/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6487.9
Applied rewrites87.9%
if 2.39999999999999988e-142 < c < 1.4499999999999999e75Initial program 78.2%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6478.3
Applied rewrites78.3%
Final simplification83.6%
(FPCore (a b c d)
:precision binary64
(if (<= c -1e-34)
(/ b c)
(if (<= c 1.6e-114)
(/ (- a) d)
(if (<= c 2.35e-54)
(/ (* b c) (fma d d (* c c)))
(if (<= c 1.15e+145) (/ (- (* b c) (* d a)) (* c c)) (/ b c))))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -1e-34) {
tmp = b / c;
} else if (c <= 1.6e-114) {
tmp = -a / d;
} else if (c <= 2.35e-54) {
tmp = (b * c) / fma(d, d, (c * c));
} else if (c <= 1.15e+145) {
tmp = ((b * c) - (d * a)) / (c * c);
} else {
tmp = b / c;
}
return tmp;
}
function code(a, b, c, d) tmp = 0.0 if (c <= -1e-34) tmp = Float64(b / c); elseif (c <= 1.6e-114) tmp = Float64(Float64(-a) / d); elseif (c <= 2.35e-54) tmp = Float64(Float64(b * c) / fma(d, d, Float64(c * c))); elseif (c <= 1.15e+145) tmp = Float64(Float64(Float64(b * c) - Float64(d * a)) / Float64(c * c)); else tmp = Float64(b / c); end return tmp end
code[a_, b_, c_, d_] := If[LessEqual[c, -1e-34], N[(b / c), $MachinePrecision], If[LessEqual[c, 1.6e-114], N[((-a) / d), $MachinePrecision], If[LessEqual[c, 2.35e-54], N[(N[(b * c), $MachinePrecision] / N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.15e+145], N[(N[(N[(b * c), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(c * c), $MachinePrecision]), $MachinePrecision], N[(b / c), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -1 \cdot 10^{-34}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{elif}\;c \leq 1.6 \cdot 10^{-114}:\\
\;\;\;\;\frac{-a}{d}\\
\mathbf{elif}\;c \leq 2.35 \cdot 10^{-54}:\\
\;\;\;\;\frac{b \cdot c}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\
\mathbf{elif}\;c \leq 1.15 \cdot 10^{+145}:\\
\;\;\;\;\frac{b \cdot c - d \cdot a}{c \cdot c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if c < -9.99999999999999928e-35 or 1.15e145 < c Initial program 45.3%
Taylor expanded in c around inf
lower-/.f6470.2
Applied rewrites70.2%
if -9.99999999999999928e-35 < c < 1.6000000000000001e-114Initial program 71.8%
Taylor expanded in c around 0
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6467.4
Applied rewrites67.4%
if 1.6000000000000001e-114 < c < 2.35e-54Initial program 81.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6481.8
Applied rewrites81.8%
Taylor expanded in c around inf
*-commutativeN/A
lower-*.f6476.7
Applied rewrites76.7%
if 2.35e-54 < c < 1.15e145Initial program 72.4%
Taylor expanded in c around inf
unpow2N/A
lower-*.f6460.0
Applied rewrites60.0%
Final simplification68.1%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (fma d d (* c c))))
(if (<= c -1e-34)
(/ b c)
(if (<= c 1.6e-114)
(/ (- a) d)
(if (<= c 5.5e-32)
(/ (* b c) t_0)
(if (<= c 1.1e+66) (/ (* (- d) a) t_0) (/ b c)))))))
double code(double a, double b, double c, double d) {
double t_0 = fma(d, d, (c * c));
double tmp;
if (c <= -1e-34) {
tmp = b / c;
} else if (c <= 1.6e-114) {
tmp = -a / d;
} else if (c <= 5.5e-32) {
tmp = (b * c) / t_0;
} else if (c <= 1.1e+66) {
tmp = (-d * a) / t_0;
} else {
tmp = b / c;
}
return tmp;
}
function code(a, b, c, d) t_0 = fma(d, d, Float64(c * c)) tmp = 0.0 if (c <= -1e-34) tmp = Float64(b / c); elseif (c <= 1.6e-114) tmp = Float64(Float64(-a) / d); elseif (c <= 5.5e-32) tmp = Float64(Float64(b * c) / t_0); elseif (c <= 1.1e+66) tmp = Float64(Float64(Float64(-d) * a) / t_0); else tmp = Float64(b / c); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -1e-34], N[(b / c), $MachinePrecision], If[LessEqual[c, 1.6e-114], N[((-a) / d), $MachinePrecision], If[LessEqual[c, 5.5e-32], N[(N[(b * c), $MachinePrecision] / t$95$0), $MachinePrecision], If[LessEqual[c, 1.1e+66], N[(N[((-d) * a), $MachinePrecision] / t$95$0), $MachinePrecision], N[(b / c), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(d, d, c \cdot c\right)\\
\mathbf{if}\;c \leq -1 \cdot 10^{-34}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{elif}\;c \leq 1.6 \cdot 10^{-114}:\\
\;\;\;\;\frac{-a}{d}\\
\mathbf{elif}\;c \leq 5.5 \cdot 10^{-32}:\\
\;\;\;\;\frac{b \cdot c}{t\_0}\\
\mathbf{elif}\;c \leq 1.1 \cdot 10^{+66}:\\
\;\;\;\;\frac{\left(-d\right) \cdot a}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if c < -9.99999999999999928e-35 or 1.0999999999999999e66 < c Initial program 47.6%
Taylor expanded in c around inf
lower-/.f6468.3
Applied rewrites68.3%
if -9.99999999999999928e-35 < c < 1.6000000000000001e-114Initial program 71.8%
Taylor expanded in c around 0
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6467.4
Applied rewrites67.4%
if 1.6000000000000001e-114 < c < 5.50000000000000024e-32Initial program 85.2%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6485.2
Applied rewrites85.2%
Taylor expanded in c around inf
*-commutativeN/A
lower-*.f6476.5
Applied rewrites76.5%
if 5.50000000000000024e-32 < c < 1.0999999999999999e66Initial program 68.0%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6468.0
Applied rewrites68.0%
Taylor expanded in c around 0
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6450.5
Applied rewrites50.5%
Final simplification67.1%
(FPCore (a b c d)
:precision binary64
(if (<= c -1e-34)
(/ b c)
(if (<= c 1.6e-114)
(/ (- a) d)
(if (<= c 7.4e-32)
(/ (* b c) (fma d d (* c c)))
(if (<= c 6.5e+38) (/ (* (/ (- a) c) d) c) (/ b c))))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -1e-34) {
tmp = b / c;
} else if (c <= 1.6e-114) {
tmp = -a / d;
} else if (c <= 7.4e-32) {
tmp = (b * c) / fma(d, d, (c * c));
} else if (c <= 6.5e+38) {
tmp = ((-a / c) * d) / c;
} else {
tmp = b / c;
}
return tmp;
}
function code(a, b, c, d) tmp = 0.0 if (c <= -1e-34) tmp = Float64(b / c); elseif (c <= 1.6e-114) tmp = Float64(Float64(-a) / d); elseif (c <= 7.4e-32) tmp = Float64(Float64(b * c) / fma(d, d, Float64(c * c))); elseif (c <= 6.5e+38) tmp = Float64(Float64(Float64(Float64(-a) / c) * d) / c); else tmp = Float64(b / c); end return tmp end
code[a_, b_, c_, d_] := If[LessEqual[c, -1e-34], N[(b / c), $MachinePrecision], If[LessEqual[c, 1.6e-114], N[((-a) / d), $MachinePrecision], If[LessEqual[c, 7.4e-32], N[(N[(b * c), $MachinePrecision] / N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 6.5e+38], N[(N[(N[((-a) / c), $MachinePrecision] * d), $MachinePrecision] / c), $MachinePrecision], N[(b / c), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -1 \cdot 10^{-34}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{elif}\;c \leq 1.6 \cdot 10^{-114}:\\
\;\;\;\;\frac{-a}{d}\\
\mathbf{elif}\;c \leq 7.4 \cdot 10^{-32}:\\
\;\;\;\;\frac{b \cdot c}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\
\mathbf{elif}\;c \leq 6.5 \cdot 10^{+38}:\\
\;\;\;\;\frac{\frac{-a}{c} \cdot d}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if c < -9.99999999999999928e-35 or 6.5e38 < c Initial program 48.7%
Taylor expanded in c around inf
lower-/.f6466.3
Applied rewrites66.3%
if -9.99999999999999928e-35 < c < 1.6000000000000001e-114Initial program 71.8%
Taylor expanded in c around 0
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6467.4
Applied rewrites67.4%
if 1.6000000000000001e-114 < c < 7.4e-32Initial program 85.2%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6485.2
Applied rewrites85.2%
Taylor expanded in c around inf
*-commutativeN/A
lower-*.f6476.5
Applied rewrites76.5%
if 7.4e-32 < c < 6.5e38Initial program 68.1%
Taylor expanded in c around 0
unpow2N/A
lower-*.f6414.6
Applied rewrites14.6%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
frac-2negN/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-outN/A
lift-neg.f64N/A
lift-*.f64N/A
frac-subN/A
lower-/.f64N/A
Applied rewrites8.6%
Taylor expanded in c around inf
lower-/.f64N/A
+-commutativeN/A
mul-1-negN/A
associate-/l*N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f6457.6
Applied rewrites57.6%
Taylor expanded in c around 0
Applied rewrites55.6%
Final simplification66.9%
(FPCore (a b c d)
:precision binary64
(if (<= c -1e-34)
(/ b c)
(if (<= c 1.6e-114)
(/ (- a) d)
(if (<= c 7.4e-32)
(/ (* b c) (fma d d (* c c)))
(if (<= c 6.5e+38) (* (/ (- d) c) (/ a c)) (/ b c))))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -1e-34) {
tmp = b / c;
} else if (c <= 1.6e-114) {
tmp = -a / d;
} else if (c <= 7.4e-32) {
tmp = (b * c) / fma(d, d, (c * c));
} else if (c <= 6.5e+38) {
tmp = (-d / c) * (a / c);
} else {
tmp = b / c;
}
return tmp;
}
function code(a, b, c, d) tmp = 0.0 if (c <= -1e-34) tmp = Float64(b / c); elseif (c <= 1.6e-114) tmp = Float64(Float64(-a) / d); elseif (c <= 7.4e-32) tmp = Float64(Float64(b * c) / fma(d, d, Float64(c * c))); elseif (c <= 6.5e+38) tmp = Float64(Float64(Float64(-d) / c) * Float64(a / c)); else tmp = Float64(b / c); end return tmp end
code[a_, b_, c_, d_] := If[LessEqual[c, -1e-34], N[(b / c), $MachinePrecision], If[LessEqual[c, 1.6e-114], N[((-a) / d), $MachinePrecision], If[LessEqual[c, 7.4e-32], N[(N[(b * c), $MachinePrecision] / N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 6.5e+38], N[(N[((-d) / c), $MachinePrecision] * N[(a / c), $MachinePrecision]), $MachinePrecision], N[(b / c), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -1 \cdot 10^{-34}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{elif}\;c \leq 1.6 \cdot 10^{-114}:\\
\;\;\;\;\frac{-a}{d}\\
\mathbf{elif}\;c \leq 7.4 \cdot 10^{-32}:\\
\;\;\;\;\frac{b \cdot c}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\
\mathbf{elif}\;c \leq 6.5 \cdot 10^{+38}:\\
\;\;\;\;\frac{-d}{c} \cdot \frac{a}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if c < -9.99999999999999928e-35 or 6.5e38 < c Initial program 48.7%
Taylor expanded in c around inf
lower-/.f6466.3
Applied rewrites66.3%
if -9.99999999999999928e-35 < c < 1.6000000000000001e-114Initial program 71.8%
Taylor expanded in c around 0
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6467.4
Applied rewrites67.4%
if 1.6000000000000001e-114 < c < 7.4e-32Initial program 85.2%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6485.2
Applied rewrites85.2%
Taylor expanded in c around inf
*-commutativeN/A
lower-*.f6476.5
Applied rewrites76.5%
if 7.4e-32 < c < 6.5e38Initial program 68.1%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6468.1
Applied rewrites68.1%
Taylor expanded in c around -inf
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f64N/A
mul-1-negN/A
lower-neg.f6457.6
Applied rewrites57.6%
Taylor expanded in c around 0
Applied rewrites55.6%
Final simplification66.9%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (fma (- a) (/ d c) b) c)))
(if (<= c -2.4e-34)
t_0
(if (<= c 2.4e-142)
(/ (fma (/ c d) b (- a)) d)
(if (<= c 6.5e+137) (/ (- (* b c) (* d a)) (fma d d (* c c))) t_0)))))
double code(double a, double b, double c, double d) {
double t_0 = fma(-a, (d / c), b) / c;
double tmp;
if (c <= -2.4e-34) {
tmp = t_0;
} else if (c <= 2.4e-142) {
tmp = fma((c / d), b, -a) / d;
} else if (c <= 6.5e+137) {
tmp = ((b * c) - (d * a)) / fma(d, d, (c * c));
} else {
tmp = t_0;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(fma(Float64(-a), Float64(d / c), b) / c) tmp = 0.0 if (c <= -2.4e-34) tmp = t_0; elseif (c <= 2.4e-142) tmp = Float64(fma(Float64(c / d), b, Float64(-a)) / d); elseif (c <= 6.5e+137) tmp = Float64(Float64(Float64(b * c) - Float64(d * a)) / fma(d, d, Float64(c * c))); else tmp = t_0; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[((-a) * N[(d / c), $MachinePrecision] + b), $MachinePrecision] / c), $MachinePrecision]}, If[LessEqual[c, -2.4e-34], t$95$0, If[LessEqual[c, 2.4e-142], N[(N[(N[(c / d), $MachinePrecision] * b + (-a)), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 6.5e+137], N[(N[(N[(b * c), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\mathsf{fma}\left(-a, \frac{d}{c}, b\right)}{c}\\
\mathbf{if}\;c \leq -2.4 \cdot 10^{-34}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq 2.4 \cdot 10^{-142}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{c}{d}, b, -a\right)}{d}\\
\mathbf{elif}\;c \leq 6.5 \cdot 10^{+137}:\\
\;\;\;\;\frac{b \cdot c - d \cdot a}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if c < -2.39999999999999991e-34 or 6.5000000000000002e137 < c Initial program 45.4%
Taylor expanded in c around 0
unpow2N/A
lower-*.f6414.0
Applied rewrites14.0%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
frac-2negN/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-outN/A
lift-neg.f64N/A
lift-*.f64N/A
frac-subN/A
lower-/.f64N/A
Applied rewrites3.3%
Taylor expanded in c around inf
lower-/.f64N/A
+-commutativeN/A
mul-1-negN/A
associate-/l*N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f6482.7
Applied rewrites82.7%
if -2.39999999999999991e-34 < c < 2.39999999999999988e-142Initial program 70.4%
Taylor expanded in c around 0
unpow2N/A
lower-*.f6464.3
Applied rewrites64.3%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
frac-2negN/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-outN/A
lift-neg.f64N/A
lift-*.f64N/A
frac-subN/A
lower-/.f64N/A
Applied rewrites32.4%
Taylor expanded in c around inf
lower-/.f64N/A
+-commutativeN/A
mul-1-negN/A
associate-/l*N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f6432.1
Applied rewrites32.1%
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
sub-negN/A
*-commutativeN/A
associate-*l/N/A
mul-1-negN/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6487.9
Applied rewrites87.9%
if 2.39999999999999988e-142 < c < 6.5000000000000002e137Initial program 78.0%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6478.0
Applied rewrites78.0%
Final simplification83.6%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- a) d)))
(if (<= d -8.6e+58)
t_0
(if (<= d -1e-59)
(/ (- (* b c) (* d a)) (* d d))
(if (<= d 2.1e+122) (/ (- 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 <= -8.6e+58) {
tmp = t_0;
} else if (d <= -1e-59) {
tmp = ((b * c) - (d * a)) / (d * d);
} else if (d <= 2.1e+122) {
tmp = (b - ((d * a) / 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 <= (-8.6d+58)) then
tmp = t_0
else if (d <= (-1d-59)) then
tmp = ((b * c) - (d * a)) / (d * d)
else if (d <= 2.1d+122) then
tmp = (b - ((d * a) / 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 <= -8.6e+58) {
tmp = t_0;
} else if (d <= -1e-59) {
tmp = ((b * c) - (d * a)) / (d * d);
} else if (d <= 2.1e+122) {
tmp = (b - ((d * a) / c)) / c;
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b, c, d): t_0 = -a / d tmp = 0 if d <= -8.6e+58: tmp = t_0 elif d <= -1e-59: tmp = ((b * c) - (d * a)) / (d * d) elif d <= 2.1e+122: 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 <= -8.6e+58) tmp = t_0; elseif (d <= -1e-59) tmp = Float64(Float64(Float64(b * c) - Float64(d * a)) / Float64(d * d)); elseif (d <= 2.1e+122) tmp = Float64(Float64(b - Float64(Float64(d * a) / 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 <= -8.6e+58) tmp = t_0; elseif (d <= -1e-59) tmp = ((b * c) - (d * a)) / (d * d); elseif (d <= 2.1e+122) tmp = (b - ((d * a) / 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, -8.6e+58], t$95$0, If[LessEqual[d, -1e-59], N[(N[(N[(b * c), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(d * d), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.1e+122], 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 -8.6 \cdot 10^{+58}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq -1 \cdot 10^{-59}:\\
\;\;\;\;\frac{b \cdot c - d \cdot a}{d \cdot d}\\
\mathbf{elif}\;d \leq 2.1 \cdot 10^{+122}:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d < -8.59999999999999982e58 or 2.10000000000000016e122 < d Initial program 40.5%
Taylor expanded in c around 0
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6475.5
Applied rewrites75.5%
if -8.59999999999999982e58 < d < -1e-59Initial program 78.0%
Taylor expanded in c around 0
unpow2N/A
lower-*.f6464.1
Applied rewrites64.1%
if -1e-59 < d < 2.10000000000000016e122Initial 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
*-commutativeN/A
lower-*.f6477.7
Applied rewrites77.7%
Final simplification75.5%
(FPCore (a b c d)
:precision binary64
(if (<= c -1e-34)
(/ b c)
(if (<= c 1.6e-114)
(/ (- a) d)
(if (<= c 6.5e+111) (/ (* b c) (fma d d (* c c))) (/ b c)))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -1e-34) {
tmp = b / c;
} else if (c <= 1.6e-114) {
tmp = -a / d;
} else if (c <= 6.5e+111) {
tmp = (b * c) / fma(d, d, (c * c));
} else {
tmp = b / c;
}
return tmp;
}
function code(a, b, c, d) tmp = 0.0 if (c <= -1e-34) tmp = Float64(b / c); elseif (c <= 1.6e-114) tmp = Float64(Float64(-a) / d); elseif (c <= 6.5e+111) tmp = Float64(Float64(b * c) / fma(d, d, Float64(c * c))); else tmp = Float64(b / c); end return tmp end
code[a_, b_, c_, d_] := If[LessEqual[c, -1e-34], N[(b / c), $MachinePrecision], If[LessEqual[c, 1.6e-114], N[((-a) / d), $MachinePrecision], If[LessEqual[c, 6.5e+111], N[(N[(b * c), $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 \cdot 10^{-34}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{elif}\;c \leq 1.6 \cdot 10^{-114}:\\
\;\;\;\;\frac{-a}{d}\\
\mathbf{elif}\;c \leq 6.5 \cdot 10^{+111}:\\
\;\;\;\;\frac{b \cdot c}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if c < -9.99999999999999928e-35 or 6.5000000000000002e111 < c Initial program 46.2%
Taylor expanded in c around inf
lower-/.f6467.7
Applied rewrites67.7%
if -9.99999999999999928e-35 < c < 1.6000000000000001e-114Initial program 71.8%
Taylor expanded in c around 0
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6467.4
Applied rewrites67.4%
if 1.6000000000000001e-114 < c < 6.5000000000000002e111Initial program 77.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6477.9
Applied rewrites77.9%
Taylor expanded in c around inf
*-commutativeN/A
lower-*.f6453.6
Applied rewrites53.6%
Final simplification65.1%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (fma (- a) (/ d c) b) c)))
(if (<= c -2.4e-34)
t_0
(if (<= c 2.8e-53) (/ (fma (/ c d) b (- a)) d) t_0))))
double code(double a, double b, double c, double d) {
double t_0 = fma(-a, (d / c), b) / c;
double tmp;
if (c <= -2.4e-34) {
tmp = t_0;
} else if (c <= 2.8e-53) {
tmp = fma((c / d), b, -a) / d;
} else {
tmp = t_0;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(fma(Float64(-a), Float64(d / c), b) / c) tmp = 0.0 if (c <= -2.4e-34) tmp = t_0; elseif (c <= 2.8e-53) tmp = Float64(fma(Float64(c / d), b, Float64(-a)) / d); else tmp = t_0; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[((-a) * N[(d / c), $MachinePrecision] + b), $MachinePrecision] / c), $MachinePrecision]}, If[LessEqual[c, -2.4e-34], t$95$0, If[LessEqual[c, 2.8e-53], N[(N[(N[(c / d), $MachinePrecision] * b + (-a)), $MachinePrecision] / d), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\mathsf{fma}\left(-a, \frac{d}{c}, b\right)}{c}\\
\mathbf{if}\;c \leq -2.4 \cdot 10^{-34}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq 2.8 \cdot 10^{-53}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{c}{d}, b, -a\right)}{d}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if c < -2.39999999999999991e-34 or 2.79999999999999985e-53 < c Initial program 52.5%
Taylor expanded in c around 0
unpow2N/A
lower-*.f6414.9
Applied rewrites14.9%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
frac-2negN/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-outN/A
lift-neg.f64N/A
lift-*.f64N/A
frac-subN/A
lower-/.f64N/A
Applied rewrites4.4%
Taylor expanded in c around inf
lower-/.f64N/A
+-commutativeN/A
mul-1-negN/A
associate-/l*N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f6477.9
Applied rewrites77.9%
if -2.39999999999999991e-34 < c < 2.79999999999999985e-53Initial program 73.2%
Taylor expanded in c around 0
unpow2N/A
lower-*.f6461.9
Applied rewrites61.9%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
frac-2negN/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-outN/A
lift-neg.f64N/A
lift-*.f64N/A
frac-subN/A
lower-/.f64N/A
Applied rewrites31.6%
Taylor expanded in c around inf
lower-/.f64N/A
+-commutativeN/A
mul-1-negN/A
associate-/l*N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f6432.8
Applied rewrites32.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
sub-negN/A
*-commutativeN/A
associate-*l/N/A
mul-1-negN/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6483.9
Applied rewrites83.9%
(FPCore (a b c d) :precision binary64 (let* ((t_0 (/ (fma (- a) (/ d c) b) c))) (if (<= c -2.4e-34) t_0 (if (<= c 2.8e-53) (/ (- (/ (* b c) d) a) d) t_0))))
double code(double a, double b, double c, double d) {
double t_0 = fma(-a, (d / c), b) / c;
double tmp;
if (c <= -2.4e-34) {
tmp = t_0;
} else if (c <= 2.8e-53) {
tmp = (((b * c) / d) - a) / d;
} else {
tmp = t_0;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(fma(Float64(-a), Float64(d / c), b) / c) tmp = 0.0 if (c <= -2.4e-34) tmp = t_0; elseif (c <= 2.8e-53) tmp = Float64(Float64(Float64(Float64(b * c) / d) - a) / d); else tmp = t_0; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[((-a) * N[(d / c), $MachinePrecision] + b), $MachinePrecision] / c), $MachinePrecision]}, If[LessEqual[c, -2.4e-34], t$95$0, If[LessEqual[c, 2.8e-53], N[(N[(N[(N[(b * c), $MachinePrecision] / d), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\mathsf{fma}\left(-a, \frac{d}{c}, b\right)}{c}\\
\mathbf{if}\;c \leq -2.4 \cdot 10^{-34}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq 2.8 \cdot 10^{-53}:\\
\;\;\;\;\frac{\frac{b \cdot c}{d} - a}{d}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if c < -2.39999999999999991e-34 or 2.79999999999999985e-53 < c Initial program 52.5%
Taylor expanded in c around 0
unpow2N/A
lower-*.f6414.9
Applied rewrites14.9%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
frac-2negN/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-outN/A
lift-neg.f64N/A
lift-*.f64N/A
frac-subN/A
lower-/.f64N/A
Applied rewrites4.4%
Taylor expanded in c around inf
lower-/.f64N/A
+-commutativeN/A
mul-1-negN/A
associate-/l*N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f6477.9
Applied rewrites77.9%
if -2.39999999999999991e-34 < c < 2.79999999999999985e-53Initial program 73.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
lower-/.f64N/A
lower--.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6483.9
Applied rewrites83.9%
Final simplification80.7%
(FPCore (a b c d) :precision binary64 (let* ((t_0 (/ (fma (/ b d) c (- a)) d))) (if (<= d -1e-59) t_0 (if (<= d 2.8e+56) (/ (- b (/ (* d a) c)) c) t_0))))
double code(double a, double b, double c, double d) {
double t_0 = fma((b / d), c, -a) / d;
double tmp;
if (d <= -1e-59) {
tmp = t_0;
} else if (d <= 2.8e+56) {
tmp = (b - ((d * a) / c)) / c;
} else {
tmp = t_0;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(fma(Float64(b / d), c, Float64(-a)) / d) tmp = 0.0 if (d <= -1e-59) tmp = t_0; elseif (d <= 2.8e+56) 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[(N[(N[(b / d), $MachinePrecision] * c + (-a)), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -1e-59], t$95$0, If[LessEqual[d, 2.8e+56], 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{\mathsf{fma}\left(\frac{b}{d}, c, -a\right)}{d}\\
\mathbf{if}\;d \leq -1 \cdot 10^{-59}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 2.8 \cdot 10^{+56}:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d < -1e-59 or 2.80000000000000008e56 < d Initial program 50.5%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6450.5
Applied rewrites50.5%
Taylor expanded in d around inf
lower-/.f64N/A
+-commutativeN/A
mul-1-negN/A
sub-negN/A
lower--.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6474.5
Applied rewrites74.5%
Applied rewrites75.5%
if -1e-59 < d < 2.80000000000000008e56Initial program 73.6%
Taylor expanded in c around inf
lower-/.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6481.0
Applied rewrites81.0%
(FPCore (a b c d) :precision binary64 (let* ((t_0 (/ (- b (/ (* d a) c)) c))) (if (<= c -2.4e-34) t_0 (if (<= c 2.8e-53) (/ (- (/ (* b c) d) a) d) t_0))))
double code(double a, double b, double c, double d) {
double t_0 = (b - ((d * a) / c)) / c;
double tmp;
if (c <= -2.4e-34) {
tmp = t_0;
} else if (c <= 2.8e-53) {
tmp = (((b * c) / d) - a) / d;
} 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 = (b - ((d * a) / c)) / c
if (c <= (-2.4d-34)) then
tmp = t_0
else if (c <= 2.8d-53) then
tmp = (((b * c) / d) - a) / d
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 = (b - ((d * a) / c)) / c;
double tmp;
if (c <= -2.4e-34) {
tmp = t_0;
} else if (c <= 2.8e-53) {
tmp = (((b * c) / d) - a) / d;
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b, c, d): t_0 = (b - ((d * a) / c)) / c tmp = 0 if c <= -2.4e-34: tmp = t_0 elif c <= 2.8e-53: tmp = (((b * c) / d) - a) / d else: tmp = t_0 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(b - Float64(Float64(d * a) / c)) / c) tmp = 0.0 if (c <= -2.4e-34) tmp = t_0; elseif (c <= 2.8e-53) tmp = Float64(Float64(Float64(Float64(b * c) / d) - a) / d); else tmp = t_0; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (b - ((d * a) / c)) / c; tmp = 0.0; if (c <= -2.4e-34) tmp = t_0; elseif (c <= 2.8e-53) tmp = (((b * c) / d) - a) / d; else tmp = t_0; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]}, If[LessEqual[c, -2.4e-34], t$95$0, If[LessEqual[c, 2.8e-53], N[(N[(N[(N[(b * c), $MachinePrecision] / d), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b - \frac{d \cdot a}{c}}{c}\\
\mathbf{if}\;c \leq -2.4 \cdot 10^{-34}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq 2.8 \cdot 10^{-53}:\\
\;\;\;\;\frac{\frac{b \cdot c}{d} - a}{d}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if c < -2.39999999999999991e-34 or 2.79999999999999985e-53 < c Initial program 52.5%
Taylor expanded in c around inf
lower-/.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6473.1
Applied rewrites73.1%
if -2.39999999999999991e-34 < c < 2.79999999999999985e-53Initial program 73.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
lower-/.f64N/A
lower--.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6483.9
Applied rewrites83.9%
Final simplification78.2%
(FPCore (a b c d) :precision binary64 (let* ((t_0 (/ (- a) d))) (if (<= d -5.2e-40) t_0 (if (<= d 3.5e-30) (/ b c) t_0))))
double code(double a, double b, double c, double d) {
double t_0 = -a / d;
double tmp;
if (d <= -5.2e-40) {
tmp = t_0;
} else if (d <= 3.5e-30) {
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 <= (-5.2d-40)) then
tmp = t_0
else if (d <= 3.5d-30) 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 <= -5.2e-40) {
tmp = t_0;
} else if (d <= 3.5e-30) {
tmp = b / c;
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b, c, d): t_0 = -a / d tmp = 0 if d <= -5.2e-40: tmp = t_0 elif d <= 3.5e-30: 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 <= -5.2e-40) tmp = t_0; elseif (d <= 3.5e-30) 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 <= -5.2e-40) tmp = t_0; elseif (d <= 3.5e-30) 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, -5.2e-40], t$95$0, If[LessEqual[d, 3.5e-30], N[(b / c), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-a}{d}\\
\mathbf{if}\;d \leq -5.2 \cdot 10^{-40}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 3.5 \cdot 10^{-30}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d < -5.2000000000000003e-40 or 3.5000000000000003e-30 < d Initial program 51.4%
Taylor expanded in c around 0
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6462.0
Applied rewrites62.0%
if -5.2000000000000003e-40 < d < 3.5000000000000003e-30Initial program 75.8%
Taylor expanded in c around inf
lower-/.f6463.9
Applied rewrites63.9%
(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 62.2%
Taylor expanded in c around inf
lower-/.f6442.4
Applied rewrites42.4%
(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 2024249
(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))))