
(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 c (* d d))))
(if (<= c -2.7e+73)
(/ (fma (- d) (/ a c) b) c)
(if (<= c -6.2e-61)
(fma (/ (- a) t_1) d (/ (* c b) t_1))
(if (<= c 7.6e-97)
(/ (fma b (/ c d) (- a)) d)
(if (<= c 3.6e+132)
(fma (/ c t_0) b (/ (* a (- d)) t_0))
(/ (fma a (- (/ d c)) b) c)))))))
double code(double a, double b, double c, double d) {
double t_0 = fma(d, d, (c * c));
double t_1 = fma(c, c, (d * d));
double tmp;
if (c <= -2.7e+73) {
tmp = fma(-d, (a / c), b) / c;
} else if (c <= -6.2e-61) {
tmp = fma((-a / t_1), d, ((c * b) / t_1));
} else if (c <= 7.6e-97) {
tmp = fma(b, (c / d), -a) / d;
} else if (c <= 3.6e+132) {
tmp = fma((c / t_0), b, ((a * -d) / t_0));
} else {
tmp = fma(a, -(d / c), b) / c;
}
return tmp;
}
function code(a, b, c, d) t_0 = fma(d, d, Float64(c * c)) t_1 = fma(c, c, Float64(d * d)) tmp = 0.0 if (c <= -2.7e+73) tmp = Float64(fma(Float64(-d), Float64(a / c), b) / c); elseif (c <= -6.2e-61) tmp = fma(Float64(Float64(-a) / t_1), d, Float64(Float64(c * b) / t_1)); elseif (c <= 7.6e-97) tmp = Float64(fma(b, Float64(c / d), Float64(-a)) / d); elseif (c <= 3.6e+132) tmp = fma(Float64(c / t_0), b, Float64(Float64(a * Float64(-d)) / t_0)); else tmp = Float64(fma(a, Float64(-Float64(d / c)), b) / c); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -2.7e+73], N[(N[((-d) * N[(a / c), $MachinePrecision] + b), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[c, -6.2e-61], N[(N[((-a) / t$95$1), $MachinePrecision] * d + N[(N[(c * b), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 7.6e-97], N[(N[(b * N[(c / d), $MachinePrecision] + (-a)), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 3.6e+132], N[(N[(c / t$95$0), $MachinePrecision] * b + N[(N[(a * (-d)), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(a * (-N[(d / c), $MachinePrecision]) + b), $MachinePrecision] / c), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(d, d, c \cdot c\right)\\
t_1 := \mathsf{fma}\left(c, c, d \cdot d\right)\\
\mathbf{if}\;c \leq -2.7 \cdot 10^{+73}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-d, \frac{a}{c}, b\right)}{c}\\
\mathbf{elif}\;c \leq -6.2 \cdot 10^{-61}:\\
\;\;\;\;\mathsf{fma}\left(\frac{-a}{t\_1}, d, \frac{c \cdot b}{t\_1}\right)\\
\mathbf{elif}\;c \leq 7.6 \cdot 10^{-97}:\\
\;\;\;\;\frac{\mathsf{fma}\left(b, \frac{c}{d}, -a\right)}{d}\\
\mathbf{elif}\;c \leq 3.6 \cdot 10^{+132}:\\
\;\;\;\;\mathsf{fma}\left(\frac{c}{t\_0}, b, \frac{a \cdot \left(-d\right)}{t\_0}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(a, -\frac{d}{c}, b\right)}{c}\\
\end{array}
\end{array}
if c < -2.6999999999999999e73Initial program 36.0%
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.6
Applied rewrites81.6%
Applied rewrites89.0%
if -2.6999999999999999e73 < c < -6.1999999999999999e-61Initial program 81.3%
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
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites81.3%
lift-fma.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
frac-2negN/A
lift-neg.f64N/A
remove-double-negN/A
lower-/.f64N/A
lower-neg.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-fma.f64N/A
lift-/.f64N/A
associate-*l/N/A
Applied rewrites92.2%
if -6.1999999999999999e-61 < c < 7.6000000000000001e-97Initial program 74.5%
Taylor expanded in c around 0
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6475.6
Applied rewrites75.6%
Taylor expanded in d around inf
+-commutativeN/A
mul-1-negN/A
sub-negN/A
lower-/.f64N/A
sub-negN/A
associate-/l*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6489.3
Applied rewrites89.3%
if 7.6000000000000001e-97 < c < 3.60000000000000016e132Initial program 78.6%
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
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites84.7%
if 3.60000000000000016e132 < c Initial program 30.5%
Taylor expanded in c around 0
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6416.8
Applied rewrites16.8%
Taylor expanded in c around inf
lower-/.f64N/A
+-commutativeN/A
mul-1-negN/A
associate-/l*N/A
distribute-rgt-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6492.0
Applied rewrites92.0%
Final simplification89.1%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (fma d d (* c c))))
(if (<= c -2.7e+73)
(/ (fma (- d) (/ a c) b) c)
(if (<= c -6.2e-61)
(fma (- d) (/ a t_0) (/ (* c b) t_0))
(if (<= c 7.6e-97)
(/ (fma b (/ c d) (- a)) d)
(if (<= c 3.6e+132)
(fma (/ c t_0) b (/ (* a (- d)) t_0))
(/ (fma a (- (/ d c)) b) c)))))))
double code(double a, double b, double c, double d) {
double t_0 = fma(d, d, (c * c));
double tmp;
if (c <= -2.7e+73) {
tmp = fma(-d, (a / c), b) / c;
} else if (c <= -6.2e-61) {
tmp = fma(-d, (a / t_0), ((c * b) / t_0));
} else if (c <= 7.6e-97) {
tmp = fma(b, (c / d), -a) / d;
} else if (c <= 3.6e+132) {
tmp = fma((c / t_0), b, ((a * -d) / t_0));
} else {
tmp = fma(a, -(d / c), b) / c;
}
return tmp;
}
function code(a, b, c, d) t_0 = fma(d, d, Float64(c * c)) tmp = 0.0 if (c <= -2.7e+73) tmp = Float64(fma(Float64(-d), Float64(a / c), b) / c); elseif (c <= -6.2e-61) tmp = fma(Float64(-d), Float64(a / t_0), Float64(Float64(c * b) / t_0)); elseif (c <= 7.6e-97) tmp = Float64(fma(b, Float64(c / d), Float64(-a)) / d); elseif (c <= 3.6e+132) tmp = fma(Float64(c / t_0), b, Float64(Float64(a * Float64(-d)) / t_0)); else tmp = Float64(fma(a, Float64(-Float64(d / c)), 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, -2.7e+73], N[(N[((-d) * N[(a / c), $MachinePrecision] + b), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[c, -6.2e-61], N[((-d) * N[(a / t$95$0), $MachinePrecision] + N[(N[(c * b), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 7.6e-97], N[(N[(b * N[(c / d), $MachinePrecision] + (-a)), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 3.6e+132], N[(N[(c / t$95$0), $MachinePrecision] * b + N[(N[(a * (-d)), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(a * (-N[(d / c), $MachinePrecision]) + b), $MachinePrecision] / c), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(d, d, c \cdot c\right)\\
\mathbf{if}\;c \leq -2.7 \cdot 10^{+73}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-d, \frac{a}{c}, b\right)}{c}\\
\mathbf{elif}\;c \leq -6.2 \cdot 10^{-61}:\\
\;\;\;\;\mathsf{fma}\left(-d, \frac{a}{t\_0}, \frac{c \cdot b}{t\_0}\right)\\
\mathbf{elif}\;c \leq 7.6 \cdot 10^{-97}:\\
\;\;\;\;\frac{\mathsf{fma}\left(b, \frac{c}{d}, -a\right)}{d}\\
\mathbf{elif}\;c \leq 3.6 \cdot 10^{+132}:\\
\;\;\;\;\mathsf{fma}\left(\frac{c}{t\_0}, b, \frac{a \cdot \left(-d\right)}{t\_0}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(a, -\frac{d}{c}, b\right)}{c}\\
\end{array}
\end{array}
if c < -2.6999999999999999e73Initial program 36.0%
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.6
Applied rewrites81.6%
Applied rewrites89.0%
if -2.6999999999999999e73 < c < -6.1999999999999999e-61Initial program 81.3%
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
lower-neg.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
lower-/.f6492.1
Applied rewrites92.1%
if -6.1999999999999999e-61 < c < 7.6000000000000001e-97Initial program 74.5%
Taylor expanded in c around 0
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6475.6
Applied rewrites75.6%
Taylor expanded in d around inf
+-commutativeN/A
mul-1-negN/A
sub-negN/A
lower-/.f64N/A
sub-negN/A
associate-/l*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6489.3
Applied rewrites89.3%
if 7.6000000000000001e-97 < c < 3.60000000000000016e132Initial program 78.6%
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
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites84.7%
if 3.60000000000000016e132 < c Initial program 30.5%
Taylor expanded in c around 0
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6416.8
Applied rewrites16.8%
Taylor expanded in c around inf
lower-/.f64N/A
+-commutativeN/A
mul-1-negN/A
associate-/l*N/A
distribute-rgt-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6492.0
Applied rewrites92.0%
Final simplification89.1%
(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))))
(if (<= c -2.7e+73)
(/ (fma (- d) (/ a c) b) c)
(if (<= c -6.2e-61)
t_1
(if (<= c 7.6e-97)
(/ (fma b (/ c d) (- a)) d)
(if (<= c 5.1e+105) t_1 (/ (fma a (- (/ d c)) b) c)))))))
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 tmp;
if (c <= -2.7e+73) {
tmp = fma(-d, (a / c), b) / c;
} else if (c <= -6.2e-61) {
tmp = t_1;
} else if (c <= 7.6e-97) {
tmp = fma(b, (c / d), -a) / d;
} else if (c <= 5.1e+105) {
tmp = t_1;
} else {
tmp = fma(a, -(d / c), b) / c;
}
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)) tmp = 0.0 if (c <= -2.7e+73) tmp = Float64(fma(Float64(-d), Float64(a / c), b) / c); elseif (c <= -6.2e-61) tmp = t_1; elseif (c <= 7.6e-97) tmp = Float64(fma(b, Float64(c / d), Float64(-a)) / d); elseif (c <= 5.1e+105) tmp = t_1; else tmp = Float64(fma(a, Float64(-Float64(d / c)), b) / c); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[((-d) * N[(a / t$95$0), $MachinePrecision] + N[(N[(c * b), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -2.7e+73], N[(N[((-d) * N[(a / c), $MachinePrecision] + b), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[c, -6.2e-61], t$95$1, If[LessEqual[c, 7.6e-97], N[(N[(b * N[(c / d), $MachinePrecision] + (-a)), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 5.1e+105], t$95$1, N[(N[(a * (-N[(d / c), $MachinePrecision]) + b), $MachinePrecision] / c), $MachinePrecision]]]]]]]
\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)\\
\mathbf{if}\;c \leq -2.7 \cdot 10^{+73}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-d, \frac{a}{c}, b\right)}{c}\\
\mathbf{elif}\;c \leq -6.2 \cdot 10^{-61}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;c \leq 7.6 \cdot 10^{-97}:\\
\;\;\;\;\frac{\mathsf{fma}\left(b, \frac{c}{d}, -a\right)}{d}\\
\mathbf{elif}\;c \leq 5.1 \cdot 10^{+105}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(a, -\frac{d}{c}, b\right)}{c}\\
\end{array}
\end{array}
if c < -2.6999999999999999e73Initial program 36.0%
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.6
Applied rewrites81.6%
Applied rewrites89.0%
if -2.6999999999999999e73 < c < -6.1999999999999999e-61 or 7.6000000000000001e-97 < c < 5.09999999999999991e105Initial program 79.8%
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
lower-neg.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
lower-/.f6485.5
Applied rewrites85.5%
if -6.1999999999999999e-61 < c < 7.6000000000000001e-97Initial program 74.5%
Taylor expanded in c around 0
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6475.6
Applied rewrites75.6%
Taylor expanded in d around inf
+-commutativeN/A
mul-1-negN/A
sub-negN/A
lower-/.f64N/A
sub-negN/A
associate-/l*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6489.3
Applied rewrites89.3%
if 5.09999999999999991e105 < c Initial program 35.0%
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.f6419.0
Applied rewrites19.0%
Taylor expanded in c around inf
lower-/.f64N/A
+-commutativeN/A
mul-1-negN/A
associate-/l*N/A
distribute-rgt-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6490.6
Applied rewrites90.6%
Final simplification88.5%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* c b) (* a d)) (fma c c (* d d)))))
(if (<= c -2.7e+73)
(/ (fma (- d) (/ a c) b) c)
(if (<= c -3.6e-61)
t_0
(if (<= c 7.6e-97)
(/ (fma b (/ c d) (- a)) d)
(if (<= c 2.6e+104) t_0 (/ (fma a (- (/ d c)) b) c)))))))
double code(double a, double b, double c, double d) {
double t_0 = ((c * b) - (a * d)) / fma(c, c, (d * d));
double tmp;
if (c <= -2.7e+73) {
tmp = fma(-d, (a / c), b) / c;
} else if (c <= -3.6e-61) {
tmp = t_0;
} else if (c <= 7.6e-97) {
tmp = fma(b, (c / d), -a) / d;
} else if (c <= 2.6e+104) {
tmp = t_0;
} else {
tmp = fma(a, -(d / c), b) / c;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(Float64(c * b) - Float64(a * d)) / fma(c, c, Float64(d * d))) tmp = 0.0 if (c <= -2.7e+73) tmp = Float64(fma(Float64(-d), Float64(a / c), b) / c); elseif (c <= -3.6e-61) tmp = t_0; elseif (c <= 7.6e-97) tmp = Float64(fma(b, Float64(c / d), Float64(-a)) / d); elseif (c <= 2.6e+104) tmp = t_0; else tmp = Float64(fma(a, Float64(-Float64(d / c)), b) / c); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(c * b), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -2.7e+73], N[(N[((-d) * N[(a / c), $MachinePrecision] + b), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[c, -3.6e-61], t$95$0, If[LessEqual[c, 7.6e-97], N[(N[(b * N[(c / d), $MachinePrecision] + (-a)), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 2.6e+104], t$95$0, N[(N[(a * (-N[(d / c), $MachinePrecision]) + b), $MachinePrecision] / c), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c \cdot b - a \cdot d}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\
\mathbf{if}\;c \leq -2.7 \cdot 10^{+73}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-d, \frac{a}{c}, b\right)}{c}\\
\mathbf{elif}\;c \leq -3.6 \cdot 10^{-61}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq 7.6 \cdot 10^{-97}:\\
\;\;\;\;\frac{\mathsf{fma}\left(b, \frac{c}{d}, -a\right)}{d}\\
\mathbf{elif}\;c \leq 2.6 \cdot 10^{+104}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(a, -\frac{d}{c}, b\right)}{c}\\
\end{array}
\end{array}
if c < -2.6999999999999999e73Initial program 36.0%
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.6
Applied rewrites81.6%
Applied rewrites89.0%
if -2.6999999999999999e73 < c < -3.60000000000000014e-61 or 7.6000000000000001e-97 < c < 2.6e104Initial program 79.8%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6479.8
Applied rewrites79.8%
if -3.60000000000000014e-61 < c < 7.6000000000000001e-97Initial program 74.5%
Taylor expanded in c around 0
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6475.6
Applied rewrites75.6%
Taylor expanded in d around inf
+-commutativeN/A
mul-1-negN/A
sub-negN/A
lower-/.f64N/A
sub-negN/A
associate-/l*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6489.3
Applied rewrites89.3%
if 2.6e104 < c Initial program 35.0%
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.f6419.0
Applied rewrites19.0%
Taylor expanded in c around inf
lower-/.f64N/A
+-commutativeN/A
mul-1-negN/A
associate-/l*N/A
distribute-rgt-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6490.6
Applied rewrites90.6%
Final simplification86.9%
(FPCore (a b c d) :precision binary64 (let* ((t_0 (/ (fma c (/ b d) (- a)) d))) (if (<= d -7.8e+98) t_0 (if (<= d 1.7e+16) (/ (- b (/ (* a d) c)) c) t_0))))
double code(double a, double b, double c, double d) {
double t_0 = fma(c, (b / d), -a) / d;
double tmp;
if (d <= -7.8e+98) {
tmp = t_0;
} else if (d <= 1.7e+16) {
tmp = (b - ((a * d) / c)) / c;
} else {
tmp = t_0;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(fma(c, Float64(b / d), Float64(-a)) / d) tmp = 0.0 if (d <= -7.8e+98) tmp = t_0; elseif (d <= 1.7e+16) tmp = Float64(Float64(b - Float64(Float64(a * d) / c)) / c); else tmp = t_0; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c * N[(b / d), $MachinePrecision] + (-a)), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -7.8e+98], t$95$0, If[LessEqual[d, 1.7e+16], N[(N[(b - N[(N[(a * d), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\mathsf{fma}\left(c, \frac{b}{d}, -a\right)}{d}\\
\mathbf{if}\;d \leq -7.8 \cdot 10^{+98}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 1.7 \cdot 10^{+16}:\\
\;\;\;\;\frac{b - \frac{a \cdot d}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d < -7.7999999999999999e98 or 1.7e16 < d Initial program 56.6%
Taylor expanded in c around 0
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
unpow2N/A
associate-/r*N/A
div-subN/A
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.0
Applied rewrites87.0%
if -7.7999999999999999e98 < d < 1.7e16Initial program 65.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-*.f6479.6
Applied rewrites79.6%
Final simplification82.6%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (fma b (/ c d) (- a)) d)))
(if (<= d -2.5e+100)
t_0
(if (<= d 1.7e+16) (/ (- b (/ (* a d) c)) c) t_0))))
double code(double a, double b, double c, double d) {
double t_0 = fma(b, (c / d), -a) / d;
double tmp;
if (d <= -2.5e+100) {
tmp = t_0;
} else if (d <= 1.7e+16) {
tmp = (b - ((a * d) / c)) / c;
} else {
tmp = t_0;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(fma(b, Float64(c / d), Float64(-a)) / d) tmp = 0.0 if (d <= -2.5e+100) tmp = t_0; elseif (d <= 1.7e+16) tmp = Float64(Float64(b - Float64(Float64(a * d) / c)) / c); else tmp = t_0; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(b * N[(c / d), $MachinePrecision] + (-a)), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -2.5e+100], t$95$0, If[LessEqual[d, 1.7e+16], N[(N[(b - N[(N[(a * d), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\mathsf{fma}\left(b, \frac{c}{d}, -a\right)}{d}\\
\mathbf{if}\;d \leq -2.5 \cdot 10^{+100}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 1.7 \cdot 10^{+16}:\\
\;\;\;\;\frac{b - \frac{a \cdot d}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d < -2.4999999999999999e100 or 1.7e16 < 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.f6478.3
Applied rewrites78.3%
Taylor expanded in d around inf
+-commutativeN/A
mul-1-negN/A
sub-negN/A
lower-/.f64N/A
sub-negN/A
associate-/l*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6486.2
Applied rewrites86.2%
if -2.4999999999999999e100 < d < 1.7e16Initial program 65.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-*.f6479.6
Applied rewrites79.6%
Final simplification82.3%
(FPCore (a b c d) :precision binary64 (if (<= d -2.5e+103) (/ a (- d)) (if (<= d 1.7e+16) (/ (- b (/ (* a d) c)) c) (/ (- (/ (* c b) d) a) d))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -2.5e+103) {
tmp = a / -d;
} else if (d <= 1.7e+16) {
tmp = (b - ((a * d) / c)) / c;
} else {
tmp = (((c * b) / d) - a) / d;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (d <= (-2.5d+103)) then
tmp = a / -d
else if (d <= 1.7d+16) then
tmp = (b - ((a * d) / c)) / c
else
tmp = (((c * b) / d) - a) / d
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (d <= -2.5e+103) {
tmp = a / -d;
} else if (d <= 1.7e+16) {
tmp = (b - ((a * d) / c)) / c;
} else {
tmp = (((c * b) / d) - a) / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -2.5e+103: tmp = a / -d elif d <= 1.7e+16: tmp = (b - ((a * d) / c)) / c else: tmp = (((c * b) / d) - a) / d return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -2.5e+103) tmp = Float64(a / Float64(-d)); elseif (d <= 1.7e+16) tmp = Float64(Float64(b - Float64(Float64(a * d) / c)) / c); else tmp = Float64(Float64(Float64(Float64(c * b) / d) - a) / d); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= -2.5e+103) tmp = a / -d; elseif (d <= 1.7e+16) tmp = (b - ((a * d) / c)) / c; else tmp = (((c * b) / d) - a) / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -2.5e+103], N[(a / (-d)), $MachinePrecision], If[LessEqual[d, 1.7e+16], N[(N[(b - N[(N[(a * d), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], N[(N[(N[(N[(c * b), $MachinePrecision] / d), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -2.5 \cdot 10^{+103}:\\
\;\;\;\;\frac{a}{-d}\\
\mathbf{elif}\;d \leq 1.7 \cdot 10^{+16}:\\
\;\;\;\;\frac{b - \frac{a \cdot d}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{c \cdot b}{d} - a}{d}\\
\end{array}
\end{array}
if d < -2.5e103Initial program 49.0%
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.f6480.1
Applied rewrites80.1%
if -2.5e103 < d < 1.7e16Initial program 65.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-*.f6479.6
Applied rewrites79.6%
if 1.7e16 < d Initial program 61.0%
Taylor expanded in c around inf
lower-/.f649.8
Applied rewrites9.8%
Taylor expanded in d around inf
+-commutativeN/A
mul-1-negN/A
sub-negN/A
lower-/.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6485.2
Applied rewrites85.2%
Final simplification81.1%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ a (- d))))
(if (<= d -2.5e+103)
t_0
(if (<= d 2.9e+16) (/ (- b (/ (* a d) c)) c) t_0))))
double code(double a, double b, double c, double d) {
double t_0 = a / -d;
double tmp;
if (d <= -2.5e+103) {
tmp = t_0;
} else if (d <= 2.9e+16) {
tmp = (b - ((a * d) / c)) / c;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: tmp
t_0 = a / -d
if (d <= (-2.5d+103)) then
tmp = t_0
else if (d <= 2.9d+16) then
tmp = (b - ((a * d) / c)) / c
else
tmp = t_0
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = a / -d;
double tmp;
if (d <= -2.5e+103) {
tmp = t_0;
} else if (d <= 2.9e+16) {
tmp = (b - ((a * d) / c)) / c;
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b, c, d): t_0 = a / -d tmp = 0 if d <= -2.5e+103: tmp = t_0 elif d <= 2.9e+16: tmp = (b - ((a * d) / c)) / c else: tmp = t_0 return tmp
function code(a, b, c, d) t_0 = Float64(a / Float64(-d)) tmp = 0.0 if (d <= -2.5e+103) tmp = t_0; elseif (d <= 2.9e+16) tmp = Float64(Float64(b - Float64(Float64(a * d) / c)) / c); else tmp = t_0; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = a / -d; tmp = 0.0; if (d <= -2.5e+103) tmp = t_0; elseif (d <= 2.9e+16) tmp = (b - ((a * d) / c)) / c; else tmp = t_0; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(a / (-d)), $MachinePrecision]}, If[LessEqual[d, -2.5e+103], t$95$0, If[LessEqual[d, 2.9e+16], N[(N[(b - N[(N[(a * d), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a}{-d}\\
\mathbf{if}\;d \leq -2.5 \cdot 10^{+103}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 2.9 \cdot 10^{+16}:\\
\;\;\;\;\frac{b - \frac{a \cdot d}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d < -2.5e103 or 2.9e16 < 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.f6478.3
Applied rewrites78.3%
if -2.5e103 < d < 2.9e16Initial program 65.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-*.f6479.6
Applied rewrites79.6%
Final simplification79.1%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ a (- d))))
(if (<= d -2.4e+139)
t_0
(if (<= d -9500000000.0)
(* a (/ (- d) (fma c c (* d d))))
(if (<= d 2.55e+16) (/ b c) t_0)))))
double code(double a, double b, double c, double d) {
double t_0 = a / -d;
double tmp;
if (d <= -2.4e+139) {
tmp = t_0;
} else if (d <= -9500000000.0) {
tmp = a * (-d / fma(c, c, (d * d)));
} else if (d <= 2.55e+16) {
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 <= -2.4e+139) tmp = t_0; elseif (d <= -9500000000.0) tmp = Float64(a * Float64(Float64(-d) / fma(c, c, Float64(d * d)))); elseif (d <= 2.55e+16) tmp = Float64(b / c); else tmp = t_0; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(a / (-d)), $MachinePrecision]}, If[LessEqual[d, -2.4e+139], t$95$0, If[LessEqual[d, -9500000000.0], N[(a * N[((-d) / N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.55e+16], N[(b / c), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a}{-d}\\
\mathbf{if}\;d \leq -2.4 \cdot 10^{+139}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq -9500000000:\\
\;\;\;\;a \cdot \frac{-d}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\
\mathbf{elif}\;d \leq 2.55 \cdot 10^{+16}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d < -2.40000000000000008e139 or 2.55e16 < 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.f6478.9
Applied rewrites78.9%
if -2.40000000000000008e139 < d < -9.5e9Initial program 68.0%
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.f6457.1
Applied rewrites57.1%
Taylor expanded in b around 0
mul-1-negN/A
lower-neg.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6475.2
Applied rewrites75.2%
if -9.5e9 < d < 2.55e16Initial program 65.6%
Taylor expanded in c around inf
lower-/.f6467.0
Applied rewrites67.0%
Final simplification72.1%
(FPCore (a b c d) :precision binary64 (if (<= d -17000000000.0) (/ -1.0 (/ d a)) (if (<= d 2.55e+16) (/ b c) (/ a (- d)))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -17000000000.0) {
tmp = -1.0 / (d / a);
} else if (d <= 2.55e+16) {
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 <= (-17000000000.0d0)) then
tmp = (-1.0d0) / (d / a)
else if (d <= 2.55d+16) 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 <= -17000000000.0) {
tmp = -1.0 / (d / a);
} else if (d <= 2.55e+16) {
tmp = b / c;
} else {
tmp = a / -d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -17000000000.0: tmp = -1.0 / (d / a) elif d <= 2.55e+16: tmp = b / c else: tmp = a / -d return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -17000000000.0) tmp = Float64(-1.0 / Float64(d / a)); elseif (d <= 2.55e+16) 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 <= -17000000000.0) tmp = -1.0 / (d / a); elseif (d <= 2.55e+16) tmp = b / c; else tmp = a / -d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -17000000000.0], N[(-1.0 / N[(d / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.55e+16], N[(b / c), $MachinePrecision], N[(a / (-d)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -17000000000:\\
\;\;\;\;\frac{-1}{\frac{d}{a}}\\
\mathbf{elif}\;d \leq 2.55 \cdot 10^{+16}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{-d}\\
\end{array}
\end{array}
if d < -1.7e10Initial program 53.9%
lift-/.f64N/A
div-invN/A
lift--.f64N/A
flip3--N/A
clear-numN/A
frac-2negN/A
metadata-evalN/A
frac-timesN/A
metadata-evalN/A
lower-/.f64N/A
Applied rewrites53.9%
Taylor expanded in c around 0
lower-/.f6470.2
Applied rewrites70.2%
if -1.7e10 < d < 2.55e16Initial program 65.6%
Taylor expanded in c around inf
lower-/.f6467.0
Applied rewrites67.0%
if 2.55e16 < d Initial program 61.0%
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.f6477.3
Applied rewrites77.3%
(FPCore (a b c d) :precision binary64 (let* ((t_0 (/ a (- d)))) (if (<= d -17000000000.0) t_0 (if (<= d 2.55e+16) (/ b c) t_0))))
double code(double a, double b, double c, double d) {
double t_0 = a / -d;
double tmp;
if (d <= -17000000000.0) {
tmp = t_0;
} else if (d <= 2.55e+16) {
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 <= (-17000000000.0d0)) then
tmp = t_0
else if (d <= 2.55d+16) 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 <= -17000000000.0) {
tmp = t_0;
} else if (d <= 2.55e+16) {
tmp = b / c;
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b, c, d): t_0 = a / -d tmp = 0 if d <= -17000000000.0: tmp = t_0 elif d <= 2.55e+16: 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 <= -17000000000.0) tmp = t_0; elseif (d <= 2.55e+16) 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 <= -17000000000.0) tmp = t_0; elseif (d <= 2.55e+16) 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, -17000000000.0], t$95$0, If[LessEqual[d, 2.55e+16], N[(b / c), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a}{-d}\\
\mathbf{if}\;d \leq -17000000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 2.55 \cdot 10^{+16}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d < -1.7e10 or 2.55e16 < d Initial program 57.7%
Taylor expanded in c around 0
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6473.8
Applied rewrites73.8%
if -1.7e10 < d < 2.55e16Initial program 65.6%
Taylor expanded in c around inf
lower-/.f6467.0
Applied rewrites67.0%
(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 61.9%
Taylor expanded in c around inf
lower-/.f6443.1
Applied rewrites43.1%
(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 2024233
(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))))