
(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 14 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 (if (<= (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))) 2e+306) (* (/ 1.0 (hypot c d)) (/ (fma a c (* b d)) (hypot c d))) (/ (/ b (hypot d c)) (/ (hypot d c) d))))
double code(double a, double b, double c, double d) {
double tmp;
if ((((a * c) + (b * d)) / ((c * c) + (d * d))) <= 2e+306) {
tmp = (1.0 / hypot(c, d)) * (fma(a, c, (b * d)) / hypot(c, d));
} else {
tmp = (b / hypot(d, c)) / (hypot(d, 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))) <= 2e+306) tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(fma(a, c, Float64(b * d)) / hypot(c, d))); else tmp = Float64(Float64(b / hypot(d, c)) / Float64(hypot(d, 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], 2e+306], N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(N[(a * c + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision] / N[(N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \leq 2 \cdot 10^{+306}:\\
\;\;\;\;\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{\frac{b}{\mathsf{hypot}\left(d, c\right)}}{\frac{\mathsf{hypot}\left(d, c\right)}{d}}\\
\end{array}
\end{array}
if (/.f64 (+.f64 (*.f64 a c) (*.f64 b d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 2.00000000000000003e306Initial program 81.0%
*-un-lft-identity81.0%
add-sqr-sqrt81.0%
times-frac81.1%
hypot-def81.1%
fma-def81.1%
hypot-def94.7%
Applied egg-rr94.7%
if 2.00000000000000003e306 < (/.f64 (+.f64 (*.f64 a c) (*.f64 b d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 5.6%
Taylor expanded in a around 0 4.4%
add-sqr-sqrt4.4%
sqrt-div4.1%
hypot-udef4.1%
sqrt-div4.1%
hypot-udef5.3%
times-frac4.1%
add-sqr-sqrt4.4%
times-frac69.6%
Applied egg-rr69.6%
*-commutative69.6%
clear-num69.7%
un-div-inv69.7%
hypot-udef10.2%
+-commutative10.2%
hypot-def69.7%
hypot-udef10.2%
+-commutative10.2%
hypot-def69.7%
Applied egg-rr69.7%
Final simplification89.1%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))))
(t_1 (* (/ d (hypot c d)) (/ b (hypot c d)))))
(if (<= d -3.6e+46)
t_1
(if (<= d -3e-130)
t_0
(if (<= d 4.7e-139)
(* (/ 1.0 c) (+ a (/ d (/ c b))))
(if (<= d 1.05e+25) t_0 t_1))))))
double code(double a, double b, double c, double d) {
double t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d));
double t_1 = (d / hypot(c, d)) * (b / hypot(c, d));
double tmp;
if (d <= -3.6e+46) {
tmp = t_1;
} else if (d <= -3e-130) {
tmp = t_0;
} else if (d <= 4.7e-139) {
tmp = (1.0 / c) * (a + (d / (c / b)));
} else if (d <= 1.05e+25) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d));
double t_1 = (d / Math.hypot(c, d)) * (b / Math.hypot(c, d));
double tmp;
if (d <= -3.6e+46) {
tmp = t_1;
} else if (d <= -3e-130) {
tmp = t_0;
} else if (d <= 4.7e-139) {
tmp = (1.0 / c) * (a + (d / (c / b)));
} else if (d <= 1.05e+25) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(a, b, c, d): t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d)) t_1 = (d / math.hypot(c, d)) * (b / math.hypot(c, d)) tmp = 0 if d <= -3.6e+46: tmp = t_1 elif d <= -3e-130: tmp = t_0 elif d <= 4.7e-139: tmp = (1.0 / c) * (a + (d / (c / b))) elif d <= 1.05e+25: tmp = t_0 else: tmp = t_1 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d))) t_1 = Float64(Float64(d / hypot(c, d)) * Float64(b / hypot(c, d))) tmp = 0.0 if (d <= -3.6e+46) tmp = t_1; elseif (d <= -3e-130) tmp = t_0; elseif (d <= 4.7e-139) tmp = Float64(Float64(1.0 / c) * Float64(a + Float64(d / Float64(c / b)))); elseif (d <= 1.05e+25) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d)); t_1 = (d / hypot(c, d)) * (b / hypot(c, d)); tmp = 0.0; if (d <= -3.6e+46) tmp = t_1; elseif (d <= -3e-130) tmp = t_0; elseif (d <= 4.7e-139) tmp = (1.0 / c) * (a + (d / (c / b))); elseif (d <= 1.05e+25) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(d / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -3.6e+46], t$95$1, If[LessEqual[d, -3e-130], t$95$0, If[LessEqual[d, 4.7e-139], N[(N[(1.0 / c), $MachinePrecision] * N[(a + N[(d / N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.05e+25], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\
t_1 := \frac{d}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{if}\;d \leq -3.6 \cdot 10^{+46}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d \leq -3 \cdot 10^{-130}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 4.7 \cdot 10^{-139}:\\
\;\;\;\;\frac{1}{c} \cdot \left(a + \frac{d}{\frac{c}{b}}\right)\\
\mathbf{elif}\;d \leq 1.05 \cdot 10^{+25}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if d < -3.5999999999999999e46 or 1.05e25 < d Initial program 45.3%
Taylor expanded in a around 0 42.4%
add-sqr-sqrt28.8%
sqrt-div20.5%
hypot-udef20.5%
sqrt-div20.5%
hypot-udef26.0%
times-frac20.5%
add-sqr-sqrt42.4%
times-frac84.7%
Applied egg-rr84.7%
if -3.5999999999999999e46 < d < -2.99999999999999986e-130 or 4.70000000000000027e-139 < d < 1.05e25Initial program 90.0%
if -2.99999999999999986e-130 < d < 4.70000000000000027e-139Initial program 74.2%
*-un-lft-identity74.2%
add-sqr-sqrt74.2%
times-frac74.3%
hypot-def74.3%
fma-def74.3%
hypot-def84.8%
Applied egg-rr84.8%
Taylor expanded in c around inf 42.2%
associate-/l*42.3%
Simplified42.3%
Taylor expanded in c around inf 90.0%
Final simplification87.4%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))))
(t_1 (/ (/ b (hypot d c)) (/ (hypot d c) d))))
(if (<= d -7.5e+48)
t_1
(if (<= d -3.05e-130)
t_0
(if (<= d 2.8e-139)
(* (/ 1.0 c) (+ a (/ d (/ c b))))
(if (<= d 2.65e+24) 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 = (b / hypot(d, c)) / (hypot(d, c) / d);
double tmp;
if (d <= -7.5e+48) {
tmp = t_1;
} else if (d <= -3.05e-130) {
tmp = t_0;
} else if (d <= 2.8e-139) {
tmp = (1.0 / c) * (a + (d / (c / b)));
} else if (d <= 2.65e+24) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d));
double t_1 = (b / Math.hypot(d, c)) / (Math.hypot(d, c) / d);
double tmp;
if (d <= -7.5e+48) {
tmp = t_1;
} else if (d <= -3.05e-130) {
tmp = t_0;
} else if (d <= 2.8e-139) {
tmp = (1.0 / c) * (a + (d / (c / b)));
} else if (d <= 2.65e+24) {
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 = (b / math.hypot(d, c)) / (math.hypot(d, c) / d) tmp = 0 if d <= -7.5e+48: tmp = t_1 elif d <= -3.05e-130: tmp = t_0 elif d <= 2.8e-139: tmp = (1.0 / c) * (a + (d / (c / b))) elif d <= 2.65e+24: 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(b / hypot(d, c)) / Float64(hypot(d, c) / d)) tmp = 0.0 if (d <= -7.5e+48) tmp = t_1; elseif (d <= -3.05e-130) tmp = t_0; elseif (d <= 2.8e-139) tmp = Float64(Float64(1.0 / c) * Float64(a + Float64(d / Float64(c / b)))); elseif (d <= 2.65e+24) 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 = (b / hypot(d, c)) / (hypot(d, c) / d); tmp = 0.0; if (d <= -7.5e+48) tmp = t_1; elseif (d <= -3.05e-130) tmp = t_0; elseif (d <= 2.8e-139) tmp = (1.0 / c) * (a + (d / (c / b))); elseif (d <= 2.65e+24) 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[(b / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision] / N[(N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -7.5e+48], t$95$1, If[LessEqual[d, -3.05e-130], t$95$0, If[LessEqual[d, 2.8e-139], N[(N[(1.0 / c), $MachinePrecision] * N[(a + N[(d / N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.65e+24], 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{\frac{b}{\mathsf{hypot}\left(d, c\right)}}{\frac{\mathsf{hypot}\left(d, c\right)}{d}}\\
\mathbf{if}\;d \leq -7.5 \cdot 10^{+48}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d \leq -3.05 \cdot 10^{-130}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 2.8 \cdot 10^{-139}:\\
\;\;\;\;\frac{1}{c} \cdot \left(a + \frac{d}{\frac{c}{b}}\right)\\
\mathbf{elif}\;d \leq 2.65 \cdot 10^{+24}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if d < -7.5000000000000006e48 or 2.6499999999999999e24 < d Initial program 45.3%
Taylor expanded in a around 0 42.4%
add-sqr-sqrt28.8%
sqrt-div20.5%
hypot-udef20.5%
sqrt-div20.5%
hypot-udef26.0%
times-frac20.5%
add-sqr-sqrt42.4%
times-frac84.7%
Applied egg-rr84.7%
*-commutative84.7%
clear-num84.7%
un-div-inv84.8%
hypot-udef47.3%
+-commutative47.3%
hypot-def84.8%
hypot-udef47.3%
+-commutative47.3%
hypot-def84.8%
Applied egg-rr84.8%
if -7.5000000000000006e48 < d < -3.04999999999999998e-130 or 2.7999999999999999e-139 < d < 2.6499999999999999e24Initial program 90.0%
if -3.04999999999999998e-130 < d < 2.7999999999999999e-139Initial program 74.2%
*-un-lft-identity74.2%
add-sqr-sqrt74.2%
times-frac74.3%
hypot-def74.3%
fma-def74.3%
hypot-def84.8%
Applied egg-rr84.8%
Taylor expanded in c around inf 42.2%
associate-/l*42.3%
Simplified42.3%
Taylor expanded in c around inf 90.0%
Final simplification87.4%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))))
(if (<= d -1.3e+68)
(* (+ b (/ c (/ d a))) (/ -1.0 (hypot c d)))
(if (<= d -2.35e-126)
t_0
(if (<= d 4.7e-139)
(* (/ 1.0 c) (+ a (/ d (/ c b))))
(if (<= d 4.4e+79) t_0 (+ (/ b d) (* (/ c d) (/ a d)))))))))
double code(double a, double b, double c, double d) {
double t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d));
double tmp;
if (d <= -1.3e+68) {
tmp = (b + (c / (d / a))) * (-1.0 / hypot(c, d));
} else if (d <= -2.35e-126) {
tmp = t_0;
} else if (d <= 4.7e-139) {
tmp = (1.0 / c) * (a + (d / (c / b)));
} else if (d <= 4.4e+79) {
tmp = t_0;
} else {
tmp = (b / d) + ((c / d) * (a / 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 (d <= -1.3e+68) {
tmp = (b + (c / (d / a))) * (-1.0 / Math.hypot(c, d));
} else if (d <= -2.35e-126) {
tmp = t_0;
} else if (d <= 4.7e-139) {
tmp = (1.0 / c) * (a + (d / (c / b)));
} else if (d <= 4.4e+79) {
tmp = t_0;
} else {
tmp = (b / d) + ((c / d) * (a / d));
}
return tmp;
}
def code(a, b, c, d): t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d)) tmp = 0 if d <= -1.3e+68: tmp = (b + (c / (d / a))) * (-1.0 / math.hypot(c, d)) elif d <= -2.35e-126: tmp = t_0 elif d <= 4.7e-139: tmp = (1.0 / c) * (a + (d / (c / b))) elif d <= 4.4e+79: tmp = t_0 else: tmp = (b / d) + ((c / d) * (a / d)) return tmp
function code(a, b, c, d) t_0 = Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d))) tmp = 0.0 if (d <= -1.3e+68) tmp = Float64(Float64(b + Float64(c / Float64(d / a))) * Float64(-1.0 / hypot(c, d))); elseif (d <= -2.35e-126) tmp = t_0; elseif (d <= 4.7e-139) tmp = Float64(Float64(1.0 / c) * Float64(a + Float64(d / Float64(c / b)))); elseif (d <= 4.4e+79) tmp = t_0; else tmp = Float64(Float64(b / d) + Float64(Float64(c / d) * Float64(a / d))); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d)); tmp = 0.0; if (d <= -1.3e+68) tmp = (b + (c / (d / a))) * (-1.0 / hypot(c, d)); elseif (d <= -2.35e-126) tmp = t_0; elseif (d <= 4.7e-139) tmp = (1.0 / c) * (a + (d / (c / b))); elseif (d <= 4.4e+79) tmp = t_0; else tmp = (b / d) + ((c / d) * (a / d)); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -1.3e+68], N[(N[(b + N[(c / N[(d / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(-1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -2.35e-126], t$95$0, If[LessEqual[d, 4.7e-139], N[(N[(1.0 / c), $MachinePrecision] * N[(a + N[(d / N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 4.4e+79], t$95$0, N[(N[(b / d), $MachinePrecision] + N[(N[(c / d), $MachinePrecision] * N[(a / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{if}\;d \leq -1.3 \cdot 10^{+68}:\\
\;\;\;\;\left(b + \frac{c}{\frac{d}{a}}\right) \cdot \frac{-1}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;d \leq -2.35 \cdot 10^{-126}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 4.7 \cdot 10^{-139}:\\
\;\;\;\;\frac{1}{c} \cdot \left(a + \frac{d}{\frac{c}{b}}\right)\\
\mathbf{elif}\;d \leq 4.4 \cdot 10^{+79}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d} + \frac{c}{d} \cdot \frac{a}{d}\\
\end{array}
\end{array}
if d < -1.2999999999999999e68Initial program 46.7%
*-un-lft-identity46.7%
add-sqr-sqrt46.7%
times-frac46.7%
hypot-def46.7%
fma-def46.7%
hypot-def64.5%
Applied egg-rr64.5%
Taylor expanded in d around -inf 82.7%
neg-mul-182.7%
+-commutative82.7%
unsub-neg82.7%
mul-1-neg82.7%
associate-/l*86.3%
distribute-neg-frac86.3%
Simplified86.3%
if -1.2999999999999999e68 < d < -2.35000000000000009e-126 or 4.70000000000000027e-139 < d < 4.3999999999999998e79Initial program 83.6%
if -2.35000000000000009e-126 < d < 4.70000000000000027e-139Initial program 74.2%
*-un-lft-identity74.2%
add-sqr-sqrt74.2%
times-frac74.3%
hypot-def74.3%
fma-def74.3%
hypot-def84.8%
Applied egg-rr84.8%
Taylor expanded in c around inf 42.2%
associate-/l*42.3%
Simplified42.3%
Taylor expanded in c around inf 90.0%
if 4.3999999999999998e79 < d Initial program 37.8%
Taylor expanded in c around 0 78.5%
unpow278.5%
times-frac82.4%
Simplified82.4%
Final simplification85.6%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))))
(t_1 (+ (/ b d) (* (/ c d) (/ a d)))))
(if (<= d -4.1e+71)
t_1
(if (<= d -9.2e-129)
t_0
(if (<= d 3.2e-139)
(* (/ 1.0 c) (+ a (/ d (/ c b))))
(if (<= d 1.5e+81) 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 = (b / d) + ((c / d) * (a / d));
double tmp;
if (d <= -4.1e+71) {
tmp = t_1;
} else if (d <= -9.2e-129) {
tmp = t_0;
} else if (d <= 3.2e-139) {
tmp = (1.0 / c) * (a + (d / (c / b)));
} else if (d <= 1.5e+81) {
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 = (b / d) + ((c / d) * (a / d))
if (d <= (-4.1d+71)) then
tmp = t_1
else if (d <= (-9.2d-129)) then
tmp = t_0
else if (d <= 3.2d-139) then
tmp = (1.0d0 / c) * (a + (d / (c / b)))
else if (d <= 1.5d+81) 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 = (b / d) + ((c / d) * (a / d));
double tmp;
if (d <= -4.1e+71) {
tmp = t_1;
} else if (d <= -9.2e-129) {
tmp = t_0;
} else if (d <= 3.2e-139) {
tmp = (1.0 / c) * (a + (d / (c / b)));
} else if (d <= 1.5e+81) {
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 = (b / d) + ((c / d) * (a / d)) tmp = 0 if d <= -4.1e+71: tmp = t_1 elif d <= -9.2e-129: tmp = t_0 elif d <= 3.2e-139: tmp = (1.0 / c) * (a + (d / (c / b))) elif d <= 1.5e+81: 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(b / d) + Float64(Float64(c / d) * Float64(a / d))) tmp = 0.0 if (d <= -4.1e+71) tmp = t_1; elseif (d <= -9.2e-129) tmp = t_0; elseif (d <= 3.2e-139) tmp = Float64(Float64(1.0 / c) * Float64(a + Float64(d / Float64(c / b)))); elseif (d <= 1.5e+81) 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 = (b / d) + ((c / d) * (a / d)); tmp = 0.0; if (d <= -4.1e+71) tmp = t_1; elseif (d <= -9.2e-129) tmp = t_0; elseif (d <= 3.2e-139) tmp = (1.0 / c) * (a + (d / (c / b))); elseif (d <= 1.5e+81) 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[(b / d), $MachinePrecision] + N[(N[(c / d), $MachinePrecision] * N[(a / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -4.1e+71], t$95$1, If[LessEqual[d, -9.2e-129], t$95$0, If[LessEqual[d, 3.2e-139], N[(N[(1.0 / c), $MachinePrecision] * N[(a + N[(d / N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.5e+81], 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{b}{d} + \frac{c}{d} \cdot \frac{a}{d}\\
\mathbf{if}\;d \leq -4.1 \cdot 10^{+71}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d \leq -9.2 \cdot 10^{-129}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 3.2 \cdot 10^{-139}:\\
\;\;\;\;\frac{1}{c} \cdot \left(a + \frac{d}{\frac{c}{b}}\right)\\
\mathbf{elif}\;d \leq 1.5 \cdot 10^{+81}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if d < -4.1000000000000002e71 or 1.49999999999999999e81 < d Initial program 42.4%
Taylor expanded in c around 0 76.2%
unpow276.2%
times-frac83.5%
Simplified83.5%
if -4.1000000000000002e71 < d < -9.1999999999999998e-129 or 3.1999999999999999e-139 < d < 1.49999999999999999e81Initial program 83.6%
if -9.1999999999999998e-129 < d < 3.1999999999999999e-139Initial program 74.2%
*-un-lft-identity74.2%
add-sqr-sqrt74.2%
times-frac74.3%
hypot-def74.3%
fma-def74.3%
hypot-def84.8%
Applied egg-rr84.8%
Taylor expanded in c around inf 42.2%
associate-/l*42.3%
Simplified42.3%
Taylor expanded in c around inf 90.0%
Final simplification85.2%
(FPCore (a b c d)
:precision binary64
(if (<= c -5.6e-13)
(* (/ 1.0 c) (+ a (/ d (/ c b))))
(if (<= c 1.65e-31)
(+ (/ b d) (* (/ c d) (/ a d)))
(+ (/ a c) (/ 1.0 (* (/ c b) (/ c d)))))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -5.6e-13) {
tmp = (1.0 / c) * (a + (d / (c / b)));
} else if (c <= 1.65e-31) {
tmp = (b / d) + ((c / d) * (a / d));
} else {
tmp = (a / c) + (1.0 / ((c / 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 (c <= (-5.6d-13)) then
tmp = (1.0d0 / c) * (a + (d / (c / b)))
else if (c <= 1.65d-31) then
tmp = (b / d) + ((c / d) * (a / d))
else
tmp = (a / c) + (1.0d0 / ((c / b) * (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.6e-13) {
tmp = (1.0 / c) * (a + (d / (c / b)));
} else if (c <= 1.65e-31) {
tmp = (b / d) + ((c / d) * (a / d));
} else {
tmp = (a / c) + (1.0 / ((c / b) * (c / d)));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -5.6e-13: tmp = (1.0 / c) * (a + (d / (c / b))) elif c <= 1.65e-31: tmp = (b / d) + ((c / d) * (a / d)) else: tmp = (a / c) + (1.0 / ((c / b) * (c / d))) return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -5.6e-13) tmp = Float64(Float64(1.0 / c) * Float64(a + Float64(d / Float64(c / b)))); elseif (c <= 1.65e-31) tmp = Float64(Float64(b / d) + Float64(Float64(c / d) * Float64(a / d))); else tmp = Float64(Float64(a / c) + Float64(1.0 / Float64(Float64(c / b) * Float64(c / d)))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -5.6e-13) tmp = (1.0 / c) * (a + (d / (c / b))); elseif (c <= 1.65e-31) tmp = (b / d) + ((c / d) * (a / d)); else tmp = (a / c) + (1.0 / ((c / b) * (c / d))); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -5.6e-13], N[(N[(1.0 / c), $MachinePrecision] * N[(a + N[(d / N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.65e-31], N[(N[(b / d), $MachinePrecision] + N[(N[(c / d), $MachinePrecision] * N[(a / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a / c), $MachinePrecision] + N[(1.0 / N[(N[(c / b), $MachinePrecision] * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -5.6 \cdot 10^{-13}:\\
\;\;\;\;\frac{1}{c} \cdot \left(a + \frac{d}{\frac{c}{b}}\right)\\
\mathbf{elif}\;c \leq 1.65 \cdot 10^{-31}:\\
\;\;\;\;\frac{b}{d} + \frac{c}{d} \cdot \frac{a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{1}{\frac{c}{b} \cdot \frac{c}{d}}\\
\end{array}
\end{array}
if c < -5.6000000000000004e-13Initial program 52.1%
*-un-lft-identity52.1%
add-sqr-sqrt52.1%
times-frac52.1%
hypot-def52.1%
fma-def52.1%
hypot-def62.0%
Applied egg-rr62.0%
Taylor expanded in c around inf 15.4%
associate-/l*15.6%
Simplified15.6%
Taylor expanded in c around inf 80.4%
if -5.6000000000000004e-13 < c < 1.65e-31Initial program 72.9%
Taylor expanded in c around 0 82.8%
unpow282.8%
times-frac86.4%
Simplified86.4%
if 1.65e-31 < c Initial program 58.9%
Taylor expanded in c around inf 68.9%
unpow268.9%
associate-/l*68.1%
Simplified68.1%
clear-num68.1%
inv-pow68.1%
associate-/l*75.9%
Applied egg-rr75.9%
unpow-175.9%
associate-/l/77.2%
*-rgt-identity77.2%
times-frac77.2%
associate-/r/77.1%
associate-*l/77.3%
*-lft-identity77.3%
Simplified77.3%
Final simplification82.5%
(FPCore (a b c d) :precision binary64 (if (or (<= c -5.5e-13) (not (<= c 4.4e-32))) (* (/ 1.0 c) (+ a (/ d (/ c b)))) (/ b d)))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -5.5e-13) || !(c <= 4.4e-32)) {
tmp = (1.0 / c) * (a + (d / (c / b)));
} else {
tmp = b / d;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if ((c <= (-5.5d-13)) .or. (.not. (c <= 4.4d-32))) then
tmp = (1.0d0 / c) * (a + (d / (c / b)))
else
tmp = b / d
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -5.5e-13) || !(c <= 4.4e-32)) {
tmp = (1.0 / c) * (a + (d / (c / b)));
} else {
tmp = b / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -5.5e-13) or not (c <= 4.4e-32): tmp = (1.0 / c) * (a + (d / (c / b))) else: tmp = b / d return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -5.5e-13) || !(c <= 4.4e-32)) tmp = Float64(Float64(1.0 / c) * Float64(a + Float64(d / Float64(c / b)))); else tmp = Float64(b / d); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((c <= -5.5e-13) || ~((c <= 4.4e-32))) tmp = (1.0 / c) * (a + (d / (c / b))); else tmp = b / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -5.5e-13], N[Not[LessEqual[c, 4.4e-32]], $MachinePrecision]], N[(N[(1.0 / c), $MachinePrecision] * N[(a + N[(d / N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(b / d), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -5.5 \cdot 10^{-13} \lor \neg \left(c \leq 4.4 \cdot 10^{-32}\right):\\
\;\;\;\;\frac{1}{c} \cdot \left(a + \frac{d}{\frac{c}{b}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d}\\
\end{array}
\end{array}
if c < -5.49999999999999979e-13 or 4.4e-32 < c Initial program 55.6%
*-un-lft-identity55.6%
add-sqr-sqrt55.6%
times-frac55.7%
hypot-def55.7%
fma-def55.7%
hypot-def68.5%
Applied egg-rr68.5%
Taylor expanded in c around inf 44.1%
associate-/l*47.6%
Simplified47.6%
Taylor expanded in c around inf 78.7%
if -5.49999999999999979e-13 < c < 4.4e-32Initial program 72.9%
Taylor expanded in c around 0 74.4%
Final simplification76.6%
(FPCore (a b c d) :precision binary64 (if (<= c -4.1e-13) (* (/ 1.0 c) (+ a (/ d (/ c b)))) (if (<= c 2.65e-33) (/ b d) (+ (/ a c) (* (/ d c) (/ b c))))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -4.1e-13) {
tmp = (1.0 / c) * (a + (d / (c / b)));
} else if (c <= 2.65e-33) {
tmp = b / d;
} 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) :: tmp
if (c <= (-4.1d-13)) then
tmp = (1.0d0 / c) * (a + (d / (c / b)))
else if (c <= 2.65d-33) then
tmp = b / d
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 tmp;
if (c <= -4.1e-13) {
tmp = (1.0 / c) * (a + (d / (c / b)));
} else if (c <= 2.65e-33) {
tmp = b / d;
} else {
tmp = (a / c) + ((d / c) * (b / c));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -4.1e-13: tmp = (1.0 / c) * (a + (d / (c / b))) elif c <= 2.65e-33: tmp = b / d else: tmp = (a / c) + ((d / c) * (b / c)) return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -4.1e-13) tmp = Float64(Float64(1.0 / c) * Float64(a + Float64(d / Float64(c / b)))); elseif (c <= 2.65e-33) tmp = Float64(b / d); 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) tmp = 0.0; if (c <= -4.1e-13) tmp = (1.0 / c) * (a + (d / (c / b))); elseif (c <= 2.65e-33) tmp = b / d; else tmp = (a / c) + ((d / c) * (b / c)); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -4.1e-13], N[(N[(1.0 / c), $MachinePrecision] * N[(a + N[(d / N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 2.65e-33], N[(b / d), $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}\;c \leq -4.1 \cdot 10^{-13}:\\
\;\;\;\;\frac{1}{c} \cdot \left(a + \frac{d}{\frac{c}{b}}\right)\\
\mathbf{elif}\;c \leq 2.65 \cdot 10^{-33}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\
\end{array}
\end{array}
if c < -4.1000000000000002e-13Initial program 52.1%
*-un-lft-identity52.1%
add-sqr-sqrt52.1%
times-frac52.1%
hypot-def52.1%
fma-def52.1%
hypot-def62.0%
Applied egg-rr62.0%
Taylor expanded in c around inf 15.4%
associate-/l*15.6%
Simplified15.6%
Taylor expanded in c around inf 80.4%
if -4.1000000000000002e-13 < c < 2.64999999999999984e-33Initial program 72.9%
Taylor expanded in c around 0 74.4%
if 2.64999999999999984e-33 < c Initial program 58.9%
Taylor expanded in c around inf 68.9%
unpow268.9%
times-frac77.2%
Simplified77.2%
Final simplification76.7%
(FPCore (a b c d)
:precision binary64
(if (<= c -2.7e-13)
(* (/ 1.0 c) (+ a (/ d (/ c b))))
(if (<= c 1.65e-31)
(+ (/ b d) (* (/ c d) (/ a d)))
(+ (/ a c) (* (/ d c) (/ b c))))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -2.7e-13) {
tmp = (1.0 / c) * (a + (d / (c / b)));
} else if (c <= 1.65e-31) {
tmp = (b / d) + ((c / d) * (a / d));
} 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) :: tmp
if (c <= (-2.7d-13)) then
tmp = (1.0d0 / c) * (a + (d / (c / b)))
else if (c <= 1.65d-31) then
tmp = (b / d) + ((c / d) * (a / d))
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 tmp;
if (c <= -2.7e-13) {
tmp = (1.0 / c) * (a + (d / (c / b)));
} else if (c <= 1.65e-31) {
tmp = (b / d) + ((c / d) * (a / d));
} else {
tmp = (a / c) + ((d / c) * (b / c));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -2.7e-13: tmp = (1.0 / c) * (a + (d / (c / b))) elif c <= 1.65e-31: tmp = (b / d) + ((c / d) * (a / d)) else: tmp = (a / c) + ((d / c) * (b / c)) return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -2.7e-13) tmp = Float64(Float64(1.0 / c) * Float64(a + Float64(d / Float64(c / b)))); elseif (c <= 1.65e-31) tmp = Float64(Float64(b / d) + Float64(Float64(c / d) * Float64(a / d))); 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) tmp = 0.0; if (c <= -2.7e-13) tmp = (1.0 / c) * (a + (d / (c / b))); elseif (c <= 1.65e-31) tmp = (b / d) + ((c / d) * (a / d)); else tmp = (a / c) + ((d / c) * (b / c)); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -2.7e-13], N[(N[(1.0 / c), $MachinePrecision] * N[(a + N[(d / N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.65e-31], N[(N[(b / d), $MachinePrecision] + N[(N[(c / d), $MachinePrecision] * N[(a / d), $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}\;c \leq -2.7 \cdot 10^{-13}:\\
\;\;\;\;\frac{1}{c} \cdot \left(a + \frac{d}{\frac{c}{b}}\right)\\
\mathbf{elif}\;c \leq 1.65 \cdot 10^{-31}:\\
\;\;\;\;\frac{b}{d} + \frac{c}{d} \cdot \frac{a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\
\end{array}
\end{array}
if c < -2.70000000000000011e-13Initial program 52.1%
*-un-lft-identity52.1%
add-sqr-sqrt52.1%
times-frac52.1%
hypot-def52.1%
fma-def52.1%
hypot-def62.0%
Applied egg-rr62.0%
Taylor expanded in c around inf 15.4%
associate-/l*15.6%
Simplified15.6%
Taylor expanded in c around inf 80.4%
if -2.70000000000000011e-13 < c < 1.65e-31Initial program 72.9%
Taylor expanded in c around 0 82.8%
unpow282.8%
times-frac86.4%
Simplified86.4%
if 1.65e-31 < c Initial program 58.9%
Taylor expanded in c around inf 68.9%
unpow268.9%
times-frac77.2%
Simplified77.2%
Final simplification82.4%
(FPCore (a b c d)
:precision binary64
(if (<= c -5.6e-13)
(/ a c)
(if (<= c 1.45e-30)
(/ b d)
(if (<= c 1.9e-5)
(* b (/ (/ d c) c))
(if (<= c 1.5e+15) (/ b d) (/ a c))))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -5.6e-13) {
tmp = a / c;
} else if (c <= 1.45e-30) {
tmp = b / d;
} else if (c <= 1.9e-5) {
tmp = b * ((d / c) / c);
} else if (c <= 1.5e+15) {
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 <= (-5.6d-13)) then
tmp = a / c
else if (c <= 1.45d-30) then
tmp = b / d
else if (c <= 1.9d-5) then
tmp = b * ((d / c) / c)
else if (c <= 1.5d+15) 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 <= -5.6e-13) {
tmp = a / c;
} else if (c <= 1.45e-30) {
tmp = b / d;
} else if (c <= 1.9e-5) {
tmp = b * ((d / c) / c);
} else if (c <= 1.5e+15) {
tmp = b / d;
} else {
tmp = a / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -5.6e-13: tmp = a / c elif c <= 1.45e-30: tmp = b / d elif c <= 1.9e-5: tmp = b * ((d / c) / c) elif c <= 1.5e+15: tmp = b / d else: tmp = a / c return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -5.6e-13) tmp = Float64(a / c); elseif (c <= 1.45e-30) tmp = Float64(b / d); elseif (c <= 1.9e-5) tmp = Float64(b * Float64(Float64(d / c) / c)); elseif (c <= 1.5e+15) 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 <= -5.6e-13) tmp = a / c; elseif (c <= 1.45e-30) tmp = b / d; elseif (c <= 1.9e-5) tmp = b * ((d / c) / c); elseif (c <= 1.5e+15) tmp = b / d; else tmp = a / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -5.6e-13], N[(a / c), $MachinePrecision], If[LessEqual[c, 1.45e-30], N[(b / d), $MachinePrecision], If[LessEqual[c, 1.9e-5], N[(b * N[(N[(d / c), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.5e+15], N[(b / d), $MachinePrecision], N[(a / c), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -5.6 \cdot 10^{-13}:\\
\;\;\;\;\frac{a}{c}\\
\mathbf{elif}\;c \leq 1.45 \cdot 10^{-30}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{elif}\;c \leq 1.9 \cdot 10^{-5}:\\
\;\;\;\;b \cdot \frac{\frac{d}{c}}{c}\\
\mathbf{elif}\;c \leq 1.5 \cdot 10^{+15}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c}\\
\end{array}
\end{array}
if c < -5.6000000000000004e-13 or 1.5e15 < c Initial program 53.3%
Taylor expanded in c around inf 66.2%
if -5.6000000000000004e-13 < c < 1.44999999999999995e-30 or 1.9000000000000001e-5 < c < 1.5e15Initial program 72.5%
Taylor expanded in c around 0 74.0%
if 1.44999999999999995e-30 < c < 1.9000000000000001e-5Initial program 99.5%
Taylor expanded in a around 0 83.5%
add-sqr-sqrt49.9%
sqrt-div49.7%
hypot-udef49.7%
sqrt-div49.5%
hypot-udef49.5%
times-frac49.9%
add-sqr-sqrt83.5%
times-frac83.0%
Applied egg-rr83.0%
Taylor expanded in d around 0 83.5%
*-commutative83.5%
associate-*r/83.2%
unpow283.2%
associate-/r*82.7%
Simplified82.7%
Final simplification70.5%
(FPCore (a b c d)
:precision binary64
(if (<= c -3.2e-13)
(/ a c)
(if (<= c 1.45e-30)
(/ b d)
(if (<= c 3.4e-6)
(* (/ d c) (/ b c))
(if (<= c 3.7e+15) (/ b d) (/ a c))))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -3.2e-13) {
tmp = a / c;
} else if (c <= 1.45e-30) {
tmp = b / d;
} else if (c <= 3.4e-6) {
tmp = (d / c) * (b / c);
} else if (c <= 3.7e+15) {
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 <= (-3.2d-13)) then
tmp = a / c
else if (c <= 1.45d-30) then
tmp = b / d
else if (c <= 3.4d-6) then
tmp = (d / c) * (b / c)
else if (c <= 3.7d+15) 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 <= -3.2e-13) {
tmp = a / c;
} else if (c <= 1.45e-30) {
tmp = b / d;
} else if (c <= 3.4e-6) {
tmp = (d / c) * (b / c);
} else if (c <= 3.7e+15) {
tmp = b / d;
} else {
tmp = a / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -3.2e-13: tmp = a / c elif c <= 1.45e-30: tmp = b / d elif c <= 3.4e-6: tmp = (d / c) * (b / c) elif c <= 3.7e+15: tmp = b / d else: tmp = a / c return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -3.2e-13) tmp = Float64(a / c); elseif (c <= 1.45e-30) tmp = Float64(b / d); elseif (c <= 3.4e-6) tmp = Float64(Float64(d / c) * Float64(b / c)); elseif (c <= 3.7e+15) 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 <= -3.2e-13) tmp = a / c; elseif (c <= 1.45e-30) tmp = b / d; elseif (c <= 3.4e-6) tmp = (d / c) * (b / c); elseif (c <= 3.7e+15) tmp = b / d; else tmp = a / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -3.2e-13], N[(a / c), $MachinePrecision], If[LessEqual[c, 1.45e-30], N[(b / d), $MachinePrecision], If[LessEqual[c, 3.4e-6], N[(N[(d / c), $MachinePrecision] * N[(b / c), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 3.7e+15], N[(b / d), $MachinePrecision], N[(a / c), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -3.2 \cdot 10^{-13}:\\
\;\;\;\;\frac{a}{c}\\
\mathbf{elif}\;c \leq 1.45 \cdot 10^{-30}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{elif}\;c \leq 3.4 \cdot 10^{-6}:\\
\;\;\;\;\frac{d}{c} \cdot \frac{b}{c}\\
\mathbf{elif}\;c \leq 3.7 \cdot 10^{+15}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c}\\
\end{array}
\end{array}
if c < -3.2e-13 or 3.7e15 < c Initial program 53.3%
Taylor expanded in c around inf 66.2%
if -3.2e-13 < c < 1.44999999999999995e-30 or 3.40000000000000006e-6 < c < 3.7e15Initial program 72.5%
Taylor expanded in c around 0 74.0%
if 1.44999999999999995e-30 < c < 3.40000000000000006e-6Initial program 99.5%
Taylor expanded in a around 0 83.5%
Taylor expanded in c around inf 83.5%
unpow283.5%
Simplified83.5%
times-frac83.0%
Applied egg-rr83.0%
Final simplification70.5%
(FPCore (a b c d)
:precision binary64
(if (<= c -6e-13)
(/ a c)
(if (<= c 1.45e-30)
(/ b d)
(if (<= c 3.4e-6)
(/ (* b d) (* c c))
(if (<= c 4.4e+15) (/ b d) (/ a c))))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -6e-13) {
tmp = a / c;
} else if (c <= 1.45e-30) {
tmp = b / d;
} else if (c <= 3.4e-6) {
tmp = (b * d) / (c * c);
} else if (c <= 4.4e+15) {
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 <= (-6d-13)) then
tmp = a / c
else if (c <= 1.45d-30) then
tmp = b / d
else if (c <= 3.4d-6) then
tmp = (b * d) / (c * c)
else if (c <= 4.4d+15) 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 <= -6e-13) {
tmp = a / c;
} else if (c <= 1.45e-30) {
tmp = b / d;
} else if (c <= 3.4e-6) {
tmp = (b * d) / (c * c);
} else if (c <= 4.4e+15) {
tmp = b / d;
} else {
tmp = a / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -6e-13: tmp = a / c elif c <= 1.45e-30: tmp = b / d elif c <= 3.4e-6: tmp = (b * d) / (c * c) elif c <= 4.4e+15: tmp = b / d else: tmp = a / c return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -6e-13) tmp = Float64(a / c); elseif (c <= 1.45e-30) tmp = Float64(b / d); elseif (c <= 3.4e-6) tmp = Float64(Float64(b * d) / Float64(c * c)); elseif (c <= 4.4e+15) 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 <= -6e-13) tmp = a / c; elseif (c <= 1.45e-30) tmp = b / d; elseif (c <= 3.4e-6) tmp = (b * d) / (c * c); elseif (c <= 4.4e+15) tmp = b / d; else tmp = a / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -6e-13], N[(a / c), $MachinePrecision], If[LessEqual[c, 1.45e-30], N[(b / d), $MachinePrecision], If[LessEqual[c, 3.4e-6], N[(N[(b * d), $MachinePrecision] / N[(c * c), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 4.4e+15], N[(b / d), $MachinePrecision], N[(a / c), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -6 \cdot 10^{-13}:\\
\;\;\;\;\frac{a}{c}\\
\mathbf{elif}\;c \leq 1.45 \cdot 10^{-30}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{elif}\;c \leq 3.4 \cdot 10^{-6}:\\
\;\;\;\;\frac{b \cdot d}{c \cdot c}\\
\mathbf{elif}\;c \leq 4.4 \cdot 10^{+15}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c}\\
\end{array}
\end{array}
if c < -5.99999999999999968e-13 or 4.4e15 < c Initial program 53.3%
Taylor expanded in c around inf 66.2%
if -5.99999999999999968e-13 < c < 1.44999999999999995e-30 or 3.40000000000000006e-6 < c < 4.4e15Initial program 72.5%
Taylor expanded in c around 0 74.0%
if 1.44999999999999995e-30 < c < 3.40000000000000006e-6Initial program 99.5%
Taylor expanded in a around 0 83.5%
Taylor expanded in c around inf 83.5%
unpow283.5%
Simplified83.5%
Final simplification70.5%
(FPCore (a b c d) :precision binary64 (if (<= c -2.9e-13) (/ a c) (if (<= c 2e+15) (/ b d) (/ a c))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -2.9e-13) {
tmp = a / c;
} else if (c <= 2e+15) {
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 <= (-2.9d-13)) then
tmp = a / c
else if (c <= 2d+15) 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 <= -2.9e-13) {
tmp = a / c;
} else if (c <= 2e+15) {
tmp = b / d;
} else {
tmp = a / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -2.9e-13: tmp = a / c elif c <= 2e+15: tmp = b / d else: tmp = a / c return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -2.9e-13) tmp = Float64(a / c); elseif (c <= 2e+15) 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 <= -2.9e-13) tmp = a / c; elseif (c <= 2e+15) tmp = b / d; else tmp = a / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -2.9e-13], N[(a / c), $MachinePrecision], If[LessEqual[c, 2e+15], N[(b / d), $MachinePrecision], N[(a / c), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -2.9 \cdot 10^{-13}:\\
\;\;\;\;\frac{a}{c}\\
\mathbf{elif}\;c \leq 2 \cdot 10^{+15}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c}\\
\end{array}
\end{array}
if c < -2.8999999999999998e-13 or 2e15 < c Initial program 53.3%
Taylor expanded in c around inf 66.2%
if -2.8999999999999998e-13 < c < 2e15Initial program 73.7%
Taylor expanded in c around 0 70.9%
Final simplification68.7%
(FPCore (a b c d) :precision binary64 (/ a c))
double code(double a, double b, double c, double d) {
return a / c;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = a / c
end function
public static double code(double a, double b, double c, double d) {
return a / c;
}
def code(a, b, c, d): return a / c
function code(a, b, c, d) return Float64(a / c) end
function tmp = code(a, b, c, d) tmp = a / c; end
code[a_, b_, c_, d_] := N[(a / c), $MachinePrecision]
\begin{array}{l}
\\
\frac{a}{c}
\end{array}
Initial program 63.9%
Taylor expanded in c around inf 40.5%
Final simplification40.5%
(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 2023182
(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))))