
(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 12 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+265)
(* (/ 1.0 (hypot c d)) (/ (fma a c (* b d)) (hypot c d)))
(if (<= t_0 INFINITY)
(/ (+ a (* b (/ d c))) c)
(/ (+ 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+265) {
tmp = (1.0 / hypot(c, d)) * (fma(a, c, (b * d)) / hypot(c, d));
} else if (t_0 <= ((double) INFINITY)) {
tmp = (a + (b * (d / c))) / c;
} 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+265) tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(fma(a, c, Float64(b * d)) / hypot(c, d))); elseif (t_0 <= Inf) 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
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+265], 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], If[LessEqual[t$95$0, Infinity], 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}
t_0 := \frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{if}\;t\_0 \leq 2 \cdot 10^{+265}:\\
\;\;\;\;\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{elif}\;t\_0 \leq \infty:\\
\;\;\;\;\frac{a + b \cdot \frac{d}{c}}{c}\\
\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))) < 2.00000000000000013e265Initial program 80.5%
*-un-lft-identity80.5%
add-sqr-sqrt80.5%
times-frac80.4%
hypot-define80.4%
fma-define80.4%
hypot-define96.8%
Applied egg-rr96.8%
if 2.00000000000000013e265 < (/.f64 (+.f64 (*.f64 a c) (*.f64 b d)) (+.f64 (*.f64 c c) (*.f64 d d))) < +inf.0Initial program 55.3%
Taylor expanded in c around inf 94.5%
associate-/l*94.6%
Simplified94.6%
if +inf.0 < (/.f64 (+.f64 (*.f64 a c) (*.f64 b d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 0.0%
*-un-lft-identity0.0%
add-sqr-sqrt0.0%
times-frac0.0%
hypot-define0.0%
fma-define0.0%
hypot-define2.8%
Applied egg-rr2.8%
Taylor expanded in d around inf 55.8%
associate-/l*66.5%
Simplified66.5%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))))
(t_1 (* (/ d (hypot c d)) (/ b (hypot c d)))))
(if (<= d -9.5e+143)
t_1
(if (<= d -1.6e-52)
t_0
(if (<= d 5.8e-146)
(/ (+ a (/ 1.0 (/ c (* b d)))) c)
(if (<= d 6.5e+144) t_0 t_1))))))
double code(double a, double b, double c, double d) {
double t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d));
double t_1 = (d / hypot(c, d)) * (b / hypot(c, d));
double tmp;
if (d <= -9.5e+143) {
tmp = t_1;
} else if (d <= -1.6e-52) {
tmp = t_0;
} else if (d <= 5.8e-146) {
tmp = (a + (1.0 / (c / (b * d)))) / c;
} else if (d <= 6.5e+144) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
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 = (d / Math.hypot(c, d)) * (b / Math.hypot(c, d));
double tmp;
if (d <= -9.5e+143) {
tmp = t_1;
} else if (d <= -1.6e-52) {
tmp = t_0;
} else if (d <= 5.8e-146) {
tmp = (a + (1.0 / (c / (b * d)))) / c;
} else if (d <= 6.5e+144) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(a, b, c, d): t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d)) t_1 = (d / math.hypot(c, d)) * (b / math.hypot(c, d)) tmp = 0 if d <= -9.5e+143: tmp = t_1 elif d <= -1.6e-52: tmp = t_0 elif d <= 5.8e-146: tmp = (a + (1.0 / (c / (b * d)))) / c elif d <= 6.5e+144: tmp = t_0 else: tmp = t_1 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(Float64(d / hypot(c, d)) * Float64(b / hypot(c, d))) tmp = 0.0 if (d <= -9.5e+143) tmp = t_1; elseif (d <= -1.6e-52) tmp = t_0; elseif (d <= 5.8e-146) tmp = Float64(Float64(a + Float64(1.0 / Float64(c / Float64(b * d)))) / c); elseif (d <= 6.5e+144) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d)); t_1 = (d / hypot(c, d)) * (b / hypot(c, d)); tmp = 0.0; if (d <= -9.5e+143) tmp = t_1; elseif (d <= -1.6e-52) tmp = t_0; elseif (d <= 5.8e-146) tmp = (a + (1.0 / (c / (b * d)))) / c; elseif (d <= 6.5e+144) tmp = t_0; else tmp = t_1; 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[(N[(d / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -9.5e+143], t$95$1, If[LessEqual[d, -1.6e-52], t$95$0, If[LessEqual[d, 5.8e-146], N[(N[(a + N[(1.0 / N[(c / N[(b * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 6.5e+144], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\
t_1 := \frac{d}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{if}\;d \leq -9.5 \cdot 10^{+143}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d \leq -1.6 \cdot 10^{-52}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 5.8 \cdot 10^{-146}:\\
\;\;\;\;\frac{a + \frac{1}{\frac{c}{b \cdot d}}}{c}\\
\mathbf{elif}\;d \leq 6.5 \cdot 10^{+144}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if d < -9.50000000000000066e143 or 6.50000000000000007e144 < d Initial program 40.5%
Taylor expanded in a around 0 40.5%
*-commutative40.5%
Simplified40.5%
add-sqr-sqrt40.5%
hypot-undefine40.5%
hypot-undefine40.5%
times-frac95.2%
Applied egg-rr95.2%
if -9.50000000000000066e143 < d < -1.60000000000000005e-52 or 5.80000000000000022e-146 < d < 6.50000000000000007e144Initial program 88.7%
if -1.60000000000000005e-52 < d < 5.80000000000000022e-146Initial program 63.7%
Taylor expanded in c around inf 88.4%
clear-num88.4%
inv-pow88.4%
*-commutative88.4%
Applied egg-rr88.4%
unpow-188.4%
*-commutative88.4%
Simplified88.4%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))))
(if (<= d -6.5e+90)
(+ (/ b d) (/ (/ a d) (/ d c)))
(if (<= d -1.45e-52)
t_0
(if (<= d 6.6e-143)
(/ (+ a (/ 1.0 (/ c (* b d)))) c)
(if (<= d 6.8e+124) t_0 (+ (/ b d) (/ c (* d (/ d a))))))))))
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 <= -6.5e+90) {
tmp = (b / d) + ((a / d) / (d / c));
} else if (d <= -1.45e-52) {
tmp = t_0;
} else if (d <= 6.6e-143) {
tmp = (a + (1.0 / (c / (b * d)))) / c;
} else if (d <= 6.8e+124) {
tmp = t_0;
} else {
tmp = (b / d) + (c / (d * (d / a)));
}
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 <= (-6.5d+90)) then
tmp = (b / d) + ((a / d) / (d / c))
else if (d <= (-1.45d-52)) then
tmp = t_0
else if (d <= 6.6d-143) then
tmp = (a + (1.0d0 / (c / (b * d)))) / c
else if (d <= 6.8d+124) then
tmp = t_0
else
tmp = (b / d) + (c / (d * (d / a)))
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 <= -6.5e+90) {
tmp = (b / d) + ((a / d) / (d / c));
} else if (d <= -1.45e-52) {
tmp = t_0;
} else if (d <= 6.6e-143) {
tmp = (a + (1.0 / (c / (b * d)))) / c;
} else if (d <= 6.8e+124) {
tmp = t_0;
} else {
tmp = (b / d) + (c / (d * (d / a)));
}
return tmp;
}
def code(a, b, c, d): t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d)) tmp = 0 if d <= -6.5e+90: tmp = (b / d) + ((a / d) / (d / c)) elif d <= -1.45e-52: tmp = t_0 elif d <= 6.6e-143: tmp = (a + (1.0 / (c / (b * d)))) / c elif d <= 6.8e+124: tmp = t_0 else: tmp = (b / d) + (c / (d * (d / a))) 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 <= -6.5e+90) tmp = Float64(Float64(b / d) + Float64(Float64(a / d) / Float64(d / c))); elseif (d <= -1.45e-52) tmp = t_0; elseif (d <= 6.6e-143) tmp = Float64(Float64(a + Float64(1.0 / Float64(c / Float64(b * d)))) / c); elseif (d <= 6.8e+124) tmp = t_0; else tmp = Float64(Float64(b / d) + Float64(c / Float64(d * Float64(d / a)))); 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 <= -6.5e+90) tmp = (b / d) + ((a / d) / (d / c)); elseif (d <= -1.45e-52) tmp = t_0; elseif (d <= 6.6e-143) tmp = (a + (1.0 / (c / (b * d)))) / c; elseif (d <= 6.8e+124) tmp = t_0; else tmp = (b / d) + (c / (d * (d / a))); 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, -6.5e+90], N[(N[(b / d), $MachinePrecision] + N[(N[(a / d), $MachinePrecision] / N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -1.45e-52], t$95$0, If[LessEqual[d, 6.6e-143], N[(N[(a + N[(1.0 / N[(c / N[(b * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 6.8e+124], t$95$0, N[(N[(b / d), $MachinePrecision] + N[(c / N[(d * N[(d / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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 -6.5 \cdot 10^{+90}:\\
\;\;\;\;\frac{b}{d} + \frac{\frac{a}{d}}{\frac{d}{c}}\\
\mathbf{elif}\;d \leq -1.45 \cdot 10^{-52}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 6.6 \cdot 10^{-143}:\\
\;\;\;\;\frac{a + \frac{1}{\frac{c}{b \cdot d}}}{c}\\
\mathbf{elif}\;d \leq 6.8 \cdot 10^{+124}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d} + \frac{c}{d \cdot \frac{d}{a}}\\
\end{array}
\end{array}
if d < -6.5000000000000001e90Initial program 53.0%
Taylor expanded in c around 0 85.7%
*-commutative85.7%
pow285.7%
times-frac87.6%
Applied egg-rr87.6%
*-commutative87.6%
clear-num87.7%
un-div-inv87.7%
Applied egg-rr87.7%
if -6.5000000000000001e90 < d < -1.4500000000000001e-52 or 6.6000000000000001e-143 < d < 6.8e124Initial program 89.9%
if -1.4500000000000001e-52 < d < 6.6000000000000001e-143Initial program 63.7%
Taylor expanded in c around inf 88.4%
clear-num88.4%
inv-pow88.4%
*-commutative88.4%
Applied egg-rr88.4%
unpow-188.4%
*-commutative88.4%
Simplified88.4%
if 6.8e124 < d Initial program 34.2%
Taylor expanded in c around 0 88.9%
*-commutative88.9%
pow288.9%
times-frac94.6%
Applied egg-rr94.6%
*-commutative94.6%
clear-num94.6%
frac-times94.7%
*-un-lft-identity94.7%
Applied egg-rr94.7%
Final simplification89.5%
(FPCore (a b c d)
:precision binary64
(if (<= d -3.5e-39)
(+ (/ b d) (/ (/ a d) (/ d c)))
(if (<= d 2.8e-125)
(/ (+ a (/ 1.0 (/ c (* b d)))) c)
(/ (+ b (/ a (/ d c))) d))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -3.5e-39) {
tmp = (b / d) + ((a / d) / (d / c));
} else if (d <= 2.8e-125) {
tmp = (a + (1.0 / (c / (b * d)))) / 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.5d-39)) then
tmp = (b / d) + ((a / d) / (d / c))
else if (d <= 2.8d-125) then
tmp = (a + (1.0d0 / (c / (b * d)))) / 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.5e-39) {
tmp = (b / d) + ((a / d) / (d / c));
} else if (d <= 2.8e-125) {
tmp = (a + (1.0 / (c / (b * d)))) / c;
} else {
tmp = (b + (a / (d / c))) / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -3.5e-39: tmp = (b / d) + ((a / d) / (d / c)) elif d <= 2.8e-125: tmp = (a + (1.0 / (c / (b * d)))) / c else: tmp = (b + (a / (d / c))) / d return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -3.5e-39) tmp = Float64(Float64(b / d) + Float64(Float64(a / d) / Float64(d / c))); elseif (d <= 2.8e-125) tmp = Float64(Float64(a + Float64(1.0 / Float64(c / Float64(b * d)))) / 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.5e-39) tmp = (b / d) + ((a / d) / (d / c)); elseif (d <= 2.8e-125) tmp = (a + (1.0 / (c / (b * d)))) / c; else tmp = (b + (a / (d / c))) / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -3.5e-39], N[(N[(b / d), $MachinePrecision] + N[(N[(a / d), $MachinePrecision] / N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.8e-125], N[(N[(a + N[(1.0 / N[(c / N[(b * d), $MachinePrecision]), $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.5 \cdot 10^{-39}:\\
\;\;\;\;\frac{b}{d} + \frac{\frac{a}{d}}{\frac{d}{c}}\\
\mathbf{elif}\;d \leq 2.8 \cdot 10^{-125}:\\
\;\;\;\;\frac{a + \frac{1}{\frac{c}{b \cdot d}}}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b + \frac{a}{\frac{d}{c}}}{d}\\
\end{array}
\end{array}
if d < -3.5e-39Initial program 63.7%
Taylor expanded in c around 0 82.0%
*-commutative82.0%
pow282.0%
times-frac83.4%
Applied egg-rr83.4%
*-commutative83.4%
clear-num83.4%
un-div-inv83.4%
Applied egg-rr83.4%
if -3.5e-39 < d < 2.8e-125Initial program 65.5%
Taylor expanded in c around inf 85.8%
clear-num85.8%
inv-pow85.8%
*-commutative85.8%
Applied egg-rr85.8%
unpow-185.8%
*-commutative85.8%
Simplified85.8%
if 2.8e-125 < d Initial program 63.5%
*-un-lft-identity63.5%
add-sqr-sqrt63.5%
times-frac63.5%
hypot-define63.5%
fma-define63.5%
hypot-define72.2%
Applied egg-rr72.2%
Taylor expanded in d around inf 82.1%
associate-/l*83.3%
Simplified83.3%
clear-num83.4%
un-div-inv83.4%
Applied egg-rr83.4%
(FPCore (a b c d) :precision binary64 (if (or (<= d -1.7e-51) (not (<= d 1.5e-126))) (/ (+ 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.7e-51) || !(d <= 1.5e-126)) {
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.7d-51)) .or. (.not. (d <= 1.5d-126))) 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.7e-51) || !(d <= 1.5e-126)) {
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.7e-51) or not (d <= 1.5e-126): 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.7e-51) || !(d <= 1.5e-126)) 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 <= -1.7e-51) || ~((d <= 1.5e-126))) 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.7e-51], N[Not[LessEqual[d, 1.5e-126]], $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 -1.7 \cdot 10^{-51} \lor \neg \left(d \leq 1.5 \cdot 10^{-126}\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 < -1.70000000000000001e-51 or 1.5000000000000001e-126 < d Initial program 63.6%
*-un-lft-identity63.6%
add-sqr-sqrt63.6%
times-frac63.6%
hypot-define63.6%
fma-define63.6%
hypot-define75.5%
Applied egg-rr75.5%
Taylor expanded in d around inf 81.2%
associate-/l*81.8%
Simplified81.8%
if -1.70000000000000001e-51 < d < 1.5000000000000001e-126Initial program 65.4%
Taylor expanded in c around inf 87.2%
Final simplification84.0%
(FPCore (a b c d) :precision binary64 (if (or (<= d -2.3e-24) (not (<= d 1.8e-103))) (/ b d) (/ (+ a (/ (* b d) c)) c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -2.3e-24) || !(d <= 1.8e-103)) {
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 <= (-2.3d-24)) .or. (.not. (d <= 1.8d-103))) 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 <= -2.3e-24) || !(d <= 1.8e-103)) {
tmp = b / d;
} else {
tmp = (a + ((b * d) / c)) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -2.3e-24) or not (d <= 1.8e-103): tmp = b / d else: tmp = (a + ((b * d) / c)) / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -2.3e-24) || !(d <= 1.8e-103)) 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 <= -2.3e-24) || ~((d <= 1.8e-103))) tmp = b / d; else tmp = (a + ((b * d) / c)) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -2.3e-24], N[Not[LessEqual[d, 1.8e-103]], $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 -2.3 \cdot 10^{-24} \lor \neg \left(d \leq 1.8 \cdot 10^{-103}\right):\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a + \frac{b \cdot d}{c}}{c}\\
\end{array}
\end{array}
if d < -2.3000000000000001e-24 or 1.7999999999999999e-103 < d Initial program 62.3%
Taylor expanded in c around 0 74.3%
if -2.3000000000000001e-24 < d < 1.7999999999999999e-103Initial program 67.0%
Taylor expanded in c around inf 83.9%
Final simplification78.5%
(FPCore (a b c d) :precision binary64 (if (or (<= d -1.05e-27) (not (<= d 1.8e-103))) (/ b d) (/ (+ a (* b (/ d c))) c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -1.05e-27) || !(d <= 1.8e-103)) {
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.05d-27)) .or. (.not. (d <= 1.8d-103))) 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.05e-27) || !(d <= 1.8e-103)) {
tmp = b / d;
} else {
tmp = (a + (b * (d / c))) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -1.05e-27) or not (d <= 1.8e-103): tmp = b / d else: tmp = (a + (b * (d / c))) / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -1.05e-27) || !(d <= 1.8e-103)) 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.05e-27) || ~((d <= 1.8e-103))) 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.05e-27], N[Not[LessEqual[d, 1.8e-103]], $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.05 \cdot 10^{-27} \lor \neg \left(d \leq 1.8 \cdot 10^{-103}\right):\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a + b \cdot \frac{d}{c}}{c}\\
\end{array}
\end{array}
if d < -1.05000000000000008e-27 or 1.7999999999999999e-103 < d Initial program 62.3%
Taylor expanded in c around 0 74.3%
if -1.05000000000000008e-27 < d < 1.7999999999999999e-103Initial program 67.0%
Taylor expanded in c around inf 83.9%
associate-/l*83.7%
Simplified83.7%
Final simplification78.4%
(FPCore (a b c d) :precision binary64 (if (<= d -5.5e-38) (+ (/ b d) (/ (/ a d) (/ d c))) (if (<= d 2.8e-125) (/ (+ a (/ (* b d) c)) c) (/ (+ b (/ a (/ d c))) d))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -5.5e-38) {
tmp = (b / d) + ((a / d) / (d / c));
} else if (d <= 2.8e-125) {
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 <= (-5.5d-38)) then
tmp = (b / d) + ((a / d) / (d / c))
else if (d <= 2.8d-125) 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 <= -5.5e-38) {
tmp = (b / d) + ((a / d) / (d / c));
} else if (d <= 2.8e-125) {
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 <= -5.5e-38: tmp = (b / d) + ((a / d) / (d / c)) elif d <= 2.8e-125: 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 <= -5.5e-38) tmp = Float64(Float64(b / d) + Float64(Float64(a / d) / Float64(d / c))); elseif (d <= 2.8e-125) 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 <= -5.5e-38) tmp = (b / d) + ((a / d) / (d / c)); elseif (d <= 2.8e-125) 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, -5.5e-38], N[(N[(b / d), $MachinePrecision] + N[(N[(a / d), $MachinePrecision] / N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.8e-125], 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 -5.5 \cdot 10^{-38}:\\
\;\;\;\;\frac{b}{d} + \frac{\frac{a}{d}}{\frac{d}{c}}\\
\mathbf{elif}\;d \leq 2.8 \cdot 10^{-125}:\\
\;\;\;\;\frac{a + \frac{b \cdot d}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b + \frac{a}{\frac{d}{c}}}{d}\\
\end{array}
\end{array}
if d < -5.50000000000000005e-38Initial program 63.7%
Taylor expanded in c around 0 82.0%
*-commutative82.0%
pow282.0%
times-frac83.4%
Applied egg-rr83.4%
*-commutative83.4%
clear-num83.4%
un-div-inv83.4%
Applied egg-rr83.4%
if -5.50000000000000005e-38 < d < 2.8e-125Initial program 65.5%
Taylor expanded in c around inf 85.8%
if 2.8e-125 < d Initial program 63.5%
*-un-lft-identity63.5%
add-sqr-sqrt63.5%
times-frac63.5%
hypot-define63.5%
fma-define63.5%
hypot-define72.2%
Applied egg-rr72.2%
Taylor expanded in d around inf 82.1%
associate-/l*83.3%
Simplified83.3%
clear-num83.4%
un-div-inv83.4%
Applied egg-rr83.4%
(FPCore (a b c d) :precision binary64 (if (<= d -2.1e-35) (+ (/ b d) (* (/ c d) (/ a d))) (if (<= d 2.7e-125) (/ (+ a (/ (* b d) c)) c) (/ (+ b (/ a (/ d c))) d))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -2.1e-35) {
tmp = (b / d) + ((c / d) * (a / d));
} else if (d <= 2.7e-125) {
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 <= (-2.1d-35)) then
tmp = (b / d) + ((c / d) * (a / d))
else if (d <= 2.7d-125) 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 <= -2.1e-35) {
tmp = (b / d) + ((c / d) * (a / d));
} else if (d <= 2.7e-125) {
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 <= -2.1e-35: tmp = (b / d) + ((c / d) * (a / d)) elif d <= 2.7e-125: 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 <= -2.1e-35) tmp = Float64(Float64(b / d) + Float64(Float64(c / d) * Float64(a / d))); elseif (d <= 2.7e-125) 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 <= -2.1e-35) tmp = (b / d) + ((c / d) * (a / d)); elseif (d <= 2.7e-125) 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, -2.1e-35], N[(N[(b / d), $MachinePrecision] + N[(N[(c / d), $MachinePrecision] * N[(a / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.7e-125], 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 -2.1 \cdot 10^{-35}:\\
\;\;\;\;\frac{b}{d} + \frac{c}{d} \cdot \frac{a}{d}\\
\mathbf{elif}\;d \leq 2.7 \cdot 10^{-125}:\\
\;\;\;\;\frac{a + \frac{b \cdot d}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b + \frac{a}{\frac{d}{c}}}{d}\\
\end{array}
\end{array}
if d < -2.1e-35Initial program 63.7%
Taylor expanded in c around 0 82.0%
*-commutative82.0%
pow282.0%
times-frac83.4%
Applied egg-rr83.4%
if -2.1e-35 < d < 2.6999999999999998e-125Initial program 65.5%
Taylor expanded in c around inf 85.8%
if 2.6999999999999998e-125 < d Initial program 63.5%
*-un-lft-identity63.5%
add-sqr-sqrt63.5%
times-frac63.5%
hypot-define63.5%
fma-define63.5%
hypot-define72.2%
Applied egg-rr72.2%
Taylor expanded in d around inf 82.1%
associate-/l*83.3%
Simplified83.3%
clear-num83.4%
un-div-inv83.4%
Applied egg-rr83.4%
(FPCore (a b c d) :precision binary64 (if (<= d -4.8e-51) (/ (+ b (* a (/ c d))) d) (if (<= d 2.8e-125) (/ (+ a (/ (* b d) c)) c) (/ (+ b (/ a (/ d c))) d))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -4.8e-51) {
tmp = (b + (a * (c / d))) / d;
} else if (d <= 2.8e-125) {
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 <= (-4.8d-51)) then
tmp = (b + (a * (c / d))) / d
else if (d <= 2.8d-125) 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 <= -4.8e-51) {
tmp = (b + (a * (c / d))) / d;
} else if (d <= 2.8e-125) {
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 <= -4.8e-51: tmp = (b + (a * (c / d))) / d elif d <= 2.8e-125: 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 <= -4.8e-51) tmp = Float64(Float64(b + Float64(a * Float64(c / d))) / d); elseif (d <= 2.8e-125) 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 <= -4.8e-51) tmp = (b + (a * (c / d))) / d; elseif (d <= 2.8e-125) 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, -4.8e-51], N[(N[(b + N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, 2.8e-125], 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 -4.8 \cdot 10^{-51}:\\
\;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d}\\
\mathbf{elif}\;d \leq 2.8 \cdot 10^{-125}:\\
\;\;\;\;\frac{a + \frac{b \cdot d}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b + \frac{a}{\frac{d}{c}}}{d}\\
\end{array}
\end{array}
if d < -4.8e-51Initial program 63.8%
*-un-lft-identity63.8%
add-sqr-sqrt63.8%
times-frac63.7%
hypot-define63.7%
fma-define63.7%
hypot-define78.6%
Applied egg-rr78.6%
Taylor expanded in d around inf 80.3%
associate-/l*80.4%
Simplified80.4%
if -4.8e-51 < d < 2.8e-125Initial program 65.4%
Taylor expanded in c around inf 87.2%
if 2.8e-125 < d Initial program 63.5%
*-un-lft-identity63.5%
add-sqr-sqrt63.5%
times-frac63.5%
hypot-define63.5%
fma-define63.5%
hypot-define72.2%
Applied egg-rr72.2%
Taylor expanded in d around inf 82.1%
associate-/l*83.3%
Simplified83.3%
clear-num83.4%
un-div-inv83.4%
Applied egg-rr83.4%
(FPCore (a b c d) :precision binary64 (if (or (<= d -3.3e-73) (not (<= d 1.15e-141))) (/ b d) (/ a c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -3.3e-73) || !(d <= 1.15e-141)) {
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 <= (-3.3d-73)) .or. (.not. (d <= 1.15d-141))) 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 <= -3.3e-73) || !(d <= 1.15e-141)) {
tmp = b / d;
} else {
tmp = a / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -3.3e-73) or not (d <= 1.15e-141): tmp = b / d else: tmp = a / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -3.3e-73) || !(d <= 1.15e-141)) 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 <= -3.3e-73) || ~((d <= 1.15e-141))) tmp = b / d; else tmp = a / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -3.3e-73], N[Not[LessEqual[d, 1.15e-141]], $MachinePrecision]], N[(b / d), $MachinePrecision], N[(a / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -3.3 \cdot 10^{-73} \lor \neg \left(d \leq 1.15 \cdot 10^{-141}\right):\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c}\\
\end{array}
\end{array}
if d < -3.30000000000000004e-73 or 1.14999999999999997e-141 < d Initial program 64.8%
Taylor expanded in c around 0 71.2%
if -3.30000000000000004e-73 < d < 1.14999999999999997e-141Initial program 63.5%
Taylor expanded in c around inf 75.1%
Final simplification72.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 64.4%
Taylor expanded in c around inf 38.6%
(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 2024143
(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))))