
(FPCore (a b c d) :precision binary64 (/ (- (* b c) (* a d)) (+ (* c c) (* d d))))
double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = ((b * c) - (a * d)) / ((c * c) + (d * d))
end function
public static double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
def code(a, b, c, d): return ((b * c) - (a * d)) / ((c * c) + (d * d))
function code(a, b, c, d) return Float64(Float64(Float64(b * c) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d))) end
function tmp = code(a, b, c, d) tmp = ((b * c) - (a * d)) / ((c * c) + (d * d)); end
code[a_, b_, c_, d_] := N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b c d) :precision binary64 (/ (- (* b c) (* a d)) (+ (* c c) (* d d))))
double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = ((b * c) - (a * d)) / ((c * c) + (d * d))
end function
public static double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
def code(a, b, c, d): return ((b * c) - (a * d)) / ((c * c) + (d * d))
function code(a, b, c, d) return Float64(Float64(Float64(b * c) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d))) end
function tmp = code(a, b, c, d) tmp = ((b * c) - (a * d)) / ((c * c) + (d * d)); end
code[a_, b_, c_, d_] := N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}
\end{array}
(FPCore (a b c d) :precision binary64 (fma (/ c (hypot c d)) (/ b (hypot c d)) (* a (/ (/ d (hypot d c)) (- (hypot d c))))))
double code(double a, double b, double c, double d) {
return fma((c / hypot(c, d)), (b / hypot(c, d)), (a * ((d / hypot(d, c)) / -hypot(d, c))));
}
function code(a, b, c, d) return fma(Float64(c / hypot(c, d)), Float64(b / hypot(c, d)), Float64(a * Float64(Float64(d / hypot(d, c)) / Float64(-hypot(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[(N[(d / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision] / (-N[Sqrt[d ^ 2 + c ^ 2], $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{\frac{d}{\mathsf{hypot}\left(d, c\right)}}{-\mathsf{hypot}\left(d, c\right)}\right)
\end{array}
Initial program 64.8%
div-sub61.9%
*-commutative61.9%
fma-define61.9%
add-sqr-sqrt61.9%
times-frac63.5%
fma-neg63.5%
fma-define63.5%
hypot-define63.5%
fma-define63.5%
hypot-define78.0%
associate-/l*80.0%
fma-define80.0%
add-sqr-sqrt80.0%
pow280.0%
Applied egg-rr80.0%
*-un-lft-identity80.0%
unpow280.0%
times-frac95.4%
hypot-undefine80.0%
+-commutative80.0%
hypot-define95.4%
hypot-undefine80.0%
+-commutative80.0%
hypot-define95.4%
Applied egg-rr95.4%
associate-*l/95.4%
*-lft-identity95.4%
Simplified95.4%
Final simplification95.4%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ c (hypot c d)))
(t_1 (fma t_0 (/ b (hypot c d)) (* a (/ (- d) (pow (hypot c d) 2.0)))))
(t_2 (fma t_0 (/ b d) (* a (/ (/ d (hypot d c)) (- (hypot d c)))))))
(if (<= d -1.35e+154)
t_2
(if (<= d -2.55e-128)
t_1
(if (<= d 4.5e-162)
(/ (- b (/ a (/ c d))) c)
(if (<= d 1.4e+150) t_1 t_2))))))
double code(double a, double b, double c, double d) {
double t_0 = c / hypot(c, d);
double t_1 = fma(t_0, (b / hypot(c, d)), (a * (-d / pow(hypot(c, d), 2.0))));
double t_2 = fma(t_0, (b / d), (a * ((d / hypot(d, c)) / -hypot(d, c))));
double tmp;
if (d <= -1.35e+154) {
tmp = t_2;
} else if (d <= -2.55e-128) {
tmp = t_1;
} else if (d <= 4.5e-162) {
tmp = (b - (a / (c / d))) / c;
} else if (d <= 1.4e+150) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(c / hypot(c, d)) t_1 = fma(t_0, Float64(b / hypot(c, d)), Float64(a * Float64(Float64(-d) / (hypot(c, d) ^ 2.0)))) t_2 = fma(t_0, Float64(b / d), Float64(a * Float64(Float64(d / hypot(d, c)) / Float64(-hypot(d, c))))) tmp = 0.0 if (d <= -1.35e+154) tmp = t_2; elseif (d <= -2.55e-128) tmp = t_1; elseif (d <= 4.5e-162) tmp = Float64(Float64(b - Float64(a / Float64(c / d))) / c); elseif (d <= 1.4e+150) tmp = t_1; else tmp = t_2; 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[(t$95$0 * N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] + N[(a * N[((-d) / N[Power[N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$0 * N[(b / d), $MachinePrecision] + N[(a * N[(N[(d / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision] / (-N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -1.35e+154], t$95$2, If[LessEqual[d, -2.55e-128], t$95$1, If[LessEqual[d, 4.5e-162], N[(N[(b - N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 1.4e+150], t$95$1, t$95$2]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c}{\mathsf{hypot}\left(c, d\right)}\\
t_1 := \mathsf{fma}\left(t\_0, \frac{b}{\mathsf{hypot}\left(c, d\right)}, a \cdot \frac{-d}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\right)\\
t_2 := \mathsf{fma}\left(t\_0, \frac{b}{d}, a \cdot \frac{\frac{d}{\mathsf{hypot}\left(d, c\right)}}{-\mathsf{hypot}\left(d, c\right)}\right)\\
\mathbf{if}\;d \leq -1.35 \cdot 10^{+154}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;d \leq -2.55 \cdot 10^{-128}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d \leq 4.5 \cdot 10^{-162}:\\
\;\;\;\;\frac{b - \frac{a}{\frac{c}{d}}}{c}\\
\mathbf{elif}\;d \leq 1.4 \cdot 10^{+150}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if d < -1.35000000000000003e154 or 1.40000000000000005e150 < d Initial program 36.2%
div-sub36.2%
*-commutative36.2%
fma-define36.2%
add-sqr-sqrt36.2%
times-frac36.4%
fma-neg36.4%
fma-define36.4%
hypot-define36.4%
fma-define36.4%
hypot-define47.1%
associate-/l*48.6%
fma-define48.6%
add-sqr-sqrt48.6%
pow248.6%
Applied egg-rr48.6%
*-un-lft-identity48.6%
unpow248.6%
times-frac99.7%
hypot-undefine48.6%
+-commutative48.6%
hypot-define99.7%
hypot-undefine48.6%
+-commutative48.6%
hypot-define99.7%
Applied egg-rr99.7%
associate-*l/99.7%
*-lft-identity99.7%
Simplified99.7%
Taylor expanded in c around 0 93.1%
if -1.35000000000000003e154 < d < -2.5500000000000002e-128 or 4.50000000000000023e-162 < d < 1.40000000000000005e150Initial program 74.2%
div-sub74.2%
*-commutative74.2%
fma-define74.2%
add-sqr-sqrt74.2%
times-frac75.6%
fma-neg75.6%
fma-define75.6%
hypot-define75.6%
fma-define75.6%
hypot-define89.2%
associate-/l*93.1%
fma-define93.1%
add-sqr-sqrt93.1%
pow293.1%
Applied egg-rr93.1%
if -2.5500000000000002e-128 < d < 4.50000000000000023e-162Initial program 73.2%
Taylor expanded in c around inf 97.3%
remove-double-neg97.3%
mul-1-neg97.3%
neg-mul-197.3%
distribute-lft-in97.3%
distribute-lft-in97.3%
mul-1-neg97.3%
unsub-neg97.3%
neg-mul-197.3%
mul-1-neg97.3%
remove-double-neg97.3%
associate-/l*97.3%
Simplified97.3%
clear-num97.3%
un-div-inv97.3%
Applied egg-rr97.3%
Final simplification94.3%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* c b) (* d a)) (+ (* c c) (* d d)))))
(if (<= d -5.4e+81)
(/ (- (* b (/ c d)) a) d)
(if (<= d -3.1e-32)
t_0
(if (<= d 5.8e-120)
(/ (- b (/ a (/ c d))) c)
(if (<= d 2.25e+49)
t_0
(fma
(/ c (hypot c d))
(/ b d)
(* a (/ (/ d (hypot d c)) (- (hypot 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 (d <= -5.4e+81) {
tmp = ((b * (c / d)) - a) / d;
} else if (d <= -3.1e-32) {
tmp = t_0;
} else if (d <= 5.8e-120) {
tmp = (b - (a / (c / d))) / c;
} else if (d <= 2.25e+49) {
tmp = t_0;
} else {
tmp = fma((c / hypot(c, d)), (b / d), (a * ((d / hypot(d, c)) / -hypot(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 (d <= -5.4e+81) tmp = Float64(Float64(Float64(b * Float64(c / d)) - a) / d); elseif (d <= -3.1e-32) tmp = t_0; elseif (d <= 5.8e-120) tmp = Float64(Float64(b - Float64(a / Float64(c / d))) / c); elseif (d <= 2.25e+49) tmp = t_0; else tmp = fma(Float64(c / hypot(c, d)), Float64(b / d), Float64(a * Float64(Float64(d / hypot(d, c)) / Float64(-hypot(d, c))))); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -5.4e+81], N[(N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, -3.1e-32], t$95$0, If[LessEqual[d, 5.8e-120], N[(N[(b - N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 2.25e+49], t$95$0, N[(N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b / d), $MachinePrecision] + N[(a * N[(N[(d / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision] / (-N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{if}\;d \leq -5.4 \cdot 10^{+81}:\\
\;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\
\mathbf{elif}\;d \leq -3.1 \cdot 10^{-32}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 5.8 \cdot 10^{-120}:\\
\;\;\;\;\frac{b - \frac{a}{\frac{c}{d}}}{c}\\
\mathbf{elif}\;d \leq 2.25 \cdot 10^{+49}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{d}, a \cdot \frac{\frac{d}{\mathsf{hypot}\left(d, c\right)}}{-\mathsf{hypot}\left(d, c\right)}\right)\\
\end{array}
\end{array}
if d < -5.3999999999999999e81Initial program 39.6%
Taylor expanded in c around 0 68.5%
+-commutative68.5%
mul-1-neg68.5%
unsub-neg68.5%
unpow268.5%
associate-/r*72.6%
div-sub72.6%
associate-/l*79.3%
Simplified79.3%
if -5.3999999999999999e81 < d < -3.10000000000000011e-32 or 5.8e-120 < d < 2.24999999999999991e49Initial program 83.8%
if -3.10000000000000011e-32 < d < 5.8e-120Initial program 73.3%
Taylor expanded in c around inf 93.0%
remove-double-neg93.0%
mul-1-neg93.0%
neg-mul-193.0%
distribute-lft-in93.0%
distribute-lft-in93.0%
mul-1-neg93.0%
unsub-neg93.0%
neg-mul-193.0%
mul-1-neg93.0%
remove-double-neg93.0%
associate-/l*93.0%
Simplified93.0%
clear-num92.9%
un-div-inv93.0%
Applied egg-rr93.0%
if 2.24999999999999991e49 < d Initial program 50.0%
div-sub50.0%
*-commutative50.0%
fma-define50.0%
add-sqr-sqrt50.0%
times-frac50.3%
fma-neg50.3%
fma-define50.3%
hypot-define50.3%
fma-define50.3%
hypot-define60.6%
associate-/l*67.1%
fma-define67.1%
add-sqr-sqrt67.1%
pow267.1%
Applied egg-rr67.1%
*-un-lft-identity67.1%
unpow267.1%
times-frac98.1%
hypot-undefine67.1%
+-commutative67.1%
hypot-define98.1%
hypot-undefine67.1%
+-commutative67.1%
hypot-define98.1%
Applied egg-rr98.1%
associate-*l/98.1%
*-lft-identity98.1%
Simplified98.1%
Taylor expanded in c around 0 90.6%
Final simplification87.9%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (- (* c b) (* d a))))
(if (<= d -5.2e+81)
(/ (- (* b (/ c d)) a) d)
(if (<= d -4e-32)
(/ t_0 (+ (* c c) (* d d)))
(if (<= d 3.6e-121)
(/ (- b (/ a (/ c d))) c)
(if (<= d 5.2e+118)
(/ t_0 (fma c c (* d d)))
(/ (- (/ b (/ d c)) a) d)))))))
double code(double a, double b, double c, double d) {
double t_0 = (c * b) - (d * a);
double tmp;
if (d <= -5.2e+81) {
tmp = ((b * (c / d)) - a) / d;
} else if (d <= -4e-32) {
tmp = t_0 / ((c * c) + (d * d));
} else if (d <= 3.6e-121) {
tmp = (b - (a / (c / d))) / c;
} else if (d <= 5.2e+118) {
tmp = t_0 / fma(c, c, (d * d));
} else {
tmp = ((b / (d / c)) - a) / d;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(c * b) - Float64(d * a)) tmp = 0.0 if (d <= -5.2e+81) tmp = Float64(Float64(Float64(b * Float64(c / d)) - a) / d); elseif (d <= -4e-32) tmp = Float64(t_0 / Float64(Float64(c * c) + Float64(d * d))); elseif (d <= 3.6e-121) tmp = Float64(Float64(b - Float64(a / Float64(c / d))) / c); elseif (d <= 5.2e+118) tmp = Float64(t_0 / fma(c, c, Float64(d * d))); else tmp = Float64(Float64(Float64(b / Float64(d / c)) - a) / d); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -5.2e+81], N[(N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, -4e-32], N[(t$95$0 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 3.6e-121], N[(N[(b - N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 5.2e+118], N[(t$95$0 / N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(b / N[(d / c), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := c \cdot b - d \cdot a\\
\mathbf{if}\;d \leq -5.2 \cdot 10^{+81}:\\
\;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\
\mathbf{elif}\;d \leq -4 \cdot 10^{-32}:\\
\;\;\;\;\frac{t\_0}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;d \leq 3.6 \cdot 10^{-121}:\\
\;\;\;\;\frac{b - \frac{a}{\frac{c}{d}}}{c}\\
\mathbf{elif}\;d \leq 5.2 \cdot 10^{+118}:\\
\;\;\;\;\frac{t\_0}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{b}{\frac{d}{c}} - a}{d}\\
\end{array}
\end{array}
if d < -5.19999999999999984e81Initial program 39.6%
Taylor expanded in c around 0 68.5%
+-commutative68.5%
mul-1-neg68.5%
unsub-neg68.5%
unpow268.5%
associate-/r*72.6%
div-sub72.6%
associate-/l*79.3%
Simplified79.3%
if -5.19999999999999984e81 < d < -4.00000000000000022e-32Initial program 86.2%
if -4.00000000000000022e-32 < d < 3.59999999999999984e-121Initial program 73.3%
Taylor expanded in c around inf 93.0%
remove-double-neg93.0%
mul-1-neg93.0%
neg-mul-193.0%
distribute-lft-in93.0%
distribute-lft-in93.0%
mul-1-neg93.0%
unsub-neg93.0%
neg-mul-193.0%
mul-1-neg93.0%
remove-double-neg93.0%
associate-/l*93.0%
Simplified93.0%
clear-num92.9%
un-div-inv93.0%
Applied egg-rr93.0%
if 3.59999999999999984e-121 < d < 5.20000000000000032e118Initial program 83.5%
fma-define83.5%
Simplified83.5%
if 5.20000000000000032e118 < d Initial program 37.7%
Taylor expanded in c around 0 74.2%
+-commutative74.2%
mul-1-neg74.2%
unsub-neg74.2%
unpow274.2%
associate-/r*76.7%
div-sub76.7%
associate-/l*86.2%
Simplified86.2%
clear-num86.2%
un-div-inv86.2%
Applied egg-rr86.2%
Final simplification86.9%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* c b) (* d a)) (+ (* c c) (* d d)))))
(if (<= d -2.6e+81)
(/ (- (* b (/ c d)) a) d)
(if (<= d -2.8e-32)
t_0
(if (<= d 3.2e-127)
(/ (- b (/ a (/ c d))) c)
(if (<= d 1.55e+117) t_0 (/ (- (/ b (/ d c)) a) d)))))))
double code(double a, double b, double c, double d) {
double t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
double tmp;
if (d <= -2.6e+81) {
tmp = ((b * (c / d)) - a) / d;
} else if (d <= -2.8e-32) {
tmp = t_0;
} else if (d <= 3.2e-127) {
tmp = (b - (a / (c / d))) / c;
} else if (d <= 1.55e+117) {
tmp = t_0;
} else {
tmp = ((b / (d / c)) - a) / d;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: tmp
t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d))
if (d <= (-2.6d+81)) then
tmp = ((b * (c / d)) - a) / d
else if (d <= (-2.8d-32)) then
tmp = t_0
else if (d <= 3.2d-127) then
tmp = (b - (a / (c / d))) / c
else if (d <= 1.55d+117) then
tmp = t_0
else
tmp = ((b / (d / c)) - a) / d
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 (d <= -2.6e+81) {
tmp = ((b * (c / d)) - a) / d;
} else if (d <= -2.8e-32) {
tmp = t_0;
} else if (d <= 3.2e-127) {
tmp = (b - (a / (c / d))) / c;
} else if (d <= 1.55e+117) {
tmp = t_0;
} else {
tmp = ((b / (d / c)) - a) / d;
}
return tmp;
}
def code(a, b, c, d): t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d)) tmp = 0 if d <= -2.6e+81: tmp = ((b * (c / d)) - a) / d elif d <= -2.8e-32: tmp = t_0 elif d <= 3.2e-127: tmp = (b - (a / (c / d))) / c elif d <= 1.55e+117: tmp = t_0 else: tmp = ((b / (d / c)) - a) / d 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 (d <= -2.6e+81) tmp = Float64(Float64(Float64(b * Float64(c / d)) - a) / d); elseif (d <= -2.8e-32) tmp = t_0; elseif (d <= 3.2e-127) tmp = Float64(Float64(b - Float64(a / Float64(c / d))) / c); elseif (d <= 1.55e+117) tmp = t_0; else tmp = Float64(Float64(Float64(b / Float64(d / c)) - a) / d); 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 (d <= -2.6e+81) tmp = ((b * (c / d)) - a) / d; elseif (d <= -2.8e-32) tmp = t_0; elseif (d <= 3.2e-127) tmp = (b - (a / (c / d))) / c; elseif (d <= 1.55e+117) tmp = t_0; else tmp = ((b / (d / c)) - a) / d; 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[d, -2.6e+81], N[(N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, -2.8e-32], t$95$0, If[LessEqual[d, 3.2e-127], N[(N[(b - N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 1.55e+117], t$95$0, N[(N[(N[(b / N[(d / c), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{if}\;d \leq -2.6 \cdot 10^{+81}:\\
\;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\
\mathbf{elif}\;d \leq -2.8 \cdot 10^{-32}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 3.2 \cdot 10^{-127}:\\
\;\;\;\;\frac{b - \frac{a}{\frac{c}{d}}}{c}\\
\mathbf{elif}\;d \leq 1.55 \cdot 10^{+117}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{b}{\frac{d}{c}} - a}{d}\\
\end{array}
\end{array}
if d < -2.59999999999999992e81Initial program 39.6%
Taylor expanded in c around 0 68.5%
+-commutative68.5%
mul-1-neg68.5%
unsub-neg68.5%
unpow268.5%
associate-/r*72.6%
div-sub72.6%
associate-/l*79.3%
Simplified79.3%
if -2.59999999999999992e81 < d < -2.7999999999999999e-32 or 3.20000000000000017e-127 < d < 1.54999999999999988e117Initial program 84.3%
if -2.7999999999999999e-32 < d < 3.20000000000000017e-127Initial program 73.3%
Taylor expanded in c around inf 93.0%
remove-double-neg93.0%
mul-1-neg93.0%
neg-mul-193.0%
distribute-lft-in93.0%
distribute-lft-in93.0%
mul-1-neg93.0%
unsub-neg93.0%
neg-mul-193.0%
mul-1-neg93.0%
remove-double-neg93.0%
associate-/l*93.0%
Simplified93.0%
clear-num92.9%
un-div-inv93.0%
Applied egg-rr93.0%
if 1.54999999999999988e117 < d Initial program 37.7%
Taylor expanded in c around 0 74.2%
+-commutative74.2%
mul-1-neg74.2%
unsub-neg74.2%
unpow274.2%
associate-/r*76.7%
div-sub76.7%
associate-/l*86.2%
Simplified86.2%
clear-num86.2%
un-div-inv86.2%
Applied egg-rr86.2%
Final simplification86.9%
(FPCore (a b c d) :precision binary64 (if (or (<= d -45000000000.0) (not (<= d 8e-6))) (/ (- (* b (/ c d)) a) d) (/ (- b (/ a (/ c d))) c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -45000000000.0) || !(d <= 8e-6)) {
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 ((d <= (-45000000000.0d0)) .or. (.not. (d <= 8d-6))) 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 ((d <= -45000000000.0) || !(d <= 8e-6)) {
tmp = ((b * (c / d)) - a) / d;
} else {
tmp = (b - (a / (c / d))) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -45000000000.0) or not (d <= 8e-6): 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 ((d <= -45000000000.0) || !(d <= 8e-6)) 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 ((d <= -45000000000.0) || ~((d <= 8e-6))) tmp = ((b * (c / d)) - a) / d; else tmp = (b - (a / (c / d))) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -45000000000.0], N[Not[LessEqual[d, 8e-6]], $MachinePrecision]], 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}\;d \leq -45000000000 \lor \neg \left(d \leq 8 \cdot 10^{-6}\right):\\
\;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - \frac{a}{\frac{c}{d}}}{c}\\
\end{array}
\end{array}
if d < -4.5e10 or 7.99999999999999964e-6 < d Initial program 55.0%
Taylor expanded in c around 0 71.6%
+-commutative71.6%
mul-1-neg71.6%
unsub-neg71.6%
unpow271.6%
associate-/r*74.0%
div-sub74.0%
associate-/l*78.2%
Simplified78.2%
if -4.5e10 < d < 7.99999999999999964e-6Initial program 74.1%
Taylor expanded in c around inf 84.8%
remove-double-neg84.8%
mul-1-neg84.8%
neg-mul-184.8%
distribute-lft-in84.8%
distribute-lft-in84.8%
mul-1-neg84.8%
unsub-neg84.8%
neg-mul-184.8%
mul-1-neg84.8%
remove-double-neg84.8%
associate-/l*84.7%
Simplified84.7%
clear-num84.7%
un-div-inv84.8%
Applied egg-rr84.8%
Final simplification81.6%
(FPCore (a b c d) :precision binary64 (if (or (<= d -1.6e+112) (not (<= d 6.4e+42))) (/ a (- d)) (/ (- b (/ a (/ c d))) c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -1.6e+112) || !(d <= 6.4e+42)) {
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 ((d <= (-1.6d+112)) .or. (.not. (d <= 6.4d+42))) 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 ((d <= -1.6e+112) || !(d <= 6.4e+42)) {
tmp = a / -d;
} else {
tmp = (b - (a / (c / d))) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -1.6e+112) or not (d <= 6.4e+42): tmp = a / -d else: tmp = (b - (a / (c / d))) / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -1.6e+112) || !(d <= 6.4e+42)) 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 ((d <= -1.6e+112) || ~((d <= 6.4e+42))) tmp = a / -d; else tmp = (b - (a / (c / d))) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -1.6e+112], N[Not[LessEqual[d, 6.4e+42]], $MachinePrecision]], 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}\;d \leq -1.6 \cdot 10^{+112} \lor \neg \left(d \leq 6.4 \cdot 10^{+42}\right):\\
\;\;\;\;\frac{a}{-d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - \frac{a}{\frac{c}{d}}}{c}\\
\end{array}
\end{array}
if d < -1.59999999999999993e112 or 6.40000000000000004e42 < d Initial program 47.6%
Taylor expanded in c around 0 66.4%
associate-*r/66.4%
neg-mul-166.4%
Simplified66.4%
if -1.59999999999999993e112 < d < 6.40000000000000004e42Initial program 75.0%
Taylor expanded in c around inf 76.2%
remove-double-neg76.2%
mul-1-neg76.2%
neg-mul-176.2%
distribute-lft-in76.2%
distribute-lft-in76.2%
mul-1-neg76.2%
unsub-neg76.2%
neg-mul-176.2%
mul-1-neg76.2%
remove-double-neg76.2%
associate-/l*76.8%
Simplified76.8%
clear-num76.8%
un-div-inv76.8%
Applied egg-rr76.8%
Final simplification72.9%
(FPCore (a b c d) :precision binary64 (if (or (<= d -2.5e+112) (not (<= d 5.8e+41))) (/ a (- d)) (/ (- b (* a (/ d c))) c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -2.5e+112) || !(d <= 5.8e+41)) {
tmp = a / -d;
} else {
tmp = (b - (a * (d / c))) / c;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if ((d <= (-2.5d+112)) .or. (.not. (d <= 5.8d+41))) then
tmp = a / -d
else
tmp = (b - (a * (d / c))) / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -2.5e+112) || !(d <= 5.8e+41)) {
tmp = a / -d;
} else {
tmp = (b - (a * (d / c))) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -2.5e+112) or not (d <= 5.8e+41): tmp = a / -d else: tmp = (b - (a * (d / c))) / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -2.5e+112) || !(d <= 5.8e+41)) tmp = Float64(a / Float64(-d)); else tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -2.5e+112) || ~((d <= 5.8e+41))) tmp = a / -d; else tmp = (b - (a * (d / c))) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -2.5e+112], N[Not[LessEqual[d, 5.8e+41]], $MachinePrecision]], N[(a / (-d)), $MachinePrecision], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -2.5 \cdot 10^{+112} \lor \neg \left(d \leq 5.8 \cdot 10^{+41}\right):\\
\;\;\;\;\frac{a}{-d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\
\end{array}
\end{array}
if d < -2.5e112 or 5.79999999999999977e41 < d Initial program 47.6%
Taylor expanded in c around 0 66.4%
associate-*r/66.4%
neg-mul-166.4%
Simplified66.4%
if -2.5e112 < d < 5.79999999999999977e41Initial program 75.0%
Taylor expanded in c around inf 76.2%
remove-double-neg76.2%
mul-1-neg76.2%
neg-mul-176.2%
distribute-lft-in76.2%
distribute-lft-in76.2%
mul-1-neg76.2%
unsub-neg76.2%
neg-mul-176.2%
mul-1-neg76.2%
remove-double-neg76.2%
associate-/l*76.8%
Simplified76.8%
Final simplification72.9%
(FPCore (a b c d) :precision binary64 (if (<= d -28000000000.0) (/ (- (* b (/ c d)) a) d) (if (<= d 4.1e-12) (/ (- b (/ a (/ c d))) c) (/ (- (/ b (/ d c)) a) d))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -28000000000.0) {
tmp = ((b * (c / d)) - a) / d;
} else if (d <= 4.1e-12) {
tmp = (b - (a / (c / d))) / c;
} else {
tmp = ((b / (d / c)) - a) / d;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (d <= (-28000000000.0d0)) then
tmp = ((b * (c / d)) - a) / d
else if (d <= 4.1d-12) then
tmp = (b - (a / (c / d))) / c
else
tmp = ((b / (d / c)) - a) / d
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (d <= -28000000000.0) {
tmp = ((b * (c / d)) - a) / d;
} else if (d <= 4.1e-12) {
tmp = (b - (a / (c / d))) / c;
} else {
tmp = ((b / (d / c)) - a) / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -28000000000.0: tmp = ((b * (c / d)) - a) / d elif d <= 4.1e-12: tmp = (b - (a / (c / d))) / c else: tmp = ((b / (d / c)) - a) / d return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -28000000000.0) tmp = Float64(Float64(Float64(b * Float64(c / d)) - a) / d); elseif (d <= 4.1e-12) tmp = Float64(Float64(b - Float64(a / Float64(c / d))) / c); else tmp = Float64(Float64(Float64(b / Float64(d / c)) - a) / d); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= -28000000000.0) tmp = ((b * (c / d)) - a) / d; elseif (d <= 4.1e-12) tmp = (b - (a / (c / d))) / c; else tmp = ((b / (d / c)) - a) / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -28000000000.0], N[(N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, 4.1e-12], N[(N[(b - N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], N[(N[(N[(b / N[(d / c), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -28000000000:\\
\;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\
\mathbf{elif}\;d \leq 4.1 \cdot 10^{-12}:\\
\;\;\;\;\frac{b - \frac{a}{\frac{c}{d}}}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{b}{\frac{d}{c}} - a}{d}\\
\end{array}
\end{array}
if d < -2.8e10Initial program 53.6%
Taylor expanded in c around 0 70.5%
+-commutative70.5%
mul-1-neg70.5%
unsub-neg70.5%
unpow270.5%
associate-/r*73.6%
div-sub73.6%
associate-/l*77.4%
Simplified77.4%
if -2.8e10 < d < 4.0999999999999999e-12Initial program 74.1%
Taylor expanded in c around inf 84.8%
remove-double-neg84.8%
mul-1-neg84.8%
neg-mul-184.8%
distribute-lft-in84.8%
distribute-lft-in84.8%
mul-1-neg84.8%
unsub-neg84.8%
neg-mul-184.8%
mul-1-neg84.8%
remove-double-neg84.8%
associate-/l*84.7%
Simplified84.7%
clear-num84.7%
un-div-inv84.8%
Applied egg-rr84.8%
if 4.0999999999999999e-12 < d Initial program 56.3%
Taylor expanded in c around 0 72.7%
+-commutative72.7%
mul-1-neg72.7%
unsub-neg72.7%
unpow272.7%
associate-/r*74.4%
div-sub74.4%
associate-/l*79.0%
Simplified79.0%
clear-num79.0%
un-div-inv79.1%
Applied egg-rr79.1%
(FPCore (a b c d) :precision binary64 (if (or (<= d -8.5e+94) (not (<= d 1.15e-41))) (/ a (- d)) (/ b c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -8.5e+94) || !(d <= 1.15e-41)) {
tmp = a / -d;
} else {
tmp = b / c;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if ((d <= (-8.5d+94)) .or. (.not. (d <= 1.15d-41))) then
tmp = a / -d
else
tmp = b / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -8.5e+94) || !(d <= 1.15e-41)) {
tmp = a / -d;
} else {
tmp = b / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -8.5e+94) or not (d <= 1.15e-41): tmp = a / -d else: tmp = b / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -8.5e+94) || !(d <= 1.15e-41)) tmp = Float64(a / Float64(-d)); else tmp = Float64(b / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -8.5e+94) || ~((d <= 1.15e-41))) tmp = a / -d; else tmp = b / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -8.5e+94], N[Not[LessEqual[d, 1.15e-41]], $MachinePrecision]], N[(a / (-d)), $MachinePrecision], N[(b / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -8.5 \cdot 10^{+94} \lor \neg \left(d \leq 1.15 \cdot 10^{-41}\right):\\
\;\;\;\;\frac{a}{-d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if d < -8.50000000000000054e94 or 1.15000000000000005e-41 < d Initial program 52.0%
Taylor expanded in c around 0 64.0%
associate-*r/64.0%
neg-mul-164.0%
Simplified64.0%
if -8.50000000000000054e94 < d < 1.15000000000000005e-41Initial program 74.5%
Taylor expanded in c around inf 62.9%
Final simplification63.4%
(FPCore (a b c d) :precision binary64 (if (or (<= d -3.5e+212) (not (<= d 1.6e+93))) (/ a d) (/ b c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -3.5e+212) || !(d <= 1.6e+93)) {
tmp = a / d;
} else {
tmp = b / c;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if ((d <= (-3.5d+212)) .or. (.not. (d <= 1.6d+93))) then
tmp = a / d
else
tmp = b / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -3.5e+212) || !(d <= 1.6e+93)) {
tmp = a / d;
} else {
tmp = b / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -3.5e+212) or not (d <= 1.6e+93): tmp = a / d else: tmp = b / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -3.5e+212) || !(d <= 1.6e+93)) tmp = Float64(a / d); else tmp = Float64(b / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -3.5e+212) || ~((d <= 1.6e+93))) tmp = a / d; else tmp = b / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -3.5e+212], N[Not[LessEqual[d, 1.6e+93]], $MachinePrecision]], N[(a / d), $MachinePrecision], N[(b / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -3.5 \cdot 10^{+212} \lor \neg \left(d \leq 1.6 \cdot 10^{+93}\right):\\
\;\;\;\;\frac{a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if d < -3.49999999999999987e212 or 1.6000000000000001e93 < d Initial program 46.0%
Taylor expanded in c around 0 73.0%
+-commutative73.0%
mul-1-neg73.0%
unsub-neg73.0%
unpow273.0%
associate-/r*76.0%
div-sub76.0%
associate-/l*85.2%
Simplified85.2%
clear-num85.2%
un-div-inv85.2%
Applied egg-rr85.2%
div-inv85.1%
add-log-exp37.0%
add-log-exp85.1%
div-inv85.1%
clear-num85.1%
fma-neg85.1%
add-sqr-sqrt48.7%
sqrt-unprod57.5%
sqr-neg57.5%
sqrt-unprod21.0%
add-sqr-sqrt49.6%
Applied egg-rr49.6%
Taylor expanded in b around 0 36.6%
if -3.49999999999999987e212 < d < 1.6000000000000001e93Initial program 71.0%
Taylor expanded in c around inf 53.4%
Final simplification49.2%
(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 64.8%
Taylor expanded in c around 0 46.7%
+-commutative46.7%
mul-1-neg46.7%
unsub-neg46.7%
unpow246.7%
associate-/r*49.9%
div-sub51.1%
associate-/l*53.2%
Simplified53.2%
clear-num53.0%
un-div-inv53.0%
Applied egg-rr53.0%
div-inv52.9%
add-log-exp19.8%
add-log-exp52.9%
div-inv52.9%
clear-num53.1%
fma-neg53.1%
add-sqr-sqrt25.3%
sqrt-unprod33.9%
sqr-neg33.9%
sqrt-unprod14.7%
add-sqr-sqrt27.9%
Applied egg-rr27.9%
Taylor expanded in b around 0 13.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 2024097
(FPCore (a b c d)
:name "Complex division, imag part"
:precision binary64
:alt
(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))))