
(FPCore (a b c d) :precision binary64 (/ (- (* b c) (* a d)) (+ (* c c) (* d d))))
double code(double a, double b, double c, double d) {
return ((b * c) - (a * 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 = ((b * c) - (a * d)) / ((c * c) + (d * d))
end function
public static double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
def code(a, b, c, d): return ((b * c) - (a * d)) / ((c * c) + (d * d))
function code(a, b, c, d) return Float64(Float64(Float64(b * c) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d))) end
function tmp = code(a, b, c, d) tmp = ((b * c) - (a * d)) / ((c * c) + (d * d)); end
code[a_, b_, c_, d_] := N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{b \cdot c - a \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 (/ (- (* b c) (* a d)) (+ (* c c) (* d d))))
double code(double a, double b, double c, double d) {
return ((b * c) - (a * 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 = ((b * c) - (a * d)) / ((c * c) + (d * d))
end function
public static double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
def code(a, b, c, d): return ((b * c) - (a * d)) / ((c * c) + (d * d))
function code(a, b, c, d) return Float64(Float64(Float64(b * c) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d))) end
function tmp = code(a, b, c, d) tmp = ((b * c) - (a * d)) / ((c * c) + (d * d)); end
code[a_, b_, c_, d_] := N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}
\end{array}
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ c (hypot c d)))
(t_1 (/ b (hypot c d)))
(t_2 (fma t_0 t_1 (/ (- a) (/ (pow (hypot c d) 2.0) d))))
(t_3 (fma t_0 t_1 (- (/ a d)))))
(if (<= d -2e+137)
t_3
(if (<= d -7.6e-131)
t_2
(if (<= d 1.85e-154)
(/ (- b (/ (* d a) c)) c)
(if (<= d 2.85e+167) t_2 t_3))))))
double code(double a, double b, double c, double d) {
double t_0 = c / hypot(c, d);
double t_1 = b / hypot(c, d);
double t_2 = fma(t_0, t_1, (-a / (pow(hypot(c, d), 2.0) / d)));
double t_3 = fma(t_0, t_1, -(a / d));
double tmp;
if (d <= -2e+137) {
tmp = t_3;
} else if (d <= -7.6e-131) {
tmp = t_2;
} else if (d <= 1.85e-154) {
tmp = (b - ((d * a) / c)) / c;
} else if (d <= 2.85e+167) {
tmp = t_2;
} else {
tmp = t_3;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(c / hypot(c, d)) t_1 = Float64(b / hypot(c, d)) t_2 = fma(t_0, t_1, Float64(Float64(-a) / Float64((hypot(c, d) ^ 2.0) / d))) t_3 = fma(t_0, t_1, Float64(-Float64(a / d))) tmp = 0.0 if (d <= -2e+137) tmp = t_3; elseif (d <= -7.6e-131) tmp = t_2; elseif (d <= 1.85e-154) tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c); elseif (d <= 2.85e+167) tmp = t_2; else tmp = t_3; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$0 * t$95$1 + N[((-a) / N[(N[Power[N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision], 2.0], $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$0 * t$95$1 + (-N[(a / d), $MachinePrecision])), $MachinePrecision]}, If[LessEqual[d, -2e+137], t$95$3, If[LessEqual[d, -7.6e-131], t$95$2, If[LessEqual[d, 1.85e-154], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 2.85e+167], t$95$2, t$95$3]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c}{\mathsf{hypot}\left(c, d\right)}\\
t_1 := \frac{b}{\mathsf{hypot}\left(c, d\right)}\\
t_2 := \mathsf{fma}\left(t_0, t_1, \frac{-a}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{d}}\right)\\
t_3 := \mathsf{fma}\left(t_0, t_1, -\frac{a}{d}\right)\\
\mathbf{if}\;d \leq -2 \cdot 10^{+137}:\\
\;\;\;\;t_3\\
\mathbf{elif}\;d \leq -7.6 \cdot 10^{-131}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;d \leq 1.85 \cdot 10^{-154}:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\
\mathbf{elif}\;d \leq 2.85 \cdot 10^{+167}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;t_3\\
\end{array}
\end{array}
if d < -2.0000000000000001e137 or 2.85000000000000008e167 < d Initial program 34.7%
div-sub34.7%
*-commutative34.7%
add-sqr-sqrt34.7%
times-frac37.9%
fma-neg37.9%
hypot-def37.9%
hypot-def53.2%
associate-/l*56.1%
add-sqr-sqrt56.1%
pow256.1%
hypot-def56.1%
Applied egg-rr56.1%
Taylor expanded in c around 0 91.6%
if -2.0000000000000001e137 < d < -7.59999999999999989e-131 or 1.84999999999999993e-154 < d < 2.85000000000000008e167Initial program 67.7%
div-sub67.7%
*-commutative67.7%
add-sqr-sqrt67.7%
times-frac72.5%
fma-neg72.5%
hypot-def72.5%
hypot-def88.3%
associate-/l*96.3%
add-sqr-sqrt96.3%
pow296.3%
hypot-def96.3%
Applied egg-rr96.3%
if -7.59999999999999989e-131 < d < 1.84999999999999993e-154Initial program 66.2%
Taylor expanded in c around inf 76.6%
+-commutative76.6%
mul-1-neg76.6%
unsub-neg76.6%
unpow276.6%
times-frac84.5%
Simplified84.5%
associate-*l/84.5%
sub-div88.0%
Applied egg-rr88.0%
*-commutative88.0%
associate-*l/90.6%
Applied egg-rr90.6%
Final simplification93.8%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (- (* c b) (* d a))))
(if (<= (/ t_0 (+ (* c c) (* d d))) 1e+302)
(* (/ 1.0 (hypot c d)) (/ t_0 (hypot c d)))
(fma (/ c (hypot c d)) (/ b (hypot c d)) (- (/ a d))))))
double code(double a, double b, double c, double d) {
double t_0 = (c * b) - (d * a);
double tmp;
if ((t_0 / ((c * c) + (d * d))) <= 1e+302) {
tmp = (1.0 / hypot(c, d)) * (t_0 / hypot(c, d));
} else {
tmp = fma((c / hypot(c, d)), (b / hypot(c, d)), -(a / d));
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(c * b) - Float64(d * a)) tmp = 0.0 if (Float64(t_0 / Float64(Float64(c * c) + Float64(d * d))) <= 1e+302) tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(t_0 / hypot(c, d))); else tmp = fma(Float64(c / hypot(c, d)), Float64(b / hypot(c, d)), Float64(-Float64(a / d))); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$0 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1e+302], N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] + (-N[(a / d), $MachinePrecision])), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := c \cdot b - d \cdot a\\
\mathbf{if}\;\frac{t_0}{c \cdot c + d \cdot d} \leq 10^{+302}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{t_0}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, -\frac{a}{d}\right)\\
\end{array}
\end{array}
if (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 1.0000000000000001e302Initial program 79.3%
*-un-lft-identity79.3%
add-sqr-sqrt79.3%
times-frac79.3%
hypot-def79.3%
hypot-def95.2%
Applied egg-rr95.2%
if 1.0000000000000001e302 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 6.8%
div-sub5.2%
*-commutative5.2%
add-sqr-sqrt5.2%
times-frac14.4%
fma-neg14.4%
hypot-def14.4%
hypot-def46.1%
associate-/l*60.5%
add-sqr-sqrt60.5%
pow260.5%
hypot-def60.5%
Applied egg-rr60.5%
Taylor expanded in c around 0 67.2%
Final simplification87.2%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (- (* c b) (* d a))) (t_1 (/ t_0 (+ (* c c) (* d d)))))
(if (<= t_1 1e+302)
(* (/ 1.0 (hypot c d)) (/ t_0 (hypot c d)))
(if (<= t_1 INFINITY)
(- (* (/ c d) (/ b d)) (/ a d))
(/ (- b (* a (/ d c))) c)))))
double code(double a, double b, double c, double d) {
double t_0 = (c * b) - (d * a);
double t_1 = t_0 / ((c * c) + (d * d));
double tmp;
if (t_1 <= 1e+302) {
tmp = (1.0 / hypot(c, d)) * (t_0 / hypot(c, d));
} else if (t_1 <= ((double) INFINITY)) {
tmp = ((c / d) * (b / d)) - (a / d);
} else {
tmp = (b - (a * (d / c))) / c;
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = (c * b) - (d * a);
double t_1 = t_0 / ((c * c) + (d * d));
double tmp;
if (t_1 <= 1e+302) {
tmp = (1.0 / Math.hypot(c, d)) * (t_0 / Math.hypot(c, d));
} else if (t_1 <= Double.POSITIVE_INFINITY) {
tmp = ((c / d) * (b / d)) - (a / d);
} else {
tmp = (b - (a * (d / c))) / c;
}
return tmp;
}
def code(a, b, c, d): t_0 = (c * b) - (d * a) t_1 = t_0 / ((c * c) + (d * d)) tmp = 0 if t_1 <= 1e+302: tmp = (1.0 / math.hypot(c, d)) * (t_0 / math.hypot(c, d)) elif t_1 <= math.inf: tmp = ((c / d) * (b / d)) - (a / d) else: tmp = (b - (a * (d / c))) / c return tmp
function code(a, b, c, d) t_0 = Float64(Float64(c * b) - Float64(d * a)) t_1 = Float64(t_0 / Float64(Float64(c * c) + Float64(d * d))) tmp = 0.0 if (t_1 <= 1e+302) tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(t_0 / hypot(c, d))); elseif (t_1 <= Inf) tmp = Float64(Float64(Float64(c / d) * Float64(b / d)) - Float64(a / d)); else tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (c * b) - (d * a); t_1 = t_0 / ((c * c) + (d * d)); tmp = 0.0; if (t_1 <= 1e+302) tmp = (1.0 / hypot(c, d)) * (t_0 / hypot(c, d)); elseif (t_1 <= Inf) tmp = ((c / d) * (b / d)) - (a / d); else tmp = (b - (a * (d / c))) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 1e+302], N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[(N[(N[(c / d), $MachinePrecision] * N[(b / d), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := c \cdot b - d \cdot a\\
t_1 := \frac{t_0}{c \cdot c + d \cdot d}\\
\mathbf{if}\;t_1 \leq 10^{+302}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{t_0}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;t_1 \leq \infty:\\
\;\;\;\;\frac{c}{d} \cdot \frac{b}{d} - \frac{a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\
\end{array}
\end{array}
if (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 1.0000000000000001e302Initial program 79.3%
*-un-lft-identity79.3%
add-sqr-sqrt79.3%
times-frac79.3%
hypot-def79.3%
hypot-def95.2%
Applied egg-rr95.2%
if 1.0000000000000001e302 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < +inf.0Initial program 22.5%
Taylor expanded in c around 0 60.8%
+-commutative60.8%
mul-1-neg60.8%
unsub-neg60.8%
*-commutative60.8%
unpow260.8%
times-frac70.2%
Simplified70.2%
if +inf.0 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 0.0%
Taylor expanded in c around inf 45.0%
+-commutative45.0%
mul-1-neg45.0%
unsub-neg45.0%
unpow245.0%
times-frac59.4%
Simplified59.4%
associate-*l/59.4%
sub-div59.5%
Applied egg-rr59.5%
Final simplification85.9%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- b (* d (/ a c))) c)))
(if (<= c -4.4e+52)
t_0
(if (<= c 5.8e-92)
(- (* (/ c d) (/ b d)) (/ a d))
(if (<= c 3.3e+100) (/ (- (* c b) (* d a)) (fma c c (* d d))) t_0)))))
double code(double a, double b, double c, double d) {
double t_0 = (b - (d * (a / c))) / c;
double tmp;
if (c <= -4.4e+52) {
tmp = t_0;
} else if (c <= 5.8e-92) {
tmp = ((c / d) * (b / d)) - (a / d);
} else if (c <= 3.3e+100) {
tmp = ((c * b) - (d * a)) / fma(c, c, (d * d));
} else {
tmp = t_0;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(b - Float64(d * Float64(a / c))) / c) tmp = 0.0 if (c <= -4.4e+52) tmp = t_0; elseif (c <= 5.8e-92) tmp = Float64(Float64(Float64(c / d) * Float64(b / d)) - Float64(a / d)); elseif (c <= 3.3e+100) tmp = Float64(Float64(Float64(c * b) - Float64(d * a)) / fma(c, c, Float64(d * d))); else tmp = t_0; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(b - N[(d * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]}, If[LessEqual[c, -4.4e+52], t$95$0, If[LessEqual[c, 5.8e-92], N[(N[(N[(c / d), $MachinePrecision] * N[(b / d), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 3.3e+100], N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b - d \cdot \frac{a}{c}}{c}\\
\mathbf{if}\;c \leq -4.4 \cdot 10^{+52}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 5.8 \cdot 10^{-92}:\\
\;\;\;\;\frac{c}{d} \cdot \frac{b}{d} - \frac{a}{d}\\
\mathbf{elif}\;c \leq 3.3 \cdot 10^{+100}:\\
\;\;\;\;\frac{c \cdot b - d \cdot a}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if c < -4.4e52 or 3.3000000000000001e100 < c Initial program 39.7%
Taylor expanded in c around inf 76.0%
+-commutative76.0%
mul-1-neg76.0%
unsub-neg76.0%
unpow276.0%
times-frac85.5%
Simplified85.5%
associate-*r/86.7%
sub-div86.7%
Applied egg-rr86.7%
if -4.4e52 < c < 5.79999999999999969e-92Initial program 69.8%
Taylor expanded in c around 0 77.3%
+-commutative77.3%
mul-1-neg77.3%
unsub-neg77.3%
*-commutative77.3%
unpow277.3%
times-frac82.0%
Simplified82.0%
if 5.79999999999999969e-92 < c < 3.3000000000000001e100Initial program 80.1%
fma-def80.2%
Simplified80.2%
Final simplification83.7%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (- (/ a d)))
(t_1 (/ (- b (* a (/ d c))) c))
(t_2 (* (/ c d) (/ b d))))
(if (<= c -2.05e+19)
t_1
(if (<= c -1.04e-54)
t_0
(if (<= c -2.2e-105)
t_1
(if (<= c -1.1e-113)
t_2
(if (<= c 2400.0)
t_0
(if (or (<= c 5.2e+26) (not (<= c 9.5e+99))) t_1 t_2))))))))
double code(double a, double b, double c, double d) {
double t_0 = -(a / d);
double t_1 = (b - (a * (d / c))) / c;
double t_2 = (c / d) * (b / d);
double tmp;
if (c <= -2.05e+19) {
tmp = t_1;
} else if (c <= -1.04e-54) {
tmp = t_0;
} else if (c <= -2.2e-105) {
tmp = t_1;
} else if (c <= -1.1e-113) {
tmp = t_2;
} else if (c <= 2400.0) {
tmp = t_0;
} else if ((c <= 5.2e+26) || !(c <= 9.5e+99)) {
tmp = t_1;
} else {
tmp = t_2;
}
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) :: t_2
real(8) :: tmp
t_0 = -(a / d)
t_1 = (b - (a * (d / c))) / c
t_2 = (c / d) * (b / d)
if (c <= (-2.05d+19)) then
tmp = t_1
else if (c <= (-1.04d-54)) then
tmp = t_0
else if (c <= (-2.2d-105)) then
tmp = t_1
else if (c <= (-1.1d-113)) then
tmp = t_2
else if (c <= 2400.0d0) then
tmp = t_0
else if ((c <= 5.2d+26) .or. (.not. (c <= 9.5d+99))) then
tmp = t_1
else
tmp = t_2
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = -(a / d);
double t_1 = (b - (a * (d / c))) / c;
double t_2 = (c / d) * (b / d);
double tmp;
if (c <= -2.05e+19) {
tmp = t_1;
} else if (c <= -1.04e-54) {
tmp = t_0;
} else if (c <= -2.2e-105) {
tmp = t_1;
} else if (c <= -1.1e-113) {
tmp = t_2;
} else if (c <= 2400.0) {
tmp = t_0;
} else if ((c <= 5.2e+26) || !(c <= 9.5e+99)) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
def code(a, b, c, d): t_0 = -(a / d) t_1 = (b - (a * (d / c))) / c t_2 = (c / d) * (b / d) tmp = 0 if c <= -2.05e+19: tmp = t_1 elif c <= -1.04e-54: tmp = t_0 elif c <= -2.2e-105: tmp = t_1 elif c <= -1.1e-113: tmp = t_2 elif c <= 2400.0: tmp = t_0 elif (c <= 5.2e+26) or not (c <= 9.5e+99): tmp = t_1 else: tmp = t_2 return tmp
function code(a, b, c, d) t_0 = Float64(-Float64(a / d)) t_1 = Float64(Float64(b - Float64(a * Float64(d / c))) / c) t_2 = Float64(Float64(c / d) * Float64(b / d)) tmp = 0.0 if (c <= -2.05e+19) tmp = t_1; elseif (c <= -1.04e-54) tmp = t_0; elseif (c <= -2.2e-105) tmp = t_1; elseif (c <= -1.1e-113) tmp = t_2; elseif (c <= 2400.0) tmp = t_0; elseif ((c <= 5.2e+26) || !(c <= 9.5e+99)) tmp = t_1; else tmp = t_2; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = -(a / d); t_1 = (b - (a * (d / c))) / c; t_2 = (c / d) * (b / d); tmp = 0.0; if (c <= -2.05e+19) tmp = t_1; elseif (c <= -1.04e-54) tmp = t_0; elseif (c <= -2.2e-105) tmp = t_1; elseif (c <= -1.1e-113) tmp = t_2; elseif (c <= 2400.0) tmp = t_0; elseif ((c <= 5.2e+26) || ~((c <= 9.5e+99))) tmp = t_1; else tmp = t_2; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = (-N[(a / d), $MachinePrecision])}, Block[{t$95$1 = N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]}, Block[{t$95$2 = N[(N[(c / d), $MachinePrecision] * N[(b / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -2.05e+19], t$95$1, If[LessEqual[c, -1.04e-54], t$95$0, If[LessEqual[c, -2.2e-105], t$95$1, If[LessEqual[c, -1.1e-113], t$95$2, If[LessEqual[c, 2400.0], t$95$0, If[Or[LessEqual[c, 5.2e+26], N[Not[LessEqual[c, 9.5e+99]], $MachinePrecision]], t$95$1, t$95$2]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -\frac{a}{d}\\
t_1 := \frac{b - a \cdot \frac{d}{c}}{c}\\
t_2 := \frac{c}{d} \cdot \frac{b}{d}\\
\mathbf{if}\;c \leq -2.05 \cdot 10^{+19}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;c \leq -1.04 \cdot 10^{-54}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq -2.2 \cdot 10^{-105}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;c \leq -1.1 \cdot 10^{-113}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;c \leq 2400:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 5.2 \cdot 10^{+26} \lor \neg \left(c \leq 9.5 \cdot 10^{+99}\right):\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\end{array}
if c < -2.05e19 or -1.04e-54 < c < -2.20000000000000004e-105 or 2400 < c < 5.20000000000000004e26 or 9.49999999999999908e99 < c Initial program 46.4%
Taylor expanded in c around inf 74.4%
+-commutative74.4%
mul-1-neg74.4%
unsub-neg74.4%
unpow274.4%
times-frac82.4%
Simplified82.4%
associate-*l/81.6%
sub-div81.6%
Applied egg-rr81.6%
if -2.05e19 < c < -1.04e-54 or -1.10000000000000002e-113 < c < 2400Initial program 70.2%
Taylor expanded in c around 0 75.9%
associate-*r/75.9%
neg-mul-175.9%
Simplified75.9%
if -2.20000000000000004e-105 < c < -1.10000000000000002e-113 or 5.20000000000000004e26 < c < 9.49999999999999908e99Initial program 72.6%
div-sub72.6%
*-commutative72.6%
add-sqr-sqrt72.6%
times-frac86.4%
fma-neg86.4%
hypot-def86.4%
hypot-def94.9%
associate-/l*90.6%
add-sqr-sqrt90.6%
pow290.6%
hypot-def90.6%
Applied egg-rr90.6%
Taylor expanded in b around inf 57.3%
*-commutative57.3%
unpow257.3%
+-commutative57.3%
unpow257.3%
Simplified57.3%
Taylor expanded in c around 0 52.9%
*-commutative52.9%
unpow252.9%
times-frac70.7%
Simplified70.7%
Final simplification78.3%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (- (/ a d)))
(t_1 (/ (- b (* d (/ a c))) c))
(t_2 (* (/ c d) (/ b d))))
(if (<= c -5.6e+18)
t_1
(if (<= c -8.7e-57)
t_0
(if (<= c -1.25e-105)
t_1
(if (<= c -1.1e-113)
t_2
(if (<= c 3100.0)
t_0
(if (<= c 3.2e+26)
(/ (- b (* a (/ d c))) c)
(if (<= c 9.5e+99) t_2 t_1)))))))))
double code(double a, double b, double c, double d) {
double t_0 = -(a / d);
double t_1 = (b - (d * (a / c))) / c;
double t_2 = (c / d) * (b / d);
double tmp;
if (c <= -5.6e+18) {
tmp = t_1;
} else if (c <= -8.7e-57) {
tmp = t_0;
} else if (c <= -1.25e-105) {
tmp = t_1;
} else if (c <= -1.1e-113) {
tmp = t_2;
} else if (c <= 3100.0) {
tmp = t_0;
} else if (c <= 3.2e+26) {
tmp = (b - (a * (d / c))) / c;
} else if (c <= 9.5e+99) {
tmp = t_2;
} 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) :: t_2
real(8) :: tmp
t_0 = -(a / d)
t_1 = (b - (d * (a / c))) / c
t_2 = (c / d) * (b / d)
if (c <= (-5.6d+18)) then
tmp = t_1
else if (c <= (-8.7d-57)) then
tmp = t_0
else if (c <= (-1.25d-105)) then
tmp = t_1
else if (c <= (-1.1d-113)) then
tmp = t_2
else if (c <= 3100.0d0) then
tmp = t_0
else if (c <= 3.2d+26) then
tmp = (b - (a * (d / c))) / c
else if (c <= 9.5d+99) then
tmp = t_2
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 / d);
double t_1 = (b - (d * (a / c))) / c;
double t_2 = (c / d) * (b / d);
double tmp;
if (c <= -5.6e+18) {
tmp = t_1;
} else if (c <= -8.7e-57) {
tmp = t_0;
} else if (c <= -1.25e-105) {
tmp = t_1;
} else if (c <= -1.1e-113) {
tmp = t_2;
} else if (c <= 3100.0) {
tmp = t_0;
} else if (c <= 3.2e+26) {
tmp = (b - (a * (d / c))) / c;
} else if (c <= 9.5e+99) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
def code(a, b, c, d): t_0 = -(a / d) t_1 = (b - (d * (a / c))) / c t_2 = (c / d) * (b / d) tmp = 0 if c <= -5.6e+18: tmp = t_1 elif c <= -8.7e-57: tmp = t_0 elif c <= -1.25e-105: tmp = t_1 elif c <= -1.1e-113: tmp = t_2 elif c <= 3100.0: tmp = t_0 elif c <= 3.2e+26: tmp = (b - (a * (d / c))) / c elif c <= 9.5e+99: tmp = t_2 else: tmp = t_1 return tmp
function code(a, b, c, d) t_0 = Float64(-Float64(a / d)) t_1 = Float64(Float64(b - Float64(d * Float64(a / c))) / c) t_2 = Float64(Float64(c / d) * Float64(b / d)) tmp = 0.0 if (c <= -5.6e+18) tmp = t_1; elseif (c <= -8.7e-57) tmp = t_0; elseif (c <= -1.25e-105) tmp = t_1; elseif (c <= -1.1e-113) tmp = t_2; elseif (c <= 3100.0) tmp = t_0; elseif (c <= 3.2e+26) tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c); elseif (c <= 9.5e+99) tmp = t_2; else tmp = t_1; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = -(a / d); t_1 = (b - (d * (a / c))) / c; t_2 = (c / d) * (b / d); tmp = 0.0; if (c <= -5.6e+18) tmp = t_1; elseif (c <= -8.7e-57) tmp = t_0; elseif (c <= -1.25e-105) tmp = t_1; elseif (c <= -1.1e-113) tmp = t_2; elseif (c <= 3100.0) tmp = t_0; elseif (c <= 3.2e+26) tmp = (b - (a * (d / c))) / c; elseif (c <= 9.5e+99) tmp = t_2; else tmp = t_1; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = (-N[(a / d), $MachinePrecision])}, Block[{t$95$1 = N[(N[(b - N[(d * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]}, Block[{t$95$2 = N[(N[(c / d), $MachinePrecision] * N[(b / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -5.6e+18], t$95$1, If[LessEqual[c, -8.7e-57], t$95$0, If[LessEqual[c, -1.25e-105], t$95$1, If[LessEqual[c, -1.1e-113], t$95$2, If[LessEqual[c, 3100.0], t$95$0, If[LessEqual[c, 3.2e+26], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[c, 9.5e+99], t$95$2, t$95$1]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -\frac{a}{d}\\
t_1 := \frac{b - d \cdot \frac{a}{c}}{c}\\
t_2 := \frac{c}{d} \cdot \frac{b}{d}\\
\mathbf{if}\;c \leq -5.6 \cdot 10^{+18}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;c \leq -8.7 \cdot 10^{-57}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq -1.25 \cdot 10^{-105}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;c \leq -1.1 \cdot 10^{-113}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;c \leq 3100:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 3.2 \cdot 10^{+26}:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\
\mathbf{elif}\;c \leq 9.5 \cdot 10^{+99}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if c < -5.6e18 or -8.7000000000000002e-57 < c < -1.24999999999999991e-105 or 9.49999999999999908e99 < c Initial program 44.3%
Taylor expanded in c around inf 73.5%
+-commutative73.5%
mul-1-neg73.5%
unsub-neg73.5%
unpow273.5%
times-frac81.8%
Simplified81.8%
associate-*r/82.9%
sub-div82.9%
Applied egg-rr82.9%
if -5.6e18 < c < -8.7000000000000002e-57 or -1.10000000000000002e-113 < c < 3100Initial program 70.2%
Taylor expanded in c around 0 75.9%
associate-*r/75.9%
neg-mul-175.9%
Simplified75.9%
if -1.24999999999999991e-105 < c < -1.10000000000000002e-113 or 3.20000000000000029e26 < c < 9.49999999999999908e99Initial program 72.6%
div-sub72.6%
*-commutative72.6%
add-sqr-sqrt72.6%
times-frac86.4%
fma-neg86.4%
hypot-def86.4%
hypot-def94.9%
associate-/l*90.6%
add-sqr-sqrt90.6%
pow290.6%
hypot-def90.6%
Applied egg-rr90.6%
Taylor expanded in b around inf 57.3%
*-commutative57.3%
unpow257.3%
+-commutative57.3%
unpow257.3%
Simplified57.3%
Taylor expanded in c around 0 52.9%
*-commutative52.9%
unpow252.9%
times-frac70.7%
Simplified70.7%
if 3100 < c < 3.20000000000000029e26Initial program 99.1%
Taylor expanded in c around inf 95.2%
+-commutative95.2%
mul-1-neg95.2%
unsub-neg95.2%
unpow295.2%
times-frac95.5%
Simplified95.5%
associate-*l/95.5%
sub-div95.5%
Applied egg-rr95.5%
Final simplification79.2%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- b (* d (/ a c))) c)))
(if (<= c -8.6e+52)
t_0
(if (<= c 2.5e-89)
(- (* (/ c d) (/ b d)) (/ a d))
(if (<= c 1.1e+102) (/ (- (* c b) (* d a)) (+ (* c c) (* d d))) t_0)))))
double code(double a, double b, double c, double d) {
double t_0 = (b - (d * (a / c))) / c;
double tmp;
if (c <= -8.6e+52) {
tmp = t_0;
} else if (c <= 2.5e-89) {
tmp = ((c / d) * (b / d)) - (a / d);
} else if (c <= 1.1e+102) {
tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: tmp
t_0 = (b - (d * (a / c))) / c
if (c <= (-8.6d+52)) then
tmp = t_0
else if (c <= 2.5d-89) then
tmp = ((c / d) * (b / d)) - (a / d)
else if (c <= 1.1d+102) then
tmp = ((c * b) - (d * a)) / ((c * c) + (d * d))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = (b - (d * (a / c))) / c;
double tmp;
if (c <= -8.6e+52) {
tmp = t_0;
} else if (c <= 2.5e-89) {
tmp = ((c / d) * (b / d)) - (a / d);
} else if (c <= 1.1e+102) {
tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b, c, d): t_0 = (b - (d * (a / c))) / c tmp = 0 if c <= -8.6e+52: tmp = t_0 elif c <= 2.5e-89: tmp = ((c / d) * (b / d)) - (a / d) elif c <= 1.1e+102: tmp = ((c * b) - (d * a)) / ((c * c) + (d * d)) else: tmp = t_0 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(b - Float64(d * Float64(a / c))) / c) tmp = 0.0 if (c <= -8.6e+52) tmp = t_0; elseif (c <= 2.5e-89) tmp = Float64(Float64(Float64(c / d) * Float64(b / d)) - Float64(a / d)); elseif (c <= 1.1e+102) tmp = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d))); else tmp = t_0; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (b - (d * (a / c))) / c; tmp = 0.0; if (c <= -8.6e+52) tmp = t_0; elseif (c <= 2.5e-89) tmp = ((c / d) * (b / d)) - (a / d); elseif (c <= 1.1e+102) tmp = ((c * b) - (d * a)) / ((c * c) + (d * d)); else tmp = t_0; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(b - N[(d * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]}, If[LessEqual[c, -8.6e+52], t$95$0, If[LessEqual[c, 2.5e-89], N[(N[(N[(c / d), $MachinePrecision] * N[(b / d), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.1e+102], N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b - d \cdot \frac{a}{c}}{c}\\
\mathbf{if}\;c \leq -8.6 \cdot 10^{+52}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 2.5 \cdot 10^{-89}:\\
\;\;\;\;\frac{c}{d} \cdot \frac{b}{d} - \frac{a}{d}\\
\mathbf{elif}\;c \leq 1.1 \cdot 10^{+102}:\\
\;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if c < -8.5999999999999999e52 or 1.10000000000000004e102 < c Initial program 39.7%
Taylor expanded in c around inf 76.0%
+-commutative76.0%
mul-1-neg76.0%
unsub-neg76.0%
unpow276.0%
times-frac85.5%
Simplified85.5%
associate-*r/86.7%
sub-div86.7%
Applied egg-rr86.7%
if -8.5999999999999999e52 < c < 2.49999999999999983e-89Initial program 69.8%
Taylor expanded in c around 0 77.3%
+-commutative77.3%
mul-1-neg77.3%
unsub-neg77.3%
*-commutative77.3%
unpow277.3%
times-frac82.0%
Simplified82.0%
if 2.49999999999999983e-89 < c < 1.10000000000000004e102Initial program 80.1%
Final simplification83.7%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (- (* (/ c d) (/ b d)) (/ a d))) (t_1 (/ (- b (* d (/ a c))) c)))
(if (<= c -5.2e+53)
t_1
(if (<= c 19000000000.0)
t_0
(if (<= c 2.3e+23)
(/ (- b (* a (/ d c))) c)
(if (<= c 1.35e+90) t_0 t_1))))))
double code(double a, double b, double c, double d) {
double t_0 = ((c / d) * (b / d)) - (a / d);
double t_1 = (b - (d * (a / c))) / c;
double tmp;
if (c <= -5.2e+53) {
tmp = t_1;
} else if (c <= 19000000000.0) {
tmp = t_0;
} else if (c <= 2.3e+23) {
tmp = (b - (a * (d / c))) / c;
} else if (c <= 1.35e+90) {
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 = ((c / d) * (b / d)) - (a / d)
t_1 = (b - (d * (a / c))) / c
if (c <= (-5.2d+53)) then
tmp = t_1
else if (c <= 19000000000.0d0) then
tmp = t_0
else if (c <= 2.3d+23) then
tmp = (b - (a * (d / c))) / c
else if (c <= 1.35d+90) 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 = ((c / d) * (b / d)) - (a / d);
double t_1 = (b - (d * (a / c))) / c;
double tmp;
if (c <= -5.2e+53) {
tmp = t_1;
} else if (c <= 19000000000.0) {
tmp = t_0;
} else if (c <= 2.3e+23) {
tmp = (b - (a * (d / c))) / c;
} else if (c <= 1.35e+90) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(a, b, c, d): t_0 = ((c / d) * (b / d)) - (a / d) t_1 = (b - (d * (a / c))) / c tmp = 0 if c <= -5.2e+53: tmp = t_1 elif c <= 19000000000.0: tmp = t_0 elif c <= 2.3e+23: tmp = (b - (a * (d / c))) / c elif c <= 1.35e+90: tmp = t_0 else: tmp = t_1 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(Float64(c / d) * Float64(b / d)) - Float64(a / d)) t_1 = Float64(Float64(b - Float64(d * Float64(a / c))) / c) tmp = 0.0 if (c <= -5.2e+53) tmp = t_1; elseif (c <= 19000000000.0) tmp = t_0; elseif (c <= 2.3e+23) tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c); elseif (c <= 1.35e+90) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((c / d) * (b / d)) - (a / d); t_1 = (b - (d * (a / c))) / c; tmp = 0.0; if (c <= -5.2e+53) tmp = t_1; elseif (c <= 19000000000.0) tmp = t_0; elseif (c <= 2.3e+23) tmp = (b - (a * (d / c))) / c; elseif (c <= 1.35e+90) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(c / d), $MachinePrecision] * N[(b / d), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(b - N[(d * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]}, If[LessEqual[c, -5.2e+53], t$95$1, If[LessEqual[c, 19000000000.0], t$95$0, If[LessEqual[c, 2.3e+23], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[c, 1.35e+90], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c}{d} \cdot \frac{b}{d} - \frac{a}{d}\\
t_1 := \frac{b - d \cdot \frac{a}{c}}{c}\\
\mathbf{if}\;c \leq -5.2 \cdot 10^{+53}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;c \leq 19000000000:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 2.3 \cdot 10^{+23}:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\
\mathbf{elif}\;c \leq 1.35 \cdot 10^{+90}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if c < -5.19999999999999996e53 or 1.35e90 < c Initial program 41.9%
Taylor expanded in c around inf 75.2%
+-commutative75.2%
mul-1-neg75.2%
unsub-neg75.2%
unpow275.2%
times-frac84.2%
Simplified84.2%
associate-*r/85.5%
sub-div85.5%
Applied egg-rr85.5%
if -5.19999999999999996e53 < c < 1.9e10 or 2.3e23 < c < 1.35e90Initial program 70.4%
Taylor expanded in c around 0 73.9%
+-commutative73.9%
mul-1-neg73.9%
unsub-neg73.9%
*-commutative73.9%
unpow273.9%
times-frac81.2%
Simplified81.2%
if 1.9e10 < c < 2.3e23Initial program 99.1%
Taylor expanded in c around inf 95.2%
+-commutative95.2%
mul-1-neg95.2%
unsub-neg95.2%
unpow295.2%
times-frac95.5%
Simplified95.5%
associate-*l/95.5%
sub-div95.5%
Applied egg-rr95.5%
Final simplification83.3%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (- (* (/ c d) (/ b d)) (/ a d))))
(if (<= c -7e+55)
(/ (- b (* d (/ a c))) c)
(if (<= c 6500000000.0)
t_0
(if (<= c 8.5e+19)
(/ (- b (* a (/ d c))) c)
(if (<= c 6.6e+92) t_0 (- (/ b c) (/ d (* c (/ c a))))))))))
double code(double a, double b, double c, double d) {
double t_0 = ((c / d) * (b / d)) - (a / d);
double tmp;
if (c <= -7e+55) {
tmp = (b - (d * (a / c))) / c;
} else if (c <= 6500000000.0) {
tmp = t_0;
} else if (c <= 8.5e+19) {
tmp = (b - (a * (d / c))) / c;
} else if (c <= 6.6e+92) {
tmp = t_0;
} else {
tmp = (b / c) - (d / (c * (c / a)));
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: tmp
t_0 = ((c / d) * (b / d)) - (a / d)
if (c <= (-7d+55)) then
tmp = (b - (d * (a / c))) / c
else if (c <= 6500000000.0d0) then
tmp = t_0
else if (c <= 8.5d+19) then
tmp = (b - (a * (d / c))) / c
else if (c <= 6.6d+92) then
tmp = t_0
else
tmp = (b / c) - (d / (c * (c / a)))
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = ((c / d) * (b / d)) - (a / d);
double tmp;
if (c <= -7e+55) {
tmp = (b - (d * (a / c))) / c;
} else if (c <= 6500000000.0) {
tmp = t_0;
} else if (c <= 8.5e+19) {
tmp = (b - (a * (d / c))) / c;
} else if (c <= 6.6e+92) {
tmp = t_0;
} else {
tmp = (b / c) - (d / (c * (c / a)));
}
return tmp;
}
def code(a, b, c, d): t_0 = ((c / d) * (b / d)) - (a / d) tmp = 0 if c <= -7e+55: tmp = (b - (d * (a / c))) / c elif c <= 6500000000.0: tmp = t_0 elif c <= 8.5e+19: tmp = (b - (a * (d / c))) / c elif c <= 6.6e+92: tmp = t_0 else: tmp = (b / c) - (d / (c * (c / a))) return tmp
function code(a, b, c, d) t_0 = Float64(Float64(Float64(c / d) * Float64(b / d)) - Float64(a / d)) tmp = 0.0 if (c <= -7e+55) tmp = Float64(Float64(b - Float64(d * Float64(a / c))) / c); elseif (c <= 6500000000.0) tmp = t_0; elseif (c <= 8.5e+19) tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c); elseif (c <= 6.6e+92) tmp = t_0; else tmp = Float64(Float64(b / c) - Float64(d / Float64(c * Float64(c / a)))); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((c / d) * (b / d)) - (a / d); tmp = 0.0; if (c <= -7e+55) tmp = (b - (d * (a / c))) / c; elseif (c <= 6500000000.0) tmp = t_0; elseif (c <= 8.5e+19) tmp = (b - (a * (d / c))) / c; elseif (c <= 6.6e+92) tmp = t_0; else tmp = (b / c) - (d / (c * (c / a))); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(c / d), $MachinePrecision] * N[(b / d), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -7e+55], N[(N[(b - N[(d * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[c, 6500000000.0], t$95$0, If[LessEqual[c, 8.5e+19], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[c, 6.6e+92], t$95$0, N[(N[(b / c), $MachinePrecision] - N[(d / N[(c * N[(c / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c}{d} \cdot \frac{b}{d} - \frac{a}{d}\\
\mathbf{if}\;c \leq -7 \cdot 10^{+55}:\\
\;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\
\mathbf{elif}\;c \leq 6500000000:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 8.5 \cdot 10^{+19}:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\
\mathbf{elif}\;c \leq 6.6 \cdot 10^{+92}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c} - \frac{d}{c \cdot \frac{c}{a}}\\
\end{array}
\end{array}
if c < -7.00000000000000021e55Initial program 49.9%
Taylor expanded in c around inf 79.1%
+-commutative79.1%
mul-1-neg79.1%
unsub-neg79.1%
unpow279.1%
times-frac88.5%
Simplified88.5%
associate-*r/90.0%
sub-div90.0%
Applied egg-rr90.0%
if -7.00000000000000021e55 < c < 6.5e9 or 8.5e19 < c < 6.59999999999999948e92Initial program 70.4%
Taylor expanded in c around 0 73.9%
+-commutative73.9%
mul-1-neg73.9%
unsub-neg73.9%
*-commutative73.9%
unpow273.9%
times-frac81.2%
Simplified81.2%
if 6.5e9 < c < 8.5e19Initial program 99.1%
Taylor expanded in c around inf 95.2%
+-commutative95.2%
mul-1-neg95.2%
unsub-neg95.2%
unpow295.2%
times-frac95.5%
Simplified95.5%
associate-*l/95.5%
sub-div95.5%
Applied egg-rr95.5%
if 6.59999999999999948e92 < c Initial program 31.6%
Taylor expanded in c around inf 70.2%
+-commutative70.2%
mul-1-neg70.2%
unsub-neg70.2%
unpow270.2%
times-frac78.8%
Simplified78.8%
clear-num78.9%
frac-times79.8%
*-un-lft-identity79.8%
Applied egg-rr79.8%
Final simplification83.3%
(FPCore (a b c d)
:precision binary64
(if (<= c -7.8e+18)
(/ b c)
(if (<= c 6.5e-30)
(- (/ a d))
(if (<= c 9.5e+99) (* (/ c d) (/ b d)) (/ b c)))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -7.8e+18) {
tmp = b / c;
} else if (c <= 6.5e-30) {
tmp = -(a / d);
} else if (c <= 9.5e+99) {
tmp = (c / d) * (b / d);
} else {
tmp = 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 <= (-7.8d+18)) then
tmp = b / c
else if (c <= 6.5d-30) then
tmp = -(a / d)
else if (c <= 9.5d+99) then
tmp = (c / d) * (b / d)
else
tmp = b / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -7.8e+18) {
tmp = b / c;
} else if (c <= 6.5e-30) {
tmp = -(a / d);
} else if (c <= 9.5e+99) {
tmp = (c / d) * (b / d);
} else {
tmp = b / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -7.8e+18: tmp = b / c elif c <= 6.5e-30: tmp = -(a / d) elif c <= 9.5e+99: tmp = (c / d) * (b / d) else: tmp = b / c return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -7.8e+18) tmp = Float64(b / c); elseif (c <= 6.5e-30) tmp = Float64(-Float64(a / d)); elseif (c <= 9.5e+99) tmp = Float64(Float64(c / d) * Float64(b / d)); else tmp = Float64(b / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -7.8e+18) tmp = b / c; elseif (c <= 6.5e-30) tmp = -(a / d); elseif (c <= 9.5e+99) tmp = (c / d) * (b / d); else tmp = b / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -7.8e+18], N[(b / c), $MachinePrecision], If[LessEqual[c, 6.5e-30], (-N[(a / d), $MachinePrecision]), If[LessEqual[c, 9.5e+99], N[(N[(c / d), $MachinePrecision] * N[(b / d), $MachinePrecision]), $MachinePrecision], N[(b / c), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -7.8 \cdot 10^{+18}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{elif}\;c \leq 6.5 \cdot 10^{-30}:\\
\;\;\;\;-\frac{a}{d}\\
\mathbf{elif}\;c \leq 9.5 \cdot 10^{+99}:\\
\;\;\;\;\frac{c}{d} \cdot \frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if c < -7.8e18 or 9.49999999999999908e99 < c Initial program 42.8%
Taylor expanded in c around inf 66.1%
if -7.8e18 < c < 6.5000000000000005e-30Initial program 71.7%
Taylor expanded in c around 0 72.4%
associate-*r/72.4%
neg-mul-172.4%
Simplified72.4%
if 6.5000000000000005e-30 < c < 9.49999999999999908e99Initial program 71.9%
div-sub71.9%
*-commutative71.9%
add-sqr-sqrt71.8%
times-frac83.9%
fma-neg83.9%
hypot-def83.9%
hypot-def95.5%
associate-/l*91.7%
add-sqr-sqrt91.7%
pow291.7%
hypot-def91.7%
Applied egg-rr91.7%
Taylor expanded in b around inf 48.1%
*-commutative48.1%
unpow248.1%
+-commutative48.1%
unpow248.1%
Simplified48.1%
Taylor expanded in c around 0 32.5%
*-commutative32.5%
unpow232.5%
times-frac52.1%
Simplified52.1%
Final simplification67.7%
(FPCore (a b c d) :precision binary64 (if (<= c -1.35e+18) (/ b c) (if (<= c 1.15e+99) (- (/ a d)) (/ b c))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -1.35e+18) {
tmp = b / c;
} else if (c <= 1.15e+99) {
tmp = -(a / d);
} else {
tmp = 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 <= (-1.35d+18)) then
tmp = b / c
else if (c <= 1.15d+99) then
tmp = -(a / d)
else
tmp = b / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -1.35e+18) {
tmp = b / c;
} else if (c <= 1.15e+99) {
tmp = -(a / d);
} else {
tmp = b / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -1.35e+18: tmp = b / c elif c <= 1.15e+99: tmp = -(a / d) else: tmp = b / c return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -1.35e+18) tmp = Float64(b / c); elseif (c <= 1.15e+99) tmp = Float64(-Float64(a / d)); else tmp = Float64(b / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -1.35e+18) tmp = b / c; elseif (c <= 1.15e+99) tmp = -(a / d); else tmp = b / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -1.35e+18], N[(b / c), $MachinePrecision], If[LessEqual[c, 1.15e+99], (-N[(a / d), $MachinePrecision]), N[(b / c), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.35 \cdot 10^{+18}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{elif}\;c \leq 1.15 \cdot 10^{+99}:\\
\;\;\;\;-\frac{a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if c < -1.35e18 or 1.1500000000000001e99 < c Initial program 43.3%
Taylor expanded in c around inf 65.6%
if -1.35e18 < c < 1.1500000000000001e99Initial program 71.5%
Taylor expanded in c around 0 66.0%
associate-*r/66.0%
neg-mul-166.0%
Simplified66.0%
Final simplification65.8%
(FPCore (a b c d) :precision binary64 (/ b c))
double code(double a, double b, double c, double d) {
return b / 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 = b / c
end function
public static double code(double a, double b, double c, double d) {
return b / c;
}
def code(a, b, c, d): return b / c
function code(a, b, c, d) return Float64(b / c) end
function tmp = code(a, b, c, d) tmp = b / c; end
code[a_, b_, c_, d_] := N[(b / c), $MachinePrecision]
\begin{array}{l}
\\
\frac{b}{c}
\end{array}
Initial program 58.6%
Taylor expanded in c around inf 39.7%
Final simplification39.7%
(FPCore (a b c d) :precision binary64 (if (< (fabs d) (fabs c)) (/ (- b (* a (/ d c))) (+ c (* d (/ d c)))) (/ (+ (- a) (* b (/ c d))) (+ d (* c (/ c d))))))
double code(double a, double b, double c, double d) {
double tmp;
if (fabs(d) < fabs(c)) {
tmp = (b - (a * (d / c))) / (c + (d * (d / c)));
} else {
tmp = (-a + (b * (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 = (b - (a * (d / c))) / (c + (d * (d / c)))
else
tmp = (-a + (b * (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 = (b - (a * (d / c))) / (c + (d * (d / c)));
} else {
tmp = (-a + (b * (c / d))) / (d + (c * (c / d)));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if math.fabs(d) < math.fabs(c): tmp = (b - (a * (d / c))) / (c + (d * (d / c))) else: tmp = (-a + (b * (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(b - Float64(a * Float64(d / c))) / Float64(c + Float64(d * Float64(d / c)))); else tmp = Float64(Float64(Float64(-a) + Float64(b * 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 = (b - (a * (d / c))) / (c + (d * (d / c))); else tmp = (-a + (b * (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[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(c + N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[((-a) + N[(b * 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{b - a \cdot \frac{d}{c}}{c + d \cdot \frac{d}{c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-a\right) + b \cdot \frac{c}{d}}{d + c \cdot \frac{c}{d}}\\
\end{array}
\end{array}
herbie shell --seed 2023293
(FPCore (a b c d)
:name "Complex division, imag part"
:precision binary64
:herbie-target
(if (< (fabs d) (fabs c)) (/ (- b (* a (/ d c))) (+ c (* d (/ d c)))) (/ (+ (- a) (* b (/ c d))) (+ d (* c (/ c d)))))
(/ (- (* b c) (* a d)) (+ (* c c) (* d d))))