
(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 11 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 (- (* b (/ c d)) a)) (t_1 (/ 1.0 (hypot c d))))
(if (<= c -8.2e+19)
(* t_1 (- (/ d (/ c a)) b))
(if (<= c -1.4e-175)
(* t_1 (/ (* d t_0) (hypot c d)))
(if (<= c 210.0) (/ t_0 d) (/ (- b (* a (/ d c))) c))))))
double code(double a, double b, double c, double d) {
double t_0 = (b * (c / d)) - a;
double t_1 = 1.0 / hypot(c, d);
double tmp;
if (c <= -8.2e+19) {
tmp = t_1 * ((d / (c / a)) - b);
} else if (c <= -1.4e-175) {
tmp = t_1 * ((d * t_0) / hypot(c, d));
} else if (c <= 210.0) {
tmp = t_0 / d;
} else {
tmp = (b - (a * (d / c))) / c;
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = (b * (c / d)) - a;
double t_1 = 1.0 / Math.hypot(c, d);
double tmp;
if (c <= -8.2e+19) {
tmp = t_1 * ((d / (c / a)) - b);
} else if (c <= -1.4e-175) {
tmp = t_1 * ((d * t_0) / Math.hypot(c, d));
} else if (c <= 210.0) {
tmp = t_0 / d;
} else {
tmp = (b - (a * (d / c))) / c;
}
return tmp;
}
def code(a, b, c, d): t_0 = (b * (c / d)) - a t_1 = 1.0 / math.hypot(c, d) tmp = 0 if c <= -8.2e+19: tmp = t_1 * ((d / (c / a)) - b) elif c <= -1.4e-175: tmp = t_1 * ((d * t_0) / math.hypot(c, d)) elif c <= 210.0: tmp = t_0 / d else: tmp = (b - (a * (d / c))) / c return tmp
function code(a, b, c, d) t_0 = Float64(Float64(b * Float64(c / d)) - a) t_1 = Float64(1.0 / hypot(c, d)) tmp = 0.0 if (c <= -8.2e+19) tmp = Float64(t_1 * Float64(Float64(d / Float64(c / a)) - b)); elseif (c <= -1.4e-175) tmp = Float64(t_1 * Float64(Float64(d * t_0) / hypot(c, d))); elseif (c <= 210.0) tmp = Float64(t_0 / d); else tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (b * (c / d)) - a; t_1 = 1.0 / hypot(c, d); tmp = 0.0; if (c <= -8.2e+19) tmp = t_1 * ((d / (c / a)) - b); elseif (c <= -1.4e-175) tmp = t_1 * ((d * t_0) / hypot(c, d)); elseif (c <= 210.0) tmp = t_0 / d; else tmp = (b - (a * (d / c))) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -8.2e+19], N[(t$95$1 * N[(N[(d / N[(c / a), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -1.4e-175], N[(t$95$1 * N[(N[(d * t$95$0), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 210.0], N[(t$95$0 / d), $MachinePrecision], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := b \cdot \frac{c}{d} - a\\
t_1 := \frac{1}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{if}\;c \leq -8.2 \cdot 10^{+19}:\\
\;\;\;\;t\_1 \cdot \left(\frac{d}{\frac{c}{a}} - b\right)\\
\mathbf{elif}\;c \leq -1.4 \cdot 10^{-175}:\\
\;\;\;\;t\_1 \cdot \frac{d \cdot t\_0}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;c \leq 210:\\
\;\;\;\;\frac{t\_0}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\
\end{array}
\end{array}
if c < -8.2e19Initial program 57.6%
*-un-lft-identity57.6%
add-sqr-sqrt57.6%
times-frac57.5%
hypot-define57.5%
fma-neg57.6%
distribute-rgt-neg-in57.6%
hypot-define72.9%
Applied egg-rr72.9%
Taylor expanded in c around -inf 81.4%
associate-*r/86.1%
+-commutative86.1%
mul-1-neg86.1%
unsub-neg86.1%
*-commutative86.1%
associate-*l/81.4%
associate-*r/87.7%
Simplified87.7%
clear-num87.7%
un-div-inv87.8%
Applied egg-rr87.8%
if -8.2e19 < c < -1.4e-175Initial program 85.6%
*-un-lft-identity85.6%
add-sqr-sqrt85.6%
times-frac85.7%
hypot-define85.7%
fma-neg85.7%
distribute-rgt-neg-in85.7%
hypot-define94.1%
Applied egg-rr94.1%
Taylor expanded in d around -inf 94.2%
mul-1-neg94.2%
distribute-rgt-neg-in94.2%
mul-1-neg94.2%
unsub-neg94.2%
associate-/l*93.9%
Simplified93.9%
if -1.4e-175 < c < 210Initial program 72.6%
*-un-lft-identity72.6%
add-sqr-sqrt72.6%
times-frac72.6%
hypot-define72.6%
fma-neg72.6%
distribute-rgt-neg-in72.6%
hypot-define77.7%
Applied egg-rr77.7%
Taylor expanded in d around -inf 77.7%
mul-1-neg77.7%
distribute-rgt-neg-in77.7%
mul-1-neg77.7%
unsub-neg77.7%
associate-/l*77.2%
Simplified77.2%
Taylor expanded in d around inf 88.6%
associate-*r/89.6%
+-commutative89.6%
mul-1-neg89.6%
unsub-neg89.6%
Simplified89.6%
if 210 < c Initial program 48.0%
Taylor expanded in c around inf 73.9%
mul-1-neg73.9%
unsub-neg73.9%
associate-/l*83.1%
Simplified83.1%
Final simplification88.2%
(FPCore (a b c d) :precision binary64 (if (<= (/ (- (* b c) (* a d)) (+ (* c c) (* d d))) 1e+267) (* (/ 1.0 (hypot c d)) (/ (fma b c (* a (- d))) (hypot c d))) (/ (- b (* a (/ d c))) c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((((b * c) - (a * d)) / ((c * c) + (d * d))) <= 1e+267) {
tmp = (1.0 / hypot(c, d)) * (fma(b, c, (a * -d)) / hypot(c, d));
} else {
tmp = (b - (a * (d / c))) / c;
}
return tmp;
}
function code(a, b, c, d) tmp = 0.0 if (Float64(Float64(Float64(b * c) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d))) <= 1e+267) tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(fma(b, c, Float64(a * Float64(-d))) / hypot(c, d))); else tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c); end return tmp end
code[a_, b_, c_, d_] := If[LessEqual[N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1e+267], N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(N[(b * c + N[(a * (-d)), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \leq 10^{+267}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\
\end{array}
\end{array}
if (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 9.9999999999999997e266Initial program 85.9%
*-un-lft-identity85.9%
add-sqr-sqrt85.9%
times-frac85.9%
hypot-define85.9%
fma-neg85.9%
distribute-rgt-neg-in85.9%
hypot-define97.1%
Applied egg-rr97.1%
if 9.9999999999999997e266 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 8.9%
Taylor expanded in c around inf 47.3%
mul-1-neg47.3%
unsub-neg47.3%
associate-/l*60.9%
Simplified60.9%
Final simplification87.2%
(FPCore (a b c d)
:precision binary64
(if (<= c -1.2e+109)
(* (/ 1.0 (hypot c d)) (- (* d (/ a c)) b))
(if (<= c -1.9e-163)
(/ (- (* b c) (* a d)) (+ (* c c) (* d d)))
(if (<= c 14.0) (/ (- (* b (/ c d)) a) d) (/ (- b (* a (/ d c))) c)))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -1.2e+109) {
tmp = (1.0 / hypot(c, d)) * ((d * (a / c)) - b);
} else if (c <= -1.9e-163) {
tmp = ((b * c) - (a * d)) / ((c * c) + (d * d));
} else if (c <= 14.0) {
tmp = ((b * (c / d)) - a) / d;
} else {
tmp = (b - (a * (d / c))) / c;
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -1.2e+109) {
tmp = (1.0 / Math.hypot(c, d)) * ((d * (a / c)) - b);
} else if (c <= -1.9e-163) {
tmp = ((b * c) - (a * d)) / ((c * c) + (d * d));
} else if (c <= 14.0) {
tmp = ((b * (c / d)) - a) / d;
} else {
tmp = (b - (a * (d / c))) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -1.2e+109: tmp = (1.0 / math.hypot(c, d)) * ((d * (a / c)) - b) elif c <= -1.9e-163: tmp = ((b * c) - (a * d)) / ((c * c) + (d * d)) elif c <= 14.0: tmp = ((b * (c / d)) - a) / d else: tmp = (b - (a * (d / c))) / c return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -1.2e+109) tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(Float64(d * Float64(a / c)) - b)); elseif (c <= -1.9e-163) tmp = Float64(Float64(Float64(b * c) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d))); elseif (c <= 14.0) tmp = Float64(Float64(Float64(b * Float64(c / d)) - a) / d); else tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -1.2e+109) tmp = (1.0 / hypot(c, d)) * ((d * (a / c)) - b); elseif (c <= -1.9e-163) tmp = ((b * c) - (a * d)) / ((c * c) + (d * d)); elseif (c <= 14.0) tmp = ((b * (c / d)) - a) / d; else tmp = (b - (a * (d / c))) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -1.2e+109], N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(N[(d * N[(a / c), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -1.9e-163], N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 14.0], N[(N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.2 \cdot 10^{+109}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(d \cdot \frac{a}{c} - b\right)\\
\mathbf{elif}\;c \leq -1.9 \cdot 10^{-163}:\\
\;\;\;\;\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;c \leq 14:\\
\;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\
\end{array}
\end{array}
if c < -1.19999999999999994e109Initial program 39.0%
*-un-lft-identity39.0%
add-sqr-sqrt39.0%
times-frac39.0%
hypot-define39.0%
fma-neg39.0%
distribute-rgt-neg-in39.0%
hypot-define63.0%
Applied egg-rr63.0%
Taylor expanded in c around -inf 81.0%
associate-*r/88.3%
+-commutative88.3%
mul-1-neg88.3%
unsub-neg88.3%
*-commutative88.3%
associate-*l/81.0%
associate-*r/90.9%
Simplified90.9%
if -1.19999999999999994e109 < c < -1.9e-163Initial program 88.3%
if -1.9e-163 < c < 14Initial program 72.7%
*-un-lft-identity72.7%
add-sqr-sqrt72.7%
times-frac72.7%
hypot-define72.7%
fma-neg72.7%
distribute-rgt-neg-in72.7%
hypot-define78.6%
Applied egg-rr78.6%
Taylor expanded in d around -inf 78.5%
mul-1-neg78.5%
distribute-rgt-neg-in78.5%
mul-1-neg78.5%
unsub-neg78.5%
associate-/l*78.1%
Simplified78.1%
Taylor expanded in d around inf 88.2%
associate-*r/89.1%
+-commutative89.1%
mul-1-neg89.1%
unsub-neg89.1%
Simplified89.1%
if 14 < c Initial program 48.0%
Taylor expanded in c around inf 73.9%
mul-1-neg73.9%
unsub-neg73.9%
associate-/l*83.1%
Simplified83.1%
Final simplification87.7%
(FPCore (a b c d)
:precision binary64
(if (<= c -2.15e+104)
(* (/ 1.0 (hypot c d)) (- (/ d (/ c a)) b))
(if (<= c -1.9e-163)
(/ (- (* b c) (* a d)) (+ (* c c) (* d d)))
(if (<= c 0.078) (/ (- (* b (/ c d)) a) d) (/ (- b (* a (/ d c))) c)))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -2.15e+104) {
tmp = (1.0 / hypot(c, d)) * ((d / (c / a)) - b);
} else if (c <= -1.9e-163) {
tmp = ((b * c) - (a * d)) / ((c * c) + (d * d));
} else if (c <= 0.078) {
tmp = ((b * (c / d)) - a) / d;
} else {
tmp = (b - (a * (d / c))) / c;
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -2.15e+104) {
tmp = (1.0 / Math.hypot(c, d)) * ((d / (c / a)) - b);
} else if (c <= -1.9e-163) {
tmp = ((b * c) - (a * d)) / ((c * c) + (d * d));
} else if (c <= 0.078) {
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 <= -2.15e+104: tmp = (1.0 / math.hypot(c, d)) * ((d / (c / a)) - b) elif c <= -1.9e-163: tmp = ((b * c) - (a * d)) / ((c * c) + (d * d)) elif c <= 0.078: 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 <= -2.15e+104) tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(Float64(d / Float64(c / a)) - b)); elseif (c <= -1.9e-163) tmp = Float64(Float64(Float64(b * c) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d))); elseif (c <= 0.078) 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 <= -2.15e+104) tmp = (1.0 / hypot(c, d)) * ((d / (c / a)) - b); elseif (c <= -1.9e-163) tmp = ((b * c) - (a * d)) / ((c * c) + (d * d)); elseif (c <= 0.078) 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, -2.15e+104], N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(N[(d / N[(c / a), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -1.9e-163], N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 0.078], 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 -2.15 \cdot 10^{+104}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(\frac{d}{\frac{c}{a}} - b\right)\\
\mathbf{elif}\;c \leq -1.9 \cdot 10^{-163}:\\
\;\;\;\;\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;c \leq 0.078:\\
\;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\
\end{array}
\end{array}
if c < -2.1500000000000001e104Initial program 39.0%
*-un-lft-identity39.0%
add-sqr-sqrt39.0%
times-frac39.0%
hypot-define39.0%
fma-neg39.0%
distribute-rgt-neg-in39.0%
hypot-define63.0%
Applied egg-rr63.0%
Taylor expanded in c around -inf 81.0%
associate-*r/88.3%
+-commutative88.3%
mul-1-neg88.3%
unsub-neg88.3%
*-commutative88.3%
associate-*l/81.0%
associate-*r/90.9%
Simplified90.9%
clear-num90.9%
un-div-inv91.0%
Applied egg-rr91.0%
if -2.1500000000000001e104 < c < -1.9e-163Initial program 88.3%
if -1.9e-163 < c < 0.0779999999999999999Initial program 72.7%
*-un-lft-identity72.7%
add-sqr-sqrt72.7%
times-frac72.7%
hypot-define72.7%
fma-neg72.7%
distribute-rgt-neg-in72.7%
hypot-define78.6%
Applied egg-rr78.6%
Taylor expanded in d around -inf 78.5%
mul-1-neg78.5%
distribute-rgt-neg-in78.5%
mul-1-neg78.5%
unsub-neg78.5%
associate-/l*78.1%
Simplified78.1%
Taylor expanded in d around inf 88.2%
associate-*r/89.1%
+-commutative89.1%
mul-1-neg89.1%
unsub-neg89.1%
Simplified89.1%
if 0.0779999999999999999 < c Initial program 48.0%
Taylor expanded in c around inf 73.9%
mul-1-neg73.9%
unsub-neg73.9%
associate-/l*83.1%
Simplified83.1%
Final simplification87.7%
(FPCore (a b c d)
:precision binary64
(if (<= c -7.5e+107)
(/ (- b (* d (/ a c))) c)
(if (<= c -1.9e-163)
(/ (- (* b c) (* a d)) (+ (* c c) (* d d)))
(if (<= c 9500.0) (/ (- (* b (/ c d)) a) d) (/ (- b (* a (/ d c))) c)))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -7.5e+107) {
tmp = (b - (d * (a / c))) / c;
} else if (c <= -1.9e-163) {
tmp = ((b * c) - (a * d)) / ((c * c) + (d * d));
} else if (c <= 9500.0) {
tmp = ((b * (c / d)) - a) / d;
} else {
tmp = (b - (a * (d / c))) / c;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (c <= (-7.5d+107)) then
tmp = (b - (d * (a / c))) / c
else if (c <= (-1.9d-163)) then
tmp = ((b * c) - (a * d)) / ((c * c) + (d * d))
else if (c <= 9500.0d0) then
tmp = ((b * (c / d)) - a) / d
else
tmp = (b - (a * (d / c))) / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -7.5e+107) {
tmp = (b - (d * (a / c))) / c;
} else if (c <= -1.9e-163) {
tmp = ((b * c) - (a * d)) / ((c * c) + (d * d));
} else if (c <= 9500.0) {
tmp = ((b * (c / d)) - a) / d;
} else {
tmp = (b - (a * (d / c))) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -7.5e+107: tmp = (b - (d * (a / c))) / c elif c <= -1.9e-163: tmp = ((b * c) - (a * d)) / ((c * c) + (d * d)) elif c <= 9500.0: tmp = ((b * (c / d)) - a) / d else: tmp = (b - (a * (d / c))) / c return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -7.5e+107) tmp = Float64(Float64(b - Float64(d * Float64(a / c))) / c); elseif (c <= -1.9e-163) tmp = Float64(Float64(Float64(b * c) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d))); elseif (c <= 9500.0) tmp = Float64(Float64(Float64(b * Float64(c / d)) - a) / d); else tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -7.5e+107) tmp = (b - (d * (a / c))) / c; elseif (c <= -1.9e-163) tmp = ((b * c) - (a * d)) / ((c * c) + (d * d)); elseif (c <= 9500.0) tmp = ((b * (c / d)) - a) / d; else tmp = (b - (a * (d / c))) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -7.5e+107], N[(N[(b - N[(d * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[c, -1.9e-163], N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 9500.0], N[(N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -7.5 \cdot 10^{+107}:\\
\;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\
\mathbf{elif}\;c \leq -1.9 \cdot 10^{-163}:\\
\;\;\;\;\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;c \leq 9500:\\
\;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\
\end{array}
\end{array}
if c < -7.4999999999999996e107Initial program 39.0%
*-un-lft-identity39.0%
add-sqr-sqrt39.0%
times-frac39.0%
hypot-define39.0%
fma-neg39.0%
distribute-rgt-neg-in39.0%
hypot-define63.0%
Applied egg-rr63.0%
Taylor expanded in c around inf 81.0%
mul-1-neg81.0%
associate-*r/88.3%
unsub-neg88.3%
*-commutative88.3%
associate-*l/81.0%
associate-*r/90.8%
Simplified90.8%
if -7.4999999999999996e107 < c < -1.9e-163Initial program 88.3%
if -1.9e-163 < c < 9500Initial program 72.7%
*-un-lft-identity72.7%
add-sqr-sqrt72.7%
times-frac72.7%
hypot-define72.7%
fma-neg72.7%
distribute-rgt-neg-in72.7%
hypot-define78.6%
Applied egg-rr78.6%
Taylor expanded in d around -inf 78.5%
mul-1-neg78.5%
distribute-rgt-neg-in78.5%
mul-1-neg78.5%
unsub-neg78.5%
associate-/l*78.1%
Simplified78.1%
Taylor expanded in d around inf 88.2%
associate-*r/89.1%
+-commutative89.1%
mul-1-neg89.1%
unsub-neg89.1%
Simplified89.1%
if 9500 < c Initial program 48.0%
Taylor expanded in c around inf 73.9%
mul-1-neg73.9%
unsub-neg73.9%
associate-/l*83.1%
Simplified83.1%
Final simplification87.7%
(FPCore (a b c d) :precision binary64 (if (or (<= c -9e-101) (not (<= c 0.0026))) (/ (- b (* a (/ d c))) c) (/ (- a) d)))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -9e-101) || !(c <= 0.0026)) {
tmp = (b - (a * (d / c))) / 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 <= (-9d-101)) .or. (.not. (c <= 0.0026d0))) then
tmp = (b - (a * (d / c))) / 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 <= -9e-101) || !(c <= 0.0026)) {
tmp = (b - (a * (d / c))) / c;
} else {
tmp = -a / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -9e-101) or not (c <= 0.0026): tmp = (b - (a * (d / c))) / c else: tmp = -a / d return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -9e-101) || !(c <= 0.0026)) tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c); else tmp = Float64(Float64(-a) / d); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((c <= -9e-101) || ~((c <= 0.0026))) tmp = (b - (a * (d / c))) / c; else tmp = -a / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -9e-101], N[Not[LessEqual[c, 0.0026]], $MachinePrecision]], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], N[((-a) / d), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -9 \cdot 10^{-101} \lor \neg \left(c \leq 0.0026\right):\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{-a}{d}\\
\end{array}
\end{array}
if c < -8.9999999999999997e-101 or 0.0025999999999999999 < c Initial program 58.4%
Taylor expanded in c around inf 73.8%
mul-1-neg73.8%
unsub-neg73.8%
associate-/l*79.7%
Simplified79.7%
if -8.9999999999999997e-101 < c < 0.0025999999999999999Initial program 73.3%
Taylor expanded in c around 0 68.5%
associate-*r/68.5%
neg-mul-168.5%
Simplified68.5%
Final simplification74.9%
(FPCore (a b c d) :precision binary64 (if (<= c -1.72e-20) (/ (- b (* d (/ a c))) c) (if (<= c 800.0) (/ (- (* b (/ c d)) a) d) (/ (- b (* a (/ d c))) c))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -1.72e-20) {
tmp = (b - (d * (a / c))) / c;
} else if (c <= 800.0) {
tmp = ((b * (c / d)) - a) / d;
} else {
tmp = (b - (a * (d / c))) / c;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (c <= (-1.72d-20)) then
tmp = (b - (d * (a / c))) / c
else if (c <= 800.0d0) then
tmp = ((b * (c / d)) - a) / d
else
tmp = (b - (a * (d / c))) / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -1.72e-20) {
tmp = (b - (d * (a / c))) / c;
} else if (c <= 800.0) {
tmp = ((b * (c / d)) - a) / d;
} else {
tmp = (b - (a * (d / c))) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -1.72e-20: tmp = (b - (d * (a / c))) / c elif c <= 800.0: tmp = ((b * (c / d)) - a) / d else: tmp = (b - (a * (d / c))) / c return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -1.72e-20) tmp = Float64(Float64(b - Float64(d * Float64(a / c))) / c); elseif (c <= 800.0) tmp = Float64(Float64(Float64(b * Float64(c / d)) - a) / d); else tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -1.72e-20) tmp = (b - (d * (a / c))) / c; elseif (c <= 800.0) tmp = ((b * (c / d)) - a) / d; else tmp = (b - (a * (d / c))) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -1.72e-20], N[(N[(b - N[(d * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[c, 800.0], N[(N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.72 \cdot 10^{-20}:\\
\;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\
\mathbf{elif}\;c \leq 800:\\
\;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\
\end{array}
\end{array}
if c < -1.7199999999999999e-20Initial program 61.1%
*-un-lft-identity61.1%
add-sqr-sqrt61.1%
times-frac61.1%
hypot-define61.1%
fma-neg61.2%
distribute-rgt-neg-in61.2%
hypot-define74.7%
Applied egg-rr74.7%
Taylor expanded in c around inf 79.2%
mul-1-neg79.2%
associate-*r/83.3%
unsub-neg83.3%
*-commutative83.3%
associate-*l/79.2%
associate-*r/84.8%
Simplified84.8%
if -1.7199999999999999e-20 < c < 800Initial program 75.1%
*-un-lft-identity75.1%
add-sqr-sqrt75.1%
times-frac75.1%
hypot-define75.1%
fma-neg75.1%
distribute-rgt-neg-in75.1%
hypot-define81.5%
Applied egg-rr81.5%
Taylor expanded in d around -inf 81.4%
mul-1-neg81.4%
distribute-rgt-neg-in81.4%
mul-1-neg81.4%
unsub-neg81.4%
associate-/l*81.0%
Simplified81.0%
Taylor expanded in d around inf 84.3%
associate-*r/85.0%
+-commutative85.0%
mul-1-neg85.0%
unsub-neg85.0%
Simplified85.0%
if 800 < c Initial program 48.0%
Taylor expanded in c around inf 73.9%
mul-1-neg73.9%
unsub-neg73.9%
associate-/l*83.1%
Simplified83.1%
Final simplification84.5%
(FPCore (a b c d) :precision binary64 (if (or (<= c -4.2e-26) (not (<= c 5e+57))) (/ b c) (/ (- a) d)))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -4.2e-26) || !(c <= 5e+57)) {
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 <= (-4.2d-26)) .or. (.not. (c <= 5d+57))) 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 <= -4.2e-26) || !(c <= 5e+57)) {
tmp = b / c;
} else {
tmp = -a / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -4.2e-26) or not (c <= 5e+57): tmp = b / c else: tmp = -a / d return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -4.2e-26) || !(c <= 5e+57)) 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 <= -4.2e-26) || ~((c <= 5e+57))) tmp = b / c; else tmp = -a / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -4.2e-26], N[Not[LessEqual[c, 5e+57]], $MachinePrecision]], N[(b / c), $MachinePrecision], N[((-a) / d), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -4.2 \cdot 10^{-26} \lor \neg \left(c \leq 5 \cdot 10^{+57}\right):\\
\;\;\;\;\frac{b}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{-a}{d}\\
\end{array}
\end{array}
if c < -4.20000000000000016e-26 or 4.99999999999999972e57 < c Initial program 53.4%
Taylor expanded in c around inf 64.3%
if -4.20000000000000016e-26 < c < 4.99999999999999972e57Initial program 74.8%
Taylor expanded in c around 0 61.3%
associate-*r/61.3%
neg-mul-161.3%
Simplified61.3%
Final simplification62.7%
(FPCore (a b c d) :precision binary64 (if (or (<= d -3e+88) (not (<= d 1.06e+94))) (/ a d) (/ a c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -3e+88) || !(d <= 1.06e+94)) {
tmp = a / d;
} else {
tmp = a / c;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if ((d <= (-3d+88)) .or. (.not. (d <= 1.06d+94))) then
tmp = a / d
else
tmp = a / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -3e+88) || !(d <= 1.06e+94)) {
tmp = a / d;
} else {
tmp = a / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -3e+88) or not (d <= 1.06e+94): tmp = a / d else: tmp = a / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -3e+88) || !(d <= 1.06e+94)) tmp = Float64(a / d); else tmp = Float64(a / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -3e+88) || ~((d <= 1.06e+94))) tmp = a / d; else tmp = a / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -3e+88], N[Not[LessEqual[d, 1.06e+94]], $MachinePrecision]], N[(a / d), $MachinePrecision], N[(a / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -3 \cdot 10^{+88} \lor \neg \left(d \leq 1.06 \cdot 10^{+94}\right):\\
\;\;\;\;\frac{a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c}\\
\end{array}
\end{array}
if d < -3.00000000000000005e88 or 1.0600000000000001e94 < d Initial program 44.9%
Taylor expanded in b around 0 37.5%
associate-/l*42.1%
*-commutative42.1%
associate-*l*42.1%
*-commutative42.1%
associate-*r/42.1%
neg-mul-142.1%
rem-square-sqrt42.1%
unpow242.1%
unpow242.1%
hypot-undefine42.1%
unpow242.1%
unpow242.1%
hypot-undefine42.1%
unpow242.1%
Simplified42.1%
unpow242.1%
hypot-undefine42.1%
hypot-undefine42.1%
add-sqr-sqrt42.1%
+-commutative42.1%
sqr-neg42.1%
neg-mul-142.1%
associate-*l*42.1%
metadata-eval42.1%
add-sqr-sqrt22.4%
sqrt-unprod38.6%
sqr-neg38.6%
sqrt-prod16.1%
add-sqr-sqrt29.9%
cancel-sign-sub-inv29.9%
*-un-lft-identity29.9%
difference-of-squares32.6%
Applied egg-rr32.6%
Taylor expanded in d around inf 30.7%
if -3.00000000000000005e88 < d < 1.0600000000000001e94Initial program 74.9%
*-un-lft-identity74.9%
add-sqr-sqrt74.9%
times-frac75.0%
hypot-define75.0%
fma-neg75.0%
distribute-rgt-neg-in75.0%
hypot-define82.1%
Applied egg-rr82.1%
Taylor expanded in c around -inf 43.1%
associate-*r/43.2%
+-commutative43.2%
mul-1-neg43.2%
unsub-neg43.2%
*-commutative43.2%
associate-*l/43.1%
associate-*r/42.7%
Simplified42.7%
Taylor expanded in c around 0 11.3%
Final simplification17.8%
(FPCore (a b c d) :precision binary64 (if (or (<= d -5.4e+94) (not (<= d 1.8e+115))) (/ a d) (/ b c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -5.4e+94) || !(d <= 1.8e+115)) {
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+94)) .or. (.not. (d <= 1.8d+115))) 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+94) || !(d <= 1.8e+115)) {
tmp = a / d;
} else {
tmp = b / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -5.4e+94) or not (d <= 1.8e+115): tmp = a / d else: tmp = b / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -5.4e+94) || !(d <= 1.8e+115)) 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+94) || ~((d <= 1.8e+115))) tmp = a / d; else tmp = b / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -5.4e+94], N[Not[LessEqual[d, 1.8e+115]], $MachinePrecision]], N[(a / d), $MachinePrecision], N[(b / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -5.4 \cdot 10^{+94} \lor \neg \left(d \leq 1.8 \cdot 10^{+115}\right):\\
\;\;\;\;\frac{a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if d < -5.4000000000000003e94 or 1.8e115 < d Initial program 42.8%
Taylor expanded in b around 0 37.2%
associate-/l*42.1%
*-commutative42.1%
associate-*l*42.1%
*-commutative42.1%
associate-*r/42.1%
neg-mul-142.1%
rem-square-sqrt42.1%
unpow242.1%
unpow242.1%
hypot-undefine42.1%
unpow242.1%
unpow242.1%
hypot-undefine42.1%
unpow242.1%
Simplified42.1%
unpow242.1%
hypot-undefine42.1%
hypot-undefine42.1%
add-sqr-sqrt42.1%
+-commutative42.1%
sqr-neg42.1%
neg-mul-142.1%
associate-*l*42.1%
metadata-eval42.1%
add-sqr-sqrt23.8%
sqrt-unprod39.6%
sqr-neg39.6%
sqrt-prod15.7%
add-sqr-sqrt30.4%
cancel-sign-sub-inv30.4%
*-un-lft-identity30.4%
difference-of-squares33.2%
Applied egg-rr33.2%
Taylor expanded in d around inf 32.4%
if -5.4000000000000003e94 < d < 1.8e115Initial program 75.0%
Taylor expanded in c around inf 52.2%
Final simplification45.9%
(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 64.8%
*-un-lft-identity64.8%
add-sqr-sqrt64.8%
times-frac64.9%
hypot-define64.9%
fma-neg64.9%
distribute-rgt-neg-in64.9%
hypot-define74.0%
Applied egg-rr74.0%
Taylor expanded in c around -inf 31.4%
associate-*r/32.5%
+-commutative32.5%
mul-1-neg32.5%
unsub-neg32.5%
*-commutative32.5%
associate-*l/31.4%
associate-*r/32.2%
Simplified32.2%
Taylor expanded in c around 0 9.7%
Final simplification9.7%
(FPCore (a b c d) :precision binary64 (if (< (fabs d) (fabs c)) (/ (- b (* a (/ d c))) (+ c (* d (/ d c)))) (/ (+ (- a) (* b (/ c d))) (+ d (* c (/ c d))))))
double code(double a, double b, double c, double d) {
double tmp;
if (fabs(d) < fabs(c)) {
tmp = (b - (a * (d / c))) / (c + (d * (d / c)));
} else {
tmp = (-a + (b * (c / d))) / (d + (c * (c / d)));
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (abs(d) < abs(c)) then
tmp = (b - (a * (d / c))) / (c + (d * (d / c)))
else
tmp = (-a + (b * (c / d))) / (d + (c * (c / d)))
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (Math.abs(d) < Math.abs(c)) {
tmp = (b - (a * (d / c))) / (c + (d * (d / c)));
} else {
tmp = (-a + (b * (c / d))) / (d + (c * (c / d)));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if math.fabs(d) < math.fabs(c): tmp = (b - (a * (d / c))) / (c + (d * (d / c))) else: tmp = (-a + (b * (c / d))) / (d + (c * (c / d))) return tmp
function code(a, b, c, d) tmp = 0.0 if (abs(d) < abs(c)) tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / Float64(c + Float64(d * Float64(d / c)))); else tmp = Float64(Float64(Float64(-a) + Float64(b * Float64(c / d))) / Float64(d + Float64(c * Float64(c / d)))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (abs(d) < abs(c)) tmp = (b - (a * (d / c))) / (c + (d * (d / c))); else tmp = (-a + (b * (c / d))) / (d + (c * (c / d))); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Less[N[Abs[d], $MachinePrecision], N[Abs[c], $MachinePrecision]], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(c + N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[((-a) + N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(d + N[(c * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left|d\right| < \left|c\right|:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c + d \cdot \frac{d}{c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-a\right) + b \cdot \frac{c}{d}}{d + c \cdot \frac{c}{d}}\\
\end{array}
\end{array}
herbie shell --seed 2024076
(FPCore (a b c d)
:name "Complex division, imag part"
:precision binary64
:alt
(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))))