
(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
(let* ((t_0 (+ a (* b (/ d c)))))
(if (<= c -9.2e+132)
(* t_0 (/ -1.0 (hypot c d)))
(if (<= c 4.3e+98)
(/ (fma a (/ c d) b) (* (hypot c d) (/ (hypot c d) d)))
(* (/ 1.0 (hypot c d)) t_0)))))
double code(double a, double b, double c, double d) {
double t_0 = a + (b * (d / c));
double tmp;
if (c <= -9.2e+132) {
tmp = t_0 * (-1.0 / hypot(c, d));
} else if (c <= 4.3e+98) {
tmp = fma(a, (c / d), b) / (hypot(c, d) * (hypot(c, d) / d));
} else {
tmp = (1.0 / hypot(c, d)) * t_0;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(a + Float64(b * Float64(d / c))) tmp = 0.0 if (c <= -9.2e+132) tmp = Float64(t_0 * Float64(-1.0 / hypot(c, d))); elseif (c <= 4.3e+98) tmp = Float64(fma(a, Float64(c / d), b) / Float64(hypot(c, d) * Float64(hypot(c, d) / d))); else tmp = Float64(Float64(1.0 / hypot(c, d)) * t_0); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(a + N[(b * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -9.2e+132], N[(t$95$0 * N[(-1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 4.3e+98], N[(N[(a * N[(c / d), $MachinePrecision] + b), $MachinePrecision] / N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] * N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := a + b \cdot \frac{d}{c}\\
\mathbf{if}\;c \leq -9.2 \cdot 10^{+132}:\\
\;\;\;\;t\_0 \cdot \frac{-1}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;c \leq 4.3 \cdot 10^{+98}:\\
\;\;\;\;\frac{\mathsf{fma}\left(a, \frac{c}{d}, b\right)}{\mathsf{hypot}\left(c, d\right) \cdot \frac{\mathsf{hypot}\left(c, d\right)}{d}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot t\_0\\
\end{array}
\end{array}
if c < -9.2000000000000006e132Initial program 41.4%
*-un-lft-identity41.4%
associate-*r/41.4%
fma-define41.4%
add-sqr-sqrt41.4%
times-frac41.4%
fma-define41.4%
hypot-define41.4%
fma-define41.4%
fma-define41.4%
hypot-define57.5%
Applied egg-rr57.5%
Taylor expanded in c around -inf 77.8%
distribute-lft-out77.8%
associate-/l*85.7%
Simplified85.7%
if -9.2000000000000006e132 < c < 4.3000000000000001e98Initial program 69.4%
Taylor expanded in d around inf 65.4%
associate-/l*63.8%
Simplified63.8%
*-commutative63.8%
add-sqr-sqrt63.8%
hypot-undefine63.8%
hypot-undefine63.8%
times-frac87.7%
+-commutative87.7%
fma-define87.7%
Applied egg-rr87.7%
clear-num87.6%
frac-times91.5%
*-commutative91.5%
*-un-lft-identity91.5%
Applied egg-rr91.5%
if 4.3000000000000001e98 < c Initial program 38.6%
*-un-lft-identity38.6%
associate-*r/38.6%
fma-define38.6%
add-sqr-sqrt38.6%
times-frac38.6%
fma-define38.6%
hypot-define38.6%
fma-define38.6%
fma-define38.6%
hypot-define57.9%
Applied egg-rr57.9%
Taylor expanded in c around inf 89.9%
associate-/l*93.7%
Simplified93.7%
Final simplification90.9%
(FPCore (a b c d)
:precision binary64
(if (<= d -1.55e+77)
(/ (- (- b) (* c (/ a d))) (hypot c d))
(if (<= d -1.45e-65)
(/ (+ (* d b) (* c a)) (+ (* c c) (* d d)))
(if (<= d 1.5e-67)
(/ (+ a (/ (* d b) c)) c)
(if (<= d 5.3e+100)
(/ (fma a c (* d b)) (fma c c (* d d)))
(* (/ d (hypot d c)) (/ b (hypot d c))))))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -1.55e+77) {
tmp = (-b - (c * (a / d))) / hypot(c, d);
} else if (d <= -1.45e-65) {
tmp = ((d * b) + (c * a)) / ((c * c) + (d * d));
} else if (d <= 1.5e-67) {
tmp = (a + ((d * b) / c)) / c;
} else if (d <= 5.3e+100) {
tmp = fma(a, c, (d * b)) / fma(c, c, (d * d));
} else {
tmp = (d / hypot(d, c)) * (b / hypot(d, c));
}
return tmp;
}
function code(a, b, c, d) tmp = 0.0 if (d <= -1.55e+77) tmp = Float64(Float64(Float64(-b) - Float64(c * Float64(a / d))) / hypot(c, d)); elseif (d <= -1.45e-65) tmp = Float64(Float64(Float64(d * b) + Float64(c * a)) / Float64(Float64(c * c) + Float64(d * d))); elseif (d <= 1.5e-67) tmp = Float64(Float64(a + Float64(Float64(d * b) / c)) / c); elseif (d <= 5.3e+100) tmp = Float64(fma(a, c, Float64(d * b)) / fma(c, c, Float64(d * d))); else tmp = Float64(Float64(d / hypot(d, c)) * Float64(b / hypot(d, c))); end return tmp end
code[a_, b_, c_, d_] := If[LessEqual[d, -1.55e+77], N[(N[((-b) - N[(c * N[(a / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -1.45e-65], N[(N[(N[(d * b), $MachinePrecision] + N[(c * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.5e-67], N[(N[(a + N[(N[(d * b), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 5.3e+100], N[(N[(a * c + N[(d * b), $MachinePrecision]), $MachinePrecision] / N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(d / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.55 \cdot 10^{+77}:\\
\;\;\;\;\frac{\left(-b\right) - c \cdot \frac{a}{d}}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;d \leq -1.45 \cdot 10^{-65}:\\
\;\;\;\;\frac{d \cdot b + c \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;d \leq 1.5 \cdot 10^{-67}:\\
\;\;\;\;\frac{a + \frac{d \cdot b}{c}}{c}\\
\mathbf{elif}\;d \leq 5.3 \cdot 10^{+100}:\\
\;\;\;\;\frac{\mathsf{fma}\left(a, c, d \cdot b\right)}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\mathsf{hypot}\left(d, c\right)} \cdot \frac{b}{\mathsf{hypot}\left(d, c\right)}\\
\end{array}
\end{array}
if d < -1.54999999999999999e77Initial program 44.6%
Taylor expanded in d around inf 44.6%
associate-/l*42.8%
Simplified42.8%
*-commutative42.8%
add-sqr-sqrt42.8%
hypot-undefine42.8%
hypot-undefine42.8%
times-frac92.2%
+-commutative92.2%
fma-define92.2%
Applied egg-rr92.2%
fma-undefine92.2%
+-commutative92.2%
clear-num92.2%
un-div-inv92.2%
Applied egg-rr92.2%
associate-/r/94.1%
Simplified94.1%
Taylor expanded in d around -inf 89.5%
if -1.54999999999999999e77 < d < -1.4499999999999999e-65Initial program 91.9%
if -1.4499999999999999e-65 < d < 1.50000000000000016e-67Initial program 61.5%
Taylor expanded in c around inf 83.1%
if 1.50000000000000016e-67 < d < 5.2999999999999998e100Initial program 81.1%
fma-define81.1%
fma-define81.2%
Simplified81.2%
if 5.2999999999999998e100 < d Initial program 31.9%
Taylor expanded in a around 0 31.9%
*-commutative31.9%
fma-define31.9%
add-sqr-sqrt31.9%
fma-define31.9%
hypot-undefine31.9%
fma-define31.9%
hypot-undefine31.9%
times-frac90.9%
Applied egg-rr90.9%
hypot-undefine36.5%
unpow236.5%
unpow236.5%
+-commutative36.5%
unpow236.5%
unpow236.5%
hypot-define90.9%
hypot-undefine36.5%
unpow236.5%
unpow236.5%
+-commutative36.5%
unpow236.5%
unpow236.5%
hypot-define90.9%
Simplified90.9%
Final simplification86.3%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (+ (* d b) (* c a)) (+ (* c c) (* d d)))))
(if (<= d -7.8e+76)
(/ (- (- b) (* c (/ a d))) (hypot c d))
(if (<= d -1.2e-65)
t_0
(if (<= d 1.1e-67)
(/ (+ a (/ (* d b) c)) c)
(if (<= d 2.25e+104) t_0 (* (/ d (hypot d c)) (/ b (hypot d c)))))))))
double code(double a, double b, double c, double d) {
double t_0 = ((d * b) + (c * a)) / ((c * c) + (d * d));
double tmp;
if (d <= -7.8e+76) {
tmp = (-b - (c * (a / d))) / hypot(c, d);
} else if (d <= -1.2e-65) {
tmp = t_0;
} else if (d <= 1.1e-67) {
tmp = (a + ((d * b) / c)) / c;
} else if (d <= 2.25e+104) {
tmp = t_0;
} else {
tmp = (d / hypot(d, c)) * (b / hypot(d, c));
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = ((d * b) + (c * a)) / ((c * c) + (d * d));
double tmp;
if (d <= -7.8e+76) {
tmp = (-b - (c * (a / d))) / Math.hypot(c, d);
} else if (d <= -1.2e-65) {
tmp = t_0;
} else if (d <= 1.1e-67) {
tmp = (a + ((d * b) / c)) / c;
} else if (d <= 2.25e+104) {
tmp = t_0;
} else {
tmp = (d / Math.hypot(d, c)) * (b / Math.hypot(d, c));
}
return tmp;
}
def code(a, b, c, d): t_0 = ((d * b) + (c * a)) / ((c * c) + (d * d)) tmp = 0 if d <= -7.8e+76: tmp = (-b - (c * (a / d))) / math.hypot(c, d) elif d <= -1.2e-65: tmp = t_0 elif d <= 1.1e-67: tmp = (a + ((d * b) / c)) / c elif d <= 2.25e+104: tmp = t_0 else: tmp = (d / math.hypot(d, c)) * (b / math.hypot(d, c)) return tmp
function code(a, b, c, d) t_0 = Float64(Float64(Float64(d * b) + Float64(c * a)) / Float64(Float64(c * c) + Float64(d * d))) tmp = 0.0 if (d <= -7.8e+76) tmp = Float64(Float64(Float64(-b) - Float64(c * Float64(a / d))) / hypot(c, d)); elseif (d <= -1.2e-65) tmp = t_0; elseif (d <= 1.1e-67) tmp = Float64(Float64(a + Float64(Float64(d * b) / c)) / c); elseif (d <= 2.25e+104) tmp = t_0; else tmp = Float64(Float64(d / hypot(d, c)) * Float64(b / hypot(d, c))); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((d * b) + (c * a)) / ((c * c) + (d * d)); tmp = 0.0; if (d <= -7.8e+76) tmp = (-b - (c * (a / d))) / hypot(c, d); elseif (d <= -1.2e-65) tmp = t_0; elseif (d <= 1.1e-67) tmp = (a + ((d * b) / c)) / c; elseif (d <= 2.25e+104) tmp = t_0; else tmp = (d / hypot(d, c)) * (b / hypot(d, c)); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(d * b), $MachinePrecision] + N[(c * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -7.8e+76], N[(N[((-b) - N[(c * N[(a / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -1.2e-65], t$95$0, If[LessEqual[d, 1.1e-67], N[(N[(a + N[(N[(d * b), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 2.25e+104], t$95$0, N[(N[(d / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{d \cdot b + c \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{if}\;d \leq -7.8 \cdot 10^{+76}:\\
\;\;\;\;\frac{\left(-b\right) - c \cdot \frac{a}{d}}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;d \leq -1.2 \cdot 10^{-65}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 1.1 \cdot 10^{-67}:\\
\;\;\;\;\frac{a + \frac{d \cdot b}{c}}{c}\\
\mathbf{elif}\;d \leq 2.25 \cdot 10^{+104}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\mathsf{hypot}\left(d, c\right)} \cdot \frac{b}{\mathsf{hypot}\left(d, c\right)}\\
\end{array}
\end{array}
if d < -7.79999999999999979e76Initial program 44.6%
Taylor expanded in d around inf 44.6%
associate-/l*42.8%
Simplified42.8%
*-commutative42.8%
add-sqr-sqrt42.8%
hypot-undefine42.8%
hypot-undefine42.8%
times-frac92.2%
+-commutative92.2%
fma-define92.2%
Applied egg-rr92.2%
fma-undefine92.2%
+-commutative92.2%
clear-num92.2%
un-div-inv92.2%
Applied egg-rr92.2%
associate-/r/94.1%
Simplified94.1%
Taylor expanded in d around -inf 89.5%
if -7.79999999999999979e76 < d < -1.2000000000000001e-65 or 1.1000000000000001e-67 < d < 2.2499999999999999e104Initial program 86.1%
if -1.2000000000000001e-65 < d < 1.1000000000000001e-67Initial program 61.5%
Taylor expanded in c around inf 83.1%
if 2.2499999999999999e104 < d Initial program 31.9%
Taylor expanded in a around 0 31.9%
*-commutative31.9%
fma-define31.9%
add-sqr-sqrt31.9%
fma-define31.9%
hypot-undefine31.9%
fma-define31.9%
hypot-undefine31.9%
times-frac90.9%
Applied egg-rr90.9%
hypot-undefine36.5%
unpow236.5%
unpow236.5%
+-commutative36.5%
unpow236.5%
unpow236.5%
hypot-define90.9%
hypot-undefine36.5%
unpow236.5%
unpow236.5%
+-commutative36.5%
unpow236.5%
unpow236.5%
hypot-define90.9%
Simplified90.9%
Final simplification86.3%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (+ b (* c (/ a d))) (hypot c d))))
(if (<= d -7.9e-22)
(* t_0 (/ d (hypot c d)))
(if (<= d 1.75e-116)
(/ (+ a (/ (* d b) c)) c)
(* t_0 (/ 1.0 (/ (hypot d c) d)))))))
double code(double a, double b, double c, double d) {
double t_0 = (b + (c * (a / d))) / hypot(c, d);
double tmp;
if (d <= -7.9e-22) {
tmp = t_0 * (d / hypot(c, d));
} else if (d <= 1.75e-116) {
tmp = (a + ((d * b) / c)) / c;
} else {
tmp = t_0 * (1.0 / (hypot(d, c) / d));
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = (b + (c * (a / d))) / Math.hypot(c, d);
double tmp;
if (d <= -7.9e-22) {
tmp = t_0 * (d / Math.hypot(c, d));
} else if (d <= 1.75e-116) {
tmp = (a + ((d * b) / c)) / c;
} else {
tmp = t_0 * (1.0 / (Math.hypot(d, c) / d));
}
return tmp;
}
def code(a, b, c, d): t_0 = (b + (c * (a / d))) / math.hypot(c, d) tmp = 0 if d <= -7.9e-22: tmp = t_0 * (d / math.hypot(c, d)) elif d <= 1.75e-116: tmp = (a + ((d * b) / c)) / c else: tmp = t_0 * (1.0 / (math.hypot(d, c) / d)) return tmp
function code(a, b, c, d) t_0 = Float64(Float64(b + Float64(c * Float64(a / d))) / hypot(c, d)) tmp = 0.0 if (d <= -7.9e-22) tmp = Float64(t_0 * Float64(d / hypot(c, d))); elseif (d <= 1.75e-116) tmp = Float64(Float64(a + Float64(Float64(d * b) / c)) / c); else tmp = Float64(t_0 * Float64(1.0 / Float64(hypot(d, c) / d))); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (b + (c * (a / d))) / hypot(c, d); tmp = 0.0; if (d <= -7.9e-22) tmp = t_0 * (d / hypot(c, d)); elseif (d <= 1.75e-116) tmp = (a + ((d * b) / c)) / c; else tmp = t_0 * (1.0 / (hypot(d, c) / d)); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(b + N[(c * N[(a / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -7.9e-22], N[(t$95$0 * N[(d / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.75e-116], N[(N[(a + N[(N[(d * b), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], N[(t$95$0 * N[(1.0 / N[(N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b + c \cdot \frac{a}{d}}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{if}\;d \leq -7.9 \cdot 10^{-22}:\\
\;\;\;\;t\_0 \cdot \frac{d}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;d \leq 1.75 \cdot 10^{-116}:\\
\;\;\;\;\frac{a + \frac{d \cdot b}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \frac{1}{\frac{\mathsf{hypot}\left(d, c\right)}{d}}\\
\end{array}
\end{array}
if d < -7.8999999999999997e-22Initial program 60.6%
Taylor expanded in d around inf 59.4%
associate-/l*58.0%
Simplified58.0%
*-commutative58.0%
add-sqr-sqrt58.0%
hypot-undefine58.0%
hypot-undefine58.0%
times-frac93.2%
+-commutative93.2%
fma-define93.2%
Applied egg-rr93.2%
fma-undefine93.2%
+-commutative93.2%
clear-num93.2%
un-div-inv93.3%
Applied egg-rr93.3%
associate-/r/94.6%
Simplified94.6%
if -7.8999999999999997e-22 < d < 1.74999999999999992e-116Initial program 65.3%
Taylor expanded in c around inf 84.4%
if 1.74999999999999992e-116 < d Initial program 58.2%
Taylor expanded in d around inf 57.0%
associate-/l*55.9%
Simplified55.9%
*-commutative55.9%
add-sqr-sqrt55.9%
hypot-undefine55.9%
hypot-undefine55.9%
times-frac90.8%
+-commutative90.8%
fma-define90.8%
Applied egg-rr90.8%
fma-undefine90.8%
+-commutative90.8%
clear-num90.8%
un-div-inv90.9%
Applied egg-rr90.9%
associate-/r/92.0%
Simplified92.0%
clear-num92.0%
inv-pow92.0%
Applied egg-rr92.0%
unpow-192.0%
hypot-undefine62.2%
unpow262.2%
unpow262.2%
+-commutative62.2%
unpow262.2%
unpow262.2%
hypot-define92.0%
Simplified92.0%
Final simplification89.9%
(FPCore (a b c d) :precision binary64 (if (or (<= d -7.8e-22) (not (<= d 1e-116))) (* (/ (+ b (* c (/ a d))) (hypot c d)) (/ d (hypot c d))) (/ (+ a (/ (* d b) c)) c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -7.8e-22) || !(d <= 1e-116)) {
tmp = ((b + (c * (a / d))) / hypot(c, d)) * (d / hypot(c, d));
} else {
tmp = (a + ((d * b) / c)) / c;
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -7.8e-22) || !(d <= 1e-116)) {
tmp = ((b + (c * (a / d))) / Math.hypot(c, d)) * (d / Math.hypot(c, d));
} else {
tmp = (a + ((d * b) / c)) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -7.8e-22) or not (d <= 1e-116): tmp = ((b + (c * (a / d))) / math.hypot(c, d)) * (d / math.hypot(c, d)) else: tmp = (a + ((d * b) / c)) / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -7.8e-22) || !(d <= 1e-116)) tmp = Float64(Float64(Float64(b + Float64(c * Float64(a / d))) / hypot(c, d)) * Float64(d / hypot(c, d))); else tmp = Float64(Float64(a + Float64(Float64(d * b) / c)) / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -7.8e-22) || ~((d <= 1e-116))) tmp = ((b + (c * (a / d))) / hypot(c, d)) * (d / hypot(c, d)); else tmp = (a + ((d * b) / c)) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -7.8e-22], N[Not[LessEqual[d, 1e-116]], $MachinePrecision]], N[(N[(N[(b + N[(c * N[(a / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(d / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a + N[(N[(d * b), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -7.8 \cdot 10^{-22} \lor \neg \left(d \leq 10^{-116}\right):\\
\;\;\;\;\frac{b + c \cdot \frac{a}{d}}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{d}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{a + \frac{d \cdot b}{c}}{c}\\
\end{array}
\end{array}
if d < -7.79999999999999996e-22 or 9.9999999999999999e-117 < d Initial program 59.3%
Taylor expanded in d around inf 58.1%
associate-/l*56.8%
Simplified56.8%
*-commutative56.8%
add-sqr-sqrt56.8%
hypot-undefine56.8%
hypot-undefine56.8%
times-frac91.9%
+-commutative91.9%
fma-define91.9%
Applied egg-rr91.9%
fma-undefine91.9%
+-commutative91.9%
clear-num91.9%
un-div-inv92.0%
Applied egg-rr92.0%
associate-/r/93.2%
Simplified93.2%
if -7.79999999999999996e-22 < d < 9.9999999999999999e-117Initial program 65.3%
Taylor expanded in c around inf 84.4%
Final simplification89.9%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (+ (* d b) (* c a)) (+ (* c c) (* d d))))
(t_1 (+ a (* b (/ d c)))))
(if (<= c -1.25e+95)
(* t_1 (/ -1.0 (hypot c d)))
(if (<= c -5e-26)
t_0
(if (<= c 1.25e-72)
(/ (+ b (* a (/ c d))) d)
(if (<= c 1.9e+67) t_0 (* (/ 1.0 (hypot c d)) t_1)))))))
double code(double a, double b, double c, double d) {
double t_0 = ((d * b) + (c * a)) / ((c * c) + (d * d));
double t_1 = a + (b * (d / c));
double tmp;
if (c <= -1.25e+95) {
tmp = t_1 * (-1.0 / hypot(c, d));
} else if (c <= -5e-26) {
tmp = t_0;
} else if (c <= 1.25e-72) {
tmp = (b + (a * (c / d))) / d;
} else if (c <= 1.9e+67) {
tmp = t_0;
} else {
tmp = (1.0 / hypot(c, d)) * t_1;
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = ((d * b) + (c * a)) / ((c * c) + (d * d));
double t_1 = a + (b * (d / c));
double tmp;
if (c <= -1.25e+95) {
tmp = t_1 * (-1.0 / Math.hypot(c, d));
} else if (c <= -5e-26) {
tmp = t_0;
} else if (c <= 1.25e-72) {
tmp = (b + (a * (c / d))) / d;
} else if (c <= 1.9e+67) {
tmp = t_0;
} else {
tmp = (1.0 / Math.hypot(c, d)) * t_1;
}
return tmp;
}
def code(a, b, c, d): t_0 = ((d * b) + (c * a)) / ((c * c) + (d * d)) t_1 = a + (b * (d / c)) tmp = 0 if c <= -1.25e+95: tmp = t_1 * (-1.0 / math.hypot(c, d)) elif c <= -5e-26: tmp = t_0 elif c <= 1.25e-72: tmp = (b + (a * (c / d))) / d elif c <= 1.9e+67: tmp = t_0 else: tmp = (1.0 / math.hypot(c, d)) * t_1 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(Float64(d * b) + Float64(c * a)) / Float64(Float64(c * c) + Float64(d * d))) t_1 = Float64(a + Float64(b * Float64(d / c))) tmp = 0.0 if (c <= -1.25e+95) tmp = Float64(t_1 * Float64(-1.0 / hypot(c, d))); elseif (c <= -5e-26) tmp = t_0; elseif (c <= 1.25e-72) tmp = Float64(Float64(b + Float64(a * Float64(c / d))) / d); elseif (c <= 1.9e+67) tmp = t_0; else tmp = Float64(Float64(1.0 / hypot(c, d)) * t_1); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((d * b) + (c * a)) / ((c * c) + (d * d)); t_1 = a + (b * (d / c)); tmp = 0.0; if (c <= -1.25e+95) tmp = t_1 * (-1.0 / hypot(c, d)); elseif (c <= -5e-26) tmp = t_0; elseif (c <= 1.25e-72) tmp = (b + (a * (c / d))) / d; elseif (c <= 1.9e+67) tmp = t_0; else tmp = (1.0 / hypot(c, d)) * t_1; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(d * b), $MachinePrecision] + N[(c * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(a + N[(b * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -1.25e+95], N[(t$95$1 * N[(-1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -5e-26], t$95$0, If[LessEqual[c, 1.25e-72], N[(N[(b + N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 1.9e+67], t$95$0, N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{d \cdot b + c \cdot a}{c \cdot c + d \cdot d}\\
t_1 := a + b \cdot \frac{d}{c}\\
\mathbf{if}\;c \leq -1.25 \cdot 10^{+95}:\\
\;\;\;\;t\_1 \cdot \frac{-1}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;c \leq -5 \cdot 10^{-26}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq 1.25 \cdot 10^{-72}:\\
\;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d}\\
\mathbf{elif}\;c \leq 1.9 \cdot 10^{+67}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot t\_1\\
\end{array}
\end{array}
if c < -1.25000000000000006e95Initial program 38.6%
*-un-lft-identity38.6%
associate-*r/38.6%
fma-define38.6%
add-sqr-sqrt38.6%
times-frac38.6%
fma-define38.6%
hypot-define38.6%
fma-define38.6%
fma-define38.6%
hypot-define52.3%
Applied egg-rr52.3%
Taylor expanded in c around -inf 71.0%
distribute-lft-out71.0%
associate-/l*76.9%
Simplified76.9%
if -1.25000000000000006e95 < c < -5.00000000000000019e-26 or 1.2499999999999999e-72 < c < 1.9000000000000001e67Initial program 81.7%
if -5.00000000000000019e-26 < c < 1.2499999999999999e-72Initial program 69.6%
Taylor expanded in d around inf 87.8%
associate-/l*89.9%
Simplified89.9%
if 1.9000000000000001e67 < c Initial program 45.3%
*-un-lft-identity45.3%
associate-*r/45.3%
fma-define45.3%
add-sqr-sqrt45.3%
times-frac45.4%
fma-define45.4%
hypot-define45.4%
fma-define45.4%
fma-define45.4%
hypot-define60.2%
Applied egg-rr60.2%
Taylor expanded in c around inf 85.3%
associate-/l*88.2%
Simplified88.2%
Final simplification85.5%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (+ (* d b) (* c a)) (+ (* c c) (* d d))))
(t_1 (+ a (* b (/ d c)))))
(if (<= c -9.5e+94)
(/ t_1 c)
(if (<= c -5e-27)
t_0
(if (<= c 2e-72)
(/ (+ b (* a (/ c d))) d)
(if (<= c 2.35e+67) t_0 (* (/ 1.0 (hypot c d)) t_1)))))))
double code(double a, double b, double c, double d) {
double t_0 = ((d * b) + (c * a)) / ((c * c) + (d * d));
double t_1 = a + (b * (d / c));
double tmp;
if (c <= -9.5e+94) {
tmp = t_1 / c;
} else if (c <= -5e-27) {
tmp = t_0;
} else if (c <= 2e-72) {
tmp = (b + (a * (c / d))) / d;
} else if (c <= 2.35e+67) {
tmp = t_0;
} else {
tmp = (1.0 / hypot(c, d)) * t_1;
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = ((d * b) + (c * a)) / ((c * c) + (d * d));
double t_1 = a + (b * (d / c));
double tmp;
if (c <= -9.5e+94) {
tmp = t_1 / c;
} else if (c <= -5e-27) {
tmp = t_0;
} else if (c <= 2e-72) {
tmp = (b + (a * (c / d))) / d;
} else if (c <= 2.35e+67) {
tmp = t_0;
} else {
tmp = (1.0 / Math.hypot(c, d)) * t_1;
}
return tmp;
}
def code(a, b, c, d): t_0 = ((d * b) + (c * a)) / ((c * c) + (d * d)) t_1 = a + (b * (d / c)) tmp = 0 if c <= -9.5e+94: tmp = t_1 / c elif c <= -5e-27: tmp = t_0 elif c <= 2e-72: tmp = (b + (a * (c / d))) / d elif c <= 2.35e+67: tmp = t_0 else: tmp = (1.0 / math.hypot(c, d)) * t_1 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(Float64(d * b) + Float64(c * a)) / Float64(Float64(c * c) + Float64(d * d))) t_1 = Float64(a + Float64(b * Float64(d / c))) tmp = 0.0 if (c <= -9.5e+94) tmp = Float64(t_1 / c); elseif (c <= -5e-27) tmp = t_0; elseif (c <= 2e-72) tmp = Float64(Float64(b + Float64(a * Float64(c / d))) / d); elseif (c <= 2.35e+67) tmp = t_0; else tmp = Float64(Float64(1.0 / hypot(c, d)) * t_1); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((d * b) + (c * a)) / ((c * c) + (d * d)); t_1 = a + (b * (d / c)); tmp = 0.0; if (c <= -9.5e+94) tmp = t_1 / c; elseif (c <= -5e-27) tmp = t_0; elseif (c <= 2e-72) tmp = (b + (a * (c / d))) / d; elseif (c <= 2.35e+67) tmp = t_0; else tmp = (1.0 / hypot(c, d)) * t_1; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(d * b), $MachinePrecision] + N[(c * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(a + N[(b * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -9.5e+94], N[(t$95$1 / c), $MachinePrecision], If[LessEqual[c, -5e-27], t$95$0, If[LessEqual[c, 2e-72], N[(N[(b + N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 2.35e+67], t$95$0, N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{d \cdot b + c \cdot a}{c \cdot c + d \cdot d}\\
t_1 := a + b \cdot \frac{d}{c}\\
\mathbf{if}\;c \leq -9.5 \cdot 10^{+94}:\\
\;\;\;\;\frac{t\_1}{c}\\
\mathbf{elif}\;c \leq -5 \cdot 10^{-27}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq 2 \cdot 10^{-72}:\\
\;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d}\\
\mathbf{elif}\;c \leq 2.35 \cdot 10^{+67}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot t\_1\\
\end{array}
\end{array}
if c < -9.4999999999999998e94Initial program 38.6%
Taylor expanded in c around inf 70.9%
associate-/l*76.7%
Simplified76.7%
if -9.4999999999999998e94 < c < -5.0000000000000002e-27 or 1.9999999999999999e-72 < c < 2.35000000000000009e67Initial program 81.7%
if -5.0000000000000002e-27 < c < 1.9999999999999999e-72Initial program 69.6%
Taylor expanded in d around inf 87.8%
associate-/l*89.9%
Simplified89.9%
if 2.35000000000000009e67 < c Initial program 45.3%
*-un-lft-identity45.3%
associate-*r/45.3%
fma-define45.3%
add-sqr-sqrt45.3%
times-frac45.4%
fma-define45.4%
hypot-define45.4%
fma-define45.4%
fma-define45.4%
hypot-define60.2%
Applied egg-rr60.2%
Taylor expanded in c around inf 85.3%
associate-/l*88.2%
Simplified88.2%
Final simplification85.5%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (+ (* d b) (* c a)) (+ (* c c) (* d d))))
(t_1 (/ (+ a (* b (/ d c))) c)))
(if (<= c -4.6e+95)
t_1
(if (<= c -4.8e-27)
t_0
(if (<= c 4.5e-74)
(/ (+ b (* a (/ c d))) d)
(if (<= c 5.8e+74) t_0 t_1))))))
double code(double a, double b, double c, double d) {
double t_0 = ((d * b) + (c * a)) / ((c * c) + (d * d));
double t_1 = (a + (b * (d / c))) / c;
double tmp;
if (c <= -4.6e+95) {
tmp = t_1;
} else if (c <= -4.8e-27) {
tmp = t_0;
} else if (c <= 4.5e-74) {
tmp = (b + (a * (c / d))) / d;
} else if (c <= 5.8e+74) {
tmp = t_0;
} else {
tmp = t_1;
}
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 = ((d * b) + (c * a)) / ((c * c) + (d * d))
t_1 = (a + (b * (d / c))) / c
if (c <= (-4.6d+95)) then
tmp = t_1
else if (c <= (-4.8d-27)) then
tmp = t_0
else if (c <= 4.5d-74) then
tmp = (b + (a * (c / d))) / d
else if (c <= 5.8d+74) then
tmp = t_0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = ((d * b) + (c * a)) / ((c * c) + (d * d));
double t_1 = (a + (b * (d / c))) / c;
double tmp;
if (c <= -4.6e+95) {
tmp = t_1;
} else if (c <= -4.8e-27) {
tmp = t_0;
} else if (c <= 4.5e-74) {
tmp = (b + (a * (c / d))) / d;
} else if (c <= 5.8e+74) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(a, b, c, d): t_0 = ((d * b) + (c * a)) / ((c * c) + (d * d)) t_1 = (a + (b * (d / c))) / c tmp = 0 if c <= -4.6e+95: tmp = t_1 elif c <= -4.8e-27: tmp = t_0 elif c <= 4.5e-74: tmp = (b + (a * (c / d))) / d elif c <= 5.8e+74: tmp = t_0 else: tmp = t_1 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(Float64(d * b) + Float64(c * a)) / Float64(Float64(c * c) + Float64(d * d))) t_1 = Float64(Float64(a + Float64(b * Float64(d / c))) / c) tmp = 0.0 if (c <= -4.6e+95) tmp = t_1; elseif (c <= -4.8e-27) tmp = t_0; elseif (c <= 4.5e-74) tmp = Float64(Float64(b + Float64(a * Float64(c / d))) / d); elseif (c <= 5.8e+74) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((d * b) + (c * a)) / ((c * c) + (d * d)); t_1 = (a + (b * (d / c))) / c; tmp = 0.0; if (c <= -4.6e+95) tmp = t_1; elseif (c <= -4.8e-27) tmp = t_0; elseif (c <= 4.5e-74) tmp = (b + (a * (c / d))) / d; elseif (c <= 5.8e+74) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(d * b), $MachinePrecision] + N[(c * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(a + N[(b * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]}, If[LessEqual[c, -4.6e+95], t$95$1, If[LessEqual[c, -4.8e-27], t$95$0, If[LessEqual[c, 4.5e-74], N[(N[(b + N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 5.8e+74], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{d \cdot b + c \cdot a}{c \cdot c + d \cdot d}\\
t_1 := \frac{a + b \cdot \frac{d}{c}}{c}\\
\mathbf{if}\;c \leq -4.6 \cdot 10^{+95}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;c \leq -4.8 \cdot 10^{-27}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq 4.5 \cdot 10^{-74}:\\
\;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d}\\
\mathbf{elif}\;c \leq 5.8 \cdot 10^{+74}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if c < -4.59999999999999994e95 or 5.8000000000000005e74 < c Initial program 41.2%
Taylor expanded in c around inf 77.5%
associate-/l*82.1%
Simplified82.1%
if -4.59999999999999994e95 < c < -4.80000000000000004e-27 or 4.4999999999999999e-74 < c < 5.8000000000000005e74Initial program 80.5%
if -4.80000000000000004e-27 < c < 4.4999999999999999e-74Initial program 69.6%
Taylor expanded in d around inf 87.8%
associate-/l*89.9%
Simplified89.9%
Final simplification85.5%
(FPCore (a b c d)
:precision binary64
(if (or (<= d -8.2e+101)
(and (not (<= d 1.1e+15)) (or (<= d 1.7e+73) (not (<= d 3.5e+170)))))
(/ b d)
(/ (+ a (* b (/ d c))) c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -8.2e+101) || (!(d <= 1.1e+15) && ((d <= 1.7e+73) || !(d <= 3.5e+170)))) {
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 <= (-8.2d+101)) .or. (.not. (d <= 1.1d+15)) .and. (d <= 1.7d+73) .or. (.not. (d <= 3.5d+170))) 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 <= -8.2e+101) || (!(d <= 1.1e+15) && ((d <= 1.7e+73) || !(d <= 3.5e+170)))) {
tmp = b / d;
} else {
tmp = (a + (b * (d / c))) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -8.2e+101) or (not (d <= 1.1e+15) and ((d <= 1.7e+73) or not (d <= 3.5e+170))): tmp = b / d else: tmp = (a + (b * (d / c))) / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -8.2e+101) || (!(d <= 1.1e+15) && ((d <= 1.7e+73) || !(d <= 3.5e+170)))) 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 <= -8.2e+101) || (~((d <= 1.1e+15)) && ((d <= 1.7e+73) || ~((d <= 3.5e+170))))) tmp = b / d; else tmp = (a + (b * (d / c))) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -8.2e+101], And[N[Not[LessEqual[d, 1.1e+15]], $MachinePrecision], Or[LessEqual[d, 1.7e+73], N[Not[LessEqual[d, 3.5e+170]], $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 -8.2 \cdot 10^{+101} \lor \neg \left(d \leq 1.1 \cdot 10^{+15}\right) \land \left(d \leq 1.7 \cdot 10^{+73} \lor \neg \left(d \leq 3.5 \cdot 10^{+170}\right)\right):\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a + b \cdot \frac{d}{c}}{c}\\
\end{array}
\end{array}
if d < -8.1999999999999999e101 or 1.1e15 < d < 1.7000000000000001e73 or 3.50000000000000005e170 < d Initial program 51.5%
Taylor expanded in c around 0 78.3%
if -8.1999999999999999e101 < d < 1.1e15 or 1.7000000000000001e73 < d < 3.50000000000000005e170Initial program 67.4%
Taylor expanded in c around inf 70.1%
associate-/l*72.0%
Simplified72.0%
Final simplification74.4%
(FPCore (a b c d)
:precision binary64
(if (<= d -4.7e+101)
(/ b d)
(if (<= d 96000000000000.0)
(/ (+ a (/ (* d b) c)) c)
(if (or (<= d 1.35e+73) (not (<= d 3.5e+170)))
(/ b d)
(/ (+ a (* b (/ d c))) c)))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -4.7e+101) {
tmp = b / d;
} else if (d <= 96000000000000.0) {
tmp = (a + ((d * b) / c)) / c;
} else if ((d <= 1.35e+73) || !(d <= 3.5e+170)) {
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 <= (-4.7d+101)) then
tmp = b / d
else if (d <= 96000000000000.0d0) then
tmp = (a + ((d * b) / c)) / c
else if ((d <= 1.35d+73) .or. (.not. (d <= 3.5d+170))) 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 <= -4.7e+101) {
tmp = b / d;
} else if (d <= 96000000000000.0) {
tmp = (a + ((d * b) / c)) / c;
} else if ((d <= 1.35e+73) || !(d <= 3.5e+170)) {
tmp = b / d;
} else {
tmp = (a + (b * (d / c))) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -4.7e+101: tmp = b / d elif d <= 96000000000000.0: tmp = (a + ((d * b) / c)) / c elif (d <= 1.35e+73) or not (d <= 3.5e+170): tmp = b / d else: tmp = (a + (b * (d / c))) / c return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -4.7e+101) tmp = Float64(b / d); elseif (d <= 96000000000000.0) tmp = Float64(Float64(a + Float64(Float64(d * b) / c)) / c); elseif ((d <= 1.35e+73) || !(d <= 3.5e+170)) 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 <= -4.7e+101) tmp = b / d; elseif (d <= 96000000000000.0) tmp = (a + ((d * b) / c)) / c; elseif ((d <= 1.35e+73) || ~((d <= 3.5e+170))) tmp = b / d; else tmp = (a + (b * (d / c))) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -4.7e+101], N[(b / d), $MachinePrecision], If[LessEqual[d, 96000000000000.0], N[(N[(a + N[(N[(d * b), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[Or[LessEqual[d, 1.35e+73], N[Not[LessEqual[d, 3.5e+170]], $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 -4.7 \cdot 10^{+101}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{elif}\;d \leq 96000000000000:\\
\;\;\;\;\frac{a + \frac{d \cdot b}{c}}{c}\\
\mathbf{elif}\;d \leq 1.35 \cdot 10^{+73} \lor \neg \left(d \leq 3.5 \cdot 10^{+170}\right):\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a + b \cdot \frac{d}{c}}{c}\\
\end{array}
\end{array}
if d < -4.69999999999999971e101 or 9.6e13 < d < 1.35e73 or 3.50000000000000005e170 < d Initial program 51.5%
Taylor expanded in c around 0 78.3%
if -4.69999999999999971e101 < d < 9.6e13Initial program 69.6%
Taylor expanded in c around inf 73.8%
if 1.35e73 < d < 3.50000000000000005e170Initial program 44.1%
Taylor expanded in c around inf 31.2%
associate-/l*59.0%
Simplified59.0%
Final simplification74.6%
(FPCore (a b c d) :precision binary64 (if (or (<= c -1.95e-23) (not (<= c 9.8e+45))) (/ (+ a (* b (/ d c))) c) (/ (+ b (* a (/ c d))) d)))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -1.95e-23) || !(c <= 9.8e+45)) {
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 ((c <= (-1.95d-23)) .or. (.not. (c <= 9.8d+45))) 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 ((c <= -1.95e-23) || !(c <= 9.8e+45)) {
tmp = (a + (b * (d / c))) / c;
} else {
tmp = (b + (a * (c / d))) / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -1.95e-23) or not (c <= 9.8e+45): 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 ((c <= -1.95e-23) || !(c <= 9.8e+45)) 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 ((c <= -1.95e-23) || ~((c <= 9.8e+45))) tmp = (a + (b * (d / c))) / c; else tmp = (b + (a * (c / d))) / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -1.95e-23], N[Not[LessEqual[c, 9.8e+45]], $MachinePrecision]], 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}\;c \leq -1.95 \cdot 10^{-23} \lor \neg \left(c \leq 9.8 \cdot 10^{+45}\right):\\
\;\;\;\;\frac{a + b \cdot \frac{d}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d}\\
\end{array}
\end{array}
if c < -1.95e-23 or 9.8000000000000004e45 < c Initial program 49.6%
Taylor expanded in c around inf 73.5%
associate-/l*76.3%
Simplified76.3%
if -1.95e-23 < c < 9.8000000000000004e45Initial program 71.3%
Taylor expanded in d around inf 84.3%
associate-/l*86.0%
Simplified86.0%
Final simplification81.6%
(FPCore (a b c d) :precision binary64 (if (or (<= c -5.8e-39) (not (<= c 2.75e+42))) (/ a c) (/ b d)))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -5.8e-39) || !(c <= 2.75e+42)) {
tmp = a / c;
} else {
tmp = b / d;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if ((c <= (-5.8d-39)) .or. (.not. (c <= 2.75d+42))) then
tmp = a / c
else
tmp = b / d
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -5.8e-39) || !(c <= 2.75e+42)) {
tmp = a / c;
} else {
tmp = b / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -5.8e-39) or not (c <= 2.75e+42): tmp = a / c else: tmp = b / d return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -5.8e-39) || !(c <= 2.75e+42)) tmp = Float64(a / c); else tmp = Float64(b / d); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((c <= -5.8e-39) || ~((c <= 2.75e+42))) tmp = a / c; else tmp = b / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -5.8e-39], N[Not[LessEqual[c, 2.75e+42]], $MachinePrecision]], N[(a / c), $MachinePrecision], N[(b / d), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -5.8 \cdot 10^{-39} \lor \neg \left(c \leq 2.75 \cdot 10^{+42}\right):\\
\;\;\;\;\frac{a}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d}\\
\end{array}
\end{array}
if c < -5.79999999999999975e-39 or 2.75000000000000001e42 < c Initial program 49.7%
Taylor expanded in c around inf 65.5%
if -5.79999999999999975e-39 < c < 2.75000000000000001e42Initial program 71.9%
Taylor expanded in c around 0 64.6%
Final simplification65.0%
(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 61.6%
Taylor expanded in c around inf 39.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 2024101
(FPCore (a b c d)
:name "Complex division, real part"
:precision binary64
:alt
(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))))