
(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
(let* ((t_0
(fma
(/ c (hypot c d))
(/ b (hypot c d))
(/ (- a) (/ (pow (hypot c d) 2.0) d)))))
(if (<= d -1.65e+159)
(- (* (/ c d) (/ b d)) (/ a d))
(if (<= d -2.8e-136)
t_0
(if (<= d 1.75e-165)
(* (/ -1.0 c) (- (/ (* d a) c) b))
(if (<= d 7.2e+149)
t_0
(* (/ 1.0 (hypot c d)) (- (/ c (/ d b)) a))))))))
double code(double a, double b, double c, double d) {
double t_0 = fma((c / hypot(c, d)), (b / hypot(c, d)), (-a / (pow(hypot(c, d), 2.0) / d)));
double tmp;
if (d <= -1.65e+159) {
tmp = ((c / d) * (b / d)) - (a / d);
} else if (d <= -2.8e-136) {
tmp = t_0;
} else if (d <= 1.75e-165) {
tmp = (-1.0 / c) * (((d * a) / c) - b);
} else if (d <= 7.2e+149) {
tmp = t_0;
} else {
tmp = (1.0 / hypot(c, d)) * ((c / (d / b)) - a);
}
return tmp;
}
function code(a, b, c, d) t_0 = fma(Float64(c / hypot(c, d)), Float64(b / hypot(c, d)), Float64(Float64(-a) / Float64((hypot(c, d) ^ 2.0) / d))) tmp = 0.0 if (d <= -1.65e+159) tmp = Float64(Float64(Float64(c / d) * Float64(b / d)) - Float64(a / d)); elseif (d <= -2.8e-136) tmp = t_0; elseif (d <= 1.75e-165) tmp = Float64(Float64(-1.0 / c) * Float64(Float64(Float64(d * a) / c) - b)); elseif (d <= 7.2e+149) tmp = t_0; else tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(Float64(c / Float64(d / b)) - a)); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = 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[Power[N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision], 2.0], $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -1.65e+159], N[(N[(N[(c / d), $MachinePrecision] * N[(b / d), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -2.8e-136], t$95$0, If[LessEqual[d, 1.75e-165], N[(N[(-1.0 / c), $MachinePrecision] * N[(N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 7.2e+149], t$95$0, N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(N[(c / N[(d / b), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, \frac{-a}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{d}}\right)\\
\mathbf{if}\;d \leq -1.65 \cdot 10^{+159}:\\
\;\;\;\;\frac{c}{d} \cdot \frac{b}{d} - \frac{a}{d}\\
\mathbf{elif}\;d \leq -2.8 \cdot 10^{-136}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 1.75 \cdot 10^{-165}:\\
\;\;\;\;\frac{-1}{c} \cdot \left(\frac{d \cdot a}{c} - b\right)\\
\mathbf{elif}\;d \leq 7.2 \cdot 10^{+149}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(\frac{c}{\frac{d}{b}} - a\right)\\
\end{array}
\end{array}
if d < -1.6499999999999999e159Initial program 29.9%
Taylor expanded in c around 0 76.2%
+-commutative76.2%
mul-1-neg76.2%
unsub-neg76.2%
unpow276.2%
times-frac80.5%
Simplified80.5%
if -1.6499999999999999e159 < d < -2.8000000000000001e-136 or 1.7500000000000001e-165 < d < 7.1999999999999999e149Initial program 72.4%
div-sub72.5%
*-commutative72.5%
add-sqr-sqrt72.5%
times-frac74.6%
fma-neg74.6%
hypot-def74.6%
hypot-def90.1%
associate-/l*91.8%
add-sqr-sqrt91.8%
pow291.8%
hypot-def91.8%
Applied egg-rr91.8%
if -2.8000000000000001e-136 < d < 1.7500000000000001e-165Initial program 62.3%
*-un-lft-identity62.3%
add-sqr-sqrt62.3%
times-frac62.4%
hypot-def62.4%
hypot-def78.8%
Applied egg-rr78.8%
Taylor expanded in c around -inf 50.4%
Taylor expanded in c around -inf 94.0%
if 7.1999999999999999e149 < d Initial program 41.0%
*-un-lft-identity41.0%
add-sqr-sqrt41.0%
times-frac41.0%
hypot-def41.0%
hypot-def64.0%
Applied egg-rr64.0%
Taylor expanded in c around 0 92.3%
mul-1-neg92.3%
unsub-neg92.3%
associate-/l*95.8%
Simplified95.8%
Final simplification91.7%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (- (* c b) (* d a))))
(if (<= (/ t_0 (+ (* c c) (* d d))) 2e+303)
(* (/ 1.0 (hypot c d)) (/ t_0 (hypot c d)))
(- (/ b c) (* (/ a c) (/ d c))))))
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))) <= 2e+303) {
tmp = (1.0 / hypot(c, d)) * (t_0 / hypot(c, d));
} else {
tmp = (b / c) - ((a / c) * (d / c));
}
return tmp;
}
public static 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))) <= 2e+303) {
tmp = (1.0 / Math.hypot(c, d)) * (t_0 / Math.hypot(c, d));
} else {
tmp = (b / c) - ((a / c) * (d / c));
}
return tmp;
}
def code(a, b, c, d): t_0 = (c * b) - (d * a) tmp = 0 if (t_0 / ((c * c) + (d * d))) <= 2e+303: tmp = (1.0 / math.hypot(c, d)) * (t_0 / math.hypot(c, d)) else: tmp = (b / c) - ((a / c) * (d / c)) 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))) <= 2e+303) tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(t_0 / hypot(c, d))); else tmp = Float64(Float64(b / c) - Float64(Float64(a / c) * Float64(d / c))); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (c * b) - (d * a); tmp = 0.0; if ((t_0 / ((c * c) + (d * d))) <= 2e+303) tmp = (1.0 / hypot(c, d)) * (t_0 / hypot(c, d)); else tmp = (b / c) - ((a / c) * (d / c)); 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[N[(t$95$0 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2e+303], 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[(b / c), $MachinePrecision] - N[(N[(a / c), $MachinePrecision] * N[(d / c), $MachinePrecision]), $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 2 \cdot 10^{+303}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{t_0}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c} - \frac{a}{c} \cdot \frac{d}{c}\\
\end{array}
\end{array}
if (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 2e303Initial program 81.1%
*-un-lft-identity81.1%
add-sqr-sqrt81.1%
times-frac81.1%
hypot-def81.1%
hypot-def97.5%
Applied egg-rr97.5%
if 2e303 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 7.5%
Taylor expanded in c around inf 48.5%
+-commutative48.5%
mul-1-neg48.5%
unsub-neg48.5%
unpow248.5%
times-frac57.0%
Simplified57.0%
Final simplification86.1%
(FPCore (a b c d)
:precision binary64
(if (<= c -4.8e+76)
(/ (- (* d (/ a c)) b) (hypot c d))
(if (<= c -9.5e-66)
(/ (- (* c b) (* d a)) (+ (* c c) (* d d)))
(if (<= c 1.85e+55)
(- (* (/ c d) (/ b d)) (/ a d))
(- (/ b c) (* (/ a c) (/ d c)))))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -4.8e+76) {
tmp = ((d * (a / c)) - b) / hypot(c, d);
} else if (c <= -9.5e-66) {
tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
} else if (c <= 1.85e+55) {
tmp = ((c / d) * (b / d)) - (a / d);
} else {
tmp = (b / c) - ((a / c) * (d / c));
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -4.8e+76) {
tmp = ((d * (a / c)) - b) / Math.hypot(c, d);
} else if (c <= -9.5e-66) {
tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
} else if (c <= 1.85e+55) {
tmp = ((c / d) * (b / d)) - (a / d);
} else {
tmp = (b / c) - ((a / c) * (d / c));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -4.8e+76: tmp = ((d * (a / c)) - b) / math.hypot(c, d) elif c <= -9.5e-66: tmp = ((c * b) - (d * a)) / ((c * c) + (d * d)) elif c <= 1.85e+55: tmp = ((c / d) * (b / d)) - (a / d) else: tmp = (b / c) - ((a / c) * (d / c)) return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -4.8e+76) tmp = Float64(Float64(Float64(d * Float64(a / c)) - b) / hypot(c, d)); elseif (c <= -9.5e-66) tmp = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d))); elseif (c <= 1.85e+55) tmp = Float64(Float64(Float64(c / d) * Float64(b / d)) - Float64(a / d)); else tmp = Float64(Float64(b / c) - Float64(Float64(a / c) * Float64(d / c))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -4.8e+76) tmp = ((d * (a / c)) - b) / hypot(c, d); elseif (c <= -9.5e-66) tmp = ((c * b) - (d * a)) / ((c * c) + (d * d)); elseif (c <= 1.85e+55) tmp = ((c / d) * (b / d)) - (a / d); else tmp = (b / c) - ((a / c) * (d / c)); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -4.8e+76], N[(N[(N[(d * N[(a / c), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -9.5e-66], N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.85e+55], N[(N[(N[(c / d), $MachinePrecision] * N[(b / d), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], N[(N[(b / c), $MachinePrecision] - N[(N[(a / c), $MachinePrecision] * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -4.8 \cdot 10^{+76}:\\
\;\;\;\;\frac{d \cdot \frac{a}{c} - b}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;c \leq -9.5 \cdot 10^{-66}:\\
\;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;c \leq 1.85 \cdot 10^{+55}:\\
\;\;\;\;\frac{c}{d} \cdot \frac{b}{d} - \frac{a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c} - \frac{a}{c} \cdot \frac{d}{c}\\
\end{array}
\end{array}
if c < -4.8e76Initial program 38.8%
*-un-lft-identity38.8%
add-sqr-sqrt38.8%
times-frac38.8%
hypot-def38.8%
hypot-def61.3%
Applied egg-rr61.3%
Taylor expanded in c around -inf 85.9%
distribute-lft-in85.9%
associate-/l*88.3%
mul-1-neg88.3%
Applied egg-rr88.3%
distribute-lft-out88.3%
associate-*l/88.6%
*-lft-identity88.6%
unsub-neg88.6%
associate-/r/90.7%
*-commutative90.7%
Simplified90.7%
if -4.8e76 < c < -9.5000000000000004e-66Initial program 94.8%
if -9.5000000000000004e-66 < c < 1.8500000000000001e55Initial program 67.2%
Taylor expanded in c around 0 83.0%
+-commutative83.0%
mul-1-neg83.0%
unsub-neg83.0%
unpow283.0%
times-frac84.8%
Simplified84.8%
if 1.8500000000000001e55 < c Initial program 51.3%
Taylor expanded in c around inf 82.1%
+-commutative82.1%
mul-1-neg82.1%
unsub-neg82.1%
unpow282.1%
times-frac88.1%
Simplified88.1%
Final simplification87.6%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (- (/ b c) (* (/ a c) (/ d c)))))
(if (<= c -3.9e+121)
t_0
(if (<= c -1.66e-65)
(/ (- (* c b) (* d a)) (+ (* c c) (* d d)))
(if (<= c 6.8e+53) (- (* (/ c d) (/ b d)) (/ a d)) t_0)))))
double code(double a, double b, double c, double d) {
double t_0 = (b / c) - ((a / c) * (d / c));
double tmp;
if (c <= -3.9e+121) {
tmp = t_0;
} else if (c <= -1.66e-65) {
tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
} else if (c <= 6.8e+53) {
tmp = ((c / d) * (b / d)) - (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 / c) - ((a / c) * (d / c))
if (c <= (-3.9d+121)) then
tmp = t_0
else if (c <= (-1.66d-65)) then
tmp = ((c * b) - (d * a)) / ((c * c) + (d * d))
else if (c <= 6.8d+53) then
tmp = ((c / d) * (b / d)) - (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 / c) - ((a / c) * (d / c));
double tmp;
if (c <= -3.9e+121) {
tmp = t_0;
} else if (c <= -1.66e-65) {
tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
} else if (c <= 6.8e+53) {
tmp = ((c / d) * (b / d)) - (a / d);
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b, c, d): t_0 = (b / c) - ((a / c) * (d / c)) tmp = 0 if c <= -3.9e+121: tmp = t_0 elif c <= -1.66e-65: tmp = ((c * b) - (d * a)) / ((c * c) + (d * d)) elif c <= 6.8e+53: tmp = ((c / d) * (b / d)) - (a / d) else: tmp = t_0 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(b / c) - Float64(Float64(a / c) * Float64(d / c))) tmp = 0.0 if (c <= -3.9e+121) tmp = t_0; elseif (c <= -1.66e-65) tmp = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d))); elseif (c <= 6.8e+53) tmp = Float64(Float64(Float64(c / d) * Float64(b / d)) - Float64(a / d)); else tmp = t_0; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (b / c) - ((a / c) * (d / c)); tmp = 0.0; if (c <= -3.9e+121) tmp = t_0; elseif (c <= -1.66e-65) tmp = ((c * b) - (d * a)) / ((c * c) + (d * d)); elseif (c <= 6.8e+53) tmp = ((c / d) * (b / d)) - (a / d); else tmp = t_0; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(b / c), $MachinePrecision] - N[(N[(a / c), $MachinePrecision] * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -3.9e+121], t$95$0, If[LessEqual[c, -1.66e-65], N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 6.8e+53], N[(N[(N[(c / d), $MachinePrecision] * N[(b / d), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b}{c} - \frac{a}{c} \cdot \frac{d}{c}\\
\mathbf{if}\;c \leq -3.9 \cdot 10^{+121}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq -1.66 \cdot 10^{-65}:\\
\;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;c \leq 6.8 \cdot 10^{+53}:\\
\;\;\;\;\frac{c}{d} \cdot \frac{b}{d} - \frac{a}{d}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if c < -3.89999999999999984e121 or 6.79999999999999995e53 < c Initial program 45.0%
Taylor expanded in c around inf 80.5%
+-commutative80.5%
mul-1-neg80.5%
unsub-neg80.5%
unpow280.5%
times-frac88.5%
Simplified88.5%
if -3.89999999999999984e121 < c < -1.6599999999999999e-65Initial program 92.2%
if -1.6599999999999999e-65 < c < 6.79999999999999995e53Initial program 67.2%
Taylor expanded in c around 0 83.0%
+-commutative83.0%
mul-1-neg83.0%
unsub-neg83.0%
unpow283.0%
times-frac84.8%
Simplified84.8%
Final simplification87.2%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (- (/ b c) (* (/ a c) (/ d c)))))
(if (<= c -6.8e+75)
t_0
(if (<= c -1.7e-64)
(/ c (/ (+ (* c c) (* d d)) b))
(if (<= c 3.9e+53) (- (* (/ c d) (/ b d)) (/ a d)) t_0)))))
double code(double a, double b, double c, double d) {
double t_0 = (b / c) - ((a / c) * (d / c));
double tmp;
if (c <= -6.8e+75) {
tmp = t_0;
} else if (c <= -1.7e-64) {
tmp = c / (((c * c) + (d * d)) / b);
} else if (c <= 3.9e+53) {
tmp = ((c / d) * (b / d)) - (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 / c) - ((a / c) * (d / c))
if (c <= (-6.8d+75)) then
tmp = t_0
else if (c <= (-1.7d-64)) then
tmp = c / (((c * c) + (d * d)) / b)
else if (c <= 3.9d+53) then
tmp = ((c / d) * (b / d)) - (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 / c) - ((a / c) * (d / c));
double tmp;
if (c <= -6.8e+75) {
tmp = t_0;
} else if (c <= -1.7e-64) {
tmp = c / (((c * c) + (d * d)) / b);
} else if (c <= 3.9e+53) {
tmp = ((c / d) * (b / d)) - (a / d);
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b, c, d): t_0 = (b / c) - ((a / c) * (d / c)) tmp = 0 if c <= -6.8e+75: tmp = t_0 elif c <= -1.7e-64: tmp = c / (((c * c) + (d * d)) / b) elif c <= 3.9e+53: tmp = ((c / d) * (b / d)) - (a / d) else: tmp = t_0 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(b / c) - Float64(Float64(a / c) * Float64(d / c))) tmp = 0.0 if (c <= -6.8e+75) tmp = t_0; elseif (c <= -1.7e-64) tmp = Float64(c / Float64(Float64(Float64(c * c) + Float64(d * d)) / b)); elseif (c <= 3.9e+53) tmp = Float64(Float64(Float64(c / d) * Float64(b / d)) - Float64(a / d)); else tmp = t_0; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (b / c) - ((a / c) * (d / c)); tmp = 0.0; if (c <= -6.8e+75) tmp = t_0; elseif (c <= -1.7e-64) tmp = c / (((c * c) + (d * d)) / b); elseif (c <= 3.9e+53) tmp = ((c / d) * (b / d)) - (a / d); else tmp = t_0; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(b / c), $MachinePrecision] - N[(N[(a / c), $MachinePrecision] * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -6.8e+75], t$95$0, If[LessEqual[c, -1.7e-64], N[(c / N[(N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 3.9e+53], N[(N[(N[(c / d), $MachinePrecision] * N[(b / d), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b}{c} - \frac{a}{c} \cdot \frac{d}{c}\\
\mathbf{if}\;c \leq -6.8 \cdot 10^{+75}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq -1.7 \cdot 10^{-64}:\\
\;\;\;\;\frac{c}{\frac{c \cdot c + d \cdot d}{b}}\\
\mathbf{elif}\;c \leq 3.9 \cdot 10^{+53}:\\
\;\;\;\;\frac{c}{d} \cdot \frac{b}{d} - \frac{a}{d}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if c < -6.80000000000000022e75 or 3.89999999999999976e53 < c Initial program 46.6%
Taylor expanded in c around inf 80.5%
+-commutative80.5%
mul-1-neg80.5%
unsub-neg80.5%
unpow280.5%
times-frac88.1%
Simplified88.1%
if -6.80000000000000022e75 < c < -1.70000000000000006e-64Initial program 94.8%
*-un-lft-identity94.8%
add-sqr-sqrt94.8%
times-frac95.0%
hypot-def95.0%
hypot-def95.2%
Applied egg-rr95.2%
Taylor expanded in b around inf 85.5%
associate-/l*85.7%
unpow285.7%
unpow285.7%
Simplified85.7%
if -1.70000000000000006e-64 < c < 3.89999999999999976e53Initial program 67.2%
Taylor expanded in c around 0 83.0%
+-commutative83.0%
mul-1-neg83.0%
unsub-neg83.0%
unpow283.0%
times-frac84.8%
Simplified84.8%
Final simplification86.4%
(FPCore (a b c d) :precision binary64 (if (or (<= c -5.5e+41) (not (<= c 4.8e+55))) (/ b c) (- (* (/ c d) (/ b d)) (/ a d))))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -5.5e+41) || !(c <= 4.8e+55)) {
tmp = b / c;
} else {
tmp = ((c / d) * (b / 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 <= (-5.5d+41)) .or. (.not. (c <= 4.8d+55))) then
tmp = b / c
else
tmp = ((c / d) * (b / 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 <= -5.5e+41) || !(c <= 4.8e+55)) {
tmp = b / c;
} else {
tmp = ((c / d) * (b / d)) - (a / d);
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -5.5e+41) or not (c <= 4.8e+55): tmp = b / c else: tmp = ((c / d) * (b / d)) - (a / d) return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -5.5e+41) || !(c <= 4.8e+55)) tmp = Float64(b / c); else tmp = Float64(Float64(Float64(c / d) * Float64(b / d)) - Float64(a / d)); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((c <= -5.5e+41) || ~((c <= 4.8e+55))) tmp = b / c; else tmp = ((c / d) * (b / d)) - (a / d); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -5.5e+41], N[Not[LessEqual[c, 4.8e+55]], $MachinePrecision]], N[(b / c), $MachinePrecision], N[(N[(N[(c / d), $MachinePrecision] * N[(b / d), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -5.5 \cdot 10^{+41} \lor \neg \left(c \leq 4.8 \cdot 10^{+55}\right):\\
\;\;\;\;\frac{b}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{d} \cdot \frac{b}{d} - \frac{a}{d}\\
\end{array}
\end{array}
if c < -5.5000000000000003e41 or 4.7999999999999998e55 < c Initial program 48.8%
Taylor expanded in c around inf 77.4%
if -5.5000000000000003e41 < c < 4.7999999999999998e55Initial program 70.5%
Taylor expanded in c around 0 78.7%
+-commutative78.7%
mul-1-neg78.7%
unsub-neg78.7%
unpow278.7%
times-frac80.4%
Simplified80.4%
Final simplification79.0%
(FPCore (a b c d) :precision binary64 (if (or (<= c -1.1e-60) (not (<= c 2.25e+54))) (- (/ b c) (* (/ a c) (/ d c))) (- (* (/ c d) (/ b d)) (/ a d))))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -1.1e-60) || !(c <= 2.25e+54)) {
tmp = (b / c) - ((a / c) * (d / c));
} else {
tmp = ((c / d) * (b / 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 <= (-1.1d-60)) .or. (.not. (c <= 2.25d+54))) then
tmp = (b / c) - ((a / c) * (d / c))
else
tmp = ((c / d) * (b / 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 <= -1.1e-60) || !(c <= 2.25e+54)) {
tmp = (b / c) - ((a / c) * (d / c));
} else {
tmp = ((c / d) * (b / d)) - (a / d);
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -1.1e-60) or not (c <= 2.25e+54): tmp = (b / c) - ((a / c) * (d / c)) else: tmp = ((c / d) * (b / d)) - (a / d) return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -1.1e-60) || !(c <= 2.25e+54)) tmp = Float64(Float64(b / c) - Float64(Float64(a / c) * Float64(d / c))); else tmp = Float64(Float64(Float64(c / d) * Float64(b / d)) - Float64(a / d)); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((c <= -1.1e-60) || ~((c <= 2.25e+54))) tmp = (b / c) - ((a / c) * (d / c)); else tmp = ((c / d) * (b / d)) - (a / d); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -1.1e-60], N[Not[LessEqual[c, 2.25e+54]], $MachinePrecision]], N[(N[(b / c), $MachinePrecision] - N[(N[(a / c), $MachinePrecision] * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(c / d), $MachinePrecision] * N[(b / d), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.1 \cdot 10^{-60} \lor \neg \left(c \leq 2.25 \cdot 10^{+54}\right):\\
\;\;\;\;\frac{b}{c} - \frac{a}{c} \cdot \frac{d}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{d} \cdot \frac{b}{d} - \frac{a}{d}\\
\end{array}
\end{array}
if c < -1.0999999999999999e-60 or 2.24999999999999992e54 < c Initial program 54.4%
Taylor expanded in c around inf 76.3%
+-commutative76.3%
mul-1-neg76.3%
unsub-neg76.3%
unpow276.3%
times-frac82.6%
Simplified82.6%
if -1.0999999999999999e-60 < c < 2.24999999999999992e54Initial program 67.2%
Taylor expanded in c around 0 83.0%
+-commutative83.0%
mul-1-neg83.0%
unsub-neg83.0%
unpow283.0%
times-frac84.8%
Simplified84.8%
Final simplification83.7%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- a) d)))
(if (<= c -7.8e-61)
(/ b c)
(if (<= c 9.2e-150)
t_0
(if (<= c 1e-123)
(/ (* c b) (* d d))
(if (<= c 5.8e+55) t_0 (/ b c)))))))
double code(double a, double b, double c, double d) {
double t_0 = -a / d;
double tmp;
if (c <= -7.8e-61) {
tmp = b / c;
} else if (c <= 9.2e-150) {
tmp = t_0;
} else if (c <= 1e-123) {
tmp = (c * b) / (d * d);
} else if (c <= 5.8e+55) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = -a / d
if (c <= (-7.8d-61)) then
tmp = b / c
else if (c <= 9.2d-150) then
tmp = t_0
else if (c <= 1d-123) then
tmp = (c * b) / (d * d)
else if (c <= 5.8d+55) then
tmp = t_0
else
tmp = b / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = -a / d;
double tmp;
if (c <= -7.8e-61) {
tmp = b / c;
} else if (c <= 9.2e-150) {
tmp = t_0;
} else if (c <= 1e-123) {
tmp = (c * b) / (d * d);
} else if (c <= 5.8e+55) {
tmp = t_0;
} else {
tmp = b / c;
}
return tmp;
}
def code(a, b, c, d): t_0 = -a / d tmp = 0 if c <= -7.8e-61: tmp = b / c elif c <= 9.2e-150: tmp = t_0 elif c <= 1e-123: tmp = (c * b) / (d * d) elif c <= 5.8e+55: tmp = t_0 else: tmp = b / c return tmp
function code(a, b, c, d) t_0 = Float64(Float64(-a) / d) tmp = 0.0 if (c <= -7.8e-61) tmp = Float64(b / c); elseif (c <= 9.2e-150) tmp = t_0; elseif (c <= 1e-123) tmp = Float64(Float64(c * b) / Float64(d * d)); elseif (c <= 5.8e+55) tmp = t_0; else tmp = Float64(b / c); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = -a / d; tmp = 0.0; if (c <= -7.8e-61) tmp = b / c; elseif (c <= 9.2e-150) tmp = t_0; elseif (c <= 1e-123) tmp = (c * b) / (d * d); elseif (c <= 5.8e+55) tmp = t_0; else tmp = b / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[((-a) / d), $MachinePrecision]}, If[LessEqual[c, -7.8e-61], N[(b / c), $MachinePrecision], If[LessEqual[c, 9.2e-150], t$95$0, If[LessEqual[c, 1e-123], N[(N[(c * b), $MachinePrecision] / N[(d * d), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 5.8e+55], t$95$0, N[(b / c), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-a}{d}\\
\mathbf{if}\;c \leq -7.8 \cdot 10^{-61}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{elif}\;c \leq 9.2 \cdot 10^{-150}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 10^{-123}:\\
\;\;\;\;\frac{c \cdot b}{d \cdot d}\\
\mathbf{elif}\;c \leq 5.8 \cdot 10^{+55}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if c < -7.80000000000000065e-61 or 5.7999999999999997e55 < c Initial program 54.4%
Taylor expanded in c around inf 72.7%
if -7.80000000000000065e-61 < c < 9.20000000000000011e-150 or 1.0000000000000001e-123 < c < 5.7999999999999997e55Initial program 65.2%
Taylor expanded in c around 0 74.9%
associate-*r/74.9%
neg-mul-174.9%
Simplified74.9%
if 9.20000000000000011e-150 < c < 1.0000000000000001e-123Initial program 89.5%
Taylor expanded in b around inf 70.8%
unpow270.8%
unpow270.8%
Simplified70.8%
*-un-lft-identity70.8%
times-frac42.6%
pow142.6%
metadata-eval42.6%
sqrt-pow242.6%
+-commutative42.6%
hypot-udef42.6%
Applied egg-rr42.6%
Taylor expanded in c around 0 70.7%
unpow270.7%
Simplified70.7%
Final simplification73.6%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- a) d)))
(if (<= c -9.4e-61)
(/ b c)
(if (<= c 1.95e-150)
t_0
(if (<= c 1.02e-123)
(/ (* (/ c d) b) d)
(if (<= c 2.2e+54) t_0 (/ b c)))))))
double code(double a, double b, double c, double d) {
double t_0 = -a / d;
double tmp;
if (c <= -9.4e-61) {
tmp = b / c;
} else if (c <= 1.95e-150) {
tmp = t_0;
} else if (c <= 1.02e-123) {
tmp = ((c / d) * b) / d;
} else if (c <= 2.2e+54) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = -a / d
if (c <= (-9.4d-61)) then
tmp = b / c
else if (c <= 1.95d-150) then
tmp = t_0
else if (c <= 1.02d-123) then
tmp = ((c / d) * b) / d
else if (c <= 2.2d+54) then
tmp = t_0
else
tmp = b / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = -a / d;
double tmp;
if (c <= -9.4e-61) {
tmp = b / c;
} else if (c <= 1.95e-150) {
tmp = t_0;
} else if (c <= 1.02e-123) {
tmp = ((c / d) * b) / d;
} else if (c <= 2.2e+54) {
tmp = t_0;
} else {
tmp = b / c;
}
return tmp;
}
def code(a, b, c, d): t_0 = -a / d tmp = 0 if c <= -9.4e-61: tmp = b / c elif c <= 1.95e-150: tmp = t_0 elif c <= 1.02e-123: tmp = ((c / d) * b) / d elif c <= 2.2e+54: tmp = t_0 else: tmp = b / c return tmp
function code(a, b, c, d) t_0 = Float64(Float64(-a) / d) tmp = 0.0 if (c <= -9.4e-61) tmp = Float64(b / c); elseif (c <= 1.95e-150) tmp = t_0; elseif (c <= 1.02e-123) tmp = Float64(Float64(Float64(c / d) * b) / d); elseif (c <= 2.2e+54) tmp = t_0; else tmp = Float64(b / c); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = -a / d; tmp = 0.0; if (c <= -9.4e-61) tmp = b / c; elseif (c <= 1.95e-150) tmp = t_0; elseif (c <= 1.02e-123) tmp = ((c / d) * b) / d; elseif (c <= 2.2e+54) tmp = t_0; else tmp = b / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[((-a) / d), $MachinePrecision]}, If[LessEqual[c, -9.4e-61], N[(b / c), $MachinePrecision], If[LessEqual[c, 1.95e-150], t$95$0, If[LessEqual[c, 1.02e-123], N[(N[(N[(c / d), $MachinePrecision] * b), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 2.2e+54], t$95$0, N[(b / c), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-a}{d}\\
\mathbf{if}\;c \leq -9.4 \cdot 10^{-61}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{elif}\;c \leq 1.95 \cdot 10^{-150}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 1.02 \cdot 10^{-123}:\\
\;\;\;\;\frac{\frac{c}{d} \cdot b}{d}\\
\mathbf{elif}\;c \leq 2.2 \cdot 10^{+54}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if c < -9.3999999999999993e-61 or 2.1999999999999999e54 < c Initial program 54.4%
Taylor expanded in c around inf 72.7%
if -9.3999999999999993e-61 < c < 1.9500000000000001e-150 or 1.02e-123 < c < 2.1999999999999999e54Initial program 65.2%
Taylor expanded in c around 0 74.9%
associate-*r/74.9%
neg-mul-174.9%
Simplified74.9%
if 1.9500000000000001e-150 < c < 1.02e-123Initial program 89.5%
Taylor expanded in b around inf 70.8%
unpow270.8%
unpow270.8%
Simplified70.8%
Taylor expanded in c around 0 70.7%
unpow270.7%
times-frac52.1%
Simplified52.1%
associate-*r/70.7%
Applied egg-rr70.7%
Final simplification73.6%
(FPCore (a b c d) :precision binary64 (if (or (<= c -2.95e-61) (not (<= c 2.3e+53))) (/ b c) (/ (- a) d)))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -2.95e-61) || !(c <= 2.3e+53)) {
tmp = b / c;
} else {
tmp = -a / d;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if ((c <= (-2.95d-61)) .or. (.not. (c <= 2.3d+53))) then
tmp = b / c
else
tmp = -a / d
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -2.95e-61) || !(c <= 2.3e+53)) {
tmp = b / c;
} else {
tmp = -a / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -2.95e-61) or not (c <= 2.3e+53): tmp = b / c else: tmp = -a / d return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -2.95e-61) || !(c <= 2.3e+53)) tmp = Float64(b / c); else tmp = Float64(Float64(-a) / d); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((c <= -2.95e-61) || ~((c <= 2.3e+53))) tmp = b / c; else tmp = -a / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -2.95e-61], N[Not[LessEqual[c, 2.3e+53]], $MachinePrecision]], N[(b / c), $MachinePrecision], N[((-a) / d), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -2.95 \cdot 10^{-61} \lor \neg \left(c \leq 2.3 \cdot 10^{+53}\right):\\
\;\;\;\;\frac{b}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{-a}{d}\\
\end{array}
\end{array}
if c < -2.94999999999999986e-61 or 2.3000000000000002e53 < c Initial program 54.4%
Taylor expanded in c around inf 72.7%
if -2.94999999999999986e-61 < c < 2.3000000000000002e53Initial program 67.2%
Taylor expanded in c around 0 70.6%
associate-*r/70.6%
neg-mul-170.6%
Simplified70.6%
Final simplification71.8%
(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 60.4%
*-un-lft-identity60.4%
add-sqr-sqrt60.4%
times-frac60.4%
hypot-def60.4%
hypot-def73.6%
Applied egg-rr73.6%
Taylor expanded in c around -inf 31.0%
Taylor expanded in c around 0 8.9%
Final simplification8.9%
(FPCore (a b c d) :precision binary64 (/ b c))
double code(double a, double b, double c, double d) {
return b / c;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = b / c
end function
public static double code(double a, double b, double c, double d) {
return b / c;
}
def code(a, b, c, d): return b / c
function code(a, b, c, d) return Float64(b / c) end
function tmp = code(a, b, c, d) tmp = b / c; end
code[a_, b_, c_, d_] := N[(b / c), $MachinePrecision]
\begin{array}{l}
\\
\frac{b}{c}
\end{array}
Initial program 60.4%
Taylor expanded in c around inf 45.4%
Final simplification45.4%
(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 2023240
(FPCore (a b c d)
:name "Complex division, imag part"
:precision binary64
:herbie-target
(if (< (fabs d) (fabs c)) (/ (- b (* a (/ d c))) (+ c (* d (/ d c)))) (/ (+ (- a) (* b (/ c d))) (+ d (* c (/ c d)))))
(/ (- (* b c) (* a d)) (+ (* c c) (* d d))))