
(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 (<= c -1.18e+104)
(* (+ a (/ b (/ c d))) (/ -1.0 (hypot c d)))
(if (<= c -5.2e-27)
t_0
(if (<= c 1.95e-131)
(+ (/ b d) (/ (/ (* a c) d) d))
(if (<= c 2.7e+88)
t_0
(if (<= c 3.3e+107)
(* (/ d (hypot c d)) (/ b (hypot c d)))
(+ (/ a c) (/ b (* c (/ c 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 (c <= -1.18e+104) {
tmp = (a + (b / (c / d))) * (-1.0 / hypot(c, d));
} else if (c <= -5.2e-27) {
tmp = t_0;
} else if (c <= 1.95e-131) {
tmp = (b / d) + (((a * c) / d) / d);
} else if (c <= 2.7e+88) {
tmp = t_0;
} else if (c <= 3.3e+107) {
tmp = (d / hypot(c, d)) * (b / hypot(c, d));
} else {
tmp = (a / c) + (b / (c * (c / d)));
}
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 tmp;
if (c <= -1.18e+104) {
tmp = (a + (b / (c / d))) * (-1.0 / Math.hypot(c, d));
} else if (c <= -5.2e-27) {
tmp = t_0;
} else if (c <= 1.95e-131) {
tmp = (b / d) + (((a * c) / d) / d);
} else if (c <= 2.7e+88) {
tmp = t_0;
} else if (c <= 3.3e+107) {
tmp = (d / Math.hypot(c, d)) * (b / Math.hypot(c, d));
} else {
tmp = (a / c) + (b / (c * (c / d)));
}
return tmp;
}
def code(a, b, c, d): t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d)) tmp = 0 if c <= -1.18e+104: tmp = (a + (b / (c / d))) * (-1.0 / math.hypot(c, d)) elif c <= -5.2e-27: tmp = t_0 elif c <= 1.95e-131: tmp = (b / d) + (((a * c) / d) / d) elif c <= 2.7e+88: tmp = t_0 elif c <= 3.3e+107: tmp = (d / math.hypot(c, d)) * (b / math.hypot(c, d)) else: tmp = (a / c) + (b / (c * (c / 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 (c <= -1.18e+104) tmp = Float64(Float64(a + Float64(b / Float64(c / d))) * Float64(-1.0 / hypot(c, d))); elseif (c <= -5.2e-27) tmp = t_0; elseif (c <= 1.95e-131) tmp = Float64(Float64(b / d) + Float64(Float64(Float64(a * c) / d) / d)); elseif (c <= 2.7e+88) tmp = t_0; elseif (c <= 3.3e+107) tmp = Float64(Float64(d / hypot(c, d)) * Float64(b / hypot(c, d))); else tmp = Float64(Float64(a / c) + Float64(b / Float64(c * Float64(c / 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 (c <= -1.18e+104) tmp = (a + (b / (c / d))) * (-1.0 / hypot(c, d)); elseif (c <= -5.2e-27) tmp = t_0; elseif (c <= 1.95e-131) tmp = (b / d) + (((a * c) / d) / d); elseif (c <= 2.7e+88) tmp = t_0; elseif (c <= 3.3e+107) tmp = (d / hypot(c, d)) * (b / hypot(c, d)); else tmp = (a / c) + (b / (c * (c / 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[c, -1.18e+104], N[(N[(a + N[(b / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(-1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -5.2e-27], t$95$0, If[LessEqual[c, 1.95e-131], N[(N[(b / d), $MachinePrecision] + N[(N[(N[(a * c), $MachinePrecision] / d), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 2.7e+88], t$95$0, If[LessEqual[c, 3.3e+107], N[(N[(d / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a / c), $MachinePrecision] + N[(b / N[(c * N[(c / d), $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}\;c \leq -1.18 \cdot 10^{+104}:\\
\;\;\;\;\left(a + \frac{b}{\frac{c}{d}}\right) \cdot \frac{-1}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;c \leq -5.2 \cdot 10^{-27}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 1.95 \cdot 10^{-131}:\\
\;\;\;\;\frac{b}{d} + \frac{\frac{a \cdot c}{d}}{d}\\
\mathbf{elif}\;c \leq 2.7 \cdot 10^{+88}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 3.3 \cdot 10^{+107}:\\
\;\;\;\;\frac{d}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{b}{c \cdot \frac{c}{d}}\\
\end{array}
\end{array}
if c < -1.18e104Initial program 28.6%
*-un-lft-identity28.6%
+-commutative28.6%
fma-udef28.6%
add-sqr-sqrt28.6%
times-frac28.6%
fma-udef28.6%
+-commutative28.6%
hypot-def28.6%
fma-def28.8%
fma-udef28.8%
+-commutative28.8%
hypot-def54.2%
Applied egg-rr54.2%
Taylor expanded in c around -inf 77.6%
neg-mul-177.6%
+-commutative77.6%
unsub-neg77.6%
mul-1-neg77.6%
associate-/l*83.4%
distribute-neg-frac83.4%
Simplified83.4%
if -1.18e104 < c < -5.20000000000000034e-27 or 1.9500000000000001e-131 < c < 2.70000000000000016e88Initial program 90.5%
if -5.20000000000000034e-27 < c < 1.9500000000000001e-131Initial program 71.5%
Taylor expanded in c around 0 83.2%
associate-/l*84.1%
associate-/r/80.2%
Simplified80.2%
associate-*l/83.2%
unpow283.2%
associate-/r*91.4%
*-commutative91.4%
Applied egg-rr91.4%
if 2.70000000000000016e88 < c < 3.30000000000000032e107Initial program 32.6%
Taylor expanded in a around 0 32.6%
*-commutative32.6%
add-sqr-sqrt32.6%
hypot-udef32.6%
hypot-udef32.6%
times-frac98.8%
Applied egg-rr98.8%
if 3.30000000000000032e107 < c Initial program 36.0%
Taylor expanded in c around inf 77.5%
associate-/l*79.4%
Simplified79.4%
pow279.4%
*-un-lft-identity79.4%
times-frac87.8%
Applied egg-rr87.8%
Final simplification89.5%
(FPCore (a b c d) :precision binary64 (if (<= (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))) INFINITY) (* (/ 1.0 (hypot c d)) (/ (fma a c (* b d)) (hypot c d))) (+ (/ a c) (/ b (* c (/ c d))))))
double code(double a, double b, double c, double d) {
double tmp;
if ((((a * c) + (b * d)) / ((c * c) + (d * d))) <= ((double) INFINITY)) {
tmp = (1.0 / hypot(c, d)) * (fma(a, c, (b * d)) / hypot(c, d));
} else {
tmp = (a / c) + (b / (c * (c / d)));
}
return tmp;
}
function code(a, b, c, d) tmp = 0.0 if (Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d))) <= Inf) tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(fma(a, c, Float64(b * d)) / hypot(c, d))); else tmp = Float64(Float64(a / c) + Float64(b / Float64(c * Float64(c / d)))); end return tmp end
code[a_, b_, c_, d_] := If[LessEqual[N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], 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[(a / c), $MachinePrecision] + N[(b / N[(c * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \leq \infty:\\
\;\;\;\;\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{a}{c} + \frac{b}{c \cdot \frac{c}{d}}\\
\end{array}
\end{array}
if (/.f64 (+.f64 (*.f64 a c) (*.f64 b d)) (+.f64 (*.f64 c c) (*.f64 d d))) < +inf.0Initial program 78.4%
*-un-lft-identity78.4%
+-commutative78.4%
fma-udef78.4%
add-sqr-sqrt78.4%
times-frac78.3%
fma-udef78.3%
+-commutative78.3%
hypot-def78.3%
fma-def78.3%
fma-udef78.3%
+-commutative78.3%
hypot-def95.8%
Applied egg-rr95.8%
if +inf.0 < (/.f64 (+.f64 (*.f64 a c) (*.f64 b d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 0.0%
Taylor expanded in c around inf 46.1%
associate-/l*51.8%
Simplified51.8%
pow251.8%
*-un-lft-identity51.8%
times-frac57.2%
Applied egg-rr57.2%
Final simplification87.3%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))))
(if (<= c -1.14e+104)
(* (+ a (/ b (/ c d))) (/ -1.0 (hypot c d)))
(if (<= c -5.5e-27)
t_0
(if (<= c 1.05e-131)
(+ (/ b d) (/ (/ (* a c) d) d))
(if (<= c 8.5e+153) t_0 (+ (/ a c) (/ b (* c (/ c 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 (c <= -1.14e+104) {
tmp = (a + (b / (c / d))) * (-1.0 / hypot(c, d));
} else if (c <= -5.5e-27) {
tmp = t_0;
} else if (c <= 1.05e-131) {
tmp = (b / d) + (((a * c) / d) / d);
} else if (c <= 8.5e+153) {
tmp = t_0;
} else {
tmp = (a / c) + (b / (c * (c / d)));
}
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 tmp;
if (c <= -1.14e+104) {
tmp = (a + (b / (c / d))) * (-1.0 / Math.hypot(c, d));
} else if (c <= -5.5e-27) {
tmp = t_0;
} else if (c <= 1.05e-131) {
tmp = (b / d) + (((a * c) / d) / d);
} else if (c <= 8.5e+153) {
tmp = t_0;
} else {
tmp = (a / c) + (b / (c * (c / d)));
}
return tmp;
}
def code(a, b, c, d): t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d)) tmp = 0 if c <= -1.14e+104: tmp = (a + (b / (c / d))) * (-1.0 / math.hypot(c, d)) elif c <= -5.5e-27: tmp = t_0 elif c <= 1.05e-131: tmp = (b / d) + (((a * c) / d) / d) elif c <= 8.5e+153: tmp = t_0 else: tmp = (a / c) + (b / (c * (c / 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 (c <= -1.14e+104) tmp = Float64(Float64(a + Float64(b / Float64(c / d))) * Float64(-1.0 / hypot(c, d))); elseif (c <= -5.5e-27) tmp = t_0; elseif (c <= 1.05e-131) tmp = Float64(Float64(b / d) + Float64(Float64(Float64(a * c) / d) / d)); elseif (c <= 8.5e+153) tmp = t_0; else tmp = Float64(Float64(a / c) + Float64(b / Float64(c * Float64(c / 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 (c <= -1.14e+104) tmp = (a + (b / (c / d))) * (-1.0 / hypot(c, d)); elseif (c <= -5.5e-27) tmp = t_0; elseif (c <= 1.05e-131) tmp = (b / d) + (((a * c) / d) / d); elseif (c <= 8.5e+153) tmp = t_0; else tmp = (a / c) + (b / (c * (c / 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[c, -1.14e+104], N[(N[(a + N[(b / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(-1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -5.5e-27], t$95$0, If[LessEqual[c, 1.05e-131], N[(N[(b / d), $MachinePrecision] + N[(N[(N[(a * c), $MachinePrecision] / d), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 8.5e+153], t$95$0, N[(N[(a / c), $MachinePrecision] + N[(b / N[(c * N[(c / d), $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}\;c \leq -1.14 \cdot 10^{+104}:\\
\;\;\;\;\left(a + \frac{b}{\frac{c}{d}}\right) \cdot \frac{-1}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;c \leq -5.5 \cdot 10^{-27}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 1.05 \cdot 10^{-131}:\\
\;\;\;\;\frac{b}{d} + \frac{\frac{a \cdot c}{d}}{d}\\
\mathbf{elif}\;c \leq 8.5 \cdot 10^{+153}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{b}{c \cdot \frac{c}{d}}\\
\end{array}
\end{array}
if c < -1.14000000000000007e104Initial program 28.6%
*-un-lft-identity28.6%
+-commutative28.6%
fma-udef28.6%
add-sqr-sqrt28.6%
times-frac28.6%
fma-udef28.6%
+-commutative28.6%
hypot-def28.6%
fma-def28.8%
fma-udef28.8%
+-commutative28.8%
hypot-def54.2%
Applied egg-rr54.2%
Taylor expanded in c around -inf 77.6%
neg-mul-177.6%
+-commutative77.6%
unsub-neg77.6%
mul-1-neg77.6%
associate-/l*83.4%
distribute-neg-frac83.4%
Simplified83.4%
if -1.14000000000000007e104 < c < -5.5000000000000002e-27 or 1.04999999999999999e-131 < c < 8.49999999999999935e153Initial program 81.8%
if -5.5000000000000002e-27 < c < 1.04999999999999999e-131Initial program 71.5%
Taylor expanded in c around 0 83.2%
associate-/l*84.1%
associate-/r/80.2%
Simplified80.2%
associate-*l/83.2%
unpow283.2%
associate-/r*91.4%
*-commutative91.4%
Applied egg-rr91.4%
if 8.49999999999999935e153 < c Initial program 28.7%
Taylor expanded in c around inf 80.6%
associate-/l*83.0%
Simplified83.0%
pow283.0%
*-un-lft-identity83.0%
times-frac93.6%
Applied egg-rr93.6%
Final simplification87.7%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))))
(if (<= c -1.14e+104)
(* (/ 1.0 c) (+ a (/ b (/ c d))))
(if (<= c -5.2e-27)
t_0
(if (<= c 4.2e-132)
(+ (/ b d) (/ (/ (* a c) d) d))
(if (<= c 2.4e+153) t_0 (+ (/ a c) (/ b (* c (/ c 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 (c <= -1.14e+104) {
tmp = (1.0 / c) * (a + (b / (c / d)));
} else if (c <= -5.2e-27) {
tmp = t_0;
} else if (c <= 4.2e-132) {
tmp = (b / d) + (((a * c) / d) / d);
} else if (c <= 2.4e+153) {
tmp = t_0;
} else {
tmp = (a / c) + (b / (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) :: t_0
real(8) :: tmp
t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d))
if (c <= (-1.14d+104)) then
tmp = (1.0d0 / c) * (a + (b / (c / d)))
else if (c <= (-5.2d-27)) then
tmp = t_0
else if (c <= 4.2d-132) then
tmp = (b / d) + (((a * c) / d) / d)
else if (c <= 2.4d+153) then
tmp = t_0
else
tmp = (a / c) + (b / (c * (c / 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 (c <= -1.14e+104) {
tmp = (1.0 / c) * (a + (b / (c / d)));
} else if (c <= -5.2e-27) {
tmp = t_0;
} else if (c <= 4.2e-132) {
tmp = (b / d) + (((a * c) / d) / d);
} else if (c <= 2.4e+153) {
tmp = t_0;
} else {
tmp = (a / c) + (b / (c * (c / d)));
}
return tmp;
}
def code(a, b, c, d): t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d)) tmp = 0 if c <= -1.14e+104: tmp = (1.0 / c) * (a + (b / (c / d))) elif c <= -5.2e-27: tmp = t_0 elif c <= 4.2e-132: tmp = (b / d) + (((a * c) / d) / d) elif c <= 2.4e+153: tmp = t_0 else: tmp = (a / c) + (b / (c * (c / 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 (c <= -1.14e+104) tmp = Float64(Float64(1.0 / c) * Float64(a + Float64(b / Float64(c / d)))); elseif (c <= -5.2e-27) tmp = t_0; elseif (c <= 4.2e-132) tmp = Float64(Float64(b / d) + Float64(Float64(Float64(a * c) / d) / d)); elseif (c <= 2.4e+153) tmp = t_0; else tmp = Float64(Float64(a / c) + Float64(b / Float64(c * Float64(c / 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 (c <= -1.14e+104) tmp = (1.0 / c) * (a + (b / (c / d))); elseif (c <= -5.2e-27) tmp = t_0; elseif (c <= 4.2e-132) tmp = (b / d) + (((a * c) / d) / d); elseif (c <= 2.4e+153) tmp = t_0; else tmp = (a / c) + (b / (c * (c / 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[c, -1.14e+104], N[(N[(1.0 / c), $MachinePrecision] * N[(a + N[(b / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -5.2e-27], t$95$0, If[LessEqual[c, 4.2e-132], N[(N[(b / d), $MachinePrecision] + N[(N[(N[(a * c), $MachinePrecision] / d), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 2.4e+153], t$95$0, N[(N[(a / c), $MachinePrecision] + N[(b / N[(c * N[(c / d), $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}\;c \leq -1.14 \cdot 10^{+104}:\\
\;\;\;\;\frac{1}{c} \cdot \left(a + \frac{b}{\frac{c}{d}}\right)\\
\mathbf{elif}\;c \leq -5.2 \cdot 10^{-27}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 4.2 \cdot 10^{-132}:\\
\;\;\;\;\frac{b}{d} + \frac{\frac{a \cdot c}{d}}{d}\\
\mathbf{elif}\;c \leq 2.4 \cdot 10^{+153}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{b}{c \cdot \frac{c}{d}}\\
\end{array}
\end{array}
if c < -1.14000000000000007e104Initial program 28.6%
*-un-lft-identity28.6%
+-commutative28.6%
fma-udef28.6%
add-sqr-sqrt28.6%
times-frac28.6%
fma-udef28.6%
+-commutative28.6%
hypot-def28.6%
fma-def28.8%
fma-udef28.8%
+-commutative28.8%
hypot-def54.2%
Applied egg-rr54.2%
Taylor expanded in c around inf 26.0%
associate-/l*26.1%
Simplified26.1%
Taylor expanded in c around inf 83.2%
if -1.14000000000000007e104 < c < -5.20000000000000034e-27 or 4.2000000000000002e-132 < c < 2.39999999999999992e153Initial program 81.8%
if -5.20000000000000034e-27 < c < 4.2000000000000002e-132Initial program 71.5%
Taylor expanded in c around 0 83.2%
associate-/l*84.1%
associate-/r/80.2%
Simplified80.2%
associate-*l/83.2%
unpow283.2%
associate-/r*91.4%
*-commutative91.4%
Applied egg-rr91.4%
if 2.39999999999999992e153 < c Initial program 28.7%
Taylor expanded in c around inf 80.6%
associate-/l*83.0%
Simplified83.0%
pow283.0%
*-un-lft-identity83.0%
times-frac93.6%
Applied egg-rr93.6%
Final simplification87.7%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (* (/ 1.0 c) (+ a (/ b (/ c d))))))
(if (<= c -1.76e-26)
t_0
(if (<= c 6e-32)
(/ b d)
(if (or (<= c 2.7e+88) (not (<= c 1.25e+107))) t_0 (/ 1.0 (/ d b)))))))
double code(double a, double b, double c, double d) {
double t_0 = (1.0 / c) * (a + (b / (c / d)));
double tmp;
if (c <= -1.76e-26) {
tmp = t_0;
} else if (c <= 6e-32) {
tmp = b / d;
} else if ((c <= 2.7e+88) || !(c <= 1.25e+107)) {
tmp = t_0;
} else {
tmp = 1.0 / (d / b);
}
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 = (1.0d0 / c) * (a + (b / (c / d)))
if (c <= (-1.76d-26)) then
tmp = t_0
else if (c <= 6d-32) then
tmp = b / d
else if ((c <= 2.7d+88) .or. (.not. (c <= 1.25d+107))) then
tmp = t_0
else
tmp = 1.0d0 / (d / b)
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = (1.0 / c) * (a + (b / (c / d)));
double tmp;
if (c <= -1.76e-26) {
tmp = t_0;
} else if (c <= 6e-32) {
tmp = b / d;
} else if ((c <= 2.7e+88) || !(c <= 1.25e+107)) {
tmp = t_0;
} else {
tmp = 1.0 / (d / b);
}
return tmp;
}
def code(a, b, c, d): t_0 = (1.0 / c) * (a + (b / (c / d))) tmp = 0 if c <= -1.76e-26: tmp = t_0 elif c <= 6e-32: tmp = b / d elif (c <= 2.7e+88) or not (c <= 1.25e+107): tmp = t_0 else: tmp = 1.0 / (d / b) return tmp
function code(a, b, c, d) t_0 = Float64(Float64(1.0 / c) * Float64(a + Float64(b / Float64(c / d)))) tmp = 0.0 if (c <= -1.76e-26) tmp = t_0; elseif (c <= 6e-32) tmp = Float64(b / d); elseif ((c <= 2.7e+88) || !(c <= 1.25e+107)) tmp = t_0; else tmp = Float64(1.0 / Float64(d / b)); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (1.0 / c) * (a + (b / (c / d))); tmp = 0.0; if (c <= -1.76e-26) tmp = t_0; elseif (c <= 6e-32) tmp = b / d; elseif ((c <= 2.7e+88) || ~((c <= 1.25e+107))) tmp = t_0; else tmp = 1.0 / (d / b); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(1.0 / c), $MachinePrecision] * N[(a + N[(b / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -1.76e-26], t$95$0, If[LessEqual[c, 6e-32], N[(b / d), $MachinePrecision], If[Or[LessEqual[c, 2.7e+88], N[Not[LessEqual[c, 1.25e+107]], $MachinePrecision]], t$95$0, N[(1.0 / N[(d / b), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{c} \cdot \left(a + \frac{b}{\frac{c}{d}}\right)\\
\mathbf{if}\;c \leq -1.76 \cdot 10^{-26}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 6 \cdot 10^{-32}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{elif}\;c \leq 2.7 \cdot 10^{+88} \lor \neg \left(c \leq 1.25 \cdot 10^{+107}\right):\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{d}{b}}\\
\end{array}
\end{array}
if c < -1.7599999999999999e-26 or 6.0000000000000001e-32 < c < 2.70000000000000016e88 or 1.25e107 < c Initial program 50.7%
*-un-lft-identity50.7%
+-commutative50.7%
fma-udef50.7%
add-sqr-sqrt50.7%
times-frac50.7%
fma-udef50.7%
+-commutative50.7%
hypot-def50.7%
fma-def50.7%
fma-udef50.7%
+-commutative50.7%
hypot-def67.2%
Applied egg-rr67.2%
Taylor expanded in c around inf 52.3%
associate-/l*53.8%
Simplified53.8%
Taylor expanded in c around inf 79.9%
if -1.7599999999999999e-26 < c < 6.0000000000000001e-32Initial program 74.6%
Taylor expanded in c around 0 74.8%
if 2.70000000000000016e88 < c < 1.25e107Initial program 32.6%
*-un-lft-identity32.6%
+-commutative32.6%
fma-udef32.6%
add-sqr-sqrt32.6%
times-frac32.3%
fma-udef32.3%
+-commutative32.3%
hypot-def32.3%
fma-def32.3%
fma-udef32.3%
+-commutative32.3%
hypot-def71.5%
Applied egg-rr71.5%
Taylor expanded in c around 0 58.0%
Taylor expanded in c around 0 84.8%
associate-/r/85.0%
Applied egg-rr85.0%
Final simplification77.7%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (* (/ 1.0 c) (+ a (/ b (/ c d))))))
(if (<= c -2.12e-26)
t_0
(if (<= c 3.4e-28)
(/ b d)
(if (<= c 2.7e+88)
(+ (/ a c) (* d (/ (/ b c) c)))
(if (<= c 1.25e+107) (/ 1.0 (/ d b)) t_0))))))
double code(double a, double b, double c, double d) {
double t_0 = (1.0 / c) * (a + (b / (c / d)));
double tmp;
if (c <= -2.12e-26) {
tmp = t_0;
} else if (c <= 3.4e-28) {
tmp = b / d;
} else if (c <= 2.7e+88) {
tmp = (a / c) + (d * ((b / c) / c));
} else if (c <= 1.25e+107) {
tmp = 1.0 / (d / b);
} else {
tmp = t_0;
}
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 = (1.0d0 / c) * (a + (b / (c / d)))
if (c <= (-2.12d-26)) then
tmp = t_0
else if (c <= 3.4d-28) then
tmp = b / d
else if (c <= 2.7d+88) then
tmp = (a / c) + (d * ((b / c) / c))
else if (c <= 1.25d+107) then
tmp = 1.0d0 / (d / b)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = (1.0 / c) * (a + (b / (c / d)));
double tmp;
if (c <= -2.12e-26) {
tmp = t_0;
} else if (c <= 3.4e-28) {
tmp = b / d;
} else if (c <= 2.7e+88) {
tmp = (a / c) + (d * ((b / c) / c));
} else if (c <= 1.25e+107) {
tmp = 1.0 / (d / b);
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b, c, d): t_0 = (1.0 / c) * (a + (b / (c / d))) tmp = 0 if c <= -2.12e-26: tmp = t_0 elif c <= 3.4e-28: tmp = b / d elif c <= 2.7e+88: tmp = (a / c) + (d * ((b / c) / c)) elif c <= 1.25e+107: tmp = 1.0 / (d / b) else: tmp = t_0 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(1.0 / c) * Float64(a + Float64(b / Float64(c / d)))) tmp = 0.0 if (c <= -2.12e-26) tmp = t_0; elseif (c <= 3.4e-28) tmp = Float64(b / d); elseif (c <= 2.7e+88) tmp = Float64(Float64(a / c) + Float64(d * Float64(Float64(b / c) / c))); elseif (c <= 1.25e+107) tmp = Float64(1.0 / Float64(d / b)); else tmp = t_0; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (1.0 / c) * (a + (b / (c / d))); tmp = 0.0; if (c <= -2.12e-26) tmp = t_0; elseif (c <= 3.4e-28) tmp = b / d; elseif (c <= 2.7e+88) tmp = (a / c) + (d * ((b / c) / c)); elseif (c <= 1.25e+107) tmp = 1.0 / (d / b); else tmp = t_0; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(1.0 / c), $MachinePrecision] * N[(a + N[(b / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -2.12e-26], t$95$0, If[LessEqual[c, 3.4e-28], N[(b / d), $MachinePrecision], If[LessEqual[c, 2.7e+88], N[(N[(a / c), $MachinePrecision] + N[(d * N[(N[(b / c), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.25e+107], N[(1.0 / N[(d / b), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{c} \cdot \left(a + \frac{b}{\frac{c}{d}}\right)\\
\mathbf{if}\;c \leq -2.12 \cdot 10^{-26}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 3.4 \cdot 10^{-28}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{elif}\;c \leq 2.7 \cdot 10^{+88}:\\
\;\;\;\;\frac{a}{c} + d \cdot \frac{\frac{b}{c}}{c}\\
\mathbf{elif}\;c \leq 1.25 \cdot 10^{+107}:\\
\;\;\;\;\frac{1}{\frac{d}{b}}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if c < -2.12000000000000002e-26 or 1.25e107 < c Initial program 44.0%
*-un-lft-identity44.0%
+-commutative44.0%
fma-udef44.0%
add-sqr-sqrt44.0%
times-frac43.9%
fma-udef43.9%
+-commutative43.9%
hypot-def43.9%
fma-def43.9%
fma-udef43.9%
+-commutative43.9%
hypot-def62.3%
Applied egg-rr62.3%
Taylor expanded in c around inf 48.5%
associate-/l*51.1%
Simplified51.1%
Taylor expanded in c around inf 81.3%
if -2.12000000000000002e-26 < c < 3.4000000000000001e-28Initial program 74.6%
Taylor expanded in c around 0 74.8%
if 3.4000000000000001e-28 < c < 2.70000000000000016e88Initial program 96.0%
Taylor expanded in c around inf 77.1%
associate-/l*71.5%
Simplified71.5%
pow271.5%
*-un-lft-identity71.5%
times-frac71.5%
Applied egg-rr71.5%
/-rgt-identity71.5%
associate-/r*71.4%
associate-/r/77.3%
Applied egg-rr77.3%
if 2.70000000000000016e88 < c < 1.25e107Initial program 32.6%
*-un-lft-identity32.6%
+-commutative32.6%
fma-udef32.6%
add-sqr-sqrt32.6%
times-frac32.3%
fma-udef32.3%
+-commutative32.3%
hypot-def32.3%
fma-def32.3%
fma-udef32.3%
+-commutative32.3%
hypot-def71.5%
Applied egg-rr71.5%
Taylor expanded in c around 0 58.0%
Taylor expanded in c around 0 84.8%
associate-/r/85.0%
Applied egg-rr85.0%
Final simplification78.1%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (* (/ 1.0 c) (+ a (/ b (/ c d))))))
(if (<= c -9.8e-26)
t_0
(if (<= c 9e-25)
(+ (/ b d) (/ (/ (* a c) d) d))
(if (<= c 2.5e+88)
(+ (/ a c) (* d (/ (/ b c) c)))
(if (<= c 1.35e+107) (+ (/ b d) (* c (/ (/ a d) d))) t_0))))))
double code(double a, double b, double c, double d) {
double t_0 = (1.0 / c) * (a + (b / (c / d)));
double tmp;
if (c <= -9.8e-26) {
tmp = t_0;
} else if (c <= 9e-25) {
tmp = (b / d) + (((a * c) / d) / d);
} else if (c <= 2.5e+88) {
tmp = (a / c) + (d * ((b / c) / c));
} else if (c <= 1.35e+107) {
tmp = (b / d) + (c * ((a / d) / d));
} else {
tmp = t_0;
}
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 = (1.0d0 / c) * (a + (b / (c / d)))
if (c <= (-9.8d-26)) then
tmp = t_0
else if (c <= 9d-25) then
tmp = (b / d) + (((a * c) / d) / d)
else if (c <= 2.5d+88) then
tmp = (a / c) + (d * ((b / c) / c))
else if (c <= 1.35d+107) then
tmp = (b / d) + (c * ((a / d) / d))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = (1.0 / c) * (a + (b / (c / d)));
double tmp;
if (c <= -9.8e-26) {
tmp = t_0;
} else if (c <= 9e-25) {
tmp = (b / d) + (((a * c) / d) / d);
} else if (c <= 2.5e+88) {
tmp = (a / c) + (d * ((b / c) / c));
} else if (c <= 1.35e+107) {
tmp = (b / d) + (c * ((a / d) / d));
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b, c, d): t_0 = (1.0 / c) * (a + (b / (c / d))) tmp = 0 if c <= -9.8e-26: tmp = t_0 elif c <= 9e-25: tmp = (b / d) + (((a * c) / d) / d) elif c <= 2.5e+88: tmp = (a / c) + (d * ((b / c) / c)) elif c <= 1.35e+107: tmp = (b / d) + (c * ((a / d) / d)) else: tmp = t_0 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(1.0 / c) * Float64(a + Float64(b / Float64(c / d)))) tmp = 0.0 if (c <= -9.8e-26) tmp = t_0; elseif (c <= 9e-25) tmp = Float64(Float64(b / d) + Float64(Float64(Float64(a * c) / d) / d)); elseif (c <= 2.5e+88) tmp = Float64(Float64(a / c) + Float64(d * Float64(Float64(b / c) / c))); elseif (c <= 1.35e+107) tmp = Float64(Float64(b / d) + Float64(c * Float64(Float64(a / d) / d))); else tmp = t_0; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (1.0 / c) * (a + (b / (c / d))); tmp = 0.0; if (c <= -9.8e-26) tmp = t_0; elseif (c <= 9e-25) tmp = (b / d) + (((a * c) / d) / d); elseif (c <= 2.5e+88) tmp = (a / c) + (d * ((b / c) / c)); elseif (c <= 1.35e+107) tmp = (b / d) + (c * ((a / d) / d)); else tmp = t_0; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(1.0 / c), $MachinePrecision] * N[(a + N[(b / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -9.8e-26], t$95$0, If[LessEqual[c, 9e-25], N[(N[(b / d), $MachinePrecision] + N[(N[(N[(a * c), $MachinePrecision] / d), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 2.5e+88], N[(N[(a / c), $MachinePrecision] + N[(d * N[(N[(b / c), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.35e+107], N[(N[(b / d), $MachinePrecision] + N[(c * N[(N[(a / d), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{c} \cdot \left(a + \frac{b}{\frac{c}{d}}\right)\\
\mathbf{if}\;c \leq -9.8 \cdot 10^{-26}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 9 \cdot 10^{-25}:\\
\;\;\;\;\frac{b}{d} + \frac{\frac{a \cdot c}{d}}{d}\\
\mathbf{elif}\;c \leq 2.5 \cdot 10^{+88}:\\
\;\;\;\;\frac{a}{c} + d \cdot \frac{\frac{b}{c}}{c}\\
\mathbf{elif}\;c \leq 1.35 \cdot 10^{+107}:\\
\;\;\;\;\frac{b}{d} + c \cdot \frac{\frac{a}{d}}{d}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if c < -9.7999999999999998e-26 or 1.3500000000000001e107 < c Initial program 44.0%
*-un-lft-identity44.0%
+-commutative44.0%
fma-udef44.0%
add-sqr-sqrt44.0%
times-frac43.9%
fma-udef43.9%
+-commutative43.9%
hypot-def43.9%
fma-def43.9%
fma-udef43.9%
+-commutative43.9%
hypot-def62.3%
Applied egg-rr62.3%
Taylor expanded in c around inf 48.5%
associate-/l*51.1%
Simplified51.1%
Taylor expanded in c around inf 81.3%
if -9.7999999999999998e-26 < c < 9.0000000000000002e-25Initial program 74.6%
Taylor expanded in c around 0 82.1%
associate-/l*82.4%
associate-/r/79.5%
Simplified79.5%
associate-*l/82.1%
unpow282.1%
associate-/r*88.9%
*-commutative88.9%
Applied egg-rr88.9%
if 9.0000000000000002e-25 < c < 2.49999999999999999e88Initial program 96.0%
Taylor expanded in c around inf 77.1%
associate-/l*71.5%
Simplified71.5%
pow271.5%
*-un-lft-identity71.5%
times-frac71.5%
Applied egg-rr71.5%
/-rgt-identity71.5%
associate-/r*71.4%
associate-/r/77.3%
Applied egg-rr77.3%
if 2.49999999999999999e88 < c < 1.3500000000000001e107Initial program 32.6%
Taylor expanded in c around 0 85.0%
associate-/l*85.0%
associate-/r/85.0%
Simplified85.0%
*-un-lft-identity85.0%
unpow285.0%
times-frac86.2%
Applied egg-rr86.2%
associate-*l/86.2%
*-lft-identity86.2%
Simplified86.2%
Final simplification84.6%
(FPCore (a b c d)
:precision binary64
(if (<= c -7e-27)
(* (/ 1.0 c) (+ a (/ b (/ c d))))
(if (<= c 1.1e-30)
(+ (/ b d) (/ (/ (* a c) d) d))
(if (<= c 2.7e+88)
(+ (/ a c) (* d (/ (/ b c) c)))
(if (<= c 1.25e+107)
(+ (/ b d) (* c (/ (/ a d) d)))
(+ (/ a c) (/ b (* c (/ c d)))))))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -7e-27) {
tmp = (1.0 / c) * (a + (b / (c / d)));
} else if (c <= 1.1e-30) {
tmp = (b / d) + (((a * c) / d) / d);
} else if (c <= 2.7e+88) {
tmp = (a / c) + (d * ((b / c) / c));
} else if (c <= 1.25e+107) {
tmp = (b / d) + (c * ((a / d) / d));
} else {
tmp = (a / c) + (b / (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 (c <= (-7d-27)) then
tmp = (1.0d0 / c) * (a + (b / (c / d)))
else if (c <= 1.1d-30) then
tmp = (b / d) + (((a * c) / d) / d)
else if (c <= 2.7d+88) then
tmp = (a / c) + (d * ((b / c) / c))
else if (c <= 1.25d+107) then
tmp = (b / d) + (c * ((a / d) / d))
else
tmp = (a / c) + (b / (c * (c / d)))
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -7e-27) {
tmp = (1.0 / c) * (a + (b / (c / d)));
} else if (c <= 1.1e-30) {
tmp = (b / d) + (((a * c) / d) / d);
} else if (c <= 2.7e+88) {
tmp = (a / c) + (d * ((b / c) / c));
} else if (c <= 1.25e+107) {
tmp = (b / d) + (c * ((a / d) / d));
} else {
tmp = (a / c) + (b / (c * (c / d)));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -7e-27: tmp = (1.0 / c) * (a + (b / (c / d))) elif c <= 1.1e-30: tmp = (b / d) + (((a * c) / d) / d) elif c <= 2.7e+88: tmp = (a / c) + (d * ((b / c) / c)) elif c <= 1.25e+107: tmp = (b / d) + (c * ((a / d) / d)) else: tmp = (a / c) + (b / (c * (c / d))) return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -7e-27) tmp = Float64(Float64(1.0 / c) * Float64(a + Float64(b / Float64(c / d)))); elseif (c <= 1.1e-30) tmp = Float64(Float64(b / d) + Float64(Float64(Float64(a * c) / d) / d)); elseif (c <= 2.7e+88) tmp = Float64(Float64(a / c) + Float64(d * Float64(Float64(b / c) / c))); elseif (c <= 1.25e+107) tmp = Float64(Float64(b / d) + Float64(c * Float64(Float64(a / d) / d))); else tmp = Float64(Float64(a / c) + Float64(b / Float64(c * Float64(c / d)))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -7e-27) tmp = (1.0 / c) * (a + (b / (c / d))); elseif (c <= 1.1e-30) tmp = (b / d) + (((a * c) / d) / d); elseif (c <= 2.7e+88) tmp = (a / c) + (d * ((b / c) / c)); elseif (c <= 1.25e+107) tmp = (b / d) + (c * ((a / d) / d)); else tmp = (a / c) + (b / (c * (c / d))); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -7e-27], N[(N[(1.0 / c), $MachinePrecision] * N[(a + N[(b / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.1e-30], N[(N[(b / d), $MachinePrecision] + N[(N[(N[(a * c), $MachinePrecision] / d), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 2.7e+88], N[(N[(a / c), $MachinePrecision] + N[(d * N[(N[(b / c), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.25e+107], N[(N[(b / d), $MachinePrecision] + N[(c * N[(N[(a / d), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a / c), $MachinePrecision] + N[(b / N[(c * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -7 \cdot 10^{-27}:\\
\;\;\;\;\frac{1}{c} \cdot \left(a + \frac{b}{\frac{c}{d}}\right)\\
\mathbf{elif}\;c \leq 1.1 \cdot 10^{-30}:\\
\;\;\;\;\frac{b}{d} + \frac{\frac{a \cdot c}{d}}{d}\\
\mathbf{elif}\;c \leq 2.7 \cdot 10^{+88}:\\
\;\;\;\;\frac{a}{c} + d \cdot \frac{\frac{b}{c}}{c}\\
\mathbf{elif}\;c \leq 1.25 \cdot 10^{+107}:\\
\;\;\;\;\frac{b}{d} + c \cdot \frac{\frac{a}{d}}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{b}{c \cdot \frac{c}{d}}\\
\end{array}
\end{array}
if c < -7.0000000000000003e-27Initial program 51.4%
*-un-lft-identity51.4%
+-commutative51.4%
fma-udef51.4%
add-sqr-sqrt51.3%
times-frac51.3%
fma-udef51.3%
+-commutative51.3%
hypot-def51.3%
fma-def51.3%
fma-udef51.3%
+-commutative51.3%
hypot-def68.5%
Applied egg-rr68.5%
Taylor expanded in c around inf 16.9%
associate-/l*16.9%
Simplified16.9%
Taylor expanded in c around inf 75.4%
if -7.0000000000000003e-27 < c < 1.09999999999999992e-30Initial program 74.6%
Taylor expanded in c around 0 82.1%
associate-/l*82.4%
associate-/r/79.5%
Simplified79.5%
associate-*l/82.1%
unpow282.1%
associate-/r*88.9%
*-commutative88.9%
Applied egg-rr88.9%
if 1.09999999999999992e-30 < c < 2.70000000000000016e88Initial program 96.0%
Taylor expanded in c around inf 77.1%
associate-/l*71.5%
Simplified71.5%
pow271.5%
*-un-lft-identity71.5%
times-frac71.5%
Applied egg-rr71.5%
/-rgt-identity71.5%
associate-/r*71.4%
associate-/r/77.3%
Applied egg-rr77.3%
if 2.70000000000000016e88 < c < 1.25e107Initial program 32.6%
Taylor expanded in c around 0 85.0%
associate-/l*85.0%
associate-/r/85.0%
Simplified85.0%
*-un-lft-identity85.0%
unpow285.0%
times-frac86.2%
Applied egg-rr86.2%
associate-*l/86.2%
*-lft-identity86.2%
Simplified86.2%
if 1.25e107 < c Initial program 36.0%
Taylor expanded in c around inf 77.5%
associate-/l*79.4%
Simplified79.4%
pow279.4%
*-un-lft-identity79.4%
times-frac87.8%
Applied egg-rr87.8%
Final simplification84.7%
(FPCore (a b c d) :precision binary64 (if (or (<= d -9e-46) (not (<= d 3.3e-47))) (+ (/ b d) (* c (/ (/ a d) d))) (* (/ 1.0 c) (+ a (/ b (/ c d))))))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -9e-46) || !(d <= 3.3e-47)) {
tmp = (b / d) + (c * ((a / d) / d));
} else {
tmp = (1.0 / c) * (a + (b / (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 <= (-9d-46)) .or. (.not. (d <= 3.3d-47))) then
tmp = (b / d) + (c * ((a / d) / d))
else
tmp = (1.0d0 / c) * (a + (b / (c / d)))
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -9e-46) || !(d <= 3.3e-47)) {
tmp = (b / d) + (c * ((a / d) / d));
} else {
tmp = (1.0 / c) * (a + (b / (c / d)));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -9e-46) or not (d <= 3.3e-47): tmp = (b / d) + (c * ((a / d) / d)) else: tmp = (1.0 / c) * (a + (b / (c / d))) return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -9e-46) || !(d <= 3.3e-47)) tmp = Float64(Float64(b / d) + Float64(c * Float64(Float64(a / d) / d))); else tmp = Float64(Float64(1.0 / c) * Float64(a + Float64(b / Float64(c / d)))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -9e-46) || ~((d <= 3.3e-47))) tmp = (b / d) + (c * ((a / d) / d)); else tmp = (1.0 / c) * (a + (b / (c / d))); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -9e-46], N[Not[LessEqual[d, 3.3e-47]], $MachinePrecision]], N[(N[(b / d), $MachinePrecision] + N[(c * N[(N[(a / d), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / c), $MachinePrecision] * N[(a + N[(b / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -9 \cdot 10^{-46} \lor \neg \left(d \leq 3.3 \cdot 10^{-47}\right):\\
\;\;\;\;\frac{b}{d} + c \cdot \frac{\frac{a}{d}}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{c} \cdot \left(a + \frac{b}{\frac{c}{d}}\right)\\
\end{array}
\end{array}
if d < -9.00000000000000001e-46 or 3.30000000000000004e-47 < d Initial program 56.6%
Taylor expanded in c around 0 72.4%
associate-/l*71.1%
associate-/r/72.6%
Simplified72.6%
*-un-lft-identity72.6%
unpow272.6%
times-frac73.3%
Applied egg-rr73.3%
associate-*l/73.3%
*-lft-identity73.3%
Simplified73.3%
if -9.00000000000000001e-46 < d < 3.30000000000000004e-47Initial program 67.4%
*-un-lft-identity67.4%
+-commutative67.4%
fma-udef67.4%
add-sqr-sqrt67.4%
times-frac67.3%
fma-udef67.3%
+-commutative67.3%
hypot-def67.3%
fma-def67.3%
fma-udef67.3%
+-commutative67.3%
hypot-def80.2%
Applied egg-rr80.2%
Taylor expanded in c around inf 55.5%
associate-/l*54.7%
Simplified54.7%
Taylor expanded in c around inf 83.7%
Final simplification77.8%
(FPCore (a b c d)
:precision binary64
(if (<= c -2.35e-20)
(/ a c)
(if (<= c 2.75e-30)
(/ b d)
(if (or (<= c 2.7e+88) (not (<= c 1.25e+107))) (/ a c) (/ 1.0 (/ d b))))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -2.35e-20) {
tmp = a / c;
} else if (c <= 2.75e-30) {
tmp = b / d;
} else if ((c <= 2.7e+88) || !(c <= 1.25e+107)) {
tmp = a / c;
} else {
tmp = 1.0 / (d / b);
}
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 <= (-2.35d-20)) then
tmp = a / c
else if (c <= 2.75d-30) then
tmp = b / d
else if ((c <= 2.7d+88) .or. (.not. (c <= 1.25d+107))) then
tmp = a / c
else
tmp = 1.0d0 / (d / b)
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -2.35e-20) {
tmp = a / c;
} else if (c <= 2.75e-30) {
tmp = b / d;
} else if ((c <= 2.7e+88) || !(c <= 1.25e+107)) {
tmp = a / c;
} else {
tmp = 1.0 / (d / b);
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -2.35e-20: tmp = a / c elif c <= 2.75e-30: tmp = b / d elif (c <= 2.7e+88) or not (c <= 1.25e+107): tmp = a / c else: tmp = 1.0 / (d / b) return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -2.35e-20) tmp = Float64(a / c); elseif (c <= 2.75e-30) tmp = Float64(b / d); elseif ((c <= 2.7e+88) || !(c <= 1.25e+107)) tmp = Float64(a / c); else tmp = Float64(1.0 / Float64(d / b)); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -2.35e-20) tmp = a / c; elseif (c <= 2.75e-30) tmp = b / d; elseif ((c <= 2.7e+88) || ~((c <= 1.25e+107))) tmp = a / c; else tmp = 1.0 / (d / b); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -2.35e-20], N[(a / c), $MachinePrecision], If[LessEqual[c, 2.75e-30], N[(b / d), $MachinePrecision], If[Or[LessEqual[c, 2.7e+88], N[Not[LessEqual[c, 1.25e+107]], $MachinePrecision]], N[(a / c), $MachinePrecision], N[(1.0 / N[(d / b), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -2.35 \cdot 10^{-20}:\\
\;\;\;\;\frac{a}{c}\\
\mathbf{elif}\;c \leq 2.75 \cdot 10^{-30}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{elif}\;c \leq 2.7 \cdot 10^{+88} \lor \neg \left(c \leq 1.25 \cdot 10^{+107}\right):\\
\;\;\;\;\frac{a}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{d}{b}}\\
\end{array}
\end{array}
if c < -2.35000000000000007e-20 or 2.74999999999999988e-30 < c < 2.70000000000000016e88 or 1.25e107 < c Initial program 50.0%
Taylor expanded in c around inf 68.7%
if -2.35000000000000007e-20 < c < 2.74999999999999988e-30Initial program 75.0%
Taylor expanded in c around 0 73.6%
if 2.70000000000000016e88 < c < 1.25e107Initial program 32.6%
*-un-lft-identity32.6%
+-commutative32.6%
fma-udef32.6%
add-sqr-sqrt32.6%
times-frac32.3%
fma-udef32.3%
+-commutative32.3%
hypot-def32.3%
fma-def32.3%
fma-udef32.3%
+-commutative32.3%
hypot-def71.5%
Applied egg-rr71.5%
Taylor expanded in c around 0 58.0%
Taylor expanded in c around 0 84.8%
associate-/r/85.0%
Applied egg-rr85.0%
Final simplification71.5%
(FPCore (a b c d)
:precision binary64
(if (or (<= c -1.36e-19)
(not (or (<= c 2e-26) (and (not (<= c 2.7e+88)) (<= c 1.25e+107)))))
(/ a c)
(/ b d)))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -1.36e-19) || !((c <= 2e-26) || (!(c <= 2.7e+88) && (c <= 1.25e+107)))) {
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 <= (-1.36d-19)) .or. (.not. (c <= 2d-26) .or. (.not. (c <= 2.7d+88)) .and. (c <= 1.25d+107))) 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 <= -1.36e-19) || !((c <= 2e-26) || (!(c <= 2.7e+88) && (c <= 1.25e+107)))) {
tmp = a / c;
} else {
tmp = b / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -1.36e-19) or not ((c <= 2e-26) or (not (c <= 2.7e+88) and (c <= 1.25e+107))): tmp = a / c else: tmp = b / d return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -1.36e-19) || !((c <= 2e-26) || (!(c <= 2.7e+88) && (c <= 1.25e+107)))) 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 <= -1.36e-19) || ~(((c <= 2e-26) || (~((c <= 2.7e+88)) && (c <= 1.25e+107))))) tmp = a / c; else tmp = b / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -1.36e-19], N[Not[Or[LessEqual[c, 2e-26], And[N[Not[LessEqual[c, 2.7e+88]], $MachinePrecision], LessEqual[c, 1.25e+107]]]], $MachinePrecision]], N[(a / c), $MachinePrecision], N[(b / d), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.36 \cdot 10^{-19} \lor \neg \left(c \leq 2 \cdot 10^{-26} \lor \neg \left(c \leq 2.7 \cdot 10^{+88}\right) \land c \leq 1.25 \cdot 10^{+107}\right):\\
\;\;\;\;\frac{a}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d}\\
\end{array}
\end{array}
if c < -1.3599999999999999e-19 or 2.0000000000000001e-26 < c < 2.70000000000000016e88 or 1.25e107 < c Initial program 50.0%
Taylor expanded in c around inf 68.7%
if -1.3599999999999999e-19 < c < 2.0000000000000001e-26 or 2.70000000000000016e88 < c < 1.25e107Initial program 72.7%
Taylor expanded in c around 0 74.2%
Final simplification71.5%
(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.2%
Taylor expanded in c around inf 40.8%
Final simplification40.8%
(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 2024011
(FPCore (a b c d)
:name "Complex division, real part"
:precision binary64
:herbie-target
(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))))