
(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
(let* ((t_0 (/ c (hypot c d))) (t_1 (/ b (hypot c d))))
(if (<= d 100.0)
(fma t_0 t_1 (/ (- a) (* (hypot c d) (/ (hypot c d) d))))
(fma
t_0
t_1
(/ (* (sqrt d) (- (/ a (hypot c d)))) (/ (hypot c d) (sqrt d)))))))
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 tmp;
if (d <= 100.0) {
tmp = fma(t_0, t_1, (-a / (hypot(c, d) * (hypot(c, d) / d))));
} else {
tmp = fma(t_0, t_1, ((sqrt(d) * -(a / hypot(c, d))) / (hypot(c, d) / sqrt(d))));
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(c / hypot(c, d)) t_1 = Float64(b / hypot(c, d)) tmp = 0.0 if (d <= 100.0) tmp = fma(t_0, t_1, Float64(Float64(-a) / Float64(hypot(c, d) * Float64(hypot(c, d) / d)))); else tmp = fma(t_0, t_1, Float64(Float64(sqrt(d) * Float64(-Float64(a / hypot(c, d)))) / Float64(hypot(c, d) / sqrt(d)))); 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]}, If[LessEqual[d, 100.0], N[(t$95$0 * t$95$1 + N[((-a) / N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] * N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * t$95$1 + N[(N[(N[Sqrt[d], $MachinePrecision] * (-N[(a / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision])), $MachinePrecision] / N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / N[Sqrt[d], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\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)}\\
\mathbf{if}\;d \leq 100:\\
\;\;\;\;\mathsf{fma}\left(t_0, t_1, \frac{-a}{\mathsf{hypot}\left(c, d\right) \cdot \frac{\mathsf{hypot}\left(c, d\right)}{d}}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t_0, t_1, \frac{\sqrt{d} \cdot \left(-\frac{a}{\mathsf{hypot}\left(c, d\right)}\right)}{\frac{\mathsf{hypot}\left(c, d\right)}{\sqrt{d}}}\right)\\
\end{array}
\end{array}
if d < 100Initial program 68.3%
div-sub62.4%
*-commutative62.4%
add-sqr-sqrt62.4%
times-frac65.1%
fma-neg65.1%
hypot-def65.1%
hypot-def80.4%
associate-/l*86.4%
add-sqr-sqrt86.4%
pow286.4%
hypot-def86.4%
Applied egg-rr86.4%
unpow286.4%
*-un-lft-identity86.4%
times-frac97.3%
Applied egg-rr97.3%
if 100 < d Initial program 44.7%
div-sub44.7%
*-commutative44.7%
add-sqr-sqrt44.7%
times-frac47.9%
fma-neg47.9%
hypot-def47.9%
hypot-def61.7%
associate-/l*69.5%
add-sqr-sqrt69.5%
pow269.5%
hypot-def69.5%
Applied egg-rr69.5%
*-un-lft-identity69.5%
add-sqr-sqrt69.3%
times-frac69.3%
hypot-udef69.3%
sqrt-pow269.3%
metadata-eval69.3%
pow169.3%
sqrt-div69.4%
hypot-udef69.4%
hypot-udef69.4%
sqrt-pow269.4%
metadata-eval69.4%
pow169.4%
sqrt-div69.3%
Applied egg-rr99.2%
associate-*l/99.3%
*-lft-identity99.3%
associate-/r/99.4%
Simplified99.4%
Final simplification97.8%
(FPCore (a b c d) :precision binary64 (fma (/ c (hypot c d)) (/ b (hypot c d)) (/ (- a) (* (hypot c d) (/ (hypot c d) d)))))
double code(double a, double b, double c, double d) {
return fma((c / hypot(c, d)), (b / hypot(c, d)), (-a / (hypot(c, d) * (hypot(c, d) / d))));
}
function code(a, b, c, d) return fma(Float64(c / hypot(c, d)), Float64(b / hypot(c, d)), Float64(Float64(-a) / Float64(hypot(c, d) * Float64(hypot(c, d) / d)))) end
code[a_, b_, c_, d_] := N[(N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] + N[((-a) / N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] * N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, \frac{-a}{\mathsf{hypot}\left(c, d\right) \cdot \frac{\mathsf{hypot}\left(c, d\right)}{d}}\right)
\end{array}
Initial program 62.0%
div-sub57.6%
*-commutative57.6%
add-sqr-sqrt57.6%
times-frac60.5%
fma-neg60.5%
hypot-def60.5%
hypot-def75.4%
associate-/l*81.8%
add-sqr-sqrt81.8%
pow281.8%
hypot-def81.8%
Applied egg-rr81.8%
unpow281.8%
*-un-lft-identity81.8%
times-frac96.1%
Applied egg-rr96.1%
Final simplification96.1%
(FPCore (a b c d) :precision binary64 (fma (/ c (hypot c d)) (/ b (hypot c d)) (* a (/ -1.0 (+ d (/ c (/ d c)))))))
double code(double a, double b, double c, double d) {
return fma((c / hypot(c, d)), (b / hypot(c, d)), (a * (-1.0 / (d + (c / (d / c))))));
}
function code(a, b, c, d) return fma(Float64(c / hypot(c, d)), Float64(b / hypot(c, d)), Float64(a * Float64(-1.0 / Float64(d + Float64(c / Float64(d / c)))))) end
code[a_, b_, c_, d_] := N[(N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] + N[(a * N[(-1.0 / N[(d + N[(c / N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, a \cdot \frac{-1}{d + \frac{c}{\frac{d}{c}}}\right)
\end{array}
Initial program 62.0%
div-sub57.6%
*-commutative57.6%
add-sqr-sqrt57.6%
times-frac60.5%
fma-neg60.5%
hypot-def60.5%
hypot-def75.4%
associate-/l*81.8%
add-sqr-sqrt81.8%
pow281.8%
hypot-def81.8%
Applied egg-rr81.8%
unpow281.8%
*-un-lft-identity81.8%
times-frac96.1%
Applied egg-rr96.1%
div-inv96.1%
frac-times81.8%
hypot-udef81.8%
hypot-udef81.8%
add-sqr-sqrt81.8%
*-un-lft-identity81.8%
Applied egg-rr81.8%
Taylor expanded in c around 0 92.8%
unpow292.8%
associate-/l*96.1%
Simplified96.1%
Final simplification96.1%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (- (* c b) (* d a))))
(if (<= (/ t_0 (+ (* c c) (* d d))) 2e+250)
(* (/ 1.0 (hypot c d)) (/ t_0 (hypot c d)))
(- (* (/ c d) (/ b 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))) <= 2e+250) {
tmp = (1.0 / hypot(c, d)) * (t_0 / hypot(c, d));
} else {
tmp = ((c / d) * (b / d)) - (a / d);
}
return tmp;
}
public static 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))) <= 2e+250) {
tmp = (1.0 / Math.hypot(c, d)) * (t_0 / Math.hypot(c, d));
} else {
tmp = ((c / d) * (b / d)) - (a / d);
}
return tmp;
}
def code(a, b, c, d): t_0 = (c * b) - (d * a) tmp = 0 if (t_0 / ((c * c) + (d * d))) <= 2e+250: tmp = (1.0 / math.hypot(c, d)) * (t_0 / math.hypot(c, d)) else: tmp = ((c / d) * (b / 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))) <= 2e+250) tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(t_0 / hypot(c, d))); else tmp = Float64(Float64(Float64(c / d) * Float64(b / d)) - Float64(a / d)); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (c * b) - (d * a); tmp = 0.0; if ((t_0 / ((c * c) + (d * d))) <= 2e+250) tmp = (1.0 / hypot(c, d)) * (t_0 / hypot(c, d)); else tmp = ((c / d) * (b / d)) - (a / d); end tmp_2 = 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], 2e+250], 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[(N[(c / d), $MachinePrecision] * N[(b / d), $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 2 \cdot 10^{+250}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{t_0}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{d} \cdot \frac{b}{d} - \frac{a}{d}\\
\end{array}
\end{array}
if (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 1.9999999999999998e250Initial program 79.8%
*-un-lft-identity79.8%
add-sqr-sqrt79.8%
times-frac79.8%
hypot-def79.8%
hypot-def95.2%
Applied egg-rr95.2%
if 1.9999999999999998e250 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 17.3%
div-sub8.9%
*-commutative8.9%
add-sqr-sqrt8.9%
times-frac12.4%
fma-neg12.4%
hypot-def12.4%
hypot-def40.3%
associate-/l*57.6%
add-sqr-sqrt57.6%
pow257.6%
hypot-def57.6%
Applied egg-rr57.6%
Taylor expanded in c around 0 46.4%
+-commutative46.4%
mul-1-neg46.4%
unsub-neg46.4%
*-commutative46.4%
unpow246.4%
times-frac60.2%
Simplified60.2%
Final simplification85.2%
(FPCore (a b c d)
:precision binary64
(if (<= c -80000000000000.0)
(- (/ b c) (/ (* a (/ d c)) c))
(if (<= c 2e-278)
(- (* (/ c d) (/ b d)) (/ a d))
(if (<= c 7.2e+95)
(* (pow (hypot c d) -2.0) (- (* c b) (* d a)))
(- (/ b c) (* (/ d c) (/ a c)))))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -80000000000000.0) {
tmp = (b / c) - ((a * (d / c)) / c);
} else if (c <= 2e-278) {
tmp = ((c / d) * (b / d)) - (a / d);
} else if (c <= 7.2e+95) {
tmp = pow(hypot(c, d), -2.0) * ((c * b) - (d * a));
} else {
tmp = (b / c) - ((d / c) * (a / c));
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -80000000000000.0) {
tmp = (b / c) - ((a * (d / c)) / c);
} else if (c <= 2e-278) {
tmp = ((c / d) * (b / d)) - (a / d);
} else if (c <= 7.2e+95) {
tmp = Math.pow(Math.hypot(c, d), -2.0) * ((c * b) - (d * a));
} else {
tmp = (b / c) - ((d / c) * (a / c));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -80000000000000.0: tmp = (b / c) - ((a * (d / c)) / c) elif c <= 2e-278: tmp = ((c / d) * (b / d)) - (a / d) elif c <= 7.2e+95: tmp = math.pow(math.hypot(c, d), -2.0) * ((c * b) - (d * a)) else: tmp = (b / c) - ((d / c) * (a / c)) return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -80000000000000.0) tmp = Float64(Float64(b / c) - Float64(Float64(a * Float64(d / c)) / c)); elseif (c <= 2e-278) tmp = Float64(Float64(Float64(c / d) * Float64(b / d)) - Float64(a / d)); elseif (c <= 7.2e+95) tmp = Float64((hypot(c, d) ^ -2.0) * Float64(Float64(c * b) - Float64(d * a))); else tmp = Float64(Float64(b / c) - Float64(Float64(d / c) * Float64(a / c))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -80000000000000.0) tmp = (b / c) - ((a * (d / c)) / c); elseif (c <= 2e-278) tmp = ((c / d) * (b / d)) - (a / d); elseif (c <= 7.2e+95) tmp = (hypot(c, d) ^ -2.0) * ((c * b) - (d * a)); else tmp = (b / c) - ((d / c) * (a / c)); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -80000000000000.0], N[(N[(b / c), $MachinePrecision] - N[(N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 2e-278], N[(N[(N[(c / d), $MachinePrecision] * N[(b / d), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 7.2e+95], N[(N[Power[N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision], -2.0], $MachinePrecision] * N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b / c), $MachinePrecision] - N[(N[(d / c), $MachinePrecision] * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -80000000000000:\\
\;\;\;\;\frac{b}{c} - \frac{a \cdot \frac{d}{c}}{c}\\
\mathbf{elif}\;c \leq 2 \cdot 10^{-278}:\\
\;\;\;\;\frac{c}{d} \cdot \frac{b}{d} - \frac{a}{d}\\
\mathbf{elif}\;c \leq 7.2 \cdot 10^{+95}:\\
\;\;\;\;{\left(\mathsf{hypot}\left(c, d\right)\right)}^{-2} \cdot \left(c \cdot b - d \cdot a\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c} - \frac{d}{c} \cdot \frac{a}{c}\\
\end{array}
\end{array}
if c < -8e13Initial program 50.6%
Taylor expanded in c around inf 71.1%
+-commutative71.1%
mul-1-neg71.1%
unsub-neg71.1%
*-commutative71.1%
unpow271.1%
times-frac80.3%
Simplified80.3%
associate-*r/80.3%
Applied egg-rr80.3%
if -8e13 < c < 1.99999999999999988e-278Initial program 71.9%
div-sub67.6%
*-commutative67.6%
add-sqr-sqrt67.6%
times-frac67.3%
fma-neg67.3%
hypot-def67.3%
hypot-def68.8%
associate-/l*77.2%
add-sqr-sqrt77.2%
pow277.2%
hypot-def77.2%
Applied egg-rr77.2%
Taylor expanded in c around 0 85.3%
+-commutative85.3%
mul-1-neg85.3%
unsub-neg85.3%
*-commutative85.3%
unpow285.3%
times-frac87.3%
Simplified87.3%
if 1.99999999999999988e-278 < c < 7.19999999999999955e95Initial program 81.7%
div-sub70.4%
*-commutative70.4%
add-sqr-sqrt70.4%
times-frac70.6%
fma-neg70.6%
hypot-def70.6%
hypot-def74.8%
associate-/l*79.4%
add-sqr-sqrt79.4%
pow279.4%
hypot-def79.4%
Applied egg-rr79.4%
fma-udef79.4%
frac-times74.9%
hypot-udef74.9%
hypot-udef74.9%
add-sqr-sqrt75.0%
unsub-neg75.0%
Applied egg-rr73.6%
cancel-sign-sub-inv73.6%
associate-*r*76.1%
associate-*r*71.6%
distribute-rgt-in82.9%
+-commutative82.9%
+-commutative82.9%
cancel-sign-sub-inv82.9%
*-commutative82.9%
Simplified82.9%
if 7.19999999999999955e95 < c Initial program 31.5%
Taylor expanded in c around inf 76.6%
+-commutative76.6%
mul-1-neg76.6%
unsub-neg76.6%
*-commutative76.6%
unpow276.6%
times-frac89.4%
Simplified89.4%
Final simplification84.6%
(FPCore (a b c d)
:precision binary64
(if (<= c -820000000000.0)
(- (/ b c) (/ (* a (/ d c)) c))
(if (<= c 2.1e-278)
(- (* (/ c d) (/ b d)) (/ a d))
(if (<= c 6.5e+94)
(/ (- (* c b) (* d a)) (+ (* c c) (* d d)))
(- (/ b c) (* (/ d c) (/ a c)))))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -820000000000.0) {
tmp = (b / c) - ((a * (d / c)) / c);
} else if (c <= 2.1e-278) {
tmp = ((c / d) * (b / d)) - (a / d);
} else if (c <= 6.5e+94) {
tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
} else {
tmp = (b / c) - ((d / c) * (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 <= (-820000000000.0d0)) then
tmp = (b / c) - ((a * (d / c)) / c)
else if (c <= 2.1d-278) then
tmp = ((c / d) * (b / d)) - (a / d)
else if (c <= 6.5d+94) then
tmp = ((c * b) - (d * a)) / ((c * c) + (d * d))
else
tmp = (b / c) - ((d / c) * (a / c))
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -820000000000.0) {
tmp = (b / c) - ((a * (d / c)) / c);
} else if (c <= 2.1e-278) {
tmp = ((c / d) * (b / d)) - (a / d);
} else if (c <= 6.5e+94) {
tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
} else {
tmp = (b / c) - ((d / c) * (a / c));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -820000000000.0: tmp = (b / c) - ((a * (d / c)) / c) elif c <= 2.1e-278: tmp = ((c / d) * (b / d)) - (a / d) elif c <= 6.5e+94: tmp = ((c * b) - (d * a)) / ((c * c) + (d * d)) else: tmp = (b / c) - ((d / c) * (a / c)) return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -820000000000.0) tmp = Float64(Float64(b / c) - Float64(Float64(a * Float64(d / c)) / c)); elseif (c <= 2.1e-278) tmp = Float64(Float64(Float64(c / d) * Float64(b / d)) - Float64(a / d)); elseif (c <= 6.5e+94) tmp = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d))); else tmp = Float64(Float64(b / c) - Float64(Float64(d / c) * Float64(a / c))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -820000000000.0) tmp = (b / c) - ((a * (d / c)) / c); elseif (c <= 2.1e-278) tmp = ((c / d) * (b / d)) - (a / d); elseif (c <= 6.5e+94) tmp = ((c * b) - (d * a)) / ((c * c) + (d * d)); else tmp = (b / c) - ((d / c) * (a / c)); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -820000000000.0], N[(N[(b / c), $MachinePrecision] - N[(N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 2.1e-278], N[(N[(N[(c / d), $MachinePrecision] * N[(b / d), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 6.5e+94], N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b / c), $MachinePrecision] - N[(N[(d / c), $MachinePrecision] * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -820000000000:\\
\;\;\;\;\frac{b}{c} - \frac{a \cdot \frac{d}{c}}{c}\\
\mathbf{elif}\;c \leq 2.1 \cdot 10^{-278}:\\
\;\;\;\;\frac{c}{d} \cdot \frac{b}{d} - \frac{a}{d}\\
\mathbf{elif}\;c \leq 6.5 \cdot 10^{+94}:\\
\;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c} - \frac{d}{c} \cdot \frac{a}{c}\\
\end{array}
\end{array}
if c < -8.2e11Initial program 50.6%
Taylor expanded in c around inf 71.1%
+-commutative71.1%
mul-1-neg71.1%
unsub-neg71.1%
*-commutative71.1%
unpow271.1%
times-frac80.3%
Simplified80.3%
associate-*r/80.3%
Applied egg-rr80.3%
if -8.2e11 < c < 2.10000000000000014e-278Initial program 71.9%
div-sub67.6%
*-commutative67.6%
add-sqr-sqrt67.6%
times-frac67.3%
fma-neg67.3%
hypot-def67.3%
hypot-def68.8%
associate-/l*77.2%
add-sqr-sqrt77.2%
pow277.2%
hypot-def77.2%
Applied egg-rr77.2%
Taylor expanded in c around 0 85.3%
+-commutative85.3%
mul-1-neg85.3%
unsub-neg85.3%
*-commutative85.3%
unpow285.3%
times-frac87.3%
Simplified87.3%
if 2.10000000000000014e-278 < c < 6.49999999999999976e94Initial program 81.7%
if 6.49999999999999976e94 < c Initial program 31.5%
Taylor expanded in c around inf 76.6%
+-commutative76.6%
mul-1-neg76.6%
unsub-neg76.6%
*-commutative76.6%
unpow276.6%
times-frac89.4%
Simplified89.4%
Final simplification84.3%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (- (* c (/ b (* d d))) (/ a d))) (t_1 (/ b (+ c (/ (* d d) c)))))
(if (<= c -2.7e-9)
t_1
(if (<= c -8.7e-221)
t_0
(if (<= c 1.16e-206) (- (/ a d)) (if (<= c 7.2e+49) t_0 t_1))))))
double code(double a, double b, double c, double d) {
double t_0 = (c * (b / (d * d))) - (a / d);
double t_1 = b / (c + ((d * d) / c));
double tmp;
if (c <= -2.7e-9) {
tmp = t_1;
} else if (c <= -8.7e-221) {
tmp = t_0;
} else if (c <= 1.16e-206) {
tmp = -(a / d);
} else if (c <= 7.2e+49) {
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 / (d * d))) - (a / d)
t_1 = b / (c + ((d * d) / c))
if (c <= (-2.7d-9)) then
tmp = t_1
else if (c <= (-8.7d-221)) then
tmp = t_0
else if (c <= 1.16d-206) then
tmp = -(a / d)
else if (c <= 7.2d+49) 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 / (d * d))) - (a / d);
double t_1 = b / (c + ((d * d) / c));
double tmp;
if (c <= -2.7e-9) {
tmp = t_1;
} else if (c <= -8.7e-221) {
tmp = t_0;
} else if (c <= 1.16e-206) {
tmp = -(a / d);
} else if (c <= 7.2e+49) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(a, b, c, d): t_0 = (c * (b / (d * d))) - (a / d) t_1 = b / (c + ((d * d) / c)) tmp = 0 if c <= -2.7e-9: tmp = t_1 elif c <= -8.7e-221: tmp = t_0 elif c <= 1.16e-206: tmp = -(a / d) elif c <= 7.2e+49: tmp = t_0 else: tmp = t_1 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(c * Float64(b / Float64(d * d))) - Float64(a / d)) t_1 = Float64(b / Float64(c + Float64(Float64(d * d) / c))) tmp = 0.0 if (c <= -2.7e-9) tmp = t_1; elseif (c <= -8.7e-221) tmp = t_0; elseif (c <= 1.16e-206) tmp = Float64(-Float64(a / d)); elseif (c <= 7.2e+49) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (c * (b / (d * d))) - (a / d); t_1 = b / (c + ((d * d) / c)); tmp = 0.0; if (c <= -2.7e-9) tmp = t_1; elseif (c <= -8.7e-221) tmp = t_0; elseif (c <= 1.16e-206) tmp = -(a / d); elseif (c <= 7.2e+49) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c * N[(b / N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(b / N[(c + N[(N[(d * d), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -2.7e-9], t$95$1, If[LessEqual[c, -8.7e-221], t$95$0, If[LessEqual[c, 1.16e-206], (-N[(a / d), $MachinePrecision]), If[LessEqual[c, 7.2e+49], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := c \cdot \frac{b}{d \cdot d} - \frac{a}{d}\\
t_1 := \frac{b}{c + \frac{d \cdot d}{c}}\\
\mathbf{if}\;c \leq -2.7 \cdot 10^{-9}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;c \leq -8.7 \cdot 10^{-221}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 1.16 \cdot 10^{-206}:\\
\;\;\;\;-\frac{a}{d}\\
\mathbf{elif}\;c \leq 7.2 \cdot 10^{+49}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if c < -2.7000000000000002e-9 or 7.19999999999999993e49 < c Initial program 48.8%
Taylor expanded in b around inf 44.5%
associate-/l*50.7%
unpow250.7%
unpow250.7%
+-commutative50.7%
fma-udef50.6%
Simplified50.6%
Taylor expanded in d around 0 72.2%
unpow272.2%
Simplified72.2%
if -2.7000000000000002e-9 < c < -8.7000000000000003e-221 or 1.16000000000000004e-206 < c < 7.19999999999999993e49Initial program 77.2%
Taylor expanded in c around 0 77.9%
+-commutative77.9%
mul-1-neg77.9%
unsub-neg77.9%
unpow277.9%
associate-/l*75.8%
associate-/r/78.0%
Simplified78.0%
if -8.7000000000000003e-221 < c < 1.16000000000000004e-206Initial program 70.9%
Taylor expanded in c around 0 83.8%
associate-*r/83.8%
neg-mul-183.8%
Simplified83.8%
Final simplification76.2%
(FPCore (a b c d) :precision binary64 (if (or (<= c -5.8e-9) (not (<= c 2.55e+51))) (/ b (+ c (/ (* d d) c))) (- (* (/ c d) (/ b d)) (/ a d))))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -5.8e-9) || !(c <= 2.55e+51)) {
tmp = b / (c + ((d * d) / c));
} else {
tmp = ((c / d) * (b / d)) - (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 <= (-5.8d-9)) .or. (.not. (c <= 2.55d+51))) then
tmp = b / (c + ((d * d) / c))
else
tmp = ((c / d) * (b / d)) - (a / d)
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -5.8e-9) || !(c <= 2.55e+51)) {
tmp = b / (c + ((d * d) / c));
} else {
tmp = ((c / d) * (b / d)) - (a / d);
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -5.8e-9) or not (c <= 2.55e+51): tmp = b / (c + ((d * d) / c)) else: tmp = ((c / d) * (b / d)) - (a / d) return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -5.8e-9) || !(c <= 2.55e+51)) tmp = Float64(b / Float64(c + Float64(Float64(d * d) / c))); else tmp = Float64(Float64(Float64(c / d) * Float64(b / d)) - Float64(a / d)); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((c <= -5.8e-9) || ~((c <= 2.55e+51))) tmp = b / (c + ((d * d) / c)); else tmp = ((c / d) * (b / d)) - (a / d); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -5.8e-9], N[Not[LessEqual[c, 2.55e+51]], $MachinePrecision]], N[(b / N[(c + N[(N[(d * d), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(c / d), $MachinePrecision] * N[(b / d), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -5.8 \cdot 10^{-9} \lor \neg \left(c \leq 2.55 \cdot 10^{+51}\right):\\
\;\;\;\;\frac{b}{c + \frac{d \cdot d}{c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{d} \cdot \frac{b}{d} - \frac{a}{d}\\
\end{array}
\end{array}
if c < -5.79999999999999982e-9 or 2.55000000000000005e51 < c Initial program 48.8%
Taylor expanded in b around inf 44.5%
associate-/l*50.7%
unpow250.7%
unpow250.7%
+-commutative50.7%
fma-udef50.6%
Simplified50.6%
Taylor expanded in d around 0 72.2%
unpow272.2%
Simplified72.2%
if -5.79999999999999982e-9 < c < 2.55000000000000005e51Initial program 74.9%
div-sub66.3%
*-commutative66.3%
add-sqr-sqrt66.3%
times-frac66.1%
fma-neg66.1%
hypot-def66.1%
hypot-def69.3%
associate-/l*76.5%
add-sqr-sqrt76.5%
pow276.5%
hypot-def76.5%
Applied egg-rr76.5%
Taylor expanded in c around 0 77.7%
+-commutative77.7%
mul-1-neg77.7%
unsub-neg77.7%
*-commutative77.7%
unpow277.7%
times-frac81.3%
Simplified81.3%
Final simplification76.8%
(FPCore (a b c d) :precision binary64 (if (or (<= c -1450000000000.0) (not (<= c 2.3e+48))) (- (/ b c) (* (/ d c) (/ a c))) (- (* (/ c d) (/ b d)) (/ a d))))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -1450000000000.0) || !(c <= 2.3e+48)) {
tmp = (b / c) - ((d / c) * (a / c));
} else {
tmp = ((c / d) * (b / d)) - (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 <= (-1450000000000.0d0)) .or. (.not. (c <= 2.3d+48))) then
tmp = (b / c) - ((d / c) * (a / c))
else
tmp = ((c / d) * (b / d)) - (a / d)
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -1450000000000.0) || !(c <= 2.3e+48)) {
tmp = (b / c) - ((d / c) * (a / c));
} else {
tmp = ((c / d) * (b / d)) - (a / d);
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -1450000000000.0) or not (c <= 2.3e+48): tmp = (b / c) - ((d / c) * (a / c)) else: tmp = ((c / d) * (b / d)) - (a / d) return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -1450000000000.0) || !(c <= 2.3e+48)) tmp = Float64(Float64(b / c) - Float64(Float64(d / c) * Float64(a / c))); else tmp = Float64(Float64(Float64(c / d) * Float64(b / d)) - Float64(a / d)); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((c <= -1450000000000.0) || ~((c <= 2.3e+48))) tmp = (b / c) - ((d / c) * (a / c)); else tmp = ((c / d) * (b / d)) - (a / d); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -1450000000000.0], N[Not[LessEqual[c, 2.3e+48]], $MachinePrecision]], N[(N[(b / c), $MachinePrecision] - N[(N[(d / c), $MachinePrecision] * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(c / d), $MachinePrecision] * N[(b / d), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -1450000000000 \lor \neg \left(c \leq 2.3 \cdot 10^{+48}\right):\\
\;\;\;\;\frac{b}{c} - \frac{d}{c} \cdot \frac{a}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{d} \cdot \frac{b}{d} - \frac{a}{d}\\
\end{array}
\end{array}
if c < -1.45e12 or 2.3e48 < c Initial program 48.0%
Taylor expanded in c around inf 71.8%
+-commutative71.8%
mul-1-neg71.8%
unsub-neg71.8%
*-commutative71.8%
unpow271.8%
times-frac81.5%
Simplified81.5%
if -1.45e12 < c < 2.3e48Initial program 74.9%
div-sub66.5%
*-commutative66.5%
add-sqr-sqrt66.5%
times-frac66.4%
fma-neg66.4%
hypot-def66.4%
hypot-def69.4%
associate-/l*76.5%
add-sqr-sqrt76.5%
pow276.5%
hypot-def76.5%
Applied egg-rr76.5%
Taylor expanded in c around 0 76.9%
+-commutative76.9%
mul-1-neg76.9%
unsub-neg76.9%
*-commutative76.9%
unpow276.9%
times-frac80.4%
Simplified80.4%
Final simplification80.9%
(FPCore (a b c d)
:precision binary64
(if (<= c -44000000000000.0)
(- (/ b c) (/ (* a (/ d c)) c))
(if (<= c 1.42e+47)
(- (* (/ c d) (/ b d)) (/ a d))
(- (/ b c) (* (/ d c) (/ a c))))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -44000000000000.0) {
tmp = (b / c) - ((a * (d / c)) / c);
} else if (c <= 1.42e+47) {
tmp = ((c / d) * (b / d)) - (a / d);
} else {
tmp = (b / c) - ((d / c) * (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 <= (-44000000000000.0d0)) then
tmp = (b / c) - ((a * (d / c)) / c)
else if (c <= 1.42d+47) then
tmp = ((c / d) * (b / d)) - (a / d)
else
tmp = (b / c) - ((d / c) * (a / c))
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -44000000000000.0) {
tmp = (b / c) - ((a * (d / c)) / c);
} else if (c <= 1.42e+47) {
tmp = ((c / d) * (b / d)) - (a / d);
} else {
tmp = (b / c) - ((d / c) * (a / c));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -44000000000000.0: tmp = (b / c) - ((a * (d / c)) / c) elif c <= 1.42e+47: tmp = ((c / d) * (b / d)) - (a / d) else: tmp = (b / c) - ((d / c) * (a / c)) return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -44000000000000.0) tmp = Float64(Float64(b / c) - Float64(Float64(a * Float64(d / c)) / c)); elseif (c <= 1.42e+47) tmp = Float64(Float64(Float64(c / d) * Float64(b / d)) - Float64(a / d)); else tmp = Float64(Float64(b / c) - Float64(Float64(d / c) * Float64(a / c))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -44000000000000.0) tmp = (b / c) - ((a * (d / c)) / c); elseif (c <= 1.42e+47) tmp = ((c / d) * (b / d)) - (a / d); else tmp = (b / c) - ((d / c) * (a / c)); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -44000000000000.0], N[(N[(b / c), $MachinePrecision] - N[(N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.42e+47], N[(N[(N[(c / d), $MachinePrecision] * N[(b / d), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], N[(N[(b / c), $MachinePrecision] - N[(N[(d / c), $MachinePrecision] * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -44000000000000:\\
\;\;\;\;\frac{b}{c} - \frac{a \cdot \frac{d}{c}}{c}\\
\mathbf{elif}\;c \leq 1.42 \cdot 10^{+47}:\\
\;\;\;\;\frac{c}{d} \cdot \frac{b}{d} - \frac{a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c} - \frac{d}{c} \cdot \frac{a}{c}\\
\end{array}
\end{array}
if c < -4.4e13Initial program 50.6%
Taylor expanded in c around inf 71.1%
+-commutative71.1%
mul-1-neg71.1%
unsub-neg71.1%
*-commutative71.1%
unpow271.1%
times-frac80.3%
Simplified80.3%
associate-*r/80.3%
Applied egg-rr80.3%
if -4.4e13 < c < 1.42e47Initial program 74.9%
div-sub66.5%
*-commutative66.5%
add-sqr-sqrt66.5%
times-frac66.4%
fma-neg66.4%
hypot-def66.4%
hypot-def69.4%
associate-/l*76.5%
add-sqr-sqrt76.5%
pow276.5%
hypot-def76.5%
Applied egg-rr76.5%
Taylor expanded in c around 0 76.9%
+-commutative76.9%
mul-1-neg76.9%
unsub-neg76.9%
*-commutative76.9%
unpow276.9%
times-frac80.4%
Simplified80.4%
if 1.42e47 < c Initial program 44.8%
Taylor expanded in c around inf 72.7%
+-commutative72.7%
mul-1-neg72.7%
unsub-neg72.7%
*-commutative72.7%
unpow272.7%
times-frac83.0%
Simplified83.0%
Final simplification80.9%
(FPCore (a b c d) :precision binary64 (if (or (<= c -6.2e-37) (not (<= c 4.8e-73))) (/ b (+ c (/ (* d d) c))) (- (/ a d))))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -6.2e-37) || !(c <= 4.8e-73)) {
tmp = b / (c + ((d * d) / 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 <= (-6.2d-37)) .or. (.not. (c <= 4.8d-73))) then
tmp = b / (c + ((d * d) / 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 <= -6.2e-37) || !(c <= 4.8e-73)) {
tmp = b / (c + ((d * d) / c));
} else {
tmp = -(a / d);
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -6.2e-37) or not (c <= 4.8e-73): tmp = b / (c + ((d * d) / c)) else: tmp = -(a / d) return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -6.2e-37) || !(c <= 4.8e-73)) tmp = Float64(b / Float64(c + Float64(Float64(d * d) / c))); else tmp = Float64(-Float64(a / d)); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((c <= -6.2e-37) || ~((c <= 4.8e-73))) tmp = b / (c + ((d * d) / c)); else tmp = -(a / d); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -6.2e-37], N[Not[LessEqual[c, 4.8e-73]], $MachinePrecision]], N[(b / N[(c + N[(N[(d * d), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-N[(a / d), $MachinePrecision])]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -6.2 \cdot 10^{-37} \lor \neg \left(c \leq 4.8 \cdot 10^{-73}\right):\\
\;\;\;\;\frac{b}{c + \frac{d \cdot d}{c}}\\
\mathbf{else}:\\
\;\;\;\;-\frac{a}{d}\\
\end{array}
\end{array}
if c < -6.19999999999999987e-37 or 4.80000000000000011e-73 < c Initial program 53.1%
Taylor expanded in b around inf 46.4%
associate-/l*51.7%
unpow251.7%
unpow251.7%
+-commutative51.7%
fma-udef51.6%
Simplified51.6%
Taylor expanded in d around 0 70.1%
unpow270.1%
Simplified70.1%
if -6.19999999999999987e-37 < c < 4.80000000000000011e-73Initial program 74.3%
Taylor expanded in c around 0 69.3%
associate-*r/69.3%
neg-mul-169.3%
Simplified69.3%
Final simplification69.7%
(FPCore (a b c d) :precision binary64 (if (or (<= c -2.8e-9) (not (<= c 1.75e+52))) (/ b c) (- (/ a d))))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -2.8e-9) || !(c <= 1.75e+52)) {
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 <= (-2.8d-9)) .or. (.not. (c <= 1.75d+52))) 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 <= -2.8e-9) || !(c <= 1.75e+52)) {
tmp = b / c;
} else {
tmp = -(a / d);
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -2.8e-9) or not (c <= 1.75e+52): tmp = b / c else: tmp = -(a / d) return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -2.8e-9) || !(c <= 1.75e+52)) 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 <= -2.8e-9) || ~((c <= 1.75e+52))) tmp = b / c; else tmp = -(a / d); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -2.8e-9], N[Not[LessEqual[c, 1.75e+52]], $MachinePrecision]], N[(b / c), $MachinePrecision], (-N[(a / d), $MachinePrecision])]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -2.8 \cdot 10^{-9} \lor \neg \left(c \leq 1.75 \cdot 10^{+52}\right):\\
\;\;\;\;\frac{b}{c}\\
\mathbf{else}:\\
\;\;\;\;-\frac{a}{d}\\
\end{array}
\end{array}
if c < -2.79999999999999984e-9 or 1.75e52 < c Initial program 48.8%
Taylor expanded in c around inf 68.5%
if -2.79999999999999984e-9 < c < 1.75e52Initial program 74.9%
Taylor expanded in c around 0 65.7%
associate-*r/65.7%
neg-mul-165.7%
Simplified65.7%
Final simplification67.1%
(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 62.0%
Taylor expanded in c around inf 41.8%
Final simplification41.8%
(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 2023275
(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))))