
(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 14 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 c c (* d d))) (t_1 (/ (fma c (/ b d) (- 0.0 a)) d)))
(if (<= d -6.5e+136)
t_1
(if (<= d -7.5e-68)
(fma d (/ (- 0.0 a) t_0) (/ (* c b) t_0))
(if (<= d 3.4e-165)
(/ (- b (* a (/ d c))) c)
(if (<= d 7e+79) (/ (- (* c b) (* d a)) (+ (* d d) (* c c))) t_1))))))
double code(double a, double b, double c, double d) {
double t_0 = fma(c, c, (d * d));
double t_1 = fma(c, (b / d), (0.0 - a)) / d;
double tmp;
if (d <= -6.5e+136) {
tmp = t_1;
} else if (d <= -7.5e-68) {
tmp = fma(d, ((0.0 - a) / t_0), ((c * b) / t_0));
} else if (d <= 3.4e-165) {
tmp = (b - (a * (d / c))) / c;
} else if (d <= 7e+79) {
tmp = ((c * b) - (d * a)) / ((d * d) + (c * c));
} else {
tmp = t_1;
}
return tmp;
}
function code(a, b, c, d) t_0 = fma(c, c, Float64(d * d)) t_1 = Float64(fma(c, Float64(b / d), Float64(0.0 - a)) / d) tmp = 0.0 if (d <= -6.5e+136) tmp = t_1; elseif (d <= -7.5e-68) tmp = fma(d, Float64(Float64(0.0 - a) / t_0), Float64(Float64(c * b) / t_0)); elseif (d <= 3.4e-165) tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c); elseif (d <= 7e+79) tmp = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(d * d) + Float64(c * c))); else tmp = t_1; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(c * N[(b / d), $MachinePrecision] + N[(0.0 - a), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -6.5e+136], t$95$1, If[LessEqual[d, -7.5e-68], N[(d * N[(N[(0.0 - a), $MachinePrecision] / t$95$0), $MachinePrecision] + N[(N[(c * b), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 3.4e-165], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 7e+79], N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(d * d), $MachinePrecision] + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(c, c, d \cdot d\right)\\
t_1 := \frac{\mathsf{fma}\left(c, \frac{b}{d}, 0 - a\right)}{d}\\
\mathbf{if}\;d \leq -6.5 \cdot 10^{+136}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d \leq -7.5 \cdot 10^{-68}:\\
\;\;\;\;\mathsf{fma}\left(d, \frac{0 - a}{t\_0}, \frac{c \cdot b}{t\_0}\right)\\
\mathbf{elif}\;d \leq 3.4 \cdot 10^{-165}:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\
\mathbf{elif}\;d \leq 7 \cdot 10^{+79}:\\
\;\;\;\;\frac{c \cdot b - d \cdot a}{d \cdot d + c \cdot c}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if d < -6.4999999999999998e136 or 6.99999999999999961e79 < d Initial program 39.1%
Taylor expanded in c around 0
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
unpow2N/A
associate-/r*N/A
div-subN/A
/-lowering-/.f64N/A
sub-negN/A
*-commutativeN/A
associate-/l*N/A
mul-1-negN/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f64N/A
mul-1-negN/A
neg-sub0N/A
--lowering--.f6489.9
Simplified89.9%
if -6.4999999999999998e136 < d < -7.50000000000000081e-68Initial program 82.5%
div-subN/A
sub-negN/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
distribute-rgt-neg-inN/A
accelerator-lowering-fma.f64N/A
neg-lowering-neg.f64N/A
/-lowering-/.f64N/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f6493.0
Applied egg-rr93.0%
if -7.50000000000000081e-68 < d < 3.4e-165Initial program 69.7%
Taylor expanded in c around inf
/-lowering-/.f64N/A
mul-1-negN/A
unsub-negN/A
--lowering--.f64N/A
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f6494.1
Simplified94.1%
*-commutativeN/A
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f6494.2
Applied egg-rr94.2%
if 3.4e-165 < d < 6.99999999999999961e79Initial program 81.4%
Final simplification90.0%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* c b) (* d a)) (+ (* d d) (* c c))))
(t_1 (/ (fma c (/ b d) (- 0.0 a)) d)))
(if (<= d -9.3e+42)
t_1
(if (<= d -7e-84)
t_0
(if (<= d 3.4e-165)
(/ (- b (* a (/ d c))) c)
(if (<= d 1.5e+81) t_0 t_1))))))
double code(double a, double b, double c, double d) {
double t_0 = ((c * b) - (d * a)) / ((d * d) + (c * c));
double t_1 = fma(c, (b / d), (0.0 - a)) / d;
double tmp;
if (d <= -9.3e+42) {
tmp = t_1;
} else if (d <= -7e-84) {
tmp = t_0;
} else if (d <= 3.4e-165) {
tmp = (b - (a * (d / c))) / c;
} else if (d <= 1.5e+81) {
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(d * d) + Float64(c * c))) t_1 = Float64(fma(c, Float64(b / d), Float64(0.0 - a)) / d) tmp = 0.0 if (d <= -9.3e+42) tmp = t_1; elseif (d <= -7e-84) tmp = t_0; elseif (d <= 3.4e-165) tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c); elseif (d <= 1.5e+81) 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[(d * d), $MachinePrecision] + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(c * N[(b / d), $MachinePrecision] + N[(0.0 - a), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -9.3e+42], t$95$1, If[LessEqual[d, -7e-84], t$95$0, If[LessEqual[d, 3.4e-165], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 1.5e+81], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c \cdot b - d \cdot a}{d \cdot d + c \cdot c}\\
t_1 := \frac{\mathsf{fma}\left(c, \frac{b}{d}, 0 - a\right)}{d}\\
\mathbf{if}\;d \leq -9.3 \cdot 10^{+42}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d \leq -7 \cdot 10^{-84}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 3.4 \cdot 10^{-165}:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\
\mathbf{elif}\;d \leq 1.5 \cdot 10^{+81}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if d < -9.3000000000000005e42 or 1.49999999999999999e81 < d Initial program 45.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
/-lowering-/.f64N/A
sub-negN/A
*-commutativeN/A
associate-/l*N/A
mul-1-negN/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f64N/A
mul-1-negN/A
neg-sub0N/A
--lowering--.f6487.4
Simplified87.4%
if -9.3000000000000005e42 < d < -7.0000000000000002e-84 or 3.4e-165 < d < 1.49999999999999999e81Initial program 85.6%
if -7.0000000000000002e-84 < d < 3.4e-165Initial program 69.1%
Taylor expanded in c around inf
/-lowering-/.f64N/A
mul-1-negN/A
unsub-negN/A
--lowering--.f64N/A
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f6494.9
Simplified94.9%
*-commutativeN/A
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f6494.9
Applied egg-rr94.9%
Final simplification89.3%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* c b) (* d a)) (* c c))))
(if (<= c -1.15e+86)
(/ b c)
(if (<= c -8.2e-69)
t_0
(if (<= c 3.3e-158)
(/ a (- 0.0 d))
(if (<= c 38000000.0)
t_0
(if (<= c 2.4e+45)
(/ (* d a) (- 0.0 (fma d d (* c c))))
(/ b c))))))))
double code(double a, double b, double c, double d) {
double t_0 = ((c * b) - (d * a)) / (c * c);
double tmp;
if (c <= -1.15e+86) {
tmp = b / c;
} else if (c <= -8.2e-69) {
tmp = t_0;
} else if (c <= 3.3e-158) {
tmp = a / (0.0 - d);
} else if (c <= 38000000.0) {
tmp = t_0;
} else if (c <= 2.4e+45) {
tmp = (d * a) / (0.0 - fma(d, d, (c * c)));
} else {
tmp = b / c;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(c * c)) tmp = 0.0 if (c <= -1.15e+86) tmp = Float64(b / c); elseif (c <= -8.2e-69) tmp = t_0; elseif (c <= 3.3e-158) tmp = Float64(a / Float64(0.0 - d)); elseif (c <= 38000000.0) tmp = t_0; elseif (c <= 2.4e+45) tmp = Float64(Float64(d * a) / Float64(0.0 - fma(d, d, Float64(c * c)))); else tmp = Float64(b / c); 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[(c * c), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -1.15e+86], N[(b / c), $MachinePrecision], If[LessEqual[c, -8.2e-69], t$95$0, If[LessEqual[c, 3.3e-158], N[(a / N[(0.0 - d), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 38000000.0], t$95$0, If[LessEqual[c, 2.4e+45], N[(N[(d * a), $MachinePrecision] / N[(0.0 - N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(b / c), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c \cdot b - d \cdot a}{c \cdot c}\\
\mathbf{if}\;c \leq -1.15 \cdot 10^{+86}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{elif}\;c \leq -8.2 \cdot 10^{-69}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq 3.3 \cdot 10^{-158}:\\
\;\;\;\;\frac{a}{0 - d}\\
\mathbf{elif}\;c \leq 38000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq 2.4 \cdot 10^{+45}:\\
\;\;\;\;\frac{d \cdot a}{0 - \mathsf{fma}\left(d, d, c \cdot c\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if c < -1.14999999999999995e86 or 2.39999999999999989e45 < c Initial program 49.3%
Taylor expanded in c around inf
/-lowering-/.f6477.4
Simplified77.4%
if -1.14999999999999995e86 < c < -8.1999999999999998e-69 or 3.3000000000000002e-158 < c < 3.8e7Initial program 79.0%
Taylor expanded in c around inf
unpow2N/A
*-lowering-*.f6456.5
Simplified56.5%
if -8.1999999999999998e-69 < c < 3.3000000000000002e-158Initial program 68.9%
Taylor expanded in c around 0
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
/-lowering-/.f64N/A
mul-1-negN/A
neg-sub0N/A
--lowering--.f6476.2
Simplified76.2%
neg-sub0N/A
neg-lowering-neg.f6476.2
Applied egg-rr76.2%
if 3.8e7 < c < 2.39999999999999989e45Initial program 99.8%
div-invN/A
flip3--N/A
clear-numN/A
frac-2negN/A
metadata-evalN/A
frac-timesN/A
metadata-evalN/A
/-lowering-/.f64N/A
Applied egg-rr99.4%
Taylor expanded in b around 0
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
mul-1-negN/A
neg-lowering-neg.f64N/A
+-commutativeN/A
unpow2N/A
accelerator-lowering-fma.f64N/A
unpow2N/A
*-lowering-*.f6484.9
Simplified84.9%
Final simplification72.1%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ a (- 0.0 d))) (t_1 (- (* c b) (* d a))))
(if (<= d -1.3e+154)
t_0
(if (<= d -5.3e-28)
(* a (/ (- 0.0 d) (fma c c (* d d))))
(if (<= d 7.5e-222)
(/ b c)
(if (<= d 1.25e-70)
(/ t_1 (* c c))
(if (<= d 5.1e+98) (/ t_1 (* d d)) t_0)))))))
double code(double a, double b, double c, double d) {
double t_0 = a / (0.0 - d);
double t_1 = (c * b) - (d * a);
double tmp;
if (d <= -1.3e+154) {
tmp = t_0;
} else if (d <= -5.3e-28) {
tmp = a * ((0.0 - d) / fma(c, c, (d * d)));
} else if (d <= 7.5e-222) {
tmp = b / c;
} else if (d <= 1.25e-70) {
tmp = t_1 / (c * c);
} else if (d <= 5.1e+98) {
tmp = t_1 / (d * d);
} else {
tmp = t_0;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(a / Float64(0.0 - d)) t_1 = Float64(Float64(c * b) - Float64(d * a)) tmp = 0.0 if (d <= -1.3e+154) tmp = t_0; elseif (d <= -5.3e-28) tmp = Float64(a * Float64(Float64(0.0 - d) / fma(c, c, Float64(d * d)))); elseif (d <= 7.5e-222) tmp = Float64(b / c); elseif (d <= 1.25e-70) tmp = Float64(t_1 / Float64(c * c)); elseif (d <= 5.1e+98) tmp = Float64(t_1 / Float64(d * d)); else tmp = t_0; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(a / N[(0.0 - d), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -1.3e+154], t$95$0, If[LessEqual[d, -5.3e-28], N[(a * N[(N[(0.0 - d), $MachinePrecision] / N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 7.5e-222], N[(b / c), $MachinePrecision], If[LessEqual[d, 1.25e-70], N[(t$95$1 / N[(c * c), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 5.1e+98], N[(t$95$1 / N[(d * d), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a}{0 - d}\\
t_1 := c \cdot b - d \cdot a\\
\mathbf{if}\;d \leq -1.3 \cdot 10^{+154}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq -5.3 \cdot 10^{-28}:\\
\;\;\;\;a \cdot \frac{0 - d}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\
\mathbf{elif}\;d \leq 7.5 \cdot 10^{-222}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{elif}\;d \leq 1.25 \cdot 10^{-70}:\\
\;\;\;\;\frac{t\_1}{c \cdot c}\\
\mathbf{elif}\;d \leq 5.1 \cdot 10^{+98}:\\
\;\;\;\;\frac{t\_1}{d \cdot d}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d < -1.29999999999999994e154 or 5.09999999999999988e98 < d Initial program 38.0%
Taylor expanded in c around 0
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
/-lowering-/.f64N/A
mul-1-negN/A
neg-sub0N/A
--lowering--.f6477.0
Simplified77.0%
neg-sub0N/A
neg-lowering-neg.f6477.0
Applied egg-rr77.0%
if -1.29999999999999994e154 < d < -5.29999999999999988e-28Initial program 76.3%
div-subN/A
sub-negN/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
distribute-rgt-neg-inN/A
accelerator-lowering-fma.f64N/A
neg-lowering-neg.f64N/A
/-lowering-/.f64N/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f6488.7
Applied egg-rr88.7%
Taylor expanded in a around inf
mul-1-negN/A
neg-sub0N/A
--lowering--.f64N/A
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
unpow2N/A
accelerator-lowering-fma.f64N/A
unpow2N/A
*-lowering-*.f6475.7
Simplified75.7%
if -5.29999999999999988e-28 < d < 7.5000000000000004e-222Initial program 72.1%
Taylor expanded in c around inf
/-lowering-/.f6478.0
Simplified78.0%
if 7.5000000000000004e-222 < d < 1.25e-70Initial program 82.1%
Taylor expanded in c around inf
unpow2N/A
*-lowering-*.f6467.9
Simplified67.9%
if 1.25e-70 < d < 5.09999999999999988e98Initial program 77.4%
Taylor expanded in c around 0
unpow2N/A
*-lowering-*.f6457.4
Simplified57.4%
Final simplification73.1%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (- (* c b) (* d a))) (t_1 (/ t_0 (* c c))))
(if (<= c -5.4e+79)
(/ b c)
(if (<= c -5.2e-68)
t_1
(if (<= c 3.3e-158)
(/ a (- 0.0 d))
(if (<= c 1.18e-73)
t_1
(if (<= c 4.8e+45) (/ t_0 (* d d)) (/ b c))))))))
double code(double a, double b, double c, double d) {
double t_0 = (c * b) - (d * a);
double t_1 = t_0 / (c * c);
double tmp;
if (c <= -5.4e+79) {
tmp = b / c;
} else if (c <= -5.2e-68) {
tmp = t_1;
} else if (c <= 3.3e-158) {
tmp = a / (0.0 - d);
} else if (c <= 1.18e-73) {
tmp = t_1;
} else if (c <= 4.8e+45) {
tmp = t_0 / (d * d);
} 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) :: t_1
real(8) :: tmp
t_0 = (c * b) - (d * a)
t_1 = t_0 / (c * c)
if (c <= (-5.4d+79)) then
tmp = b / c
else if (c <= (-5.2d-68)) then
tmp = t_1
else if (c <= 3.3d-158) then
tmp = a / (0.0d0 - d)
else if (c <= 1.18d-73) then
tmp = t_1
else if (c <= 4.8d+45) then
tmp = t_0 / (d * d)
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 = (c * b) - (d * a);
double t_1 = t_0 / (c * c);
double tmp;
if (c <= -5.4e+79) {
tmp = b / c;
} else if (c <= -5.2e-68) {
tmp = t_1;
} else if (c <= 3.3e-158) {
tmp = a / (0.0 - d);
} else if (c <= 1.18e-73) {
tmp = t_1;
} else if (c <= 4.8e+45) {
tmp = t_0 / (d * d);
} else {
tmp = b / c;
}
return tmp;
}
def code(a, b, c, d): t_0 = (c * b) - (d * a) t_1 = t_0 / (c * c) tmp = 0 if c <= -5.4e+79: tmp = b / c elif c <= -5.2e-68: tmp = t_1 elif c <= 3.3e-158: tmp = a / (0.0 - d) elif c <= 1.18e-73: tmp = t_1 elif c <= 4.8e+45: tmp = t_0 / (d * d) else: tmp = b / c return tmp
function code(a, b, c, d) t_0 = Float64(Float64(c * b) - Float64(d * a)) t_1 = Float64(t_0 / Float64(c * c)) tmp = 0.0 if (c <= -5.4e+79) tmp = Float64(b / c); elseif (c <= -5.2e-68) tmp = t_1; elseif (c <= 3.3e-158) tmp = Float64(a / Float64(0.0 - d)); elseif (c <= 1.18e-73) tmp = t_1; elseif (c <= 4.8e+45) tmp = Float64(t_0 / Float64(d * d)); else tmp = Float64(b / c); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (c * b) - (d * a); t_1 = t_0 / (c * c); tmp = 0.0; if (c <= -5.4e+79) tmp = b / c; elseif (c <= -5.2e-68) tmp = t_1; elseif (c <= 3.3e-158) tmp = a / (0.0 - d); elseif (c <= 1.18e-73) tmp = t_1; elseif (c <= 4.8e+45) tmp = t_0 / (d * d); else tmp = b / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 / N[(c * c), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -5.4e+79], N[(b / c), $MachinePrecision], If[LessEqual[c, -5.2e-68], t$95$1, If[LessEqual[c, 3.3e-158], N[(a / N[(0.0 - d), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.18e-73], t$95$1, If[LessEqual[c, 4.8e+45], N[(t$95$0 / N[(d * d), $MachinePrecision]), $MachinePrecision], N[(b / c), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := c \cdot b - d \cdot a\\
t_1 := \frac{t\_0}{c \cdot c}\\
\mathbf{if}\;c \leq -5.4 \cdot 10^{+79}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{elif}\;c \leq -5.2 \cdot 10^{-68}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;c \leq 3.3 \cdot 10^{-158}:\\
\;\;\;\;\frac{a}{0 - d}\\
\mathbf{elif}\;c \leq 1.18 \cdot 10^{-73}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;c \leq 4.8 \cdot 10^{+45}:\\
\;\;\;\;\frac{t\_0}{d \cdot d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if c < -5.3999999999999999e79 or 4.79999999999999979e45 < c Initial program 49.3%
Taylor expanded in c around inf
/-lowering-/.f6477.4
Simplified77.4%
if -5.3999999999999999e79 < c < -5.1999999999999996e-68 or 3.3000000000000002e-158 < c < 1.17999999999999993e-73Initial program 75.7%
Taylor expanded in c around inf
unpow2N/A
*-lowering-*.f6460.3
Simplified60.3%
if -5.1999999999999996e-68 < c < 3.3000000000000002e-158Initial program 68.9%
Taylor expanded in c around 0
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
/-lowering-/.f64N/A
mul-1-negN/A
neg-sub0N/A
--lowering--.f6476.2
Simplified76.2%
neg-sub0N/A
neg-lowering-neg.f6476.2
Applied egg-rr76.2%
if 1.17999999999999993e-73 < c < 4.79999999999999979e45Initial program 96.0%
Taylor expanded in c around 0
unpow2N/A
*-lowering-*.f6467.6
Simplified67.6%
Final simplification72.5%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ a (- 0.0 d))) (t_1 (/ (* d a) (- 0.0 (fma d d (* c c))))))
(if (<= d -3.8e+42)
t_0
(if (<= d -1.6e-27)
t_1
(if (<= d 3.7e-159) (/ b c) (if (<= d 260000000000.0) t_1 t_0))))))
double code(double a, double b, double c, double d) {
double t_0 = a / (0.0 - d);
double t_1 = (d * a) / (0.0 - fma(d, d, (c * c)));
double tmp;
if (d <= -3.8e+42) {
tmp = t_0;
} else if (d <= -1.6e-27) {
tmp = t_1;
} else if (d <= 3.7e-159) {
tmp = b / c;
} else if (d <= 260000000000.0) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(a / Float64(0.0 - d)) t_1 = Float64(Float64(d * a) / Float64(0.0 - fma(d, d, Float64(c * c)))) tmp = 0.0 if (d <= -3.8e+42) tmp = t_0; elseif (d <= -1.6e-27) tmp = t_1; elseif (d <= 3.7e-159) tmp = Float64(b / c); elseif (d <= 260000000000.0) tmp = t_1; else tmp = t_0; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(a / N[(0.0 - d), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(d * a), $MachinePrecision] / N[(0.0 - N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -3.8e+42], t$95$0, If[LessEqual[d, -1.6e-27], t$95$1, If[LessEqual[d, 3.7e-159], N[(b / c), $MachinePrecision], If[LessEqual[d, 260000000000.0], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a}{0 - d}\\
t_1 := \frac{d \cdot a}{0 - \mathsf{fma}\left(d, d, c \cdot c\right)}\\
\mathbf{if}\;d \leq -3.8 \cdot 10^{+42}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq -1.6 \cdot 10^{-27}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d \leq 3.7 \cdot 10^{-159}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{elif}\;d \leq 260000000000:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d < -3.7999999999999998e42 or 2.6e11 < d Initial program 49.9%
Taylor expanded in c around 0
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
/-lowering-/.f64N/A
mul-1-negN/A
neg-sub0N/A
--lowering--.f6470.2
Simplified70.2%
neg-sub0N/A
neg-lowering-neg.f6470.2
Applied egg-rr70.2%
if -3.7999999999999998e42 < d < -1.59999999999999995e-27 or 3.6999999999999999e-159 < d < 2.6e11Initial program 88.6%
div-invN/A
flip3--N/A
clear-numN/A
frac-2negN/A
metadata-evalN/A
frac-timesN/A
metadata-evalN/A
/-lowering-/.f64N/A
Applied egg-rr87.9%
Taylor expanded in b around 0
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
mul-1-negN/A
neg-lowering-neg.f64N/A
+-commutativeN/A
unpow2N/A
accelerator-lowering-fma.f64N/A
unpow2N/A
*-lowering-*.f6460.8
Simplified60.8%
if -1.59999999999999995e-27 < d < 3.6999999999999999e-159Initial program 72.2%
Taylor expanded in c around inf
/-lowering-/.f6475.7
Simplified75.7%
Final simplification70.5%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ a (- 0.0 d))))
(if (<= d -2.55e+153)
t_0
(if (<= d -5.8e-26)
(* a (/ (- 0.0 d) (fma c c (* d d))))
(if (<= d 7.8e+37) (/ (- b (/ (* d a) c)) c) t_0)))))
double code(double a, double b, double c, double d) {
double t_0 = a / (0.0 - d);
double tmp;
if (d <= -2.55e+153) {
tmp = t_0;
} else if (d <= -5.8e-26) {
tmp = a * ((0.0 - d) / fma(c, c, (d * d)));
} else if (d <= 7.8e+37) {
tmp = (b - ((d * a) / c)) / c;
} else {
tmp = t_0;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(a / Float64(0.0 - d)) tmp = 0.0 if (d <= -2.55e+153) tmp = t_0; elseif (d <= -5.8e-26) tmp = Float64(a * Float64(Float64(0.0 - d) / fma(c, c, Float64(d * d)))); elseif (d <= 7.8e+37) 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[(a / N[(0.0 - d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -2.55e+153], t$95$0, If[LessEqual[d, -5.8e-26], N[(a * N[(N[(0.0 - d), $MachinePrecision] / N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 7.8e+37], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a}{0 - d}\\
\mathbf{if}\;d \leq -2.55 \cdot 10^{+153}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq -5.8 \cdot 10^{-26}:\\
\;\;\;\;a \cdot \frac{0 - d}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\
\mathbf{elif}\;d \leq 7.8 \cdot 10^{+37}:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d < -2.55000000000000018e153 or 7.7999999999999997e37 < d Initial program 45.7%
Taylor expanded in c around 0
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
/-lowering-/.f64N/A
mul-1-negN/A
neg-sub0N/A
--lowering--.f6475.0
Simplified75.0%
neg-sub0N/A
neg-lowering-neg.f6475.0
Applied egg-rr75.0%
if -2.55000000000000018e153 < d < -5.7999999999999996e-26Initial program 76.3%
div-subN/A
sub-negN/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
distribute-rgt-neg-inN/A
accelerator-lowering-fma.f64N/A
neg-lowering-neg.f64N/A
/-lowering-/.f64N/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f6488.7
Applied egg-rr88.7%
Taylor expanded in a around inf
mul-1-negN/A
neg-sub0N/A
--lowering--.f64N/A
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
unpow2N/A
accelerator-lowering-fma.f64N/A
unpow2N/A
*-lowering-*.f6475.7
Simplified75.7%
if -5.7999999999999996e-26 < d < 7.7999999999999997e37Initial program 74.1%
Taylor expanded in c around inf
/-lowering-/.f64N/A
mul-1-negN/A
unsub-negN/A
--lowering--.f64N/A
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f6483.3
Simplified83.3%
Final simplification79.8%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ a (- 0.0 d))))
(if (<= d -1.3e+154)
t_0
(if (<= d -5.2e-25)
(* a (/ (- 0.0 d) (fma c c (* d d))))
(if (<= d 7.2e+41) (/ (- b (* a (/ d c))) c) t_0)))))
double code(double a, double b, double c, double d) {
double t_0 = a / (0.0 - d);
double tmp;
if (d <= -1.3e+154) {
tmp = t_0;
} else if (d <= -5.2e-25) {
tmp = a * ((0.0 - d) / fma(c, c, (d * d)));
} else if (d <= 7.2e+41) {
tmp = (b - (a * (d / c))) / c;
} else {
tmp = t_0;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(a / Float64(0.0 - d)) tmp = 0.0 if (d <= -1.3e+154) tmp = t_0; elseif (d <= -5.2e-25) tmp = Float64(a * Float64(Float64(0.0 - d) / fma(c, c, Float64(d * d)))); elseif (d <= 7.2e+41) tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c); else tmp = t_0; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(a / N[(0.0 - d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -1.3e+154], t$95$0, If[LessEqual[d, -5.2e-25], N[(a * N[(N[(0.0 - d), $MachinePrecision] / N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 7.2e+41], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a}{0 - d}\\
\mathbf{if}\;d \leq -1.3 \cdot 10^{+154}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq -5.2 \cdot 10^{-25}:\\
\;\;\;\;a \cdot \frac{0 - d}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\
\mathbf{elif}\;d \leq 7.2 \cdot 10^{+41}:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d < -1.29999999999999994e154 or 7.20000000000000051e41 < d Initial program 45.7%
Taylor expanded in c around 0
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
/-lowering-/.f64N/A
mul-1-negN/A
neg-sub0N/A
--lowering--.f6475.0
Simplified75.0%
neg-sub0N/A
neg-lowering-neg.f6475.0
Applied egg-rr75.0%
if -1.29999999999999994e154 < d < -5.2e-25Initial program 76.3%
div-subN/A
sub-negN/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
distribute-rgt-neg-inN/A
accelerator-lowering-fma.f64N/A
neg-lowering-neg.f64N/A
/-lowering-/.f64N/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f6488.7
Applied egg-rr88.7%
Taylor expanded in a around inf
mul-1-negN/A
neg-sub0N/A
--lowering--.f64N/A
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
unpow2N/A
accelerator-lowering-fma.f64N/A
unpow2N/A
*-lowering-*.f6475.7
Simplified75.7%
if -5.2e-25 < d < 7.20000000000000051e41Initial program 74.1%
Taylor expanded in c around inf
/-lowering-/.f64N/A
mul-1-negN/A
unsub-negN/A
--lowering--.f64N/A
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f6483.3
Simplified83.3%
*-commutativeN/A
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f6483.3
Applied egg-rr83.3%
Final simplification79.8%
(FPCore (a b c d) :precision binary64 (let* ((t_0 (/ (fma c (/ b d) (- 0.0 a)) d))) (if (<= d -15200000.0) t_0 (if (<= d 2.9) (/ (- b (/ (* d a) c)) c) t_0))))
double code(double a, double b, double c, double d) {
double t_0 = fma(c, (b / d), (0.0 - a)) / d;
double tmp;
if (d <= -15200000.0) {
tmp = t_0;
} else if (d <= 2.9) {
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(0.0 - a)) / d) tmp = 0.0 if (d <= -15200000.0) tmp = t_0; elseif (d <= 2.9) 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] + N[(0.0 - a), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -15200000.0], t$95$0, If[LessEqual[d, 2.9], 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}, 0 - a\right)}{d}\\
\mathbf{if}\;d \leq -15200000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 2.9:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d < -1.52e7 or 2.89999999999999991 < d Initial program 53.7%
Taylor expanded in c around 0
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
unpow2N/A
associate-/r*N/A
div-subN/A
/-lowering-/.f64N/A
sub-negN/A
*-commutativeN/A
associate-/l*N/A
mul-1-negN/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f64N/A
mul-1-negN/A
neg-sub0N/A
--lowering--.f6482.4
Simplified82.4%
if -1.52e7 < d < 2.89999999999999991Initial program 76.2%
Taylor expanded in c around inf
/-lowering-/.f64N/A
mul-1-negN/A
unsub-negN/A
--lowering--.f64N/A
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f6486.5
Simplified86.5%
(FPCore (a b c d) :precision binary64 (let* ((t_0 (/ (fma b (/ c d) (- 0.0 a)) d))) (if (<= d -310000.0) t_0 (if (<= d 7.2) (/ (- b (/ (* d a) c)) c) t_0))))
double code(double a, double b, double c, double d) {
double t_0 = fma(b, (c / d), (0.0 - a)) / d;
double tmp;
if (d <= -310000.0) {
tmp = t_0;
} else if (d <= 7.2) {
tmp = (b - ((d * a) / c)) / c;
} else {
tmp = t_0;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(fma(b, Float64(c / d), Float64(0.0 - a)) / d) tmp = 0.0 if (d <= -310000.0) tmp = t_0; elseif (d <= 7.2) 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[(b * N[(c / d), $MachinePrecision] + N[(0.0 - a), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -310000.0], t$95$0, If[LessEqual[d, 7.2], 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(b, \frac{c}{d}, 0 - a\right)}{d}\\
\mathbf{if}\;d \leq -310000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 7.2:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d < -3.1e5 or 7.20000000000000018 < d Initial program 53.7%
div-invN/A
flip3--N/A
clear-numN/A
frac-2negN/A
metadata-evalN/A
frac-timesN/A
metadata-evalN/A
/-lowering-/.f64N/A
Applied egg-rr53.5%
Taylor expanded in d around inf
/-lowering-/.f64N/A
+-commutativeN/A
associate-/l*N/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f64N/A
mul-1-negN/A
neg-sub0N/A
--lowering--.f6481.3
Simplified81.3%
if -3.1e5 < d < 7.20000000000000018Initial program 76.2%
Taylor expanded in c around inf
/-lowering-/.f64N/A
mul-1-negN/A
unsub-negN/A
--lowering--.f64N/A
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f6486.5
Simplified86.5%
(FPCore (a b c d) :precision binary64 (let* ((t_0 (/ (- (/ (* c b) d) a) d))) (if (<= d -6200000.0) t_0 (if (<= d 42.0) (/ (- 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 <= -6200000.0) {
tmp = t_0;
} else if (d <= 42.0) {
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 <= (-6200000.0d0)) then
tmp = t_0
else if (d <= 42.0d0) 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 <= -6200000.0) {
tmp = t_0;
} else if (d <= 42.0) {
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 <= -6200000.0: tmp = t_0 elif d <= 42.0: 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 <= -6200000.0) tmp = t_0; elseif (d <= 42.0) 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 <= -6200000.0) tmp = t_0; elseif (d <= 42.0) 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, -6200000.0], t$95$0, If[LessEqual[d, 42.0], 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 -6200000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 42:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d < -6.2e6 or 42 < d Initial program 53.7%
div-subN/A
sub-negN/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
distribute-rgt-neg-inN/A
accelerator-lowering-fma.f64N/A
neg-lowering-neg.f64N/A
/-lowering-/.f64N/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f6458.9
Applied egg-rr58.9%
Taylor expanded in d around inf
/-lowering-/.f64N/A
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
--lowering--.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f6476.7
Simplified76.7%
if -6.2e6 < d < 42Initial program 76.2%
Taylor expanded in c around inf
/-lowering-/.f64N/A
mul-1-negN/A
unsub-negN/A
--lowering--.f64N/A
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f6486.5
Simplified86.5%
Final simplification81.9%
(FPCore (a b c d)
:precision binary64
(if (<= c -1.9e+106)
(/ b c)
(if (<= c -6.2e-127)
(* b (/ c (fma c c (* d d))))
(if (<= c 2.15e+45) (/ a (- 0.0 d)) (/ b c)))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -1.9e+106) {
tmp = b / c;
} else if (c <= -6.2e-127) {
tmp = b * (c / fma(c, c, (d * d)));
} else if (c <= 2.15e+45) {
tmp = a / (0.0 - d);
} else {
tmp = b / c;
}
return tmp;
}
function code(a, b, c, d) tmp = 0.0 if (c <= -1.9e+106) tmp = Float64(b / c); elseif (c <= -6.2e-127) tmp = Float64(b * Float64(c / fma(c, c, Float64(d * d)))); elseif (c <= 2.15e+45) tmp = Float64(a / Float64(0.0 - d)); else tmp = Float64(b / c); end return tmp end
code[a_, b_, c_, d_] := If[LessEqual[c, -1.9e+106], N[(b / c), $MachinePrecision], If[LessEqual[c, -6.2e-127], N[(b * N[(c / N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 2.15e+45], N[(a / N[(0.0 - d), $MachinePrecision]), $MachinePrecision], N[(b / c), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.9 \cdot 10^{+106}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{elif}\;c \leq -6.2 \cdot 10^{-127}:\\
\;\;\;\;b \cdot \frac{c}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\
\mathbf{elif}\;c \leq 2.15 \cdot 10^{+45}:\\
\;\;\;\;\frac{a}{0 - d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if c < -1.8999999999999999e106 or 2.1500000000000002e45 < c Initial program 49.7%
Taylor expanded in c around inf
/-lowering-/.f6477.7
Simplified77.7%
if -1.8999999999999999e106 < c < -6.2e-127Initial program 78.7%
Taylor expanded in b around inf
+-rgt-identityN/A
*-commutativeN/A
associate-/l*N/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f64N/A
+-commutativeN/A
unpow2N/A
accelerator-lowering-fma.f64N/A
unpow2N/A
*-lowering-*.f6453.2
Simplified53.2%
+-rgt-identityN/A
associate-*r/N/A
*-commutativeN/A
+-commutativeN/A
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f6455.1
Applied egg-rr55.1%
if -6.2e-127 < c < 2.1500000000000002e45Initial program 73.3%
Taylor expanded in c around 0
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
/-lowering-/.f64N/A
mul-1-negN/A
neg-sub0N/A
--lowering--.f6465.6
Simplified65.6%
neg-sub0N/A
neg-lowering-neg.f6465.6
Applied egg-rr65.6%
Final simplification68.1%
(FPCore (a b c d) :precision binary64 (if (<= c -95000.0) (/ b c) (if (<= c 2.05e+45) (/ a (- 0.0 d)) (/ b c))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -95000.0) {
tmp = b / c;
} else if (c <= 2.05e+45) {
tmp = a / (0.0 - d);
} 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) :: tmp
if (c <= (-95000.0d0)) then
tmp = b / c
else if (c <= 2.05d+45) then
tmp = a / (0.0d0 - d)
else
tmp = b / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -95000.0) {
tmp = b / c;
} else if (c <= 2.05e+45) {
tmp = a / (0.0 - d);
} else {
tmp = b / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -95000.0: tmp = b / c elif c <= 2.05e+45: tmp = a / (0.0 - d) else: tmp = b / c return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -95000.0) tmp = Float64(b / c); elseif (c <= 2.05e+45) tmp = Float64(a / Float64(0.0 - d)); else tmp = Float64(b / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -95000.0) tmp = b / c; elseif (c <= 2.05e+45) tmp = a / (0.0 - d); else tmp = b / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -95000.0], N[(b / c), $MachinePrecision], If[LessEqual[c, 2.05e+45], N[(a / N[(0.0 - d), $MachinePrecision]), $MachinePrecision], N[(b / c), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -95000:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{elif}\;c \leq 2.05 \cdot 10^{+45}:\\
\;\;\;\;\frac{a}{0 - d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if c < -95000 or 2.05000000000000006e45 < c Initial program 55.2%
Taylor expanded in c around inf
/-lowering-/.f6474.4
Simplified74.4%
if -95000 < c < 2.05000000000000006e45Initial program 73.7%
Taylor expanded in c around 0
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
/-lowering-/.f64N/A
mul-1-negN/A
neg-sub0N/A
--lowering--.f6460.3
Simplified60.3%
neg-sub0N/A
neg-lowering-neg.f6460.3
Applied egg-rr60.3%
Final simplification66.4%
(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 65.6%
Taylor expanded in c around inf
/-lowering-/.f6442.7
Simplified42.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 2024196
(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))))