
(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 11 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 (if (<= c -1.4e+235) (- (/ b c) (/ (/ a c) (/ c d))) (fma (/ c (hypot c d)) (/ b (hypot c d)) (/ (- a) (fma c (/ c d) d)))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -1.4e+235) {
tmp = (b / c) - ((a / c) / (c / d));
} else {
tmp = fma((c / hypot(c, d)), (b / hypot(c, d)), (-a / fma(c, (c / d), d)));
}
return tmp;
}
function code(a, b, c, d) tmp = 0.0 if (c <= -1.4e+235) tmp = Float64(Float64(b / c) - Float64(Float64(a / c) / Float64(c / d))); else tmp = fma(Float64(c / hypot(c, d)), Float64(b / hypot(c, d)), Float64(Float64(-a) / fma(c, Float64(c / d), d))); end return tmp end
code[a_, b_, c_, d_] := If[LessEqual[c, -1.4e+235], N[(N[(b / c), $MachinePrecision] - N[(N[(a / c), $MachinePrecision] / N[(c / d), $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) / N[(c * N[(c / d), $MachinePrecision] + d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.4 \cdot 10^{+235}:\\
\;\;\;\;\frac{b}{c} - \frac{\frac{a}{c}}{\frac{c}{d}}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, \frac{-a}{\mathsf{fma}\left(c, \frac{c}{d}, d\right)}\right)\\
\end{array}
\end{array}
if c < -1.40000000000000013e235Initial program 32.7%
Taylor expanded in c around inf 74.6%
+-commutative74.6%
mul-1-neg74.6%
unsub-neg74.6%
associate-/l*76.3%
associate-/r/76.3%
Simplified76.3%
*-un-lft-identity76.3%
pow276.3%
times-frac85.3%
Applied egg-rr85.3%
associate-*l/85.4%
*-lft-identity85.4%
Simplified85.4%
associate-*l/99.9%
Applied egg-rr99.9%
associate-/l*99.9%
Simplified99.9%
if -1.40000000000000013e235 < c Initial program 57.7%
div-sub55.0%
sub-neg55.0%
*-commutative55.0%
add-sqr-sqrt55.0%
times-frac60.3%
fma-def60.3%
hypot-def60.3%
hypot-def75.4%
associate-/l*77.7%
add-sqr-sqrt77.7%
pow277.7%
hypot-def77.7%
Applied egg-rr77.7%
Taylor expanded in c around 0 93.2%
+-commutative93.2%
unpow293.2%
associate-*r/97.1%
fma-def97.1%
Simplified97.1%
Final simplification97.4%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (- (* c b) (* a d))) (t_1 (/ t_0 (+ (* c c) (* d d)))))
(if (or (<= t_1 (- INFINITY)) (not (<= t_1 5e+237)))
(fma (/ c (hypot c d)) (/ b (hypot c d)) (/ (- a) d))
(* (/ 1.0 (hypot c d)) (/ t_0 (hypot c d))))))
double code(double a, double b, double c, double d) {
double t_0 = (c * b) - (a * d);
double t_1 = t_0 / ((c * c) + (d * d));
double tmp;
if ((t_1 <= -((double) INFINITY)) || !(t_1 <= 5e+237)) {
tmp = fma((c / hypot(c, d)), (b / hypot(c, d)), (-a / d));
} else {
tmp = (1.0 / hypot(c, d)) * (t_0 / hypot(c, d));
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(c * b) - Float64(a * d)) t_1 = Float64(t_0 / Float64(Float64(c * c) + Float64(d * d))) tmp = 0.0 if ((t_1 <= Float64(-Inf)) || !(t_1 <= 5e+237)) tmp = fma(Float64(c / hypot(c, d)), Float64(b / hypot(c, d)), Float64(Float64(-a) / d)); else tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(t_0 / hypot(c, d))); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c * b), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, (-Infinity)], N[Not[LessEqual[t$95$1, 5e+237]], $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], 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]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := c \cdot b - a \cdot d\\
t_1 := \frac{t_0}{c \cdot c + d \cdot d}\\
\mathbf{if}\;t_1 \leq -\infty \lor \neg \left(t_1 \leq 5 \cdot 10^{+237}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, \frac{-a}{d}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{t_0}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\end{array}
if (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < -inf.0 or 5.0000000000000002e237 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 19.1%
div-sub12.1%
sub-neg12.1%
*-commutative12.1%
add-sqr-sqrt12.1%
times-frac27.1%
fma-def27.1%
hypot-def27.1%
hypot-def54.4%
associate-/l*61.4%
add-sqr-sqrt61.4%
pow261.4%
hypot-def61.4%
Applied egg-rr61.4%
Taylor expanded in c around 0 70.9%
if -inf.0 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 5.0000000000000002e237Initial program 75.1%
*-un-lft-identity75.1%
add-sqr-sqrt75.1%
times-frac75.2%
hypot-def75.2%
hypot-def99.1%
Applied egg-rr99.1%
Final simplification89.3%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (- (* c b) (* a d))))
(if (<= (/ t_0 (+ (* c c) (* d d))) 4e+302)
(* (/ 1.0 (hypot c d)) (/ t_0 (hypot c d)))
(fma -1.0 (* (/ a c) (/ d c)) (/ b c)))))
double code(double a, double b, double c, double d) {
double t_0 = (c * b) - (a * d);
double tmp;
if ((t_0 / ((c * c) + (d * d))) <= 4e+302) {
tmp = (1.0 / hypot(c, d)) * (t_0 / hypot(c, d));
} else {
tmp = fma(-1.0, ((a / c) * (d / c)), (b / c));
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(c * b) - Float64(a * d)) tmp = 0.0 if (Float64(t_0 / Float64(Float64(c * c) + Float64(d * d))) <= 4e+302) tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(t_0 / hypot(c, d))); else tmp = fma(-1.0, Float64(Float64(a / c) * Float64(d / c)), Float64(b / c)); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c * b), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$0 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 4e+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[(-1.0 * N[(N[(a / c), $MachinePrecision] * N[(d / c), $MachinePrecision]), $MachinePrecision] + N[(b / c), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := c \cdot b - a \cdot d\\
\mathbf{if}\;\frac{t_0}{c \cdot c + d \cdot d} \leq 4 \cdot 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(-1, \frac{a}{c} \cdot \frac{d}{c}, \frac{b}{c}\right)\\
\end{array}
\end{array}
if (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 4.0000000000000003e302Initial program 71.5%
*-un-lft-identity71.5%
add-sqr-sqrt71.5%
times-frac71.5%
hypot-def71.5%
hypot-def94.6%
Applied egg-rr94.6%
if 4.0000000000000003e302 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 11.0%
Taylor expanded in c around inf 41.6%
fma-def41.6%
associate-/l*44.3%
Simplified44.3%
associate-/r/44.3%
associate-*l/41.6%
*-commutative41.6%
pow241.6%
times-frac54.1%
Applied egg-rr54.1%
Final simplification84.0%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* c b) (* a d)) (+ (* c c) (* d d)))))
(if (<= c -8e+81)
(- (/ b c) (/ (/ a c) (/ c d)))
(if (<= c -4.8e-156)
t_0
(if (<= c 2.2e-218)
(/ (- a) d)
(if (<= c 0.28) t_0 (* (/ c (hypot c d)) (/ b (hypot c d)))))))))
double code(double a, double b, double c, double d) {
double t_0 = ((c * b) - (a * d)) / ((c * c) + (d * d));
double tmp;
if (c <= -8e+81) {
tmp = (b / c) - ((a / c) / (c / d));
} else if (c <= -4.8e-156) {
tmp = t_0;
} else if (c <= 2.2e-218) {
tmp = -a / d;
} else if (c <= 0.28) {
tmp = t_0;
} else {
tmp = (c / hypot(c, d)) * (b / hypot(c, d));
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = ((c * b) - (a * d)) / ((c * c) + (d * d));
double tmp;
if (c <= -8e+81) {
tmp = (b / c) - ((a / c) / (c / d));
} else if (c <= -4.8e-156) {
tmp = t_0;
} else if (c <= 2.2e-218) {
tmp = -a / d;
} else if (c <= 0.28) {
tmp = t_0;
} else {
tmp = (c / Math.hypot(c, d)) * (b / Math.hypot(c, d));
}
return tmp;
}
def code(a, b, c, d): t_0 = ((c * b) - (a * d)) / ((c * c) + (d * d)) tmp = 0 if c <= -8e+81: tmp = (b / c) - ((a / c) / (c / d)) elif c <= -4.8e-156: tmp = t_0 elif c <= 2.2e-218: tmp = -a / d elif c <= 0.28: tmp = t_0 else: tmp = (c / math.hypot(c, d)) * (b / math.hypot(c, d)) return tmp
function code(a, b, c, d) t_0 = Float64(Float64(Float64(c * b) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d))) tmp = 0.0 if (c <= -8e+81) tmp = Float64(Float64(b / c) - Float64(Float64(a / c) / Float64(c / d))); elseif (c <= -4.8e-156) tmp = t_0; elseif (c <= 2.2e-218) tmp = Float64(Float64(-a) / d); elseif (c <= 0.28) tmp = t_0; else tmp = Float64(Float64(c / hypot(c, d)) * Float64(b / hypot(c, d))); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((c * b) - (a * d)) / ((c * c) + (d * d)); tmp = 0.0; if (c <= -8e+81) tmp = (b / c) - ((a / c) / (c / d)); elseif (c <= -4.8e-156) tmp = t_0; elseif (c <= 2.2e-218) tmp = -a / d; elseif (c <= 0.28) tmp = t_0; else tmp = (c / hypot(c, d)) * (b / hypot(c, d)); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(c * b), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -8e+81], N[(N[(b / c), $MachinePrecision] - N[(N[(a / c), $MachinePrecision] / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -4.8e-156], t$95$0, If[LessEqual[c, 2.2e-218], N[((-a) / d), $MachinePrecision], If[LessEqual[c, 0.28], t$95$0, N[(N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c \cdot b - a \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{if}\;c \leq -8 \cdot 10^{+81}:\\
\;\;\;\;\frac{b}{c} - \frac{\frac{a}{c}}{\frac{c}{d}}\\
\mathbf{elif}\;c \leq -4.8 \cdot 10^{-156}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 2.2 \cdot 10^{-218}:\\
\;\;\;\;\frac{-a}{d}\\
\mathbf{elif}\;c \leq 0.28:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\end{array}
if c < -7.99999999999999937e81Initial program 32.6%
Taylor expanded in c around inf 70.3%
+-commutative70.3%
mul-1-neg70.3%
unsub-neg70.3%
associate-/l*69.7%
associate-/r/71.2%
Simplified71.2%
*-un-lft-identity71.2%
pow271.2%
times-frac79.6%
Applied egg-rr79.6%
associate-*l/79.6%
*-lft-identity79.6%
Simplified79.6%
associate-*l/84.9%
Applied egg-rr84.9%
associate-/l*85.0%
Simplified85.0%
if -7.99999999999999937e81 < c < -4.8e-156 or 2.20000000000000007e-218 < c < 0.28000000000000003Initial program 81.2%
if -4.8e-156 < c < 2.20000000000000007e-218Initial program 64.2%
Taylor expanded in c around 0 88.1%
associate-*r/88.1%
neg-mul-188.1%
Simplified88.1%
if 0.28000000000000003 < c Initial program 29.4%
flip--18.4%
clear-num18.4%
fma-def18.4%
pow218.4%
pow218.4%
Applied egg-rr18.4%
Taylor expanded in b around inf 30.0%
associate-/r*30.0%
Simplified30.0%
associate-/r/30.0%
inv-pow30.0%
pow-flip30.0%
metadata-eval30.0%
pow130.0%
add-sqr-sqrt30.0%
hypot-udef30.0%
hypot-udef30.0%
times-frac77.6%
Applied egg-rr77.6%
Final simplification82.7%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* c b) (* a d)) (+ (* c c) (* d d)))))
(if (<= c -1.9e+78)
(- (/ b c) (/ (/ a c) (/ c d)))
(if (<= c -8e-158)
t_0
(if (<= c 3.9e-218)
(/ (- a) d)
(if (<= c 4.3e+21) t_0 (fma -1.0 (* (/ a c) (/ d c)) (/ b c))))))))
double code(double a, double b, double c, double d) {
double t_0 = ((c * b) - (a * d)) / ((c * c) + (d * d));
double tmp;
if (c <= -1.9e+78) {
tmp = (b / c) - ((a / c) / (c / d));
} else if (c <= -8e-158) {
tmp = t_0;
} else if (c <= 3.9e-218) {
tmp = -a / d;
} else if (c <= 4.3e+21) {
tmp = t_0;
} else {
tmp = fma(-1.0, ((a / c) * (d / c)), (b / c));
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(Float64(c * b) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d))) tmp = 0.0 if (c <= -1.9e+78) tmp = Float64(Float64(b / c) - Float64(Float64(a / c) / Float64(c / d))); elseif (c <= -8e-158) tmp = t_0; elseif (c <= 3.9e-218) tmp = Float64(Float64(-a) / d); elseif (c <= 4.3e+21) tmp = t_0; else tmp = fma(-1.0, Float64(Float64(a / c) * Float64(d / c)), Float64(b / c)); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(c * b), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -1.9e+78], N[(N[(b / c), $MachinePrecision] - N[(N[(a / c), $MachinePrecision] / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -8e-158], t$95$0, If[LessEqual[c, 3.9e-218], N[((-a) / d), $MachinePrecision], If[LessEqual[c, 4.3e+21], t$95$0, N[(-1.0 * N[(N[(a / c), $MachinePrecision] * N[(d / c), $MachinePrecision]), $MachinePrecision] + N[(b / c), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c \cdot b - a \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{if}\;c \leq -1.9 \cdot 10^{+78}:\\
\;\;\;\;\frac{b}{c} - \frac{\frac{a}{c}}{\frac{c}{d}}\\
\mathbf{elif}\;c \leq -8 \cdot 10^{-158}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 3.9 \cdot 10^{-218}:\\
\;\;\;\;\frac{-a}{d}\\
\mathbf{elif}\;c \leq 4.3 \cdot 10^{+21}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-1, \frac{a}{c} \cdot \frac{d}{c}, \frac{b}{c}\right)\\
\end{array}
\end{array}
if c < -1.9e78Initial program 32.6%
Taylor expanded in c around inf 70.3%
+-commutative70.3%
mul-1-neg70.3%
unsub-neg70.3%
associate-/l*69.7%
associate-/r/71.2%
Simplified71.2%
*-un-lft-identity71.2%
pow271.2%
times-frac79.6%
Applied egg-rr79.6%
associate-*l/79.6%
*-lft-identity79.6%
Simplified79.6%
associate-*l/84.9%
Applied egg-rr84.9%
associate-/l*85.0%
Simplified85.0%
if -1.9e78 < c < -8.00000000000000052e-158 or 3.9e-218 < c < 4.3e21Initial program 80.6%
if -8.00000000000000052e-158 < c < 3.9e-218Initial program 64.2%
Taylor expanded in c around 0 88.1%
associate-*r/88.1%
neg-mul-188.1%
Simplified88.1%
if 4.3e21 < c Initial program 28.6%
Taylor expanded in c around inf 62.1%
fma-def62.1%
associate-/l*62.5%
Simplified62.5%
associate-/r/64.3%
associate-*l/62.1%
*-commutative62.1%
pow262.1%
times-frac73.1%
Applied egg-rr73.1%
Final simplification81.6%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* c b) (* a d)) (+ (* c c) (* d d))))
(t_1 (- (/ b c) (/ (/ a c) (/ c d)))))
(if (<= c -6.8e+78)
t_1
(if (<= c -4.3e-160)
t_0
(if (<= c 6.5e-218) (/ (- a) d) (if (<= c 4.3e+21) t_0 t_1))))))
double code(double a, double b, double c, double d) {
double t_0 = ((c * b) - (a * d)) / ((c * c) + (d * d));
double t_1 = (b / c) - ((a / c) / (c / d));
double tmp;
if (c <= -6.8e+78) {
tmp = t_1;
} else if (c <= -4.3e-160) {
tmp = t_0;
} else if (c <= 6.5e-218) {
tmp = -a / d;
} else if (c <= 4.3e+21) {
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) - (a * d)) / ((c * c) + (d * d))
t_1 = (b / c) - ((a / c) / (c / d))
if (c <= (-6.8d+78)) then
tmp = t_1
else if (c <= (-4.3d-160)) then
tmp = t_0
else if (c <= 6.5d-218) then
tmp = -a / d
else if (c <= 4.3d+21) 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) - (a * d)) / ((c * c) + (d * d));
double t_1 = (b / c) - ((a / c) / (c / d));
double tmp;
if (c <= -6.8e+78) {
tmp = t_1;
} else if (c <= -4.3e-160) {
tmp = t_0;
} else if (c <= 6.5e-218) {
tmp = -a / d;
} else if (c <= 4.3e+21) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(a, b, c, d): t_0 = ((c * b) - (a * d)) / ((c * c) + (d * d)) t_1 = (b / c) - ((a / c) / (c / d)) tmp = 0 if c <= -6.8e+78: tmp = t_1 elif c <= -4.3e-160: tmp = t_0 elif c <= 6.5e-218: tmp = -a / d elif c <= 4.3e+21: tmp = t_0 else: tmp = t_1 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(Float64(c * b) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d))) t_1 = Float64(Float64(b / c) - Float64(Float64(a / c) / Float64(c / d))) tmp = 0.0 if (c <= -6.8e+78) tmp = t_1; elseif (c <= -4.3e-160) tmp = t_0; elseif (c <= 6.5e-218) tmp = Float64(Float64(-a) / d); elseif (c <= 4.3e+21) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((c * b) - (a * d)) / ((c * c) + (d * d)); t_1 = (b / c) - ((a / c) / (c / d)); tmp = 0.0; if (c <= -6.8e+78) tmp = t_1; elseif (c <= -4.3e-160) tmp = t_0; elseif (c <= 6.5e-218) tmp = -a / d; elseif (c <= 4.3e+21) 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 * b), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(b / c), $MachinePrecision] - N[(N[(a / c), $MachinePrecision] / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -6.8e+78], t$95$1, If[LessEqual[c, -4.3e-160], t$95$0, If[LessEqual[c, 6.5e-218], N[((-a) / d), $MachinePrecision], If[LessEqual[c, 4.3e+21], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c \cdot b - a \cdot d}{c \cdot c + d \cdot d}\\
t_1 := \frac{b}{c} - \frac{\frac{a}{c}}{\frac{c}{d}}\\
\mathbf{if}\;c \leq -6.8 \cdot 10^{+78}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;c \leq -4.3 \cdot 10^{-160}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 6.5 \cdot 10^{-218}:\\
\;\;\;\;\frac{-a}{d}\\
\mathbf{elif}\;c \leq 4.3 \cdot 10^{+21}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if c < -6.80000000000000014e78 or 4.3e21 < c Initial program 30.7%
Taylor expanded in c around inf 66.3%
+-commutative66.3%
mul-1-neg66.3%
unsub-neg66.3%
associate-/l*66.2%
associate-/r/67.9%
Simplified67.9%
*-un-lft-identity67.9%
pow267.9%
times-frac75.6%
Applied egg-rr75.6%
associate-*l/75.6%
*-lft-identity75.6%
Simplified75.6%
associate-*l/79.2%
Applied egg-rr79.2%
associate-/l*79.3%
Simplified79.3%
if -6.80000000000000014e78 < c < -4.30000000000000014e-160 or 6.49999999999999983e-218 < c < 4.3e21Initial program 80.6%
if -4.30000000000000014e-160 < c < 6.49999999999999983e-218Initial program 64.2%
Taylor expanded in c around 0 88.1%
associate-*r/88.1%
neg-mul-188.1%
Simplified88.1%
Final simplification81.6%
(FPCore (a b c d)
:precision binary64
(if (or (<= c -1.8e-33)
(and (not (<= c 2.3e-92)) (or (<= c 1.55e-44) (not (<= c 4.4e+21)))))
(- (/ b c) (* d (/ (/ a c) c)))
(/ (- a) d)))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -1.8e-33) || (!(c <= 2.3e-92) && ((c <= 1.55e-44) || !(c <= 4.4e+21)))) {
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 <= (-1.8d-33)) .or. (.not. (c <= 2.3d-92)) .and. (c <= 1.55d-44) .or. (.not. (c <= 4.4d+21))) 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 <= -1.8e-33) || (!(c <= 2.3e-92) && ((c <= 1.55e-44) || !(c <= 4.4e+21)))) {
tmp = (b / c) - (d * ((a / c) / c));
} else {
tmp = -a / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -1.8e-33) or (not (c <= 2.3e-92) and ((c <= 1.55e-44) or not (c <= 4.4e+21))): tmp = (b / c) - (d * ((a / c) / c)) else: tmp = -a / d return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -1.8e-33) || (!(c <= 2.3e-92) && ((c <= 1.55e-44) || !(c <= 4.4e+21)))) 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 <= -1.8e-33) || (~((c <= 2.3e-92)) && ((c <= 1.55e-44) || ~((c <= 4.4e+21))))) 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, -1.8e-33], And[N[Not[LessEqual[c, 2.3e-92]], $MachinePrecision], Or[LessEqual[c, 1.55e-44], N[Not[LessEqual[c, 4.4e+21]], $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 -1.8 \cdot 10^{-33} \lor \neg \left(c \leq 2.3 \cdot 10^{-92}\right) \land \left(c \leq 1.55 \cdot 10^{-44} \lor \neg \left(c \leq 4.4 \cdot 10^{+21}\right)\right):\\
\;\;\;\;\frac{b}{c} - d \cdot \frac{\frac{a}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{-a}{d}\\
\end{array}
\end{array}
if c < -1.80000000000000017e-33 or 2.30000000000000016e-92 < c < 1.54999999999999992e-44 or 4.4e21 < c Initial program 44.5%
Taylor expanded in c around inf 66.9%
+-commutative66.9%
mul-1-neg66.9%
unsub-neg66.9%
associate-/l*66.9%
associate-/r/68.1%
Simplified68.1%
*-un-lft-identity68.1%
pow268.1%
times-frac73.9%
Applied egg-rr73.9%
associate-*l/73.9%
*-lft-identity73.9%
Simplified73.9%
if -1.80000000000000017e-33 < c < 2.30000000000000016e-92 or 1.54999999999999992e-44 < c < 4.4e21Initial program 70.9%
Taylor expanded in c around 0 74.5%
associate-*r/74.5%
neg-mul-174.5%
Simplified74.5%
Final simplification74.1%
(FPCore (a b c d)
:precision binary64
(if (or (<= c -1.85e-38)
(not (or (<= c 2.3e-92) (and (not (<= c 2.15e-42)) (<= c 1.15e+22)))))
(- (/ b c) (/ (/ a c) (/ c d)))
(/ (- a) d)))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -1.85e-38) || !((c <= 2.3e-92) || (!(c <= 2.15e-42) && (c <= 1.15e+22)))) {
tmp = (b / c) - ((a / c) / (c / d));
} 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.85d-38)) .or. (.not. (c <= 2.3d-92) .or. (.not. (c <= 2.15d-42)) .and. (c <= 1.15d+22))) then
tmp = (b / c) - ((a / c) / (c / d))
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.85e-38) || !((c <= 2.3e-92) || (!(c <= 2.15e-42) && (c <= 1.15e+22)))) {
tmp = (b / c) - ((a / c) / (c / d));
} else {
tmp = -a / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -1.85e-38) or not ((c <= 2.3e-92) or (not (c <= 2.15e-42) and (c <= 1.15e+22))): tmp = (b / c) - ((a / c) / (c / d)) else: tmp = -a / d return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -1.85e-38) || !((c <= 2.3e-92) || (!(c <= 2.15e-42) && (c <= 1.15e+22)))) tmp = Float64(Float64(b / c) - Float64(Float64(a / c) / Float64(c / d))); else tmp = Float64(Float64(-a) / d); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((c <= -1.85e-38) || ~(((c <= 2.3e-92) || (~((c <= 2.15e-42)) && (c <= 1.15e+22))))) tmp = (b / c) - ((a / c) / (c / d)); else tmp = -a / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -1.85e-38], N[Not[Or[LessEqual[c, 2.3e-92], And[N[Not[LessEqual[c, 2.15e-42]], $MachinePrecision], LessEqual[c, 1.15e+22]]]], $MachinePrecision]], N[(N[(b / c), $MachinePrecision] - N[(N[(a / c), $MachinePrecision] / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-a) / d), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.85 \cdot 10^{-38} \lor \neg \left(c \leq 2.3 \cdot 10^{-92} \lor \neg \left(c \leq 2.15 \cdot 10^{-42}\right) \land c \leq 1.15 \cdot 10^{+22}\right):\\
\;\;\;\;\frac{b}{c} - \frac{\frac{a}{c}}{\frac{c}{d}}\\
\mathbf{else}:\\
\;\;\;\;\frac{-a}{d}\\
\end{array}
\end{array}
if c < -1.85e-38 or 2.30000000000000016e-92 < c < 2.1500000000000001e-42 or 1.1500000000000001e22 < c Initial program 44.5%
Taylor expanded in c around inf 66.9%
+-commutative66.9%
mul-1-neg66.9%
unsub-neg66.9%
associate-/l*66.9%
associate-/r/68.1%
Simplified68.1%
*-un-lft-identity68.1%
pow268.1%
times-frac73.9%
Applied egg-rr73.9%
associate-*l/73.9%
*-lft-identity73.9%
Simplified73.9%
associate-*l/76.5%
Applied egg-rr76.5%
associate-/l*76.6%
Simplified76.6%
if -1.85e-38 < c < 2.30000000000000016e-92 or 2.1500000000000001e-42 < c < 1.1500000000000001e22Initial program 70.9%
Taylor expanded in c around 0 74.5%
associate-*r/74.5%
neg-mul-174.5%
Simplified74.5%
Final simplification75.7%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- a) d)) (t_1 (- (/ b c) (/ (/ a c) (/ c d)))))
(if (<= c -1.85e-34)
t_1
(if (<= c 5.7e-95)
t_0
(if (<= c 1e-44)
(+ (/ b c) (* d (* (/ a c) (/ -1.0 c))))
(if (<= c 4.4e+21) t_0 t_1))))))
double code(double a, double b, double c, double d) {
double t_0 = -a / d;
double t_1 = (b / c) - ((a / c) / (c / d));
double tmp;
if (c <= -1.85e-34) {
tmp = t_1;
} else if (c <= 5.7e-95) {
tmp = t_0;
} else if (c <= 1e-44) {
tmp = (b / c) + (d * ((a / c) * (-1.0 / c)));
} else if (c <= 4.4e+21) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = -a / d
t_1 = (b / c) - ((a / c) / (c / d))
if (c <= (-1.85d-34)) then
tmp = t_1
else if (c <= 5.7d-95) then
tmp = t_0
else if (c <= 1d-44) then
tmp = (b / c) + (d * ((a / c) * ((-1.0d0) / c)))
else if (c <= 4.4d+21) then
tmp = t_0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = -a / d;
double t_1 = (b / c) - ((a / c) / (c / d));
double tmp;
if (c <= -1.85e-34) {
tmp = t_1;
} else if (c <= 5.7e-95) {
tmp = t_0;
} else if (c <= 1e-44) {
tmp = (b / c) + (d * ((a / c) * (-1.0 / c)));
} else if (c <= 4.4e+21) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(a, b, c, d): t_0 = -a / d t_1 = (b / c) - ((a / c) / (c / d)) tmp = 0 if c <= -1.85e-34: tmp = t_1 elif c <= 5.7e-95: tmp = t_0 elif c <= 1e-44: tmp = (b / c) + (d * ((a / c) * (-1.0 / c))) elif c <= 4.4e+21: tmp = t_0 else: tmp = t_1 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(-a) / d) t_1 = Float64(Float64(b / c) - Float64(Float64(a / c) / Float64(c / d))) tmp = 0.0 if (c <= -1.85e-34) tmp = t_1; elseif (c <= 5.7e-95) tmp = t_0; elseif (c <= 1e-44) tmp = Float64(Float64(b / c) + Float64(d * Float64(Float64(a / c) * Float64(-1.0 / c)))); elseif (c <= 4.4e+21) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = -a / d; t_1 = (b / c) - ((a / c) / (c / d)); tmp = 0.0; if (c <= -1.85e-34) tmp = t_1; elseif (c <= 5.7e-95) tmp = t_0; elseif (c <= 1e-44) tmp = (b / c) + (d * ((a / c) * (-1.0 / c))); elseif (c <= 4.4e+21) tmp = t_0; 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 / c), $MachinePrecision] - N[(N[(a / c), $MachinePrecision] / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -1.85e-34], t$95$1, If[LessEqual[c, 5.7e-95], t$95$0, If[LessEqual[c, 1e-44], N[(N[(b / c), $MachinePrecision] + N[(d * N[(N[(a / c), $MachinePrecision] * N[(-1.0 / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 4.4e+21], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-a}{d}\\
t_1 := \frac{b}{c} - \frac{\frac{a}{c}}{\frac{c}{d}}\\
\mathbf{if}\;c \leq -1.85 \cdot 10^{-34}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;c \leq 5.7 \cdot 10^{-95}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 10^{-44}:\\
\;\;\;\;\frac{b}{c} + d \cdot \left(\frac{a}{c} \cdot \frac{-1}{c}\right)\\
\mathbf{elif}\;c \leq 4.4 \cdot 10^{+21}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if c < -1.84999999999999994e-34 or 4.4e21 < c Initial program 41.3%
Taylor expanded in c around inf 65.3%
+-commutative65.3%
mul-1-neg65.3%
unsub-neg65.3%
associate-/l*65.2%
associate-/r/66.5%
Simplified66.5%
*-un-lft-identity66.5%
pow266.5%
times-frac72.7%
Applied egg-rr72.7%
associate-*l/72.7%
*-lft-identity72.7%
Simplified72.7%
associate-*l/75.5%
Applied egg-rr75.5%
associate-/l*75.6%
Simplified75.6%
if -1.84999999999999994e-34 < c < 5.7e-95 or 9.99999999999999953e-45 < c < 4.4e21Initial program 70.9%
Taylor expanded in c around 0 74.5%
associate-*r/74.5%
neg-mul-174.5%
Simplified74.5%
if 5.7e-95 < c < 9.99999999999999953e-45Initial program 89.5%
Taylor expanded in c around inf 90.1%
+-commutative90.1%
mul-1-neg90.1%
unsub-neg90.1%
associate-/l*90.0%
associate-/r/90.1%
Simplified90.1%
*-un-lft-identity90.1%
pow290.1%
times-frac90.3%
Applied egg-rr90.3%
Final simplification75.7%
(FPCore (a b c d)
:precision binary64
(if (or (<= c -5.2e-35)
(and (not (<= c 2.2e-92)) (or (<= c 9.8e-45) (not (<= c 4.4e+21)))))
(/ b c)
(/ (- a) d)))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -5.2e-35) || (!(c <= 2.2e-92) && ((c <= 9.8e-45) || !(c <= 4.4e+21)))) {
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 <= (-5.2d-35)) .or. (.not. (c <= 2.2d-92)) .and. (c <= 9.8d-45) .or. (.not. (c <= 4.4d+21))) 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 <= -5.2e-35) || (!(c <= 2.2e-92) && ((c <= 9.8e-45) || !(c <= 4.4e+21)))) {
tmp = b / c;
} else {
tmp = -a / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -5.2e-35) or (not (c <= 2.2e-92) and ((c <= 9.8e-45) or not (c <= 4.4e+21))): tmp = b / c else: tmp = -a / d return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -5.2e-35) || (!(c <= 2.2e-92) && ((c <= 9.8e-45) || !(c <= 4.4e+21)))) 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 <= -5.2e-35) || (~((c <= 2.2e-92)) && ((c <= 9.8e-45) || ~((c <= 4.4e+21))))) tmp = b / c; else tmp = -a / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -5.2e-35], And[N[Not[LessEqual[c, 2.2e-92]], $MachinePrecision], Or[LessEqual[c, 9.8e-45], N[Not[LessEqual[c, 4.4e+21]], $MachinePrecision]]]], N[(b / c), $MachinePrecision], N[((-a) / d), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -5.2 \cdot 10^{-35} \lor \neg \left(c \leq 2.2 \cdot 10^{-92}\right) \land \left(c \leq 9.8 \cdot 10^{-45} \lor \neg \left(c \leq 4.4 \cdot 10^{+21}\right)\right):\\
\;\;\;\;\frac{b}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{-a}{d}\\
\end{array}
\end{array}
if c < -5.20000000000000009e-35 or 2.19999999999999987e-92 < c < 9.7999999999999996e-45 or 4.4e21 < c Initial program 44.5%
Taylor expanded in c around inf 62.4%
if -5.20000000000000009e-35 < c < 2.19999999999999987e-92 or 9.7999999999999996e-45 < c < 4.4e21Initial program 70.9%
Taylor expanded in c around 0 74.5%
associate-*r/74.5%
neg-mul-174.5%
Simplified74.5%
Final simplification67.5%
(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 55.7%
Taylor expanded in c around inf 42.6%
Final simplification42.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 2024020
(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))))