
(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 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b c d) :precision binary64 (/ (- (* b c) (* a d)) (+ (* c c) (* d d))))
double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = ((b * c) - (a * d)) / ((c * c) + (d * d))
end function
public static double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
def code(a, b, c, d): return ((b * c) - (a * d)) / ((c * c) + (d * d))
function code(a, b, c, d) return Float64(Float64(Float64(b * c) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d))) end
function tmp = code(a, b, c, d) tmp = ((b * c) - (a * d)) / ((c * c) + (d * d)); end
code[a_, b_, c_, d_] := N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}
\end{array}
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (fma d d (* c c))) (t_1 (/ (fma c (/ b d) (- a)) d)))
(if (<= d -1.05e+62)
t_1
(if (<= d -5.2e-104)
(fma (/ c t_0) b (/ (* d (- a)) t_0))
(if (<= d 3e-101)
(/ (fma (- d) (/ a c) b) c)
(if (<= d 4e+88) (* a (fma b (/ c (* a t_0)) (/ (- d) t_0))) t_1))))))
double code(double a, double b, double c, double d) {
double t_0 = fma(d, d, (c * c));
double t_1 = fma(c, (b / d), -a) / d;
double tmp;
if (d <= -1.05e+62) {
tmp = t_1;
} else if (d <= -5.2e-104) {
tmp = fma((c / t_0), b, ((d * -a) / t_0));
} else if (d <= 3e-101) {
tmp = fma(-d, (a / c), b) / c;
} else if (d <= 4e+88) {
tmp = a * fma(b, (c / (a * t_0)), (-d / t_0));
} else {
tmp = t_1;
}
return tmp;
}
function code(a, b, c, d) t_0 = fma(d, d, Float64(c * c)) t_1 = Float64(fma(c, Float64(b / d), Float64(-a)) / d) tmp = 0.0 if (d <= -1.05e+62) tmp = t_1; elseif (d <= -5.2e-104) tmp = fma(Float64(c / t_0), b, Float64(Float64(d * Float64(-a)) / t_0)); elseif (d <= 3e-101) tmp = Float64(fma(Float64(-d), Float64(a / c), b) / c); elseif (d <= 4e+88) tmp = Float64(a * fma(b, Float64(c / Float64(a * t_0)), Float64(Float64(-d) / t_0))); else tmp = t_1; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(c * N[(b / d), $MachinePrecision] + (-a)), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -1.05e+62], t$95$1, If[LessEqual[d, -5.2e-104], N[(N[(c / t$95$0), $MachinePrecision] * b + N[(N[(d * (-a)), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 3e-101], N[(N[((-d) * N[(a / c), $MachinePrecision] + b), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 4e+88], N[(a * N[(b * N[(c / N[(a * t$95$0), $MachinePrecision]), $MachinePrecision] + N[((-d) / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(d, d, c \cdot c\right)\\
t_1 := \frac{\mathsf{fma}\left(c, \frac{b}{d}, -a\right)}{d}\\
\mathbf{if}\;d \leq -1.05 \cdot 10^{+62}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d \leq -5.2 \cdot 10^{-104}:\\
\;\;\;\;\mathsf{fma}\left(\frac{c}{t\_0}, b, \frac{d \cdot \left(-a\right)}{t\_0}\right)\\
\mathbf{elif}\;d \leq 3 \cdot 10^{-101}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-d, \frac{a}{c}, b\right)}{c}\\
\mathbf{elif}\;d \leq 4 \cdot 10^{+88}:\\
\;\;\;\;a \cdot \mathsf{fma}\left(b, \frac{c}{a \cdot t\_0}, \frac{-d}{t\_0}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if d < -1.05e62 or 3.99999999999999984e88 < d Initial program 40.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.f6486.7
Applied rewrites86.7%
if -1.05e62 < d < -5.20000000000000005e-104Initial program 80.7%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
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
distribute-neg-frac2N/A
Applied rewrites83.6%
if -5.20000000000000005e-104 < d < 3.0000000000000003e-101Initial program 69.7%
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-*.f6491.2
Applied rewrites91.2%
lift-*.f64N/A
lift-/.f64N/A
sub-negN/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f64N/A
lower-/.f6491.2
Applied rewrites91.2%
if 3.0000000000000003e-101 < d < 3.99999999999999984e88Initial program 83.8%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
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
distribute-neg-frac2N/A
Applied rewrites84.0%
Taylor expanded in a around inf
lower-*.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
+-commutativeN/A
unpow2N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f64N/A
+-commutativeN/A
unpow2N/A
lower-fma.f64N/A
Applied rewrites86.8%
Final simplification87.8%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (fma d d (* c c))) (t_1 (/ (fma c (/ b d) (- a)) d)))
(if (<= d -1.05e+62)
t_1
(if (<= d -5.2e-104)
(fma (/ c t_0) b (/ (* d (- a)) t_0))
(if (<= d 2.4e-101)
(/ (fma (- d) (/ a c) b) c)
(if (<= d 2.7e+88) (fma (- d) (/ a t_0) (/ (* c b) t_0)) t_1))))))
double code(double a, double b, double c, double d) {
double t_0 = fma(d, d, (c * c));
double t_1 = fma(c, (b / d), -a) / d;
double tmp;
if (d <= -1.05e+62) {
tmp = t_1;
} else if (d <= -5.2e-104) {
tmp = fma((c / t_0), b, ((d * -a) / t_0));
} else if (d <= 2.4e-101) {
tmp = fma(-d, (a / c), b) / c;
} else if (d <= 2.7e+88) {
tmp = fma(-d, (a / t_0), ((c * b) / t_0));
} else {
tmp = t_1;
}
return tmp;
}
function code(a, b, c, d) t_0 = fma(d, d, Float64(c * c)) t_1 = Float64(fma(c, Float64(b / d), Float64(-a)) / d) tmp = 0.0 if (d <= -1.05e+62) tmp = t_1; elseif (d <= -5.2e-104) tmp = fma(Float64(c / t_0), b, Float64(Float64(d * Float64(-a)) / t_0)); elseif (d <= 2.4e-101) tmp = Float64(fma(Float64(-d), Float64(a / c), b) / c); elseif (d <= 2.7e+88) tmp = fma(Float64(-d), Float64(a / t_0), Float64(Float64(c * b) / t_0)); else tmp = t_1; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(c * N[(b / d), $MachinePrecision] + (-a)), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -1.05e+62], t$95$1, If[LessEqual[d, -5.2e-104], N[(N[(c / t$95$0), $MachinePrecision] * b + N[(N[(d * (-a)), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.4e-101], N[(N[((-d) * N[(a / c), $MachinePrecision] + b), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 2.7e+88], N[((-d) * N[(a / t$95$0), $MachinePrecision] + N[(N[(c * b), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(d, d, c \cdot c\right)\\
t_1 := \frac{\mathsf{fma}\left(c, \frac{b}{d}, -a\right)}{d}\\
\mathbf{if}\;d \leq -1.05 \cdot 10^{+62}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d \leq -5.2 \cdot 10^{-104}:\\
\;\;\;\;\mathsf{fma}\left(\frac{c}{t\_0}, b, \frac{d \cdot \left(-a\right)}{t\_0}\right)\\
\mathbf{elif}\;d \leq 2.4 \cdot 10^{-101}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-d, \frac{a}{c}, b\right)}{c}\\
\mathbf{elif}\;d \leq 2.7 \cdot 10^{+88}:\\
\;\;\;\;\mathsf{fma}\left(-d, \frac{a}{t\_0}, \frac{c \cdot b}{t\_0}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if d < -1.05e62 or 2.70000000000000016e88 < d Initial program 40.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.f6486.7
Applied rewrites86.7%
if -1.05e62 < d < -5.20000000000000005e-104Initial program 80.7%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
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
distribute-neg-frac2N/A
Applied rewrites83.6%
if -5.20000000000000005e-104 < d < 2.4e-101Initial program 69.7%
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-*.f6491.2
Applied rewrites91.2%
lift-*.f64N/A
lift-/.f64N/A
sub-negN/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f64N/A
lower-/.f6491.2
Applied rewrites91.2%
if 2.4e-101 < d < 2.70000000000000016e88Initial program 83.8%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
div-subN/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
Applied rewrites85.6%
Final simplification87.6%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (fma d d (* c c)))
(t_1 (fma (- d) (/ a t_0) (/ (* c b) t_0)))
(t_2 (/ (fma c (/ b d) (- a)) d)))
(if (<= d -3.6e+62)
t_2
(if (<= d -2.8e-97)
t_1
(if (<= d 2.4e-101)
(/ (fma (- d) (/ a c) b) c)
(if (<= d 2.7e+88) t_1 t_2))))))
double code(double a, double b, double c, double d) {
double t_0 = fma(d, d, (c * c));
double t_1 = fma(-d, (a / t_0), ((c * b) / t_0));
double t_2 = fma(c, (b / d), -a) / d;
double tmp;
if (d <= -3.6e+62) {
tmp = t_2;
} else if (d <= -2.8e-97) {
tmp = t_1;
} else if (d <= 2.4e-101) {
tmp = fma(-d, (a / c), b) / c;
} else if (d <= 2.7e+88) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
function code(a, b, c, d) t_0 = fma(d, d, Float64(c * c)) t_1 = fma(Float64(-d), Float64(a / t_0), Float64(Float64(c * b) / t_0)) t_2 = Float64(fma(c, Float64(b / d), Float64(-a)) / d) tmp = 0.0 if (d <= -3.6e+62) tmp = t_2; elseif (d <= -2.8e-97) tmp = t_1; elseif (d <= 2.4e-101) tmp = Float64(fma(Float64(-d), Float64(a / c), b) / c); elseif (d <= 2.7e+88) tmp = t_1; else tmp = t_2; 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[((-d) * N[(a / t$95$0), $MachinePrecision] + N[(N[(c * b), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(c * N[(b / d), $MachinePrecision] + (-a)), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -3.6e+62], t$95$2, If[LessEqual[d, -2.8e-97], t$95$1, If[LessEqual[d, 2.4e-101], N[(N[((-d) * N[(a / c), $MachinePrecision] + b), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 2.7e+88], t$95$1, t$95$2]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(d, d, c \cdot c\right)\\
t_1 := \mathsf{fma}\left(-d, \frac{a}{t\_0}, \frac{c \cdot b}{t\_0}\right)\\
t_2 := \frac{\mathsf{fma}\left(c, \frac{b}{d}, -a\right)}{d}\\
\mathbf{if}\;d \leq -3.6 \cdot 10^{+62}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;d \leq -2.8 \cdot 10^{-97}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d \leq 2.4 \cdot 10^{-101}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-d, \frac{a}{c}, b\right)}{c}\\
\mathbf{elif}\;d \leq 2.7 \cdot 10^{+88}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if d < -3.6e62 or 2.70000000000000016e88 < d Initial program 40.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.f6486.7
Applied rewrites86.7%
if -3.6e62 < d < -2.8000000000000002e-97 or 2.4e-101 < d < 2.70000000000000016e88Initial program 81.5%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
div-subN/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
Applied rewrites83.8%
if -2.8000000000000002e-97 < d < 2.4e-101Initial program 70.7%
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-*.f6490.5
Applied rewrites90.5%
lift-*.f64N/A
lift-/.f64N/A
sub-negN/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f64N/A
lower-/.f6490.5
Applied rewrites90.5%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* c b) (* d a)) (+ (* c c) (* d d))))
(t_1 (/ (fma c (/ b d) (- a)) d)))
(if (<= d -9.2e+61)
t_1
(if (<= d -5.2e-104)
t_0
(if (<= d 2.6e-102)
(/ (fma (- d) (/ a c) b) c)
(if (<= d 3.2e+78) t_0 t_1))))))
double code(double a, double b, double c, double d) {
double t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
double t_1 = fma(c, (b / d), -a) / d;
double tmp;
if (d <= -9.2e+61) {
tmp = t_1;
} else if (d <= -5.2e-104) {
tmp = t_0;
} else if (d <= 2.6e-102) {
tmp = fma(-d, (a / c), b) / c;
} else if (d <= 3.2e+78) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d))) t_1 = Float64(fma(c, Float64(b / d), Float64(-a)) / d) tmp = 0.0 if (d <= -9.2e+61) tmp = t_1; elseif (d <= -5.2e-104) tmp = t_0; elseif (d <= 2.6e-102) tmp = Float64(fma(Float64(-d), Float64(a / c), b) / c); elseif (d <= 3.2e+78) tmp = t_0; else tmp = t_1; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(c * N[(b / d), $MachinePrecision] + (-a)), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -9.2e+61], t$95$1, If[LessEqual[d, -5.2e-104], t$95$0, If[LessEqual[d, 2.6e-102], N[(N[((-d) * N[(a / c), $MachinePrecision] + b), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 3.2e+78], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
t_1 := \frac{\mathsf{fma}\left(c, \frac{b}{d}, -a\right)}{d}\\
\mathbf{if}\;d \leq -9.2 \cdot 10^{+61}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d \leq -5.2 \cdot 10^{-104}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 2.6 \cdot 10^{-102}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-d, \frac{a}{c}, b\right)}{c}\\
\mathbf{elif}\;d \leq 3.2 \cdot 10^{+78}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if d < -9.1999999999999998e61 or 3.19999999999999994e78 < d Initial program 40.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.f6486.7
Applied rewrites86.7%
if -9.1999999999999998e61 < d < -5.20000000000000005e-104 or 2.59999999999999986e-102 < d < 3.19999999999999994e78Initial program 82.3%
if -5.20000000000000005e-104 < d < 2.59999999999999986e-102Initial program 69.7%
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-*.f6491.2
Applied rewrites91.2%
lift-*.f64N/A
lift-/.f64N/A
sub-negN/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f64N/A
lower-/.f6491.2
Applied rewrites91.2%
Final simplification87.0%
(FPCore (a b c d)
:precision binary64
(if (<= d -5.3e+45)
(/ -1.0 (/ d a))
(if (<= d 6.5e-67)
(/ b c)
(if (<= d 3.8e+88) (* a (/ (- d) (fma c c (* d d)))) (/ a (- d))))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -5.3e+45) {
tmp = -1.0 / (d / a);
} else if (d <= 6.5e-67) {
tmp = b / c;
} else if (d <= 3.8e+88) {
tmp = a * (-d / fma(c, c, (d * d)));
} else {
tmp = a / -d;
}
return tmp;
}
function code(a, b, c, d) tmp = 0.0 if (d <= -5.3e+45) tmp = Float64(-1.0 / Float64(d / a)); elseif (d <= 6.5e-67) tmp = Float64(b / c); elseif (d <= 3.8e+88) tmp = Float64(a * Float64(Float64(-d) / fma(c, c, Float64(d * d)))); else tmp = Float64(a / Float64(-d)); end return tmp end
code[a_, b_, c_, d_] := If[LessEqual[d, -5.3e+45], N[(-1.0 / N[(d / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 6.5e-67], N[(b / c), $MachinePrecision], If[LessEqual[d, 3.8e+88], N[(a * N[((-d) / N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a / (-d)), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -5.3 \cdot 10^{+45}:\\
\;\;\;\;\frac{-1}{\frac{d}{a}}\\
\mathbf{elif}\;d \leq 6.5 \cdot 10^{-67}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{elif}\;d \leq 3.8 \cdot 10^{+88}:\\
\;\;\;\;a \cdot \frac{-d}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{-d}\\
\end{array}
\end{array}
if d < -5.29999999999999991e45Initial program 42.4%
Taylor expanded in c around 0
Applied rewrites68.5%
Taylor expanded in c around 0
mul-1-negN/A
lower-neg.f6472.5
Applied rewrites72.5%
lift-neg.f64N/A
frac-2negN/A
lift-neg.f64N/A
div-invN/A
lift-neg.f64N/A
remove-double-negN/A
lower-*.f64N/A
metadata-evalN/A
frac-2negN/A
metadata-evalN/A
metadata-evalN/A
lift-neg.f64N/A
remove-double-negN/A
lower-/.f6472.3
Applied rewrites72.3%
associate-*r/N/A
clear-numN/A
*-commutativeN/A
neg-mul-1N/A
lift-neg.f64N/A
lift-/.f64N/A
frac-2negN/A
metadata-evalN/A
lower-/.f64N/A
lift-/.f64N/A
lift-neg.f64N/A
distribute-frac-neg2N/A
remove-double-negN/A
lower-/.f6473.2
Applied rewrites73.2%
if -5.29999999999999991e45 < d < 6.4999999999999997e-67Initial program 73.1%
Taylor expanded in c around inf
lower-/.f6467.4
Applied rewrites67.4%
if 6.4999999999999997e-67 < d < 3.7999999999999997e88Initial program 84.8%
Taylor expanded in b around 0
mul-1-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-neg.f64N/A
+-commutativeN/A
unpow2N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6473.7
Applied rewrites73.7%
*-commutativeN/A
lift-*.f64N/A
lift-fma.f64N/A
lift-neg.f64N/A
associate-/l*N/A
lower-*.f64N/A
frac-2negN/A
lift-neg.f64N/A
remove-double-negN/A
lower-/.f64N/A
lower-neg.f6477.5
lift-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
lower-*.f6477.5
Applied rewrites77.5%
if 3.7999999999999997e88 < d Initial program 42.8%
Taylor expanded in c around 0
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6476.1
Applied rewrites76.1%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (fma c (/ b d) (- a)) d)))
(if (<= d -6.2e+42)
t_0
(if (<= d 2.3e-41) (/ (fma (- d) (/ a c) b) 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 <= -6.2e+42) {
tmp = t_0;
} else if (d <= 2.3e-41) {
tmp = fma(-d, (a / c), b) / 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 <= -6.2e+42) tmp = t_0; elseif (d <= 2.3e-41) tmp = Float64(fma(Float64(-d), Float64(a / c), b) / 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, -6.2e+42], t$95$0, If[LessEqual[d, 2.3e-41], N[(N[((-d) * N[(a / c), $MachinePrecision] + b), $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 -6.2 \cdot 10^{+42}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 2.3 \cdot 10^{-41}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-d, \frac{a}{c}, b\right)}{c}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d < -6.2000000000000003e42 or 2.3000000000000001e-41 < d Initial program 49.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
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.f6482.2
Applied rewrites82.2%
if -6.2000000000000003e42 < d < 2.3000000000000001e-41Initial program 73.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-*.f6484.2
Applied rewrites84.2%
lift-*.f64N/A
lift-/.f64N/A
sub-negN/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f64N/A
lower-/.f6484.3
Applied rewrites84.3%
(FPCore (a b c d) :precision binary64 (let* ((t_0 (/ (fma c (/ b d) (- a)) d))) (if (<= d -3.9e+42) t_0 (if (<= d 2.3e-41) (/ (- b (/ (* d a) 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.9e+42) {
tmp = t_0;
} else if (d <= 2.3e-41) {
tmp = (b - ((d * a) / 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.9e+42) tmp = t_0; elseif (d <= 2.3e-41) 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[(c * N[(b / d), $MachinePrecision] + (-a)), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -3.9e+42], t$95$0, If[LessEqual[d, 2.3e-41], 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(c, \frac{b}{d}, -a\right)}{d}\\
\mathbf{if}\;d \leq -3.9 \cdot 10^{+42}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 2.3 \cdot 10^{-41}:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d < -3.8999999999999997e42 or 2.3000000000000001e-41 < d Initial program 49.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
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.f6482.2
Applied rewrites82.2%
if -3.8999999999999997e42 < d < 2.3000000000000001e-41Initial program 73.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-*.f6484.2
Applied rewrites84.2%
(FPCore (a b c d) :precision binary64 (let* ((t_0 (/ (- (/ (* c b) d) a) d))) (if (<= d -3.9e+42) t_0 (if (<= d 2.3e-41) (/ (- b (/ (* d a) 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.9e+42) {
tmp = t_0;
} else if (d <= 2.3e-41) {
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 = (((c * b) / d) - a) / d
if (d <= (-3.9d+42)) then
tmp = t_0
else if (d <= 2.3d-41) 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 = (((c * b) / d) - a) / d;
double tmp;
if (d <= -3.9e+42) {
tmp = t_0;
} else if (d <= 2.3e-41) {
tmp = (b - ((d * a) / 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.9e+42: tmp = t_0 elif d <= 2.3e-41: tmp = (b - ((d * a) / 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.9e+42) tmp = t_0; elseif (d <= 2.3e-41) 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 = (((c * b) / d) - a) / d; tmp = 0.0; if (d <= -3.9e+42) tmp = t_0; elseif (d <= 2.3e-41) 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[(N[(N[(N[(c * b), $MachinePrecision] / d), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -3.9e+42], t$95$0, If[LessEqual[d, 2.3e-41], 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{\frac{c \cdot b}{d} - a}{d}\\
\mathbf{if}\;d \leq -3.9 \cdot 10^{+42}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 2.3 \cdot 10^{-41}:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d < -3.8999999999999997e42 or 2.3000000000000001e-41 < d Initial program 49.3%
Taylor expanded in c around 0
Applied rewrites65.7%
Taylor expanded in c around 0
lower-*.f6475.2
Applied rewrites75.2%
if -3.8999999999999997e42 < d < 2.3000000000000001e-41Initial program 73.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-*.f6484.2
Applied rewrites84.2%
Final simplification79.9%
(FPCore (a b c d) :precision binary64 (if (<= d -5.3e+45) (/ -1.0 (/ d a)) (if (<= d 2.3e-41) (/ (- b (/ (* d a) c)) c) (/ a (- d)))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -5.3e+45) {
tmp = -1.0 / (d / a);
} else if (d <= 2.3e-41) {
tmp = (b - ((d * a) / c)) / c;
} else {
tmp = a / -d;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (d <= (-5.3d+45)) then
tmp = (-1.0d0) / (d / a)
else if (d <= 2.3d-41) then
tmp = (b - ((d * a) / c)) / c
else
tmp = a / -d
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (d <= -5.3e+45) {
tmp = -1.0 / (d / a);
} else if (d <= 2.3e-41) {
tmp = (b - ((d * a) / c)) / c;
} else {
tmp = a / -d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -5.3e+45: tmp = -1.0 / (d / a) elif d <= 2.3e-41: tmp = (b - ((d * a) / c)) / c else: tmp = a / -d return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -5.3e+45) tmp = Float64(-1.0 / Float64(d / a)); elseif (d <= 2.3e-41) tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c); else tmp = Float64(a / Float64(-d)); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= -5.3e+45) tmp = -1.0 / (d / a); elseif (d <= 2.3e-41) tmp = (b - ((d * a) / c)) / c; else tmp = a / -d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -5.3e+45], N[(-1.0 / N[(d / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.3e-41], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], N[(a / (-d)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -5.3 \cdot 10^{+45}:\\
\;\;\;\;\frac{-1}{\frac{d}{a}}\\
\mathbf{elif}\;d \leq 2.3 \cdot 10^{-41}:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{-d}\\
\end{array}
\end{array}
if d < -5.29999999999999991e45Initial program 42.4%
Taylor expanded in c around 0
Applied rewrites68.5%
Taylor expanded in c around 0
mul-1-negN/A
lower-neg.f6472.5
Applied rewrites72.5%
lift-neg.f64N/A
frac-2negN/A
lift-neg.f64N/A
div-invN/A
lift-neg.f64N/A
remove-double-negN/A
lower-*.f64N/A
metadata-evalN/A
frac-2negN/A
metadata-evalN/A
metadata-evalN/A
lift-neg.f64N/A
remove-double-negN/A
lower-/.f6472.3
Applied rewrites72.3%
associate-*r/N/A
clear-numN/A
*-commutativeN/A
neg-mul-1N/A
lift-neg.f64N/A
lift-/.f64N/A
frac-2negN/A
metadata-evalN/A
lower-/.f64N/A
lift-/.f64N/A
lift-neg.f64N/A
distribute-frac-neg2N/A
remove-double-negN/A
lower-/.f6473.2
Applied rewrites73.2%
if -5.29999999999999991e45 < d < 2.3000000000000001e-41Initial program 74.1%
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-*.f6483.7
Applied rewrites83.7%
if 2.3000000000000001e-41 < d Initial program 54.6%
Taylor expanded in c around 0
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6470.2
Applied rewrites70.2%
(FPCore (a b c d) :precision binary64 (if (<= d -5.3e+45) (/ -1.0 (/ d a)) (if (<= d 9.8e-61) (/ b c) (/ a (- d)))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -5.3e+45) {
tmp = -1.0 / (d / a);
} else if (d <= 9.8e-61) {
tmp = b / c;
} else {
tmp = a / -d;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (d <= (-5.3d+45)) then
tmp = (-1.0d0) / (d / a)
else if (d <= 9.8d-61) then
tmp = b / c
else
tmp = a / -d
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (d <= -5.3e+45) {
tmp = -1.0 / (d / a);
} else if (d <= 9.8e-61) {
tmp = b / c;
} else {
tmp = a / -d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -5.3e+45: tmp = -1.0 / (d / a) elif d <= 9.8e-61: tmp = b / c else: tmp = a / -d return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -5.3e+45) tmp = Float64(-1.0 / Float64(d / a)); elseif (d <= 9.8e-61) tmp = Float64(b / c); else tmp = Float64(a / Float64(-d)); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= -5.3e+45) tmp = -1.0 / (d / a); elseif (d <= 9.8e-61) tmp = b / c; else tmp = a / -d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -5.3e+45], N[(-1.0 / N[(d / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 9.8e-61], N[(b / c), $MachinePrecision], N[(a / (-d)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -5.3 \cdot 10^{+45}:\\
\;\;\;\;\frac{-1}{\frac{d}{a}}\\
\mathbf{elif}\;d \leq 9.8 \cdot 10^{-61}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{-d}\\
\end{array}
\end{array}
if d < -5.29999999999999991e45Initial program 42.4%
Taylor expanded in c around 0
Applied rewrites68.5%
Taylor expanded in c around 0
mul-1-negN/A
lower-neg.f6472.5
Applied rewrites72.5%
lift-neg.f64N/A
frac-2negN/A
lift-neg.f64N/A
div-invN/A
lift-neg.f64N/A
remove-double-negN/A
lower-*.f64N/A
metadata-evalN/A
frac-2negN/A
metadata-evalN/A
metadata-evalN/A
lift-neg.f64N/A
remove-double-negN/A
lower-/.f6472.3
Applied rewrites72.3%
associate-*r/N/A
clear-numN/A
*-commutativeN/A
neg-mul-1N/A
lift-neg.f64N/A
lift-/.f64N/A
frac-2negN/A
metadata-evalN/A
lower-/.f64N/A
lift-/.f64N/A
lift-neg.f64N/A
distribute-frac-neg2N/A
remove-double-negN/A
lower-/.f6473.2
Applied rewrites73.2%
if -5.29999999999999991e45 < d < 9.80000000000000004e-61Initial program 73.5%
Taylor expanded in c around inf
lower-/.f6467.2
Applied rewrites67.2%
if 9.80000000000000004e-61 < d Initial program 56.6%
Taylor expanded in c around 0
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6467.5
Applied rewrites67.5%
(FPCore (a b c d) :precision binary64 (let* ((t_0 (/ a (- d)))) (if (<= d -5.3e+45) t_0 (if (<= d 9.8e-61) (/ b c) t_0))))
double code(double a, double b, double c, double d) {
double t_0 = a / -d;
double tmp;
if (d <= -5.3e+45) {
tmp = t_0;
} else if (d <= 9.8e-61) {
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.3d+45)) then
tmp = t_0
else if (d <= 9.8d-61) 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.3e+45) {
tmp = t_0;
} else if (d <= 9.8e-61) {
tmp = b / c;
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b, c, d): t_0 = a / -d tmp = 0 if d <= -5.3e+45: tmp = t_0 elif d <= 9.8e-61: tmp = b / c else: tmp = t_0 return tmp
function code(a, b, c, d) t_0 = Float64(a / Float64(-d)) tmp = 0.0 if (d <= -5.3e+45) tmp = t_0; elseif (d <= 9.8e-61) 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.3e+45) tmp = t_0; elseif (d <= 9.8e-61) 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.3e+45], t$95$0, If[LessEqual[d, 9.8e-61], N[(b / c), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a}{-d}\\
\mathbf{if}\;d \leq -5.3 \cdot 10^{+45}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 9.8 \cdot 10^{-61}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d < -5.29999999999999991e45 or 9.80000000000000004e-61 < d Initial program 50.2%
Taylor expanded in c around 0
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6469.7
Applied rewrites69.7%
if -5.29999999999999991e45 < d < 9.80000000000000004e-61Initial program 73.5%
Taylor expanded in c around inf
lower-/.f6467.2
Applied rewrites67.2%
(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-/.f6444.7
Applied rewrites44.7%
(FPCore (a b c d) :precision binary64 (if (< (fabs d) (fabs c)) (/ (- b (* a (/ d c))) (+ c (* d (/ d c)))) (/ (+ (- a) (* b (/ c d))) (+ d (* c (/ c d))))))
double code(double a, double b, double c, double d) {
double tmp;
if (fabs(d) < fabs(c)) {
tmp = (b - (a * (d / c))) / (c + (d * (d / c)));
} else {
tmp = (-a + (b * (c / d))) / (d + (c * (c / d)));
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (abs(d) < abs(c)) then
tmp = (b - (a * (d / c))) / (c + (d * (d / c)))
else
tmp = (-a + (b * (c / d))) / (d + (c * (c / d)))
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (Math.abs(d) < Math.abs(c)) {
tmp = (b - (a * (d / c))) / (c + (d * (d / c)));
} else {
tmp = (-a + (b * (c / d))) / (d + (c * (c / d)));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if math.fabs(d) < math.fabs(c): tmp = (b - (a * (d / c))) / (c + (d * (d / c))) else: tmp = (-a + (b * (c / d))) / (d + (c * (c / d))) return tmp
function code(a, b, c, d) tmp = 0.0 if (abs(d) < abs(c)) tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / Float64(c + Float64(d * Float64(d / c)))); else tmp = Float64(Float64(Float64(-a) + Float64(b * Float64(c / d))) / Float64(d + Float64(c * Float64(c / d)))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (abs(d) < abs(c)) tmp = (b - (a * (d / c))) / (c + (d * (d / c))); else tmp = (-a + (b * (c / d))) / (d + (c * (c / d))); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Less[N[Abs[d], $MachinePrecision], N[Abs[c], $MachinePrecision]], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(c + N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[((-a) + N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(d + N[(c * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left|d\right| < \left|c\right|:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c + d \cdot \frac{d}{c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-a\right) + b \cdot \frac{c}{d}}{d + c \cdot \frac{c}{d}}\\
\end{array}
\end{array}
herbie shell --seed 2024214
(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))))