
(FPCore (a b c d) :precision binary64 (/ (- (* b c) (* a d)) (+ (* c c) (* d d))))
double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = ((b * c) - (a * d)) / ((c * c) + (d * d))
end function
public static double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
def code(a, b, c, d): return ((b * c) - (a * d)) / ((c * c) + (d * d))
function code(a, b, c, d) return Float64(Float64(Float64(b * c) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d))) end
function tmp = code(a, b, c, d) tmp = ((b * c) - (a * d)) / ((c * c) + (d * d)); end
code[a_, b_, c_, d_] := N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b c d) :precision binary64 (/ (- (* b c) (* a d)) (+ (* c c) (* d d))))
double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = ((b * c) - (a * d)) / ((c * c) + (d * d))
end function
public static double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
def code(a, b, c, d): return ((b * c) - (a * d)) / ((c * c) + (d * d))
function code(a, b, c, d) return Float64(Float64(Float64(b * c) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d))) end
function tmp = code(a, b, c, d) tmp = ((b * c) - (a * d)) / ((c * c) + (d * d)); end
code[a_, b_, c_, d_] := N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}
\end{array}
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ c (hypot c d)))
(t_1 (/ b (hypot c d)))
(t_2 (fma t_0 t_1 (* a (/ (- d) (pow (hypot c d) 2.0))))))
(if (<= d -1.55e+140)
(fma t_0 t_1 (/ a (- d)))
(if (<= d -7.5e-124)
t_2
(if (<= d 9.5e-168)
(/ (- b (/ (* d a) c)) c)
(if (<= d 1.02e+155)
t_2
(* (/ 1.0 (+ d (* 0.5 (* c (/ c d))))) (- (* b (/ c d)) a))))))))
double code(double a, double b, double c, double d) {
double t_0 = c / hypot(c, d);
double t_1 = b / hypot(c, d);
double t_2 = fma(t_0, t_1, (a * (-d / pow(hypot(c, d), 2.0))));
double tmp;
if (d <= -1.55e+140) {
tmp = fma(t_0, t_1, (a / -d));
} else if (d <= -7.5e-124) {
tmp = t_2;
} else if (d <= 9.5e-168) {
tmp = (b - ((d * a) / c)) / c;
} else if (d <= 1.02e+155) {
tmp = t_2;
} else {
tmp = (1.0 / (d + (0.5 * (c * (c / d))))) * ((b * (c / d)) - a);
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(c / hypot(c, d)) t_1 = Float64(b / hypot(c, d)) t_2 = fma(t_0, t_1, Float64(a * Float64(Float64(-d) / (hypot(c, d) ^ 2.0)))) tmp = 0.0 if (d <= -1.55e+140) tmp = fma(t_0, t_1, Float64(a / Float64(-d))); elseif (d <= -7.5e-124) tmp = t_2; elseif (d <= 9.5e-168) tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c); elseif (d <= 1.02e+155) tmp = t_2; else tmp = Float64(Float64(1.0 / Float64(d + Float64(0.5 * Float64(c * Float64(c / d))))) * Float64(Float64(b * Float64(c / d)) - a)); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$0 * t$95$1 + N[(a * N[((-d) / N[Power[N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -1.55e+140], N[(t$95$0 * t$95$1 + N[(a / (-d)), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -7.5e-124], t$95$2, If[LessEqual[d, 9.5e-168], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 1.02e+155], t$95$2, N[(N[(1.0 / N[(d + N[(0.5 * N[(c * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c}{\mathsf{hypot}\left(c, d\right)}\\
t_1 := \frac{b}{\mathsf{hypot}\left(c, d\right)}\\
t_2 := \mathsf{fma}\left(t\_0, t\_1, a \cdot \frac{-d}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\right)\\
\mathbf{if}\;d \leq -1.55 \cdot 10^{+140}:\\
\;\;\;\;\mathsf{fma}\left(t\_0, t\_1, \frac{a}{-d}\right)\\
\mathbf{elif}\;d \leq -7.5 \cdot 10^{-124}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;d \leq 9.5 \cdot 10^{-168}:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\
\mathbf{elif}\;d \leq 1.02 \cdot 10^{+155}:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{d + 0.5 \cdot \left(c \cdot \frac{c}{d}\right)} \cdot \left(b \cdot \frac{c}{d} - a\right)\\
\end{array}
\end{array}
if d < -1.55e140Initial program 28.5%
div-sub28.5%
*-commutative28.5%
add-sqr-sqrt28.5%
times-frac28.9%
fma-neg28.9%
hypot-define28.9%
hypot-define41.4%
associate-/l*47.4%
add-sqr-sqrt47.4%
pow247.4%
hypot-define47.4%
Applied egg-rr47.4%
Taylor expanded in d around inf 100.0%
if -1.55e140 < d < -7.4999999999999996e-124 or 9.49999999999999918e-168 < d < 1.02e155Initial program 75.3%
div-sub75.3%
*-commutative75.3%
add-sqr-sqrt75.3%
times-frac79.5%
fma-neg79.5%
hypot-define79.5%
hypot-define92.0%
associate-/l*95.5%
add-sqr-sqrt95.5%
pow295.5%
hypot-define95.5%
Applied egg-rr95.5%
if -7.4999999999999996e-124 < d < 9.49999999999999918e-168Initial program 61.4%
Taylor expanded in c around inf 90.3%
associate-*r/90.3%
mul-1-neg90.3%
distribute-rgt-neg-out90.3%
Simplified90.3%
if 1.02e155 < d Initial program 19.6%
*-un-lft-identity19.6%
add-sqr-sqrt19.6%
times-frac19.6%
hypot-define19.6%
hypot-define43.9%
Applied egg-rr43.9%
Taylor expanded in c around 0 78.0%
+-commutative78.0%
mul-1-neg78.0%
sub-neg78.0%
associate-/l*89.6%
Simplified89.6%
Taylor expanded in c around 0 76.8%
unpow276.8%
*-un-lft-identity76.8%
times-frac89.8%
Applied egg-rr89.8%
Final simplification94.1%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (- (* c b) (* d a))))
(if (<= (/ t_0 (+ (* c c) (* d d))) 1e+206)
(* (/ 1.0 (hypot c d)) (/ t_0 (hypot c d)))
(fma (/ c (hypot c d)) (/ b (hypot c d)) (/ a (- d))))))
double code(double a, double b, double c, double d) {
double t_0 = (c * b) - (d * a);
double tmp;
if ((t_0 / ((c * c) + (d * d))) <= 1e+206) {
tmp = (1.0 / hypot(c, d)) * (t_0 / hypot(c, d));
} else {
tmp = fma((c / hypot(c, d)), (b / hypot(c, d)), (a / -d));
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(c * b) - Float64(d * a)) tmp = 0.0 if (Float64(t_0 / Float64(Float64(c * c) + Float64(d * d))) <= 1e+206) tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(t_0 / hypot(c, d))); else tmp = fma(Float64(c / hypot(c, d)), Float64(b / hypot(c, d)), Float64(a / Float64(-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[N[(t$95$0 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1e+206], N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] + N[(a / (-d)), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := c \cdot b - d \cdot a\\
\mathbf{if}\;\frac{t\_0}{c \cdot c + d \cdot d} \leq 10^{+206}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{t\_0}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, \frac{a}{-d}\right)\\
\end{array}
\end{array}
if (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 1e206Initial program 75.5%
*-un-lft-identity75.5%
add-sqr-sqrt75.5%
times-frac75.6%
hypot-define75.6%
hypot-define95.0%
Applied egg-rr95.0%
if 1e206 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 15.4%
div-sub14.0%
*-commutative14.0%
add-sqr-sqrt14.0%
times-frac18.6%
fma-neg18.6%
hypot-define18.6%
hypot-define43.9%
associate-/l*53.0%
add-sqr-sqrt53.0%
pow253.0%
hypot-define53.0%
Applied egg-rr53.0%
Taylor expanded in d around inf 71.6%
Final simplification87.7%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (* (/ 1.0 (hypot c d)) (/ (- (* c b) (* d a)) (hypot c d))))
(t_1 (- (* b (/ c d)) a)))
(if (<= d -2.8e+100)
(/ t_1 d)
(if (<= d -4.5e-163)
t_0
(if (<= d 8e-170)
(/ (- b (* a (/ d c))) c)
(if (<= d 4.7e+55)
t_0
(* (/ 1.0 (+ d (* 0.5 (* c (/ c d))))) t_1)))))))
double code(double a, double b, double c, double d) {
double t_0 = (1.0 / hypot(c, d)) * (((c * b) - (d * a)) / hypot(c, d));
double t_1 = (b * (c / d)) - a;
double tmp;
if (d <= -2.8e+100) {
tmp = t_1 / d;
} else if (d <= -4.5e-163) {
tmp = t_0;
} else if (d <= 8e-170) {
tmp = (b - (a * (d / c))) / c;
} else if (d <= 4.7e+55) {
tmp = t_0;
} else {
tmp = (1.0 / (d + (0.5 * (c * (c / d))))) * t_1;
}
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) - (d * a)) / Math.hypot(c, d));
double t_1 = (b * (c / d)) - a;
double tmp;
if (d <= -2.8e+100) {
tmp = t_1 / d;
} else if (d <= -4.5e-163) {
tmp = t_0;
} else if (d <= 8e-170) {
tmp = (b - (a * (d / c))) / c;
} else if (d <= 4.7e+55) {
tmp = t_0;
} else {
tmp = (1.0 / (d + (0.5 * (c * (c / d))))) * t_1;
}
return tmp;
}
def code(a, b, c, d): t_0 = (1.0 / math.hypot(c, d)) * (((c * b) - (d * a)) / math.hypot(c, d)) t_1 = (b * (c / d)) - a tmp = 0 if d <= -2.8e+100: tmp = t_1 / d elif d <= -4.5e-163: tmp = t_0 elif d <= 8e-170: tmp = (b - (a * (d / c))) / c elif d <= 4.7e+55: tmp = t_0 else: tmp = (1.0 / (d + (0.5 * (c * (c / d))))) * t_1 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(1.0 / hypot(c, d)) * Float64(Float64(Float64(c * b) - Float64(d * a)) / hypot(c, d))) t_1 = Float64(Float64(b * Float64(c / d)) - a) tmp = 0.0 if (d <= -2.8e+100) tmp = Float64(t_1 / d); elseif (d <= -4.5e-163) tmp = t_0; elseif (d <= 8e-170) tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c); elseif (d <= 4.7e+55) tmp = t_0; else tmp = Float64(Float64(1.0 / Float64(d + Float64(0.5 * Float64(c * Float64(c / d))))) * t_1); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (1.0 / hypot(c, d)) * (((c * b) - (d * a)) / hypot(c, d)); t_1 = (b * (c / d)) - a; tmp = 0.0; if (d <= -2.8e+100) tmp = t_1 / d; elseif (d <= -4.5e-163) tmp = t_0; elseif (d <= 8e-170) tmp = (b - (a * (d / c))) / c; elseif (d <= 4.7e+55) tmp = t_0; else tmp = (1.0 / (d + (0.5 * (c * (c / d))))) * t_1; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]}, If[LessEqual[d, -2.8e+100], N[(t$95$1 / d), $MachinePrecision], If[LessEqual[d, -4.5e-163], t$95$0, If[LessEqual[d, 8e-170], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 4.7e+55], t$95$0, N[(N[(1.0 / N[(d + N[(0.5 * N[(c * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{c \cdot b - d \cdot a}{\mathsf{hypot}\left(c, d\right)}\\
t_1 := b \cdot \frac{c}{d} - a\\
\mathbf{if}\;d \leq -2.8 \cdot 10^{+100}:\\
\;\;\;\;\frac{t\_1}{d}\\
\mathbf{elif}\;d \leq -4.5 \cdot 10^{-163}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 8 \cdot 10^{-170}:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\
\mathbf{elif}\;d \leq 4.7 \cdot 10^{+55}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{d + 0.5 \cdot \left(c \cdot \frac{c}{d}\right)} \cdot t\_1\\
\end{array}
\end{array}
if d < -2.7999999999999998e100Initial program 30.5%
div-sub30.5%
*-commutative30.5%
add-sqr-sqrt30.5%
times-frac32.9%
fma-neg32.9%
hypot-define32.9%
hypot-define44.4%
associate-/l*52.0%
add-sqr-sqrt52.0%
pow252.0%
hypot-define52.0%
Applied egg-rr52.0%
Taylor expanded in d around inf 91.5%
associate-/l*97.9%
Simplified97.9%
if -2.7999999999999998e100 < d < -4.4999999999999997e-163 or 7.99999999999999987e-170 < d < 4.7000000000000001e55Initial program 74.9%
*-un-lft-identity74.9%
add-sqr-sqrt74.9%
times-frac75.0%
hypot-define75.0%
hypot-define87.8%
Applied egg-rr87.8%
if -4.4999999999999997e-163 < d < 7.99999999999999987e-170Initial program 62.3%
Taylor expanded in c around inf 92.4%
mul-1-neg92.4%
unsub-neg92.4%
associate-/l*93.9%
Simplified93.9%
if 4.7000000000000001e55 < d Initial program 40.6%
*-un-lft-identity40.6%
add-sqr-sqrt40.6%
times-frac40.5%
hypot-define40.5%
hypot-define57.6%
Applied egg-rr57.6%
Taylor expanded in c around 0 77.9%
+-commutative77.9%
mul-1-neg77.9%
sub-neg77.9%
associate-/l*85.3%
Simplified85.3%
Taylor expanded in c around 0 78.9%
unpow278.9%
*-un-lft-identity78.9%
times-frac87.3%
Applied egg-rr87.3%
Final simplification91.0%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (- (* c b) (* d a))))
(if (<= d -6.2e+86)
(/ (- (/ c (/ d b)) a) d)
(if (<= d -1.1e-115)
(/ t_0 (+ (* c c) (* d d)))
(if (<= d 8.4e-148)
(/ (- b (/ (* d a) c)) c)
(if (<= d 7.7e+105)
(* t_0 (/ 1.0 (pow (hypot c d) 2.0)))
(* (/ 1.0 (+ d (* 0.5 (* c (/ c d))))) (- (* b (/ c d)) a))))))))
double code(double a, double b, double c, double d) {
double t_0 = (c * b) - (d * a);
double tmp;
if (d <= -6.2e+86) {
tmp = ((c / (d / b)) - a) / d;
} else if (d <= -1.1e-115) {
tmp = t_0 / ((c * c) + (d * d));
} else if (d <= 8.4e-148) {
tmp = (b - ((d * a) / c)) / c;
} else if (d <= 7.7e+105) {
tmp = t_0 * (1.0 / pow(hypot(c, d), 2.0));
} else {
tmp = (1.0 / (d + (0.5 * (c * (c / d))))) * ((b * (c / d)) - a);
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = (c * b) - (d * a);
double tmp;
if (d <= -6.2e+86) {
tmp = ((c / (d / b)) - a) / d;
} else if (d <= -1.1e-115) {
tmp = t_0 / ((c * c) + (d * d));
} else if (d <= 8.4e-148) {
tmp = (b - ((d * a) / c)) / c;
} else if (d <= 7.7e+105) {
tmp = t_0 * (1.0 / Math.pow(Math.hypot(c, d), 2.0));
} else {
tmp = (1.0 / (d + (0.5 * (c * (c / d))))) * ((b * (c / d)) - a);
}
return tmp;
}
def code(a, b, c, d): t_0 = (c * b) - (d * a) tmp = 0 if d <= -6.2e+86: tmp = ((c / (d / b)) - a) / d elif d <= -1.1e-115: tmp = t_0 / ((c * c) + (d * d)) elif d <= 8.4e-148: tmp = (b - ((d * a) / c)) / c elif d <= 7.7e+105: tmp = t_0 * (1.0 / math.pow(math.hypot(c, d), 2.0)) else: tmp = (1.0 / (d + (0.5 * (c * (c / d))))) * ((b * (c / d)) - a) return tmp
function code(a, b, c, d) t_0 = Float64(Float64(c * b) - Float64(d * a)) tmp = 0.0 if (d <= -6.2e+86) tmp = Float64(Float64(Float64(c / Float64(d / b)) - a) / d); elseif (d <= -1.1e-115) tmp = Float64(t_0 / Float64(Float64(c * c) + Float64(d * d))); elseif (d <= 8.4e-148) tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c); elseif (d <= 7.7e+105) tmp = Float64(t_0 * Float64(1.0 / (hypot(c, d) ^ 2.0))); else tmp = Float64(Float64(1.0 / Float64(d + Float64(0.5 * Float64(c * Float64(c / d))))) * Float64(Float64(b * Float64(c / d)) - a)); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (c * b) - (d * a); tmp = 0.0; if (d <= -6.2e+86) tmp = ((c / (d / b)) - a) / d; elseif (d <= -1.1e-115) tmp = t_0 / ((c * c) + (d * d)); elseif (d <= 8.4e-148) tmp = (b - ((d * a) / c)) / c; elseif (d <= 7.7e+105) tmp = t_0 * (1.0 / (hypot(c, d) ^ 2.0)); else tmp = (1.0 / (d + (0.5 * (c * (c / d))))) * ((b * (c / d)) - a); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -6.2e+86], N[(N[(N[(c / N[(d / b), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, -1.1e-115], N[(t$95$0 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 8.4e-148], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 7.7e+105], N[(t$95$0 * N[(1.0 / N[Power[N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(d + N[(0.5 * N[(c * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := c \cdot b - d \cdot a\\
\mathbf{if}\;d \leq -6.2 \cdot 10^{+86}:\\
\;\;\;\;\frac{\frac{c}{\frac{d}{b}} - a}{d}\\
\mathbf{elif}\;d \leq -1.1 \cdot 10^{-115}:\\
\;\;\;\;\frac{t\_0}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;d \leq 8.4 \cdot 10^{-148}:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\
\mathbf{elif}\;d \leq 7.7 \cdot 10^{+105}:\\
\;\;\;\;t\_0 \cdot \frac{1}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{d + 0.5 \cdot \left(c \cdot \frac{c}{d}\right)} \cdot \left(b \cdot \frac{c}{d} - a\right)\\
\end{array}
\end{array}
if d < -6.2000000000000004e86Initial program 32.8%
Taylor expanded in c around 0 82.1%
+-commutative82.1%
mul-1-neg82.1%
unsub-neg82.1%
unpow282.1%
associate-/r*86.9%
div-sub86.9%
*-commutative86.9%
associate-/l*92.5%
Simplified92.5%
clear-num92.4%
un-div-inv92.5%
Applied egg-rr92.5%
if -6.2000000000000004e86 < d < -1.1e-115Initial program 82.1%
if -1.1e-115 < d < 8.4000000000000001e-148Initial program 61.5%
Taylor expanded in c around inf 90.7%
associate-*r/90.7%
mul-1-neg90.7%
distribute-rgt-neg-out90.7%
Simplified90.7%
if 8.4000000000000001e-148 < d < 7.70000000000000011e105Initial program 79.1%
clear-num79.0%
associate-/r/79.3%
add-sqr-sqrt79.3%
pow279.3%
hypot-define79.3%
Applied egg-rr79.3%
if 7.70000000000000011e105 < d Initial program 31.6%
*-un-lft-identity31.6%
add-sqr-sqrt31.6%
times-frac31.6%
hypot-define31.6%
hypot-define51.2%
Applied egg-rr51.2%
Taylor expanded in c around 0 76.6%
+-commutative76.6%
mul-1-neg76.6%
sub-neg76.6%
associate-/l*85.1%
Simplified85.1%
Taylor expanded in c around 0 75.8%
unpow275.8%
*-un-lft-identity75.8%
times-frac85.5%
Applied egg-rr85.5%
Final simplification86.7%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* c b) (* d a)) (+ (* c c) (* d d)))))
(if (<= d -7.5e+80)
(/ (- (/ c (/ d b)) a) d)
(if (<= d -4.5e-120)
t_0
(if (<= d 9.2e-142)
(/ (- b (/ (* d a) c)) c)
(if (<= d 4.5e+55)
t_0
(* (/ 1.0 (+ d (* 0.5 (* c (/ c d))))) (- (* b (/ c d)) a))))))))
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 <= -7.5e+80) {
tmp = ((c / (d / b)) - a) / d;
} else if (d <= -4.5e-120) {
tmp = t_0;
} else if (d <= 9.2e-142) {
tmp = (b - ((d * a) / c)) / c;
} else if (d <= 4.5e+55) {
tmp = t_0;
} else {
tmp = (1.0 / (d + (0.5 * (c * (c / d))))) * ((b * (c / d)) - a);
}
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 <= (-7.5d+80)) then
tmp = ((c / (d / b)) - a) / d
else if (d <= (-4.5d-120)) then
tmp = t_0
else if (d <= 9.2d-142) then
tmp = (b - ((d * a) / c)) / c
else if (d <= 4.5d+55) then
tmp = t_0
else
tmp = (1.0d0 / (d + (0.5d0 * (c * (c / d))))) * ((b * (c / d)) - a)
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 <= -7.5e+80) {
tmp = ((c / (d / b)) - a) / d;
} else if (d <= -4.5e-120) {
tmp = t_0;
} else if (d <= 9.2e-142) {
tmp = (b - ((d * a) / c)) / c;
} else if (d <= 4.5e+55) {
tmp = t_0;
} else {
tmp = (1.0 / (d + (0.5 * (c * (c / d))))) * ((b * (c / d)) - a);
}
return tmp;
}
def code(a, b, c, d): t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d)) tmp = 0 if d <= -7.5e+80: tmp = ((c / (d / b)) - a) / d elif d <= -4.5e-120: tmp = t_0 elif d <= 9.2e-142: tmp = (b - ((d * a) / c)) / c elif d <= 4.5e+55: tmp = t_0 else: tmp = (1.0 / (d + (0.5 * (c * (c / d))))) * ((b * (c / d)) - a) 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 <= -7.5e+80) tmp = Float64(Float64(Float64(c / Float64(d / b)) - a) / d); elseif (d <= -4.5e-120) tmp = t_0; elseif (d <= 9.2e-142) tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c); elseif (d <= 4.5e+55) tmp = t_0; else tmp = Float64(Float64(1.0 / Float64(d + Float64(0.5 * Float64(c * Float64(c / d))))) * Float64(Float64(b * Float64(c / d)) - a)); 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 <= -7.5e+80) tmp = ((c / (d / b)) - a) / d; elseif (d <= -4.5e-120) tmp = t_0; elseif (d <= 9.2e-142) tmp = (b - ((d * a) / c)) / c; elseif (d <= 4.5e+55) tmp = t_0; else tmp = (1.0 / (d + (0.5 * (c * (c / d))))) * ((b * (c / d)) - a); 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, -7.5e+80], N[(N[(N[(c / N[(d / b), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, -4.5e-120], t$95$0, If[LessEqual[d, 9.2e-142], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 4.5e+55], t$95$0, N[(N[(1.0 / N[(d + N[(0.5 * N[(c * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $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 -7.5 \cdot 10^{+80}:\\
\;\;\;\;\frac{\frac{c}{\frac{d}{b}} - a}{d}\\
\mathbf{elif}\;d \leq -4.5 \cdot 10^{-120}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 9.2 \cdot 10^{-142}:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\
\mathbf{elif}\;d \leq 4.5 \cdot 10^{+55}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{d + 0.5 \cdot \left(c \cdot \frac{c}{d}\right)} \cdot \left(b \cdot \frac{c}{d} - a\right)\\
\end{array}
\end{array}
if d < -7.49999999999999994e80Initial program 32.8%
Taylor expanded in c around 0 82.1%
+-commutative82.1%
mul-1-neg82.1%
unsub-neg82.1%
unpow282.1%
associate-/r*86.9%
div-sub86.9%
*-commutative86.9%
associate-/l*92.5%
Simplified92.5%
clear-num92.4%
un-div-inv92.5%
Applied egg-rr92.5%
if -7.49999999999999994e80 < d < -4.5e-120 or 9.20000000000000009e-142 < d < 4.49999999999999998e55Initial program 78.8%
if -4.5e-120 < d < 9.20000000000000009e-142Initial program 61.5%
Taylor expanded in c around inf 90.7%
associate-*r/90.7%
mul-1-neg90.7%
distribute-rgt-neg-out90.7%
Simplified90.7%
if 4.49999999999999998e55 < d Initial program 40.6%
*-un-lft-identity40.6%
add-sqr-sqrt40.6%
times-frac40.5%
hypot-define40.5%
hypot-define57.6%
Applied egg-rr57.6%
Taylor expanded in c around 0 77.9%
+-commutative77.9%
mul-1-neg77.9%
sub-neg77.9%
associate-/l*85.3%
Simplified85.3%
Taylor expanded in c around 0 78.9%
unpow278.9%
*-un-lft-identity78.9%
times-frac87.3%
Applied egg-rr87.3%
Final simplification86.6%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* c b) (* d a)) (+ (* c c) (* d d)))))
(if (<= d -1.22e+82)
(/ (- (/ c (/ d b)) a) d)
(if (<= d -4.5e-122)
t_0
(if (<= d 2.5e-145)
(/ (- b (/ (* d a) c)) c)
(if (<= d 2.1e+143) t_0 (/ (- (* b (/ c d)) 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 <= -1.22e+82) {
tmp = ((c / (d / b)) - a) / d;
} else if (d <= -4.5e-122) {
tmp = t_0;
} else if (d <= 2.5e-145) {
tmp = (b - ((d * a) / c)) / c;
} else if (d <= 2.1e+143) {
tmp = t_0;
} else {
tmp = ((b * (c / d)) - a) / d;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: tmp
t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d))
if (d <= (-1.22d+82)) then
tmp = ((c / (d / b)) - a) / d
else if (d <= (-4.5d-122)) then
tmp = t_0
else if (d <= 2.5d-145) then
tmp = (b - ((d * a) / c)) / c
else if (d <= 2.1d+143) then
tmp = t_0
else
tmp = ((b * (c / d)) - 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 <= -1.22e+82) {
tmp = ((c / (d / b)) - a) / d;
} else if (d <= -4.5e-122) {
tmp = t_0;
} else if (d <= 2.5e-145) {
tmp = (b - ((d * a) / c)) / c;
} else if (d <= 2.1e+143) {
tmp = t_0;
} else {
tmp = ((b * (c / d)) - a) / d;
}
return tmp;
}
def code(a, b, c, d): t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d)) tmp = 0 if d <= -1.22e+82: tmp = ((c / (d / b)) - a) / d elif d <= -4.5e-122: tmp = t_0 elif d <= 2.5e-145: tmp = (b - ((d * a) / c)) / c elif d <= 2.1e+143: tmp = t_0 else: tmp = ((b * (c / d)) - 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 <= -1.22e+82) tmp = Float64(Float64(Float64(c / Float64(d / b)) - a) / d); elseif (d <= -4.5e-122) tmp = t_0; elseif (d <= 2.5e-145) tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c); elseif (d <= 2.1e+143) tmp = t_0; 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 = ((c * b) - (d * a)) / ((c * c) + (d * d)); tmp = 0.0; if (d <= -1.22e+82) tmp = ((c / (d / b)) - a) / d; elseif (d <= -4.5e-122) tmp = t_0; elseif (d <= 2.5e-145) tmp = (b - ((d * a) / c)) / c; elseif (d <= 2.1e+143) tmp = t_0; else tmp = ((b * (c / d)) - 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, -1.22e+82], N[(N[(N[(c / N[(d / b), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, -4.5e-122], t$95$0, If[LessEqual[d, 2.5e-145], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 2.1e+143], t$95$0, N[(N[(N[(b * N[(c / d), $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 -1.22 \cdot 10^{+82}:\\
\;\;\;\;\frac{\frac{c}{\frac{d}{b}} - a}{d}\\
\mathbf{elif}\;d \leq -4.5 \cdot 10^{-122}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 2.5 \cdot 10^{-145}:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\
\mathbf{elif}\;d \leq 2.1 \cdot 10^{+143}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\
\end{array}
\end{array}
if d < -1.22000000000000008e82Initial program 32.8%
Taylor expanded in c around 0 82.1%
+-commutative82.1%
mul-1-neg82.1%
unsub-neg82.1%
unpow282.1%
associate-/r*86.9%
div-sub86.9%
*-commutative86.9%
associate-/l*92.5%
Simplified92.5%
clear-num92.4%
un-div-inv92.5%
Applied egg-rr92.5%
if -1.22000000000000008e82 < d < -4.4999999999999998e-122 or 2.4999999999999999e-145 < d < 2.09999999999999988e143Initial program 79.7%
if -4.4999999999999998e-122 < d < 2.4999999999999999e-145Initial program 61.5%
Taylor expanded in c around inf 90.7%
associate-*r/90.7%
mul-1-neg90.7%
distribute-rgt-neg-out90.7%
Simplified90.7%
if 2.09999999999999988e143 < d Initial program 24.5%
div-sub24.5%
*-commutative24.5%
add-sqr-sqrt24.5%
times-frac24.7%
fma-neg24.7%
hypot-define24.7%
hypot-define31.9%
associate-/l*43.6%
add-sqr-sqrt43.6%
pow243.6%
hypot-define43.6%
Applied egg-rr43.6%
Taylor expanded in d around inf 77.3%
associate-/l*87.3%
Simplified87.3%
Final simplification86.5%
(FPCore (a b c d) :precision binary64 (if (or (<= c -7.5e+89) (not (<= c 2400000000000.0))) (/ (- b (* a (/ d c))) c) (/ (- (* b (/ c d)) a) d)))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -7.5e+89) || !(c <= 2400000000000.0)) {
tmp = (b - (a * (d / c))) / c;
} else {
tmp = ((b * (c / d)) - a) / d;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if ((c <= (-7.5d+89)) .or. (.not. (c <= 2400000000000.0d0))) then
tmp = (b - (a * (d / c))) / c
else
tmp = ((b * (c / d)) - a) / d
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -7.5e+89) || !(c <= 2400000000000.0)) {
tmp = (b - (a * (d / c))) / c;
} else {
tmp = ((b * (c / d)) - a) / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -7.5e+89) or not (c <= 2400000000000.0): tmp = (b - (a * (d / c))) / c else: tmp = ((b * (c / d)) - a) / d return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -7.5e+89) || !(c <= 2400000000000.0)) tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c); else tmp = Float64(Float64(Float64(b * Float64(c / d)) - a) / d); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((c <= -7.5e+89) || ~((c <= 2400000000000.0))) tmp = (b - (a * (d / c))) / c; else tmp = ((b * (c / d)) - a) / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -7.5e+89], N[Not[LessEqual[c, 2400000000000.0]], $MachinePrecision]], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], N[(N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -7.5 \cdot 10^{+89} \lor \neg \left(c \leq 2400000000000\right):\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\
\end{array}
\end{array}
if c < -7.49999999999999947e89 or 2.4e12 < c Initial program 47.1%
Taylor expanded in c around inf 73.9%
mul-1-neg73.9%
unsub-neg73.9%
associate-/l*77.8%
Simplified77.8%
if -7.49999999999999947e89 < c < 2.4e12Initial program 63.7%
div-sub60.1%
*-commutative60.1%
add-sqr-sqrt60.1%
times-frac61.2%
fma-neg61.2%
hypot-define61.2%
hypot-define64.9%
associate-/l*67.5%
add-sqr-sqrt67.5%
pow267.5%
hypot-define67.5%
Applied egg-rr67.5%
Taylor expanded in d around inf 81.7%
associate-/l*83.4%
Simplified83.4%
Final simplification81.1%
(FPCore (a b c d) :precision binary64 (if (or (<= d -5.2e+35) (not (<= d 4.2e+21))) (/ a (- d)) (/ (- b (* a (/ d c))) c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -5.2e+35) || !(d <= 4.2e+21)) {
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 <= (-5.2d+35)) .or. (.not. (d <= 4.2d+21))) 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 <= -5.2e+35) || !(d <= 4.2e+21)) {
tmp = a / -d;
} else {
tmp = (b - (a * (d / c))) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -5.2e+35) or not (d <= 4.2e+21): tmp = a / -d else: tmp = (b - (a * (d / c))) / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -5.2e+35) || !(d <= 4.2e+21)) 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 <= -5.2e+35) || ~((d <= 4.2e+21))) tmp = a / -d; else tmp = (b - (a * (d / c))) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -5.2e+35], N[Not[LessEqual[d, 4.2e+21]], $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 -5.2 \cdot 10^{+35} \lor \neg \left(d \leq 4.2 \cdot 10^{+21}\right):\\
\;\;\;\;\frac{a}{-d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\
\end{array}
\end{array}
if d < -5.20000000000000013e35 or 4.2e21 < d Initial program 43.8%
Taylor expanded in c around 0 73.2%
associate-*r/73.2%
neg-mul-173.2%
Simplified73.2%
if -5.20000000000000013e35 < d < 4.2e21Initial program 68.2%
Taylor expanded in c around inf 75.7%
mul-1-neg75.7%
unsub-neg75.7%
associate-/l*75.6%
Simplified75.6%
Final simplification74.5%
(FPCore (a b c d)
:precision binary64
(if (<= c -7.5e+89)
(/ (- b (/ (* d a) c)) c)
(if (<= c 440000000000.0)
(/ (- (* b (/ c d)) a) d)
(/ (- b (* a (/ d c))) c))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -7.5e+89) {
tmp = (b - ((d * a) / c)) / c;
} else if (c <= 440000000000.0) {
tmp = ((b * (c / d)) - 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 (c <= (-7.5d+89)) then
tmp = (b - ((d * a) / c)) / c
else if (c <= 440000000000.0d0) then
tmp = ((b * (c / d)) - 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 (c <= -7.5e+89) {
tmp = (b - ((d * a) / c)) / c;
} else if (c <= 440000000000.0) {
tmp = ((b * (c / d)) - a) / d;
} else {
tmp = (b - (a * (d / c))) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -7.5e+89: tmp = (b - ((d * a) / c)) / c elif c <= 440000000000.0: tmp = ((b * (c / d)) - a) / d else: tmp = (b - (a * (d / c))) / c return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -7.5e+89) tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c); elseif (c <= 440000000000.0) tmp = Float64(Float64(Float64(b * Float64(c / d)) - a) / 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 (c <= -7.5e+89) tmp = (b - ((d * a) / c)) / c; elseif (c <= 440000000000.0) tmp = ((b * (c / d)) - a) / d; else tmp = (b - (a * (d / c))) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -7.5e+89], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[c, 440000000000.0], N[(N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -7.5 \cdot 10^{+89}:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\
\mathbf{elif}\;c \leq 440000000000:\\
\;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\
\end{array}
\end{array}
if c < -7.49999999999999947e89Initial program 34.9%
Taylor expanded in c around inf 78.0%
associate-*r/78.0%
mul-1-neg78.0%
distribute-rgt-neg-out78.0%
Simplified78.0%
if -7.49999999999999947e89 < c < 4.4e11Initial program 63.7%
div-sub60.1%
*-commutative60.1%
add-sqr-sqrt60.1%
times-frac61.2%
fma-neg61.2%
hypot-define61.2%
hypot-define64.9%
associate-/l*67.5%
add-sqr-sqrt67.5%
pow267.5%
hypot-define67.5%
Applied egg-rr67.5%
Taylor expanded in d around inf 81.7%
associate-/l*83.4%
Simplified83.4%
if 4.4e11 < c Initial program 55.3%
Taylor expanded in c around inf 71.1%
mul-1-neg71.1%
unsub-neg71.1%
associate-/l*78.9%
Simplified78.9%
Final simplification81.4%
(FPCore (a b c d) :precision binary64 (if (or (<= c -3.5e+111) (not (<= c 310000.0))) (/ b c) (/ a (- d))))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -3.5e+111) || !(c <= 310000.0)) {
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 <= (-3.5d+111)) .or. (.not. (c <= 310000.0d0))) 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 <= -3.5e+111) || !(c <= 310000.0)) {
tmp = b / c;
} else {
tmp = a / -d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -3.5e+111) or not (c <= 310000.0): tmp = b / c else: tmp = a / -d return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -3.5e+111) || !(c <= 310000.0)) 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 <= -3.5e+111) || ~((c <= 310000.0))) tmp = b / c; else tmp = a / -d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -3.5e+111], N[Not[LessEqual[c, 310000.0]], $MachinePrecision]], N[(b / c), $MachinePrecision], N[(a / (-d)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -3.5 \cdot 10^{+111} \lor \neg \left(c \leq 310000\right):\\
\;\;\;\;\frac{b}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{-d}\\
\end{array}
\end{array}
if c < -3.5000000000000002e111 or 3.1e5 < c Initial program 46.5%
Taylor expanded in c around inf 67.2%
if -3.5000000000000002e111 < c < 3.1e5Initial program 63.7%
Taylor expanded in c around 0 68.1%
associate-*r/68.1%
neg-mul-168.1%
Simplified68.1%
Final simplification67.7%
(FPCore (a b c d) :precision binary64 (if (<= d -5.5e+152) (/ a d) (/ b c)))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -5.5e+152) {
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 <= (-5.5d+152)) 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 <= -5.5e+152) {
tmp = a / d;
} else {
tmp = b / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -5.5e+152: tmp = a / d else: tmp = b / c return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -5.5e+152) 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 <= -5.5e+152) tmp = a / d; else tmp = b / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -5.5e+152], N[(a / d), $MachinePrecision], N[(b / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -5.5 \cdot 10^{+152}:\\
\;\;\;\;\frac{a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if d < -5.4999999999999999e152Initial program 28.7%
*-un-lft-identity28.7%
add-sqr-sqrt28.7%
times-frac28.7%
hypot-define28.7%
hypot-define53.7%
Applied egg-rr53.7%
Taylor expanded in c around 0 29.3%
+-commutative29.3%
mul-1-neg29.3%
sub-neg29.3%
associate-/l*29.4%
Simplified29.4%
Taylor expanded in d around -inf 29.7%
if -5.4999999999999999e152 < d Initial program 61.6%
Taylor expanded in c around inf 43.0%
(FPCore (a b c d) :precision binary64 (if (<= c 1.45e+89) (/ a d) (/ a c)))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= 1.45e+89) {
tmp = a / d;
} else {
tmp = a / c;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (c <= 1.45d+89) then
tmp = a / d
else
tmp = a / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= 1.45e+89) {
tmp = a / d;
} else {
tmp = a / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= 1.45e+89: tmp = a / d else: tmp = a / c return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= 1.45e+89) tmp = Float64(a / d); else tmp = Float64(a / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= 1.45e+89) tmp = a / d; else tmp = a / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, 1.45e+89], N[(a / d), $MachinePrecision], N[(a / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq 1.45 \cdot 10^{+89}:\\
\;\;\;\;\frac{a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c}\\
\end{array}
\end{array}
if c < 1.45000000000000013e89Initial program 59.3%
*-un-lft-identity59.3%
add-sqr-sqrt59.3%
times-frac59.3%
hypot-define59.3%
hypot-define75.9%
Applied egg-rr75.9%
Taylor expanded in c around 0 37.3%
+-commutative37.3%
mul-1-neg37.3%
sub-neg37.3%
associate-/l*38.1%
Simplified38.1%
Taylor expanded in d around -inf 11.8%
if 1.45000000000000013e89 < c Initial program 43.8%
*-un-lft-identity43.8%
add-sqr-sqrt43.8%
times-frac43.8%
hypot-define43.8%
hypot-define53.5%
Applied egg-rr53.5%
Taylor expanded in c around -inf 23.1%
associate-*r/23.7%
+-commutative23.7%
mul-1-neg23.7%
unsub-neg23.7%
Simplified23.7%
Taylor expanded in c around 0 23.0%
(FPCore (a b c d) :precision binary64 (/ a c))
double code(double a, double b, double c, double d) {
return a / c;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = a / c
end function
public static double code(double a, double b, double c, double d) {
return a / c;
}
def code(a, b, c, d): return a / c
function code(a, b, c, d) return Float64(a / c) end
function tmp = code(a, b, c, d) tmp = a / c; end
code[a_, b_, c_, d_] := N[(a / c), $MachinePrecision]
\begin{array}{l}
\\
\frac{a}{c}
\end{array}
Initial program 56.8%
*-un-lft-identity56.8%
add-sqr-sqrt56.8%
times-frac56.8%
hypot-define56.8%
hypot-define72.2%
Applied egg-rr72.2%
Taylor expanded in c around -inf 27.7%
associate-*r/27.8%
+-commutative27.8%
mul-1-neg27.8%
unsub-neg27.8%
Simplified27.8%
Taylor expanded in c around 0 9.3%
(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 2024146
(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))))