
(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 11 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
(let* ((t_0 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))))
(if (<= t_0 -2e+278)
(/ (+ a (* b (/ d c))) c)
(if (<= t_0 2e+279)
(* (/ 1.0 (hypot c d)) (/ (fma a c (* b d)) (hypot c d)))
(/ (+ b (* a (/ c d))) d)))))
double code(double a, double b, double c, double d) {
double t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d));
double tmp;
if (t_0 <= -2e+278) {
tmp = (a + (b * (d / c))) / c;
} else if (t_0 <= 2e+279) {
tmp = (1.0 / hypot(c, d)) * (fma(a, c, (b * d)) / hypot(c, d));
} else {
tmp = (b + (a * (c / d))) / d;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d))) tmp = 0.0 if (t_0 <= -2e+278) tmp = Float64(Float64(a + Float64(b * Float64(d / c))) / c); elseif (t_0 <= 2e+279) tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(fma(a, c, Float64(b * d)) / hypot(c, d))); else tmp = Float64(Float64(b + Float64(a * Float64(c / d))) / d); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -2e+278], N[(N[(a + N[(b * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[t$95$0, 2e+279], N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(N[(a * c + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b + N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{if}\;t\_0 \leq -2 \cdot 10^{+278}:\\
\;\;\;\;\frac{a + b \cdot \frac{d}{c}}{c}\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+279}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d}\\
\end{array}
\end{array}
if (/.f64 (+.f64 (*.f64 a c) (*.f64 b d)) (+.f64 (*.f64 c c) (*.f64 d d))) < -1.99999999999999993e278Initial program 38.6%
Taylor expanded in c around inf 79.9%
+-commutative79.9%
associate-/l*86.6%
fma-define86.6%
Simplified86.6%
fma-undefine86.6%
Applied egg-rr86.6%
if -1.99999999999999993e278 < (/.f64 (+.f64 (*.f64 a c) (*.f64 b d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 2.00000000000000012e279Initial program 82.9%
*-un-lft-identity82.9%
add-sqr-sqrt82.9%
times-frac82.9%
hypot-define82.9%
fma-define82.9%
hypot-define99.0%
Applied egg-rr99.0%
if 2.00000000000000012e279 < (/.f64 (+.f64 (*.f64 a c) (*.f64 b d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 11.6%
Taylor expanded in d around inf 52.1%
associate-/l*65.6%
Simplified65.6%
Final simplification90.1%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))) (t_1 (* a (/ c d))))
(if (<= d -3.6e+113)
(/ (+ b t_1) d)
(if (<= d -9e-101)
t_0
(if (<= d 1.5e-129)
(/ (+ a (* b (/ d c))) c)
(if (<= d 8.7e+89)
t_0
(/
(+ b (- (- t_1 (* a (pow (/ c d) 3.0))) (* b (pow (/ c d) 2.0))))
d)))))))
double code(double a, double b, double c, double d) {
double t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d));
double t_1 = a * (c / d);
double tmp;
if (d <= -3.6e+113) {
tmp = (b + t_1) / d;
} else if (d <= -9e-101) {
tmp = t_0;
} else if (d <= 1.5e-129) {
tmp = (a + (b * (d / c))) / c;
} else if (d <= 8.7e+89) {
tmp = t_0;
} else {
tmp = (b + ((t_1 - (a * pow((c / d), 3.0))) - (b * pow((c / d), 2.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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d))
t_1 = a * (c / d)
if (d <= (-3.6d+113)) then
tmp = (b + t_1) / d
else if (d <= (-9d-101)) then
tmp = t_0
else if (d <= 1.5d-129) then
tmp = (a + (b * (d / c))) / c
else if (d <= 8.7d+89) then
tmp = t_0
else
tmp = (b + ((t_1 - (a * ((c / d) ** 3.0d0))) - (b * ((c / d) ** 2.0d0)))) / d
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d));
double t_1 = a * (c / d);
double tmp;
if (d <= -3.6e+113) {
tmp = (b + t_1) / d;
} else if (d <= -9e-101) {
tmp = t_0;
} else if (d <= 1.5e-129) {
tmp = (a + (b * (d / c))) / c;
} else if (d <= 8.7e+89) {
tmp = t_0;
} else {
tmp = (b + ((t_1 - (a * Math.pow((c / d), 3.0))) - (b * Math.pow((c / d), 2.0)))) / d;
}
return tmp;
}
def code(a, b, c, d): t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d)) t_1 = a * (c / d) tmp = 0 if d <= -3.6e+113: tmp = (b + t_1) / d elif d <= -9e-101: tmp = t_0 elif d <= 1.5e-129: tmp = (a + (b * (d / c))) / c elif d <= 8.7e+89: tmp = t_0 else: tmp = (b + ((t_1 - (a * math.pow((c / d), 3.0))) - (b * math.pow((c / d), 2.0)))) / d return tmp
function code(a, b, c, d) t_0 = Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d))) t_1 = Float64(a * Float64(c / d)) tmp = 0.0 if (d <= -3.6e+113) tmp = Float64(Float64(b + t_1) / d); elseif (d <= -9e-101) tmp = t_0; elseif (d <= 1.5e-129) tmp = Float64(Float64(a + Float64(b * Float64(d / c))) / c); elseif (d <= 8.7e+89) tmp = t_0; else tmp = Float64(Float64(b + Float64(Float64(t_1 - Float64(a * (Float64(c / d) ^ 3.0))) - Float64(b * (Float64(c / d) ^ 2.0)))) / d); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d)); t_1 = a * (c / d); tmp = 0.0; if (d <= -3.6e+113) tmp = (b + t_1) / d; elseif (d <= -9e-101) tmp = t_0; elseif (d <= 1.5e-129) tmp = (a + (b * (d / c))) / c; elseif (d <= 8.7e+89) tmp = t_0; else tmp = (b + ((t_1 - (a * ((c / d) ^ 3.0))) - (b * ((c / d) ^ 2.0)))) / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -3.6e+113], N[(N[(b + t$95$1), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, -9e-101], t$95$0, If[LessEqual[d, 1.5e-129], N[(N[(a + N[(b * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 8.7e+89], t$95$0, N[(N[(b + N[(N[(t$95$1 - N[(a * N[Power[N[(c / d), $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(b * N[Power[N[(c / d), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\
t_1 := a \cdot \frac{c}{d}\\
\mathbf{if}\;d \leq -3.6 \cdot 10^{+113}:\\
\;\;\;\;\frac{b + t\_1}{d}\\
\mathbf{elif}\;d \leq -9 \cdot 10^{-101}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 1.5 \cdot 10^{-129}:\\
\;\;\;\;\frac{a + b \cdot \frac{d}{c}}{c}\\
\mathbf{elif}\;d \leq 8.7 \cdot 10^{+89}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{b + \left(\left(t\_1 - a \cdot {\left(\frac{c}{d}\right)}^{3}\right) - b \cdot {\left(\frac{c}{d}\right)}^{2}\right)}{d}\\
\end{array}
\end{array}
if d < -3.59999999999999992e113Initial program 26.9%
Taylor expanded in d around inf 76.2%
associate-/l*89.6%
Simplified89.6%
if -3.59999999999999992e113 < d < -8.9999999999999997e-101 or 1.4999999999999999e-129 < d < 8.70000000000000019e89Initial program 87.8%
if -8.9999999999999997e-101 < d < 1.4999999999999999e-129Initial program 72.5%
Taylor expanded in c around inf 89.9%
+-commutative89.9%
associate-/l*89.9%
fma-define89.9%
Simplified89.9%
fma-undefine89.9%
Applied egg-rr89.9%
if 8.70000000000000019e89 < d Initial program 27.5%
*-un-lft-identity27.5%
add-sqr-sqrt27.5%
times-frac27.5%
hypot-define27.5%
fma-define27.5%
hypot-define52.3%
Applied egg-rr52.3%
Taylor expanded in d around inf 51.1%
Simplified88.8%
Final simplification89.0%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))))
(if (<= d -8.2e+118)
(/ (+ b (* a (/ c d))) d)
(if (<= d -4.7e-101)
t_0
(if (<= d 1.85e-131)
(/ (+ a (* b (/ d c))) c)
(if (<= d 1.5e+70) t_0 (/ (+ b (/ a (/ 1.0 (/ c d)))) d)))))))
double code(double a, double b, double c, double d) {
double t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d));
double tmp;
if (d <= -8.2e+118) {
tmp = (b + (a * (c / d))) / d;
} else if (d <= -4.7e-101) {
tmp = t_0;
} else if (d <= 1.85e-131) {
tmp = (a + (b * (d / c))) / c;
} else if (d <= 1.5e+70) {
tmp = t_0;
} else {
tmp = (b + (a / (1.0 / (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) :: t_0
real(8) :: tmp
t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d))
if (d <= (-8.2d+118)) then
tmp = (b + (a * (c / d))) / d
else if (d <= (-4.7d-101)) then
tmp = t_0
else if (d <= 1.85d-131) then
tmp = (a + (b * (d / c))) / c
else if (d <= 1.5d+70) then
tmp = t_0
else
tmp = (b + (a / (1.0d0 / (c / d)))) / d
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d));
double tmp;
if (d <= -8.2e+118) {
tmp = (b + (a * (c / d))) / d;
} else if (d <= -4.7e-101) {
tmp = t_0;
} else if (d <= 1.85e-131) {
tmp = (a + (b * (d / c))) / c;
} else if (d <= 1.5e+70) {
tmp = t_0;
} else {
tmp = (b + (a / (1.0 / (c / d)))) / d;
}
return tmp;
}
def code(a, b, c, d): t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d)) tmp = 0 if d <= -8.2e+118: tmp = (b + (a * (c / d))) / d elif d <= -4.7e-101: tmp = t_0 elif d <= 1.85e-131: tmp = (a + (b * (d / c))) / c elif d <= 1.5e+70: tmp = t_0 else: tmp = (b + (a / (1.0 / (c / d)))) / d return tmp
function code(a, b, c, d) t_0 = Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d))) tmp = 0.0 if (d <= -8.2e+118) tmp = Float64(Float64(b + Float64(a * Float64(c / d))) / d); elseif (d <= -4.7e-101) tmp = t_0; elseif (d <= 1.85e-131) tmp = Float64(Float64(a + Float64(b * Float64(d / c))) / c); elseif (d <= 1.5e+70) tmp = t_0; else tmp = Float64(Float64(b + Float64(a / Float64(1.0 / Float64(c / d)))) / d); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d)); tmp = 0.0; if (d <= -8.2e+118) tmp = (b + (a * (c / d))) / d; elseif (d <= -4.7e-101) tmp = t_0; elseif (d <= 1.85e-131) tmp = (a + (b * (d / c))) / c; elseif (d <= 1.5e+70) tmp = t_0; else tmp = (b + (a / (1.0 / (c / d)))) / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = 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, -8.2e+118], N[(N[(b + N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, -4.7e-101], t$95$0, If[LessEqual[d, 1.85e-131], N[(N[(a + N[(b * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 1.5e+70], t$95$0, N[(N[(b + N[(a / N[(1.0 / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{if}\;d \leq -8.2 \cdot 10^{+118}:\\
\;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d}\\
\mathbf{elif}\;d \leq -4.7 \cdot 10^{-101}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 1.85 \cdot 10^{-131}:\\
\;\;\;\;\frac{a + b \cdot \frac{d}{c}}{c}\\
\mathbf{elif}\;d \leq 1.5 \cdot 10^{+70}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{b + \frac{a}{\frac{1}{\frac{c}{d}}}}{d}\\
\end{array}
\end{array}
if d < -8.1999999999999994e118Initial program 26.9%
Taylor expanded in d around inf 76.2%
associate-/l*89.6%
Simplified89.6%
if -8.1999999999999994e118 < d < -4.6999999999999999e-101 or 1.8500000000000001e-131 < d < 1.49999999999999988e70Initial program 88.8%
if -4.6999999999999999e-101 < d < 1.8500000000000001e-131Initial program 72.5%
Taylor expanded in c around inf 89.9%
+-commutative89.9%
associate-/l*89.9%
fma-define89.9%
Simplified89.9%
fma-undefine89.9%
Applied egg-rr89.9%
if 1.49999999999999988e70 < d Initial program 27.0%
Taylor expanded in d around inf 79.0%
associate-/l*86.7%
Simplified86.7%
clear-num86.7%
un-div-inv86.8%
Applied egg-rr86.8%
clear-num86.8%
inv-pow86.8%
Applied egg-rr86.8%
unpow-186.8%
Simplified86.8%
Final simplification88.9%
(FPCore (a b c d)
:precision binary64
(if (<= d -4.5e-98)
(/ (+ b (* a (/ c d))) d)
(if (<= d 2.5e-76)
(/ (+ a (* b (/ d c))) c)
(if (<= d 3.6e+47)
(/ (* b d) (+ (* c c) (* d d)))
(/ (+ b (/ a (/ 1.0 (/ c d)))) d)))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -4.5e-98) {
tmp = (b + (a * (c / d))) / d;
} else if (d <= 2.5e-76) {
tmp = (a + (b * (d / c))) / c;
} else if (d <= 3.6e+47) {
tmp = (b * d) / ((c * c) + (d * d));
} else {
tmp = (b + (a / (1.0 / (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 <= (-4.5d-98)) then
tmp = (b + (a * (c / d))) / d
else if (d <= 2.5d-76) then
tmp = (a + (b * (d / c))) / c
else if (d <= 3.6d+47) then
tmp = (b * d) / ((c * c) + (d * d))
else
tmp = (b + (a / (1.0d0 / (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 <= -4.5e-98) {
tmp = (b + (a * (c / d))) / d;
} else if (d <= 2.5e-76) {
tmp = (a + (b * (d / c))) / c;
} else if (d <= 3.6e+47) {
tmp = (b * d) / ((c * c) + (d * d));
} else {
tmp = (b + (a / (1.0 / (c / d)))) / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -4.5e-98: tmp = (b + (a * (c / d))) / d elif d <= 2.5e-76: tmp = (a + (b * (d / c))) / c elif d <= 3.6e+47: tmp = (b * d) / ((c * c) + (d * d)) else: tmp = (b + (a / (1.0 / (c / d)))) / d return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -4.5e-98) tmp = Float64(Float64(b + Float64(a * Float64(c / d))) / d); elseif (d <= 2.5e-76) tmp = Float64(Float64(a + Float64(b * Float64(d / c))) / c); elseif (d <= 3.6e+47) tmp = Float64(Float64(b * d) / Float64(Float64(c * c) + Float64(d * d))); else tmp = Float64(Float64(b + Float64(a / Float64(1.0 / Float64(c / d)))) / d); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= -4.5e-98) tmp = (b + (a * (c / d))) / d; elseif (d <= 2.5e-76) tmp = (a + (b * (d / c))) / c; elseif (d <= 3.6e+47) tmp = (b * d) / ((c * c) + (d * d)); else tmp = (b + (a / (1.0 / (c / d)))) / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -4.5e-98], N[(N[(b + N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, 2.5e-76], N[(N[(a + N[(b * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 3.6e+47], N[(N[(b * d), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b + N[(a / N[(1.0 / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -4.5 \cdot 10^{-98}:\\
\;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d}\\
\mathbf{elif}\;d \leq 2.5 \cdot 10^{-76}:\\
\;\;\;\;\frac{a + b \cdot \frac{d}{c}}{c}\\
\mathbf{elif}\;d \leq 3.6 \cdot 10^{+47}:\\
\;\;\;\;\frac{b \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b + \frac{a}{\frac{1}{\frac{c}{d}}}}{d}\\
\end{array}
\end{array}
if d < -4.49999999999999997e-98Initial program 61.2%
Taylor expanded in d around inf 71.2%
associate-/l*77.4%
Simplified77.4%
if -4.49999999999999997e-98 < d < 2.4999999999999999e-76Initial program 74.0%
Taylor expanded in c around inf 87.9%
+-commutative87.9%
associate-/l*87.9%
fma-define87.9%
Simplified87.9%
fma-undefine87.9%
Applied egg-rr87.9%
if 2.4999999999999999e-76 < d < 3.60000000000000008e47Initial program 84.4%
Taylor expanded in a around 0 77.2%
*-commutative77.2%
Simplified77.2%
if 3.60000000000000008e47 < d Initial program 31.4%
Taylor expanded in d around inf 78.3%
associate-/l*85.6%
Simplified85.6%
clear-num85.6%
un-div-inv85.6%
Applied egg-rr85.6%
clear-num85.6%
inv-pow85.6%
Applied egg-rr85.6%
unpow-185.6%
Simplified85.6%
Final simplification83.1%
(FPCore (a b c d)
:precision binary64
(if (<= d -4.5e-98)
(/ (+ b (* a (/ c d))) d)
(if (<= d 1.55e-77)
(/ (+ a (* b (/ d c))) c)
(if (<= d 1e+48)
(/ (* b d) (+ (* c c) (* d d)))
(/ (+ b (/ a (/ d c))) d)))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -4.5e-98) {
tmp = (b + (a * (c / d))) / d;
} else if (d <= 1.55e-77) {
tmp = (a + (b * (d / c))) / c;
} else if (d <= 1e+48) {
tmp = (b * d) / ((c * c) + (d * d));
} else {
tmp = (b + (a / (d / 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 (d <= (-4.5d-98)) then
tmp = (b + (a * (c / d))) / d
else if (d <= 1.55d-77) then
tmp = (a + (b * (d / c))) / c
else if (d <= 1d+48) then
tmp = (b * d) / ((c * c) + (d * d))
else
tmp = (b + (a / (d / c))) / 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-98) {
tmp = (b + (a * (c / d))) / d;
} else if (d <= 1.55e-77) {
tmp = (a + (b * (d / c))) / c;
} else if (d <= 1e+48) {
tmp = (b * d) / ((c * c) + (d * d));
} else {
tmp = (b + (a / (d / c))) / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -4.5e-98: tmp = (b + (a * (c / d))) / d elif d <= 1.55e-77: tmp = (a + (b * (d / c))) / c elif d <= 1e+48: tmp = (b * d) / ((c * c) + (d * d)) else: tmp = (b + (a / (d / c))) / d return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -4.5e-98) tmp = Float64(Float64(b + Float64(a * Float64(c / d))) / d); elseif (d <= 1.55e-77) tmp = Float64(Float64(a + Float64(b * Float64(d / c))) / c); elseif (d <= 1e+48) tmp = Float64(Float64(b * d) / Float64(Float64(c * c) + Float64(d * d))); else tmp = Float64(Float64(b + Float64(a / Float64(d / c))) / d); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= -4.5e-98) tmp = (b + (a * (c / d))) / d; elseif (d <= 1.55e-77) tmp = (a + (b * (d / c))) / c; elseif (d <= 1e+48) tmp = (b * d) / ((c * c) + (d * d)); else tmp = (b + (a / (d / c))) / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -4.5e-98], N[(N[(b + N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, 1.55e-77], N[(N[(a + N[(b * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 1e+48], N[(N[(b * d), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b + N[(a / N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -4.5 \cdot 10^{-98}:\\
\;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d}\\
\mathbf{elif}\;d \leq 1.55 \cdot 10^{-77}:\\
\;\;\;\;\frac{a + b \cdot \frac{d}{c}}{c}\\
\mathbf{elif}\;d \leq 10^{+48}:\\
\;\;\;\;\frac{b \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b + \frac{a}{\frac{d}{c}}}{d}\\
\end{array}
\end{array}
if d < -4.49999999999999997e-98Initial program 61.2%
Taylor expanded in d around inf 71.2%
associate-/l*77.4%
Simplified77.4%
if -4.49999999999999997e-98 < d < 1.55000000000000004e-77Initial program 74.0%
Taylor expanded in c around inf 87.9%
+-commutative87.9%
associate-/l*87.9%
fma-define87.9%
Simplified87.9%
fma-undefine87.9%
Applied egg-rr87.9%
if 1.55000000000000004e-77 < d < 1.00000000000000004e48Initial program 84.4%
Taylor expanded in a around 0 77.2%
*-commutative77.2%
Simplified77.2%
if 1.00000000000000004e48 < d Initial program 31.4%
Taylor expanded in d around inf 78.3%
associate-/l*85.6%
Simplified85.6%
clear-num85.6%
un-div-inv85.6%
Applied egg-rr85.6%
Final simplification83.1%
(FPCore (a b c d) :precision binary64 (if (or (<= d -4.5e-98) (not (<= d 6.8e+50))) (/ (+ b (* a (/ c d))) d) (/ (+ a (/ (* b d) c)) c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -4.5e-98) || !(d <= 6.8e+50)) {
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 <= (-4.5d-98)) .or. (.not. (d <= 6.8d+50))) 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 <= -4.5e-98) || !(d <= 6.8e+50)) {
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 <= -4.5e-98) or not (d <= 6.8e+50): 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 <= -4.5e-98) || !(d <= 6.8e+50)) 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 <= -4.5e-98) || ~((d <= 6.8e+50))) 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, -4.5e-98], N[Not[LessEqual[d, 6.8e+50]], $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 -4.5 \cdot 10^{-98} \lor \neg \left(d \leq 6.8 \cdot 10^{+50}\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 < -4.49999999999999997e-98 or 6.7999999999999997e50 < d Initial program 49.9%
Taylor expanded in d around inf 73.9%
associate-/l*80.5%
Simplified80.5%
if -4.49999999999999997e-98 < d < 6.7999999999999997e50Initial program 76.2%
Taylor expanded in c around inf 81.8%
*-commutative81.8%
Simplified81.8%
Final simplification81.1%
(FPCore (a b c d) :precision binary64 (if (or (<= d -5e-15) (not (<= d 3.7e+54))) (/ b d) (/ (+ a (/ (* b d) c)) c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -5e-15) || !(d <= 3.7e+54)) {
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 <= (-5d-15)) .or. (.not. (d <= 3.7d+54))) 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 <= -5e-15) || !(d <= 3.7e+54)) {
tmp = b / d;
} else {
tmp = (a + ((b * d) / c)) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -5e-15) or not (d <= 3.7e+54): tmp = b / d else: tmp = (a + ((b * d) / c)) / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -5e-15) || !(d <= 3.7e+54)) 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 <= -5e-15) || ~((d <= 3.7e+54))) tmp = b / d; else tmp = (a + ((b * d) / c)) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -5e-15], N[Not[LessEqual[d, 3.7e+54]], $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 -5 \cdot 10^{-15} \lor \neg \left(d \leq 3.7 \cdot 10^{+54}\right):\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a + \frac{b \cdot d}{c}}{c}\\
\end{array}
\end{array}
if d < -4.99999999999999999e-15 or 3.7000000000000002e54 < d Initial program 41.6%
Taylor expanded in c around 0 70.4%
if -4.99999999999999999e-15 < d < 3.7000000000000002e54Initial program 78.7%
Taylor expanded in c around inf 76.7%
*-commutative76.7%
Simplified76.7%
Final simplification74.0%
(FPCore (a b c d) :precision binary64 (if (<= d -3.3e-99) (/ (+ b (* a (/ c d))) d) (if (<= d 5.6e+50) (/ (+ a (* b (/ d c))) c) (/ (+ b (/ a (/ d c))) d))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -3.3e-99) {
tmp = (b + (a * (c / d))) / d;
} else if (d <= 5.6e+50) {
tmp = (a + (b * (d / c))) / c;
} else {
tmp = (b + (a / (d / 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 (d <= (-3.3d-99)) then
tmp = (b + (a * (c / d))) / d
else if (d <= 5.6d+50) then
tmp = (a + (b * (d / c))) / c
else
tmp = (b + (a / (d / c))) / d
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (d <= -3.3e-99) {
tmp = (b + (a * (c / d))) / d;
} else if (d <= 5.6e+50) {
tmp = (a + (b * (d / c))) / c;
} else {
tmp = (b + (a / (d / c))) / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -3.3e-99: tmp = (b + (a * (c / d))) / d elif d <= 5.6e+50: tmp = (a + (b * (d / c))) / c else: tmp = (b + (a / (d / c))) / d return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -3.3e-99) tmp = Float64(Float64(b + Float64(a * Float64(c / d))) / d); elseif (d <= 5.6e+50) tmp = Float64(Float64(a + Float64(b * Float64(d / c))) / c); else tmp = Float64(Float64(b + Float64(a / Float64(d / c))) / d); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= -3.3e-99) tmp = (b + (a * (c / d))) / d; elseif (d <= 5.6e+50) tmp = (a + (b * (d / c))) / c; else tmp = (b + (a / (d / c))) / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -3.3e-99], N[(N[(b + N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, 5.6e+50], N[(N[(a + N[(b * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], N[(N[(b + N[(a / N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -3.3 \cdot 10^{-99}:\\
\;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d}\\
\mathbf{elif}\;d \leq 5.6 \cdot 10^{+50}:\\
\;\;\;\;\frac{a + b \cdot \frac{d}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b + \frac{a}{\frac{d}{c}}}{d}\\
\end{array}
\end{array}
if d < -3.29999999999999986e-99Initial program 61.2%
Taylor expanded in d around inf 71.2%
associate-/l*77.4%
Simplified77.4%
if -3.29999999999999986e-99 < d < 5.5999999999999996e50Initial program 76.2%
Taylor expanded in c around inf 81.8%
+-commutative81.8%
associate-/l*81.8%
fma-define81.8%
Simplified81.8%
fma-undefine81.8%
Applied egg-rr81.8%
if 5.5999999999999996e50 < d Initial program 31.4%
Taylor expanded in d around inf 78.3%
associate-/l*85.6%
Simplified85.6%
clear-num85.6%
un-div-inv85.6%
Applied egg-rr85.6%
Final simplification81.2%
(FPCore (a b c d) :precision binary64 (if (<= d -7.8e-99) (/ (+ b (* a (/ c d))) d) (if (<= d 2.6e+47) (/ (+ a (/ (* b d) c)) c) (/ (+ b (/ a (/ d c))) d))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -7.8e-99) {
tmp = (b + (a * (c / d))) / d;
} else if (d <= 2.6e+47) {
tmp = (a + ((b * d) / c)) / c;
} else {
tmp = (b + (a / (d / 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 (d <= (-7.8d-99)) then
tmp = (b + (a * (c / d))) / d
else if (d <= 2.6d+47) then
tmp = (a + ((b * d) / c)) / c
else
tmp = (b + (a / (d / c))) / d
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (d <= -7.8e-99) {
tmp = (b + (a * (c / d))) / d;
} else if (d <= 2.6e+47) {
tmp = (a + ((b * d) / c)) / c;
} else {
tmp = (b + (a / (d / c))) / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -7.8e-99: tmp = (b + (a * (c / d))) / d elif d <= 2.6e+47: tmp = (a + ((b * d) / c)) / c else: tmp = (b + (a / (d / c))) / d return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -7.8e-99) tmp = Float64(Float64(b + Float64(a * Float64(c / d))) / d); elseif (d <= 2.6e+47) tmp = Float64(Float64(a + Float64(Float64(b * d) / c)) / c); else tmp = Float64(Float64(b + Float64(a / Float64(d / c))) / d); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= -7.8e-99) tmp = (b + (a * (c / d))) / d; elseif (d <= 2.6e+47) tmp = (a + ((b * d) / c)) / c; else tmp = (b + (a / (d / c))) / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -7.8e-99], N[(N[(b + N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, 2.6e+47], N[(N[(a + N[(N[(b * d), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], N[(N[(b + N[(a / N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -7.8 \cdot 10^{-99}:\\
\;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d}\\
\mathbf{elif}\;d \leq 2.6 \cdot 10^{+47}:\\
\;\;\;\;\frac{a + \frac{b \cdot d}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b + \frac{a}{\frac{d}{c}}}{d}\\
\end{array}
\end{array}
if d < -7.79999999999999975e-99Initial program 61.2%
Taylor expanded in d around inf 71.2%
associate-/l*77.4%
Simplified77.4%
if -7.79999999999999975e-99 < d < 2.60000000000000003e47Initial program 76.2%
Taylor expanded in c around inf 81.8%
*-commutative81.8%
Simplified81.8%
if 2.60000000000000003e47 < d Initial program 31.4%
Taylor expanded in d around inf 78.3%
associate-/l*85.6%
Simplified85.6%
clear-num85.6%
un-div-inv85.6%
Applied egg-rr85.6%
Final simplification81.2%
(FPCore (a b c d) :precision binary64 (if (or (<= d -1.45e-99) (not (<= d 3.45e-71))) (/ b d) (/ a c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -1.45e-99) || !(d <= 3.45e-71)) {
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.45d-99)) .or. (.not. (d <= 3.45d-71))) 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.45e-99) || !(d <= 3.45e-71)) {
tmp = b / d;
} else {
tmp = a / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -1.45e-99) or not (d <= 3.45e-71): tmp = b / d else: tmp = a / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -1.45e-99) || !(d <= 3.45e-71)) 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.45e-99) || ~((d <= 3.45e-71))) tmp = b / d; else tmp = a / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -1.45e-99], N[Not[LessEqual[d, 3.45e-71]], $MachinePrecision]], N[(b / d), $MachinePrecision], N[(a / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.45 \cdot 10^{-99} \lor \neg \left(d \leq 3.45 \cdot 10^{-71}\right):\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c}\\
\end{array}
\end{array}
if d < -1.44999999999999993e-99 or 3.4500000000000002e-71 < d Initial program 54.8%
Taylor expanded in c around 0 62.8%
if -1.44999999999999993e-99 < d < 3.4500000000000002e-71Initial program 74.8%
Taylor expanded in c around inf 65.9%
Final simplification64.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 62.9%
Taylor expanded in c around inf 37.7%
(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 2024191
(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))))