
(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 10 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
(-
(* (/ 1.0 (hypot c d)) (* c (/ b (hypot c d))))
(* d (/ (/ a (hypot d c)) (hypot d c))))))
(if (<= c -4.2e-63)
t_0
(if (<= c 2e-108)
(/ (- (* b (/ c d)) a) d)
(if (<= c 1.6e-44) (/ (- (* c b) (* d a)) (+ (* c c) (* d d))) t_0)))))
double code(double a, double b, double c, double d) {
double t_0 = ((1.0 / hypot(c, d)) * (c * (b / hypot(c, d)))) - (d * ((a / hypot(d, c)) / hypot(d, c)));
double tmp;
if (c <= -4.2e-63) {
tmp = t_0;
} else if (c <= 2e-108) {
tmp = ((b * (c / d)) - a) / d;
} else if (c <= 1.6e-44) {
tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
} else {
tmp = t_0;
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = ((1.0 / Math.hypot(c, d)) * (c * (b / Math.hypot(c, d)))) - (d * ((a / Math.hypot(d, c)) / Math.hypot(d, c)));
double tmp;
if (c <= -4.2e-63) {
tmp = t_0;
} else if (c <= 2e-108) {
tmp = ((b * (c / d)) - a) / d;
} else if (c <= 1.6e-44) {
tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b, c, d): t_0 = ((1.0 / math.hypot(c, d)) * (c * (b / math.hypot(c, d)))) - (d * ((a / math.hypot(d, c)) / math.hypot(d, c))) tmp = 0 if c <= -4.2e-63: tmp = t_0 elif c <= 2e-108: tmp = ((b * (c / d)) - a) / d elif c <= 1.6e-44: tmp = ((c * b) - (d * a)) / ((c * c) + (d * d)) else: tmp = t_0 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(Float64(1.0 / hypot(c, d)) * Float64(c * Float64(b / hypot(c, d)))) - Float64(d * Float64(Float64(a / hypot(d, c)) / hypot(d, c)))) tmp = 0.0 if (c <= -4.2e-63) tmp = t_0; elseif (c <= 2e-108) tmp = Float64(Float64(Float64(b * Float64(c / d)) - a) / d); elseif (c <= 1.6e-44) tmp = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d))); else tmp = t_0; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((1.0 / hypot(c, d)) * (c * (b / hypot(c, d)))) - (d * ((a / hypot(d, c)) / hypot(d, c))); tmp = 0.0; if (c <= -4.2e-63) tmp = t_0; elseif (c <= 2e-108) tmp = ((b * (c / d)) - a) / d; elseif (c <= 1.6e-44) tmp = ((c * b) - (d * a)) / ((c * c) + (d * d)); else tmp = t_0; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(c * N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(d * N[(N[(a / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision] / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -4.2e-63], t$95$0, If[LessEqual[c, 2e-108], N[(N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 1.6e-44], N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(c \cdot \frac{b}{\mathsf{hypot}\left(c, d\right)}\right) - d \cdot \frac{\frac{a}{\mathsf{hypot}\left(d, c\right)}}{\mathsf{hypot}\left(d, c\right)}\\
\mathbf{if}\;c \leq -4.2 \cdot 10^{-63}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq 2 \cdot 10^{-108}:\\
\;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\
\mathbf{elif}\;c \leq 1.6 \cdot 10^{-44}:\\
\;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if c < -4.2e-63 or 1.59999999999999997e-44 < c Initial program 52.2%
div-sub52.1%
*-un-lft-identity52.1%
add-sqr-sqrt52.1%
times-frac52.1%
fmm-def52.1%
hypot-define52.1%
hypot-define59.5%
associate-/l*59.1%
add-sqr-sqrt59.1%
pow259.1%
hypot-define59.1%
Applied egg-rr59.1%
fmm-undef59.1%
*-commutative59.1%
associate-/l*84.0%
associate-*r/82.4%
*-commutative82.4%
associate-/l*84.2%
Simplified84.2%
*-un-lft-identity84.2%
unpow284.2%
times-frac92.9%
Applied egg-rr92.9%
associate-*l/93.0%
*-lft-identity93.0%
hypot-undefine84.3%
unpow284.3%
unpow284.3%
+-commutative84.3%
unpow284.3%
unpow284.3%
hypot-define93.0%
hypot-undefine84.3%
unpow284.3%
unpow284.3%
+-commutative84.3%
unpow284.3%
unpow284.3%
hypot-define93.0%
Simplified93.0%
if -4.2e-63 < c < 2.00000000000000008e-108Initial program 66.6%
div-sub62.0%
*-un-lft-identity62.0%
add-sqr-sqrt62.0%
times-frac62.0%
fmm-def63.1%
hypot-define63.1%
hypot-define63.2%
associate-/l*70.1%
add-sqr-sqrt70.1%
pow270.1%
hypot-define70.1%
Applied egg-rr70.1%
fmm-undef69.0%
*-commutative69.0%
associate-/l*68.0%
associate-*r/61.1%
*-commutative61.1%
associate-/l*60.4%
Simplified60.4%
Taylor expanded in d around inf 92.6%
associate-/l*92.8%
Simplified92.8%
if 2.00000000000000008e-108 < c < 1.59999999999999997e-44Initial program 94.6%
Final simplification93.0%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ 1.0 (hypot c d)))
(t_1
(-
(* t_0 (* c (/ b (hypot c d))))
(* d (/ a (pow (hypot c d) 2.0))))))
(if (<= d -1.65e+120)
(- (/ (* c t_0) (/ (hypot c d) b)) (/ a d))
(if (<= d -4.2e-101)
t_1
(if (<= d 7.1e-140)
(/ (- b (* a (/ d c))) c)
(if (<= d 2e+163) t_1 (/ (- (* b (/ c d)) a) d)))))))
double code(double a, double b, double c, double d) {
double t_0 = 1.0 / hypot(c, d);
double t_1 = (t_0 * (c * (b / hypot(c, d)))) - (d * (a / pow(hypot(c, d), 2.0)));
double tmp;
if (d <= -1.65e+120) {
tmp = ((c * t_0) / (hypot(c, d) / b)) - (a / d);
} else if (d <= -4.2e-101) {
tmp = t_1;
} else if (d <= 7.1e-140) {
tmp = (b - (a * (d / c))) / c;
} else if (d <= 2e+163) {
tmp = t_1;
} else {
tmp = ((b * (c / d)) - a) / d;
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = 1.0 / Math.hypot(c, d);
double t_1 = (t_0 * (c * (b / Math.hypot(c, d)))) - (d * (a / Math.pow(Math.hypot(c, d), 2.0)));
double tmp;
if (d <= -1.65e+120) {
tmp = ((c * t_0) / (Math.hypot(c, d) / b)) - (a / d);
} else if (d <= -4.2e-101) {
tmp = t_1;
} else if (d <= 7.1e-140) {
tmp = (b - (a * (d / c))) / c;
} else if (d <= 2e+163) {
tmp = t_1;
} else {
tmp = ((b * (c / d)) - a) / d;
}
return tmp;
}
def code(a, b, c, d): t_0 = 1.0 / math.hypot(c, d) t_1 = (t_0 * (c * (b / math.hypot(c, d)))) - (d * (a / math.pow(math.hypot(c, d), 2.0))) tmp = 0 if d <= -1.65e+120: tmp = ((c * t_0) / (math.hypot(c, d) / b)) - (a / d) elif d <= -4.2e-101: tmp = t_1 elif d <= 7.1e-140: tmp = (b - (a * (d / c))) / c elif d <= 2e+163: tmp = t_1 else: tmp = ((b * (c / d)) - a) / d return tmp
function code(a, b, c, d) t_0 = Float64(1.0 / hypot(c, d)) t_1 = Float64(Float64(t_0 * Float64(c * Float64(b / hypot(c, d)))) - Float64(d * Float64(a / (hypot(c, d) ^ 2.0)))) tmp = 0.0 if (d <= -1.65e+120) tmp = Float64(Float64(Float64(c * t_0) / Float64(hypot(c, d) / b)) - Float64(a / d)); elseif (d <= -4.2e-101) tmp = t_1; elseif (d <= 7.1e-140) tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c); elseif (d <= 2e+163) tmp = t_1; else tmp = Float64(Float64(Float64(b * Float64(c / d)) - a) / d); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = 1.0 / hypot(c, d); t_1 = (t_0 * (c * (b / hypot(c, d)))) - (d * (a / (hypot(c, d) ^ 2.0))); tmp = 0.0; if (d <= -1.65e+120) tmp = ((c * t_0) / (hypot(c, d) / b)) - (a / d); elseif (d <= -4.2e-101) tmp = t_1; elseif (d <= 7.1e-140) tmp = (b - (a * (d / c))) / c; elseif (d <= 2e+163) tmp = t_1; else tmp = ((b * (c / d)) - a) / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 * N[(c * N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(d * N[(a / N[Power[N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -1.65e+120], N[(N[(N[(c * t$95$0), $MachinePrecision] / N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -4.2e-101], t$95$1, If[LessEqual[d, 7.1e-140], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 2e+163], t$95$1, N[(N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\mathsf{hypot}\left(c, d\right)}\\
t_1 := t\_0 \cdot \left(c \cdot \frac{b}{\mathsf{hypot}\left(c, d\right)}\right) - d \cdot \frac{a}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\\
\mathbf{if}\;d \leq -1.65 \cdot 10^{+120}:\\
\;\;\;\;\frac{c \cdot t\_0}{\frac{\mathsf{hypot}\left(c, d\right)}{b}} - \frac{a}{d}\\
\mathbf{elif}\;d \leq -4.2 \cdot 10^{-101}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d \leq 7.1 \cdot 10^{-140}:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\
\mathbf{elif}\;d \leq 2 \cdot 10^{+163}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\
\end{array}
\end{array}
if d < -1.64999999999999995e120Initial program 23.7%
div-sub23.7%
*-un-lft-identity23.7%
add-sqr-sqrt23.7%
times-frac23.6%
fmm-def23.6%
hypot-define23.6%
hypot-define26.5%
associate-/l*30.9%
add-sqr-sqrt30.9%
pow230.9%
hypot-define30.9%
Applied egg-rr30.9%
fmm-undef30.9%
*-commutative30.9%
associate-/l*40.0%
associate-*r/35.5%
*-commutative35.5%
associate-/l*40.0%
Simplified40.0%
*-un-lft-identity40.0%
unpow240.0%
times-frac77.7%
Applied egg-rr77.7%
associate-*l/77.8%
*-lft-identity77.8%
hypot-undefine40.0%
unpow240.0%
unpow240.0%
+-commutative40.0%
unpow240.0%
unpow240.0%
hypot-define77.8%
hypot-undefine40.0%
unpow240.0%
unpow240.0%
+-commutative40.0%
unpow240.0%
unpow240.0%
hypot-define77.8%
Simplified77.8%
associate-*r*77.9%
clear-num77.9%
un-div-inv78.0%
Applied egg-rr78.0%
Taylor expanded in d around inf 94.1%
if -1.64999999999999995e120 < d < -4.20000000000000031e-101 or 7.09999999999999986e-140 < d < 1.9999999999999999e163Initial program 68.6%
div-sub68.6%
*-un-lft-identity68.6%
add-sqr-sqrt68.6%
times-frac68.6%
fmm-def68.6%
hypot-define68.6%
hypot-define73.2%
associate-/l*76.3%
add-sqr-sqrt76.3%
pow276.3%
hypot-define76.3%
Applied egg-rr76.3%
fmm-undef76.3%
*-commutative76.3%
associate-/l*93.2%
associate-*r/90.1%
*-commutative90.1%
associate-/l*89.3%
Simplified89.3%
if -4.20000000000000031e-101 < d < 7.09999999999999986e-140Initial program 72.3%
Taylor expanded in c around inf 91.3%
mul-1-neg91.3%
unsub-neg91.3%
associate-/l*91.4%
Simplified91.4%
if 1.9999999999999999e163 < d Initial program 38.6%
div-sub38.6%
*-un-lft-identity38.6%
add-sqr-sqrt38.6%
times-frac38.6%
fmm-def38.6%
hypot-define38.6%
hypot-define38.8%
associate-/l*40.3%
add-sqr-sqrt40.3%
pow240.3%
hypot-define40.3%
Applied egg-rr40.3%
fmm-undef40.3%
*-commutative40.3%
associate-/l*52.4%
associate-*r/41.8%
*-commutative41.8%
associate-/l*52.4%
Simplified52.4%
Taylor expanded in d around inf 76.2%
associate-/l*91.4%
Simplified91.4%
Final simplification90.7%
(FPCore (a b c d)
:precision binary64
(if (<= c -4.7e+151)
(/ (- b (* a (/ d c))) c)
(if (<= c 1.6e-80)
(- (/ (* c (/ 1.0 (hypot c d))) (/ (hypot c d) b)) (/ a d))
(if (<= c 1.3e+141)
(/ (- (* c b) (* d a)) (+ (* c c) (* d d)))
(/ (- b (/ a (/ c d))) c)))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -4.7e+151) {
tmp = (b - (a * (d / c))) / c;
} else if (c <= 1.6e-80) {
tmp = ((c * (1.0 / hypot(c, d))) / (hypot(c, d) / b)) - (a / d);
} else if (c <= 1.3e+141) {
tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
} else {
tmp = (b - (a / (c / d))) / c;
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -4.7e+151) {
tmp = (b - (a * (d / c))) / c;
} else if (c <= 1.6e-80) {
tmp = ((c * (1.0 / Math.hypot(c, d))) / (Math.hypot(c, d) / b)) - (a / d);
} else if (c <= 1.3e+141) {
tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
} else {
tmp = (b - (a / (c / d))) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -4.7e+151: tmp = (b - (a * (d / c))) / c elif c <= 1.6e-80: tmp = ((c * (1.0 / math.hypot(c, d))) / (math.hypot(c, d) / b)) - (a / d) elif c <= 1.3e+141: tmp = ((c * b) - (d * a)) / ((c * c) + (d * d)) else: tmp = (b - (a / (c / d))) / c return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -4.7e+151) tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c); elseif (c <= 1.6e-80) tmp = Float64(Float64(Float64(c * Float64(1.0 / hypot(c, d))) / Float64(hypot(c, d) / b)) - Float64(a / d)); elseif (c <= 1.3e+141) tmp = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d))); else tmp = Float64(Float64(b - Float64(a / Float64(c / d))) / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -4.7e+151) tmp = (b - (a * (d / c))) / c; elseif (c <= 1.6e-80) tmp = ((c * (1.0 / hypot(c, d))) / (hypot(c, d) / b)) - (a / d); elseif (c <= 1.3e+141) tmp = ((c * b) - (d * a)) / ((c * c) + (d * d)); else tmp = (b - (a / (c / d))) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -4.7e+151], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[c, 1.6e-80], N[(N[(N[(c * N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.3e+141], 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 - N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -4.7 \cdot 10^{+151}:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\
\mathbf{elif}\;c \leq 1.6 \cdot 10^{-80}:\\
\;\;\;\;\frac{c \cdot \frac{1}{\mathsf{hypot}\left(c, d\right)}}{\frac{\mathsf{hypot}\left(c, d\right)}{b}} - \frac{a}{d}\\
\mathbf{elif}\;c \leq 1.3 \cdot 10^{+141}:\\
\;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - \frac{a}{\frac{c}{d}}}{c}\\
\end{array}
\end{array}
if c < -4.69999999999999989e151Initial program 33.7%
Taylor expanded in c around inf 92.5%
mul-1-neg92.5%
unsub-neg92.5%
associate-/l*96.4%
Simplified96.4%
if -4.69999999999999989e151 < c < 1.5999999999999999e-80Initial program 68.6%
div-sub65.7%
*-un-lft-identity65.7%
add-sqr-sqrt65.7%
times-frac65.6%
fmm-def66.3%
hypot-define66.3%
hypot-define66.5%
associate-/l*71.5%
add-sqr-sqrt71.5%
pow271.5%
hypot-define71.5%
Applied egg-rr71.5%
fmm-undef70.8%
*-commutative70.8%
associate-/l*75.5%
associate-*r/70.5%
*-commutative70.5%
associate-/l*69.5%
Simplified69.5%
*-un-lft-identity69.5%
unpow269.5%
times-frac80.3%
Applied egg-rr80.3%
associate-*l/80.4%
*-lft-identity80.4%
hypot-undefine69.6%
unpow269.6%
unpow269.6%
+-commutative69.6%
unpow269.6%
unpow269.6%
hypot-define80.4%
hypot-undefine69.6%
unpow269.6%
unpow269.6%
+-commutative69.6%
unpow269.6%
unpow269.6%
hypot-define80.4%
Simplified80.4%
associate-*r*80.5%
clear-num80.4%
un-div-inv80.7%
Applied egg-rr80.7%
Taylor expanded in d around inf 85.5%
if 1.5999999999999999e-80 < c < 1.3e141Initial program 87.3%
if 1.3e141 < c Initial program 24.5%
Taylor expanded in c around inf 82.8%
mul-1-neg82.8%
unsub-neg82.8%
associate-/l*84.7%
Simplified84.7%
clear-num84.7%
un-div-inv84.7%
Applied egg-rr84.7%
Final simplification87.3%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* c b) (* d a)) (+ (* c c) (* d d)))))
(if (<= c -1.7e+67)
(/ (- b (* a (/ d c))) c)
(if (<= c -3.6e-36)
t_0
(if (<= c 8.2e-106)
(/ (- (* b (/ c d)) a) d)
(if (<= c 1e+139) t_0 (/ (- b (/ a (/ c d))) c)))))))
double code(double a, double b, double c, double d) {
double t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
double tmp;
if (c <= -1.7e+67) {
tmp = (b - (a * (d / c))) / c;
} else if (c <= -3.6e-36) {
tmp = t_0;
} else if (c <= 8.2e-106) {
tmp = ((b * (c / d)) - a) / d;
} else if (c <= 1e+139) {
tmp = t_0;
} else {
tmp = (b - (a / (c / d))) / 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) :: t_0
real(8) :: tmp
t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d))
if (c <= (-1.7d+67)) then
tmp = (b - (a * (d / c))) / c
else if (c <= (-3.6d-36)) then
tmp = t_0
else if (c <= 8.2d-106) then
tmp = ((b * (c / d)) - a) / d
else if (c <= 1d+139) then
tmp = t_0
else
tmp = (b - (a / (c / d))) / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
double tmp;
if (c <= -1.7e+67) {
tmp = (b - (a * (d / c))) / c;
} else if (c <= -3.6e-36) {
tmp = t_0;
} else if (c <= 8.2e-106) {
tmp = ((b * (c / d)) - a) / d;
} else if (c <= 1e+139) {
tmp = t_0;
} else {
tmp = (b - (a / (c / d))) / c;
}
return tmp;
}
def code(a, b, c, d): t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d)) tmp = 0 if c <= -1.7e+67: tmp = (b - (a * (d / c))) / c elif c <= -3.6e-36: tmp = t_0 elif c <= 8.2e-106: tmp = ((b * (c / d)) - a) / d elif c <= 1e+139: tmp = t_0 else: tmp = (b - (a / (c / d))) / c 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))) tmp = 0.0 if (c <= -1.7e+67) tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c); elseif (c <= -3.6e-36) tmp = t_0; elseif (c <= 8.2e-106) tmp = Float64(Float64(Float64(b * Float64(c / d)) - a) / d); elseif (c <= 1e+139) tmp = t_0; else tmp = Float64(Float64(b - Float64(a / Float64(c / d))) / c); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d)); tmp = 0.0; if (c <= -1.7e+67) tmp = (b - (a * (d / c))) / c; elseif (c <= -3.6e-36) tmp = t_0; elseif (c <= 8.2e-106) tmp = ((b * (c / d)) - a) / d; elseif (c <= 1e+139) tmp = t_0; else tmp = (b - (a / (c / d))) / c; end tmp_2 = 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]}, If[LessEqual[c, -1.7e+67], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[c, -3.6e-36], t$95$0, If[LessEqual[c, 8.2e-106], N[(N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 1e+139], t$95$0, N[(N[(b - N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{if}\;c \leq -1.7 \cdot 10^{+67}:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\
\mathbf{elif}\;c \leq -3.6 \cdot 10^{-36}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq 8.2 \cdot 10^{-106}:\\
\;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\
\mathbf{elif}\;c \leq 10^{+139}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{b - \frac{a}{\frac{c}{d}}}{c}\\
\end{array}
\end{array}
if c < -1.7000000000000001e67Initial program 39.2%
Taylor expanded in c around inf 84.8%
mul-1-neg84.8%
unsub-neg84.8%
associate-/l*87.4%
Simplified87.4%
if -1.7000000000000001e67 < c < -3.60000000000000032e-36 or 8.1999999999999998e-106 < c < 1.00000000000000003e139Initial program 85.6%
if -3.60000000000000032e-36 < c < 8.1999999999999998e-106Initial program 67.3%
div-sub62.9%
*-un-lft-identity62.9%
add-sqr-sqrt62.9%
times-frac62.9%
fmm-def63.9%
hypot-define63.9%
hypot-define64.1%
associate-/l*70.6%
add-sqr-sqrt70.6%
pow270.6%
hypot-define70.6%
Applied egg-rr70.6%
fmm-undef69.6%
*-commutative69.6%
associate-/l*68.6%
associate-*r/62.1%
*-commutative62.1%
associate-/l*61.4%
Simplified61.4%
Taylor expanded in d around inf 92.0%
associate-/l*92.2%
Simplified92.2%
if 1.00000000000000003e139 < c Initial program 24.5%
Taylor expanded in c around inf 82.8%
mul-1-neg82.8%
unsub-neg82.8%
associate-/l*84.7%
Simplified84.7%
clear-num84.7%
un-div-inv84.7%
Applied egg-rr84.7%
Final simplification88.4%
(FPCore (a b c d) :precision binary64 (if (or (<= c -1e-21) (not (<= c 2.5e-79))) (/ (- b (* a (/ d c))) c) (/ a (- d))))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -1e-21) || !(c <= 2.5e-79)) {
tmp = (b - (a * (d / 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 <= (-1d-21)) .or. (.not. (c <= 2.5d-79))) then
tmp = (b - (a * (d / 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 <= -1e-21) || !(c <= 2.5e-79)) {
tmp = (b - (a * (d / c))) / c;
} else {
tmp = a / -d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -1e-21) or not (c <= 2.5e-79): tmp = (b - (a * (d / c))) / c else: tmp = a / -d return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -1e-21) || !(c <= 2.5e-79)) tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c); else tmp = Float64(a / Float64(-d)); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((c <= -1e-21) || ~((c <= 2.5e-79))) tmp = (b - (a * (d / c))) / c; else tmp = a / -d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -1e-21], N[Not[LessEqual[c, 2.5e-79]], $MachinePrecision]], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], N[(a / (-d)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -1 \cdot 10^{-21} \lor \neg \left(c \leq 2.5 \cdot 10^{-79}\right):\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{-d}\\
\end{array}
\end{array}
if c < -9.99999999999999908e-22 or 2.5e-79 < c Initial program 53.2%
Taylor expanded in c around inf 75.0%
mul-1-neg75.0%
unsub-neg75.0%
associate-/l*76.4%
Simplified76.4%
if -9.99999999999999908e-22 < c < 2.5e-79Initial program 70.0%
Taylor expanded in c around 0 74.6%
associate-*r/74.6%
neg-mul-174.6%
Simplified74.6%
Final simplification75.7%
(FPCore (a b c d) :precision binary64 (if (<= c -3.1e+70) (/ (- b (* a (/ d c))) c) (if (<= c 2.5e-79) (/ (- (* b (/ c d)) a) d) (/ (- b (/ a (/ c d))) c))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -3.1e+70) {
tmp = (b - (a * (d / c))) / c;
} else if (c <= 2.5e-79) {
tmp = ((b * (c / d)) - a) / d;
} else {
tmp = (b - (a / (c / d))) / c;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (c <= (-3.1d+70)) then
tmp = (b - (a * (d / c))) / c
else if (c <= 2.5d-79) then
tmp = ((b * (c / d)) - a) / d
else
tmp = (b - (a / (c / d))) / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -3.1e+70) {
tmp = (b - (a * (d / c))) / c;
} else if (c <= 2.5e-79) {
tmp = ((b * (c / d)) - a) / d;
} else {
tmp = (b - (a / (c / d))) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -3.1e+70: tmp = (b - (a * (d / c))) / c elif c <= 2.5e-79: tmp = ((b * (c / d)) - a) / d else: tmp = (b - (a / (c / d))) / c return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -3.1e+70) tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c); elseif (c <= 2.5e-79) tmp = Float64(Float64(Float64(b * Float64(c / d)) - a) / d); else tmp = Float64(Float64(b - Float64(a / Float64(c / d))) / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -3.1e+70) tmp = (b - (a * (d / c))) / c; elseif (c <= 2.5e-79) tmp = ((b * (c / d)) - a) / d; else tmp = (b - (a / (c / d))) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -3.1e+70], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[c, 2.5e-79], N[(N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], N[(N[(b - N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -3.1 \cdot 10^{+70}:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\
\mathbf{elif}\;c \leq 2.5 \cdot 10^{-79}:\\
\;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - \frac{a}{\frac{c}{d}}}{c}\\
\end{array}
\end{array}
if c < -3.1000000000000003e70Initial program 40.5%
Taylor expanded in c around inf 86.0%
mul-1-neg86.0%
unsub-neg86.0%
associate-/l*88.7%
Simplified88.7%
if -3.1000000000000003e70 < c < 2.5e-79Initial program 70.1%
div-sub66.8%
*-un-lft-identity66.8%
add-sqr-sqrt66.8%
times-frac66.7%
fmm-def67.5%
hypot-define67.5%
hypot-define67.6%
associate-/l*73.3%
add-sqr-sqrt73.3%
pow273.3%
hypot-define73.3%
Applied egg-rr73.3%
fmm-undef72.6%
*-commutative72.6%
associate-/l*73.4%
associate-*r/67.6%
*-commutative67.6%
associate-/l*66.6%
Simplified66.6%
Taylor expanded in d around inf 83.2%
associate-/l*84.9%
Simplified84.9%
if 2.5e-79 < c Initial program 58.0%
Taylor expanded in c around inf 75.2%
mul-1-neg75.2%
unsub-neg75.2%
associate-/l*76.0%
Simplified76.0%
clear-num76.0%
un-div-inv76.0%
Applied egg-rr76.0%
(FPCore (a b c d) :precision binary64 (if (<= c -1.85e-22) (/ (- b (* a (/ d c))) c) (if (<= c 1.45e-79) (/ a (- d)) (/ (- b (/ a (/ c d))) c))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -1.85e-22) {
tmp = (b - (a * (d / c))) / c;
} else if (c <= 1.45e-79) {
tmp = a / -d;
} else {
tmp = (b - (a / (c / d))) / c;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (c <= (-1.85d-22)) then
tmp = (b - (a * (d / c))) / c
else if (c <= 1.45d-79) then
tmp = a / -d
else
tmp = (b - (a / (c / d))) / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -1.85e-22) {
tmp = (b - (a * (d / c))) / c;
} else if (c <= 1.45e-79) {
tmp = a / -d;
} else {
tmp = (b - (a / (c / d))) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -1.85e-22: tmp = (b - (a * (d / c))) / c elif c <= 1.45e-79: tmp = a / -d else: tmp = (b - (a / (c / d))) / c return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -1.85e-22) tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c); elseif (c <= 1.45e-79) tmp = Float64(a / Float64(-d)); else tmp = Float64(Float64(b - Float64(a / Float64(c / d))) / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -1.85e-22) tmp = (b - (a * (d / c))) / c; elseif (c <= 1.45e-79) tmp = a / -d; else tmp = (b - (a / (c / d))) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -1.85e-22], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[c, 1.45e-79], N[(a / (-d)), $MachinePrecision], N[(N[(b - N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.85 \cdot 10^{-22}:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\
\mathbf{elif}\;c \leq 1.45 \cdot 10^{-79}:\\
\;\;\;\;\frac{a}{-d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - \frac{a}{\frac{c}{d}}}{c}\\
\end{array}
\end{array}
if c < -1.85e-22Initial program 48.5%
Taylor expanded in c around inf 74.9%
mul-1-neg74.9%
unsub-neg74.9%
associate-/l*76.9%
Simplified76.9%
if -1.85e-22 < c < 1.45e-79Initial program 70.0%
Taylor expanded in c around 0 74.6%
associate-*r/74.6%
neg-mul-174.6%
Simplified74.6%
if 1.45e-79 < c Initial program 58.0%
Taylor expanded in c around inf 75.2%
mul-1-neg75.2%
unsub-neg75.2%
associate-/l*76.0%
Simplified76.0%
clear-num76.0%
un-div-inv76.0%
Applied egg-rr76.0%
Final simplification75.7%
(FPCore (a b c d) :precision binary64 (if (or (<= c -2.65e+67) (not (<= c 2.5e-79))) (/ b c) (/ a (- d))))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -2.65e+67) || !(c <= 2.5e-79)) {
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.65d+67)) .or. (.not. (c <= 2.5d-79))) 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.65e+67) || !(c <= 2.5e-79)) {
tmp = b / c;
} else {
tmp = a / -d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -2.65e+67) or not (c <= 2.5e-79): tmp = b / c else: tmp = a / -d return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -2.65e+67) || !(c <= 2.5e-79)) tmp = Float64(b / c); else tmp = Float64(a / Float64(-d)); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((c <= -2.65e+67) || ~((c <= 2.5e-79))) tmp = b / c; else tmp = a / -d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -2.65e+67], N[Not[LessEqual[c, 2.5e-79]], $MachinePrecision]], N[(b / c), $MachinePrecision], N[(a / (-d)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -2.65 \cdot 10^{+67} \lor \neg \left(c \leq 2.5 \cdot 10^{-79}\right):\\
\;\;\;\;\frac{b}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{-d}\\
\end{array}
\end{array}
if c < -2.65e67 or 2.5e-79 < c Initial program 49.8%
Taylor expanded in c around inf 68.5%
if -2.65e67 < c < 2.5e-79Initial program 71.2%
Taylor expanded in c around 0 69.8%
associate-*r/69.8%
neg-mul-169.8%
Simplified69.8%
Final simplification69.1%
(FPCore (a b c d) :precision binary64 (if (<= d 3.1e+226) (/ b c) (/ a d)))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= 3.1e+226) {
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 (d <= 3.1d+226) 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 (d <= 3.1e+226) {
tmp = b / c;
} else {
tmp = a / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= 3.1e+226: tmp = b / c else: tmp = a / d return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= 3.1e+226) tmp = Float64(b / c); else tmp = Float64(a / d); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= 3.1e+226) tmp = b / c; else tmp = a / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, 3.1e+226], N[(b / c), $MachinePrecision], N[(a / d), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq 3.1 \cdot 10^{+226}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{d}\\
\end{array}
\end{array}
if d < 3.09999999999999976e226Initial program 61.5%
Taylor expanded in c around inf 45.4%
if 3.09999999999999976e226 < d Initial program 48.4%
Taylor expanded in c around 0 83.5%
associate-*r/83.5%
neg-mul-183.5%
Simplified83.5%
neg-sub083.5%
sub-neg83.5%
add-sqr-sqrt30.7%
sqrt-unprod57.9%
sqr-neg57.9%
sqrt-unprod27.1%
add-sqr-sqrt49.8%
Applied egg-rr49.8%
+-lft-identity49.8%
Simplified49.8%
(FPCore (a b c d) :precision binary64 (/ a d))
double code(double a, double b, double c, double d) {
return a / d;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = a / d
end function
public static double code(double a, double b, double c, double d) {
return a / d;
}
def code(a, b, c, d): return a / d
function code(a, b, c, d) return Float64(a / d) end
function tmp = code(a, b, c, d) tmp = a / d; end
code[a_, b_, c_, d_] := N[(a / d), $MachinePrecision]
\begin{array}{l}
\\
\frac{a}{d}
\end{array}
Initial program 60.3%
Taylor expanded in c around 0 43.2%
associate-*r/43.2%
neg-mul-143.2%
Simplified43.2%
neg-sub043.2%
sub-neg43.2%
add-sqr-sqrt22.7%
sqrt-unprod23.0%
sqr-neg23.0%
sqrt-unprod5.1%
add-sqr-sqrt9.8%
Applied egg-rr9.8%
+-lft-identity9.8%
Simplified9.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 2024180
(FPCore (a b c d)
:name "Complex division, imag part"
:precision binary64
:alt
(! :herbie-platform default (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))))