
(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 13 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 (or (<= d -3.3e-158) (not (<= d 5e-101))) (* (/ (fma a (/ c d) b) (hypot c d)) (/ d (hypot c d))) (/ (+ a (* b (/ d c))) c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -3.3e-158) || !(d <= 5e-101)) {
tmp = (fma(a, (c / d), b) / hypot(c, d)) * (d / hypot(c, d));
} else {
tmp = (a + (b * (d / c))) / c;
}
return tmp;
}
function code(a, b, c, d) tmp = 0.0 if ((d <= -3.3e-158) || !(d <= 5e-101)) tmp = Float64(Float64(fma(a, Float64(c / d), b) / hypot(c, d)) * Float64(d / hypot(c, d))); else tmp = Float64(Float64(a + Float64(b * Float64(d / c))) / c); end return tmp end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -3.3e-158], N[Not[LessEqual[d, 5e-101]], $MachinePrecision]], N[(N[(N[(a * N[(c / d), $MachinePrecision] + b), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(d / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a + N[(b * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -3.3 \cdot 10^{-158} \lor \neg \left(d \leq 5 \cdot 10^{-101}\right):\\
\;\;\;\;\frac{\mathsf{fma}\left(a, \frac{c}{d}, b\right)}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{d}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{a + b \cdot \frac{d}{c}}{c}\\
\end{array}
\end{array}
if d < -3.3000000000000002e-158 or 5.0000000000000001e-101 < d Initial program 64.0%
fma-define64.1%
fma-define64.1%
Simplified64.1%
Taylor expanded in d around inf 61.8%
*-commutative61.8%
associate-*r/61.3%
fma-undefine61.3%
add-sqr-sqrt61.2%
hypot-undefine61.2%
hypot-undefine61.2%
times-frac90.5%
associate-*r/83.3%
+-commutative83.3%
associate-*r/90.5%
fma-define90.5%
Applied egg-rr90.5%
if -3.3000000000000002e-158 < d < 5.0000000000000001e-101Initial program 71.1%
fma-define71.1%
fma-define71.1%
Simplified71.1%
*-un-lft-identity71.1%
fma-define71.1%
add-sqr-sqrt71.1%
times-frac71.2%
fma-define71.2%
hypot-define71.2%
fma-define71.2%
fma-define71.2%
hypot-define80.5%
Applied egg-rr80.5%
Taylor expanded in c around inf 94.7%
associate-/l*94.7%
Simplified94.7%
Final simplification91.8%
(FPCore (a b c d) :precision binary64 (if (<= (/ (+ (* a c) (* d b)) (+ (* c c) (* d d))) 1e+290) (* (/ 1.0 (hypot c d)) (/ (fma a c (* d b)) (hypot c d))) (/ (+ a (* b (/ d c))) c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((((a * c) + (d * b)) / ((c * c) + (d * d))) <= 1e+290) {
tmp = (1.0 / hypot(c, d)) * (fma(a, c, (d * b)) / hypot(c, d));
} else {
tmp = (a + (b * (d / c))) / c;
}
return tmp;
}
function code(a, b, c, d) tmp = 0.0 if (Float64(Float64(Float64(a * c) + Float64(d * b)) / Float64(Float64(c * c) + Float64(d * d))) <= 1e+290) tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(fma(a, c, Float64(d * b)) / hypot(c, d))); else tmp = Float64(Float64(a + Float64(b * Float64(d / c))) / c); end return tmp end
code[a_, b_, c_, d_] := If[LessEqual[N[(N[(N[(a * c), $MachinePrecision] + N[(d * b), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1e+290], N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(N[(a * c + N[(d * b), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a + N[(b * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{a \cdot c + d \cdot b}{c \cdot c + d \cdot d} \leq 10^{+290}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{\mathsf{fma}\left(a, c, d \cdot b\right)}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{a + b \cdot \frac{d}{c}}{c}\\
\end{array}
\end{array}
if (/.f64 (+.f64 (*.f64 a c) (*.f64 b d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 1.00000000000000006e290Initial program 83.1%
fma-define83.2%
fma-define83.2%
Simplified83.2%
*-un-lft-identity83.2%
fma-define83.1%
add-sqr-sqrt83.1%
times-frac83.2%
fma-define83.2%
hypot-define83.2%
fma-define83.2%
fma-define83.2%
hypot-define96.3%
Applied egg-rr96.3%
if 1.00000000000000006e290 < (/.f64 (+.f64 (*.f64 a c) (*.f64 b d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 13.4%
fma-define13.4%
fma-define13.4%
Simplified13.4%
*-un-lft-identity13.4%
fma-define13.4%
add-sqr-sqrt13.4%
times-frac13.4%
fma-define13.4%
hypot-define13.4%
fma-define13.4%
fma-define13.4%
hypot-define17.2%
Applied egg-rr17.2%
Taylor expanded in c around inf 53.5%
associate-/l*58.5%
Simplified58.5%
Final simplification87.1%
(FPCore (a b c d)
:precision binary64
(if (<= d -4.7e+79)
(/ (+ b (- (* a (/ c d)) (* b (pow (/ c d) 2.0)))) d)
(if (<= d -3.05e-158)
(/ (fma a c (* d b)) (fma c c (* d d)))
(if (<= d 1.4e-31)
(/ (+ a (* b (/ d c))) c)
(+ (/ b d) (* a (* (/ c d) (/ 1.0 d))))))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -4.7e+79) {
tmp = (b + ((a * (c / d)) - (b * pow((c / d), 2.0)))) / d;
} else if (d <= -3.05e-158) {
tmp = fma(a, c, (d * b)) / fma(c, c, (d * d));
} else if (d <= 1.4e-31) {
tmp = (a + (b * (d / c))) / c;
} else {
tmp = (b / d) + (a * ((c / d) * (1.0 / d)));
}
return tmp;
}
function code(a, b, c, d) tmp = 0.0 if (d <= -4.7e+79) tmp = Float64(Float64(b + Float64(Float64(a * Float64(c / d)) - Float64(b * (Float64(c / d) ^ 2.0)))) / d); elseif (d <= -3.05e-158) tmp = Float64(fma(a, c, Float64(d * b)) / fma(c, c, Float64(d * d))); elseif (d <= 1.4e-31) tmp = Float64(Float64(a + Float64(b * Float64(d / c))) / c); else tmp = Float64(Float64(b / d) + Float64(a * Float64(Float64(c / d) * Float64(1.0 / d)))); end return tmp end
code[a_, b_, c_, d_] := If[LessEqual[d, -4.7e+79], 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, -3.05e-158], N[(N[(a * c + N[(d * b), $MachinePrecision]), $MachinePrecision] / N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.4e-31], N[(N[(a + N[(b * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], N[(N[(b / d), $MachinePrecision] + N[(a * N[(N[(c / d), $MachinePrecision] * N[(1.0 / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -4.7 \cdot 10^{+79}:\\
\;\;\;\;\frac{b + \left(a \cdot \frac{c}{d} - b \cdot {\left(\frac{c}{d}\right)}^{2}\right)}{d}\\
\mathbf{elif}\;d \leq -3.05 \cdot 10^{-158}:\\
\;\;\;\;\frac{\mathsf{fma}\left(a, c, d \cdot b\right)}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\
\mathbf{elif}\;d \leq 1.4 \cdot 10^{-31}:\\
\;\;\;\;\frac{a + b \cdot \frac{d}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d} + a \cdot \left(\frac{c}{d} \cdot \frac{1}{d}\right)\\
\end{array}
\end{array}
if d < -4.70000000000000023e79Initial program 48.5%
fma-define48.5%
fma-define48.5%
Simplified48.5%
*-un-lft-identity48.5%
fma-define48.5%
add-sqr-sqrt48.5%
times-frac48.5%
fma-define48.5%
hypot-define48.5%
fma-define48.5%
fma-define48.5%
hypot-define66.7%
Applied egg-rr66.7%
Taylor expanded in d around inf 72.9%
associate-*r/77.3%
+-commutative77.3%
mul-1-neg77.3%
unsub-neg77.3%
associate-/l*79.6%
unpow279.6%
unpow279.6%
times-frac89.9%
unpow289.9%
Simplified89.9%
if -4.70000000000000023e79 < d < -3.0499999999999999e-158Initial program 89.8%
fma-define89.9%
fma-define89.9%
Simplified89.9%
if -3.0499999999999999e-158 < d < 1.3999999999999999e-31Initial program 71.9%
fma-define71.9%
fma-define71.9%
Simplified71.9%
*-un-lft-identity71.9%
fma-define71.9%
add-sqr-sqrt71.9%
times-frac71.9%
fma-define71.9%
hypot-define71.9%
fma-define71.9%
fma-define71.9%
hypot-define81.6%
Applied egg-rr81.6%
Taylor expanded in c around inf 88.8%
associate-/l*88.8%
Simplified88.8%
if 1.3999999999999999e-31 < d Initial program 55.7%
fma-define55.7%
fma-define55.7%
Simplified55.7%
Taylor expanded in c around 0 75.0%
associate-/l*78.5%
Simplified78.5%
*-un-lft-identity78.5%
pow278.5%
times-frac86.3%
Applied egg-rr86.3%
Final simplification88.5%
(FPCore (a b c d)
:precision binary64
(if (<= d -2.7e+75)
(/ (+ b (- (* a (/ c d)) (* b (pow (/ c d) 2.0)))) d)
(if (<= d -1.45e-157)
(/ (+ (* a c) (* d b)) (+ (* c c) (* d d)))
(if (<= d 6.5e-32)
(/ (+ a (* b (/ d c))) c)
(+ (/ b d) (* a (* (/ c d) (/ 1.0 d))))))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -2.7e+75) {
tmp = (b + ((a * (c / d)) - (b * pow((c / d), 2.0)))) / d;
} else if (d <= -1.45e-157) {
tmp = ((a * c) + (d * b)) / ((c * c) + (d * d));
} else if (d <= 6.5e-32) {
tmp = (a + (b * (d / c))) / c;
} else {
tmp = (b / d) + (a * ((c / d) * (1.0 / 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+75)) then
tmp = (b + ((a * (c / d)) - (b * ((c / d) ** 2.0d0)))) / d
else if (d <= (-1.45d-157)) then
tmp = ((a * c) + (d * b)) / ((c * c) + (d * d))
else if (d <= 6.5d-32) then
tmp = (a + (b * (d / c))) / c
else
tmp = (b / d) + (a * ((c / d) * (1.0d0 / 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+75) {
tmp = (b + ((a * (c / d)) - (b * Math.pow((c / d), 2.0)))) / d;
} else if (d <= -1.45e-157) {
tmp = ((a * c) + (d * b)) / ((c * c) + (d * d));
} else if (d <= 6.5e-32) {
tmp = (a + (b * (d / c))) / c;
} else {
tmp = (b / d) + (a * ((c / d) * (1.0 / d)));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -2.7e+75: tmp = (b + ((a * (c / d)) - (b * math.pow((c / d), 2.0)))) / d elif d <= -1.45e-157: tmp = ((a * c) + (d * b)) / ((c * c) + (d * d)) elif d <= 6.5e-32: tmp = (a + (b * (d / c))) / c else: tmp = (b / d) + (a * ((c / d) * (1.0 / d))) return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -2.7e+75) tmp = Float64(Float64(b + Float64(Float64(a * Float64(c / d)) - Float64(b * (Float64(c / d) ^ 2.0)))) / d); elseif (d <= -1.45e-157) tmp = Float64(Float64(Float64(a * c) + Float64(d * b)) / Float64(Float64(c * c) + Float64(d * d))); elseif (d <= 6.5e-32) tmp = Float64(Float64(a + Float64(b * Float64(d / c))) / c); else tmp = Float64(Float64(b / d) + Float64(a * Float64(Float64(c / d) * Float64(1.0 / d)))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= -2.7e+75) tmp = (b + ((a * (c / d)) - (b * ((c / d) ^ 2.0)))) / d; elseif (d <= -1.45e-157) tmp = ((a * c) + (d * b)) / ((c * c) + (d * d)); elseif (d <= 6.5e-32) tmp = (a + (b * (d / c))) / c; else tmp = (b / d) + (a * ((c / d) * (1.0 / d))); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -2.7e+75], 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.45e-157], N[(N[(N[(a * c), $MachinePrecision] + N[(d * b), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 6.5e-32], N[(N[(a + N[(b * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], N[(N[(b / d), $MachinePrecision] + N[(a * N[(N[(c / d), $MachinePrecision] * N[(1.0 / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -2.7 \cdot 10^{+75}:\\
\;\;\;\;\frac{b + \left(a \cdot \frac{c}{d} - b \cdot {\left(\frac{c}{d}\right)}^{2}\right)}{d}\\
\mathbf{elif}\;d \leq -1.45 \cdot 10^{-157}:\\
\;\;\;\;\frac{a \cdot c + d \cdot b}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;d \leq 6.5 \cdot 10^{-32}:\\
\;\;\;\;\frac{a + b \cdot \frac{d}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d} + a \cdot \left(\frac{c}{d} \cdot \frac{1}{d}\right)\\
\end{array}
\end{array}
if d < -2.69999999999999998e75Initial program 48.5%
fma-define48.5%
fma-define48.5%
Simplified48.5%
*-un-lft-identity48.5%
fma-define48.5%
add-sqr-sqrt48.5%
times-frac48.5%
fma-define48.5%
hypot-define48.5%
fma-define48.5%
fma-define48.5%
hypot-define66.7%
Applied egg-rr66.7%
Taylor expanded in d around inf 72.9%
associate-*r/77.3%
+-commutative77.3%
mul-1-neg77.3%
unsub-neg77.3%
associate-/l*79.6%
unpow279.6%
unpow279.6%
times-frac89.9%
unpow289.9%
Simplified89.9%
if -2.69999999999999998e75 < d < -1.44999999999999994e-157Initial program 89.8%
if -1.44999999999999994e-157 < d < 6.49999999999999988e-32Initial program 71.9%
fma-define71.9%
fma-define71.9%
Simplified71.9%
*-un-lft-identity71.9%
fma-define71.9%
add-sqr-sqrt71.9%
times-frac71.9%
fma-define71.9%
hypot-define71.9%
fma-define71.9%
fma-define71.9%
hypot-define81.6%
Applied egg-rr81.6%
Taylor expanded in c around inf 88.8%
associate-/l*88.8%
Simplified88.8%
if 6.49999999999999988e-32 < d Initial program 55.7%
fma-define55.7%
fma-define55.7%
Simplified55.7%
Taylor expanded in c around 0 75.0%
associate-/l*78.5%
Simplified78.5%
*-un-lft-identity78.5%
pow278.5%
times-frac86.3%
Applied egg-rr86.3%
Final simplification88.5%
(FPCore (a b c d)
:precision binary64
(if (<= d -4.5e+76)
(/ (+ b (* c (/ a d))) d)
(if (<= d -5e-158)
(/ (+ (* a c) (* d b)) (+ (* c c) (* d d)))
(if (<= d 6.8e-32)
(/ (+ a (* b (/ d c))) c)
(+ (/ b d) (* a (* (/ c d) (/ 1.0 d))))))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -4.5e+76) {
tmp = (b + (c * (a / d))) / d;
} else if (d <= -5e-158) {
tmp = ((a * c) + (d * b)) / ((c * c) + (d * d));
} else if (d <= 6.8e-32) {
tmp = (a + (b * (d / c))) / c;
} else {
tmp = (b / d) + (a * ((c / d) * (1.0 / 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 <= (-4.5d+76)) then
tmp = (b + (c * (a / d))) / d
else if (d <= (-5d-158)) then
tmp = ((a * c) + (d * b)) / ((c * c) + (d * d))
else if (d <= 6.8d-32) then
tmp = (a + (b * (d / c))) / c
else
tmp = (b / d) + (a * ((c / d) * (1.0d0 / d)))
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (d <= -4.5e+76) {
tmp = (b + (c * (a / d))) / d;
} else if (d <= -5e-158) {
tmp = ((a * c) + (d * b)) / ((c * c) + (d * d));
} else if (d <= 6.8e-32) {
tmp = (a + (b * (d / c))) / c;
} else {
tmp = (b / d) + (a * ((c / d) * (1.0 / d)));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -4.5e+76: tmp = (b + (c * (a / d))) / d elif d <= -5e-158: tmp = ((a * c) + (d * b)) / ((c * c) + (d * d)) elif d <= 6.8e-32: tmp = (a + (b * (d / c))) / c else: tmp = (b / d) + (a * ((c / d) * (1.0 / d))) return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -4.5e+76) tmp = Float64(Float64(b + Float64(c * Float64(a / d))) / d); elseif (d <= -5e-158) tmp = Float64(Float64(Float64(a * c) + Float64(d * b)) / Float64(Float64(c * c) + Float64(d * d))); elseif (d <= 6.8e-32) tmp = Float64(Float64(a + Float64(b * Float64(d / c))) / c); else tmp = Float64(Float64(b / d) + Float64(a * Float64(Float64(c / d) * Float64(1.0 / d)))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= -4.5e+76) tmp = (b + (c * (a / d))) / d; elseif (d <= -5e-158) tmp = ((a * c) + (d * b)) / ((c * c) + (d * d)); elseif (d <= 6.8e-32) tmp = (a + (b * (d / c))) / c; else tmp = (b / d) + (a * ((c / d) * (1.0 / d))); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -4.5e+76], N[(N[(b + N[(c * N[(a / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, -5e-158], N[(N[(N[(a * c), $MachinePrecision] + N[(d * b), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 6.8e-32], N[(N[(a + N[(b * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], N[(N[(b / d), $MachinePrecision] + N[(a * N[(N[(c / d), $MachinePrecision] * N[(1.0 / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -4.5 \cdot 10^{+76}:\\
\;\;\;\;\frac{b + c \cdot \frac{a}{d}}{d}\\
\mathbf{elif}\;d \leq -5 \cdot 10^{-158}:\\
\;\;\;\;\frac{a \cdot c + d \cdot b}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;d \leq 6.8 \cdot 10^{-32}:\\
\;\;\;\;\frac{a + b \cdot \frac{d}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d} + a \cdot \left(\frac{c}{d} \cdot \frac{1}{d}\right)\\
\end{array}
\end{array}
if d < -4.4999999999999997e76Initial program 48.5%
fma-define48.5%
fma-define48.5%
Simplified48.5%
Taylor expanded in d around inf 83.1%
associate-/l*89.7%
Simplified89.7%
associate-*r/83.1%
*-commutative83.1%
Applied egg-rr83.1%
associate-/l*89.8%
*-commutative89.8%
Applied egg-rr89.8%
if -4.4999999999999997e76 < d < -4.99999999999999972e-158Initial program 89.8%
if -4.99999999999999972e-158 < d < 6.79999999999999956e-32Initial program 71.9%
fma-define71.9%
fma-define71.9%
Simplified71.9%
*-un-lft-identity71.9%
fma-define71.9%
add-sqr-sqrt71.9%
times-frac71.9%
fma-define71.9%
hypot-define71.9%
fma-define71.9%
fma-define71.9%
hypot-define81.6%
Applied egg-rr81.6%
Taylor expanded in c around inf 88.8%
associate-/l*88.8%
Simplified88.8%
if 6.79999999999999956e-32 < d Initial program 55.7%
fma-define55.7%
fma-define55.7%
Simplified55.7%
Taylor expanded in c around 0 75.0%
associate-/l*78.5%
Simplified78.5%
*-un-lft-identity78.5%
pow278.5%
times-frac86.3%
Applied egg-rr86.3%
Final simplification88.4%
(FPCore (a b c d)
:precision binary64
(if (<= d -1.35e-68)
(+ (/ b d) (/ (/ a d) (/ d c)))
(if (<= d 1.05e-31)
(/ (+ a (* b (/ d c))) c)
(+ (/ b d) (* a (* (/ c d) (/ 1.0 d)))))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -1.35e-68) {
tmp = (b / d) + ((a / d) / (d / c));
} else if (d <= 1.05e-31) {
tmp = (a + (b * (d / c))) / c;
} else {
tmp = (b / d) + (a * ((c / d) * (1.0 / 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.35d-68)) then
tmp = (b / d) + ((a / d) / (d / c))
else if (d <= 1.05d-31) then
tmp = (a + (b * (d / c))) / c
else
tmp = (b / d) + (a * ((c / d) * (1.0d0 / d)))
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (d <= -1.35e-68) {
tmp = (b / d) + ((a / d) / (d / c));
} else if (d <= 1.05e-31) {
tmp = (a + (b * (d / c))) / c;
} else {
tmp = (b / d) + (a * ((c / d) * (1.0 / d)));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -1.35e-68: tmp = (b / d) + ((a / d) / (d / c)) elif d <= 1.05e-31: tmp = (a + (b * (d / c))) / c else: tmp = (b / d) + (a * ((c / d) * (1.0 / d))) return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -1.35e-68) tmp = Float64(Float64(b / d) + Float64(Float64(a / d) / Float64(d / c))); elseif (d <= 1.05e-31) tmp = Float64(Float64(a + Float64(b * Float64(d / c))) / c); else tmp = Float64(Float64(b / d) + Float64(a * Float64(Float64(c / d) * Float64(1.0 / d)))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= -1.35e-68) tmp = (b / d) + ((a / d) / (d / c)); elseif (d <= 1.05e-31) tmp = (a + (b * (d / c))) / c; else tmp = (b / d) + (a * ((c / d) * (1.0 / d))); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -1.35e-68], N[(N[(b / d), $MachinePrecision] + N[(N[(a / d), $MachinePrecision] / N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.05e-31], N[(N[(a + N[(b * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], N[(N[(b / d), $MachinePrecision] + N[(a * N[(N[(c / d), $MachinePrecision] * N[(1.0 / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.35 \cdot 10^{-68}:\\
\;\;\;\;\frac{b}{d} + \frac{\frac{a}{d}}{\frac{d}{c}}\\
\mathbf{elif}\;d \leq 1.05 \cdot 10^{-31}:\\
\;\;\;\;\frac{a + b \cdot \frac{d}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d} + a \cdot \left(\frac{c}{d} \cdot \frac{1}{d}\right)\\
\end{array}
\end{array}
if d < -1.3500000000000001e-68Initial program 66.1%
fma-define66.1%
fma-define66.1%
Simplified66.1%
Taylor expanded in c around 0 74.2%
associate-/l*75.8%
Simplified75.8%
*-un-lft-identity75.8%
pow275.8%
times-frac75.8%
Applied egg-rr75.8%
associate-*r*81.2%
clear-num81.2%
un-div-inv81.2%
un-div-inv81.3%
Applied egg-rr81.3%
if -1.3500000000000001e-68 < d < 1.04999999999999996e-31Initial program 73.2%
fma-define73.2%
fma-define73.2%
Simplified73.2%
*-un-lft-identity73.2%
fma-define73.2%
add-sqr-sqrt73.2%
times-frac73.2%
fma-define73.2%
hypot-define73.2%
fma-define73.3%
fma-define73.3%
hypot-define82.6%
Applied egg-rr82.6%
Taylor expanded in c around inf 84.6%
associate-/l*84.6%
Simplified84.6%
if 1.04999999999999996e-31 < d Initial program 55.7%
fma-define55.7%
fma-define55.7%
Simplified55.7%
Taylor expanded in c around 0 75.0%
associate-/l*78.5%
Simplified78.5%
*-un-lft-identity78.5%
pow278.5%
times-frac86.3%
Applied egg-rr86.3%
Final simplification84.2%
(FPCore (a b c d)
:precision binary64
(if (<= d -1.3e-68)
(+ (/ b d) (/ (/ a d) (/ d c)))
(if (<= d 1.4e-31)
(/ (+ a (* b (/ d c))) c)
(+ (/ b d) (/ (* a (/ c d)) d)))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -1.3e-68) {
tmp = (b / d) + ((a / d) / (d / c));
} else if (d <= 1.4e-31) {
tmp = (a + (b * (d / c))) / c;
} else {
tmp = (b / d) + ((a * (c / 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.3d-68)) then
tmp = (b / d) + ((a / d) / (d / c))
else if (d <= 1.4d-31) then
tmp = (a + (b * (d / c))) / c
else
tmp = (b / d) + ((a * (c / 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.3e-68) {
tmp = (b / d) + ((a / d) / (d / c));
} else if (d <= 1.4e-31) {
tmp = (a + (b * (d / c))) / c;
} else {
tmp = (b / d) + ((a * (c / d)) / d);
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -1.3e-68: tmp = (b / d) + ((a / d) / (d / c)) elif d <= 1.4e-31: tmp = (a + (b * (d / c))) / c else: tmp = (b / d) + ((a * (c / d)) / d) return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -1.3e-68) tmp = Float64(Float64(b / d) + Float64(Float64(a / d) / Float64(d / c))); elseif (d <= 1.4e-31) tmp = Float64(Float64(a + Float64(b * Float64(d / c))) / c); else tmp = Float64(Float64(b / d) + Float64(Float64(a * Float64(c / d)) / d)); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= -1.3e-68) tmp = (b / d) + ((a / d) / (d / c)); elseif (d <= 1.4e-31) tmp = (a + (b * (d / c))) / c; else tmp = (b / d) + ((a * (c / d)) / d); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -1.3e-68], N[(N[(b / d), $MachinePrecision] + N[(N[(a / d), $MachinePrecision] / N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.4e-31], N[(N[(a + N[(b * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], N[(N[(b / d), $MachinePrecision] + N[(N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.3 \cdot 10^{-68}:\\
\;\;\;\;\frac{b}{d} + \frac{\frac{a}{d}}{\frac{d}{c}}\\
\mathbf{elif}\;d \leq 1.4 \cdot 10^{-31}:\\
\;\;\;\;\frac{a + b \cdot \frac{d}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d} + \frac{a \cdot \frac{c}{d}}{d}\\
\end{array}
\end{array}
if d < -1.2999999999999999e-68Initial program 66.1%
fma-define66.1%
fma-define66.1%
Simplified66.1%
Taylor expanded in c around 0 74.2%
associate-/l*75.8%
Simplified75.8%
*-un-lft-identity75.8%
pow275.8%
times-frac75.8%
Applied egg-rr75.8%
associate-*r*81.2%
clear-num81.2%
un-div-inv81.2%
un-div-inv81.3%
Applied egg-rr81.3%
if -1.2999999999999999e-68 < d < 1.3999999999999999e-31Initial program 73.2%
fma-define73.2%
fma-define73.2%
Simplified73.2%
*-un-lft-identity73.2%
fma-define73.2%
add-sqr-sqrt73.2%
times-frac73.2%
fma-define73.2%
hypot-define73.2%
fma-define73.3%
fma-define73.3%
hypot-define82.6%
Applied egg-rr82.6%
Taylor expanded in c around inf 84.6%
associate-/l*84.6%
Simplified84.6%
if 1.3999999999999999e-31 < d Initial program 55.7%
fma-define55.7%
fma-define55.7%
Simplified55.7%
Taylor expanded in c around 0 75.0%
associate-/l*78.5%
Simplified78.5%
*-un-lft-identity78.5%
pow278.5%
times-frac86.3%
Applied egg-rr86.3%
*-commutative86.3%
associate-*l/86.3%
*-un-lft-identity86.3%
associate-*l/86.3%
Applied egg-rr86.3%
Final simplification84.2%
(FPCore (a b c d)
:precision binary64
(if (<= d -1.35e-68)
(/ (+ b (* c (/ a d))) d)
(if (<= d 1e-31)
(/ (+ a (* b (/ d c))) c)
(+ (/ b d) (/ (* a (/ c d)) d)))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -1.35e-68) {
tmp = (b + (c * (a / d))) / d;
} else if (d <= 1e-31) {
tmp = (a + (b * (d / c))) / c;
} else {
tmp = (b / d) + ((a * (c / 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.35d-68)) then
tmp = (b + (c * (a / d))) / d
else if (d <= 1d-31) then
tmp = (a + (b * (d / c))) / c
else
tmp = (b / d) + ((a * (c / 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.35e-68) {
tmp = (b + (c * (a / d))) / d;
} else if (d <= 1e-31) {
tmp = (a + (b * (d / c))) / c;
} else {
tmp = (b / d) + ((a * (c / d)) / d);
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -1.35e-68: tmp = (b + (c * (a / d))) / d elif d <= 1e-31: tmp = (a + (b * (d / c))) / c else: tmp = (b / d) + ((a * (c / d)) / d) return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -1.35e-68) tmp = Float64(Float64(b + Float64(c * Float64(a / d))) / d); elseif (d <= 1e-31) tmp = Float64(Float64(a + Float64(b * Float64(d / c))) / c); else tmp = Float64(Float64(b / d) + Float64(Float64(a * Float64(c / d)) / d)); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= -1.35e-68) tmp = (b + (c * (a / d))) / d; elseif (d <= 1e-31) tmp = (a + (b * (d / c))) / c; else tmp = (b / d) + ((a * (c / d)) / d); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -1.35e-68], N[(N[(b + N[(c * N[(a / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, 1e-31], N[(N[(a + N[(b * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], N[(N[(b / d), $MachinePrecision] + N[(N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.35 \cdot 10^{-68}:\\
\;\;\;\;\frac{b + c \cdot \frac{a}{d}}{d}\\
\mathbf{elif}\;d \leq 10^{-31}:\\
\;\;\;\;\frac{a + b \cdot \frac{d}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d} + \frac{a \cdot \frac{c}{d}}{d}\\
\end{array}
\end{array}
if d < -1.3500000000000001e-68Initial program 66.1%
fma-define66.1%
fma-define66.1%
Simplified66.1%
Taylor expanded in d around inf 77.1%
associate-/l*81.2%
Simplified81.2%
associate-*r/77.1%
*-commutative77.1%
Applied egg-rr77.1%
associate-/l*81.3%
*-commutative81.3%
Applied egg-rr81.3%
if -1.3500000000000001e-68 < d < 1e-31Initial program 73.2%
fma-define73.2%
fma-define73.2%
Simplified73.2%
*-un-lft-identity73.2%
fma-define73.2%
add-sqr-sqrt73.2%
times-frac73.2%
fma-define73.2%
hypot-define73.2%
fma-define73.3%
fma-define73.3%
hypot-define82.6%
Applied egg-rr82.6%
Taylor expanded in c around inf 84.6%
associate-/l*84.6%
Simplified84.6%
if 1e-31 < d Initial program 55.7%
fma-define55.7%
fma-define55.7%
Simplified55.7%
Taylor expanded in c around 0 75.0%
associate-/l*78.5%
Simplified78.5%
*-un-lft-identity78.5%
pow278.5%
times-frac86.3%
Applied egg-rr86.3%
*-commutative86.3%
associate-*l/86.3%
*-un-lft-identity86.3%
associate-*l/86.3%
Applied egg-rr86.3%
Final simplification84.2%
(FPCore (a b c d) :precision binary64 (if (or (<= d -1.2e-68) (not (<= d 1.2e-31))) (/ (+ b (* a (/ c d))) d) (/ (+ a (* b (/ d c))) c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -1.2e-68) || !(d <= 1.2e-31)) {
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 <= (-1.2d-68)) .or. (.not. (d <= 1.2d-31))) 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 <= -1.2e-68) || !(d <= 1.2e-31)) {
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 <= -1.2e-68) or not (d <= 1.2e-31): 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 <= -1.2e-68) || !(d <= 1.2e-31)) tmp = Float64(Float64(b + Float64(a * Float64(c / d))) / d); else tmp = Float64(Float64(a + Float64(b * Float64(d / c))) / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -1.2e-68) || ~((d <= 1.2e-31))) 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, -1.2e-68], N[Not[LessEqual[d, 1.2e-31]], $MachinePrecision]], N[(N[(b + N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], N[(N[(a + N[(b * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.2 \cdot 10^{-68} \lor \neg \left(d \leq 1.2 \cdot 10^{-31}\right):\\
\;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a + b \cdot \frac{d}{c}}{c}\\
\end{array}
\end{array}
if d < -1.19999999999999996e-68 or 1.2e-31 < d Initial program 60.8%
fma-define60.8%
fma-define60.8%
Simplified60.8%
Taylor expanded in d around inf 76.9%
associate-/l*83.8%
Simplified83.8%
if -1.19999999999999996e-68 < d < 1.2e-31Initial program 73.2%
fma-define73.2%
fma-define73.2%
Simplified73.2%
*-un-lft-identity73.2%
fma-define73.2%
add-sqr-sqrt73.2%
times-frac73.2%
fma-define73.2%
hypot-define73.2%
fma-define73.3%
fma-define73.3%
hypot-define82.6%
Applied egg-rr82.6%
Taylor expanded in c around inf 84.6%
associate-/l*84.6%
Simplified84.6%
Final simplification84.1%
(FPCore (a b c d) :precision binary64 (if (or (<= d -1.3e-68) (not (<= d 7.4e-31))) (/ b d) (/ (+ a (* b (/ d c))) c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -1.3e-68) || !(d <= 7.4e-31)) {
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 <= (-1.3d-68)) .or. (.not. (d <= 7.4d-31))) 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 <= -1.3e-68) || !(d <= 7.4e-31)) {
tmp = b / d;
} else {
tmp = (a + (b * (d / c))) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -1.3e-68) or not (d <= 7.4e-31): tmp = b / d else: tmp = (a + (b * (d / c))) / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -1.3e-68) || !(d <= 7.4e-31)) tmp = Float64(b / d); else tmp = Float64(Float64(a + Float64(b * Float64(d / c))) / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -1.3e-68) || ~((d <= 7.4e-31))) tmp = b / d; else tmp = (a + (b * (d / c))) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -1.3e-68], N[Not[LessEqual[d, 7.4e-31]], $MachinePrecision]], N[(b / d), $MachinePrecision], N[(N[(a + N[(b * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.3 \cdot 10^{-68} \lor \neg \left(d \leq 7.4 \cdot 10^{-31}\right):\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a + b \cdot \frac{d}{c}}{c}\\
\end{array}
\end{array}
if d < -1.2999999999999999e-68 or 7.3999999999999996e-31 < d Initial program 60.5%
fma-define60.5%
fma-define60.5%
Simplified60.5%
Taylor expanded in c around 0 69.0%
if -1.2999999999999999e-68 < d < 7.3999999999999996e-31Initial program 73.4%
fma-define73.4%
fma-define73.4%
Simplified73.4%
*-un-lft-identity73.4%
fma-define73.4%
add-sqr-sqrt73.4%
times-frac73.4%
fma-define73.4%
hypot-define73.5%
fma-define73.5%
fma-define73.5%
hypot-define82.8%
Applied egg-rr82.8%
Taylor expanded in c around inf 83.9%
associate-/l*83.9%
Simplified83.9%
Final simplification75.7%
(FPCore (a b c d) :precision binary64 (if (<= d -1.35e-68) (/ (+ b (* c (/ a d))) d) (if (<= d 1.26e-31) (/ (+ a (* b (/ d c))) c) (/ (+ b (* a (/ c d))) d))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -1.35e-68) {
tmp = (b + (c * (a / d))) / d;
} else if (d <= 1.26e-31) {
tmp = (a + (b * (d / c))) / c;
} else {
tmp = (b + (a * (c / 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.35d-68)) then
tmp = (b + (c * (a / d))) / d
else if (d <= 1.26d-31) then
tmp = (a + (b * (d / c))) / c
else
tmp = (b + (a * (c / 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.35e-68) {
tmp = (b + (c * (a / d))) / d;
} else if (d <= 1.26e-31) {
tmp = (a + (b * (d / c))) / c;
} else {
tmp = (b + (a * (c / d))) / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -1.35e-68: tmp = (b + (c * (a / d))) / d elif d <= 1.26e-31: tmp = (a + (b * (d / c))) / c else: tmp = (b + (a * (c / d))) / d return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -1.35e-68) tmp = Float64(Float64(b + Float64(c * Float64(a / d))) / d); elseif (d <= 1.26e-31) tmp = Float64(Float64(a + Float64(b * Float64(d / c))) / c); else tmp = Float64(Float64(b + Float64(a * Float64(c / d))) / d); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= -1.35e-68) tmp = (b + (c * (a / d))) / d; elseif (d <= 1.26e-31) tmp = (a + (b * (d / c))) / c; else tmp = (b + (a * (c / d))) / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -1.35e-68], N[(N[(b + N[(c * N[(a / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, 1.26e-31], N[(N[(a + N[(b * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], N[(N[(b + N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.35 \cdot 10^{-68}:\\
\;\;\;\;\frac{b + c \cdot \frac{a}{d}}{d}\\
\mathbf{elif}\;d \leq 1.26 \cdot 10^{-31}:\\
\;\;\;\;\frac{a + b \cdot \frac{d}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d}\\
\end{array}
\end{array}
if d < -1.3500000000000001e-68Initial program 66.1%
fma-define66.1%
fma-define66.1%
Simplified66.1%
Taylor expanded in d around inf 77.1%
associate-/l*81.2%
Simplified81.2%
associate-*r/77.1%
*-commutative77.1%
Applied egg-rr77.1%
associate-/l*81.3%
*-commutative81.3%
Applied egg-rr81.3%
if -1.3500000000000001e-68 < d < 1.2599999999999999e-31Initial program 73.2%
fma-define73.2%
fma-define73.2%
Simplified73.2%
*-un-lft-identity73.2%
fma-define73.2%
add-sqr-sqrt73.2%
times-frac73.2%
fma-define73.2%
hypot-define73.2%
fma-define73.3%
fma-define73.3%
hypot-define82.6%
Applied egg-rr82.6%
Taylor expanded in c around inf 84.6%
associate-/l*84.6%
Simplified84.6%
if 1.2599999999999999e-31 < d Initial program 55.7%
fma-define55.7%
fma-define55.7%
Simplified55.7%
Taylor expanded in d around inf 76.7%
associate-/l*86.2%
Simplified86.2%
Final simplification84.2%
(FPCore (a b c d) :precision binary64 (if (or (<= d -1.35e-68) (not (<= d 4.5e-31))) (/ b d) (/ a c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -1.35e-68) || !(d <= 4.5e-31)) {
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 <= (-1.35d-68)) .or. (.not. (d <= 4.5d-31))) 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 <= -1.35e-68) || !(d <= 4.5e-31)) {
tmp = b / d;
} else {
tmp = a / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -1.35e-68) or not (d <= 4.5e-31): tmp = b / d else: tmp = a / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -1.35e-68) || !(d <= 4.5e-31)) 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 <= -1.35e-68) || ~((d <= 4.5e-31))) tmp = b / d; else tmp = a / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -1.35e-68], N[Not[LessEqual[d, 4.5e-31]], $MachinePrecision]], N[(b / d), $MachinePrecision], N[(a / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.35 \cdot 10^{-68} \lor \neg \left(d \leq 4.5 \cdot 10^{-31}\right):\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c}\\
\end{array}
\end{array}
if d < -1.3500000000000001e-68 or 4.5000000000000004e-31 < d Initial program 60.5%
fma-define60.5%
fma-define60.5%
Simplified60.5%
Taylor expanded in c around 0 69.0%
if -1.3500000000000001e-68 < d < 4.5000000000000004e-31Initial program 73.4%
fma-define73.4%
fma-define73.4%
Simplified73.4%
Taylor expanded in c around inf 70.6%
Final simplification69.7%
(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 66.2%
fma-define66.3%
fma-define66.3%
Simplified66.3%
Taylor expanded in c around inf 42.4%
(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 2024125
(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))))