
(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 (fma (/ c (hypot c d)) (/ b (hypot c d)) (- (* a (* (/ 1.0 (hypot c d)) (/ d (hypot c d)))))))
double code(double a, double b, double c, double d) {
return fma((c / hypot(c, d)), (b / hypot(c, d)), -(a * ((1.0 / hypot(c, d)) * (d / hypot(c, d)))));
}
function code(a, b, c, d) return fma(Float64(c / hypot(c, d)), Float64(b / hypot(c, d)), Float64(-Float64(a * Float64(Float64(1.0 / hypot(c, d)) * Float64(d / hypot(c, d)))))) end
code[a_, b_, c_, d_] := N[(N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] + (-N[(a * N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(d / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision])), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, -a \cdot \left(\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{d}{\mathsf{hypot}\left(c, d\right)}\right)\right)
\end{array}
Initial program 58.2%
div-sub55.8%
*-commutative55.8%
add-sqr-sqrt55.8%
times-frac56.9%
fma-neg56.9%
hypot-define56.9%
hypot-define76.3%
associate-/l*79.3%
add-sqr-sqrt79.3%
pow279.3%
hypot-define79.3%
Applied egg-rr79.3%
*-un-lft-identity79.3%
unpow279.3%
times-frac94.9%
Applied egg-rr94.9%
(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)))))
(if (<= d -1.4e+117)
t_2
(if (<= d 6.3e+125)
(fma t_0 t_1 (- (* a (/ d (pow (hypot c d) 2.0)))))
t_2))))
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));
double tmp;
if (d <= -1.4e+117) {
tmp = t_2;
} else if (d <= 6.3e+125) {
tmp = fma(t_0, t_1, -(a * (d / pow(hypot(c, d), 2.0))));
} else {
tmp = t_2;
}
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(-Float64(a / d))) tmp = 0.0 if (d <= -1.4e+117) tmp = t_2; elseif (d <= 6.3e+125) tmp = fma(t_0, t_1, Float64(-Float64(a * Float64(d / (hypot(c, d) ^ 2.0))))); 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[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$0 * t$95$1 + (-N[(a / d), $MachinePrecision])), $MachinePrecision]}, If[LessEqual[d, -1.4e+117], t$95$2, If[LessEqual[d, 6.3e+125], 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], t$95$2]]]]]
\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, -\frac{a}{d}\right)\\
\mathbf{if}\;d \leq -1.4 \cdot 10^{+117}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;d \leq 6.3 \cdot 10^{+125}:\\
\;\;\;\;\mathsf{fma}\left(t\_0, t\_1, -a \cdot \frac{d}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if d < -1.39999999999999999e117 or 6.3000000000000002e125 < d Initial program 30.8%
div-sub30.8%
*-commutative30.8%
add-sqr-sqrt30.8%
times-frac31.0%
fma-neg31.0%
hypot-define31.0%
hypot-define45.9%
associate-/l*52.9%
add-sqr-sqrt52.9%
pow252.9%
hypot-define52.9%
Applied egg-rr52.9%
Taylor expanded in d around inf 89.6%
if -1.39999999999999999e117 < d < 6.3000000000000002e125Initial program 71.2%
div-sub67.6%
*-commutative67.6%
add-sqr-sqrt67.6%
times-frac69.1%
fma-neg69.1%
hypot-define69.1%
hypot-define90.6%
associate-/l*91.7%
add-sqr-sqrt91.7%
pow291.7%
hypot-define91.7%
Applied egg-rr91.7%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (pow (hypot c d) 2.0)))
(if (<= c -12000000000000.0)
(+ (* -1.0 (* (/ d c) (/ a c))) (/ b c))
(if (<= c 2.9e-141)
(/ (- (/ b (/ d c)) a) d)
(if (<= c 7.8e+158)
(- (* b (/ c t_0)) (* a (/ d t_0)))
(+ (* -1.0 (/ (/ d (/ c a)) c)) (/ b c)))))))
double code(double a, double b, double c, double d) {
double t_0 = pow(hypot(c, d), 2.0);
double tmp;
if (c <= -12000000000000.0) {
tmp = (-1.0 * ((d / c) * (a / c))) + (b / c);
} else if (c <= 2.9e-141) {
tmp = ((b / (d / c)) - a) / d;
} else if (c <= 7.8e+158) {
tmp = (b * (c / t_0)) - (a * (d / t_0));
} else {
tmp = (-1.0 * ((d / (c / a)) / c)) + (b / c);
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = Math.pow(Math.hypot(c, d), 2.0);
double tmp;
if (c <= -12000000000000.0) {
tmp = (-1.0 * ((d / c) * (a / c))) + (b / c);
} else if (c <= 2.9e-141) {
tmp = ((b / (d / c)) - a) / d;
} else if (c <= 7.8e+158) {
tmp = (b * (c / t_0)) - (a * (d / t_0));
} else {
tmp = (-1.0 * ((d / (c / a)) / c)) + (b / c);
}
return tmp;
}
def code(a, b, c, d): t_0 = math.pow(math.hypot(c, d), 2.0) tmp = 0 if c <= -12000000000000.0: tmp = (-1.0 * ((d / c) * (a / c))) + (b / c) elif c <= 2.9e-141: tmp = ((b / (d / c)) - a) / d elif c <= 7.8e+158: tmp = (b * (c / t_0)) - (a * (d / t_0)) else: tmp = (-1.0 * ((d / (c / a)) / c)) + (b / c) return tmp
function code(a, b, c, d) t_0 = hypot(c, d) ^ 2.0 tmp = 0.0 if (c <= -12000000000000.0) tmp = Float64(Float64(-1.0 * Float64(Float64(d / c) * Float64(a / c))) + Float64(b / c)); elseif (c <= 2.9e-141) tmp = Float64(Float64(Float64(b / Float64(d / c)) - a) / d); elseif (c <= 7.8e+158) tmp = Float64(Float64(b * Float64(c / t_0)) - Float64(a * Float64(d / t_0))); else tmp = Float64(Float64(-1.0 * Float64(Float64(d / Float64(c / a)) / c)) + Float64(b / c)); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = hypot(c, d) ^ 2.0; tmp = 0.0; if (c <= -12000000000000.0) tmp = (-1.0 * ((d / c) * (a / c))) + (b / c); elseif (c <= 2.9e-141) tmp = ((b / (d / c)) - a) / d; elseif (c <= 7.8e+158) tmp = (b * (c / t_0)) - (a * (d / t_0)); else tmp = (-1.0 * ((d / (c / a)) / c)) + (b / c); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[Power[N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[c, -12000000000000.0], N[(N[(-1.0 * N[(N[(d / c), $MachinePrecision] * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(b / c), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 2.9e-141], N[(N[(N[(b / N[(d / c), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 7.8e+158], N[(N[(b * N[(c / t$95$0), $MachinePrecision]), $MachinePrecision] - N[(a * N[(d / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-1.0 * N[(N[(d / N[(c / a), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] + N[(b / c), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}\\
\mathbf{if}\;c \leq -12000000000000:\\
\;\;\;\;-1 \cdot \left(\frac{d}{c} \cdot \frac{a}{c}\right) + \frac{b}{c}\\
\mathbf{elif}\;c \leq 2.9 \cdot 10^{-141}:\\
\;\;\;\;\frac{\frac{b}{\frac{d}{c}} - a}{d}\\
\mathbf{elif}\;c \leq 7.8 \cdot 10^{+158}:\\
\;\;\;\;b \cdot \frac{c}{t\_0} - a \cdot \frac{d}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;-1 \cdot \frac{\frac{d}{\frac{c}{a}}}{c} + \frac{b}{c}\\
\end{array}
\end{array}
if c < -1.2e13Initial program 40.0%
Taylor expanded in d around 0 68.8%
*-commutative68.8%
unpow268.8%
times-frac76.2%
Applied egg-rr76.2%
if -1.2e13 < c < 2.9e-141Initial program 71.0%
Taylor expanded in d around inf 92.0%
+-commutative92.0%
mul-1-neg92.0%
unsub-neg92.0%
associate-/l*92.9%
Applied egg-rr92.9%
clear-num93.0%
un-div-inv93.0%
Applied egg-rr93.0%
if 2.9e-141 < c < 7.8e158Initial program 76.8%
div-sub76.8%
associate-/l*81.8%
add-sqr-sqrt81.8%
pow281.8%
hypot-define81.8%
associate-/l*85.2%
add-sqr-sqrt85.2%
pow285.2%
hypot-define85.2%
Applied egg-rr85.2%
if 7.8e158 < c Initial program 28.4%
Taylor expanded in d around 0 78.9%
*-commutative78.9%
unpow278.9%
times-frac92.5%
Applied egg-rr92.5%
associate-*l/92.5%
clear-num92.5%
un-div-inv92.5%
Applied egg-rr92.5%
(FPCore (a b c d)
:precision binary64
(if (<= c -10000000000000.0)
(+ (* -1.0 (* (/ d c) (/ a c))) (/ b c))
(if (<= c 2.75e-136)
(/ (- (/ b (/ d c)) a) d)
(if (<= c 4e+97)
(/ (- (* b c) (* a d)) (+ (* c c) (* d d)))
(+ (* -1.0 (/ (/ d (/ c a)) c)) (/ b c))))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -10000000000000.0) {
tmp = (-1.0 * ((d / c) * (a / c))) + (b / c);
} else if (c <= 2.75e-136) {
tmp = ((b / (d / c)) - a) / d;
} else if (c <= 4e+97) {
tmp = ((b * c) - (a * d)) / ((c * c) + (d * d));
} else {
tmp = (-1.0 * ((d / (c / a)) / c)) + (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 (c <= (-10000000000000.0d0)) then
tmp = ((-1.0d0) * ((d / c) * (a / c))) + (b / c)
else if (c <= 2.75d-136) then
tmp = ((b / (d / c)) - a) / d
else if (c <= 4d+97) then
tmp = ((b * c) - (a * d)) / ((c * c) + (d * d))
else
tmp = ((-1.0d0) * ((d / (c / a)) / c)) + (b / c)
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -10000000000000.0) {
tmp = (-1.0 * ((d / c) * (a / c))) + (b / c);
} else if (c <= 2.75e-136) {
tmp = ((b / (d / c)) - a) / d;
} else if (c <= 4e+97) {
tmp = ((b * c) - (a * d)) / ((c * c) + (d * d));
} else {
tmp = (-1.0 * ((d / (c / a)) / c)) + (b / c);
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -10000000000000.0: tmp = (-1.0 * ((d / c) * (a / c))) + (b / c) elif c <= 2.75e-136: tmp = ((b / (d / c)) - a) / d elif c <= 4e+97: tmp = ((b * c) - (a * d)) / ((c * c) + (d * d)) else: tmp = (-1.0 * ((d / (c / a)) / c)) + (b / c) return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -10000000000000.0) tmp = Float64(Float64(-1.0 * Float64(Float64(d / c) * Float64(a / c))) + Float64(b / c)); elseif (c <= 2.75e-136) tmp = Float64(Float64(Float64(b / Float64(d / c)) - a) / d); elseif (c <= 4e+97) tmp = Float64(Float64(Float64(b * c) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d))); else tmp = Float64(Float64(-1.0 * Float64(Float64(d / Float64(c / a)) / c)) + Float64(b / c)); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -10000000000000.0) tmp = (-1.0 * ((d / c) * (a / c))) + (b / c); elseif (c <= 2.75e-136) tmp = ((b / (d / c)) - a) / d; elseif (c <= 4e+97) tmp = ((b * c) - (a * d)) / ((c * c) + (d * d)); else tmp = (-1.0 * ((d / (c / a)) / c)) + (b / c); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -10000000000000.0], N[(N[(-1.0 * N[(N[(d / c), $MachinePrecision] * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(b / c), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 2.75e-136], N[(N[(N[(b / N[(d / c), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 4e+97], N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-1.0 * N[(N[(d / N[(c / a), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] + N[(b / c), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -10000000000000:\\
\;\;\;\;-1 \cdot \left(\frac{d}{c} \cdot \frac{a}{c}\right) + \frac{b}{c}\\
\mathbf{elif}\;c \leq 2.75 \cdot 10^{-136}:\\
\;\;\;\;\frac{\frac{b}{\frac{d}{c}} - a}{d}\\
\mathbf{elif}\;c \leq 4 \cdot 10^{+97}:\\
\;\;\;\;\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{else}:\\
\;\;\;\;-1 \cdot \frac{\frac{d}{\frac{c}{a}}}{c} + \frac{b}{c}\\
\end{array}
\end{array}
if c < -1e13Initial program 40.0%
Taylor expanded in d around 0 68.8%
*-commutative68.8%
unpow268.8%
times-frac76.2%
Applied egg-rr76.2%
if -1e13 < c < 2.75e-136Initial program 70.4%
Taylor expanded in d around inf 92.1%
+-commutative92.1%
mul-1-neg92.1%
unsub-neg92.1%
associate-/l*93.0%
Applied egg-rr93.0%
clear-num93.0%
un-div-inv93.0%
Applied egg-rr93.0%
if 2.75e-136 < c < 4.0000000000000003e97Initial program 84.0%
if 4.0000000000000003e97 < c Initial program 30.4%
Taylor expanded in d around 0 78.5%
*-commutative78.5%
unpow278.5%
times-frac89.8%
Applied egg-rr89.8%
associate-*l/89.9%
clear-num89.9%
un-div-inv89.9%
Applied egg-rr89.9%
(FPCore (a b c d)
:precision binary64
(if (<= c -14000000000000.0)
(+ (* -1.0 (* (/ d c) (/ a c))) (/ b c))
(if (<= c 1950.0)
(/ (- (/ b (/ d c)) a) d)
(+ (* -1.0 (/ (/ d (/ c a)) c)) (/ b c)))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -14000000000000.0) {
tmp = (-1.0 * ((d / c) * (a / c))) + (b / c);
} else if (c <= 1950.0) {
tmp = ((b / (d / c)) - a) / d;
} else {
tmp = (-1.0 * ((d / (c / a)) / c)) + (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 (c <= (-14000000000000.0d0)) then
tmp = ((-1.0d0) * ((d / c) * (a / c))) + (b / c)
else if (c <= 1950.0d0) then
tmp = ((b / (d / c)) - a) / d
else
tmp = ((-1.0d0) * ((d / (c / a)) / c)) + (b / c)
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -14000000000000.0) {
tmp = (-1.0 * ((d / c) * (a / c))) + (b / c);
} else if (c <= 1950.0) {
tmp = ((b / (d / c)) - a) / d;
} else {
tmp = (-1.0 * ((d / (c / a)) / c)) + (b / c);
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -14000000000000.0: tmp = (-1.0 * ((d / c) * (a / c))) + (b / c) elif c <= 1950.0: tmp = ((b / (d / c)) - a) / d else: tmp = (-1.0 * ((d / (c / a)) / c)) + (b / c) return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -14000000000000.0) tmp = Float64(Float64(-1.0 * Float64(Float64(d / c) * Float64(a / c))) + Float64(b / c)); elseif (c <= 1950.0) tmp = Float64(Float64(Float64(b / Float64(d / c)) - a) / d); else tmp = Float64(Float64(-1.0 * Float64(Float64(d / Float64(c / a)) / c)) + Float64(b / c)); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -14000000000000.0) tmp = (-1.0 * ((d / c) * (a / c))) + (b / c); elseif (c <= 1950.0) tmp = ((b / (d / c)) - a) / d; else tmp = (-1.0 * ((d / (c / a)) / c)) + (b / c); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -14000000000000.0], N[(N[(-1.0 * N[(N[(d / c), $MachinePrecision] * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(b / c), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1950.0], N[(N[(N[(b / N[(d / c), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], N[(N[(-1.0 * N[(N[(d / N[(c / a), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] + N[(b / c), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -14000000000000:\\
\;\;\;\;-1 \cdot \left(\frac{d}{c} \cdot \frac{a}{c}\right) + \frac{b}{c}\\
\mathbf{elif}\;c \leq 1950:\\
\;\;\;\;\frac{\frac{b}{\frac{d}{c}} - a}{d}\\
\mathbf{else}:\\
\;\;\;\;-1 \cdot \frac{\frac{d}{\frac{c}{a}}}{c} + \frac{b}{c}\\
\end{array}
\end{array}
if c < -1.4e13Initial program 40.0%
Taylor expanded in d around 0 68.8%
*-commutative68.8%
unpow268.8%
times-frac76.2%
Applied egg-rr76.2%
if -1.4e13 < c < 1950Initial program 72.7%
Taylor expanded in d around inf 85.7%
+-commutative85.7%
mul-1-neg85.7%
unsub-neg85.7%
associate-/l*86.4%
Applied egg-rr86.4%
clear-num86.5%
un-div-inv86.5%
Applied egg-rr86.5%
if 1950 < c Initial program 47.1%
Taylor expanded in d around 0 76.0%
*-commutative76.0%
unpow276.0%
times-frac82.7%
Applied egg-rr82.7%
associate-*l/84.2%
clear-num84.2%
un-div-inv84.2%
Applied egg-rr84.2%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (+ (* -1.0 (* (/ d c) (/ a c))) (/ b c))))
(if (<= c -13500000000000.0)
t_0
(if (<= c 35000.0) (/ (- (/ b (/ d c)) a) d) t_0))))
double code(double a, double b, double c, double d) {
double t_0 = (-1.0 * ((d / c) * (a / c))) + (b / c);
double tmp;
if (c <= -13500000000000.0) {
tmp = t_0;
} else if (c <= 35000.0) {
tmp = ((b / (d / c)) - a) / d;
} else {
tmp = t_0;
}
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 = ((-1.0d0) * ((d / c) * (a / c))) + (b / c)
if (c <= (-13500000000000.0d0)) then
tmp = t_0
else if (c <= 35000.0d0) then
tmp = ((b / (d / c)) - a) / d
else
tmp = t_0
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = (-1.0 * ((d / c) * (a / c))) + (b / c);
double tmp;
if (c <= -13500000000000.0) {
tmp = t_0;
} else if (c <= 35000.0) {
tmp = ((b / (d / c)) - a) / d;
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b, c, d): t_0 = (-1.0 * ((d / c) * (a / c))) + (b / c) tmp = 0 if c <= -13500000000000.0: tmp = t_0 elif c <= 35000.0: tmp = ((b / (d / c)) - a) / d else: tmp = t_0 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(-1.0 * Float64(Float64(d / c) * Float64(a / c))) + Float64(b / c)) tmp = 0.0 if (c <= -13500000000000.0) tmp = t_0; elseif (c <= 35000.0) tmp = Float64(Float64(Float64(b / Float64(d / c)) - a) / d); else tmp = t_0; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (-1.0 * ((d / c) * (a / c))) + (b / c); tmp = 0.0; if (c <= -13500000000000.0) tmp = t_0; elseif (c <= 35000.0) tmp = ((b / (d / c)) - a) / d; else tmp = t_0; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(-1.0 * N[(N[(d / c), $MachinePrecision] * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(b / c), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -13500000000000.0], t$95$0, If[LessEqual[c, 35000.0], N[(N[(N[(b / N[(d / c), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -1 \cdot \left(\frac{d}{c} \cdot \frac{a}{c}\right) + \frac{b}{c}\\
\mathbf{if}\;c \leq -13500000000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq 35000:\\
\;\;\;\;\frac{\frac{b}{\frac{d}{c}} - a}{d}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if c < -1.35e13 or 35000 < c Initial program 43.8%
Taylor expanded in d around 0 72.6%
*-commutative72.6%
unpow272.6%
times-frac79.7%
Applied egg-rr79.7%
if -1.35e13 < c < 35000Initial program 72.7%
Taylor expanded in d around inf 85.7%
+-commutative85.7%
mul-1-neg85.7%
unsub-neg85.7%
associate-/l*86.4%
Applied egg-rr86.4%
clear-num86.5%
un-div-inv86.5%
Applied egg-rr86.5%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (+ b (* -1.0 (/ (* a d) c))) c)))
(if (<= c -11500000000000.0)
t_0
(if (<= c 10000.0) (/ (- (/ b (/ d c)) a) d) t_0))))
double code(double a, double b, double c, double d) {
double t_0 = (b + (-1.0 * ((a * d) / c))) / c;
double tmp;
if (c <= -11500000000000.0) {
tmp = t_0;
} else if (c <= 10000.0) {
tmp = ((b / (d / c)) - a) / d;
} else {
tmp = t_0;
}
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 = (b + ((-1.0d0) * ((a * d) / c))) / c
if (c <= (-11500000000000.0d0)) then
tmp = t_0
else if (c <= 10000.0d0) then
tmp = ((b / (d / c)) - a) / d
else
tmp = t_0
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = (b + (-1.0 * ((a * d) / c))) / c;
double tmp;
if (c <= -11500000000000.0) {
tmp = t_0;
} else if (c <= 10000.0) {
tmp = ((b / (d / c)) - a) / d;
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b, c, d): t_0 = (b + (-1.0 * ((a * d) / c))) / c tmp = 0 if c <= -11500000000000.0: tmp = t_0 elif c <= 10000.0: tmp = ((b / (d / c)) - a) / d else: tmp = t_0 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(b + Float64(-1.0 * Float64(Float64(a * d) / c))) / c) tmp = 0.0 if (c <= -11500000000000.0) tmp = t_0; elseif (c <= 10000.0) tmp = Float64(Float64(Float64(b / Float64(d / c)) - a) / d); else tmp = t_0; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (b + (-1.0 * ((a * d) / c))) / c; tmp = 0.0; if (c <= -11500000000000.0) tmp = t_0; elseif (c <= 10000.0) tmp = ((b / (d / c)) - a) / d; else tmp = t_0; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(b + N[(-1.0 * N[(N[(a * d), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]}, If[LessEqual[c, -11500000000000.0], t$95$0, If[LessEqual[c, 10000.0], N[(N[(N[(b / N[(d / c), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b + -1 \cdot \frac{a \cdot d}{c}}{c}\\
\mathbf{if}\;c \leq -11500000000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq 10000:\\
\;\;\;\;\frac{\frac{b}{\frac{d}{c}} - a}{d}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if c < -1.15e13 or 1e4 < c Initial program 43.8%
Taylor expanded in c around inf 75.1%
if -1.15e13 < c < 1e4Initial program 72.7%
Taylor expanded in d around inf 85.7%
+-commutative85.7%
mul-1-neg85.7%
unsub-neg85.7%
associate-/l*86.4%
Applied egg-rr86.4%
clear-num86.5%
un-div-inv86.5%
Applied egg-rr86.5%
(FPCore (a b c d) :precision binary64 (if (<= c -1e+153) (/ b c) (if (<= c 3.8e+40) (/ (- (/ b (/ d c)) a) d) (/ b c))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -1e+153) {
tmp = b / c;
} else if (c <= 3.8e+40) {
tmp = ((b / (d / c)) - 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 (c <= (-1d+153)) then
tmp = b / c
else if (c <= 3.8d+40) then
tmp = ((b / (d / c)) - 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 (c <= -1e+153) {
tmp = b / c;
} else if (c <= 3.8e+40) {
tmp = ((b / (d / c)) - a) / d;
} else {
tmp = b / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -1e+153: tmp = b / c elif c <= 3.8e+40: tmp = ((b / (d / c)) - a) / d else: tmp = b / c return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -1e+153) tmp = Float64(b / c); elseif (c <= 3.8e+40) tmp = Float64(Float64(Float64(b / Float64(d / c)) - a) / d); else tmp = Float64(b / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -1e+153) tmp = b / c; elseif (c <= 3.8e+40) tmp = ((b / (d / c)) - a) / d; else tmp = b / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -1e+153], N[(b / c), $MachinePrecision], If[LessEqual[c, 3.8e+40], N[(N[(N[(b / N[(d / c), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], N[(b / c), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -1 \cdot 10^{+153}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{elif}\;c \leq 3.8 \cdot 10^{+40}:\\
\;\;\;\;\frac{\frac{b}{\frac{d}{c}} - a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if c < -1e153 or 3.80000000000000004e40 < c Initial program 30.8%
Taylor expanded in c around inf 77.6%
if -1e153 < c < 3.80000000000000004e40Initial program 73.4%
Taylor expanded in d around inf 75.0%
+-commutative75.0%
mul-1-neg75.0%
unsub-neg75.0%
associate-/l*76.2%
Applied egg-rr76.2%
clear-num76.2%
un-div-inv76.2%
Applied egg-rr76.2%
(FPCore (a b c d) :precision binary64 (if (<= c -1e+153) (/ b c) (if (<= c 3.6e+40) (/ (- (* b (/ c d)) a) d) (/ b c))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -1e+153) {
tmp = b / c;
} else if (c <= 3.6e+40) {
tmp = ((b * (c / d)) - 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 (c <= (-1d+153)) then
tmp = b / c
else if (c <= 3.6d+40) then
tmp = ((b * (c / d)) - 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 (c <= -1e+153) {
tmp = b / c;
} else if (c <= 3.6e+40) {
tmp = ((b * (c / d)) - a) / d;
} else {
tmp = b / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -1e+153: tmp = b / c elif c <= 3.6e+40: tmp = ((b * (c / d)) - a) / d else: tmp = b / c return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -1e+153) tmp = Float64(b / c); elseif (c <= 3.6e+40) tmp = Float64(Float64(Float64(b * Float64(c / d)) - a) / d); else tmp = Float64(b / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -1e+153) tmp = b / c; elseif (c <= 3.6e+40) tmp = ((b * (c / d)) - a) / d; else tmp = b / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -1e+153], N[(b / c), $MachinePrecision], If[LessEqual[c, 3.6e+40], N[(N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], N[(b / c), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -1 \cdot 10^{+153}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{elif}\;c \leq 3.6 \cdot 10^{+40}:\\
\;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if c < -1e153 or 3.59999999999999996e40 < c Initial program 30.8%
Taylor expanded in c around inf 77.6%
if -1e153 < c < 3.59999999999999996e40Initial program 73.4%
Taylor expanded in d around inf 75.0%
+-commutative75.0%
mul-1-neg75.0%
unsub-neg75.0%
associate-/l*76.2%
Applied egg-rr76.2%
(FPCore (a b c d) :precision binary64 (if (<= c -7800000000000.0) (/ b c) (if (<= c 6e+26) (* -1.0 (/ a d)) (/ b c))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -7800000000000.0) {
tmp = b / c;
} else if (c <= 6e+26) {
tmp = -1.0 * (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 (c <= (-7800000000000.0d0)) then
tmp = b / c
else if (c <= 6d+26) then
tmp = (-1.0d0) * (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 (c <= -7800000000000.0) {
tmp = b / c;
} else if (c <= 6e+26) {
tmp = -1.0 * (a / d);
} else {
tmp = b / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -7800000000000.0: tmp = b / c elif c <= 6e+26: tmp = -1.0 * (a / d) else: tmp = b / c return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -7800000000000.0) tmp = Float64(b / c); elseif (c <= 6e+26) tmp = Float64(-1.0 * Float64(a / d)); else tmp = Float64(b / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -7800000000000.0) tmp = b / c; elseif (c <= 6e+26) tmp = -1.0 * (a / d); else tmp = b / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -7800000000000.0], N[(b / c), $MachinePrecision], If[LessEqual[c, 6e+26], N[(-1.0 * N[(a / d), $MachinePrecision]), $MachinePrecision], N[(b / c), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -7800000000000:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{elif}\;c \leq 6 \cdot 10^{+26}:\\
\;\;\;\;-1 \cdot \frac{a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if c < -7.8e12 or 5.99999999999999994e26 < c Initial program 42.0%
Taylor expanded in c around inf 66.7%
if -7.8e12 < c < 5.99999999999999994e26Initial program 73.5%
Taylor expanded in c around 0 68.1%
(FPCore (a b c d) :precision binary64 (if (<= d -1.2e+167) (/ a d) (if (<= d 5.2e+230) (/ b c) (/ a d))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -1.2e+167) {
tmp = a / d;
} else if (d <= 5.2e+230) {
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 <= (-1.2d+167)) then
tmp = a / d
else if (d <= 5.2d+230) 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 <= -1.2e+167) {
tmp = a / d;
} else if (d <= 5.2e+230) {
tmp = b / c;
} else {
tmp = a / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -1.2e+167: tmp = a / d elif d <= 5.2e+230: tmp = b / c else: tmp = a / d return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -1.2e+167) tmp = Float64(a / d); elseif (d <= 5.2e+230) 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 <= -1.2e+167) tmp = a / d; elseif (d <= 5.2e+230) tmp = b / c; else tmp = a / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -1.2e+167], N[(a / d), $MachinePrecision], If[LessEqual[d, 5.2e+230], N[(b / c), $MachinePrecision], N[(a / d), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.2 \cdot 10^{+167}:\\
\;\;\;\;\frac{a}{d}\\
\mathbf{elif}\;d \leq 5.2 \cdot 10^{+230}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{d}\\
\end{array}
\end{array}
if d < -1.19999999999999999e167 or 5.1999999999999997e230 < d Initial program 37.2%
fma-neg37.2%
distribute-rgt-neg-out37.2%
*-un-lft-identity37.2%
add-sqr-sqrt37.2%
times-frac37.2%
hypot-define37.2%
add-sqr-sqrt22.2%
sqrt-unprod34.2%
distribute-rgt-neg-out34.2%
distribute-rgt-neg-out34.2%
sqr-neg34.2%
sqrt-unprod15.0%
add-sqr-sqrt37.2%
hypot-define43.2%
Applied egg-rr43.2%
Taylor expanded in c around 0 37.9%
if -1.19999999999999999e167 < d < 5.1999999999999997e230Initial program 63.0%
Taylor expanded in c around inf 48.4%
(FPCore (a b c d) :precision binary64 (if (<= d -3.8e+145) (/ a d) (if (<= d 1.3e+107) (/ a c) (/ a d))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -3.8e+145) {
tmp = a / d;
} else if (d <= 1.3e+107) {
tmp = a / 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.8d+145)) then
tmp = a / d
else if (d <= 1.3d+107) then
tmp = a / 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.8e+145) {
tmp = a / d;
} else if (d <= 1.3e+107) {
tmp = a / c;
} else {
tmp = a / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -3.8e+145: tmp = a / d elif d <= 1.3e+107: tmp = a / c else: tmp = a / d return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -3.8e+145) tmp = Float64(a / d); elseif (d <= 1.3e+107) tmp = Float64(a / c); else tmp = Float64(a / d); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= -3.8e+145) tmp = a / d; elseif (d <= 1.3e+107) tmp = a / c; else tmp = a / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -3.8e+145], N[(a / d), $MachinePrecision], If[LessEqual[d, 1.3e+107], N[(a / c), $MachinePrecision], N[(a / d), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -3.8 \cdot 10^{+145}:\\
\;\;\;\;\frac{a}{d}\\
\mathbf{elif}\;d \leq 1.3 \cdot 10^{+107}:\\
\;\;\;\;\frac{a}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{d}\\
\end{array}
\end{array}
if d < -3.80000000000000012e145 or 1.3000000000000001e107 < d Initial program 31.0%
fma-neg31.0%
distribute-rgt-neg-out31.0%
*-un-lft-identity31.0%
add-sqr-sqrt31.0%
times-frac31.0%
hypot-define31.0%
add-sqr-sqrt16.7%
sqrt-unprod26.4%
distribute-rgt-neg-out26.4%
distribute-rgt-neg-out26.4%
sqr-neg26.4%
sqrt-unprod13.0%
add-sqr-sqrt28.5%
hypot-define36.7%
Applied egg-rr36.7%
Taylor expanded in c around 0 26.1%
if -3.80000000000000012e145 < d < 1.3000000000000001e107Initial program 70.8%
fma-neg70.9%
distribute-rgt-neg-out70.9%
*-un-lft-identity70.9%
add-sqr-sqrt70.9%
times-frac70.7%
hypot-define70.7%
add-sqr-sqrt48.9%
sqrt-unprod51.8%
distribute-rgt-neg-out51.8%
distribute-rgt-neg-out51.8%
sqr-neg51.8%
sqrt-unprod18.1%
add-sqr-sqrt35.9%
hypot-define43.6%
Applied egg-rr43.6%
Taylor expanded in c around -inf 37.8%
Taylor expanded in d around -inf 13.3%
(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 58.2%
fma-neg58.2%
distribute-rgt-neg-out58.2%
*-un-lft-identity58.2%
add-sqr-sqrt58.2%
times-frac58.1%
hypot-define58.2%
add-sqr-sqrt38.7%
sqrt-unprod43.8%
distribute-rgt-neg-out43.8%
distribute-rgt-neg-out43.8%
sqr-neg43.8%
sqrt-unprod16.5%
add-sqr-sqrt33.5%
hypot-define41.4%
Applied egg-rr41.4%
Taylor expanded in c around -inf 29.6%
Taylor expanded in d around -inf 10.7%
(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 2024116 -o generate:simplify
(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))))