
(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))) (t_1 (+ (/ a c) (* (/ d c) (/ b c)))))
(if (<= c -9.2e+50)
t_1
(if (<= c -2e-97)
(/ t_0 (fma c c (* d d)))
(if (<= c 1.7e-160)
(* (/ 1.0 d) (+ b (* a (/ c d))))
(if (<= c 1.12e-11) (/ t_0 (+ (* c c) (* d d))) t_1))))))
double code(double a, double b, double c, double d) {
double t_0 = (a * c) + (b * d);
double t_1 = (a / c) + ((d / c) * (b / c));
double tmp;
if (c <= -9.2e+50) {
tmp = t_1;
} else if (c <= -2e-97) {
tmp = t_0 / fma(c, c, (d * d));
} else if (c <= 1.7e-160) {
tmp = (1.0 / d) * (b + (a * (c / d)));
} else if (c <= 1.12e-11) {
tmp = t_0 / ((c * c) + (d * d));
} else {
tmp = t_1;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(a * c) + Float64(b * d)) t_1 = Float64(Float64(a / c) + Float64(Float64(d / c) * Float64(b / c))) tmp = 0.0 if (c <= -9.2e+50) tmp = t_1; elseif (c <= -2e-97) tmp = Float64(t_0 / fma(c, c, Float64(d * d))); elseif (c <= 1.7e-160) tmp = Float64(Float64(1.0 / d) * Float64(b + Float64(a * Float64(c / d)))); elseif (c <= 1.12e-11) tmp = Float64(t_0 / Float64(Float64(c * c) + Float64(d * d))); else tmp = t_1; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(a / c), $MachinePrecision] + N[(N[(d / c), $MachinePrecision] * N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -9.2e+50], t$95$1, If[LessEqual[c, -2e-97], N[(t$95$0 / N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.7e-160], N[(N[(1.0 / d), $MachinePrecision] * N[(b + N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.12e-11], N[(t$95$0 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := a \cdot c + b \cdot d\\
t_1 := \frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\
\mathbf{if}\;c \leq -9.2 \cdot 10^{+50}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;c \leq -2 \cdot 10^{-97}:\\
\;\;\;\;\frac{t_0}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\
\mathbf{elif}\;c \leq 1.7 \cdot 10^{-160}:\\
\;\;\;\;\frac{1}{d} \cdot \left(b + a \cdot \frac{c}{d}\right)\\
\mathbf{elif}\;c \leq 1.12 \cdot 10^{-11}:\\
\;\;\;\;\frac{t_0}{c \cdot c + d \cdot d}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if c < -9.19999999999999987e50 or 1.1200000000000001e-11 < c Initial program 44.4%
Taylor expanded in c around inf 79.1%
*-commutative79.1%
unpow279.1%
times-frac85.2%
Simplified85.2%
if -9.19999999999999987e50 < c < -2.00000000000000007e-97Initial program 87.5%
fma-def87.5%
fma-def87.6%
Simplified87.6%
fma-def87.6%
+-commutative87.6%
Applied egg-rr87.6%
if -2.00000000000000007e-97 < c < 1.70000000000000011e-160Initial program 73.3%
Taylor expanded in c around 0 81.4%
*-commutative81.4%
unpow281.4%
times-frac91.7%
Simplified91.7%
+-commutative91.7%
frac-times81.4%
associate-/l/92.9%
div-inv92.9%
div-inv92.6%
distribute-rgt-out93.8%
div-inv93.9%
*-commutative93.9%
associate-*l*93.8%
div-inv93.9%
Applied egg-rr93.9%
if 1.70000000000000011e-160 < c < 1.1200000000000001e-11Initial program 91.7%
Final simplification89.0%
(FPCore (a b c d) :precision binary64 (if (<= (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))) 1e+305) (* (/ 1.0 (hypot c d)) (/ (fma a c (* b d)) (hypot c d))) (+ (/ a c) (* (/ d c) (/ b c)))))
double code(double a, double b, double c, double d) {
double tmp;
if ((((a * c) + (b * d)) / ((c * c) + (d * d))) <= 1e+305) {
tmp = (1.0 / hypot(c, d)) * (fma(a, c, (b * d)) / hypot(c, d));
} else {
tmp = (a / c) + ((d / c) * (b / c));
}
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))) <= 1e+305) 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(Float64(d / c) * Float64(b / c))); 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], 1e+305], 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[(N[(d / c), $MachinePrecision] * N[(b / c), $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 10^{+305}:\\
\;\;\;\;\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{d}{c} \cdot \frac{b}{c}\\
\end{array}
\end{array}
if (/.f64 (+.f64 (*.f64 a c) (*.f64 b d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 9.9999999999999994e304Initial program 79.6%
*-un-lft-identity79.6%
add-sqr-sqrt79.6%
times-frac79.6%
hypot-def79.6%
fma-def79.6%
hypot-def95.6%
Applied egg-rr95.6%
if 9.9999999999999994e304 < (/.f64 (+.f64 (*.f64 a c) (*.f64 b d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 17.6%
Taylor expanded in c around inf 53.9%
*-commutative53.9%
unpow253.9%
times-frac66.3%
Simplified66.3%
Final simplification88.3%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))))
(t_1 (+ (/ a c) (* (/ d c) (/ b c)))))
(if (<= c -2.95e+50)
t_1
(if (<= c -9e-109)
t_0
(if (<= c 1.15e-160)
(* (/ 1.0 d) (+ b (* a (/ c d))))
(if (<= c 1.12e-11) t_0 t_1))))))
double code(double a, double b, double c, double d) {
double t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d));
double t_1 = (a / c) + ((d / c) * (b / c));
double tmp;
if (c <= -2.95e+50) {
tmp = t_1;
} else if (c <= -9e-109) {
tmp = t_0;
} else if (c <= 1.15e-160) {
tmp = (1.0 / d) * (b + (a * (c / d)));
} else if (c <= 1.12e-11) {
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 = ((a * c) + (b * d)) / ((c * c) + (d * d))
t_1 = (a / c) + ((d / c) * (b / c))
if (c <= (-2.95d+50)) then
tmp = t_1
else if (c <= (-9d-109)) then
tmp = t_0
else if (c <= 1.15d-160) then
tmp = (1.0d0 / d) * (b + (a * (c / d)))
else if (c <= 1.12d-11) 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 = ((a * c) + (b * d)) / ((c * c) + (d * d));
double t_1 = (a / c) + ((d / c) * (b / c));
double tmp;
if (c <= -2.95e+50) {
tmp = t_1;
} else if (c <= -9e-109) {
tmp = t_0;
} else if (c <= 1.15e-160) {
tmp = (1.0 / d) * (b + (a * (c / d)));
} else if (c <= 1.12e-11) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(a, b, c, d): t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d)) t_1 = (a / c) + ((d / c) * (b / c)) tmp = 0 if c <= -2.95e+50: tmp = t_1 elif c <= -9e-109: tmp = t_0 elif c <= 1.15e-160: tmp = (1.0 / d) * (b + (a * (c / d))) elif c <= 1.12e-11: tmp = t_0 else: tmp = t_1 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d))) t_1 = Float64(Float64(a / c) + Float64(Float64(d / c) * Float64(b / c))) tmp = 0.0 if (c <= -2.95e+50) tmp = t_1; elseif (c <= -9e-109) tmp = t_0; elseif (c <= 1.15e-160) tmp = Float64(Float64(1.0 / d) * Float64(b + Float64(a * Float64(c / d)))); elseif (c <= 1.12e-11) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d)); t_1 = (a / c) + ((d / c) * (b / c)); tmp = 0.0; if (c <= -2.95e+50) tmp = t_1; elseif (c <= -9e-109) tmp = t_0; elseif (c <= 1.15e-160) tmp = (1.0 / d) * (b + (a * (c / d))); elseif (c <= 1.12e-11) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(a / c), $MachinePrecision] + N[(N[(d / c), $MachinePrecision] * N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -2.95e+50], t$95$1, If[LessEqual[c, -9e-109], t$95$0, If[LessEqual[c, 1.15e-160], N[(N[(1.0 / d), $MachinePrecision] * N[(b + N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.12e-11], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\
t_1 := \frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\
\mathbf{if}\;c \leq -2.95 \cdot 10^{+50}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;c \leq -9 \cdot 10^{-109}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 1.15 \cdot 10^{-160}:\\
\;\;\;\;\frac{1}{d} \cdot \left(b + a \cdot \frac{c}{d}\right)\\
\mathbf{elif}\;c \leq 1.12 \cdot 10^{-11}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if c < -2.9499999999999999e50 or 1.1200000000000001e-11 < c Initial program 44.4%
Taylor expanded in c around inf 79.1%
*-commutative79.1%
unpow279.1%
times-frac85.2%
Simplified85.2%
if -2.9499999999999999e50 < c < -9.0000000000000002e-109 or 1.14999999999999992e-160 < c < 1.1200000000000001e-11Initial program 89.9%
if -9.0000000000000002e-109 < c < 1.14999999999999992e-160Initial program 73.3%
Taylor expanded in c around 0 81.4%
*-commutative81.4%
unpow281.4%
times-frac91.7%
Simplified91.7%
+-commutative91.7%
frac-times81.4%
associate-/l/92.9%
div-inv92.9%
div-inv92.6%
distribute-rgt-out93.8%
div-inv93.9%
*-commutative93.9%
associate-*l*93.8%
div-inv93.9%
Applied egg-rr93.9%
Final simplification89.0%
(FPCore (a b c d)
:precision binary64
(if (or (<= c -1.85e-28)
(and (not (<= c 7.5e-109)) (or (<= c 2.4e-31) (not (<= c 1.45e-11)))))
(+ (/ a c) (* b (/ d (* c c))))
(* (/ 1.0 d) (+ b (* a (/ c d))))))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -1.85e-28) || (!(c <= 7.5e-109) && ((c <= 2.4e-31) || !(c <= 1.45e-11)))) {
tmp = (a / c) + (b * (d / (c * c)));
} else {
tmp = (1.0 / d) * (b + (a * (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 <= (-1.85d-28)) .or. (.not. (c <= 7.5d-109)) .and. (c <= 2.4d-31) .or. (.not. (c <= 1.45d-11))) then
tmp = (a / c) + (b * (d / (c * c)))
else
tmp = (1.0d0 / d) * (b + (a * (c / d)))
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -1.85e-28) || (!(c <= 7.5e-109) && ((c <= 2.4e-31) || !(c <= 1.45e-11)))) {
tmp = (a / c) + (b * (d / (c * c)));
} else {
tmp = (1.0 / d) * (b + (a * (c / d)));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -1.85e-28) or (not (c <= 7.5e-109) and ((c <= 2.4e-31) or not (c <= 1.45e-11))): tmp = (a / c) + (b * (d / (c * c))) else: tmp = (1.0 / d) * (b + (a * (c / d))) return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -1.85e-28) || (!(c <= 7.5e-109) && ((c <= 2.4e-31) || !(c <= 1.45e-11)))) tmp = Float64(Float64(a / c) + Float64(b * Float64(d / Float64(c * c)))); else tmp = Float64(Float64(1.0 / d) * Float64(b + Float64(a * Float64(c / d)))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((c <= -1.85e-28) || (~((c <= 7.5e-109)) && ((c <= 2.4e-31) || ~((c <= 1.45e-11))))) tmp = (a / c) + (b * (d / (c * c))); else tmp = (1.0 / d) * (b + (a * (c / d))); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -1.85e-28], And[N[Not[LessEqual[c, 7.5e-109]], $MachinePrecision], Or[LessEqual[c, 2.4e-31], N[Not[LessEqual[c, 1.45e-11]], $MachinePrecision]]]], N[(N[(a / c), $MachinePrecision] + N[(b * N[(d / N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / d), $MachinePrecision] * N[(b + N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.85 \cdot 10^{-28} \lor \neg \left(c \leq 7.5 \cdot 10^{-109}\right) \land \left(c \leq 2.4 \cdot 10^{-31} \lor \neg \left(c \leq 1.45 \cdot 10^{-11}\right)\right):\\
\;\;\;\;\frac{a}{c} + b \cdot \frac{d}{c \cdot c}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{d} \cdot \left(b + a \cdot \frac{c}{d}\right)\\
\end{array}
\end{array}
if c < -1.8500000000000001e-28 or 7.49999999999999982e-109 < c < 2.4e-31 or 1.45e-11 < c Initial program 54.8%
Taylor expanded in c around inf 77.3%
unpow277.3%
associate-/l*77.6%
Simplified77.6%
Taylor expanded in b around 0 77.3%
unpow277.3%
*-lft-identity77.3%
times-frac77.6%
/-rgt-identity77.6%
Simplified77.6%
if -1.8500000000000001e-28 < c < 7.49999999999999982e-109 or 2.4e-31 < c < 1.45e-11Initial program 75.9%
Taylor expanded in c around 0 79.0%
*-commutative79.0%
unpow279.0%
times-frac86.6%
Simplified86.6%
+-commutative86.6%
frac-times79.0%
associate-/l/87.4%
div-inv87.4%
div-inv87.2%
distribute-rgt-out88.0%
div-inv88.0%
*-commutative88.0%
associate-*l*88.0%
div-inv88.0%
Applied egg-rr88.0%
Final simplification82.2%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (* (/ 1.0 d) (+ b (* a (/ c d)))))
(t_1 (+ (/ a c) (* b (/ d (* c c))))))
(if (<= c -1.45e-31)
t_1
(if (<= c 3.4e-105)
t_0
(if (<= c 5.2e-38)
t_1
(if (<= c 1.3e-11) t_0 (+ (/ a c) (* d (/ b (* c c))))))))))
double code(double a, double b, double c, double d) {
double t_0 = (1.0 / d) * (b + (a * (c / d)));
double t_1 = (a / c) + (b * (d / (c * c)));
double tmp;
if (c <= -1.45e-31) {
tmp = t_1;
} else if (c <= 3.4e-105) {
tmp = t_0;
} else if (c <= 5.2e-38) {
tmp = t_1;
} else if (c <= 1.3e-11) {
tmp = t_0;
} else {
tmp = (a / c) + (d * (b / (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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (1.0d0 / d) * (b + (a * (c / d)))
t_1 = (a / c) + (b * (d / (c * c)))
if (c <= (-1.45d-31)) then
tmp = t_1
else if (c <= 3.4d-105) then
tmp = t_0
else if (c <= 5.2d-38) then
tmp = t_1
else if (c <= 1.3d-11) then
tmp = t_0
else
tmp = (a / c) + (d * (b / (c * c)))
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = (1.0 / d) * (b + (a * (c / d)));
double t_1 = (a / c) + (b * (d / (c * c)));
double tmp;
if (c <= -1.45e-31) {
tmp = t_1;
} else if (c <= 3.4e-105) {
tmp = t_0;
} else if (c <= 5.2e-38) {
tmp = t_1;
} else if (c <= 1.3e-11) {
tmp = t_0;
} else {
tmp = (a / c) + (d * (b / (c * c)));
}
return tmp;
}
def code(a, b, c, d): t_0 = (1.0 / d) * (b + (a * (c / d))) t_1 = (a / c) + (b * (d / (c * c))) tmp = 0 if c <= -1.45e-31: tmp = t_1 elif c <= 3.4e-105: tmp = t_0 elif c <= 5.2e-38: tmp = t_1 elif c <= 1.3e-11: tmp = t_0 else: tmp = (a / c) + (d * (b / (c * c))) return tmp
function code(a, b, c, d) t_0 = Float64(Float64(1.0 / d) * Float64(b + Float64(a * Float64(c / d)))) t_1 = Float64(Float64(a / c) + Float64(b * Float64(d / Float64(c * c)))) tmp = 0.0 if (c <= -1.45e-31) tmp = t_1; elseif (c <= 3.4e-105) tmp = t_0; elseif (c <= 5.2e-38) tmp = t_1; elseif (c <= 1.3e-11) tmp = t_0; else tmp = Float64(Float64(a / c) + Float64(d * Float64(b / Float64(c * c)))); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (1.0 / d) * (b + (a * (c / d))); t_1 = (a / c) + (b * (d / (c * c))); tmp = 0.0; if (c <= -1.45e-31) tmp = t_1; elseif (c <= 3.4e-105) tmp = t_0; elseif (c <= 5.2e-38) tmp = t_1; elseif (c <= 1.3e-11) tmp = t_0; else tmp = (a / c) + (d * (b / (c * c))); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(1.0 / d), $MachinePrecision] * N[(b + N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(a / c), $MachinePrecision] + N[(b * N[(d / N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -1.45e-31], t$95$1, If[LessEqual[c, 3.4e-105], t$95$0, If[LessEqual[c, 5.2e-38], t$95$1, If[LessEqual[c, 1.3e-11], t$95$0, N[(N[(a / c), $MachinePrecision] + N[(d * N[(b / N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{d} \cdot \left(b + a \cdot \frac{c}{d}\right)\\
t_1 := \frac{a}{c} + b \cdot \frac{d}{c \cdot c}\\
\mathbf{if}\;c \leq -1.45 \cdot 10^{-31}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;c \leq 3.4 \cdot 10^{-105}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 5.2 \cdot 10^{-38}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;c \leq 1.3 \cdot 10^{-11}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + d \cdot \frac{b}{c \cdot c}\\
\end{array}
\end{array}
if c < -1.45e-31 or 3.39999999999999992e-105 < c < 5.20000000000000022e-38Initial program 60.6%
Taylor expanded in c around inf 75.5%
unpow275.5%
associate-/l*75.8%
Simplified75.8%
Taylor expanded in b around 0 75.5%
unpow275.5%
*-lft-identity75.5%
times-frac75.8%
/-rgt-identity75.8%
Simplified75.8%
if -1.45e-31 < c < 3.39999999999999992e-105 or 5.20000000000000022e-38 < c < 1.3e-11Initial program 75.9%
Taylor expanded in c around 0 79.0%
*-commutative79.0%
unpow279.0%
times-frac86.6%
Simplified86.6%
+-commutative86.6%
frac-times79.0%
associate-/l/87.4%
div-inv87.4%
div-inv87.2%
distribute-rgt-out88.0%
div-inv88.0%
*-commutative88.0%
associate-*l*88.0%
div-inv88.0%
Applied egg-rr88.0%
if 1.3e-11 < c Initial program 47.2%
Taylor expanded in c around inf 79.7%
unpow279.7%
associate-/l*80.0%
Simplified80.0%
associate-/r/83.0%
Applied egg-rr83.0%
Final simplification82.9%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (* (/ 1.0 d) (+ b (* a (/ c d)))))
(t_1 (+ (/ a c) (* (/ d c) (/ b c)))))
(if (<= c -5.3e-29)
t_1
(if (<= c 6.8e-105)
t_0
(if (<= c 6.2e-37)
(+ (/ a c) (* b (/ d (* c c))))
(if (<= c 1.3e-11) t_0 t_1))))))
double code(double a, double b, double c, double d) {
double t_0 = (1.0 / d) * (b + (a * (c / d)));
double t_1 = (a / c) + ((d / c) * (b / c));
double tmp;
if (c <= -5.3e-29) {
tmp = t_1;
} else if (c <= 6.8e-105) {
tmp = t_0;
} else if (c <= 6.2e-37) {
tmp = (a / c) + (b * (d / (c * c)));
} else if (c <= 1.3e-11) {
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 = (1.0d0 / d) * (b + (a * (c / d)))
t_1 = (a / c) + ((d / c) * (b / c))
if (c <= (-5.3d-29)) then
tmp = t_1
else if (c <= 6.8d-105) then
tmp = t_0
else if (c <= 6.2d-37) then
tmp = (a / c) + (b * (d / (c * c)))
else if (c <= 1.3d-11) 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 = (1.0 / d) * (b + (a * (c / d)));
double t_1 = (a / c) + ((d / c) * (b / c));
double tmp;
if (c <= -5.3e-29) {
tmp = t_1;
} else if (c <= 6.8e-105) {
tmp = t_0;
} else if (c <= 6.2e-37) {
tmp = (a / c) + (b * (d / (c * c)));
} else if (c <= 1.3e-11) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(a, b, c, d): t_0 = (1.0 / d) * (b + (a * (c / d))) t_1 = (a / c) + ((d / c) * (b / c)) tmp = 0 if c <= -5.3e-29: tmp = t_1 elif c <= 6.8e-105: tmp = t_0 elif c <= 6.2e-37: tmp = (a / c) + (b * (d / (c * c))) elif c <= 1.3e-11: tmp = t_0 else: tmp = t_1 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(1.0 / d) * Float64(b + Float64(a * Float64(c / d)))) t_1 = Float64(Float64(a / c) + Float64(Float64(d / c) * Float64(b / c))) tmp = 0.0 if (c <= -5.3e-29) tmp = t_1; elseif (c <= 6.8e-105) tmp = t_0; elseif (c <= 6.2e-37) tmp = Float64(Float64(a / c) + Float64(b * Float64(d / Float64(c * c)))); elseif (c <= 1.3e-11) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (1.0 / d) * (b + (a * (c / d))); t_1 = (a / c) + ((d / c) * (b / c)); tmp = 0.0; if (c <= -5.3e-29) tmp = t_1; elseif (c <= 6.8e-105) tmp = t_0; elseif (c <= 6.2e-37) tmp = (a / c) + (b * (d / (c * c))); elseif (c <= 1.3e-11) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(1.0 / d), $MachinePrecision] * N[(b + N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(a / c), $MachinePrecision] + N[(N[(d / c), $MachinePrecision] * N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -5.3e-29], t$95$1, If[LessEqual[c, 6.8e-105], t$95$0, If[LessEqual[c, 6.2e-37], N[(N[(a / c), $MachinePrecision] + N[(b * N[(d / N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.3e-11], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{d} \cdot \left(b + a \cdot \frac{c}{d}\right)\\
t_1 := \frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\
\mathbf{if}\;c \leq -5.3 \cdot 10^{-29}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;c \leq 6.8 \cdot 10^{-105}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 6.2 \cdot 10^{-37}:\\
\;\;\;\;\frac{a}{c} + b \cdot \frac{d}{c \cdot c}\\
\mathbf{elif}\;c \leq 1.3 \cdot 10^{-11}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if c < -5.2999999999999999e-29 or 1.3e-11 < c Initial program 48.8%
Taylor expanded in c around inf 79.3%
*-commutative79.3%
unpow279.3%
times-frac84.2%
Simplified84.2%
if -5.2999999999999999e-29 < c < 6.79999999999999984e-105 or 6.19999999999999987e-37 < c < 1.3e-11Initial program 75.9%
Taylor expanded in c around 0 79.0%
*-commutative79.0%
unpow279.0%
times-frac86.6%
Simplified86.6%
+-commutative86.6%
frac-times79.0%
associate-/l/87.4%
div-inv87.4%
div-inv87.2%
distribute-rgt-out88.0%
div-inv88.0%
*-commutative88.0%
associate-*l*88.0%
div-inv88.0%
Applied egg-rr88.0%
if 6.79999999999999984e-105 < c < 6.19999999999999987e-37Initial program 94.5%
Taylor expanded in c around inf 64.7%
unpow264.7%
associate-/l*64.7%
Simplified64.7%
Taylor expanded in b around 0 64.7%
unpow264.7%
*-lft-identity64.7%
times-frac64.7%
/-rgt-identity64.7%
Simplified64.7%
Final simplification84.5%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (* (/ 1.0 d) (+ b (* a (/ c d))))))
(if (<= c -3.8e-28)
(+ (/ a c) (/ (* b (/ d c)) c))
(if (<= c 6.8e-105)
t_0
(if (<= c 5.6e-30)
(+ (/ a c) (* b (/ d (* c c))))
(if (<= c 1.2e-11) t_0 (+ (/ a c) (* (/ d c) (/ b c)))))))))
double code(double a, double b, double c, double d) {
double t_0 = (1.0 / d) * (b + (a * (c / d)));
double tmp;
if (c <= -3.8e-28) {
tmp = (a / c) + ((b * (d / c)) / c);
} else if (c <= 6.8e-105) {
tmp = t_0;
} else if (c <= 5.6e-30) {
tmp = (a / c) + (b * (d / (c * c)));
} else if (c <= 1.2e-11) {
tmp = t_0;
} else {
tmp = (a / c) + ((d / c) * (b / 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) :: t_0
real(8) :: tmp
t_0 = (1.0d0 / d) * (b + (a * (c / d)))
if (c <= (-3.8d-28)) then
tmp = (a / c) + ((b * (d / c)) / c)
else if (c <= 6.8d-105) then
tmp = t_0
else if (c <= 5.6d-30) then
tmp = (a / c) + (b * (d / (c * c)))
else if (c <= 1.2d-11) then
tmp = t_0
else
tmp = (a / c) + ((d / c) * (b / c))
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = (1.0 / d) * (b + (a * (c / d)));
double tmp;
if (c <= -3.8e-28) {
tmp = (a / c) + ((b * (d / c)) / c);
} else if (c <= 6.8e-105) {
tmp = t_0;
} else if (c <= 5.6e-30) {
tmp = (a / c) + (b * (d / (c * c)));
} else if (c <= 1.2e-11) {
tmp = t_0;
} else {
tmp = (a / c) + ((d / c) * (b / c));
}
return tmp;
}
def code(a, b, c, d): t_0 = (1.0 / d) * (b + (a * (c / d))) tmp = 0 if c <= -3.8e-28: tmp = (a / c) + ((b * (d / c)) / c) elif c <= 6.8e-105: tmp = t_0 elif c <= 5.6e-30: tmp = (a / c) + (b * (d / (c * c))) elif c <= 1.2e-11: tmp = t_0 else: tmp = (a / c) + ((d / c) * (b / c)) return tmp
function code(a, b, c, d) t_0 = Float64(Float64(1.0 / d) * Float64(b + Float64(a * Float64(c / d)))) tmp = 0.0 if (c <= -3.8e-28) tmp = Float64(Float64(a / c) + Float64(Float64(b * Float64(d / c)) / c)); elseif (c <= 6.8e-105) tmp = t_0; elseif (c <= 5.6e-30) tmp = Float64(Float64(a / c) + Float64(b * Float64(d / Float64(c * c)))); elseif (c <= 1.2e-11) tmp = t_0; else tmp = Float64(Float64(a / c) + Float64(Float64(d / c) * Float64(b / c))); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (1.0 / d) * (b + (a * (c / d))); tmp = 0.0; if (c <= -3.8e-28) tmp = (a / c) + ((b * (d / c)) / c); elseif (c <= 6.8e-105) tmp = t_0; elseif (c <= 5.6e-30) tmp = (a / c) + (b * (d / (c * c))); elseif (c <= 1.2e-11) tmp = t_0; else tmp = (a / c) + ((d / c) * (b / c)); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(1.0 / d), $MachinePrecision] * N[(b + N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -3.8e-28], N[(N[(a / c), $MachinePrecision] + N[(N[(b * N[(d / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 6.8e-105], t$95$0, If[LessEqual[c, 5.6e-30], N[(N[(a / c), $MachinePrecision] + N[(b * N[(d / N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.2e-11], t$95$0, N[(N[(a / c), $MachinePrecision] + N[(N[(d / c), $MachinePrecision] * N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{d} \cdot \left(b + a \cdot \frac{c}{d}\right)\\
\mathbf{if}\;c \leq -3.8 \cdot 10^{-28}:\\
\;\;\;\;\frac{a}{c} + \frac{b \cdot \frac{d}{c}}{c}\\
\mathbf{elif}\;c \leq 6.8 \cdot 10^{-105}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 5.6 \cdot 10^{-30}:\\
\;\;\;\;\frac{a}{c} + b \cdot \frac{d}{c \cdot c}\\
\mathbf{elif}\;c \leq 1.2 \cdot 10^{-11}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\
\end{array}
\end{array}
if c < -3.80000000000000009e-28Initial program 50.3%
Taylor expanded in c around inf 78.9%
unpow278.9%
associate-/l*79.2%
Simplified79.2%
associate-/r/79.1%
Applied egg-rr79.1%
associate-*l/78.9%
associate-/r*80.7%
associate-*r/82.4%
Applied egg-rr82.4%
if -3.80000000000000009e-28 < c < 6.79999999999999984e-105 or 5.59999999999999977e-30 < c < 1.2000000000000001e-11Initial program 75.9%
Taylor expanded in c around 0 79.0%
*-commutative79.0%
unpow279.0%
times-frac86.6%
Simplified86.6%
+-commutative86.6%
frac-times79.0%
associate-/l/87.4%
div-inv87.4%
div-inv87.2%
distribute-rgt-out88.0%
div-inv88.0%
*-commutative88.0%
associate-*l*88.0%
div-inv88.0%
Applied egg-rr88.0%
if 6.79999999999999984e-105 < c < 5.59999999999999977e-30Initial program 94.5%
Taylor expanded in c around inf 64.7%
unpow264.7%
associate-/l*64.7%
Simplified64.7%
Taylor expanded in b around 0 64.7%
unpow264.7%
*-lft-identity64.7%
times-frac64.7%
/-rgt-identity64.7%
Simplified64.7%
if 1.2000000000000001e-11 < c Initial program 47.2%
Taylor expanded in c around inf 79.7%
*-commutative79.7%
unpow279.7%
times-frac87.6%
Simplified87.6%
Final simplification84.8%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (* (/ 1.0 d) (+ b (* a (/ c d))))) (t_1 (* b (/ d c))))
(if (<= c -2.8e-32)
(+ (/ a c) (/ t_1 c))
(if (<= c 4e-106)
t_0
(if (<= c 8.6e-31)
(+ (/ a c) (/ 1.0 (/ c t_1)))
(if (<= c 1.15e-11) t_0 (+ (/ a c) (* (/ d c) (/ b c)))))))))
double code(double a, double b, double c, double d) {
double t_0 = (1.0 / d) * (b + (a * (c / d)));
double t_1 = b * (d / c);
double tmp;
if (c <= -2.8e-32) {
tmp = (a / c) + (t_1 / c);
} else if (c <= 4e-106) {
tmp = t_0;
} else if (c <= 8.6e-31) {
tmp = (a / c) + (1.0 / (c / t_1));
} else if (c <= 1.15e-11) {
tmp = t_0;
} else {
tmp = (a / c) + ((d / c) * (b / 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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (1.0d0 / d) * (b + (a * (c / d)))
t_1 = b * (d / c)
if (c <= (-2.8d-32)) then
tmp = (a / c) + (t_1 / c)
else if (c <= 4d-106) then
tmp = t_0
else if (c <= 8.6d-31) then
tmp = (a / c) + (1.0d0 / (c / t_1))
else if (c <= 1.15d-11) then
tmp = t_0
else
tmp = (a / c) + ((d / c) * (b / c))
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = (1.0 / d) * (b + (a * (c / d)));
double t_1 = b * (d / c);
double tmp;
if (c <= -2.8e-32) {
tmp = (a / c) + (t_1 / c);
} else if (c <= 4e-106) {
tmp = t_0;
} else if (c <= 8.6e-31) {
tmp = (a / c) + (1.0 / (c / t_1));
} else if (c <= 1.15e-11) {
tmp = t_0;
} else {
tmp = (a / c) + ((d / c) * (b / c));
}
return tmp;
}
def code(a, b, c, d): t_0 = (1.0 / d) * (b + (a * (c / d))) t_1 = b * (d / c) tmp = 0 if c <= -2.8e-32: tmp = (a / c) + (t_1 / c) elif c <= 4e-106: tmp = t_0 elif c <= 8.6e-31: tmp = (a / c) + (1.0 / (c / t_1)) elif c <= 1.15e-11: tmp = t_0 else: tmp = (a / c) + ((d / c) * (b / c)) return tmp
function code(a, b, c, d) t_0 = Float64(Float64(1.0 / d) * Float64(b + Float64(a * Float64(c / d)))) t_1 = Float64(b * Float64(d / c)) tmp = 0.0 if (c <= -2.8e-32) tmp = Float64(Float64(a / c) + Float64(t_1 / c)); elseif (c <= 4e-106) tmp = t_0; elseif (c <= 8.6e-31) tmp = Float64(Float64(a / c) + Float64(1.0 / Float64(c / t_1))); elseif (c <= 1.15e-11) tmp = t_0; else tmp = Float64(Float64(a / c) + Float64(Float64(d / c) * Float64(b / c))); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (1.0 / d) * (b + (a * (c / d))); t_1 = b * (d / c); tmp = 0.0; if (c <= -2.8e-32) tmp = (a / c) + (t_1 / c); elseif (c <= 4e-106) tmp = t_0; elseif (c <= 8.6e-31) tmp = (a / c) + (1.0 / (c / t_1)); elseif (c <= 1.15e-11) tmp = t_0; else tmp = (a / c) + ((d / c) * (b / c)); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(1.0 / d), $MachinePrecision] * N[(b + N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(b * N[(d / c), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -2.8e-32], N[(N[(a / c), $MachinePrecision] + N[(t$95$1 / c), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 4e-106], t$95$0, If[LessEqual[c, 8.6e-31], N[(N[(a / c), $MachinePrecision] + N[(1.0 / N[(c / t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.15e-11], t$95$0, N[(N[(a / c), $MachinePrecision] + N[(N[(d / c), $MachinePrecision] * N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{d} \cdot \left(b + a \cdot \frac{c}{d}\right)\\
t_1 := b \cdot \frac{d}{c}\\
\mathbf{if}\;c \leq -2.8 \cdot 10^{-32}:\\
\;\;\;\;\frac{a}{c} + \frac{t_1}{c}\\
\mathbf{elif}\;c \leq 4 \cdot 10^{-106}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 8.6 \cdot 10^{-31}:\\
\;\;\;\;\frac{a}{c} + \frac{1}{\frac{c}{t_1}}\\
\mathbf{elif}\;c \leq 1.15 \cdot 10^{-11}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\
\end{array}
\end{array}
if c < -2.7999999999999999e-32Initial program 50.3%
Taylor expanded in c around inf 78.9%
unpow278.9%
associate-/l*79.2%
Simplified79.2%
associate-/r/79.1%
Applied egg-rr79.1%
associate-*l/78.9%
associate-/r*80.7%
associate-*r/82.4%
Applied egg-rr82.4%
if -2.7999999999999999e-32 < c < 3.99999999999999976e-106 or 8.6e-31 < c < 1.15000000000000007e-11Initial program 75.9%
Taylor expanded in c around 0 79.0%
*-commutative79.0%
unpow279.0%
times-frac86.6%
Simplified86.6%
+-commutative86.6%
frac-times79.0%
associate-/l/87.4%
div-inv87.4%
div-inv87.2%
distribute-rgt-out88.0%
div-inv88.0%
*-commutative88.0%
associate-*l*88.0%
div-inv88.0%
Applied egg-rr88.0%
if 3.99999999999999976e-106 < c < 8.6e-31Initial program 94.5%
Taylor expanded in c around inf 64.7%
unpow264.7%
associate-/l*64.7%
Simplified64.7%
clear-num64.7%
inv-pow64.7%
associate-/l*64.6%
Applied egg-rr64.6%
unpow-164.6%
associate-/l/64.7%
Simplified64.7%
if 1.15000000000000007e-11 < c Initial program 47.2%
Taylor expanded in c around inf 79.7%
*-commutative79.7%
unpow279.7%
times-frac87.6%
Simplified87.6%
Final simplification84.8%
(FPCore (a b c d) :precision binary64 (if (or (<= c -5.5e-47) (not (<= c 1.5e-11))) (/ a (+ c (/ (* d d) c))) (* (/ 1.0 d) (+ b (* a (/ c d))))))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -5.5e-47) || !(c <= 1.5e-11)) {
tmp = a / (c + ((d * d) / c));
} else {
tmp = (1.0 / d) * (b + (a * (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 <= (-5.5d-47)) .or. (.not. (c <= 1.5d-11))) then
tmp = a / (c + ((d * d) / c))
else
tmp = (1.0d0 / d) * (b + (a * (c / d)))
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -5.5e-47) || !(c <= 1.5e-11)) {
tmp = a / (c + ((d * d) / c));
} else {
tmp = (1.0 / d) * (b + (a * (c / d)));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -5.5e-47) or not (c <= 1.5e-11): tmp = a / (c + ((d * d) / c)) else: tmp = (1.0 / d) * (b + (a * (c / d))) return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -5.5e-47) || !(c <= 1.5e-11)) tmp = Float64(a / Float64(c + Float64(Float64(d * d) / c))); else tmp = Float64(Float64(1.0 / d) * Float64(b + Float64(a * Float64(c / d)))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((c <= -5.5e-47) || ~((c <= 1.5e-11))) tmp = a / (c + ((d * d) / c)); else tmp = (1.0 / d) * (b + (a * (c / d))); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -5.5e-47], N[Not[LessEqual[c, 1.5e-11]], $MachinePrecision]], N[(a / N[(c + N[(N[(d * d), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / d), $MachinePrecision] * N[(b + N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -5.5 \cdot 10^{-47} \lor \neg \left(c \leq 1.5 \cdot 10^{-11}\right):\\
\;\;\;\;\frac{a}{c + \frac{d \cdot d}{c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{d} \cdot \left(b + a \cdot \frac{c}{d}\right)\\
\end{array}
\end{array}
if c < -5.5000000000000002e-47 or 1.5e-11 < c Initial program 49.6%
Taylor expanded in a around inf 43.5%
associate-/l*50.4%
unpow250.4%
unpow250.4%
+-commutative50.4%
fma-udef50.4%
Simplified50.4%
Taylor expanded in d around 0 76.1%
unpow276.1%
Simplified76.1%
if -5.5000000000000002e-47 < c < 1.5e-11Initial program 78.2%
Taylor expanded in c around 0 73.6%
*-commutative73.6%
unpow273.6%
times-frac80.3%
Simplified80.3%
+-commutative80.3%
frac-times73.6%
associate-/l/81.0%
div-inv81.0%
div-inv80.8%
distribute-rgt-out81.5%
div-inv81.5%
*-commutative81.5%
associate-*l*81.5%
div-inv81.6%
Applied egg-rr81.6%
Final simplification78.9%
(FPCore (a b c d) :precision binary64 (if (or (<= c -3.1e-94) (not (<= c 8.5e-121))) (/ a (+ c (/ (* d d) c))) (/ b d)))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -3.1e-94) || !(c <= 8.5e-121)) {
tmp = a / (c + ((d * d) / 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 <= (-3.1d-94)) .or. (.not. (c <= 8.5d-121))) then
tmp = a / (c + ((d * d) / 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 <= -3.1e-94) || !(c <= 8.5e-121)) {
tmp = a / (c + ((d * d) / c));
} else {
tmp = b / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -3.1e-94) or not (c <= 8.5e-121): tmp = a / (c + ((d * d) / c)) else: tmp = b / d return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -3.1e-94) || !(c <= 8.5e-121)) tmp = Float64(a / Float64(c + Float64(Float64(d * d) / c))); else tmp = Float64(b / d); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((c <= -3.1e-94) || ~((c <= 8.5e-121))) tmp = a / (c + ((d * d) / c)); else tmp = b / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -3.1e-94], N[Not[LessEqual[c, 8.5e-121]], $MachinePrecision]], N[(a / N[(c + N[(N[(d * d), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(b / d), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -3.1 \cdot 10^{-94} \lor \neg \left(c \leq 8.5 \cdot 10^{-121}\right):\\
\;\;\;\;\frac{a}{c + \frac{d \cdot d}{c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d}\\
\end{array}
\end{array}
if c < -3.0999999999999998e-94 or 8.50000000000000025e-121 < c Initial program 58.5%
Taylor expanded in a around inf 45.8%
associate-/l*51.1%
unpow251.1%
unpow251.1%
+-commutative51.1%
fma-udef51.1%
Simplified51.1%
Taylor expanded in d around 0 70.7%
unpow270.7%
Simplified70.7%
if -3.0999999999999998e-94 < c < 8.50000000000000025e-121Initial program 74.5%
Taylor expanded in c around 0 79.2%
Final simplification73.7%
(FPCore (a b c d) :precision binary64 (if (<= c -6.8e-7) (/ a c) (if (<= c 9.5e-121) (/ b d) (/ a c))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -6.8e-7) {
tmp = a / c;
} else if (c <= 9.5e-121) {
tmp = b / d;
} else {
tmp = a / c;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (c <= (-6.8d-7)) then
tmp = a / c
else if (c <= 9.5d-121) then
tmp = b / d
else
tmp = a / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -6.8e-7) {
tmp = a / c;
} else if (c <= 9.5e-121) {
tmp = b / d;
} else {
tmp = a / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -6.8e-7: tmp = a / c elif c <= 9.5e-121: tmp = b / d else: tmp = a / c return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -6.8e-7) tmp = Float64(a / c); elseif (c <= 9.5e-121) tmp = Float64(b / d); else tmp = Float64(a / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -6.8e-7) tmp = a / c; elseif (c <= 9.5e-121) tmp = b / d; else tmp = a / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -6.8e-7], N[(a / c), $MachinePrecision], If[LessEqual[c, 9.5e-121], N[(b / d), $MachinePrecision], N[(a / c), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -6.8 \cdot 10^{-7}:\\
\;\;\;\;\frac{a}{c}\\
\mathbf{elif}\;c \leq 9.5 \cdot 10^{-121}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c}\\
\end{array}
\end{array}
if c < -6.79999999999999948e-7 or 9.4999999999999994e-121 < c Initial program 55.2%
Taylor expanded in c around inf 69.2%
if -6.79999999999999948e-7 < c < 9.4999999999999994e-121Initial program 76.1%
Taylor expanded in c around 0 72.1%
Final simplification70.4%
(FPCore (a b c d) :precision binary64 (/ a c))
double code(double a, double b, double c, double d) {
return a / c;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = a / c
end function
public static double code(double a, double b, double c, double d) {
return a / c;
}
def code(a, b, c, d): return a / c
function code(a, b, c, d) return Float64(a / c) end
function tmp = code(a, b, c, d) tmp = a / c; end
code[a_, b_, c_, d_] := N[(a / c), $MachinePrecision]
\begin{array}{l}
\\
\frac{a}{c}
\end{array}
Initial program 64.1%
Taylor expanded in c around inf 46.7%
Final simplification46.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 2023279
(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))))