
(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 c c (* d d)))
(t_1
(fma
(fma
(- (* (/ a (pow c 4.0)) d) (/ b (pow c 3.0)))
d
(/ (/ (- a) c) c))
d
(/ b c))))
(if (<= c -1.15e+138)
t_1
(if (<= c -2.5e-148)
(* (fma (/ (/ b t_0) a) c (/ (- d) t_0)) a)
(if (<= c 9e-146)
(/ (- (/ (* b c) d) a) d)
(if (<= c 1.05e+114)
(/ (fma (- b) c (* d a)) (- (fma 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(fma((((a / pow(c, 4.0)) * d) - (b / pow(c, 3.0))), d, ((-a / c) / c)), d, (b / c));
double tmp;
if (c <= -1.15e+138) {
tmp = t_1;
} else if (c <= -2.5e-148) {
tmp = fma(((b / t_0) / a), c, (-d / t_0)) * a;
} else if (c <= 9e-146) {
tmp = (((b * c) / d) - a) / d;
} else if (c <= 1.05e+114) {
tmp = fma(-b, c, (d * a)) / -fma(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 = fma(fma(Float64(Float64(Float64(a / (c ^ 4.0)) * d) - Float64(b / (c ^ 3.0))), d, Float64(Float64(Float64(-a) / c) / c)), d, Float64(b / c)) tmp = 0.0 if (c <= -1.15e+138) tmp = t_1; elseif (c <= -2.5e-148) tmp = Float64(fma(Float64(Float64(b / t_0) / a), c, Float64(Float64(-d) / t_0)) * a); elseif (c <= 9e-146) tmp = Float64(Float64(Float64(Float64(b * c) / d) - a) / d); elseif (c <= 1.05e+114) tmp = Float64(fma(Float64(-b), c, Float64(d * a)) / Float64(-fma(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[(N[(N[(N[(a / N[Power[c, 4.0], $MachinePrecision]), $MachinePrecision] * d), $MachinePrecision] - N[(b / N[Power[c, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * d + N[(N[((-a) / c), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] * d + N[(b / c), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -1.15e+138], t$95$1, If[LessEqual[c, -2.5e-148], N[(N[(N[(N[(b / t$95$0), $MachinePrecision] / a), $MachinePrecision] * c + N[((-d) / t$95$0), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision], If[LessEqual[c, 9e-146], N[(N[(N[(N[(b * c), $MachinePrecision] / d), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 1.05e+114], N[(N[((-b) * c + N[(d * a), $MachinePrecision]), $MachinePrecision] / (-N[(d * d + 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 := \mathsf{fma}\left(\mathsf{fma}\left(\frac{a}{{c}^{4}} \cdot d - \frac{b}{{c}^{3}}, d, \frac{\frac{-a}{c}}{c}\right), d, \frac{b}{c}\right)\\
\mathbf{if}\;c \leq -1.15 \cdot 10^{+138}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;c \leq -2.5 \cdot 10^{-148}:\\
\;\;\;\;\mathsf{fma}\left(\frac{\frac{b}{t\_0}}{a}, c, \frac{-d}{t\_0}\right) \cdot a\\
\mathbf{elif}\;c \leq 9 \cdot 10^{-146}:\\
\;\;\;\;\frac{\frac{b \cdot c}{d} - a}{d}\\
\mathbf{elif}\;c \leq 1.05 \cdot 10^{+114}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-b, c, d \cdot a\right)}{-\mathsf{fma}\left(d, d, c \cdot c\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if c < -1.15000000000000004e138 or 1.05e114 < c Initial program 32.9%
Taylor expanded in d around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites91.3%
if -1.15000000000000004e138 < c < -2.4999999999999999e-148Initial program 70.8%
Taylor expanded in a around inf
mul-1-negN/A
neg-sub0N/A
associate-+l-N/A
unsub-negN/A
mul-1-negN/A
+-commutativeN/A
neg-sub0N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites78.2%
if -2.4999999999999999e-148 < c < 9.0000000000000001e-146Initial program 68.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
lower-/.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6492.9
Applied rewrites92.9%
if 9.0000000000000001e-146 < c < 1.05e114Initial program 79.8%
lift-/.f64N/A
frac-2negN/A
lower-/.f64N/A
lift--.f64N/A
sub-negN/A
distribute-neg-inN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
remove-double-negN/A
lower-fma.f64N/A
lower-neg.f64N/A
lower-neg.f6479.8
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6479.9
Applied rewrites79.9%
Final simplification85.9%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (fma c c (* d d))) (t_1 (fma (/ c d) (/ b d) (/ (- a) d))))
(if (<= d -2.8e+53)
t_1
(if (<= d -1.3e-144)
(/ (fma (- b) c (* d a)) (- (fma d d (* c c))))
(if (<= d 3e-30)
(/ (- b (/ (* d a) c)) c)
(if (<= d 3.25e+124)
(* (fma (/ (/ b t_0) a) c (/ (- d) t_0)) a)
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 / d), (b / d), (-a / d));
double tmp;
if (d <= -2.8e+53) {
tmp = t_1;
} else if (d <= -1.3e-144) {
tmp = fma(-b, c, (d * a)) / -fma(d, d, (c * c));
} else if (d <= 3e-30) {
tmp = (b - ((d * a) / c)) / c;
} else if (d <= 3.25e+124) {
tmp = fma(((b / t_0) / a), c, (-d / t_0)) * a;
} else {
tmp = t_1;
}
return tmp;
}
function code(a, b, c, d) t_0 = fma(c, c, Float64(d * d)) t_1 = fma(Float64(c / d), Float64(b / d), Float64(Float64(-a) / d)) tmp = 0.0 if (d <= -2.8e+53) tmp = t_1; elseif (d <= -1.3e-144) tmp = Float64(fma(Float64(-b), c, Float64(d * a)) / Float64(-fma(d, d, Float64(c * c)))); elseif (d <= 3e-30) tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c); elseif (d <= 3.25e+124) tmp = Float64(fma(Float64(Float64(b / t_0) / a), c, Float64(Float64(-d) / t_0)) * a); 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 / d), $MachinePrecision] * N[(b / d), $MachinePrecision] + N[((-a) / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -2.8e+53], t$95$1, If[LessEqual[d, -1.3e-144], N[(N[((-b) * c + N[(d * a), $MachinePrecision]), $MachinePrecision] / (-N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision])), $MachinePrecision], If[LessEqual[d, 3e-30], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 3.25e+124], N[(N[(N[(N[(b / t$95$0), $MachinePrecision] / a), $MachinePrecision] * c + N[((-d) / t$95$0), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(c, c, d \cdot d\right)\\
t_1 := \mathsf{fma}\left(\frac{c}{d}, \frac{b}{d}, \frac{-a}{d}\right)\\
\mathbf{if}\;d \leq -2.8 \cdot 10^{+53}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d \leq -1.3 \cdot 10^{-144}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-b, c, d \cdot a\right)}{-\mathsf{fma}\left(d, d, c \cdot c\right)}\\
\mathbf{elif}\;d \leq 3 \cdot 10^{-30}:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\
\mathbf{elif}\;d \leq 3.25 \cdot 10^{+124}:\\
\;\;\;\;\mathsf{fma}\left(\frac{\frac{b}{t\_0}}{a}, c, \frac{-d}{t\_0}\right) \cdot a\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if d < -2.8e53 or 3.25000000000000004e124 < d Initial program 40.9%
Taylor expanded in c around inf
lower-/.f6422.0
Applied rewrites22.0%
Taylor expanded in c around 0
+-commutativeN/A
*-commutativeN/A
unpow2N/A
times-fracN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6483.8
Applied rewrites83.8%
if -2.8e53 < d < -1.3e-144Initial program 83.6%
lift-/.f64N/A
frac-2negN/A
lower-/.f64N/A
lift--.f64N/A
sub-negN/A
distribute-neg-inN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
remove-double-negN/A
lower-fma.f64N/A
lower-neg.f64N/A
lower-neg.f6483.6
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6483.6
Applied rewrites83.6%
if -1.3e-144 < d < 2.9999999999999999e-30Initial program 73.3%
Taylor expanded in c around inf
lower-/.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6488.7
Applied rewrites88.7%
if 2.9999999999999999e-30 < d < 3.25000000000000004e124Initial program 59.6%
Taylor expanded in a around inf
mul-1-negN/A
neg-sub0N/A
associate-+l-N/A
unsub-negN/A
mul-1-negN/A
+-commutativeN/A
neg-sub0N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites75.9%
Final simplification84.3%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- a) d)) (t_1 (- (* b c) (* d a))))
(if (<= d -6.8e+53)
t_0
(if (<= d -2.8e-60)
(/ t_1 (* d d))
(if (<= d -1.45e-149)
(/ t_1 (* c c))
(if (<= d 1.9e-114)
(/ b c)
(if (<= d 2.7e+124) (* (/ d (fma c c (* d d))) (- a)) t_0)))))))
double code(double a, double b, double c, double d) {
double t_0 = -a / d;
double t_1 = (b * c) - (d * a);
double tmp;
if (d <= -6.8e+53) {
tmp = t_0;
} else if (d <= -2.8e-60) {
tmp = t_1 / (d * d);
} else if (d <= -1.45e-149) {
tmp = t_1 / (c * c);
} else if (d <= 1.9e-114) {
tmp = b / c;
} else if (d <= 2.7e+124) {
tmp = (d / fma(c, c, (d * d))) * -a;
} else {
tmp = t_0;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(-a) / d) t_1 = Float64(Float64(b * c) - Float64(d * a)) tmp = 0.0 if (d <= -6.8e+53) tmp = t_0; elseif (d <= -2.8e-60) tmp = Float64(t_1 / Float64(d * d)); elseif (d <= -1.45e-149) tmp = Float64(t_1 / Float64(c * c)); elseif (d <= 1.9e-114) tmp = Float64(b / c); elseif (d <= 2.7e+124) tmp = Float64(Float64(d / fma(c, c, Float64(d * d))) * Float64(-a)); else tmp = t_0; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[((-a) / d), $MachinePrecision]}, Block[{t$95$1 = N[(N[(b * c), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -6.8e+53], t$95$0, If[LessEqual[d, -2.8e-60], N[(t$95$1 / N[(d * d), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -1.45e-149], N[(t$95$1 / N[(c * c), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.9e-114], N[(b / c), $MachinePrecision], If[LessEqual[d, 2.7e+124], N[(N[(d / N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * (-a)), $MachinePrecision], t$95$0]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-a}{d}\\
t_1 := b \cdot c - d \cdot a\\
\mathbf{if}\;d \leq -6.8 \cdot 10^{+53}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq -2.8 \cdot 10^{-60}:\\
\;\;\;\;\frac{t\_1}{d \cdot d}\\
\mathbf{elif}\;d \leq -1.45 \cdot 10^{-149}:\\
\;\;\;\;\frac{t\_1}{c \cdot c}\\
\mathbf{elif}\;d \leq 1.9 \cdot 10^{-114}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{elif}\;d \leq 2.7 \cdot 10^{+124}:\\
\;\;\;\;\frac{d}{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot \left(-a\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d < -6.79999999999999995e53 or 2.69999999999999978e124 < d Initial program 40.9%
Taylor expanded in c around 0
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6476.3
Applied rewrites76.3%
if -6.79999999999999995e53 < d < -2.8000000000000002e-60Initial program 78.0%
Taylor expanded in c around 0
unpow2N/A
lower-*.f6464.1
Applied rewrites64.1%
if -2.8000000000000002e-60 < d < -1.45e-149Initial program 91.1%
Taylor expanded in c around inf
unpow2N/A
lower-*.f6479.1
Applied rewrites79.1%
if -1.45e-149 < d < 1.8999999999999999e-114Initial program 74.0%
Taylor expanded in c around inf
lower-/.f6477.1
Applied rewrites77.1%
if 1.8999999999999999e-114 < d < 2.69999999999999978e124Initial program 62.5%
Taylor expanded in b around 0
associate-/l*N/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
unpow2N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6453.8
Applied rewrites53.8%
Final simplification70.9%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- b (/ (* d a) c)) c)))
(if (<= c -3.1e-35)
t_0
(if (<= c 9e-146)
(/ (- (/ (* b c) d) a) d)
(if (<= c 6.7e+137)
(/ (fma (- b) c (* d a)) (- (fma d d (* c c))))
t_0)))))
double code(double a, double b, double c, double d) {
double t_0 = (b - ((d * a) / c)) / c;
double tmp;
if (c <= -3.1e-35) {
tmp = t_0;
} else if (c <= 9e-146) {
tmp = (((b * c) / d) - a) / d;
} else if (c <= 6.7e+137) {
tmp = fma(-b, c, (d * a)) / -fma(d, d, (c * c));
} else {
tmp = t_0;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(b - Float64(Float64(d * a) / c)) / c) tmp = 0.0 if (c <= -3.1e-35) tmp = t_0; elseif (c <= 9e-146) tmp = Float64(Float64(Float64(Float64(b * c) / d) - a) / d); elseif (c <= 6.7e+137) tmp = Float64(fma(Float64(-b), c, Float64(d * a)) / Float64(-fma(d, d, Float64(c * c)))); else tmp = t_0; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]}, If[LessEqual[c, -3.1e-35], t$95$0, If[LessEqual[c, 9e-146], N[(N[(N[(N[(b * c), $MachinePrecision] / d), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 6.7e+137], N[(N[((-b) * c + N[(d * a), $MachinePrecision]), $MachinePrecision] / (-N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision])), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b - \frac{d \cdot a}{c}}{c}\\
\mathbf{if}\;c \leq -3.1 \cdot 10^{-35}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq 9 \cdot 10^{-146}:\\
\;\;\;\;\frac{\frac{b \cdot c}{d} - a}{d}\\
\mathbf{elif}\;c \leq 6.7 \cdot 10^{+137}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-b, c, d \cdot a\right)}{-\mathsf{fma}\left(d, d, c \cdot c\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if c < -3.10000000000000012e-35 or 6.6999999999999999e137 < c Initial program 45.4%
Taylor expanded in c around inf
lower-/.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6476.4
Applied rewrites76.4%
if -3.10000000000000012e-35 < c < 9.0000000000000001e-146Initial program 70.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
lower-/.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6487.9
Applied rewrites87.9%
if 9.0000000000000001e-146 < c < 6.6999999999999999e137Initial program 78.0%
lift-/.f64N/A
frac-2negN/A
lower-/.f64N/A
lift--.f64N/A
sub-negN/A
distribute-neg-inN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
remove-double-negN/A
lower-fma.f64N/A
lower-neg.f64N/A
lower-neg.f6478.0
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6478.0
Applied rewrites78.0%
Final simplification81.1%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- b (/ (* d a) c)) c)))
(if (<= c -3.1e-35)
t_0
(if (<= c 9e-146)
(/ (- (/ (* b c) d) a) d)
(if (<= c 6.7e+137) (/ (- (* b c) (* d a)) (+ (* c c) (* d d))) t_0)))))
double code(double a, double b, double c, double d) {
double t_0 = (b - ((d * a) / c)) / c;
double tmp;
if (c <= -3.1e-35) {
tmp = t_0;
} else if (c <= 9e-146) {
tmp = (((b * c) / d) - a) / d;
} else if (c <= 6.7e+137) {
tmp = ((b * c) - (d * a)) / ((c * c) + (d * d));
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: tmp
t_0 = (b - ((d * a) / c)) / c
if (c <= (-3.1d-35)) then
tmp = t_0
else if (c <= 9d-146) then
tmp = (((b * c) / d) - a) / d
else if (c <= 6.7d+137) then
tmp = ((b * c) - (d * a)) / ((c * c) + (d * d))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = (b - ((d * a) / c)) / c;
double tmp;
if (c <= -3.1e-35) {
tmp = t_0;
} else if (c <= 9e-146) {
tmp = (((b * c) / d) - a) / d;
} else if (c <= 6.7e+137) {
tmp = ((b * c) - (d * a)) / ((c * c) + (d * d));
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b, c, d): t_0 = (b - ((d * a) / c)) / c tmp = 0 if c <= -3.1e-35: tmp = t_0 elif c <= 9e-146: tmp = (((b * c) / d) - a) / d elif c <= 6.7e+137: tmp = ((b * c) - (d * a)) / ((c * c) + (d * d)) else: tmp = t_0 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(b - Float64(Float64(d * a) / c)) / c) tmp = 0.0 if (c <= -3.1e-35) tmp = t_0; elseif (c <= 9e-146) tmp = Float64(Float64(Float64(Float64(b * c) / d) - a) / d); elseif (c <= 6.7e+137) tmp = Float64(Float64(Float64(b * c) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d))); else tmp = t_0; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (b - ((d * a) / c)) / c; tmp = 0.0; if (c <= -3.1e-35) tmp = t_0; elseif (c <= 9e-146) tmp = (((b * c) / d) - a) / d; elseif (c <= 6.7e+137) tmp = ((b * c) - (d * a)) / ((c * c) + (d * d)); else tmp = t_0; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]}, If[LessEqual[c, -3.1e-35], t$95$0, If[LessEqual[c, 9e-146], N[(N[(N[(N[(b * c), $MachinePrecision] / d), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 6.7e+137], N[(N[(N[(b * c), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b - \frac{d \cdot a}{c}}{c}\\
\mathbf{if}\;c \leq -3.1 \cdot 10^{-35}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq 9 \cdot 10^{-146}:\\
\;\;\;\;\frac{\frac{b \cdot c}{d} - a}{d}\\
\mathbf{elif}\;c \leq 6.7 \cdot 10^{+137}:\\
\;\;\;\;\frac{b \cdot c - d \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if c < -3.10000000000000012e-35 or 6.6999999999999999e137 < c Initial program 45.4%
Taylor expanded in c around inf
lower-/.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6476.4
Applied rewrites76.4%
if -3.10000000000000012e-35 < c < 9.0000000000000001e-146Initial program 70.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
lower-/.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6487.9
Applied rewrites87.9%
if 9.0000000000000001e-146 < c < 6.6999999999999999e137Initial program 78.0%
Final simplification81.0%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- a) d)))
(if (<= d -4e-54)
t_0
(if (<= d -1.45e-149)
(/ (- (* b c) (* d a)) (* c c))
(if (<= d 1.9e-114)
(/ b c)
(if (<= d 2.7e+124) (* (/ d (fma c c (* d d))) (- a)) t_0))))))
double code(double a, double b, double c, double d) {
double t_0 = -a / d;
double tmp;
if (d <= -4e-54) {
tmp = t_0;
} else if (d <= -1.45e-149) {
tmp = ((b * c) - (d * a)) / (c * c);
} else if (d <= 1.9e-114) {
tmp = b / c;
} else if (d <= 2.7e+124) {
tmp = (d / fma(c, c, (d * d))) * -a;
} else {
tmp = t_0;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(-a) / d) tmp = 0.0 if (d <= -4e-54) tmp = t_0; elseif (d <= -1.45e-149) tmp = Float64(Float64(Float64(b * c) - Float64(d * a)) / Float64(c * c)); elseif (d <= 1.9e-114) tmp = Float64(b / c); elseif (d <= 2.7e+124) tmp = Float64(Float64(d / fma(c, c, Float64(d * d))) * Float64(-a)); else tmp = t_0; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[((-a) / d), $MachinePrecision]}, If[LessEqual[d, -4e-54], t$95$0, If[LessEqual[d, -1.45e-149], N[(N[(N[(b * c), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(c * c), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.9e-114], N[(b / c), $MachinePrecision], If[LessEqual[d, 2.7e+124], N[(N[(d / N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * (-a)), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-a}{d}\\
\mathbf{if}\;d \leq -4 \cdot 10^{-54}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq -1.45 \cdot 10^{-149}:\\
\;\;\;\;\frac{b \cdot c - d \cdot a}{c \cdot c}\\
\mathbf{elif}\;d \leq 1.9 \cdot 10^{-114}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{elif}\;d \leq 2.7 \cdot 10^{+124}:\\
\;\;\;\;\frac{d}{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot \left(-a\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d < -4.0000000000000001e-54 or 2.69999999999999978e124 < d Initial program 48.7%
Taylor expanded in c around 0
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6468.4
Applied rewrites68.4%
if -4.0000000000000001e-54 < d < -1.45e-149Initial program 91.9%
Taylor expanded in c around inf
unpow2N/A
lower-*.f6477.1
Applied rewrites77.1%
if -1.45e-149 < d < 1.8999999999999999e-114Initial program 74.0%
Taylor expanded in c around inf
lower-/.f6477.1
Applied rewrites77.1%
if 1.8999999999999999e-114 < d < 2.69999999999999978e124Initial program 62.5%
Taylor expanded in b around 0
associate-/l*N/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
unpow2N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6453.8
Applied rewrites53.8%
Final simplification68.5%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- a) d)) (t_1 (* (/ d (fma c c (* d d))) (- a))))
(if (<= d -1.3e+147)
t_0
(if (<= d -8.6e-98)
t_1
(if (<= d 1.9e-114) (/ b c) (if (<= d 2.7e+124) t_1 t_0))))))
double code(double a, double b, double c, double d) {
double t_0 = -a / d;
double t_1 = (d / fma(c, c, (d * d))) * -a;
double tmp;
if (d <= -1.3e+147) {
tmp = t_0;
} else if (d <= -8.6e-98) {
tmp = t_1;
} else if (d <= 1.9e-114) {
tmp = b / c;
} else if (d <= 2.7e+124) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(-a) / d) t_1 = Float64(Float64(d / fma(c, c, Float64(d * d))) * Float64(-a)) tmp = 0.0 if (d <= -1.3e+147) tmp = t_0; elseif (d <= -8.6e-98) tmp = t_1; elseif (d <= 1.9e-114) tmp = Float64(b / c); elseif (d <= 2.7e+124) tmp = t_1; else tmp = t_0; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[((-a) / d), $MachinePrecision]}, Block[{t$95$1 = N[(N[(d / N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * (-a)), $MachinePrecision]}, If[LessEqual[d, -1.3e+147], t$95$0, If[LessEqual[d, -8.6e-98], t$95$1, If[LessEqual[d, 1.9e-114], N[(b / c), $MachinePrecision], If[LessEqual[d, 2.7e+124], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-a}{d}\\
t_1 := \frac{d}{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot \left(-a\right)\\
\mathbf{if}\;d \leq -1.3 \cdot 10^{+147}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq -8.6 \cdot 10^{-98}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d \leq 1.9 \cdot 10^{-114}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{elif}\;d \leq 2.7 \cdot 10^{+124}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d < -1.2999999999999999e147 or 2.69999999999999978e124 < d Initial program 37.0%
Taylor expanded in c around 0
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6481.4
Applied rewrites81.4%
if -1.2999999999999999e147 < d < -8.59999999999999977e-98 or 1.8999999999999999e-114 < d < 2.69999999999999978e124Initial program 66.5%
Taylor expanded in b around 0
associate-/l*N/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
unpow2N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6456.7
Applied rewrites56.7%
if -8.59999999999999977e-98 < d < 1.8999999999999999e-114Initial program 77.3%
Taylor expanded in c around inf
lower-/.f6472.4
Applied rewrites72.4%
Final simplification68.2%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (* (/ c (fma c c (* d d))) b)))
(if (<= c -1e+141)
(/ b c)
(if (<= c -2.7e-35)
t_0
(if (<= c 1.3e-114) (/ (- a) d) (if (<= c 1.02e+114) t_0 (/ b c)))))))
double code(double a, double b, double c, double d) {
double t_0 = (c / fma(c, c, (d * d))) * b;
double tmp;
if (c <= -1e+141) {
tmp = b / c;
} else if (c <= -2.7e-35) {
tmp = t_0;
} else if (c <= 1.3e-114) {
tmp = -a / d;
} else if (c <= 1.02e+114) {
tmp = t_0;
} else {
tmp = b / c;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(c / fma(c, c, Float64(d * d))) * b) tmp = 0.0 if (c <= -1e+141) tmp = Float64(b / c); elseif (c <= -2.7e-35) tmp = t_0; elseif (c <= 1.3e-114) tmp = Float64(Float64(-a) / d); elseif (c <= 1.02e+114) tmp = t_0; else tmp = Float64(b / c); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c / N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision]}, If[LessEqual[c, -1e+141], N[(b / c), $MachinePrecision], If[LessEqual[c, -2.7e-35], t$95$0, If[LessEqual[c, 1.3e-114], N[((-a) / d), $MachinePrecision], If[LessEqual[c, 1.02e+114], t$95$0, N[(b / c), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c}{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot b\\
\mathbf{if}\;c \leq -1 \cdot 10^{+141}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{elif}\;c \leq -2.7 \cdot 10^{-35}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq 1.3 \cdot 10^{-114}:\\
\;\;\;\;\frac{-a}{d}\\
\mathbf{elif}\;c \leq 1.02 \cdot 10^{+114}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if c < -1.00000000000000002e141 or 1.01999999999999999e114 < c Initial program 33.9%
Taylor expanded in c around inf
lower-/.f6481.7
Applied rewrites81.7%
if -1.00000000000000002e141 < c < -2.6999999999999997e-35 or 1.30000000000000007e-114 < c < 1.01999999999999999e114Initial program 73.2%
Taylor expanded in c around inf
lower-/.f6436.1
Applied rewrites36.1%
Taylor expanded in b around inf
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6455.4
Applied rewrites55.4%
if -2.6999999999999997e-35 < c < 1.30000000000000007e-114Initial program 71.8%
Taylor expanded in c around 0
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6467.4
Applied rewrites67.4%
Final simplification67.2%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- a) d)))
(if (<= d -6.8e+53)
t_0
(if (<= d -3.1e-60)
(/ (- (* b c) (* d a)) (* d d))
(if (<= d 2.1e+122) (/ (- b (/ (* d a) c)) c) t_0)))))
double code(double a, double b, double c, double d) {
double t_0 = -a / d;
double tmp;
if (d <= -6.8e+53) {
tmp = t_0;
} else if (d <= -3.1e-60) {
tmp = ((b * c) - (d * a)) / (d * d);
} else if (d <= 2.1e+122) {
tmp = (b - ((d * a) / c)) / c;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: tmp
t_0 = -a / d
if (d <= (-6.8d+53)) then
tmp = t_0
else if (d <= (-3.1d-60)) then
tmp = ((b * c) - (d * a)) / (d * d)
else if (d <= 2.1d+122) then
tmp = (b - ((d * a) / c)) / c
else
tmp = t_0
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = -a / d;
double tmp;
if (d <= -6.8e+53) {
tmp = t_0;
} else if (d <= -3.1e-60) {
tmp = ((b * c) - (d * a)) / (d * d);
} else if (d <= 2.1e+122) {
tmp = (b - ((d * a) / c)) / c;
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b, c, d): t_0 = -a / d tmp = 0 if d <= -6.8e+53: tmp = t_0 elif d <= -3.1e-60: tmp = ((b * c) - (d * a)) / (d * d) elif d <= 2.1e+122: tmp = (b - ((d * a) / c)) / c else: tmp = t_0 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(-a) / d) tmp = 0.0 if (d <= -6.8e+53) tmp = t_0; elseif (d <= -3.1e-60) tmp = Float64(Float64(Float64(b * c) - Float64(d * a)) / Float64(d * d)); elseif (d <= 2.1e+122) tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c); else tmp = t_0; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = -a / d; tmp = 0.0; if (d <= -6.8e+53) tmp = t_0; elseif (d <= -3.1e-60) tmp = ((b * c) - (d * a)) / (d * d); elseif (d <= 2.1e+122) tmp = (b - ((d * a) / c)) / c; else tmp = t_0; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[((-a) / d), $MachinePrecision]}, If[LessEqual[d, -6.8e+53], t$95$0, If[LessEqual[d, -3.1e-60], N[(N[(N[(b * c), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(d * d), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.1e+122], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-a}{d}\\
\mathbf{if}\;d \leq -6.8 \cdot 10^{+53}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq -3.1 \cdot 10^{-60}:\\
\;\;\;\;\frac{b \cdot c - d \cdot a}{d \cdot d}\\
\mathbf{elif}\;d \leq 2.1 \cdot 10^{+122}:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d < -6.79999999999999995e53 or 2.10000000000000016e122 < d Initial program 40.5%
Taylor expanded in c around 0
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6475.5
Applied rewrites75.5%
if -6.79999999999999995e53 < d < -3.09999999999999988e-60Initial program 78.0%
Taylor expanded in c around 0
unpow2N/A
lower-*.f6464.1
Applied rewrites64.1%
if -3.09999999999999988e-60 < d < 2.10000000000000016e122Initial program 72.9%
Taylor expanded in c around inf
lower-/.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6477.7
Applied rewrites77.7%
Final simplification75.5%
(FPCore (a b c d) :precision binary64 (let* ((t_0 (/ (- b (/ (* d a) c)) c))) (if (<= c -3.1e-35) t_0 (if (<= c 5e-52) (/ (- (/ (* b c) d) a) d) t_0))))
double code(double a, double b, double c, double d) {
double t_0 = (b - ((d * a) / c)) / c;
double tmp;
if (c <= -3.1e-35) {
tmp = t_0;
} else if (c <= 5e-52) {
tmp = (((b * c) / d) - a) / d;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: tmp
t_0 = (b - ((d * a) / c)) / c
if (c <= (-3.1d-35)) then
tmp = t_0
else if (c <= 5d-52) then
tmp = (((b * c) / d) - a) / d
else
tmp = t_0
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = (b - ((d * a) / c)) / c;
double tmp;
if (c <= -3.1e-35) {
tmp = t_0;
} else if (c <= 5e-52) {
tmp = (((b * c) / d) - a) / d;
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b, c, d): t_0 = (b - ((d * a) / c)) / c tmp = 0 if c <= -3.1e-35: tmp = t_0 elif c <= 5e-52: tmp = (((b * c) / d) - a) / d else: tmp = t_0 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(b - Float64(Float64(d * a) / c)) / c) tmp = 0.0 if (c <= -3.1e-35) tmp = t_0; elseif (c <= 5e-52) tmp = Float64(Float64(Float64(Float64(b * c) / d) - a) / d); else tmp = t_0; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (b - ((d * a) / c)) / c; tmp = 0.0; if (c <= -3.1e-35) tmp = t_0; elseif (c <= 5e-52) tmp = (((b * c) / d) - a) / d; else tmp = t_0; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]}, If[LessEqual[c, -3.1e-35], t$95$0, If[LessEqual[c, 5e-52], N[(N[(N[(N[(b * c), $MachinePrecision] / d), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b - \frac{d \cdot a}{c}}{c}\\
\mathbf{if}\;c \leq -3.1 \cdot 10^{-35}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq 5 \cdot 10^{-52}:\\
\;\;\;\;\frac{\frac{b \cdot c}{d} - a}{d}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if c < -3.10000000000000012e-35 or 5e-52 < c Initial program 52.5%
Taylor expanded in c around inf
lower-/.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6473.1
Applied rewrites73.1%
if -3.10000000000000012e-35 < c < 5e-52Initial program 73.2%
Taylor expanded in c around 0
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
unpow2N/A
associate-/r*N/A
div-subN/A
lower-/.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6483.9
Applied rewrites83.9%
Final simplification78.2%
(FPCore (a b c d) :precision binary64 (let* ((t_0 (/ (- a) d))) (if (<= d -1.8e-39) t_0 (if (<= d 3.1e-30) (/ b c) t_0))))
double code(double a, double b, double c, double d) {
double t_0 = -a / d;
double tmp;
if (d <= -1.8e-39) {
tmp = t_0;
} else if (d <= 3.1e-30) {
tmp = b / c;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: tmp
t_0 = -a / d
if (d <= (-1.8d-39)) then
tmp = t_0
else if (d <= 3.1d-30) then
tmp = b / c
else
tmp = t_0
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = -a / d;
double tmp;
if (d <= -1.8e-39) {
tmp = t_0;
} else if (d <= 3.1e-30) {
tmp = b / c;
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b, c, d): t_0 = -a / d tmp = 0 if d <= -1.8e-39: tmp = t_0 elif d <= 3.1e-30: tmp = b / c else: tmp = t_0 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(-a) / d) tmp = 0.0 if (d <= -1.8e-39) tmp = t_0; elseif (d <= 3.1e-30) tmp = Float64(b / c); else tmp = t_0; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = -a / d; tmp = 0.0; if (d <= -1.8e-39) tmp = t_0; elseif (d <= 3.1e-30) tmp = b / c; else tmp = t_0; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[((-a) / d), $MachinePrecision]}, If[LessEqual[d, -1.8e-39], t$95$0, If[LessEqual[d, 3.1e-30], N[(b / c), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-a}{d}\\
\mathbf{if}\;d \leq -1.8 \cdot 10^{-39}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 3.1 \cdot 10^{-30}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d < -1.8e-39 or 3.09999999999999991e-30 < d Initial program 51.4%
Taylor expanded in c around 0
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6462.0
Applied rewrites62.0%
if -1.8e-39 < d < 3.09999999999999991e-30Initial program 75.8%
Taylor expanded in c around inf
lower-/.f6463.9
Applied rewrites63.9%
(FPCore (a b c d) :precision binary64 (/ b c))
double code(double a, double b, double c, double d) {
return b / c;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = b / c
end function
public static double code(double a, double b, double c, double d) {
return b / c;
}
def code(a, b, c, d): return b / c
function code(a, b, c, d) return Float64(b / c) end
function tmp = code(a, b, c, d) tmp = b / c; end
code[a_, b_, c_, d_] := N[(b / c), $MachinePrecision]
\begin{array}{l}
\\
\frac{b}{c}
\end{array}
Initial program 62.2%
Taylor expanded in c around inf
lower-/.f6442.4
Applied rewrites42.4%
(FPCore (a b c d) :precision binary64 (if (< (fabs d) (fabs c)) (/ (- b (* a (/ d c))) (+ c (* d (/ d c)))) (/ (+ (- a) (* b (/ c d))) (+ d (* c (/ c d))))))
double code(double a, double b, double c, double d) {
double tmp;
if (fabs(d) < fabs(c)) {
tmp = (b - (a * (d / c))) / (c + (d * (d / c)));
} else {
tmp = (-a + (b * (c / d))) / (d + (c * (c / d)));
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (abs(d) < abs(c)) then
tmp = (b - (a * (d / c))) / (c + (d * (d / c)))
else
tmp = (-a + (b * (c / d))) / (d + (c * (c / d)))
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (Math.abs(d) < Math.abs(c)) {
tmp = (b - (a * (d / c))) / (c + (d * (d / c)));
} else {
tmp = (-a + (b * (c / d))) / (d + (c * (c / d)));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if math.fabs(d) < math.fabs(c): tmp = (b - (a * (d / c))) / (c + (d * (d / c))) else: tmp = (-a + (b * (c / d))) / (d + (c * (c / d))) return tmp
function code(a, b, c, d) tmp = 0.0 if (abs(d) < abs(c)) tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / Float64(c + Float64(d * Float64(d / c)))); else tmp = Float64(Float64(Float64(-a) + Float64(b * Float64(c / d))) / Float64(d + Float64(c * Float64(c / d)))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (abs(d) < abs(c)) tmp = (b - (a * (d / c))) / (c + (d * (d / c))); else tmp = (-a + (b * (c / d))) / (d + (c * (c / d))); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Less[N[Abs[d], $MachinePrecision], N[Abs[c], $MachinePrecision]], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(c + N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[((-a) + N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(d + N[(c * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left|d\right| < \left|c\right|:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c + d \cdot \frac{d}{c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-a\right) + b \cdot \frac{c}{d}}{d + c \cdot \frac{c}{d}}\\
\end{array}
\end{array}
herbie shell --seed 2024249
(FPCore (a b c d)
:name "Complex division, imag part"
:precision binary64
:alt
(! :herbie-platform default (if (< (fabs d) (fabs c)) (/ (- b (* a (/ d c))) (+ c (* d (/ d c)))) (/ (+ (- a) (* b (/ c d))) (+ d (* c (/ c d))))))
(/ (- (* b c) (* a d)) (+ (* c c) (* d d))))