
(FPCore (a b c d) :precision binary64 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))))
double code(double a, double b, double c, double d) {
return ((a * c) + (b * 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 = ((a * c) + (b * d)) / ((c * c) + (d * d))
end function
public static double code(double a, double b, double c, double d) {
return ((a * c) + (b * d)) / ((c * c) + (d * d));
}
def code(a, b, c, d): return ((a * c) + (b * d)) / ((c * c) + (d * d))
function code(a, b, c, d) return Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d))) end
function tmp = code(a, b, c, d) tmp = ((a * c) + (b * d)) / ((c * c) + (d * d)); end
code[a_, b_, c_, d_] := N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{a \cdot c + b \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 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))))
double code(double a, double b, double c, double d) {
return ((a * c) + (b * 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 = ((a * c) + (b * d)) / ((c * c) + (d * d))
end function
public static double code(double a, double b, double c, double d) {
return ((a * c) + (b * d)) / ((c * c) + (d * d));
}
def code(a, b, c, d): return ((a * c) + (b * d)) / ((c * c) + (d * d))
function code(a, b, c, d) return Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d))) end
function tmp = code(a, b, c, d) tmp = ((a * c) + (b * d)) / ((c * c) + (d * d)); end
code[a_, b_, c_, d_] := N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}
\end{array}
(FPCore (a b c d) :precision binary64 (if (<= (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))) 2e+223) (/ (/ (fma c a (* b d)) (hypot c d)) (hypot c d)) (/ (+ b (/ a (/ d c))) d)))
double code(double a, double b, double c, double d) {
double tmp;
if ((((a * c) + (b * d)) / ((c * c) + (d * d))) <= 2e+223) {
tmp = (fma(c, a, (b * d)) / hypot(c, d)) / hypot(c, d);
} else {
tmp = (b + (a / (d / c))) / d;
}
return tmp;
}
function code(a, b, c, d) tmp = 0.0 if (Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d))) <= 2e+223) tmp = Float64(Float64(fma(c, a, Float64(b * d)) / hypot(c, d)) / hypot(c, d)); else tmp = Float64(Float64(b + Float64(a / Float64(d / c))) / d); end return tmp end
code[a_, b_, c_, d_] := If[LessEqual[N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2e+223], N[(N[(N[(c * a + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision], N[(N[(b + N[(a / N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \leq 2 \cdot 10^{+223}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(c, a, b \cdot d\right)}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{b + \frac{a}{\frac{d}{c}}}{d}\\
\end{array}
\end{array}
if (/.f64 (+.f64 (*.f64 a c) (*.f64 b d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 2.00000000000000009e223Initial program 79.9%
*-un-lft-identity79.9%
add-sqr-sqrt79.9%
times-frac79.8%
hypot-define79.8%
fma-define79.8%
hypot-define96.1%
Applied egg-rr96.1%
associate-*l/96.3%
*-un-lft-identity96.3%
fma-undefine96.3%
*-commutative96.3%
*-commutative96.3%
fma-define96.3%
Applied egg-rr96.3%
if 2.00000000000000009e223 < (/.f64 (+.f64 (*.f64 a c) (*.f64 b d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 17.1%
Taylor expanded in d around inf 60.0%
*-commutative60.0%
*-un-lft-identity60.0%
times-frac67.4%
Applied egg-rr67.4%
clear-num67.3%
frac-times68.9%
*-un-lft-identity68.9%
associate-/r/68.9%
clear-num68.9%
Applied egg-rr68.9%
Final simplification89.0%
(FPCore (a b c d)
:precision binary64
(if (<= d -9e+63)
(/ (+ b (- (* a (/ c d)) (* b (pow (/ c d) 2.0)))) d)
(if (<= d -1.15e-114)
(/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))
(if (<= d 1850000000000.0)
(/ (fma b (/ 1.0 (/ c d)) a) c)
(/ (+ b (* c (/ a d))) (hypot c d))))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -9e+63) {
tmp = (b + ((a * (c / d)) - (b * pow((c / d), 2.0)))) / d;
} else if (d <= -1.15e-114) {
tmp = ((a * c) + (b * d)) / ((c * c) + (d * d));
} else if (d <= 1850000000000.0) {
tmp = fma(b, (1.0 / (c / d)), a) / c;
} else {
tmp = (b + (c * (a / d))) / hypot(c, d);
}
return tmp;
}
function code(a, b, c, d) tmp = 0.0 if (d <= -9e+63) tmp = Float64(Float64(b + Float64(Float64(a * Float64(c / d)) - Float64(b * (Float64(c / d) ^ 2.0)))) / d); elseif (d <= -1.15e-114) tmp = Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d))); elseif (d <= 1850000000000.0) tmp = Float64(fma(b, Float64(1.0 / Float64(c / d)), a) / c); else tmp = Float64(Float64(b + Float64(c * Float64(a / d))) / hypot(c, d)); end return tmp end
code[a_, b_, c_, d_] := If[LessEqual[d, -9e+63], N[(N[(b + N[(N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision] - N[(b * N[Power[N[(c / d), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, -1.15e-114], N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1850000000000.0], N[(N[(b * N[(1.0 / N[(c / d), $MachinePrecision]), $MachinePrecision] + a), $MachinePrecision] / c), $MachinePrecision], N[(N[(b + N[(c * N[(a / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -9 \cdot 10^{+63}:\\
\;\;\;\;\frac{b + \left(a \cdot \frac{c}{d} - b \cdot {\left(\frac{c}{d}\right)}^{2}\right)}{d}\\
\mathbf{elif}\;d \leq -1.15 \cdot 10^{-114}:\\
\;\;\;\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;d \leq 1850000000000:\\
\;\;\;\;\frac{\mathsf{fma}\left(b, \frac{1}{\frac{c}{d}}, a\right)}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b + c \cdot \frac{a}{d}}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\end{array}
if d < -9.00000000000000034e63Initial program 36.9%
*-un-lft-identity36.9%
add-sqr-sqrt36.9%
times-frac36.9%
hypot-define36.9%
fma-define36.9%
hypot-define54.0%
Applied egg-rr54.0%
add-sqr-sqrt53.9%
pow253.9%
inv-pow53.9%
sqrt-pow153.9%
metadata-eval53.9%
Applied egg-rr53.9%
Taylor expanded in d around inf 65.0%
+-commutative65.0%
associate-/l*65.0%
*-commutative65.0%
mul-1-neg65.0%
unsub-neg65.0%
*-commutative65.0%
associate-/l*68.6%
unpow268.6%
unpow268.6%
times-frac83.0%
unpow283.0%
Simplified83.0%
if -9.00000000000000034e63 < d < -1.15e-114Initial program 81.3%
if -1.15e-114 < d < 1.85e12Initial program 75.7%
Taylor expanded in c around inf 89.0%
+-commutative89.0%
associate-/l*89.1%
fma-define89.1%
Simplified89.1%
clear-num89.2%
inv-pow89.2%
Applied egg-rr89.2%
unpow-189.2%
Simplified89.2%
if 1.85e12 < d Initial program 54.1%
*-un-lft-identity54.1%
add-sqr-sqrt54.1%
times-frac54.1%
hypot-define54.1%
fma-define54.1%
hypot-define75.1%
Applied egg-rr75.1%
associate-*l/75.1%
*-un-lft-identity75.1%
fma-undefine75.1%
*-commutative75.1%
*-commutative75.1%
fma-define75.1%
Applied egg-rr75.1%
Taylor expanded in c around 0 82.4%
*-commutative78.9%
*-un-lft-identity78.9%
times-frac86.0%
Applied egg-rr87.8%
Final simplification86.4%
(FPCore (a b c d)
:precision binary64
(if (<= d -8.2e+63)
(/ (+ b (* a (/ c d))) d)
(if (<= d -3e-113)
(/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))
(if (<= d 10000000000000.0)
(/ (fma b (/ 1.0 (/ c d)) a) c)
(/ (+ b (* c (/ a d))) (hypot c d))))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -8.2e+63) {
tmp = (b + (a * (c / d))) / d;
} else if (d <= -3e-113) {
tmp = ((a * c) + (b * d)) / ((c * c) + (d * d));
} else if (d <= 10000000000000.0) {
tmp = fma(b, (1.0 / (c / d)), a) / c;
} else {
tmp = (b + (c * (a / d))) / hypot(c, d);
}
return tmp;
}
function code(a, b, c, d) tmp = 0.0 if (d <= -8.2e+63) tmp = Float64(Float64(b + Float64(a * Float64(c / d))) / d); elseif (d <= -3e-113) tmp = Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d))); elseif (d <= 10000000000000.0) tmp = Float64(fma(b, Float64(1.0 / Float64(c / d)), a) / c); else tmp = Float64(Float64(b + Float64(c * Float64(a / d))) / hypot(c, d)); end return tmp end
code[a_, b_, c_, d_] := If[LessEqual[d, -8.2e+63], N[(N[(b + N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, -3e-113], N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 10000000000000.0], N[(N[(b * N[(1.0 / N[(c / d), $MachinePrecision]), $MachinePrecision] + a), $MachinePrecision] / c), $MachinePrecision], N[(N[(b + N[(c * N[(a / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -8.2 \cdot 10^{+63}:\\
\;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d}\\
\mathbf{elif}\;d \leq -3 \cdot 10^{-113}:\\
\;\;\;\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;d \leq 10000000000000:\\
\;\;\;\;\frac{\mathsf{fma}\left(b, \frac{1}{\frac{c}{d}}, a\right)}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b + c \cdot \frac{a}{d}}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\end{array}
if d < -8.19999999999999985e63Initial program 36.9%
Taylor expanded in d around inf 79.3%
associate-/l*82.8%
Simplified82.8%
if -8.19999999999999985e63 < d < -3.0000000000000001e-113Initial program 81.3%
if -3.0000000000000001e-113 < d < 1e13Initial program 75.7%
Taylor expanded in c around inf 89.0%
+-commutative89.0%
associate-/l*89.1%
fma-define89.1%
Simplified89.1%
clear-num89.2%
inv-pow89.2%
Applied egg-rr89.2%
unpow-189.2%
Simplified89.2%
if 1e13 < d Initial program 54.1%
*-un-lft-identity54.1%
add-sqr-sqrt54.1%
times-frac54.1%
hypot-define54.1%
fma-define54.1%
hypot-define75.1%
Applied egg-rr75.1%
associate-*l/75.1%
*-un-lft-identity75.1%
fma-undefine75.1%
*-commutative75.1%
*-commutative75.1%
fma-define75.1%
Applied egg-rr75.1%
Taylor expanded in c around 0 82.4%
*-commutative78.9%
*-un-lft-identity78.9%
times-frac86.0%
Applied egg-rr87.8%
Final simplification86.4%
(FPCore (a b c d)
:precision binary64
(if (<= d -7.2e+63)
(/ (+ b (* a (/ c d))) d)
(if (<= d -2.5e-118)
(/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))
(if (<= d 2.5e+14)
(/ (fma b (/ 1.0 (/ c d)) a) c)
(/ (+ b (* c (/ a d))) d)))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -7.2e+63) {
tmp = (b + (a * (c / d))) / d;
} else if (d <= -2.5e-118) {
tmp = ((a * c) + (b * d)) / ((c * c) + (d * d));
} else if (d <= 2.5e+14) {
tmp = fma(b, (1.0 / (c / d)), a) / c;
} else {
tmp = (b + (c * (a / d))) / d;
}
return tmp;
}
function code(a, b, c, d) tmp = 0.0 if (d <= -7.2e+63) tmp = Float64(Float64(b + Float64(a * Float64(c / d))) / d); elseif (d <= -2.5e-118) tmp = Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d))); elseif (d <= 2.5e+14) tmp = Float64(fma(b, Float64(1.0 / Float64(c / d)), a) / c); else tmp = Float64(Float64(b + Float64(c * Float64(a / d))) / d); end return tmp end
code[a_, b_, c_, d_] := If[LessEqual[d, -7.2e+63], N[(N[(b + N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, -2.5e-118], N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.5e+14], N[(N[(b * N[(1.0 / N[(c / d), $MachinePrecision]), $MachinePrecision] + a), $MachinePrecision] / c), $MachinePrecision], N[(N[(b + N[(c * N[(a / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -7.2 \cdot 10^{+63}:\\
\;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d}\\
\mathbf{elif}\;d \leq -2.5 \cdot 10^{-118}:\\
\;\;\;\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;d \leq 2.5 \cdot 10^{+14}:\\
\;\;\;\;\frac{\mathsf{fma}\left(b, \frac{1}{\frac{c}{d}}, a\right)}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b + c \cdot \frac{a}{d}}{d}\\
\end{array}
\end{array}
if d < -7.19999999999999998e63Initial program 36.9%
Taylor expanded in d around inf 79.3%
associate-/l*82.8%
Simplified82.8%
if -7.19999999999999998e63 < d < -2.50000000000000007e-118Initial program 81.3%
if -2.50000000000000007e-118 < d < 2.5e14Initial program 75.7%
Taylor expanded in c around inf 89.0%
+-commutative89.0%
associate-/l*89.1%
fma-define89.1%
Simplified89.1%
clear-num89.2%
inv-pow89.2%
Applied egg-rr89.2%
unpow-189.2%
Simplified89.2%
if 2.5e14 < d Initial program 54.1%
Taylor expanded in d around inf 78.9%
*-commutative78.9%
*-un-lft-identity78.9%
times-frac86.0%
Applied egg-rr86.0%
Taylor expanded in c around 0 86.0%
(FPCore (a b c d)
:precision binary64
(if (<= d -1.62e+63)
(/ (+ b (* a (/ c d))) d)
(if (<= d -5e-119)
(/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))
(if (<= d 7000000000000.0)
(/ (+ a (* b (/ d c))) c)
(/ (+ b (* c (/ a d))) d)))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -1.62e+63) {
tmp = (b + (a * (c / d))) / d;
} else if (d <= -5e-119) {
tmp = ((a * c) + (b * d)) / ((c * c) + (d * d));
} else if (d <= 7000000000000.0) {
tmp = (a + (b * (d / c))) / c;
} else {
tmp = (b + (c * (a / d))) / d;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (d <= (-1.62d+63)) then
tmp = (b + (a * (c / d))) / d
else if (d <= (-5d-119)) then
tmp = ((a * c) + (b * d)) / ((c * c) + (d * d))
else if (d <= 7000000000000.0d0) then
tmp = (a + (b * (d / c))) / c
else
tmp = (b + (c * (a / d))) / d
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (d <= -1.62e+63) {
tmp = (b + (a * (c / d))) / d;
} else if (d <= -5e-119) {
tmp = ((a * c) + (b * d)) / ((c * c) + (d * d));
} else if (d <= 7000000000000.0) {
tmp = (a + (b * (d / c))) / c;
} else {
tmp = (b + (c * (a / d))) / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -1.62e+63: tmp = (b + (a * (c / d))) / d elif d <= -5e-119: tmp = ((a * c) + (b * d)) / ((c * c) + (d * d)) elif d <= 7000000000000.0: tmp = (a + (b * (d / c))) / c else: tmp = (b + (c * (a / d))) / d return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -1.62e+63) tmp = Float64(Float64(b + Float64(a * Float64(c / d))) / d); elseif (d <= -5e-119) tmp = Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d))); elseif (d <= 7000000000000.0) tmp = Float64(Float64(a + Float64(b * Float64(d / c))) / c); else tmp = Float64(Float64(b + Float64(c * Float64(a / d))) / d); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= -1.62e+63) tmp = (b + (a * (c / d))) / d; elseif (d <= -5e-119) tmp = ((a * c) + (b * d)) / ((c * c) + (d * d)); elseif (d <= 7000000000000.0) tmp = (a + (b * (d / c))) / c; else tmp = (b + (c * (a / d))) / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -1.62e+63], N[(N[(b + N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, -5e-119], N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 7000000000000.0], N[(N[(a + N[(b * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], N[(N[(b + N[(c * N[(a / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.62 \cdot 10^{+63}:\\
\;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d}\\
\mathbf{elif}\;d \leq -5 \cdot 10^{-119}:\\
\;\;\;\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;d \leq 7000000000000:\\
\;\;\;\;\frac{a + b \cdot \frac{d}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b + c \cdot \frac{a}{d}}{d}\\
\end{array}
\end{array}
if d < -1.62e63Initial program 36.9%
Taylor expanded in d around inf 79.3%
associate-/l*82.8%
Simplified82.8%
if -1.62e63 < d < -4.99999999999999993e-119Initial program 81.3%
if -4.99999999999999993e-119 < d < 7e12Initial program 75.7%
Taylor expanded in c around inf 89.0%
+-commutative89.0%
associate-/l*89.1%
fma-define89.1%
Simplified89.1%
fma-undefine89.1%
Applied egg-rr89.1%
if 7e12 < d Initial program 54.1%
Taylor expanded in d around inf 78.9%
*-commutative78.9%
*-un-lft-identity78.9%
times-frac86.0%
Applied egg-rr86.0%
Taylor expanded in c around 0 86.0%
Final simplification86.0%
(FPCore (a b c d)
:precision binary64
(if (<= d -6e-75)
(/ b d)
(if (<= d 8.8e-179)
(/ a c)
(if (<= d 2.1e-14) (/ (* b (/ d c)) c) (/ b d)))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -6e-75) {
tmp = b / d;
} else if (d <= 8.8e-179) {
tmp = a / c;
} else if (d <= 2.1e-14) {
tmp = (b * (d / c)) / c;
} else {
tmp = b / d;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (d <= (-6d-75)) then
tmp = b / d
else if (d <= 8.8d-179) then
tmp = a / c
else if (d <= 2.1d-14) then
tmp = (b * (d / c)) / c
else
tmp = b / d
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (d <= -6e-75) {
tmp = b / d;
} else if (d <= 8.8e-179) {
tmp = a / c;
} else if (d <= 2.1e-14) {
tmp = (b * (d / c)) / c;
} else {
tmp = b / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -6e-75: tmp = b / d elif d <= 8.8e-179: tmp = a / c elif d <= 2.1e-14: tmp = (b * (d / c)) / c else: tmp = b / d return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -6e-75) tmp = Float64(b / d); elseif (d <= 8.8e-179) tmp = Float64(a / c); elseif (d <= 2.1e-14) tmp = Float64(Float64(b * Float64(d / c)) / c); else tmp = Float64(b / d); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= -6e-75) tmp = b / d; elseif (d <= 8.8e-179) tmp = a / c; elseif (d <= 2.1e-14) tmp = (b * (d / c)) / c; else tmp = b / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -6e-75], N[(b / d), $MachinePrecision], If[LessEqual[d, 8.8e-179], N[(a / c), $MachinePrecision], If[LessEqual[d, 2.1e-14], N[(N[(b * N[(d / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], N[(b / d), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -6 \cdot 10^{-75}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{elif}\;d \leq 8.8 \cdot 10^{-179}:\\
\;\;\;\;\frac{a}{c}\\
\mathbf{elif}\;d \leq 2.1 \cdot 10^{-14}:\\
\;\;\;\;\frac{b \cdot \frac{d}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d}\\
\end{array}
\end{array}
if d < -5.9999999999999997e-75 or 2.0999999999999999e-14 < d Initial program 54.2%
Taylor expanded in c around 0 65.5%
if -5.9999999999999997e-75 < d < 8.80000000000000018e-179Initial program 71.1%
Taylor expanded in c around inf 78.6%
if 8.80000000000000018e-179 < d < 2.0999999999999999e-14Initial program 84.1%
Taylor expanded in c around inf 85.9%
+-commutative85.9%
associate-/l*85.9%
fma-define85.9%
Simplified85.9%
Taylor expanded in b around inf 62.2%
associate-*r/62.3%
Simplified62.3%
(FPCore (a b c d) :precision binary64 (if (<= d -2.7e-74) (/ b d) (if (<= d 4e-180) (/ a c) (if (<= d 4.4e-14) (* (/ d c) (/ b c)) (/ b d)))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -2.7e-74) {
tmp = b / d;
} else if (d <= 4e-180) {
tmp = a / c;
} else if (d <= 4.4e-14) {
tmp = (d / c) * (b / c);
} else {
tmp = b / d;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (d <= (-2.7d-74)) then
tmp = b / d
else if (d <= 4d-180) then
tmp = a / c
else if (d <= 4.4d-14) then
tmp = (d / c) * (b / c)
else
tmp = b / d
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (d <= -2.7e-74) {
tmp = b / d;
} else if (d <= 4e-180) {
tmp = a / c;
} else if (d <= 4.4e-14) {
tmp = (d / c) * (b / c);
} else {
tmp = b / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -2.7e-74: tmp = b / d elif d <= 4e-180: tmp = a / c elif d <= 4.4e-14: tmp = (d / c) * (b / c) else: tmp = b / d return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -2.7e-74) tmp = Float64(b / d); elseif (d <= 4e-180) tmp = Float64(a / c); elseif (d <= 4.4e-14) tmp = Float64(Float64(d / c) * Float64(b / c)); else tmp = Float64(b / d); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= -2.7e-74) tmp = b / d; elseif (d <= 4e-180) tmp = a / c; elseif (d <= 4.4e-14) tmp = (d / c) * (b / c); else tmp = b / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -2.7e-74], N[(b / d), $MachinePrecision], If[LessEqual[d, 4e-180], N[(a / c), $MachinePrecision], If[LessEqual[d, 4.4e-14], N[(N[(d / c), $MachinePrecision] * N[(b / c), $MachinePrecision]), $MachinePrecision], N[(b / d), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -2.7 \cdot 10^{-74}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{elif}\;d \leq 4 \cdot 10^{-180}:\\
\;\;\;\;\frac{a}{c}\\
\mathbf{elif}\;d \leq 4.4 \cdot 10^{-14}:\\
\;\;\;\;\frac{d}{c} \cdot \frac{b}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d}\\
\end{array}
\end{array}
if d < -2.70000000000000018e-74 or 4.4000000000000002e-14 < d Initial program 54.2%
Taylor expanded in c around 0 65.5%
if -2.70000000000000018e-74 < d < 4.0000000000000001e-180Initial program 71.1%
Taylor expanded in c around inf 78.6%
if 4.0000000000000001e-180 < d < 4.4000000000000002e-14Initial program 84.1%
Taylor expanded in c around inf 85.9%
+-commutative85.9%
associate-/l*85.9%
fma-define85.9%
Simplified85.9%
Taylor expanded in b around inf 62.2%
associate-/l/57.1%
*-commutative57.1%
times-frac57.5%
Applied egg-rr57.5%
(FPCore (a b c d)
:precision binary64
(if (<= d -2.05e-75)
(/ b d)
(if (<= d 2.3e-132)
(/ a c)
(if (<= d 8.5e-14) (* d (/ (/ b c) c)) (/ b d)))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -2.05e-75) {
tmp = b / d;
} else if (d <= 2.3e-132) {
tmp = a / c;
} else if (d <= 8.5e-14) {
tmp = d * ((b / c) / c);
} else {
tmp = b / d;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (d <= (-2.05d-75)) then
tmp = b / d
else if (d <= 2.3d-132) then
tmp = a / c
else if (d <= 8.5d-14) then
tmp = d * ((b / c) / c)
else
tmp = b / d
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (d <= -2.05e-75) {
tmp = b / d;
} else if (d <= 2.3e-132) {
tmp = a / c;
} else if (d <= 8.5e-14) {
tmp = d * ((b / c) / c);
} else {
tmp = b / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -2.05e-75: tmp = b / d elif d <= 2.3e-132: tmp = a / c elif d <= 8.5e-14: tmp = d * ((b / c) / c) else: tmp = b / d return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -2.05e-75) tmp = Float64(b / d); elseif (d <= 2.3e-132) tmp = Float64(a / c); elseif (d <= 8.5e-14) tmp = Float64(d * Float64(Float64(b / c) / c)); else tmp = Float64(b / d); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= -2.05e-75) tmp = b / d; elseif (d <= 2.3e-132) tmp = a / c; elseif (d <= 8.5e-14) tmp = d * ((b / c) / c); else tmp = b / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -2.05e-75], N[(b / d), $MachinePrecision], If[LessEqual[d, 2.3e-132], N[(a / c), $MachinePrecision], If[LessEqual[d, 8.5e-14], N[(d * N[(N[(b / c), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision], N[(b / d), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -2.05 \cdot 10^{-75}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{elif}\;d \leq 2.3 \cdot 10^{-132}:\\
\;\;\;\;\frac{a}{c}\\
\mathbf{elif}\;d \leq 8.5 \cdot 10^{-14}:\\
\;\;\;\;d \cdot \frac{\frac{b}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d}\\
\end{array}
\end{array}
if d < -2.05000000000000001e-75 or 8.50000000000000038e-14 < d Initial program 54.2%
Taylor expanded in c around 0 65.5%
if -2.05000000000000001e-75 < d < 2.30000000000000003e-132Initial program 73.6%
Taylor expanded in c around inf 72.6%
if 2.30000000000000003e-132 < d < 8.50000000000000038e-14Initial program 84.6%
Taylor expanded in c around inf 77.7%
+-commutative77.7%
associate-/l*77.8%
fma-define77.8%
Simplified77.8%
Taylor expanded in b around inf 62.6%
*-commutative62.6%
associate-/l*62.6%
Applied egg-rr62.6%
associate-/l*62.7%
Applied egg-rr62.7%
(FPCore (a b c d) :precision binary64 (if (or (<= d -68000000.0) (not (<= d 38000000000.0))) (/ (+ b (* a (/ c d))) d) (/ (+ a (/ (* b d) c)) c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -68000000.0) || !(d <= 38000000000.0)) {
tmp = (b + (a * (c / d))) / d;
} else {
tmp = (a + ((b * d) / c)) / 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 ((d <= (-68000000.0d0)) .or. (.not. (d <= 38000000000.0d0))) then
tmp = (b + (a * (c / d))) / d
else
tmp = (a + ((b * d) / c)) / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -68000000.0) || !(d <= 38000000000.0)) {
tmp = (b + (a * (c / d))) / d;
} else {
tmp = (a + ((b * d) / c)) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -68000000.0) or not (d <= 38000000000.0): tmp = (b + (a * (c / d))) / d else: tmp = (a + ((b * d) / c)) / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -68000000.0) || !(d <= 38000000000.0)) tmp = Float64(Float64(b + Float64(a * Float64(c / d))) / d); else tmp = Float64(Float64(a + Float64(Float64(b * d) / c)) / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -68000000.0) || ~((d <= 38000000000.0))) tmp = (b + (a * (c / d))) / d; else tmp = (a + ((b * d) / c)) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -68000000.0], N[Not[LessEqual[d, 38000000000.0]], $MachinePrecision]], N[(N[(b + N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], N[(N[(a + N[(N[(b * d), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -68000000 \lor \neg \left(d \leq 38000000000\right):\\
\;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a + \frac{b \cdot d}{c}}{c}\\
\end{array}
\end{array}
if d < -6.8e7 or 3.8e10 < d Initial program 49.4%
Taylor expanded in d around inf 78.5%
associate-/l*80.6%
Simplified80.6%
if -6.8e7 < d < 3.8e10Initial program 76.8%
Taylor expanded in c around inf 83.9%
*-commutative83.9%
Simplified83.9%
Final simplification82.3%
(FPCore (a b c d) :precision binary64 (if (or (<= d -13000000.0) (not (<= d 6.4e+15))) (/ b d) (/ (+ a (/ (* b d) c)) c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -13000000.0) || !(d <= 6.4e+15)) {
tmp = b / d;
} else {
tmp = (a + ((b * d) / c)) / 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 ((d <= (-13000000.0d0)) .or. (.not. (d <= 6.4d+15))) then
tmp = b / d
else
tmp = (a + ((b * d) / c)) / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -13000000.0) || !(d <= 6.4e+15)) {
tmp = b / d;
} else {
tmp = (a + ((b * d) / c)) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -13000000.0) or not (d <= 6.4e+15): tmp = b / d else: tmp = (a + ((b * d) / c)) / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -13000000.0) || !(d <= 6.4e+15)) tmp = Float64(b / d); else tmp = Float64(Float64(a + Float64(Float64(b * d) / c)) / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -13000000.0) || ~((d <= 6.4e+15))) tmp = b / d; else tmp = (a + ((b * d) / c)) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -13000000.0], N[Not[LessEqual[d, 6.4e+15]], $MachinePrecision]], N[(b / d), $MachinePrecision], N[(N[(a + N[(N[(b * d), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -13000000 \lor \neg \left(d \leq 6.4 \cdot 10^{+15}\right):\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a + \frac{b \cdot d}{c}}{c}\\
\end{array}
\end{array}
if d < -1.3e7 or 6.4e15 < d Initial program 49.4%
Taylor expanded in c around 0 68.0%
if -1.3e7 < d < 6.4e15Initial program 76.8%
Taylor expanded in c around inf 83.9%
*-commutative83.9%
Simplified83.9%
Final simplification76.0%
(FPCore (a b c d)
:precision binary64
(if (<= d -48000000.0)
(/ (+ b (* a (/ c d))) d)
(if (<= d 1400000000000.0)
(/ (+ a (* b (/ d c))) c)
(/ (+ b (* c (/ a d))) d))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -48000000.0) {
tmp = (b + (a * (c / d))) / d;
} else if (d <= 1400000000000.0) {
tmp = (a + (b * (d / c))) / c;
} else {
tmp = (b + (c * (a / d))) / d;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (d <= (-48000000.0d0)) then
tmp = (b + (a * (c / d))) / d
else if (d <= 1400000000000.0d0) then
tmp = (a + (b * (d / c))) / c
else
tmp = (b + (c * (a / d))) / d
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (d <= -48000000.0) {
tmp = (b + (a * (c / d))) / d;
} else if (d <= 1400000000000.0) {
tmp = (a + (b * (d / c))) / c;
} else {
tmp = (b + (c * (a / d))) / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -48000000.0: tmp = (b + (a * (c / d))) / d elif d <= 1400000000000.0: tmp = (a + (b * (d / c))) / c else: tmp = (b + (c * (a / d))) / d return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -48000000.0) tmp = Float64(Float64(b + Float64(a * Float64(c / d))) / d); elseif (d <= 1400000000000.0) tmp = Float64(Float64(a + Float64(b * Float64(d / c))) / c); else tmp = Float64(Float64(b + Float64(c * Float64(a / d))) / d); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= -48000000.0) tmp = (b + (a * (c / d))) / d; elseif (d <= 1400000000000.0) tmp = (a + (b * (d / c))) / c; else tmp = (b + (c * (a / d))) / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -48000000.0], N[(N[(b + N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, 1400000000000.0], N[(N[(a + N[(b * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], N[(N[(b + N[(c * N[(a / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -48000000:\\
\;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d}\\
\mathbf{elif}\;d \leq 1400000000000:\\
\;\;\;\;\frac{a + b \cdot \frac{d}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b + c \cdot \frac{a}{d}}{d}\\
\end{array}
\end{array}
if d < -4.8e7Initial program 45.8%
Taylor expanded in d around inf 78.2%
associate-/l*81.0%
Simplified81.0%
if -4.8e7 < d < 1.4e12Initial program 76.8%
Taylor expanded in c around inf 83.9%
+-commutative83.9%
associate-/l*84.0%
fma-define84.0%
Simplified84.0%
fma-undefine84.0%
Applied egg-rr84.0%
if 1.4e12 < d Initial program 54.1%
Taylor expanded in d around inf 78.9%
*-commutative78.9%
*-un-lft-identity78.9%
times-frac86.0%
Applied egg-rr86.0%
Taylor expanded in c around 0 86.0%
Final simplification83.6%
(FPCore (a b c d)
:precision binary64
(if (<= d -56000000.0)
(/ (+ b (* a (/ c d))) d)
(if (<= d 16000000000.0)
(/ (+ a (/ (* b d) c)) c)
(/ (+ b (* c (/ a d))) d))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -56000000.0) {
tmp = (b + (a * (c / d))) / d;
} else if (d <= 16000000000.0) {
tmp = (a + ((b * d) / c)) / c;
} else {
tmp = (b + (c * (a / d))) / d;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (d <= (-56000000.0d0)) then
tmp = (b + (a * (c / d))) / d
else if (d <= 16000000000.0d0) then
tmp = (a + ((b * d) / c)) / c
else
tmp = (b + (c * (a / d))) / d
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (d <= -56000000.0) {
tmp = (b + (a * (c / d))) / d;
} else if (d <= 16000000000.0) {
tmp = (a + ((b * d) / c)) / c;
} else {
tmp = (b + (c * (a / d))) / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -56000000.0: tmp = (b + (a * (c / d))) / d elif d <= 16000000000.0: tmp = (a + ((b * d) / c)) / c else: tmp = (b + (c * (a / d))) / d return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -56000000.0) tmp = Float64(Float64(b + Float64(a * Float64(c / d))) / d); elseif (d <= 16000000000.0) tmp = Float64(Float64(a + Float64(Float64(b * d) / c)) / c); else tmp = Float64(Float64(b + Float64(c * Float64(a / d))) / d); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= -56000000.0) tmp = (b + (a * (c / d))) / d; elseif (d <= 16000000000.0) tmp = (a + ((b * d) / c)) / c; else tmp = (b + (c * (a / d))) / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -56000000.0], N[(N[(b + N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, 16000000000.0], N[(N[(a + N[(N[(b * d), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], N[(N[(b + N[(c * N[(a / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -56000000:\\
\;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d}\\
\mathbf{elif}\;d \leq 16000000000:\\
\;\;\;\;\frac{a + \frac{b \cdot d}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b + c \cdot \frac{a}{d}}{d}\\
\end{array}
\end{array}
if d < -5.6e7Initial program 45.8%
Taylor expanded in d around inf 78.2%
associate-/l*81.0%
Simplified81.0%
if -5.6e7 < d < 1.6e10Initial program 76.8%
Taylor expanded in c around inf 83.9%
*-commutative83.9%
Simplified83.9%
if 1.6e10 < d Initial program 54.1%
Taylor expanded in d around inf 78.9%
*-commutative78.9%
*-un-lft-identity78.9%
times-frac86.0%
Applied egg-rr86.0%
Taylor expanded in c around 0 86.0%
Final simplification83.6%
(FPCore (a b c d) :precision binary64 (if (or (<= d -2.65e-74) (not (<= d 0.25))) (/ b d) (/ a c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -2.65e-74) || !(d <= 0.25)) {
tmp = b / d;
} else {
tmp = a / 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 ((d <= (-2.65d-74)) .or. (.not. (d <= 0.25d0))) then
tmp = b / d
else
tmp = a / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -2.65e-74) || !(d <= 0.25)) {
tmp = b / d;
} else {
tmp = a / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -2.65e-74) or not (d <= 0.25): tmp = b / d else: tmp = a / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -2.65e-74) || !(d <= 0.25)) tmp = Float64(b / d); else tmp = Float64(a / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -2.65e-74) || ~((d <= 0.25))) tmp = b / d; else tmp = a / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -2.65e-74], N[Not[LessEqual[d, 0.25]], $MachinePrecision]], N[(b / d), $MachinePrecision], N[(a / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -2.65 \cdot 10^{-74} \lor \neg \left(d \leq 0.25\right):\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c}\\
\end{array}
\end{array}
if d < -2.64999999999999994e-74 or 0.25 < d Initial program 53.9%
Taylor expanded in c around 0 65.5%
if -2.64999999999999994e-74 < d < 0.25Initial program 75.3%
Taylor expanded in c around inf 66.8%
Final simplification66.1%
(FPCore (a b c d) :precision binary64 (/ a c))
double code(double a, double b, double c, double d) {
return a / 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 = a / c
end function
public static double code(double a, double b, double c, double d) {
return a / c;
}
def code(a, b, c, d): return a / c
function code(a, b, c, d) return Float64(a / c) end
function tmp = code(a, b, c, d) tmp = a / c; end
code[a_, b_, c_, d_] := N[(a / c), $MachinePrecision]
\begin{array}{l}
\\
\frac{a}{c}
\end{array}
Initial program 63.2%
Taylor expanded in c around inf 40.9%
(FPCore (a b c d) :precision binary64 (if (< (fabs d) (fabs c)) (/ (+ a (* b (/ d c))) (+ c (* d (/ d c)))) (/ (+ b (* a (/ c d))) (+ d (* c (/ c d))))))
double code(double a, double b, double c, double d) {
double tmp;
if (fabs(d) < fabs(c)) {
tmp = (a + (b * (d / c))) / (c + (d * (d / c)));
} else {
tmp = (b + (a * (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 = (a + (b * (d / c))) / (c + (d * (d / c)))
else
tmp = (b + (a * (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 = (a + (b * (d / c))) / (c + (d * (d / c)));
} else {
tmp = (b + (a * (c / d))) / (d + (c * (c / d)));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if math.fabs(d) < math.fabs(c): tmp = (a + (b * (d / c))) / (c + (d * (d / c))) else: tmp = (b + (a * (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(a + Float64(b * Float64(d / c))) / Float64(c + Float64(d * Float64(d / c)))); else tmp = Float64(Float64(b + Float64(a * 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 = (a + (b * (d / c))) / (c + (d * (d / c))); else tmp = (b + (a * (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[(a + N[(b * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(c + N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b + N[(a * 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{a + b \cdot \frac{d}{c}}{c + d \cdot \frac{d}{c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d + c \cdot \frac{c}{d}}\\
\end{array}
\end{array}
herbie shell --seed 2024166
(FPCore (a b c d)
:name "Complex division, real part"
:precision binary64
:alt
(! :herbie-platform default (if (< (fabs d) (fabs c)) (/ (+ a (* b (/ d c))) (+ c (* d (/ d c)))) (/ (+ b (* a (/ c d))) (+ d (* c (/ c d))))))
(/ (+ (* a c) (* b d)) (+ (* c c) (* d d))))