
(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 14 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 (- (* (/ 1.0 (hypot d c)) (* c (/ b (hypot d c)))) (/ (* d (/ a (hypot c d))) (hypot c d))))
double code(double a, double b, double c, double d) {
return ((1.0 / hypot(d, c)) * (c * (b / hypot(d, c)))) - ((d * (a / hypot(c, d))) / hypot(c, d));
}
public static double code(double a, double b, double c, double d) {
return ((1.0 / Math.hypot(d, c)) * (c * (b / Math.hypot(d, c)))) - ((d * (a / Math.hypot(c, d))) / Math.hypot(c, d));
}
def code(a, b, c, d): return ((1.0 / math.hypot(d, c)) * (c * (b / math.hypot(d, c)))) - ((d * (a / math.hypot(c, d))) / math.hypot(c, d))
function code(a, b, c, d) return Float64(Float64(Float64(1.0 / hypot(d, c)) * Float64(c * Float64(b / hypot(d, c)))) - Float64(Float64(d * Float64(a / hypot(c, d))) / hypot(c, d))) end
function tmp = code(a, b, c, d) tmp = ((1.0 / hypot(d, c)) * (c * (b / hypot(d, c)))) - ((d * (a / hypot(c, d))) / hypot(c, d)); end
code[a_, b_, c_, d_] := N[(N[(N[(1.0 / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision] * N[(c * N[(b / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(d * N[(a / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\mathsf{hypot}\left(d, c\right)} \cdot \left(c \cdot \frac{b}{\mathsf{hypot}\left(d, c\right)}\right) - \frac{d \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}
\end{array}
Initial program 58.8%
div-sub55.2%
*-un-lft-identity55.2%
fma-define55.3%
add-sqr-sqrt55.2%
times-frac55.3%
fma-neg55.3%
fma-define55.3%
hypot-define55.3%
fma-define55.3%
hypot-define63.6%
associate-/l*65.2%
fma-define65.2%
add-sqr-sqrt65.2%
pow265.2%
Applied egg-rr65.2%
fma-neg65.2%
Simplified77.4%
*-un-lft-identity77.4%
unpow277.4%
times-frac85.4%
hypot-undefine77.4%
+-commutative77.4%
hypot-define85.4%
hypot-undefine77.4%
+-commutative77.4%
hypot-define85.4%
Applied egg-rr85.4%
associate-*l/85.4%
*-lft-identity85.4%
Simplified85.4%
associate-*r/98.2%
Applied egg-rr98.2%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* c b) (* d a)) (+ (* c c) (* d d)))))
(if (or (<= t_0 (- INFINITY)) (not (<= t_0 INFINITY)))
(-
(* (/ 1.0 (hypot d c)) (* c (/ b (hypot d c))))
(* d (/ (/ a (hypot c d)) (hypot c d))))
(* (/ 1.0 (hypot c d)) (/ (fma b c (* d (- a))) (hypot c 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 ((t_0 <= -((double) INFINITY)) || !(t_0 <= ((double) INFINITY))) {
tmp = ((1.0 / hypot(d, c)) * (c * (b / hypot(d, c)))) - (d * ((a / hypot(c, d)) / hypot(c, d)));
} else {
tmp = (1.0 / hypot(c, d)) * (fma(b, c, (d * -a)) / hypot(c, 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 ((t_0 <= Float64(-Inf)) || !(t_0 <= Inf)) tmp = Float64(Float64(Float64(1.0 / hypot(d, c)) * Float64(c * Float64(b / hypot(d, c)))) - Float64(d * Float64(Float64(a / hypot(c, d)) / hypot(c, d)))); else tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(fma(b, c, Float64(d * Float64(-a))) / hypot(c, d))); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, (-Infinity)], N[Not[LessEqual[t$95$0, Infinity]], $MachinePrecision]], N[(N[(N[(1.0 / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision] * N[(c * N[(b / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(d * N[(N[(a / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(N[(b * c + N[(d * (-a)), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{if}\;t\_0 \leq -\infty \lor \neg \left(t\_0 \leq \infty\right):\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(d, c\right)} \cdot \left(c \cdot \frac{b}{\mathsf{hypot}\left(d, c\right)}\right) - d \cdot \frac{\frac{a}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{\mathsf{fma}\left(b, c, d \cdot \left(-a\right)\right)}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\end{array}
if (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < -inf.0 or +inf.0 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 12.4%
div-sub7.9%
*-un-lft-identity7.9%
fma-define7.9%
add-sqr-sqrt7.9%
times-frac7.9%
fma-neg7.9%
fma-define7.9%
hypot-define7.9%
fma-define7.9%
hypot-define11.9%
associate-/l*18.4%
fma-define18.4%
add-sqr-sqrt18.4%
pow218.4%
Applied egg-rr18.4%
fma-neg18.4%
Simplified63.8%
*-un-lft-identity63.8%
unpow263.8%
times-frac84.6%
hypot-undefine63.8%
+-commutative63.8%
hypot-define84.6%
hypot-undefine63.8%
+-commutative63.8%
hypot-define84.6%
Applied egg-rr84.6%
associate-*l/84.5%
*-lft-identity84.5%
Simplified84.5%
if -inf.0 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < +inf.0Initial program 76.3%
fma-define76.3%
*-un-lft-identity76.3%
add-sqr-sqrt76.3%
times-frac76.3%
fma-define76.3%
hypot-define76.3%
fma-neg76.3%
distribute-rgt-neg-in76.3%
fma-define76.3%
hypot-define96.9%
Applied egg-rr96.9%
Final simplification93.5%
(FPCore (a b c d)
:precision binary64
(let* ((t_0
(-
(* (/ 1.0 (hypot d c)) (* c (/ b (hypot d c))))
(* d (/ a (pow (hypot d c) 2.0)))))
(t_1 (/ (- (* c (/ b d)) a) d)))
(if (<= d -6.8e+87)
t_1
(if (<= d -4.6e-48)
t_0
(if (<= d 6.2e-102)
(/ (- b (/ (* d a) c)) c)
(if (<= d 9.6e+116) t_0 t_1))))))
double code(double a, double b, double c, double d) {
double t_0 = ((1.0 / hypot(d, c)) * (c * (b / hypot(d, c)))) - (d * (a / pow(hypot(d, c), 2.0)));
double t_1 = ((c * (b / d)) - a) / d;
double tmp;
if (d <= -6.8e+87) {
tmp = t_1;
} else if (d <= -4.6e-48) {
tmp = t_0;
} else if (d <= 6.2e-102) {
tmp = (b - ((d * a) / c)) / c;
} else if (d <= 9.6e+116) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = ((1.0 / Math.hypot(d, c)) * (c * (b / Math.hypot(d, c)))) - (d * (a / Math.pow(Math.hypot(d, c), 2.0)));
double t_1 = ((c * (b / d)) - a) / d;
double tmp;
if (d <= -6.8e+87) {
tmp = t_1;
} else if (d <= -4.6e-48) {
tmp = t_0;
} else if (d <= 6.2e-102) {
tmp = (b - ((d * a) / c)) / c;
} else if (d <= 9.6e+116) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(a, b, c, d): t_0 = ((1.0 / math.hypot(d, c)) * (c * (b / math.hypot(d, c)))) - (d * (a / math.pow(math.hypot(d, c), 2.0))) t_1 = ((c * (b / d)) - a) / d tmp = 0 if d <= -6.8e+87: tmp = t_1 elif d <= -4.6e-48: tmp = t_0 elif d <= 6.2e-102: tmp = (b - ((d * a) / c)) / c elif d <= 9.6e+116: tmp = t_0 else: tmp = t_1 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(Float64(1.0 / hypot(d, c)) * Float64(c * Float64(b / hypot(d, c)))) - Float64(d * Float64(a / (hypot(d, c) ^ 2.0)))) t_1 = Float64(Float64(Float64(c * Float64(b / d)) - a) / d) tmp = 0.0 if (d <= -6.8e+87) tmp = t_1; elseif (d <= -4.6e-48) tmp = t_0; elseif (d <= 6.2e-102) tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c); elseif (d <= 9.6e+116) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((1.0 / hypot(d, c)) * (c * (b / hypot(d, c)))) - (d * (a / (hypot(d, c) ^ 2.0))); t_1 = ((c * (b / d)) - a) / d; tmp = 0.0; if (d <= -6.8e+87) tmp = t_1; elseif (d <= -4.6e-48) tmp = t_0; elseif (d <= 6.2e-102) tmp = (b - ((d * a) / c)) / c; elseif (d <= 9.6e+116) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(1.0 / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision] * N[(c * N[(b / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(d * N[(a / N[Power[N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -6.8e+87], t$95$1, If[LessEqual[d, -4.6e-48], t$95$0, If[LessEqual[d, 6.2e-102], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 9.6e+116], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\mathsf{hypot}\left(d, c\right)} \cdot \left(c \cdot \frac{b}{\mathsf{hypot}\left(d, c\right)}\right) - d \cdot \frac{a}{{\left(\mathsf{hypot}\left(d, c\right)\right)}^{2}}\\
t_1 := \frac{c \cdot \frac{b}{d} - a}{d}\\
\mathbf{if}\;d \leq -6.8 \cdot 10^{+87}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d \leq -4.6 \cdot 10^{-48}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 6.2 \cdot 10^{-102}:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\
\mathbf{elif}\;d \leq 9.6 \cdot 10^{+116}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if d < -6.8000000000000004e87 or 9.6000000000000001e116 < d Initial program 41.5%
Taylor expanded in c around 0 81.8%
+-commutative81.8%
mul-1-neg81.8%
unsub-neg81.8%
unpow281.8%
associate-/r*84.0%
div-sub84.0%
*-commutative84.0%
associate-/l*92.1%
Simplified92.1%
if -6.8000000000000004e87 < d < -4.6000000000000001e-48 or 6.20000000000000026e-102 < d < 9.6000000000000001e116Initial program 76.8%
div-sub76.8%
*-un-lft-identity76.8%
fma-define76.8%
add-sqr-sqrt76.8%
times-frac76.7%
fma-neg76.8%
fma-define76.7%
hypot-define76.8%
fma-define76.8%
hypot-define85.0%
associate-/l*85.4%
fma-define85.4%
add-sqr-sqrt85.4%
pow285.4%
Applied egg-rr85.4%
fma-neg85.4%
Simplified97.2%
if -4.6000000000000001e-48 < d < 6.20000000000000026e-102Initial program 62.2%
Taylor expanded in c around inf 93.8%
mul-1-neg93.8%
unsub-neg93.8%
associate-/l*93.6%
Simplified93.6%
Taylor expanded in a around 0 93.8%
*-commutative93.8%
Simplified93.8%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* c (/ b d)) a) d)))
(if (<= d -1.05e+14)
t_0
(if (<= d 3.8e-102)
(/ (- b (/ (* d a) c)) c)
(if (<= d 9.6e+114)
(* (/ 1.0 (hypot c d)) (/ (fma b c (* d (- a))) (hypot c d)))
t_0)))))
double code(double a, double b, double c, double d) {
double t_0 = ((c * (b / d)) - a) / d;
double tmp;
if (d <= -1.05e+14) {
tmp = t_0;
} else if (d <= 3.8e-102) {
tmp = (b - ((d * a) / c)) / c;
} else if (d <= 9.6e+114) {
tmp = (1.0 / hypot(c, d)) * (fma(b, c, (d * -a)) / hypot(c, d));
} else {
tmp = t_0;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(Float64(c * Float64(b / d)) - a) / d) tmp = 0.0 if (d <= -1.05e+14) tmp = t_0; elseif (d <= 3.8e-102) tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c); elseif (d <= 9.6e+114) tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(fma(b, c, Float64(d * Float64(-a))) / hypot(c, d))); else tmp = t_0; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -1.05e+14], t$95$0, If[LessEqual[d, 3.8e-102], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 9.6e+114], N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(N[(b * c + N[(d * (-a)), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c \cdot \frac{b}{d} - a}{d}\\
\mathbf{if}\;d \leq -1.05 \cdot 10^{+14}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 3.8 \cdot 10^{-102}:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\
\mathbf{elif}\;d \leq 9.6 \cdot 10^{+114}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{\mathsf{fma}\left(b, c, d \cdot \left(-a\right)\right)}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d < -1.05e14 or 9.6e114 < d Initial program 44.1%
Taylor expanded in c around 0 80.1%
+-commutative80.1%
mul-1-neg80.1%
unsub-neg80.1%
unpow280.1%
associate-/r*82.1%
div-sub82.1%
*-commutative82.1%
associate-/l*89.3%
Simplified89.3%
if -1.05e14 < d < 3.80000000000000026e-102Initial program 63.5%
Taylor expanded in c around inf 92.0%
mul-1-neg92.0%
unsub-neg92.0%
associate-/l*91.8%
Simplified91.8%
Taylor expanded in a around 0 92.0%
*-commutative92.0%
Simplified92.0%
if 3.80000000000000026e-102 < d < 9.6e114Initial program 80.6%
fma-define80.7%
*-un-lft-identity80.7%
add-sqr-sqrt80.6%
times-frac80.5%
fma-define80.5%
hypot-define80.5%
fma-neg80.5%
distribute-rgt-neg-in80.5%
fma-define80.5%
hypot-define89.9%
Applied egg-rr89.9%
Final simplification90.6%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* c (/ b d)) a) d)))
(if (<= d -7e+15)
t_0
(if (<= d 3.2e-94)
(/ (- b (/ (* d a) c)) c)
(if (<= d 2.4e+64) (/ (- (* c b) (* d a)) (fma c c (* d d))) t_0)))))
double code(double a, double b, double c, double d) {
double t_0 = ((c * (b / d)) - a) / d;
double tmp;
if (d <= -7e+15) {
tmp = t_0;
} else if (d <= 3.2e-94) {
tmp = (b - ((d * a) / c)) / c;
} else if (d <= 2.4e+64) {
tmp = ((c * b) - (d * a)) / fma(c, c, (d * d));
} else {
tmp = t_0;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(Float64(c * Float64(b / d)) - a) / d) tmp = 0.0 if (d <= -7e+15) tmp = t_0; elseif (d <= 3.2e-94) tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c); elseif (d <= 2.4e+64) tmp = Float64(Float64(Float64(c * b) - Float64(d * a)) / fma(c, c, Float64(d * d))); else tmp = t_0; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -7e+15], t$95$0, If[LessEqual[d, 3.2e-94], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 2.4e+64], N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c \cdot \frac{b}{d} - a}{d}\\
\mathbf{if}\;d \leq -7 \cdot 10^{+15}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 3.2 \cdot 10^{-94}:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\
\mathbf{elif}\;d \leq 2.4 \cdot 10^{+64}:\\
\;\;\;\;\frac{c \cdot b - d \cdot a}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d < -7e15 or 2.39999999999999999e64 < d Initial program 46.5%
Taylor expanded in c around 0 80.7%
+-commutative80.7%
mul-1-neg80.7%
unsub-neg80.7%
unpow280.7%
associate-/r*82.6%
div-sub82.5%
*-commutative82.5%
associate-/l*89.2%
Simplified89.2%
if -7e15 < d < 3.19999999999999997e-94Initial program 63.5%
Taylor expanded in c around inf 92.0%
mul-1-neg92.0%
unsub-neg92.0%
associate-/l*91.8%
Simplified91.8%
Taylor expanded in a around 0 92.0%
*-commutative92.0%
Simplified92.0%
if 3.19999999999999997e-94 < d < 2.39999999999999999e64Initial program 81.8%
fma-define81.9%
Simplified81.9%
Final simplification89.6%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* c (/ b d)) a) d)))
(if (<= d -8200.0)
t_0
(if (<= d 1.8e-99)
(/ (- b (/ (* d a) c)) c)
(if (<= d 2.2e+64) (/ (- (* c b) (* d a)) (+ (* c c) (* d d))) t_0)))))
double code(double a, double b, double c, double d) {
double t_0 = ((c * (b / d)) - a) / d;
double tmp;
if (d <= -8200.0) {
tmp = t_0;
} else if (d <= 1.8e-99) {
tmp = (b - ((d * a) / c)) / c;
} else if (d <= 2.2e+64) {
tmp = ((c * b) - (d * a)) / ((c * c) + (d * 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 = ((c * (b / d)) - a) / d
if (d <= (-8200.0d0)) then
tmp = t_0
else if (d <= 1.8d-99) then
tmp = (b - ((d * a) / c)) / c
else if (d <= 2.2d+64) then
tmp = ((c * b) - (d * a)) / ((c * c) + (d * 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 = ((c * (b / d)) - a) / d;
double tmp;
if (d <= -8200.0) {
tmp = t_0;
} else if (d <= 1.8e-99) {
tmp = (b - ((d * a) / c)) / c;
} else if (d <= 2.2e+64) {
tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b, c, d): t_0 = ((c * (b / d)) - a) / d tmp = 0 if d <= -8200.0: tmp = t_0 elif d <= 1.8e-99: tmp = (b - ((d * a) / c)) / c elif d <= 2.2e+64: tmp = ((c * b) - (d * a)) / ((c * c) + (d * d)) else: tmp = t_0 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(Float64(c * Float64(b / d)) - a) / d) tmp = 0.0 if (d <= -8200.0) tmp = t_0; elseif (d <= 1.8e-99) tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c); elseif (d <= 2.2e+64) tmp = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d))); else tmp = t_0; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((c * (b / d)) - a) / d; tmp = 0.0; if (d <= -8200.0) tmp = t_0; elseif (d <= 1.8e-99) tmp = (b - ((d * a) / c)) / c; elseif (d <= 2.2e+64) tmp = ((c * b) - (d * a)) / ((c * c) + (d * d)); else tmp = t_0; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -8200.0], t$95$0, If[LessEqual[d, 1.8e-99], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 2.2e+64], N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c \cdot \frac{b}{d} - a}{d}\\
\mathbf{if}\;d \leq -8200:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 1.8 \cdot 10^{-99}:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\
\mathbf{elif}\;d \leq 2.2 \cdot 10^{+64}:\\
\;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d < -8200 or 2.20000000000000002e64 < d Initial program 46.5%
Taylor expanded in c around 0 80.7%
+-commutative80.7%
mul-1-neg80.7%
unsub-neg80.7%
unpow280.7%
associate-/r*82.6%
div-sub82.5%
*-commutative82.5%
associate-/l*89.2%
Simplified89.2%
if -8200 < d < 1.8e-99Initial program 63.5%
Taylor expanded in c around inf 92.0%
mul-1-neg92.0%
unsub-neg92.0%
associate-/l*91.8%
Simplified91.8%
Taylor expanded in a around 0 92.0%
*-commutative92.0%
Simplified92.0%
if 1.8e-99 < d < 2.20000000000000002e64Initial program 81.8%
Final simplification89.5%
(FPCore (a b c d) :precision binary64 (if (or (<= d -8e+16) (not (<= d 0.32))) (/ (- (* c (/ b d)) a) d) (/ (- b (/ (* d a) c)) c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -8e+16) || !(d <= 0.32)) {
tmp = ((c * (b / d)) - a) / d;
} else {
tmp = (b - ((d * a) / 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 <= (-8d+16)) .or. (.not. (d <= 0.32d0))) then
tmp = ((c * (b / d)) - a) / d
else
tmp = (b - ((d * a) / c)) / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -8e+16) || !(d <= 0.32)) {
tmp = ((c * (b / d)) - a) / d;
} else {
tmp = (b - ((d * a) / c)) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -8e+16) or not (d <= 0.32): tmp = ((c * (b / d)) - a) / d else: tmp = (b - ((d * a) / c)) / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -8e+16) || !(d <= 0.32)) tmp = Float64(Float64(Float64(c * Float64(b / d)) - a) / d); else tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -8e+16) || ~((d <= 0.32))) tmp = ((c * (b / d)) - a) / d; else tmp = (b - ((d * a) / c)) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -8e+16], N[Not[LessEqual[d, 0.32]], $MachinePrecision]], N[(N[(N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -8 \cdot 10^{+16} \lor \neg \left(d \leq 0.32\right):\\
\;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\
\end{array}
\end{array}
if d < -8e16 or 0.320000000000000007 < d Initial program 51.1%
Taylor expanded in c around 0 77.4%
+-commutative77.4%
mul-1-neg77.4%
unsub-neg77.4%
unpow277.4%
associate-/r*79.1%
div-sub79.0%
*-commutative79.0%
associate-/l*84.9%
Simplified84.9%
if -8e16 < d < 0.320000000000000007Initial program 65.5%
Taylor expanded in c around inf 88.9%
mul-1-neg88.9%
unsub-neg88.9%
associate-/l*88.8%
Simplified88.8%
Taylor expanded in a around 0 88.9%
*-commutative88.9%
Simplified88.9%
Final simplification87.0%
(FPCore (a b c d) :precision binary64 (if (or (<= d -1.7e+19) (not (<= d 5.6))) (/ (- (* b (/ c d)) a) d) (/ (- b (/ (* d a) c)) c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -1.7e+19) || !(d <= 5.6)) {
tmp = ((b * (c / d)) - a) / d;
} else {
tmp = (b - ((d * a) / 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 <= (-1.7d+19)) .or. (.not. (d <= 5.6d0))) then
tmp = ((b * (c / d)) - a) / d
else
tmp = (b - ((d * a) / c)) / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -1.7e+19) || !(d <= 5.6)) {
tmp = ((b * (c / d)) - a) / d;
} else {
tmp = (b - ((d * a) / c)) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -1.7e+19) or not (d <= 5.6): tmp = ((b * (c / d)) - a) / d else: tmp = (b - ((d * a) / c)) / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -1.7e+19) || !(d <= 5.6)) tmp = Float64(Float64(Float64(b * Float64(c / d)) - a) / d); else tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -1.7e+19) || ~((d <= 5.6))) tmp = ((b * (c / d)) - a) / d; else tmp = (b - ((d * a) / c)) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -1.7e+19], N[Not[LessEqual[d, 5.6]], $MachinePrecision]], N[(N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.7 \cdot 10^{+19} \lor \neg \left(d \leq 5.6\right):\\
\;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\
\end{array}
\end{array}
if d < -1.7e19 or 5.5999999999999996 < d Initial program 51.1%
div-sub51.1%
*-commutative51.1%
fma-define51.1%
add-sqr-sqrt51.1%
times-frac49.9%
fma-neg49.9%
fma-define49.9%
hypot-define49.9%
fma-define49.9%
hypot-define62.1%
associate-/l*69.0%
fma-define69.0%
add-sqr-sqrt69.0%
pow269.0%
Applied egg-rr69.0%
Taylor expanded in d around inf 79.0%
associate-/l*82.5%
Simplified82.5%
if -1.7e19 < d < 5.5999999999999996Initial program 65.5%
Taylor expanded in c around inf 88.9%
mul-1-neg88.9%
unsub-neg88.9%
associate-/l*88.8%
Simplified88.8%
Taylor expanded in a around 0 88.9%
*-commutative88.9%
Simplified88.9%
Final simplification85.9%
(FPCore (a b c d) :precision binary64 (if (or (<= d -4.2e+17) (not (<= d 5.2e+63))) (/ a (- d)) (/ (- b (/ (* d a) c)) c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -4.2e+17) || !(d <= 5.2e+63)) {
tmp = a / -d;
} else {
tmp = (b - ((d * a) / 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 <= (-4.2d+17)) .or. (.not. (d <= 5.2d+63))) then
tmp = a / -d
else
tmp = (b - ((d * a) / c)) / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -4.2e+17) || !(d <= 5.2e+63)) {
tmp = a / -d;
} else {
tmp = (b - ((d * a) / c)) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -4.2e+17) or not (d <= 5.2e+63): tmp = a / -d else: tmp = (b - ((d * a) / c)) / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -4.2e+17) || !(d <= 5.2e+63)) tmp = Float64(a / Float64(-d)); else tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -4.2e+17) || ~((d <= 5.2e+63))) tmp = a / -d; else tmp = (b - ((d * a) / c)) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -4.2e+17], N[Not[LessEqual[d, 5.2e+63]], $MachinePrecision]], N[(a / (-d)), $MachinePrecision], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -4.2 \cdot 10^{+17} \lor \neg \left(d \leq 5.2 \cdot 10^{+63}\right):\\
\;\;\;\;\frac{a}{-d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\
\end{array}
\end{array}
if d < -4.2e17 or 5.2000000000000002e63 < d Initial program 46.5%
Taylor expanded in c around 0 72.5%
associate-*r/72.5%
neg-mul-172.5%
Simplified72.5%
if -4.2e17 < d < 5.2000000000000002e63Initial program 67.4%
Taylor expanded in c around inf 85.0%
mul-1-neg85.0%
unsub-neg85.0%
associate-/l*84.9%
Simplified84.9%
Taylor expanded in a around 0 85.0%
*-commutative85.0%
Simplified85.0%
Final simplification79.9%
(FPCore (a b c d) :precision binary64 (if (or (<= d -6e+18) (not (<= d 1.35e+63))) (/ a (- d)) (/ (- b (* d (/ a c))) c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -6e+18) || !(d <= 1.35e+63)) {
tmp = a / -d;
} else {
tmp = (b - (d * (a / 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 <= (-6d+18)) .or. (.not. (d <= 1.35d+63))) then
tmp = a / -d
else
tmp = (b - (d * (a / c))) / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -6e+18) || !(d <= 1.35e+63)) {
tmp = a / -d;
} else {
tmp = (b - (d * (a / c))) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -6e+18) or not (d <= 1.35e+63): tmp = a / -d else: tmp = (b - (d * (a / c))) / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -6e+18) || !(d <= 1.35e+63)) tmp = Float64(a / Float64(-d)); else tmp = Float64(Float64(b - Float64(d * Float64(a / c))) / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -6e+18) || ~((d <= 1.35e+63))) tmp = a / -d; else tmp = (b - (d * (a / c))) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -6e+18], N[Not[LessEqual[d, 1.35e+63]], $MachinePrecision]], N[(a / (-d)), $MachinePrecision], N[(N[(b - N[(d * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -6 \cdot 10^{+18} \lor \neg \left(d \leq 1.35 \cdot 10^{+63}\right):\\
\;\;\;\;\frac{a}{-d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\
\end{array}
\end{array}
if d < -6e18 or 1.35000000000000009e63 < d Initial program 46.5%
Taylor expanded in c around 0 72.5%
associate-*r/72.5%
neg-mul-172.5%
Simplified72.5%
if -6e18 < d < 1.35000000000000009e63Initial program 67.4%
Taylor expanded in c around inf 85.0%
mul-1-neg85.0%
unsub-neg85.0%
associate-/l*84.9%
Simplified84.9%
Taylor expanded in a around 0 85.0%
*-commutative85.0%
Simplified85.0%
associate-/l*85.0%
Applied egg-rr85.0%
Final simplification79.9%
(FPCore (a b c d) :precision binary64 (if (or (<= d -7e+18) (not (<= d 2.45e+63))) (/ a (- d)) (/ (- b (* a (/ d c))) c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -7e+18) || !(d <= 2.45e+63)) {
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 <= (-7d+18)) .or. (.not. (d <= 2.45d+63))) 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 <= -7e+18) || !(d <= 2.45e+63)) {
tmp = a / -d;
} else {
tmp = (b - (a * (d / c))) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -7e+18) or not (d <= 2.45e+63): tmp = a / -d else: tmp = (b - (a * (d / c))) / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -7e+18) || !(d <= 2.45e+63)) 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 <= -7e+18) || ~((d <= 2.45e+63))) tmp = a / -d; else tmp = (b - (a * (d / c))) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -7e+18], N[Not[LessEqual[d, 2.45e+63]], $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 -7 \cdot 10^{+18} \lor \neg \left(d \leq 2.45 \cdot 10^{+63}\right):\\
\;\;\;\;\frac{a}{-d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\
\end{array}
\end{array}
if d < -7e18 or 2.4499999999999998e63 < d Initial program 46.5%
Taylor expanded in c around 0 72.5%
associate-*r/72.5%
neg-mul-172.5%
Simplified72.5%
if -7e18 < d < 2.4499999999999998e63Initial program 67.4%
Taylor expanded in c around inf 85.0%
mul-1-neg85.0%
unsub-neg85.0%
associate-/l*84.9%
Simplified84.9%
Final simplification79.8%
(FPCore (a b c d) :precision binary64 (if (or (<= d -2.2) (not (<= d 1.4e+63))) (/ a (- d)) (/ b c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -2.2) || !(d <= 1.4e+63)) {
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 <= (-2.2d0)) .or. (.not. (d <= 1.4d+63))) 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 <= -2.2) || !(d <= 1.4e+63)) {
tmp = a / -d;
} else {
tmp = b / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -2.2) or not (d <= 1.4e+63): tmp = a / -d else: tmp = b / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -2.2) || !(d <= 1.4e+63)) tmp = Float64(a / Float64(-d)); else tmp = Float64(b / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -2.2) || ~((d <= 1.4e+63))) tmp = a / -d; else tmp = b / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -2.2], N[Not[LessEqual[d, 1.4e+63]], $MachinePrecision]], N[(a / (-d)), $MachinePrecision], N[(b / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -2.2 \lor \neg \left(d \leq 1.4 \cdot 10^{+63}\right):\\
\;\;\;\;\frac{a}{-d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if d < -2.2000000000000002 or 1.39999999999999993e63 < d Initial program 46.6%
Taylor expanded in c around 0 72.1%
associate-*r/72.1%
neg-mul-172.1%
Simplified72.1%
if -2.2000000000000002 < d < 1.39999999999999993e63Initial program 67.6%
Taylor expanded in c around inf 72.6%
Final simplification72.4%
(FPCore (a b c d) :precision binary64 (if (or (<= d -5.4e+78) (not (<= d 1.55e+114))) (/ a d) (/ b c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -5.4e+78) || !(d <= 1.55e+114)) {
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.4d+78)) .or. (.not. (d <= 1.55d+114))) 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.4e+78) || !(d <= 1.55e+114)) {
tmp = a / d;
} else {
tmp = b / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -5.4e+78) or not (d <= 1.55e+114): tmp = a / d else: tmp = b / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -5.4e+78) || !(d <= 1.55e+114)) 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.4e+78) || ~((d <= 1.55e+114))) tmp = a / d; else tmp = b / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -5.4e+78], N[Not[LessEqual[d, 1.55e+114]], $MachinePrecision]], N[(a / d), $MachinePrecision], N[(b / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -5.4 \cdot 10^{+78} \lor \neg \left(d \leq 1.55 \cdot 10^{+114}\right):\\
\;\;\;\;\frac{a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if d < -5.40000000000000009e78 or 1.55e114 < d Initial program 42.9%
Taylor expanded in c around 0 75.7%
associate-*r/75.7%
neg-mul-175.7%
Simplified75.7%
add-sqr-sqrt32.7%
sqrt-unprod37.3%
sqr-neg37.3%
sqrt-unprod11.9%
add-sqr-sqrt23.5%
*-un-lft-identity23.5%
Applied egg-rr23.5%
*-lft-identity23.5%
Simplified23.5%
if -5.40000000000000009e78 < d < 1.55e114Initial program 67.2%
Taylor expanded in c around inf 67.6%
Final simplification52.4%
(FPCore (a b c d) :precision binary64 (/ a d))
double code(double a, double b, double c, double d) {
return a / d;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = a / d
end function
public static double code(double a, double b, double c, double d) {
return a / d;
}
def code(a, b, c, d): return a / d
function code(a, b, c, d) return Float64(a / d) end
function tmp = code(a, b, c, d) tmp = a / d; end
code[a_, b_, c_, d_] := N[(a / d), $MachinePrecision]
\begin{array}{l}
\\
\frac{a}{d}
\end{array}
Initial program 58.8%
Taylor expanded in c around 0 39.9%
associate-*r/39.9%
neg-mul-139.9%
Simplified39.9%
add-sqr-sqrt19.9%
sqrt-unprod22.4%
sqr-neg22.4%
sqrt-unprod5.4%
add-sqr-sqrt10.8%
*-un-lft-identity10.8%
Applied egg-rr10.8%
*-lft-identity10.8%
Simplified10.8%
(FPCore (a b c d) :precision binary64 (if (< (fabs d) (fabs c)) (/ (- b (* a (/ d c))) (+ c (* d (/ d c)))) (/ (+ (- a) (* b (/ c d))) (+ d (* c (/ c d))))))
double code(double a, double b, double c, double d) {
double tmp;
if (fabs(d) < fabs(c)) {
tmp = (b - (a * (d / c))) / (c + (d * (d / c)));
} else {
tmp = (-a + (b * (c / d))) / (d + (c * (c / d)));
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (abs(d) < abs(c)) then
tmp = (b - (a * (d / c))) / (c + (d * (d / c)))
else
tmp = (-a + (b * (c / d))) / (d + (c * (c / d)))
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (Math.abs(d) < Math.abs(c)) {
tmp = (b - (a * (d / c))) / (c + (d * (d / c)));
} else {
tmp = (-a + (b * (c / d))) / (d + (c * (c / d)));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if math.fabs(d) < math.fabs(c): tmp = (b - (a * (d / c))) / (c + (d * (d / c))) else: tmp = (-a + (b * (c / d))) / (d + (c * (c / d))) return tmp
function code(a, b, c, d) tmp = 0.0 if (abs(d) < abs(c)) tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / Float64(c + Float64(d * Float64(d / c)))); else tmp = Float64(Float64(Float64(-a) + Float64(b * Float64(c / d))) / Float64(d + Float64(c * Float64(c / d)))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (abs(d) < abs(c)) tmp = (b - (a * (d / c))) / (c + (d * (d / c))); else tmp = (-a + (b * (c / d))) / (d + (c * (c / d))); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Less[N[Abs[d], $MachinePrecision], N[Abs[c], $MachinePrecision]], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(c + N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[((-a) + N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(d + N[(c * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left|d\right| < \left|c\right|:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c + d \cdot \frac{d}{c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-a\right) + b \cdot \frac{c}{d}}{d + c \cdot \frac{c}{d}}\\
\end{array}
\end{array}
herbie shell --seed 2024121
(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))))