
(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)) (* (/ (/ d (hypot d c)) (hypot d c)) (- a))))
double code(double a, double b, double c, double d) {
return fma((c / hypot(c, d)), (b / hypot(c, d)), (((d / hypot(d, c)) / hypot(d, c)) * -a));
}
function code(a, b, c, d) return fma(Float64(c / hypot(c, d)), Float64(b / hypot(c, d)), Float64(Float64(Float64(d / hypot(d, c)) / hypot(d, c)) * Float64(-a))) 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[(N[(N[(d / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision] / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision] * (-a)), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, \frac{\frac{d}{\mathsf{hypot}\left(d, c\right)}}{\mathsf{hypot}\left(d, c\right)} \cdot \left(-a\right)\right)
\end{array}
Initial program 61.8%
div-sub58.6%
*-commutative58.6%
fma-define58.6%
add-sqr-sqrt58.6%
times-frac60.8%
fmm-def60.8%
fma-define60.8%
hypot-define60.8%
fma-define60.8%
hypot-define76.4%
associate-/l*79.0%
fma-define79.0%
add-sqr-sqrt79.0%
pow279.0%
Applied egg-rr79.0%
*-un-lft-identity79.0%
unpow279.0%
times-frac95.6%
Applied egg-rr95.6%
associate-*l/95.6%
*-lft-identity95.6%
hypot-undefine79.1%
unpow279.1%
unpow279.1%
+-commutative79.1%
unpow279.1%
unpow279.1%
hypot-define95.6%
hypot-undefine79.1%
unpow279.1%
unpow279.1%
+-commutative79.1%
unpow279.1%
unpow279.1%
hypot-define95.6%
Simplified95.6%
Final simplification95.6%
(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 (* (/ d (pow (hypot c d) 2.0)) (- a)))))
(if (<= d -5.5e+100)
(/ (- (* b (/ c d)) a) d)
(if (<= d -1.45e-112)
t_2
(if (<= d 1.66e-198)
(/ (- b (/ (* d a) c)) c)
(if (<= d 2e+63) t_2 (fma t_0 t_1 (/ (- a) (hypot d c)))))))))
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, ((d / pow(hypot(c, d), 2.0)) * -a));
double tmp;
if (d <= -5.5e+100) {
tmp = ((b * (c / d)) - a) / d;
} else if (d <= -1.45e-112) {
tmp = t_2;
} else if (d <= 1.66e-198) {
tmp = (b - ((d * a) / c)) / c;
} else if (d <= 2e+63) {
tmp = t_2;
} else {
tmp = fma(t_0, t_1, (-a / hypot(d, c)));
}
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(d / (hypot(c, d) ^ 2.0)) * Float64(-a))) tmp = 0.0 if (d <= -5.5e+100) tmp = Float64(Float64(Float64(b * Float64(c / d)) - a) / d); elseif (d <= -1.45e-112) tmp = t_2; elseif (d <= 1.66e-198) tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c); elseif (d <= 2e+63) tmp = t_2; else tmp = fma(t_0, t_1, Float64(Float64(-a) / hypot(d, c))); 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[(N[(d / N[Power[N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * (-a)), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -5.5e+100], N[(N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, -1.45e-112], t$95$2, If[LessEqual[d, 1.66e-198], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 2e+63], t$95$2, N[(t$95$0 * t$95$1 + N[((-a) / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c}{\mathsf{hypot}\left(c, d\right)}\\
t_1 := \frac{b}{\mathsf{hypot}\left(c, d\right)}\\
t_2 := \mathsf{fma}\left(t\_0, t\_1, \frac{d}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}} \cdot \left(-a\right)\right)\\
\mathbf{if}\;d \leq -5.5 \cdot 10^{+100}:\\
\;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\
\mathbf{elif}\;d \leq -1.45 \cdot 10^{-112}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;d \leq 1.66 \cdot 10^{-198}:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\
\mathbf{elif}\;d \leq 2 \cdot 10^{+63}:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t\_0, t\_1, \frac{-a}{\mathsf{hypot}\left(d, c\right)}\right)\\
\end{array}
\end{array}
if d < -5.5000000000000002e100Initial program 42.2%
div-sub42.2%
*-commutative42.2%
fma-define42.2%
add-sqr-sqrt42.2%
times-frac42.4%
fmm-def42.4%
fma-define42.4%
hypot-define42.4%
fma-define42.4%
hypot-define50.5%
associate-/l*54.4%
fma-define54.4%
add-sqr-sqrt54.4%
pow254.4%
Applied egg-rr54.4%
*-un-lft-identity54.4%
unpow254.4%
times-frac97.2%
Applied egg-rr97.2%
associate-*l/97.2%
*-lft-identity97.2%
hypot-undefine54.4%
unpow254.4%
unpow254.4%
+-commutative54.4%
unpow254.4%
unpow254.4%
hypot-define97.2%
hypot-undefine54.4%
unpow254.4%
unpow254.4%
+-commutative54.4%
unpow254.4%
unpow254.4%
hypot-define97.2%
Simplified97.2%
Taylor expanded in d around inf 87.1%
associate-/l*90.1%
Simplified90.1%
if -5.5000000000000002e100 < d < -1.44999999999999996e-112 or 1.65999999999999996e-198 < d < 2.00000000000000012e63Initial program 76.5%
div-sub76.5%
*-commutative76.5%
fma-define76.5%
add-sqr-sqrt76.5%
times-frac77.8%
fmm-def77.9%
fma-define77.9%
hypot-define77.9%
fma-define77.9%
hypot-define93.7%
associate-/l*93.3%
fma-define93.3%
add-sqr-sqrt93.3%
pow293.3%
Applied egg-rr93.3%
if -1.44999999999999996e-112 < d < 1.65999999999999996e-198Initial program 63.6%
Taylor expanded in c around inf 91.4%
mul-1-neg91.4%
unsub-neg91.4%
associate-/l*90.8%
Simplified90.8%
Taylor expanded in a around 0 91.4%
if 2.00000000000000012e63 < d Initial program 39.6%
div-sub39.6%
*-commutative39.6%
fma-define39.6%
add-sqr-sqrt39.6%
times-frac42.2%
fmm-def42.1%
fma-define42.1%
hypot-define42.1%
fma-define42.1%
hypot-define65.4%
associate-/l*68.7%
fma-define68.7%
add-sqr-sqrt68.7%
pow268.7%
Applied egg-rr68.7%
*-un-lft-identity68.7%
unpow268.7%
times-frac97.4%
Applied egg-rr97.4%
associate-*l/97.4%
*-lft-identity97.4%
hypot-undefine68.8%
unpow268.8%
unpow268.8%
+-commutative68.8%
unpow268.8%
unpow268.8%
hypot-define97.4%
hypot-undefine68.8%
unpow268.8%
unpow268.8%
+-commutative68.8%
unpow268.8%
unpow268.8%
hypot-define97.4%
Simplified97.4%
Taylor expanded in d around inf 97.4%
add-sqr-sqrt62.7%
sqrt-unprod67.4%
sqr-neg67.4%
sqrt-unprod50.4%
add-sqr-sqrt55.9%
neg-sub055.9%
sub-neg55.9%
add-sqr-sqrt50.4%
sqrt-unprod67.4%
sqr-neg67.4%
sqrt-unprod62.7%
add-sqr-sqrt97.4%
un-div-inv97.6%
Applied egg-rr97.6%
+-lft-identity97.6%
Simplified97.6%
Final simplification93.1%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (- (* c b) (* d a))))
(if (<= d -8e+113)
(/ (- (* b (/ c d)) a) d)
(if (<= d -3.25e-111)
(/ t_0 (fma c c (* d d)))
(if (<= d 3e-121)
(/ (- b (/ (* d a) c)) c)
(if (<= d 5.6e-70)
(/ t_0 (+ (* d d) (* c c)))
(fma
(/ c (hypot c d))
(/ b (hypot c d))
(/ (- a) (hypot d c)))))))))
double code(double a, double b, double c, double d) {
double t_0 = (c * b) - (d * a);
double tmp;
if (d <= -8e+113) {
tmp = ((b * (c / d)) - a) / d;
} else if (d <= -3.25e-111) {
tmp = t_0 / fma(c, c, (d * d));
} else if (d <= 3e-121) {
tmp = (b - ((d * a) / c)) / c;
} else if (d <= 5.6e-70) {
tmp = t_0 / ((d * d) + (c * c));
} else {
tmp = fma((c / hypot(c, d)), (b / hypot(c, d)), (-a / hypot(d, c)));
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(c * b) - Float64(d * a)) tmp = 0.0 if (d <= -8e+113) tmp = Float64(Float64(Float64(b * Float64(c / d)) - a) / d); elseif (d <= -3.25e-111) tmp = Float64(t_0 / fma(c, c, Float64(d * d))); elseif (d <= 3e-121) tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c); elseif (d <= 5.6e-70) tmp = Float64(t_0 / Float64(Float64(d * d) + Float64(c * c))); else tmp = fma(Float64(c / hypot(c, d)), Float64(b / hypot(c, d)), Float64(Float64(-a) / hypot(d, c))); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -8e+113], N[(N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, -3.25e-111], N[(t$95$0 / N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 3e-121], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 5.6e-70], N[(t$95$0 / N[(N[(d * d), $MachinePrecision] + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] + N[((-a) / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := c \cdot b - d \cdot a\\
\mathbf{if}\;d \leq -8 \cdot 10^{+113}:\\
\;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\
\mathbf{elif}\;d \leq -3.25 \cdot 10^{-111}:\\
\;\;\;\;\frac{t\_0}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\
\mathbf{elif}\;d \leq 3 \cdot 10^{-121}:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\
\mathbf{elif}\;d \leq 5.6 \cdot 10^{-70}:\\
\;\;\;\;\frac{t\_0}{d \cdot d + c \cdot c}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, \frac{-a}{\mathsf{hypot}\left(d, c\right)}\right)\\
\end{array}
\end{array}
if d < -8e113Initial program 38.9%
div-sub38.9%
*-commutative38.9%
fma-define38.9%
add-sqr-sqrt38.9%
times-frac39.2%
fmm-def39.2%
fma-define39.2%
hypot-define39.2%
fma-define39.2%
hypot-define47.7%
associate-/l*51.9%
fma-define51.9%
add-sqr-sqrt51.9%
pow251.9%
Applied egg-rr51.9%
*-un-lft-identity51.9%
unpow251.9%
times-frac97.1%
Applied egg-rr97.1%
associate-*l/97.1%
*-lft-identity97.1%
hypot-undefine51.9%
unpow251.9%
unpow251.9%
+-commutative51.9%
unpow251.9%
unpow251.9%
hypot-define97.1%
hypot-undefine51.9%
unpow251.9%
unpow251.9%
+-commutative51.9%
unpow251.9%
unpow251.9%
hypot-define97.1%
Simplified97.1%
Taylor expanded in d around inf 86.3%
associate-/l*89.6%
Simplified89.6%
if -8e113 < d < -3.24999999999999987e-111Initial program 90.3%
fma-define90.4%
Simplified90.4%
if -3.24999999999999987e-111 < d < 2.9999999999999999e-121Initial program 61.8%
Taylor expanded in c around inf 90.3%
mul-1-neg90.3%
unsub-neg90.3%
associate-/l*89.9%
Simplified89.9%
Taylor expanded in a around 0 90.3%
if 2.9999999999999999e-121 < d < 5.5999999999999998e-70Initial program 86.6%
if 5.5999999999999998e-70 < d Initial program 51.8%
div-sub51.8%
*-commutative51.8%
fma-define51.8%
add-sqr-sqrt51.8%
times-frac54.8%
fmm-def54.8%
fma-define54.8%
hypot-define54.8%
fma-define54.8%
hypot-define76.0%
associate-/l*78.0%
fma-define78.0%
add-sqr-sqrt78.0%
pow278.0%
Applied egg-rr78.0%
*-un-lft-identity78.0%
unpow278.0%
times-frac94.7%
Applied egg-rr94.7%
associate-*l/94.7%
*-lft-identity94.7%
hypot-undefine78.1%
unpow278.1%
unpow278.1%
+-commutative78.1%
unpow278.1%
unpow278.1%
hypot-define94.7%
hypot-undefine78.1%
unpow278.1%
unpow278.1%
+-commutative78.1%
unpow278.1%
unpow278.1%
hypot-define94.7%
Simplified94.7%
Taylor expanded in d around inf 88.2%
add-sqr-sqrt56.8%
sqrt-unprod66.8%
sqr-neg66.8%
sqrt-unprod41.8%
add-sqr-sqrt49.3%
neg-sub049.3%
sub-neg49.3%
add-sqr-sqrt41.8%
sqrt-unprod66.8%
sqr-neg66.8%
sqrt-unprod56.8%
add-sqr-sqrt88.2%
un-div-inv88.3%
Applied egg-rr88.3%
+-lft-identity88.3%
Simplified88.3%
Final simplification89.4%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* b (/ c d)) a) d)))
(if (<= d -9.2e+113)
t_0
(if (<= d -5.2e-112)
(/ (- (* c b) (* d a)) (fma c c (* d d)))
(if (<= d 5.6e-121)
(/ (- b (/ (* d a) c)) c)
(if (<= d 2.4e+67)
(/ (fma b c (* d (- a))) (fma d d (* c c)))
t_0))))))
double code(double a, double b, double c, double d) {
double t_0 = ((b * (c / d)) - a) / d;
double tmp;
if (d <= -9.2e+113) {
tmp = t_0;
} else if (d <= -5.2e-112) {
tmp = ((c * b) - (d * a)) / fma(c, c, (d * d));
} else if (d <= 5.6e-121) {
tmp = (b - ((d * a) / c)) / c;
} else if (d <= 2.4e+67) {
tmp = fma(b, c, (d * -a)) / fma(d, d, (c * c));
} else {
tmp = t_0;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(Float64(b * Float64(c / d)) - a) / d) tmp = 0.0 if (d <= -9.2e+113) tmp = t_0; elseif (d <= -5.2e-112) tmp = Float64(Float64(Float64(c * b) - Float64(d * a)) / fma(c, c, Float64(d * d))); elseif (d <= 5.6e-121) tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c); elseif (d <= 2.4e+67) tmp = Float64(fma(b, c, Float64(d * Float64(-a))) / fma(d, d, Float64(c * c))); else tmp = t_0; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -9.2e+113], t$95$0, If[LessEqual[d, -5.2e-112], N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 5.6e-121], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 2.4e+67], N[(N[(b * c + N[(d * (-a)), $MachinePrecision]), $MachinePrecision] / N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b \cdot \frac{c}{d} - a}{d}\\
\mathbf{if}\;d \leq -9.2 \cdot 10^{+113}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq -5.2 \cdot 10^{-112}:\\
\;\;\;\;\frac{c \cdot b - d \cdot a}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\
\mathbf{elif}\;d \leq 5.6 \cdot 10^{-121}:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\
\mathbf{elif}\;d \leq 2.4 \cdot 10^{+67}:\\
\;\;\;\;\frac{\mathsf{fma}\left(b, c, d \cdot \left(-a\right)\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d < -9.19999999999999987e113 or 2.40000000000000002e67 < d Initial program 39.3%
div-sub39.3%
*-commutative39.3%
fma-define39.3%
add-sqr-sqrt39.3%
times-frac40.8%
fmm-def40.8%
fma-define40.8%
hypot-define40.8%
fma-define40.8%
hypot-define57.4%
associate-/l*61.1%
fma-define61.1%
add-sqr-sqrt61.1%
pow261.1%
Applied egg-rr61.1%
*-un-lft-identity61.1%
unpow261.1%
times-frac97.2%
Applied egg-rr97.2%
associate-*l/97.2%
*-lft-identity97.2%
hypot-undefine61.1%
unpow261.1%
unpow261.1%
+-commutative61.1%
unpow261.1%
unpow261.1%
hypot-define97.2%
hypot-undefine61.1%
unpow261.1%
unpow261.1%
+-commutative61.1%
unpow261.1%
unpow261.1%
hypot-define97.2%
Simplified97.2%
Taylor expanded in d around inf 80.4%
associate-/l*85.6%
Simplified85.6%
if -9.19999999999999987e113 < d < -5.19999999999999983e-112Initial program 90.3%
fma-define90.4%
Simplified90.4%
if -5.19999999999999983e-112 < d < 5.6000000000000002e-121Initial program 61.8%
Taylor expanded in c around inf 90.3%
mul-1-neg90.3%
unsub-neg90.3%
associate-/l*89.9%
Simplified89.9%
Taylor expanded in a around 0 90.3%
if 5.6000000000000002e-121 < d < 2.40000000000000002e67Initial program 74.6%
fmm-def74.6%
distribute-rgt-neg-out74.6%
+-commutative74.6%
fma-define74.6%
Simplified74.6%
Final simplification86.0%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (- (* c b) (* d a))) (t_1 (/ (- (* b (/ c d)) a) d)))
(if (<= d -9.2e+113)
t_1
(if (<= d -2.3e-112)
(/ t_0 (fma c c (* d d)))
(if (<= d 1.8e-121)
(/ (- b (/ (* d a) c)) c)
(if (<= d 3e+67) (/ t_0 (+ (* d d) (* c c))) t_1))))))
double code(double a, double b, double c, double d) {
double t_0 = (c * b) - (d * a);
double t_1 = ((b * (c / d)) - a) / d;
double tmp;
if (d <= -9.2e+113) {
tmp = t_1;
} else if (d <= -2.3e-112) {
tmp = t_0 / fma(c, c, (d * d));
} else if (d <= 1.8e-121) {
tmp = (b - ((d * a) / c)) / c;
} else if (d <= 3e+67) {
tmp = t_0 / ((d * d) + (c * c));
} else {
tmp = t_1;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(c * b) - Float64(d * a)) t_1 = Float64(Float64(Float64(b * Float64(c / d)) - a) / d) tmp = 0.0 if (d <= -9.2e+113) tmp = t_1; elseif (d <= -2.3e-112) tmp = Float64(t_0 / fma(c, c, Float64(d * d))); elseif (d <= 1.8e-121) tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c); elseif (d <= 3e+67) tmp = Float64(t_0 / Float64(Float64(d * d) + Float64(c * c))); else tmp = t_1; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -9.2e+113], t$95$1, If[LessEqual[d, -2.3e-112], N[(t$95$0 / N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.8e-121], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 3e+67], N[(t$95$0 / N[(N[(d * d), $MachinePrecision] + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := c \cdot b - d \cdot a\\
t_1 := \frac{b \cdot \frac{c}{d} - a}{d}\\
\mathbf{if}\;d \leq -9.2 \cdot 10^{+113}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d \leq -2.3 \cdot 10^{-112}:\\
\;\;\;\;\frac{t\_0}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\
\mathbf{elif}\;d \leq 1.8 \cdot 10^{-121}:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\
\mathbf{elif}\;d \leq 3 \cdot 10^{+67}:\\
\;\;\;\;\frac{t\_0}{d \cdot d + c \cdot c}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if d < -9.19999999999999987e113 or 3.0000000000000001e67 < d Initial program 39.3%
div-sub39.3%
*-commutative39.3%
fma-define39.3%
add-sqr-sqrt39.3%
times-frac40.8%
fmm-def40.8%
fma-define40.8%
hypot-define40.8%
fma-define40.8%
hypot-define57.4%
associate-/l*61.1%
fma-define61.1%
add-sqr-sqrt61.1%
pow261.1%
Applied egg-rr61.1%
*-un-lft-identity61.1%
unpow261.1%
times-frac97.2%
Applied egg-rr97.2%
associate-*l/97.2%
*-lft-identity97.2%
hypot-undefine61.1%
unpow261.1%
unpow261.1%
+-commutative61.1%
unpow261.1%
unpow261.1%
hypot-define97.2%
hypot-undefine61.1%
unpow261.1%
unpow261.1%
+-commutative61.1%
unpow261.1%
unpow261.1%
hypot-define97.2%
Simplified97.2%
Taylor expanded in d around inf 80.4%
associate-/l*85.6%
Simplified85.6%
if -9.19999999999999987e113 < d < -2.29999999999999991e-112Initial program 90.3%
fma-define90.4%
Simplified90.4%
if -2.29999999999999991e-112 < d < 1.79999999999999992e-121Initial program 61.8%
Taylor expanded in c around inf 90.3%
mul-1-neg90.3%
unsub-neg90.3%
associate-/l*89.9%
Simplified89.9%
Taylor expanded in a around 0 90.3%
if 1.79999999999999992e-121 < d < 3.0000000000000001e67Initial program 74.6%
Final simplification86.0%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* c b) (* d a)) (+ (* d d) (* c c))))
(t_1 (/ (- (* b (/ c d)) a) d)))
(if (<= d -6.4e+116)
t_1
(if (<= d -3.45e-112)
t_0
(if (<= d 1.2e-120)
(/ (- b (/ (* d a) c)) c)
(if (<= d 2.3e+67) t_0 t_1))))))
double code(double a, double b, double c, double d) {
double t_0 = ((c * b) - (d * a)) / ((d * d) + (c * c));
double t_1 = ((b * (c / d)) - a) / d;
double tmp;
if (d <= -6.4e+116) {
tmp = t_1;
} else if (d <= -3.45e-112) {
tmp = t_0;
} else if (d <= 1.2e-120) {
tmp = (b - ((d * a) / c)) / c;
} else if (d <= 2.3e+67) {
tmp = t_0;
} else {
tmp = t_1;
}
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) :: t_1
real(8) :: tmp
t_0 = ((c * b) - (d * a)) / ((d * d) + (c * c))
t_1 = ((b * (c / d)) - a) / d
if (d <= (-6.4d+116)) then
tmp = t_1
else if (d <= (-3.45d-112)) then
tmp = t_0
else if (d <= 1.2d-120) then
tmp = (b - ((d * a) / c)) / c
else if (d <= 2.3d+67) then
tmp = t_0
else
tmp = t_1
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 * d) + (c * c));
double t_1 = ((b * (c / d)) - a) / d;
double tmp;
if (d <= -6.4e+116) {
tmp = t_1;
} else if (d <= -3.45e-112) {
tmp = t_0;
} else if (d <= 1.2e-120) {
tmp = (b - ((d * a) / c)) / c;
} else if (d <= 2.3e+67) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(a, b, c, d): t_0 = ((c * b) - (d * a)) / ((d * d) + (c * c)) t_1 = ((b * (c / d)) - a) / d tmp = 0 if d <= -6.4e+116: tmp = t_1 elif d <= -3.45e-112: tmp = t_0 elif d <= 1.2e-120: tmp = (b - ((d * a) / c)) / c elif d <= 2.3e+67: tmp = t_0 else: tmp = t_1 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(d * d) + Float64(c * c))) t_1 = Float64(Float64(Float64(b * Float64(c / d)) - a) / d) tmp = 0.0 if (d <= -6.4e+116) tmp = t_1; elseif (d <= -3.45e-112) tmp = t_0; elseif (d <= 1.2e-120) tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c); elseif (d <= 2.3e+67) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((c * b) - (d * a)) / ((d * d) + (c * c)); t_1 = ((b * (c / d)) - a) / d; tmp = 0.0; if (d <= -6.4e+116) tmp = t_1; elseif (d <= -3.45e-112) tmp = t_0; elseif (d <= 1.2e-120) tmp = (b - ((d * a) / c)) / c; elseif (d <= 2.3e+67) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(d * d), $MachinePrecision] + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -6.4e+116], t$95$1, If[LessEqual[d, -3.45e-112], t$95$0, If[LessEqual[d, 1.2e-120], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 2.3e+67], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c \cdot b - d \cdot a}{d \cdot d + c \cdot c}\\
t_1 := \frac{b \cdot \frac{c}{d} - a}{d}\\
\mathbf{if}\;d \leq -6.4 \cdot 10^{+116}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d \leq -3.45 \cdot 10^{-112}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 1.2 \cdot 10^{-120}:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\
\mathbf{elif}\;d \leq 2.3 \cdot 10^{+67}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if d < -6.4000000000000001e116 or 2.2999999999999999e67 < d Initial program 39.3%
div-sub39.3%
*-commutative39.3%
fma-define39.3%
add-sqr-sqrt39.3%
times-frac40.8%
fmm-def40.8%
fma-define40.8%
hypot-define40.8%
fma-define40.8%
hypot-define57.4%
associate-/l*61.1%
fma-define61.1%
add-sqr-sqrt61.1%
pow261.1%
Applied egg-rr61.1%
*-un-lft-identity61.1%
unpow261.1%
times-frac97.2%
Applied egg-rr97.2%
associate-*l/97.2%
*-lft-identity97.2%
hypot-undefine61.1%
unpow261.1%
unpow261.1%
+-commutative61.1%
unpow261.1%
unpow261.1%
hypot-define97.2%
hypot-undefine61.1%
unpow261.1%
unpow261.1%
+-commutative61.1%
unpow261.1%
unpow261.1%
hypot-define97.2%
Simplified97.2%
Taylor expanded in d around inf 80.4%
associate-/l*85.6%
Simplified85.6%
if -6.4000000000000001e116 < d < -3.45000000000000009e-112 or 1.2e-120 < d < 2.2999999999999999e67Initial program 82.1%
if -3.45000000000000009e-112 < d < 1.2e-120Initial program 61.8%
Taylor expanded in c around inf 90.3%
mul-1-neg90.3%
unsub-neg90.3%
associate-/l*89.9%
Simplified89.9%
Taylor expanded in a around 0 90.3%
Final simplification86.0%
(FPCore (a b c d) :precision binary64 (if (or (<= d -7e+23) (not (<= d 5.4e+89))) (/ a (- d)) (/ (- b (/ (* d a) c)) c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -7e+23) || !(d <= 5.4e+89)) {
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 <= (-7d+23)) .or. (.not. (d <= 5.4d+89))) 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 <= -7e+23) || !(d <= 5.4e+89)) {
tmp = a / -d;
} else {
tmp = (b - ((d * a) / c)) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -7e+23) or not (d <= 5.4e+89): tmp = a / -d else: tmp = (b - ((d * a) / c)) / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -7e+23) || !(d <= 5.4e+89)) 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 <= -7e+23) || ~((d <= 5.4e+89))) tmp = a / -d; else tmp = (b - ((d * a) / c)) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -7e+23], N[Not[LessEqual[d, 5.4e+89]], $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 -7 \cdot 10^{+23} \lor \neg \left(d \leq 5.4 \cdot 10^{+89}\right):\\
\;\;\;\;\frac{a}{-d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\
\end{array}
\end{array}
if d < -7.0000000000000004e23 or 5.4e89 < d Initial program 48.9%
Taylor expanded in c around 0 68.0%
associate-*r/68.0%
neg-mul-168.0%
Simplified68.0%
if -7.0000000000000004e23 < d < 5.4e89Initial program 69.1%
Taylor expanded in c around inf 72.8%
mul-1-neg72.8%
unsub-neg72.8%
associate-/l*72.6%
Simplified72.6%
Taylor expanded in a around 0 72.8%
Final simplification71.1%
(FPCore (a b c d) :precision binary64 (if (or (<= d -1.9e+23) (not (<= d 5.1e+82))) (/ a (- d)) (/ (- b (* a (/ d c))) c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -1.9e+23) || !(d <= 5.1e+82)) {
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 <= (-1.9d+23)) .or. (.not. (d <= 5.1d+82))) 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 <= -1.9e+23) || !(d <= 5.1e+82)) {
tmp = a / -d;
} else {
tmp = (b - (a * (d / c))) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -1.9e+23) or not (d <= 5.1e+82): tmp = a / -d else: tmp = (b - (a * (d / c))) / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -1.9e+23) || !(d <= 5.1e+82)) 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 <= -1.9e+23) || ~((d <= 5.1e+82))) tmp = a / -d; else tmp = (b - (a * (d / c))) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -1.9e+23], N[Not[LessEqual[d, 5.1e+82]], $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 -1.9 \cdot 10^{+23} \lor \neg \left(d \leq 5.1 \cdot 10^{+82}\right):\\
\;\;\;\;\frac{a}{-d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\
\end{array}
\end{array}
if d < -1.89999999999999987e23 or 5.1000000000000003e82 < d Initial program 48.9%
Taylor expanded in c around 0 68.0%
associate-*r/68.0%
neg-mul-168.0%
Simplified68.0%
if -1.89999999999999987e23 < d < 5.1000000000000003e82Initial program 69.1%
Taylor expanded in c around inf 72.8%
mul-1-neg72.8%
unsub-neg72.8%
associate-/l*72.6%
Simplified72.6%
Final simplification70.9%
(FPCore (a b c d) :precision binary64 (if (<= c -1e+86) (/ (- b (/ (* d a) c)) c) (if (<= c 1e+33) (/ (- (* b (/ c d)) a) d) (/ (- b (* a (/ d c))) c))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -1e+86) {
tmp = (b - ((d * a) / c)) / c;
} else if (c <= 1e+33) {
tmp = ((b * (c / d)) - a) / d;
} else {
tmp = (b - (a * (d / c))) / c;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (c <= (-1d+86)) then
tmp = (b - ((d * a) / c)) / c
else if (c <= 1d+33) then
tmp = ((b * (c / d)) - a) / d
else
tmp = (b - (a * (d / c))) / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -1e+86) {
tmp = (b - ((d * a) / c)) / c;
} else if (c <= 1e+33) {
tmp = ((b * (c / d)) - a) / d;
} else {
tmp = (b - (a * (d / c))) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -1e+86: tmp = (b - ((d * a) / c)) / c elif c <= 1e+33: tmp = ((b * (c / d)) - a) / d else: tmp = (b - (a * (d / c))) / c return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -1e+86) tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c); elseif (c <= 1e+33) tmp = Float64(Float64(Float64(b * Float64(c / d)) - a) / d); else tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -1e+86) tmp = (b - ((d * a) / c)) / c; elseif (c <= 1e+33) tmp = ((b * (c / d)) - a) / d; else tmp = (b - (a * (d / c))) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -1e+86], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[c, 1e+33], N[(N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -1 \cdot 10^{+86}:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\
\mathbf{elif}\;c \leq 10^{+33}:\\
\;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\
\end{array}
\end{array}
if c < -1e86Initial program 40.0%
Taylor expanded in c around inf 86.1%
mul-1-neg86.1%
unsub-neg86.1%
associate-/l*82.9%
Simplified82.9%
Taylor expanded in a around 0 86.1%
if -1e86 < c < 9.9999999999999995e32Initial program 72.2%
div-sub66.9%
*-commutative66.9%
fma-define66.9%
add-sqr-sqrt66.9%
times-frac68.1%
fmm-def68.1%
fma-define68.1%
hypot-define68.1%
fma-define68.1%
hypot-define71.3%
associate-/l*75.6%
fma-define75.6%
add-sqr-sqrt75.6%
pow275.6%
Applied egg-rr75.6%
*-un-lft-identity75.6%
unpow275.6%
times-frac97.2%
Applied egg-rr97.2%
associate-*l/97.3%
*-lft-identity97.3%
hypot-undefine75.7%
unpow275.7%
unpow275.7%
+-commutative75.7%
unpow275.7%
unpow275.7%
hypot-define97.3%
hypot-undefine75.7%
unpow275.7%
unpow275.7%
+-commutative75.7%
unpow275.7%
unpow275.7%
hypot-define97.3%
Simplified97.3%
Taylor expanded in d around inf 77.8%
associate-/l*79.6%
Simplified79.6%
if 9.9999999999999995e32 < c Initial program 50.4%
Taylor expanded in c around inf 75.1%
mul-1-neg75.1%
unsub-neg75.1%
associate-/l*82.6%
Simplified82.6%
Final simplification81.4%
(FPCore (a b c d) :precision binary64 (if (or (<= c -2.8e+33) (not (<= c 2.15e+43))) (/ b c) (/ a (- d))))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -2.8e+33) || !(c <= 2.15e+43)) {
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.8d+33)) .or. (.not. (c <= 2.15d+43))) 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.8e+33) || !(c <= 2.15e+43)) {
tmp = b / c;
} else {
tmp = a / -d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -2.8e+33) or not (c <= 2.15e+43): tmp = b / c else: tmp = a / -d return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -2.8e+33) || !(c <= 2.15e+43)) tmp = Float64(b / c); else tmp = Float64(a / Float64(-d)); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((c <= -2.8e+33) || ~((c <= 2.15e+43))) tmp = b / c; else tmp = a / -d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -2.8e+33], N[Not[LessEqual[c, 2.15e+43]], $MachinePrecision]], N[(b / c), $MachinePrecision], N[(a / (-d)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -2.8 \cdot 10^{+33} \lor \neg \left(c \leq 2.15 \cdot 10^{+43}\right):\\
\;\;\;\;\frac{b}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{-d}\\
\end{array}
\end{array}
if c < -2.8000000000000001e33 or 2.15e43 < c Initial program 47.3%
Taylor expanded in c around inf 69.9%
if -2.8000000000000001e33 < c < 2.15e43Initial program 72.1%
Taylor expanded in c around 0 59.0%
associate-*r/59.0%
neg-mul-159.0%
Simplified59.0%
Final simplification63.5%
(FPCore (a b c d) :precision binary64 (if (<= c -5.6e+31) (/ 1.0 (/ c b)) (if (<= c 3.4e+42) (/ a (- d)) (/ b c))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -5.6e+31) {
tmp = 1.0 / (c / b);
} else if (c <= 3.4e+42) {
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 (c <= (-5.6d+31)) then
tmp = 1.0d0 / (c / b)
else if (c <= 3.4d+42) 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 (c <= -5.6e+31) {
tmp = 1.0 / (c / b);
} else if (c <= 3.4e+42) {
tmp = a / -d;
} else {
tmp = b / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -5.6e+31: tmp = 1.0 / (c / b) elif c <= 3.4e+42: tmp = a / -d else: tmp = b / c return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -5.6e+31) tmp = Float64(1.0 / Float64(c / b)); elseif (c <= 3.4e+42) 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 (c <= -5.6e+31) tmp = 1.0 / (c / b); elseif (c <= 3.4e+42) tmp = a / -d; else tmp = b / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -5.6e+31], N[(1.0 / N[(c / b), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 3.4e+42], N[(a / (-d)), $MachinePrecision], N[(b / c), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -5.6 \cdot 10^{+31}:\\
\;\;\;\;\frac{1}{\frac{c}{b}}\\
\mathbf{elif}\;c \leq 3.4 \cdot 10^{+42}:\\
\;\;\;\;\frac{a}{-d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if c < -5.60000000000000034e31Initial program 44.6%
Taylor expanded in c around inf 73.8%
clear-num74.4%
inv-pow74.4%
Applied egg-rr74.4%
unpow-174.4%
Simplified74.4%
if -5.60000000000000034e31 < c < 3.39999999999999975e42Initial program 72.1%
Taylor expanded in c around 0 59.0%
associate-*r/59.0%
neg-mul-159.0%
Simplified59.0%
if 3.39999999999999975e42 < c Initial program 50.5%
Taylor expanded in c around inf 65.4%
Final simplification63.7%
(FPCore (a b c d) :precision binary64 (if (<= d -8.2e+119) (/ a d) (/ b c)))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -8.2e+119) {
tmp = a / d;
} else {
tmp = b / c;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (d <= (-8.2d+119)) then
tmp = a / d
else
tmp = b / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (d <= -8.2e+119) {
tmp = a / d;
} else {
tmp = b / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -8.2e+119: tmp = a / d else: tmp = b / c return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -8.2e+119) 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 <= -8.2e+119) tmp = a / d; else tmp = b / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -8.2e+119], N[(a / d), $MachinePrecision], N[(b / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -8.2 \cdot 10^{+119}:\\
\;\;\;\;\frac{a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if d < -8.1999999999999994e119Initial program 38.9%
Taylor expanded in c around 0 80.1%
associate-*r/80.1%
neg-mul-180.1%
Simplified80.1%
add-sqr-sqrt35.9%
sqrt-unprod38.8%
sqr-neg38.8%
sqrt-unprod18.9%
add-sqr-sqrt29.2%
*-un-lft-identity29.2%
Applied egg-rr29.2%
*-lft-identity29.2%
Simplified29.2%
if -8.1999999999999994e119 < d Initial program 65.6%
Taylor expanded in c around inf 48.3%
(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 61.8%
Taylor expanded in c around 0 40.4%
associate-*r/40.4%
neg-mul-140.4%
Simplified40.4%
add-sqr-sqrt19.1%
sqrt-unprod19.0%
sqr-neg19.0%
sqrt-unprod4.9%
add-sqr-sqrt11.0%
*-un-lft-identity11.0%
Applied egg-rr11.0%
*-lft-identity11.0%
Simplified11.0%
(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 2024139
(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))))