
(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 13 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 (- (/ (/ c (hypot c d)) (/ (hypot c d) b)) (/ a (fma c (/ c d) d))))
double code(double a, double b, double c, double d) {
return ((c / hypot(c, d)) / (hypot(c, d) / b)) - (a / fma(c, (c / d), d));
}
function code(a, b, c, d) return Float64(Float64(Float64(c / hypot(c, d)) / Float64(hypot(c, d) / b)) - Float64(a / fma(c, Float64(c / d), d))) end
code[a_, b_, c_, d_] := N[(N[(N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] / N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision] - N[(a / N[(c * N[(c / d), $MachinePrecision] + d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{c}{\mathsf{hypot}\left(c, d\right)}}{\frac{\mathsf{hypot}\left(c, d\right)}{b}} - \frac{a}{\mathsf{fma}\left(c, \frac{c}{d}, d\right)}
\end{array}
Initial program 63.5%
div-sub60.7%
add-sqr-sqrt60.7%
pow260.7%
hypot-def60.7%
associate-/l*61.5%
add-sqr-sqrt61.5%
pow261.5%
hypot-def61.5%
Applied egg-rr61.5%
*-commutative61.5%
unpow261.5%
times-frac80.3%
Applied egg-rr80.3%
Taylor expanded in c around 0 91.4%
+-commutative91.4%
unpow291.4%
associate-*r/96.5%
fma-def96.5%
Simplified96.5%
clear-num96.3%
un-div-inv96.6%
Applied egg-rr96.6%
Final simplification96.6%
(FPCore (a b c d) :precision binary64 (- (* (/ c (hypot c d)) (/ b (hypot c d))) (/ a (fma c (/ c d) d))))
double code(double a, double b, double c, double d) {
return ((c / hypot(c, d)) * (b / hypot(c, d))) - (a / fma(c, (c / d), d));
}
function code(a, b, c, d) return Float64(Float64(Float64(c / hypot(c, d)) * Float64(b / hypot(c, d))) - Float64(a / fma(c, Float64(c / d), d))) end
code[a_, b_, c_, d_] := N[(N[(N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(a / N[(c * N[(c / d), $MachinePrecision] + d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{c}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b}{\mathsf{hypot}\left(c, d\right)} - \frac{a}{\mathsf{fma}\left(c, \frac{c}{d}, d\right)}
\end{array}
Initial program 63.5%
div-sub60.7%
add-sqr-sqrt60.7%
pow260.7%
hypot-def60.7%
associate-/l*61.5%
add-sqr-sqrt61.5%
pow261.5%
hypot-def61.5%
Applied egg-rr61.5%
*-commutative61.5%
unpow261.5%
times-frac80.3%
Applied egg-rr80.3%
Taylor expanded in c around 0 91.4%
+-commutative91.4%
unpow291.4%
associate-*r/96.5%
fma-def96.5%
Simplified96.5%
Final simplification96.5%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (- (/ b c) (/ a (fma c (/ c d) d))))
(t_1 (+ (* c c) (* d d)))
(t_2 (/ (- (* c b) (* d a)) t_1)))
(if (<= t_2 (- INFINITY))
t_0
(if (<= t_2 -5e-292)
t_2
(if (<= t_2 0.0)
(/ (- a) (* (hypot d c) (/ (hypot d c) d)))
(if (<= t_2 2e+202) (/ (fma c b (* d (- a))) t_1) t_0))))))
double code(double a, double b, double c, double d) {
double t_0 = (b / c) - (a / fma(c, (c / d), d));
double t_1 = (c * c) + (d * d);
double t_2 = ((c * b) - (d * a)) / t_1;
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = t_0;
} else if (t_2 <= -5e-292) {
tmp = t_2;
} else if (t_2 <= 0.0) {
tmp = -a / (hypot(d, c) * (hypot(d, c) / d));
} else if (t_2 <= 2e+202) {
tmp = fma(c, b, (d * -a)) / t_1;
} else {
tmp = t_0;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(b / c) - Float64(a / fma(c, Float64(c / d), d))) t_1 = Float64(Float64(c * c) + Float64(d * d)) t_2 = Float64(Float64(Float64(c * b) - Float64(d * a)) / t_1) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = t_0; elseif (t_2 <= -5e-292) tmp = t_2; elseif (t_2 <= 0.0) tmp = Float64(Float64(-a) / Float64(hypot(d, c) * Float64(hypot(d, c) / d))); elseif (t_2 <= 2e+202) tmp = Float64(fma(c, b, Float64(d * Float64(-a))) / t_1); else tmp = t_0; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(b / c), $MachinePrecision] - N[(a / N[(c * N[(c / d), $MachinePrecision] + d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], t$95$0, If[LessEqual[t$95$2, -5e-292], t$95$2, If[LessEqual[t$95$2, 0.0], N[((-a) / N[(N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision] * N[(N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 2e+202], N[(N[(c * b + N[(d * (-a)), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision], t$95$0]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b}{c} - \frac{a}{\mathsf{fma}\left(c, \frac{c}{d}, d\right)}\\
t_1 := c \cdot c + d \cdot d\\
t_2 := \frac{c \cdot b - d \cdot a}{t_1}\\
\mathbf{if}\;t_2 \leq -\infty:\\
\;\;\;\;t_0\\
\mathbf{elif}\;t_2 \leq -5 \cdot 10^{-292}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;t_2 \leq 0:\\
\;\;\;\;\frac{-a}{\mathsf{hypot}\left(d, c\right) \cdot \frac{\mathsf{hypot}\left(d, c\right)}{d}}\\
\mathbf{elif}\;t_2 \leq 2 \cdot 10^{+202}:\\
\;\;\;\;\frac{\mathsf{fma}\left(c, b, d \cdot \left(-a\right)\right)}{t_1}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < -inf.0 or 1.9999999999999998e202 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 25.7%
div-sub17.6%
add-sqr-sqrt17.6%
pow217.6%
hypot-def17.6%
associate-/l*23.7%
add-sqr-sqrt23.7%
pow223.7%
hypot-def23.7%
Applied egg-rr23.7%
*-commutative23.7%
unpow223.7%
times-frac68.7%
Applied egg-rr68.7%
Taylor expanded in c around 0 90.5%
+-commutative90.5%
unpow290.5%
associate-*r/98.8%
fma-def98.8%
Simplified98.8%
Taylor expanded in c around inf 80.8%
if -inf.0 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < -4.99999999999999981e-292Initial program 99.3%
if -4.99999999999999981e-292 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 0.0Initial program 62.0%
Taylor expanded in b around 0 62.0%
mul-1-neg62.0%
+-commutative62.0%
*-commutative62.0%
fma-def62.0%
distribute-rgt-neg-in62.0%
Simplified62.0%
Taylor expanded in b around 0 62.0%
mul-1-neg62.0%
associate-/l*62.0%
distribute-neg-frac62.0%
+-commutative62.0%
unpow262.0%
fma-def62.0%
Simplified62.0%
add-sqr-sqrt62.0%
*-un-lft-identity62.0%
times-frac62.0%
fma-udef62.0%
unpow262.0%
hypot-def62.0%
fma-udef62.0%
unpow262.0%
hypot-def82.9%
Applied egg-rr82.9%
if 0.0 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 1.9999999999999998e202Initial program 99.0%
Taylor expanded in b around 0 99.0%
mul-1-neg99.0%
+-commutative99.0%
*-commutative99.0%
fma-def99.0%
distribute-rgt-neg-in99.0%
Simplified99.0%
Final simplification88.3%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (+ (* c c) (* d d))) (t_1 (- (/ b c) (/ a (fma c (/ c d) d)))))
(if (<= c -3.3e+102)
t_1
(if (<= c -1.8e-158)
(/ (- (* c b) (* d a)) t_0)
(if (<= c 2.15e-148)
(- (/ b (* d (/ d c))) (/ a d))
(if (<= c 7.6e+27) (/ (fma c b (* d (- a))) t_0) t_1))))))
double code(double a, double b, double c, double d) {
double t_0 = (c * c) + (d * d);
double t_1 = (b / c) - (a / fma(c, (c / d), d));
double tmp;
if (c <= -3.3e+102) {
tmp = t_1;
} else if (c <= -1.8e-158) {
tmp = ((c * b) - (d * a)) / t_0;
} else if (c <= 2.15e-148) {
tmp = (b / (d * (d / c))) - (a / d);
} else if (c <= 7.6e+27) {
tmp = fma(c, b, (d * -a)) / t_0;
} else {
tmp = t_1;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(c * c) + Float64(d * d)) t_1 = Float64(Float64(b / c) - Float64(a / fma(c, Float64(c / d), d))) tmp = 0.0 if (c <= -3.3e+102) tmp = t_1; elseif (c <= -1.8e-158) tmp = Float64(Float64(Float64(c * b) - Float64(d * a)) / t_0); elseif (c <= 2.15e-148) tmp = Float64(Float64(b / Float64(d * Float64(d / c))) - Float64(a / d)); elseif (c <= 7.6e+27) tmp = Float64(fma(c, b, Float64(d * Float64(-a))) / t_0); else tmp = t_1; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(b / c), $MachinePrecision] - N[(a / N[(c * N[(c / d), $MachinePrecision] + d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -3.3e+102], t$95$1, If[LessEqual[c, -1.8e-158], N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision], If[LessEqual[c, 2.15e-148], N[(N[(b / N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 7.6e+27], N[(N[(c * b + N[(d * (-a)), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := c \cdot c + d \cdot d\\
t_1 := \frac{b}{c} - \frac{a}{\mathsf{fma}\left(c, \frac{c}{d}, d\right)}\\
\mathbf{if}\;c \leq -3.3 \cdot 10^{+102}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;c \leq -1.8 \cdot 10^{-158}:\\
\;\;\;\;\frac{c \cdot b - d \cdot a}{t_0}\\
\mathbf{elif}\;c \leq 2.15 \cdot 10^{-148}:\\
\;\;\;\;\frac{b}{d \cdot \frac{d}{c}} - \frac{a}{d}\\
\mathbf{elif}\;c \leq 7.6 \cdot 10^{+27}:\\
\;\;\;\;\frac{\mathsf{fma}\left(c, b, d \cdot \left(-a\right)\right)}{t_0}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if c < -3.29999999999999999e102 or 7.60000000000000043e27 < c Initial program 40.0%
div-sub40.0%
add-sqr-sqrt40.0%
pow240.0%
hypot-def40.0%
associate-/l*40.5%
add-sqr-sqrt40.5%
pow240.5%
hypot-def40.5%
Applied egg-rr40.5%
*-commutative40.5%
unpow240.5%
times-frac83.8%
Applied egg-rr83.8%
Taylor expanded in c around 0 86.7%
+-commutative86.7%
unpow286.7%
associate-*r/96.3%
fma-def96.3%
Simplified96.3%
Taylor expanded in c around inf 88.1%
if -3.29999999999999999e102 < c < -1.79999999999999995e-158Initial program 81.5%
if -1.79999999999999995e-158 < c < 2.1499999999999999e-148Initial program 68.2%
Taylor expanded in b around 0 68.2%
mul-1-neg68.2%
+-commutative68.2%
*-commutative68.2%
fma-def68.2%
distribute-rgt-neg-in68.2%
Simplified68.2%
Taylor expanded in c around 0 80.1%
+-commutative80.1%
mul-1-neg80.1%
unsub-neg80.1%
associate-/l*84.9%
Simplified84.9%
unpow284.9%
*-un-lft-identity84.9%
times-frac92.8%
Applied egg-rr92.8%
if 2.1499999999999999e-148 < c < 7.60000000000000043e27Initial program 89.7%
Taylor expanded in b around 0 89.7%
mul-1-neg89.7%
+-commutative89.7%
*-commutative89.7%
fma-def89.8%
distribute-rgt-neg-in89.8%
Simplified89.8%
Final simplification88.0%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* c b) (* d a)) (+ (* c c) (* d d))))
(t_1 (- (/ b c) (/ a (fma c (/ c d) d)))))
(if (<= c -3.3e+102)
t_1
(if (<= c -3.5e-158)
t_0
(if (<= c 4e-149)
(- (/ b (* d (/ d c))) (/ a d))
(if (<= c 2.1e+28) t_0 t_1))))))
double code(double a, double b, double c, double d) {
double t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
double t_1 = (b / c) - (a / fma(c, (c / d), d));
double tmp;
if (c <= -3.3e+102) {
tmp = t_1;
} else if (c <= -3.5e-158) {
tmp = t_0;
} else if (c <= 4e-149) {
tmp = (b / (d * (d / c))) - (a / d);
} else if (c <= 2.1e+28) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d))) t_1 = Float64(Float64(b / c) - Float64(a / fma(c, Float64(c / d), d))) tmp = 0.0 if (c <= -3.3e+102) tmp = t_1; elseif (c <= -3.5e-158) tmp = t_0; elseif (c <= 4e-149) tmp = Float64(Float64(b / Float64(d * Float64(d / c))) - Float64(a / d)); elseif (c <= 2.1e+28) tmp = t_0; else tmp = t_1; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(b / c), $MachinePrecision] - N[(a / N[(c * N[(c / d), $MachinePrecision] + d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -3.3e+102], t$95$1, If[LessEqual[c, -3.5e-158], t$95$0, If[LessEqual[c, 4e-149], N[(N[(b / N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 2.1e+28], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
t_1 := \frac{b}{c} - \frac{a}{\mathsf{fma}\left(c, \frac{c}{d}, d\right)}\\
\mathbf{if}\;c \leq -3.3 \cdot 10^{+102}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;c \leq -3.5 \cdot 10^{-158}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 4 \cdot 10^{-149}:\\
\;\;\;\;\frac{b}{d \cdot \frac{d}{c}} - \frac{a}{d}\\
\mathbf{elif}\;c \leq 2.1 \cdot 10^{+28}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if c < -3.29999999999999999e102 or 2.09999999999999989e28 < c Initial program 40.0%
div-sub40.0%
add-sqr-sqrt40.0%
pow240.0%
hypot-def40.0%
associate-/l*40.5%
add-sqr-sqrt40.5%
pow240.5%
hypot-def40.5%
Applied egg-rr40.5%
*-commutative40.5%
unpow240.5%
times-frac83.8%
Applied egg-rr83.8%
Taylor expanded in c around 0 86.7%
+-commutative86.7%
unpow286.7%
associate-*r/96.3%
fma-def96.3%
Simplified96.3%
Taylor expanded in c around inf 88.1%
if -3.29999999999999999e102 < c < -3.50000000000000012e-158 or 3.99999999999999992e-149 < c < 2.09999999999999989e28Initial program 84.7%
if -3.50000000000000012e-158 < c < 3.99999999999999992e-149Initial program 68.2%
Taylor expanded in b around 0 68.2%
mul-1-neg68.2%
+-commutative68.2%
*-commutative68.2%
fma-def68.2%
distribute-rgt-neg-in68.2%
Simplified68.2%
Taylor expanded in c around 0 80.1%
+-commutative80.1%
mul-1-neg80.1%
unsub-neg80.1%
associate-/l*84.9%
Simplified84.9%
unpow284.9%
*-un-lft-identity84.9%
times-frac92.8%
Applied egg-rr92.8%
Final simplification88.0%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (* c b) (+ (* c c) (* d d))))
(t_1 (- (/ b c) (* d (/ (/ a c) c)))))
(if (<= c -0.00028)
t_1
(if (<= c -6.4e-139)
t_0
(if (<= c 3.7e-32) (/ (- a) d) (if (<= c 3400000000000.0) t_0 t_1))))))
double code(double a, double b, double c, double d) {
double t_0 = (c * b) / ((c * c) + (d * d));
double t_1 = (b / c) - (d * ((a / c) / c));
double tmp;
if (c <= -0.00028) {
tmp = t_1;
} else if (c <= -6.4e-139) {
tmp = t_0;
} else if (c <= 3.7e-32) {
tmp = -a / d;
} else if (c <= 3400000000000.0) {
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 * b) / ((c * c) + (d * d))
t_1 = (b / c) - (d * ((a / c) / c))
if (c <= (-0.00028d0)) then
tmp = t_1
else if (c <= (-6.4d-139)) then
tmp = t_0
else if (c <= 3.7d-32) then
tmp = -a / d
else if (c <= 3400000000000.0d0) 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 * b) / ((c * c) + (d * d));
double t_1 = (b / c) - (d * ((a / c) / c));
double tmp;
if (c <= -0.00028) {
tmp = t_1;
} else if (c <= -6.4e-139) {
tmp = t_0;
} else if (c <= 3.7e-32) {
tmp = -a / d;
} else if (c <= 3400000000000.0) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(a, b, c, d): t_0 = (c * b) / ((c * c) + (d * d)) t_1 = (b / c) - (d * ((a / c) / c)) tmp = 0 if c <= -0.00028: tmp = t_1 elif c <= -6.4e-139: tmp = t_0 elif c <= 3.7e-32: tmp = -a / d elif c <= 3400000000000.0: tmp = t_0 else: tmp = t_1 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(c * b) / Float64(Float64(c * c) + Float64(d * d))) t_1 = Float64(Float64(b / c) - Float64(d * Float64(Float64(a / c) / c))) tmp = 0.0 if (c <= -0.00028) tmp = t_1; elseif (c <= -6.4e-139) tmp = t_0; elseif (c <= 3.7e-32) tmp = Float64(Float64(-a) / d); elseif (c <= 3400000000000.0) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (c * b) / ((c * c) + (d * d)); t_1 = (b / c) - (d * ((a / c) / c)); tmp = 0.0; if (c <= -0.00028) tmp = t_1; elseif (c <= -6.4e-139) tmp = t_0; elseif (c <= 3.7e-32) tmp = -a / d; elseif (c <= 3400000000000.0) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c * b), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(b / c), $MachinePrecision] - N[(d * N[(N[(a / c), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -0.00028], t$95$1, If[LessEqual[c, -6.4e-139], t$95$0, If[LessEqual[c, 3.7e-32], N[((-a) / d), $MachinePrecision], If[LessEqual[c, 3400000000000.0], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c \cdot b}{c \cdot c + d \cdot d}\\
t_1 := \frac{b}{c} - d \cdot \frac{\frac{a}{c}}{c}\\
\mathbf{if}\;c \leq -0.00028:\\
\;\;\;\;t_1\\
\mathbf{elif}\;c \leq -6.4 \cdot 10^{-139}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 3.7 \cdot 10^{-32}:\\
\;\;\;\;\frac{-a}{d}\\
\mathbf{elif}\;c \leq 3400000000000:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if c < -2.7999999999999998e-4 or 3.4e12 < c Initial program 48.9%
Taylor expanded in c around inf 74.2%
+-commutative74.2%
mul-1-neg74.2%
unsub-neg74.2%
associate-/l*72.2%
associate-/r/75.0%
Simplified75.0%
*-un-lft-identity75.0%
unpow275.0%
times-frac78.9%
Applied egg-rr78.9%
associate-*l/78.9%
*-lft-identity78.9%
Simplified78.9%
if -2.7999999999999998e-4 < c < -6.3999999999999999e-139 or 3.7e-32 < c < 3.4e12Initial program 86.8%
Taylor expanded in b around inf 69.7%
*-commutative69.7%
Simplified69.7%
if -6.3999999999999999e-139 < c < 3.7e-32Initial program 73.2%
Taylor expanded in c around 0 76.1%
associate-*r/76.1%
neg-mul-176.1%
Simplified76.1%
Final simplification76.5%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (- (/ b c) (* d (/ (/ a c) c)))))
(if (<= c -5e+102)
t_0
(if (<= c -5.5e-158)
(/ (- (* c b) (* d a)) (+ (* c c) (* d d)))
(if (<= c 1.45e-17) (- (/ b (* d (/ d c))) (/ a d)) t_0)))))
double code(double a, double b, double c, double d) {
double t_0 = (b / c) - (d * ((a / c) / c));
double tmp;
if (c <= -5e+102) {
tmp = t_0;
} else if (c <= -5.5e-158) {
tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
} else if (c <= 1.45e-17) {
tmp = (b / (d * (d / c))) - (a / 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 / c) - (d * ((a / c) / c))
if (c <= (-5d+102)) then
tmp = t_0
else if (c <= (-5.5d-158)) then
tmp = ((c * b) - (d * a)) / ((c * c) + (d * d))
else if (c <= 1.45d-17) then
tmp = (b / (d * (d / c))) - (a / 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 / c) - (d * ((a / c) / c));
double tmp;
if (c <= -5e+102) {
tmp = t_0;
} else if (c <= -5.5e-158) {
tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
} else if (c <= 1.45e-17) {
tmp = (b / (d * (d / c))) - (a / d);
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b, c, d): t_0 = (b / c) - (d * ((a / c) / c)) tmp = 0 if c <= -5e+102: tmp = t_0 elif c <= -5.5e-158: tmp = ((c * b) - (d * a)) / ((c * c) + (d * d)) elif c <= 1.45e-17: tmp = (b / (d * (d / c))) - (a / d) else: tmp = t_0 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(b / c) - Float64(d * Float64(Float64(a / c) / c))) tmp = 0.0 if (c <= -5e+102) tmp = t_0; elseif (c <= -5.5e-158) tmp = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d))); elseif (c <= 1.45e-17) tmp = Float64(Float64(b / Float64(d * Float64(d / c))) - Float64(a / d)); else tmp = t_0; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (b / c) - (d * ((a / c) / c)); tmp = 0.0; if (c <= -5e+102) tmp = t_0; elseif (c <= -5.5e-158) tmp = ((c * b) - (d * a)) / ((c * c) + (d * d)); elseif (c <= 1.45e-17) tmp = (b / (d * (d / c))) - (a / d); else tmp = t_0; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(b / c), $MachinePrecision] - N[(d * N[(N[(a / c), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -5e+102], t$95$0, If[LessEqual[c, -5.5e-158], N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.45e-17], N[(N[(b / N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b}{c} - d \cdot \frac{\frac{a}{c}}{c}\\
\mathbf{if}\;c \leq -5 \cdot 10^{+102}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq -5.5 \cdot 10^{-158}:\\
\;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;c \leq 1.45 \cdot 10^{-17}:\\
\;\;\;\;\frac{b}{d \cdot \frac{d}{c}} - \frac{a}{d}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if c < -5e102 or 1.4500000000000001e-17 < c Initial program 46.3%
Taylor expanded in c around inf 74.8%
+-commutative74.8%
mul-1-neg74.8%
unsub-neg74.8%
associate-/l*72.6%
associate-/r/75.8%
Simplified75.8%
*-un-lft-identity75.8%
unpow275.8%
times-frac80.1%
Applied egg-rr80.1%
associate-*l/80.1%
*-lft-identity80.1%
Simplified80.1%
if -5e102 < c < -5.50000000000000025e-158Initial program 81.5%
if -5.50000000000000025e-158 < c < 1.4500000000000001e-17Initial program 73.3%
Taylor expanded in b around 0 73.3%
mul-1-neg73.3%
+-commutative73.3%
*-commutative73.3%
fma-def73.3%
distribute-rgt-neg-in73.3%
Simplified73.3%
Taylor expanded in c around 0 81.9%
+-commutative81.9%
mul-1-neg81.9%
unsub-neg81.9%
associate-/l*85.5%
Simplified85.5%
unpow285.5%
*-un-lft-identity85.5%
times-frac91.3%
Applied egg-rr91.3%
Final simplification84.2%
(FPCore (a b c d) :precision binary64 (if (or (<= c -2.9e-87) (not (<= c 1.18e-30))) (- (/ b c) (* d (/ (/ a c) c))) (/ (- a) d)))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -2.9e-87) || !(c <= 1.18e-30)) {
tmp = (b / c) - (d * ((a / c) / c));
} else {
tmp = -a / 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 <= (-2.9d-87)) .or. (.not. (c <= 1.18d-30))) then
tmp = (b / c) - (d * ((a / c) / c))
else
tmp = -a / d
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -2.9e-87) || !(c <= 1.18e-30)) {
tmp = (b / c) - (d * ((a / c) / c));
} else {
tmp = -a / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -2.9e-87) or not (c <= 1.18e-30): tmp = (b / c) - (d * ((a / c) / c)) else: tmp = -a / d return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -2.9e-87) || !(c <= 1.18e-30)) tmp = Float64(Float64(b / c) - Float64(d * Float64(Float64(a / c) / c))); else tmp = Float64(Float64(-a) / d); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((c <= -2.9e-87) || ~((c <= 1.18e-30))) tmp = (b / c) - (d * ((a / c) / c)); else tmp = -a / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -2.9e-87], N[Not[LessEqual[c, 1.18e-30]], $MachinePrecision]], N[(N[(b / c), $MachinePrecision] - N[(d * N[(N[(a / c), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-a) / d), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -2.9 \cdot 10^{-87} \lor \neg \left(c \leq 1.18 \cdot 10^{-30}\right):\\
\;\;\;\;\frac{b}{c} - d \cdot \frac{\frac{a}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{-a}{d}\\
\end{array}
\end{array}
if c < -2.8999999999999999e-87 or 1.18000000000000006e-30 < c Initial program 55.7%
Taylor expanded in c around inf 70.6%
+-commutative70.6%
mul-1-neg70.6%
unsub-neg70.6%
associate-/l*69.0%
associate-/r/70.7%
Simplified70.7%
*-un-lft-identity70.7%
unpow270.7%
times-frac73.8%
Applied egg-rr73.8%
associate-*l/73.8%
*-lft-identity73.8%
Simplified73.8%
if -2.8999999999999999e-87 < c < 1.18000000000000006e-30Initial program 74.9%
Taylor expanded in c around 0 71.9%
associate-*r/71.9%
neg-mul-171.9%
Simplified71.9%
Final simplification73.0%
(FPCore (a b c d) :precision binary64 (if (or (<= c -0.0215) (not (<= c 2.4e-17))) (- (/ b c) (* d (/ (/ a c) c))) (- (/ b (* d (/ d c))) (/ a d))))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -0.0215) || !(c <= 2.4e-17)) {
tmp = (b / c) - (d * ((a / c) / c));
} else {
tmp = (b / (d * (d / c))) - (a / 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 <= (-0.0215d0)) .or. (.not. (c <= 2.4d-17))) then
tmp = (b / c) - (d * ((a / c) / c))
else
tmp = (b / (d * (d / c))) - (a / d)
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -0.0215) || !(c <= 2.4e-17)) {
tmp = (b / c) - (d * ((a / c) / c));
} else {
tmp = (b / (d * (d / c))) - (a / d);
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -0.0215) or not (c <= 2.4e-17): tmp = (b / c) - (d * ((a / c) / c)) else: tmp = (b / (d * (d / c))) - (a / d) return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -0.0215) || !(c <= 2.4e-17)) tmp = Float64(Float64(b / c) - Float64(d * Float64(Float64(a / c) / c))); else tmp = Float64(Float64(b / Float64(d * Float64(d / c))) - Float64(a / d)); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((c <= -0.0215) || ~((c <= 2.4e-17))) tmp = (b / c) - (d * ((a / c) / c)); else tmp = (b / (d * (d / c))) - (a / d); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -0.0215], N[Not[LessEqual[c, 2.4e-17]], $MachinePrecision]], N[(N[(b / c), $MachinePrecision] - N[(d * N[(N[(a / c), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b / N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -0.0215 \lor \neg \left(c \leq 2.4 \cdot 10^{-17}\right):\\
\;\;\;\;\frac{b}{c} - d \cdot \frac{\frac{a}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d \cdot \frac{d}{c}} - \frac{a}{d}\\
\end{array}
\end{array}
if c < -0.021499999999999998 or 2.39999999999999986e-17 < c Initial program 51.7%
Taylor expanded in c around inf 72.9%
+-commutative72.9%
mul-1-neg72.9%
unsub-neg72.9%
associate-/l*71.1%
associate-/r/73.7%
Simplified73.7%
*-un-lft-identity73.7%
unpow273.7%
times-frac77.3%
Applied egg-rr77.3%
associate-*l/77.3%
*-lft-identity77.3%
Simplified77.3%
if -0.021499999999999998 < c < 2.39999999999999986e-17Initial program 76.4%
Taylor expanded in b around 0 76.4%
mul-1-neg76.4%
+-commutative76.4%
*-commutative76.4%
fma-def76.4%
distribute-rgt-neg-in76.4%
Simplified76.4%
Taylor expanded in c around 0 75.8%
+-commutative75.8%
mul-1-neg75.8%
unsub-neg75.8%
associate-/l*78.4%
Simplified78.4%
unpow278.4%
*-un-lft-identity78.4%
times-frac82.6%
Applied egg-rr82.6%
Final simplification79.8%
(FPCore (a b c d) :precision binary64 (if (or (<= c -1.65e+32) (not (<= c 2.26e-29))) (/ b c) (/ (- a) d)))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -1.65e+32) || !(c <= 2.26e-29)) {
tmp = b / c;
} else {
tmp = -a / d;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if ((c <= (-1.65d+32)) .or. (.not. (c <= 2.26d-29))) then
tmp = b / c
else
tmp = -a / d
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -1.65e+32) || !(c <= 2.26e-29)) {
tmp = b / c;
} else {
tmp = -a / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -1.65e+32) or not (c <= 2.26e-29): tmp = b / c else: tmp = -a / d return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -1.65e+32) || !(c <= 2.26e-29)) tmp = Float64(b / c); else tmp = Float64(Float64(-a) / d); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((c <= -1.65e+32) || ~((c <= 2.26e-29))) tmp = b / c; else tmp = -a / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -1.65e+32], N[Not[LessEqual[c, 2.26e-29]], $MachinePrecision]], N[(b / c), $MachinePrecision], N[((-a) / d), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.65 \cdot 10^{+32} \lor \neg \left(c \leq 2.26 \cdot 10^{-29}\right):\\
\;\;\;\;\frac{b}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{-a}{d}\\
\end{array}
\end{array}
if c < -1.6500000000000001e32 or 2.25999999999999991e-29 < c Initial program 51.4%
Taylor expanded in c around inf 65.6%
if -1.6500000000000001e32 < c < 2.25999999999999991e-29Initial program 75.7%
Taylor expanded in c around 0 66.6%
associate-*r/66.6%
neg-mul-166.6%
Simplified66.6%
Final simplification66.1%
(FPCore (a b c d) :precision binary64 (if (or (<= d -1.02e+68) (not (<= d 2.2e+69))) (/ a d) (/ a c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -1.02e+68) || !(d <= 2.2e+69)) {
tmp = a / 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 ((d <= (-1.02d+68)) .or. (.not. (d <= 2.2d+69))) then
tmp = a / 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 ((d <= -1.02e+68) || !(d <= 2.2e+69)) {
tmp = a / d;
} else {
tmp = a / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -1.02e+68) or not (d <= 2.2e+69): tmp = a / d else: tmp = a / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -1.02e+68) || !(d <= 2.2e+69)) tmp = Float64(a / d); else tmp = Float64(a / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -1.02e+68) || ~((d <= 2.2e+69))) tmp = a / d; else tmp = a / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -1.02e+68], N[Not[LessEqual[d, 2.2e+69]], $MachinePrecision]], N[(a / d), $MachinePrecision], N[(a / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.02 \cdot 10^{+68} \lor \neg \left(d \leq 2.2 \cdot 10^{+69}\right):\\
\;\;\;\;\frac{a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c}\\
\end{array}
\end{array}
if d < -1.02e68 or 2.2000000000000002e69 < d Initial program 47.5%
Taylor expanded in b around 0 47.5%
mul-1-neg47.5%
+-commutative47.5%
*-commutative47.5%
fma-def47.5%
distribute-rgt-neg-in47.5%
Simplified47.5%
*-un-lft-identity47.5%
add-sqr-sqrt47.5%
hypot-udef47.5%
hypot-udef47.5%
times-frac67.8%
add-sqr-sqrt29.9%
sqrt-unprod15.6%
sqr-neg15.6%
sqrt-prod23.8%
add-sqr-sqrt40.9%
Applied egg-rr40.9%
Taylor expanded in c around 0 32.1%
if -1.02e68 < d < 2.2000000000000002e69Initial program 71.8%
Taylor expanded in b around 0 71.8%
mul-1-neg71.8%
+-commutative71.8%
*-commutative71.8%
fma-def71.8%
distribute-rgt-neg-in71.8%
Simplified71.8%
*-un-lft-identity71.8%
add-sqr-sqrt71.8%
hypot-udef71.8%
hypot-udef71.8%
times-frac80.1%
add-sqr-sqrt37.0%
sqrt-unprod53.7%
sqr-neg53.7%
sqrt-prod20.8%
add-sqr-sqrt46.5%
Applied egg-rr46.5%
Taylor expanded in c around -inf 47.3%
neg-mul-147.3%
+-commutative47.3%
unsub-neg47.3%
mul-1-neg47.3%
associate-/l*47.2%
distribute-neg-frac47.2%
Simplified47.2%
Taylor expanded in d around -inf 10.8%
Final simplification18.1%
(FPCore (a b c d) :precision binary64 (if (or (<= d -8.2e+152) (not (<= d 3.5e+77))) (/ a d) (/ b c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -8.2e+152) || !(d <= 3.5e+77)) {
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 ((d <= (-8.2d+152)) .or. (.not. (d <= 3.5d+77))) 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 ((d <= -8.2e+152) || !(d <= 3.5e+77)) {
tmp = a / d;
} else {
tmp = b / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -8.2e+152) or not (d <= 3.5e+77): tmp = a / d else: tmp = b / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -8.2e+152) || !(d <= 3.5e+77)) tmp = Float64(a / d); else tmp = Float64(b / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -8.2e+152) || ~((d <= 3.5e+77))) tmp = a / d; else tmp = b / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -8.2e+152], N[Not[LessEqual[d, 3.5e+77]], $MachinePrecision]], N[(a / d), $MachinePrecision], N[(b / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -8.2 \cdot 10^{+152} \lor \neg \left(d \leq 3.5 \cdot 10^{+77}\right):\\
\;\;\;\;\frac{a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if d < -8.1999999999999996e152 or 3.5000000000000001e77 < d Initial program 44.5%
Taylor expanded in b around 0 44.5%
mul-1-neg44.5%
+-commutative44.5%
*-commutative44.5%
fma-def44.5%
distribute-rgt-neg-in44.5%
Simplified44.5%
*-un-lft-identity44.5%
add-sqr-sqrt44.5%
hypot-udef44.5%
hypot-udef44.5%
times-frac67.9%
add-sqr-sqrt25.3%
sqrt-unprod8.8%
sqr-neg8.8%
sqrt-prod27.6%
add-sqr-sqrt43.1%
Applied egg-rr43.1%
Taylor expanded in c around 0 35.3%
if -8.1999999999999996e152 < d < 3.5000000000000001e77Initial program 71.5%
Taylor expanded in c around inf 55.7%
Final simplification49.6%
(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.5%
Taylor expanded in b around 0 63.5%
mul-1-neg63.5%
+-commutative63.5%
*-commutative63.5%
fma-def63.5%
distribute-rgt-neg-in63.5%
Simplified63.5%
*-un-lft-identity63.5%
add-sqr-sqrt63.5%
hypot-udef63.5%
hypot-udef63.5%
times-frac75.9%
add-sqr-sqrt34.6%
sqrt-unprod40.6%
sqr-neg40.6%
sqrt-prod21.8%
add-sqr-sqrt44.6%
Applied egg-rr44.6%
Taylor expanded in c around -inf 35.7%
neg-mul-135.7%
+-commutative35.7%
unsub-neg35.7%
mul-1-neg35.7%
associate-/l*36.4%
distribute-neg-frac36.4%
Simplified36.4%
Taylor expanded in d around -inf 10.6%
Final simplification10.6%
(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 2023332
(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))))