
(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 (/ (- b (/ 1.0 (/ (/ c d) a))) c)))
(if (<= c -1.2e+108)
t_0
(if (<= c -7.5e-126)
(/ (fma (- d) a (* b c)) (fma d d (* c c)))
(if (<= c 6000000.0) (/ (fma (/ c d) b (- a)) d) t_0)))))
double code(double a, double b, double c, double d) {
double t_0 = (b - (1.0 / ((c / d) / a))) / c;
double tmp;
if (c <= -1.2e+108) {
tmp = t_0;
} else if (c <= -7.5e-126) {
tmp = fma(-d, a, (b * c)) / fma(d, d, (c * c));
} else if (c <= 6000000.0) {
tmp = fma((c / d), b, -a) / d;
} else {
tmp = t_0;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(b - Float64(1.0 / Float64(Float64(c / d) / a))) / c) tmp = 0.0 if (c <= -1.2e+108) tmp = t_0; elseif (c <= -7.5e-126) tmp = Float64(fma(Float64(-d), a, Float64(b * c)) / fma(d, d, Float64(c * c))); elseif (c <= 6000000.0) 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[(b - N[(1.0 / N[(N[(c / d), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]}, If[LessEqual[c, -1.2e+108], t$95$0, If[LessEqual[c, -7.5e-126], N[(N[((-d) * a + N[(b * c), $MachinePrecision]), $MachinePrecision] / N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 6000000.0], N[(N[(N[(c / d), $MachinePrecision] * b + (-a)), $MachinePrecision] / d), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b - \frac{1}{\frac{\frac{c}{d}}{a}}}{c}\\
\mathbf{if}\;c \leq -1.2 \cdot 10^{+108}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq -7.5 \cdot 10^{-126}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-d, a, b \cdot c\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\
\mathbf{elif}\;c \leq 6000000:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{c}{d}, b, -a\right)}{d}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if c < -1.20000000000000009e108 or 6e6 < c Initial program 37.8%
Taylor expanded in c around inf
lower-/.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6474.6
Applied rewrites74.6%
Applied rewrites81.0%
if -1.20000000000000009e108 < c < -7.49999999999999976e-126Initial program 80.9%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f6480.9
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6480.9
Applied rewrites80.9%
if -7.49999999999999976e-126 < c < 6e6Initial program 68.8%
Taylor expanded in c around 0
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6469.4
Applied rewrites69.4%
Taylor expanded in c around 0
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
unpow2N/A
associate-/r*N/A
div-subN/A
sub-negN/A
mul-1-negN/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
associate-*l/N/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6489.7
Applied rewrites89.7%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* b c) (* d a)) (* d d))) (t_1 (/ (- a) d)))
(if (<= d -4e+121)
t_1
(if (<= d -2.9e+59)
(* (/ b (fma c c (* d d))) c)
(if (<= d -3.1e-22)
t_0
(if (<= d 8e+50)
(/ (- b (/ (* d a) c)) c)
(if (<= d 3.8e+76) t_0 (if (<= d 6.1e+88) (/ b c) t_1))))))))
double code(double a, double b, double c, double d) {
double t_0 = ((b * c) - (d * a)) / (d * d);
double t_1 = -a / d;
double tmp;
if (d <= -4e+121) {
tmp = t_1;
} else if (d <= -2.9e+59) {
tmp = (b / fma(c, c, (d * d))) * c;
} else if (d <= -3.1e-22) {
tmp = t_0;
} else if (d <= 8e+50) {
tmp = (b - ((d * a) / c)) / c;
} else if (d <= 3.8e+76) {
tmp = t_0;
} else if (d <= 6.1e+88) {
tmp = b / c;
} else {
tmp = t_1;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(Float64(b * c) - Float64(d * a)) / Float64(d * d)) t_1 = Float64(Float64(-a) / d) tmp = 0.0 if (d <= -4e+121) tmp = t_1; elseif (d <= -2.9e+59) tmp = Float64(Float64(b / fma(c, c, Float64(d * d))) * c); elseif (d <= -3.1e-22) tmp = t_0; elseif (d <= 8e+50) tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c); elseif (d <= 3.8e+76) tmp = t_0; elseif (d <= 6.1e+88) tmp = Float64(b / c); else tmp = t_1; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(b * c), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(d * d), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[((-a) / d), $MachinePrecision]}, If[LessEqual[d, -4e+121], t$95$1, If[LessEqual[d, -2.9e+59], N[(N[(b / N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * c), $MachinePrecision], If[LessEqual[d, -3.1e-22], t$95$0, If[LessEqual[d, 8e+50], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 3.8e+76], t$95$0, If[LessEqual[d, 6.1e+88], N[(b / c), $MachinePrecision], t$95$1]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b \cdot c - d \cdot a}{d \cdot d}\\
t_1 := \frac{-a}{d}\\
\mathbf{if}\;d \leq -4 \cdot 10^{+121}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d \leq -2.9 \cdot 10^{+59}:\\
\;\;\;\;\frac{b}{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot c\\
\mathbf{elif}\;d \leq -3.1 \cdot 10^{-22}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 8 \cdot 10^{+50}:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\
\mathbf{elif}\;d \leq 3.8 \cdot 10^{+76}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 6.1 \cdot 10^{+88}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if d < -4.00000000000000015e121 or 6.0999999999999998e88 < d Initial program 36.3%
Taylor expanded in c around 0
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6474.9
Applied rewrites74.9%
if -4.00000000000000015e121 < d < -2.89999999999999991e59Initial program 62.7%
Taylor expanded in b around inf
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6467.4
Applied rewrites67.4%
if -2.89999999999999991e59 < d < -3.10000000000000013e-22 or 8.0000000000000006e50 < d < 3.80000000000000024e76Initial program 85.4%
Taylor expanded in c around 0
unpow2N/A
lower-*.f6475.1
Applied rewrites75.1%
if -3.10000000000000013e-22 < d < 8.0000000000000006e50Initial program 72.6%
Taylor expanded in c around inf
lower-/.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6483.8
Applied rewrites83.8%
if 3.80000000000000024e76 < d < 6.0999999999999998e88Initial program 33.3%
Taylor expanded in c around inf
lower-/.f64100.0
Applied rewrites100.0%
Final simplification78.9%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- b (/ (* d a) c)) c)) (t_1 (/ (fma (/ c d) b (- a)) d)))
(if (<= d -1.45e+100)
(/ (fma (/ b d) c (- a)) d)
(if (<= d -1.22e+72)
t_0
(if (<= d -3.1e-22) t_1 (if (<= d 7.5e+50) t_0 t_1))))))
double code(double a, double b, double c, double d) {
double t_0 = (b - ((d * a) / c)) / c;
double t_1 = fma((c / d), b, -a) / d;
double tmp;
if (d <= -1.45e+100) {
tmp = fma((b / d), c, -a) / d;
} else if (d <= -1.22e+72) {
tmp = t_0;
} else if (d <= -3.1e-22) {
tmp = t_1;
} else if (d <= 7.5e+50) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(b - Float64(Float64(d * a) / c)) / c) t_1 = Float64(fma(Float64(c / d), b, Float64(-a)) / d) tmp = 0.0 if (d <= -1.45e+100) tmp = Float64(fma(Float64(b / d), c, Float64(-a)) / d); elseif (d <= -1.22e+72) tmp = t_0; elseif (d <= -3.1e-22) tmp = t_1; elseif (d <= 7.5e+50) tmp = t_0; else tmp = t_1; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(c / d), $MachinePrecision] * b + (-a)), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -1.45e+100], N[(N[(N[(b / d), $MachinePrecision] * c + (-a)), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, -1.22e+72], t$95$0, If[LessEqual[d, -3.1e-22], t$95$1, If[LessEqual[d, 7.5e+50], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b - \frac{d \cdot a}{c}}{c}\\
t_1 := \frac{\mathsf{fma}\left(\frac{c}{d}, b, -a\right)}{d}\\
\mathbf{if}\;d \leq -1.45 \cdot 10^{+100}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{b}{d}, c, -a\right)}{d}\\
\mathbf{elif}\;d \leq -1.22 \cdot 10^{+72}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq -3.1 \cdot 10^{-22}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d \leq 7.5 \cdot 10^{+50}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if d < -1.45e100Initial program 41.0%
Taylor expanded in c around inf
lower-/.f6411.8
Applied rewrites11.8%
Taylor expanded in c around 0
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
unpow2N/A
associate-/r*N/A
div-subN/A
unsub-negN/A
mul-1-negN/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6490.6
Applied rewrites90.6%
Applied rewrites92.8%
if -1.45e100 < d < -1.2200000000000001e72 or -3.10000000000000013e-22 < d < 7.4999999999999999e50Initial program 72.0%
Taylor expanded in c around inf
lower-/.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6484.1
Applied rewrites84.1%
if -1.2200000000000001e72 < d < -3.10000000000000013e-22 or 7.4999999999999999e50 < d Initial program 51.4%
Taylor expanded in c around 0
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6458.6
Applied rewrites58.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
sub-negN/A
mul-1-negN/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
associate-*l/N/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6474.5
Applied rewrites74.5%
Final simplification82.8%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- b (/ (* d a) c)) c)) (t_1 (/ (fma (/ b d) c (- a)) d)))
(if (<= d -1.45e+100)
t_1
(if (<= d -1.22e+72)
t_0
(if (<= d -3.1e-22)
(/ (- (/ (* b c) d) a) d)
(if (<= d 7.5e+50) t_0 t_1))))))
double code(double a, double b, double c, double d) {
double t_0 = (b - ((d * a) / c)) / c;
double t_1 = fma((b / d), c, -a) / d;
double tmp;
if (d <= -1.45e+100) {
tmp = t_1;
} else if (d <= -1.22e+72) {
tmp = t_0;
} else if (d <= -3.1e-22) {
tmp = (((b * c) / d) - a) / d;
} else if (d <= 7.5e+50) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(b - Float64(Float64(d * a) / c)) / c) t_1 = Float64(fma(Float64(b / d), c, Float64(-a)) / d) tmp = 0.0 if (d <= -1.45e+100) tmp = t_1; elseif (d <= -1.22e+72) tmp = t_0; elseif (d <= -3.1e-22) tmp = Float64(Float64(Float64(Float64(b * c) / d) - a) / d); elseif (d <= 7.5e+50) tmp = t_0; else tmp = t_1; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(b / d), $MachinePrecision] * c + (-a)), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -1.45e+100], t$95$1, If[LessEqual[d, -1.22e+72], t$95$0, If[LessEqual[d, -3.1e-22], N[(N[(N[(N[(b * c), $MachinePrecision] / d), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, 7.5e+50], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b - \frac{d \cdot a}{c}}{c}\\
t_1 := \frac{\mathsf{fma}\left(\frac{b}{d}, c, -a\right)}{d}\\
\mathbf{if}\;d \leq -1.45 \cdot 10^{+100}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d \leq -1.22 \cdot 10^{+72}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq -3.1 \cdot 10^{-22}:\\
\;\;\;\;\frac{\frac{b \cdot c}{d} - a}{d}\\
\mathbf{elif}\;d \leq 7.5 \cdot 10^{+50}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if d < -1.45e100 or 7.4999999999999999e50 < d Initial program 40.8%
Taylor expanded in c around inf
lower-/.f6419.9
Applied rewrites19.9%
Taylor expanded in c around 0
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
unpow2N/A
associate-/r*N/A
div-subN/A
unsub-negN/A
mul-1-negN/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6481.1
Applied rewrites81.1%
Applied rewrites83.3%
if -1.45e100 < d < -1.2200000000000001e72 or -3.10000000000000013e-22 < d < 7.4999999999999999e50Initial program 72.0%
Taylor expanded in c around inf
lower-/.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6484.1
Applied rewrites84.1%
if -1.2200000000000001e72 < d < -3.10000000000000013e-22Initial program 81.5%
Taylor expanded in c around 0
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
unpow2N/A
associate-/r*N/A
div-subN/A
lower-/.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6472.6
Applied rewrites72.6%
Final simplification82.8%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- b (/ (* d a) c)) c)) (t_1 (/ (- (/ (* b c) d) a) d)))
(if (<= d -1.45e+100)
t_1
(if (<= d -1.22e+72)
t_0
(if (<= d -3.1e-22) t_1 (if (<= d 7.5e+50) t_0 t_1))))))
double code(double a, double b, double c, double d) {
double t_0 = (b - ((d * a) / c)) / c;
double t_1 = (((b * c) / d) - a) / d;
double tmp;
if (d <= -1.45e+100) {
tmp = t_1;
} else if (d <= -1.22e+72) {
tmp = t_0;
} else if (d <= -3.1e-22) {
tmp = t_1;
} else if (d <= 7.5e+50) {
tmp = t_0;
} else {
tmp = t_1;
}
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) :: t_1
real(8) :: tmp
t_0 = (b - ((d * a) / c)) / c
t_1 = (((b * c) / d) - a) / d
if (d <= (-1.45d+100)) then
tmp = t_1
else if (d <= (-1.22d+72)) then
tmp = t_0
else if (d <= (-3.1d-22)) then
tmp = t_1
else if (d <= 7.5d+50) then
tmp = t_0
else
tmp = t_1
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 t_1 = (((b * c) / d) - a) / d;
double tmp;
if (d <= -1.45e+100) {
tmp = t_1;
} else if (d <= -1.22e+72) {
tmp = t_0;
} else if (d <= -3.1e-22) {
tmp = t_1;
} else if (d <= 7.5e+50) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(a, b, c, d): t_0 = (b - ((d * a) / c)) / c t_1 = (((b * c) / d) - a) / d tmp = 0 if d <= -1.45e+100: tmp = t_1 elif d <= -1.22e+72: tmp = t_0 elif d <= -3.1e-22: tmp = t_1 elif d <= 7.5e+50: tmp = t_0 else: tmp = t_1 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(b - Float64(Float64(d * a) / c)) / c) t_1 = Float64(Float64(Float64(Float64(b * c) / d) - a) / d) tmp = 0.0 if (d <= -1.45e+100) tmp = t_1; elseif (d <= -1.22e+72) tmp = t_0; elseif (d <= -3.1e-22) tmp = t_1; elseif (d <= 7.5e+50) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (b - ((d * a) / c)) / c; t_1 = (((b * c) / d) - a) / d; tmp = 0.0; if (d <= -1.45e+100) tmp = t_1; elseif (d <= -1.22e+72) tmp = t_0; elseif (d <= -3.1e-22) tmp = t_1; elseif (d <= 7.5e+50) tmp = t_0; else tmp = t_1; 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]}, Block[{t$95$1 = N[(N[(N[(N[(b * c), $MachinePrecision] / d), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -1.45e+100], t$95$1, If[LessEqual[d, -1.22e+72], t$95$0, If[LessEqual[d, -3.1e-22], t$95$1, If[LessEqual[d, 7.5e+50], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b - \frac{d \cdot a}{c}}{c}\\
t_1 := \frac{\frac{b \cdot c}{d} - a}{d}\\
\mathbf{if}\;d \leq -1.45 \cdot 10^{+100}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d \leq -1.22 \cdot 10^{+72}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq -3.1 \cdot 10^{-22}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d \leq 7.5 \cdot 10^{+50}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if d < -1.45e100 or -1.2200000000000001e72 < d < -3.10000000000000013e-22 or 7.4999999999999999e50 < d Initial program 47.3%
Taylor expanded in c around 0
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
unpow2N/A
associate-/r*N/A
div-subN/A
lower-/.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6479.7
Applied rewrites79.7%
if -1.45e100 < d < -1.2200000000000001e72 or -3.10000000000000013e-22 < d < 7.4999999999999999e50Initial program 72.0%
Taylor expanded in c around inf
lower-/.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6484.1
Applied rewrites84.1%
Final simplification81.9%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- a) d)))
(if (<= c -2.1e+107)
(/ b c)
(if (<= c -2.1e-127)
(/ (* b c) (fma d d (* c c)))
(if (<= c 1.22e-129)
t_0
(if (<= c 4.5e-33)
(/ (- (* b c) (* d a)) (* d d))
(if (<= c 11500000.0) t_0 (/ b c))))))))
double code(double a, double b, double c, double d) {
double t_0 = -a / d;
double tmp;
if (c <= -2.1e+107) {
tmp = b / c;
} else if (c <= -2.1e-127) {
tmp = (b * c) / fma(d, d, (c * c));
} else if (c <= 1.22e-129) {
tmp = t_0;
} else if (c <= 4.5e-33) {
tmp = ((b * c) - (d * a)) / (d * d);
} else if (c <= 11500000.0) {
tmp = t_0;
} else {
tmp = b / c;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(-a) / d) tmp = 0.0 if (c <= -2.1e+107) tmp = Float64(b / c); elseif (c <= -2.1e-127) tmp = Float64(Float64(b * c) / fma(d, d, Float64(c * c))); elseif (c <= 1.22e-129) tmp = t_0; elseif (c <= 4.5e-33) tmp = Float64(Float64(Float64(b * c) - Float64(d * a)) / Float64(d * d)); elseif (c <= 11500000.0) tmp = t_0; else tmp = Float64(b / c); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[((-a) / d), $MachinePrecision]}, If[LessEqual[c, -2.1e+107], N[(b / c), $MachinePrecision], If[LessEqual[c, -2.1e-127], N[(N[(b * c), $MachinePrecision] / N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.22e-129], t$95$0, If[LessEqual[c, 4.5e-33], N[(N[(N[(b * c), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(d * d), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 11500000.0], t$95$0, N[(b / c), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-a}{d}\\
\mathbf{if}\;c \leq -2.1 \cdot 10^{+107}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{elif}\;c \leq -2.1 \cdot 10^{-127}:\\
\;\;\;\;\frac{b \cdot c}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\
\mathbf{elif}\;c \leq 1.22 \cdot 10^{-129}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq 4.5 \cdot 10^{-33}:\\
\;\;\;\;\frac{b \cdot c - d \cdot a}{d \cdot d}\\
\mathbf{elif}\;c \leq 11500000:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if c < -2.1e107 or 1.15e7 < c Initial program 37.2%
Taylor expanded in c around inf
lower-/.f6472.0
Applied rewrites72.0%
if -2.1e107 < c < -2.1000000000000001e-127Initial program 81.3%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f6481.3
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6481.3
Applied rewrites81.3%
Taylor expanded in c around inf
*-commutativeN/A
lower-*.f6463.1
Applied rewrites63.1%
if -2.1000000000000001e-127 < c < 1.21999999999999999e-129 or 4.49999999999999991e-33 < c < 1.15e7Initial program 65.0%
Taylor expanded in c around 0
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6472.4
Applied rewrites72.4%
if 1.21999999999999999e-129 < c < 4.49999999999999991e-33Initial program 85.5%
Taylor expanded in c around 0
unpow2N/A
lower-*.f6476.0
Applied rewrites76.0%
Final simplification70.7%
(FPCore (a b c d)
:precision binary64
(if (<= c -2.3e+108)
(/ b c)
(if (<= c -7.5e-126)
(/ (fma (- d) a (* b c)) (fma d d (* c c)))
(if (<= c 6000000.0)
(/ (fma (/ c d) b (- a)) d)
(/ (- b (/ (* d a) c)) c)))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -2.3e+108) {
tmp = b / c;
} else if (c <= -7.5e-126) {
tmp = fma(-d, a, (b * c)) / fma(d, d, (c * c));
} else if (c <= 6000000.0) {
tmp = fma((c / d), b, -a) / d;
} else {
tmp = (b - ((d * a) / c)) / c;
}
return tmp;
}
function code(a, b, c, d) tmp = 0.0 if (c <= -2.3e+108) tmp = Float64(b / c); elseif (c <= -7.5e-126) tmp = Float64(fma(Float64(-d), a, Float64(b * c)) / fma(d, d, Float64(c * c))); elseif (c <= 6000000.0) tmp = Float64(fma(Float64(c / d), b, Float64(-a)) / d); else tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c); end return tmp end
code[a_, b_, c_, d_] := If[LessEqual[c, -2.3e+108], N[(b / c), $MachinePrecision], If[LessEqual[c, -7.5e-126], N[(N[((-d) * a + N[(b * c), $MachinePrecision]), $MachinePrecision] / N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 6000000.0], N[(N[(N[(c / d), $MachinePrecision] * b + (-a)), $MachinePrecision] / d), $MachinePrecision], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -2.3 \cdot 10^{+108}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{elif}\;c \leq -7.5 \cdot 10^{-126}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-d, a, b \cdot c\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\
\mathbf{elif}\;c \leq 6000000:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{c}{d}, b, -a\right)}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\
\end{array}
\end{array}
if c < -2.2999999999999999e108Initial program 23.7%
Taylor expanded in c around inf
lower-/.f6472.3
Applied rewrites72.3%
if -2.2999999999999999e108 < c < -7.49999999999999976e-126Initial program 80.9%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f6480.9
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6480.9
Applied rewrites80.9%
if -7.49999999999999976e-126 < c < 6e6Initial program 68.8%
Taylor expanded in c around 0
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6469.4
Applied rewrites69.4%
Taylor expanded in c around 0
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
unpow2N/A
associate-/r*N/A
div-subN/A
sub-negN/A
mul-1-negN/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
associate-*l/N/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6489.7
Applied rewrites89.7%
if 6e6 < c Initial program 50.5%
Taylor expanded in c around inf
lower-/.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6479.6
Applied rewrites79.6%
Final simplification82.9%
(FPCore (a b c d)
:precision binary64
(if (<= c -2.1e+107)
(/ b c)
(if (<= c -2.1e-127)
(/ (* b c) (fma d d (* c c)))
(if (<= c 11500000.0) (/ (- a) d) (/ b c)))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -2.1e+107) {
tmp = b / c;
} else if (c <= -2.1e-127) {
tmp = (b * c) / fma(d, d, (c * c));
} else if (c <= 11500000.0) {
tmp = -a / d;
} else {
tmp = b / c;
}
return tmp;
}
function code(a, b, c, d) tmp = 0.0 if (c <= -2.1e+107) tmp = Float64(b / c); elseif (c <= -2.1e-127) tmp = Float64(Float64(b * c) / fma(d, d, Float64(c * c))); elseif (c <= 11500000.0) tmp = Float64(Float64(-a) / d); else tmp = Float64(b / c); end return tmp end
code[a_, b_, c_, d_] := If[LessEqual[c, -2.1e+107], N[(b / c), $MachinePrecision], If[LessEqual[c, -2.1e-127], N[(N[(b * c), $MachinePrecision] / N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 11500000.0], N[((-a) / d), $MachinePrecision], N[(b / c), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -2.1 \cdot 10^{+107}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{elif}\;c \leq -2.1 \cdot 10^{-127}:\\
\;\;\;\;\frac{b \cdot c}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\
\mathbf{elif}\;c \leq 11500000:\\
\;\;\;\;\frac{-a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if c < -2.1e107 or 1.15e7 < c Initial program 37.2%
Taylor expanded in c around inf
lower-/.f6472.0
Applied rewrites72.0%
if -2.1e107 < c < -2.1000000000000001e-127Initial program 81.3%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f6481.3
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6481.3
Applied rewrites81.3%
Taylor expanded in c around inf
*-commutativeN/A
lower-*.f6463.1
Applied rewrites63.1%
if -2.1000000000000001e-127 < c < 1.15e7Initial program 68.8%
Taylor expanded in c around 0
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6469.4
Applied rewrites69.4%
Final simplification69.1%
(FPCore (a b c d)
:precision binary64
(if (<= c -6.2e+112)
(/ b c)
(if (<= c -2.1e-127)
(* (/ c (fma c c (* d d))) b)
(if (<= c 11500000.0) (/ (- a) d) (/ b c)))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -6.2e+112) {
tmp = b / c;
} else if (c <= -2.1e-127) {
tmp = (c / fma(c, c, (d * d))) * b;
} else if (c <= 11500000.0) {
tmp = -a / d;
} else {
tmp = b / c;
}
return tmp;
}
function code(a, b, c, d) tmp = 0.0 if (c <= -6.2e+112) tmp = Float64(b / c); elseif (c <= -2.1e-127) tmp = Float64(Float64(c / fma(c, c, Float64(d * d))) * b); elseif (c <= 11500000.0) tmp = Float64(Float64(-a) / d); else tmp = Float64(b / c); end return tmp end
code[a_, b_, c_, d_] := If[LessEqual[c, -6.2e+112], N[(b / c), $MachinePrecision], If[LessEqual[c, -2.1e-127], N[(N[(c / N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision], If[LessEqual[c, 11500000.0], N[((-a) / d), $MachinePrecision], N[(b / c), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -6.2 \cdot 10^{+112}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{elif}\;c \leq -2.1 \cdot 10^{-127}:\\
\;\;\;\;\frac{c}{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot b\\
\mathbf{elif}\;c \leq 11500000:\\
\;\;\;\;\frac{-a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if c < -6.19999999999999965e112 or 1.15e7 < c Initial program 36.5%
Taylor expanded in c around inf
lower-/.f6471.7
Applied rewrites71.7%
if -6.19999999999999965e112 < c < -2.1000000000000001e-127Initial program 81.6%
Taylor expanded in c around inf
lower-/.f6441.2
Applied rewrites41.2%
Taylor expanded in b around inf
*-commutativeN/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6461.9
Applied rewrites61.9%
if -2.1000000000000001e-127 < c < 1.15e7Initial program 68.8%
Taylor expanded in c around 0
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6469.4
Applied rewrites69.4%
(FPCore (a b c d)
:precision binary64
(if (<= c -2.6e+114)
(/ b c)
(if (<= c -2.2e-127)
(* (/ b (fma c c (* d d))) c)
(if (<= c 11500000.0) (/ (- a) d) (/ b c)))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -2.6e+114) {
tmp = b / c;
} else if (c <= -2.2e-127) {
tmp = (b / fma(c, c, (d * d))) * c;
} else if (c <= 11500000.0) {
tmp = -a / d;
} else {
tmp = b / c;
}
return tmp;
}
function code(a, b, c, d) tmp = 0.0 if (c <= -2.6e+114) tmp = Float64(b / c); elseif (c <= -2.2e-127) tmp = Float64(Float64(b / fma(c, c, Float64(d * d))) * c); elseif (c <= 11500000.0) tmp = Float64(Float64(-a) / d); else tmp = Float64(b / c); end return tmp end
code[a_, b_, c_, d_] := If[LessEqual[c, -2.6e+114], N[(b / c), $MachinePrecision], If[LessEqual[c, -2.2e-127], N[(N[(b / N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * c), $MachinePrecision], If[LessEqual[c, 11500000.0], N[((-a) / d), $MachinePrecision], N[(b / c), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -2.6 \cdot 10^{+114}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{elif}\;c \leq -2.2 \cdot 10^{-127}:\\
\;\;\;\;\frac{b}{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot c\\
\mathbf{elif}\;c \leq 11500000:\\
\;\;\;\;\frac{-a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if c < -2.6e114 or 1.15e7 < c Initial program 35.8%
Taylor expanded in c around inf
lower-/.f6471.4
Applied rewrites71.4%
if -2.6e114 < c < -2.2000000000000001e-127Initial program 81.9%
Taylor expanded in b around inf
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6459.2
Applied rewrites59.2%
if -2.2000000000000001e-127 < c < 1.15e7Initial program 68.8%
Taylor expanded in c around 0
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6469.4
Applied rewrites69.4%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- a) d)))
(if (<= c -5.5e+80)
(/ b c)
(if (<= c -5.5e+25)
t_0
(if (<= c -4.5e-127) (/ b c) (if (<= c 11500000.0) t_0 (/ b c)))))))
double code(double a, double b, double c, double d) {
double t_0 = -a / d;
double tmp;
if (c <= -5.5e+80) {
tmp = b / c;
} else if (c <= -5.5e+25) {
tmp = t_0;
} else if (c <= -4.5e-127) {
tmp = b / c;
} else if (c <= 11500000.0) {
tmp = t_0;
} else {
tmp = b / c;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: tmp
t_0 = -a / d
if (c <= (-5.5d+80)) then
tmp = b / c
else if (c <= (-5.5d+25)) then
tmp = t_0
else if (c <= (-4.5d-127)) then
tmp = b / c
else if (c <= 11500000.0d0) then
tmp = t_0
else
tmp = b / c
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 (c <= -5.5e+80) {
tmp = b / c;
} else if (c <= -5.5e+25) {
tmp = t_0;
} else if (c <= -4.5e-127) {
tmp = b / c;
} else if (c <= 11500000.0) {
tmp = t_0;
} else {
tmp = b / c;
}
return tmp;
}
def code(a, b, c, d): t_0 = -a / d tmp = 0 if c <= -5.5e+80: tmp = b / c elif c <= -5.5e+25: tmp = t_0 elif c <= -4.5e-127: tmp = b / c elif c <= 11500000.0: tmp = t_0 else: tmp = b / c return tmp
function code(a, b, c, d) t_0 = Float64(Float64(-a) / d) tmp = 0.0 if (c <= -5.5e+80) tmp = Float64(b / c); elseif (c <= -5.5e+25) tmp = t_0; elseif (c <= -4.5e-127) tmp = Float64(b / c); elseif (c <= 11500000.0) tmp = t_0; else tmp = Float64(b / c); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = -a / d; tmp = 0.0; if (c <= -5.5e+80) tmp = b / c; elseif (c <= -5.5e+25) tmp = t_0; elseif (c <= -4.5e-127) tmp = b / c; elseif (c <= 11500000.0) tmp = t_0; else tmp = b / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[((-a) / d), $MachinePrecision]}, If[LessEqual[c, -5.5e+80], N[(b / c), $MachinePrecision], If[LessEqual[c, -5.5e+25], t$95$0, If[LessEqual[c, -4.5e-127], N[(b / c), $MachinePrecision], If[LessEqual[c, 11500000.0], t$95$0, N[(b / c), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-a}{d}\\
\mathbf{if}\;c \leq -5.5 \cdot 10^{+80}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{elif}\;c \leq -5.5 \cdot 10^{+25}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq -4.5 \cdot 10^{-127}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{elif}\;c \leq 11500000:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if c < -5.49999999999999967e80 or -5.50000000000000018e25 < c < -4.4999999999999999e-127 or 1.15e7 < c Initial program 51.5%
Taylor expanded in c around inf
lower-/.f6464.1
Applied rewrites64.1%
if -5.49999999999999967e80 < c < -5.50000000000000018e25 or -4.4999999999999999e-127 < c < 1.15e7Initial program 68.4%
Taylor expanded in c around 0
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6468.7
Applied rewrites68.7%
(FPCore (a b c d) :precision binary64 (/ b c))
double code(double a, double b, double c, double d) {
return b / c;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = b / c
end function
public static double code(double a, double b, double c, double d) {
return b / c;
}
def code(a, b, c, d): return b / c
function code(a, b, c, d) return Float64(b / c) end
function tmp = code(a, b, c, d) tmp = b / c; end
code[a_, b_, c_, d_] := N[(b / c), $MachinePrecision]
\begin{array}{l}
\\
\frac{b}{c}
\end{array}
Initial program 59.4%
Taylor expanded in c around inf
lower-/.f6441.3
Applied rewrites41.3%
(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 2024259
(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))))