
(FPCore (a b c d) :precision binary64 (/ (- (* b c) (* a d)) (+ (* c c) (* d d))))
double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = ((b * c) - (a * d)) / ((c * c) + (d * d))
end function
public static double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
def code(a, b, c, d): return ((b * c) - (a * d)) / ((c * c) + (d * d))
function code(a, b, c, d) return Float64(Float64(Float64(b * c) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d))) end
function tmp = code(a, b, c, d) tmp = ((b * c) - (a * d)) / ((c * c) + (d * d)); end
code[a_, b_, c_, d_] := N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b c d) :precision binary64 (/ (- (* b c) (* a d)) (+ (* c c) (* d d))))
double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = ((b * c) - (a * d)) / ((c * c) + (d * d))
end function
public static double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
def code(a, b, c, d): return ((b * c) - (a * d)) / ((c * c) + (d * d))
function code(a, b, c, d) return Float64(Float64(Float64(b * c) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d))) end
function tmp = code(a, b, c, d) tmp = ((b * c) - (a * d)) / ((c * c) + (d * d)); end
code[a_, b_, c_, d_] := N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}
\end{array}
(FPCore (a b c d) :precision binary64 (if (<= (/ (- (* b c) (* a d)) (+ (* c c) (* d d))) 2e+293) (* (/ (- (* a d) (* b c)) (hypot c d)) (/ -1.0 (hypot c d))) (/ (- (/ c (/ d b)) a) d)))
double code(double a, double b, double c, double d) {
double tmp;
if ((((b * c) - (a * d)) / ((c * c) + (d * d))) <= 2e+293) {
tmp = (((a * d) - (b * c)) / hypot(c, d)) * (-1.0 / hypot(c, d));
} else {
tmp = ((c / (d / b)) - a) / d;
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double tmp;
if ((((b * c) - (a * d)) / ((c * c) + (d * d))) <= 2e+293) {
tmp = (((a * d) - (b * c)) / Math.hypot(c, d)) * (-1.0 / Math.hypot(c, d));
} else {
tmp = ((c / (d / b)) - a) / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (((b * c) - (a * d)) / ((c * c) + (d * d))) <= 2e+293: tmp = (((a * d) - (b * c)) / math.hypot(c, d)) * (-1.0 / math.hypot(c, d)) else: tmp = ((c / (d / b)) - a) / d 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))) <= 2e+293) tmp = Float64(Float64(Float64(Float64(a * d) - Float64(b * c)) / hypot(c, d)) * Float64(-1.0 / hypot(c, d))); else tmp = Float64(Float64(Float64(c / Float64(d / b)) - a) / d); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((((b * c) - (a * d)) / ((c * c) + (d * d))) <= 2e+293) tmp = (((a * d) - (b * c)) / hypot(c, d)) * (-1.0 / hypot(c, d)); else tmp = ((c / (d / b)) - a) / d; end tmp_2 = 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], 2e+293], N[(N[(N[(N[(a * d), $MachinePrecision] - N[(b * c), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(-1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(c / N[(d / b), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \leq 2 \cdot 10^{+293}:\\
\;\;\;\;\frac{a \cdot d - b \cdot c}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{-1}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{c}{\frac{d}{b}} - a}{d}\\
\end{array}
\end{array}
if (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 1.9999999999999998e293Initial program 76.0%
*-un-lft-identity76.0%
add-sqr-sqrt76.0%
times-frac76.0%
hypot-define76.0%
hypot-define95.6%
Applied egg-rr95.6%
if 1.9999999999999998e293 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 9.0%
Taylor expanded in c around 0 45.1%
+-commutative45.1%
mul-1-neg45.1%
unsub-neg45.1%
unpow245.1%
associate-/r*50.6%
div-sub52.4%
*-commutative52.4%
associate-/l*57.8%
Simplified57.8%
clear-num57.8%
un-div-inv57.9%
Applied egg-rr57.9%
Final simplification87.2%
(FPCore (a b c d)
:precision binary64
(if (<= d -2.4e+106)
(/ (- (/ c (/ d b)) a) d)
(if (<= d 5.5e+97)
(* b (/ (/ (- c (/ d (/ b a))) (hypot c d)) (hypot c d)))
(/ (- (* c (/ b d)) a) d))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -2.4e+106) {
tmp = ((c / (d / b)) - a) / d;
} else if (d <= 5.5e+97) {
tmp = b * (((c - (d / (b / a))) / hypot(c, d)) / hypot(c, d));
} else {
tmp = ((c * (b / d)) - a) / d;
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double tmp;
if (d <= -2.4e+106) {
tmp = ((c / (d / b)) - a) / d;
} else if (d <= 5.5e+97) {
tmp = b * (((c - (d / (b / a))) / Math.hypot(c, d)) / Math.hypot(c, d));
} else {
tmp = ((c * (b / d)) - a) / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -2.4e+106: tmp = ((c / (d / b)) - a) / d elif d <= 5.5e+97: tmp = b * (((c - (d / (b / a))) / math.hypot(c, d)) / math.hypot(c, d)) else: tmp = ((c * (b / d)) - a) / d return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -2.4e+106) tmp = Float64(Float64(Float64(c / Float64(d / b)) - a) / d); elseif (d <= 5.5e+97) tmp = Float64(b * Float64(Float64(Float64(c - Float64(d / Float64(b / a))) / hypot(c, d)) / hypot(c, d))); else tmp = Float64(Float64(Float64(c * Float64(b / d)) - a) / d); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= -2.4e+106) tmp = ((c / (d / b)) - a) / d; elseif (d <= 5.5e+97) tmp = b * (((c - (d / (b / a))) / hypot(c, d)) / hypot(c, d)); else tmp = ((c * (b / d)) - a) / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -2.4e+106], N[(N[(N[(c / N[(d / b), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, 5.5e+97], N[(b * N[(N[(N[(c - N[(d / N[(b / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -2.4 \cdot 10^{+106}:\\
\;\;\;\;\frac{\frac{c}{\frac{d}{b}} - a}{d}\\
\mathbf{elif}\;d \leq 5.5 \cdot 10^{+97}:\\
\;\;\;\;b \cdot \frac{\frac{c - \frac{d}{\frac{b}{a}}}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\
\end{array}
\end{array}
if d < -2.4000000000000001e106Initial program 34.4%
Taylor expanded in c around 0 71.7%
+-commutative71.7%
mul-1-neg71.7%
unsub-neg71.7%
unpow271.7%
associate-/r*80.1%
div-sub80.2%
*-commutative80.2%
associate-/l*83.4%
Simplified83.4%
clear-num83.4%
un-div-inv83.4%
Applied egg-rr83.4%
if -2.4000000000000001e106 < d < 5.50000000000000021e97Initial program 72.9%
*-un-lft-identity72.9%
add-sqr-sqrt72.9%
times-frac72.8%
hypot-define72.8%
hypot-define85.6%
Applied egg-rr85.6%
Taylor expanded in b around inf 82.2%
mul-1-neg82.2%
unsub-neg82.2%
*-commutative82.2%
associate-/l*76.1%
Simplified76.1%
associate-*l/76.3%
*-un-lft-identity76.3%
clear-num75.7%
associate-/l*88.0%
clear-num87.9%
un-div-inv89.3%
Applied egg-rr89.3%
associate-/r/89.8%
associate-*r/77.9%
associate-/l*78.0%
*-commutative78.0%
associate-*r/78.1%
*-rgt-identity78.1%
associate-*r/90.1%
associate-/l*88.8%
Simplified88.8%
if 5.50000000000000021e97 < d Initial program 37.5%
Taylor expanded in c around 0 73.9%
+-commutative73.9%
mul-1-neg73.9%
unsub-neg73.9%
unpow273.9%
associate-/r*78.0%
div-sub78.0%
*-commutative78.0%
associate-/l*82.1%
Simplified82.1%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* b c) (* a d)) (+ (* c c) (* d d)))))
(if (<= c -2.2e+36)
(/ (- b (* a (/ d c))) c)
(if (<= c -8.5e-116)
t_0
(if (<= c 8.2e-117)
(/ (- (* b (/ c d)) a) d)
(if (<= c 9.5e+55) t_0 (* (- (* d (/ a c)) b) (/ -1.0 c))))))))
double code(double a, double b, double c, double d) {
double t_0 = ((b * c) - (a * d)) / ((c * c) + (d * d));
double tmp;
if (c <= -2.2e+36) {
tmp = (b - (a * (d / c))) / c;
} else if (c <= -8.5e-116) {
tmp = t_0;
} else if (c <= 8.2e-117) {
tmp = ((b * (c / d)) - a) / d;
} else if (c <= 9.5e+55) {
tmp = t_0;
} else {
tmp = ((d * (a / c)) - b) * (-1.0 / c);
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: tmp
t_0 = ((b * c) - (a * d)) / ((c * c) + (d * d))
if (c <= (-2.2d+36)) then
tmp = (b - (a * (d / c))) / c
else if (c <= (-8.5d-116)) then
tmp = t_0
else if (c <= 8.2d-117) then
tmp = ((b * (c / d)) - a) / d
else if (c <= 9.5d+55) then
tmp = t_0
else
tmp = ((d * (a / c)) - b) * ((-1.0d0) / c)
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = ((b * c) - (a * d)) / ((c * c) + (d * d));
double tmp;
if (c <= -2.2e+36) {
tmp = (b - (a * (d / c))) / c;
} else if (c <= -8.5e-116) {
tmp = t_0;
} else if (c <= 8.2e-117) {
tmp = ((b * (c / d)) - a) / d;
} else if (c <= 9.5e+55) {
tmp = t_0;
} else {
tmp = ((d * (a / c)) - b) * (-1.0 / c);
}
return tmp;
}
def code(a, b, c, d): t_0 = ((b * c) - (a * d)) / ((c * c) + (d * d)) tmp = 0 if c <= -2.2e+36: tmp = (b - (a * (d / c))) / c elif c <= -8.5e-116: tmp = t_0 elif c <= 8.2e-117: tmp = ((b * (c / d)) - a) / d elif c <= 9.5e+55: tmp = t_0 else: tmp = ((d * (a / c)) - b) * (-1.0 / c) return tmp
function code(a, b, c, d) t_0 = Float64(Float64(Float64(b * c) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d))) tmp = 0.0 if (c <= -2.2e+36) tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c); elseif (c <= -8.5e-116) tmp = t_0; elseif (c <= 8.2e-117) tmp = Float64(Float64(Float64(b * Float64(c / d)) - a) / d); elseif (c <= 9.5e+55) tmp = t_0; else tmp = Float64(Float64(Float64(d * Float64(a / c)) - b) * Float64(-1.0 / c)); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((b * c) - (a * d)) / ((c * c) + (d * d)); tmp = 0.0; if (c <= -2.2e+36) tmp = (b - (a * (d / c))) / c; elseif (c <= -8.5e-116) tmp = t_0; elseif (c <= 8.2e-117) tmp = ((b * (c / d)) - a) / d; elseif (c <= 9.5e+55) tmp = t_0; else tmp = ((d * (a / c)) - b) * (-1.0 / c); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = 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, -2.2e+36], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[c, -8.5e-116], t$95$0, If[LessEqual[c, 8.2e-117], N[(N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 9.5e+55], t$95$0, N[(N[(N[(d * N[(a / c), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision] * N[(-1.0 / c), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{if}\;c \leq -2.2 \cdot 10^{+36}:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\
\mathbf{elif}\;c \leq -8.5 \cdot 10^{-116}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq 8.2 \cdot 10^{-117}:\\
\;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\
\mathbf{elif}\;c \leq 9.5 \cdot 10^{+55}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\left(d \cdot \frac{a}{c} - b\right) \cdot \frac{-1}{c}\\
\end{array}
\end{array}
if c < -2.2e36Initial program 49.5%
*-un-lft-identity49.5%
add-sqr-sqrt49.5%
times-frac49.5%
hypot-define49.5%
hypot-define72.1%
Applied egg-rr72.1%
Taylor expanded in b around inf 62.1%
mul-1-neg62.1%
unsub-neg62.1%
*-commutative62.1%
associate-/l*58.1%
Simplified58.1%
Taylor expanded in c around inf 84.3%
mul-1-neg84.3%
unsub-neg84.3%
associate-/l*86.4%
Simplified86.4%
if -2.2e36 < c < -8.4999999999999995e-116 or 8.20000000000000063e-117 < c < 9.49999999999999989e55Initial program 81.3%
if -8.4999999999999995e-116 < c < 8.20000000000000063e-117Initial program 67.3%
Taylor expanded in c around 0 79.4%
+-commutative79.4%
mul-1-neg79.4%
unsub-neg79.4%
unpow279.4%
associate-/r*88.6%
div-sub90.0%
*-commutative90.0%
associate-/l*87.6%
Simplified87.6%
clear-num87.5%
un-div-inv87.5%
Applied egg-rr87.5%
associate-/r/90.1%
Simplified90.1%
if 9.49999999999999989e55 < c Initial program 30.6%
Taylor expanded in c around inf 74.9%
mul-1-neg74.9%
unsub-neg74.9%
*-commutative74.9%
Simplified74.9%
frac-2neg74.9%
div-inv74.7%
sub-neg74.7%
distribute-neg-in74.7%
distribute-neg-frac274.7%
distribute-frac-neg74.7%
frac-2neg74.7%
associate-/l*84.4%
Applied egg-rr84.4%
Final simplification85.5%
(FPCore (a b c d)
:precision binary64
(if (<= c -3.5e-31)
(/ (- b (* a (/ d c))) c)
(if (<= c 2.8e+87)
(/ (- (* b (/ c d)) a) d)
(* (- (* d (/ a c)) b) (/ -1.0 c)))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -3.5e-31) {
tmp = (b - (a * (d / c))) / c;
} else if (c <= 2.8e+87) {
tmp = ((b * (c / d)) - a) / d;
} else {
tmp = ((d * (a / c)) - b) * (-1.0 / 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 <= (-3.5d-31)) then
tmp = (b - (a * (d / c))) / c
else if (c <= 2.8d+87) then
tmp = ((b * (c / d)) - a) / d
else
tmp = ((d * (a / c)) - b) * ((-1.0d0) / c)
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -3.5e-31) {
tmp = (b - (a * (d / c))) / c;
} else if (c <= 2.8e+87) {
tmp = ((b * (c / d)) - a) / d;
} else {
tmp = ((d * (a / c)) - b) * (-1.0 / c);
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -3.5e-31: tmp = (b - (a * (d / c))) / c elif c <= 2.8e+87: tmp = ((b * (c / d)) - a) / d else: tmp = ((d * (a / c)) - b) * (-1.0 / c) return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -3.5e-31) tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c); elseif (c <= 2.8e+87) tmp = Float64(Float64(Float64(b * Float64(c / d)) - a) / d); else tmp = Float64(Float64(Float64(d * Float64(a / c)) - b) * Float64(-1.0 / c)); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -3.5e-31) tmp = (b - (a * (d / c))) / c; elseif (c <= 2.8e+87) tmp = ((b * (c / d)) - a) / d; else tmp = ((d * (a / c)) - b) * (-1.0 / c); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -3.5e-31], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[c, 2.8e+87], N[(N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], N[(N[(N[(d * N[(a / c), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision] * N[(-1.0 / c), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -3.5 \cdot 10^{-31}:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\
\mathbf{elif}\;c \leq 2.8 \cdot 10^{+87}:\\
\;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\
\mathbf{else}:\\
\;\;\;\;\left(d \cdot \frac{a}{c} - b\right) \cdot \frac{-1}{c}\\
\end{array}
\end{array}
if c < -3.49999999999999985e-31Initial program 59.4%
*-un-lft-identity59.4%
add-sqr-sqrt59.4%
times-frac59.4%
hypot-define59.4%
hypot-define76.6%
Applied egg-rr76.6%
Taylor expanded in b around inf 67.8%
mul-1-neg67.8%
unsub-neg67.8%
*-commutative67.8%
associate-/l*63.4%
Simplified63.4%
Taylor expanded in c around inf 79.9%
mul-1-neg79.9%
unsub-neg79.9%
associate-/l*81.4%
Simplified81.4%
if -3.49999999999999985e-31 < c < 2.80000000000000015e87Initial program 71.0%
Taylor expanded in c around 0 68.5%
+-commutative68.5%
mul-1-neg68.5%
unsub-neg68.5%
unpow268.5%
associate-/r*76.2%
div-sub77.1%
*-commutative77.1%
associate-/l*76.4%
Simplified76.4%
clear-num76.4%
un-div-inv76.5%
Applied egg-rr76.5%
associate-/r/77.8%
Simplified77.8%
if 2.80000000000000015e87 < c Initial program 32.9%
Taylor expanded in c around inf 79.0%
mul-1-neg79.0%
unsub-neg79.0%
*-commutative79.0%
Simplified79.0%
frac-2neg79.0%
div-inv78.7%
sub-neg78.7%
distribute-neg-in78.7%
distribute-neg-frac278.7%
distribute-frac-neg78.7%
frac-2neg78.7%
associate-/l*89.3%
Applied egg-rr89.3%
Final simplification80.8%
(FPCore (a b c d)
:precision binary64
(if (<= c -5.9e-27)
(/ (- b (* a (/ d c))) c)
(if (<= c 3.4e+87)
(/ (- (* b (/ c d)) a) d)
(/ (+ b (* a (* d (/ -1.0 c)))) c))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -5.9e-27) {
tmp = (b - (a * (d / c))) / c;
} else if (c <= 3.4e+87) {
tmp = ((b * (c / d)) - a) / d;
} else {
tmp = (b + (a * (d * (-1.0 / 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 <= (-5.9d-27)) then
tmp = (b - (a * (d / c))) / c
else if (c <= 3.4d+87) then
tmp = ((b * (c / d)) - a) / d
else
tmp = (b + (a * (d * ((-1.0d0) / c)))) / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -5.9e-27) {
tmp = (b - (a * (d / c))) / c;
} else if (c <= 3.4e+87) {
tmp = ((b * (c / d)) - a) / d;
} else {
tmp = (b + (a * (d * (-1.0 / c)))) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -5.9e-27: tmp = (b - (a * (d / c))) / c elif c <= 3.4e+87: tmp = ((b * (c / d)) - a) / d else: tmp = (b + (a * (d * (-1.0 / c)))) / c return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -5.9e-27) tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c); elseif (c <= 3.4e+87) tmp = Float64(Float64(Float64(b * Float64(c / d)) - a) / d); else tmp = Float64(Float64(b + Float64(a * Float64(d * Float64(-1.0 / c)))) / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -5.9e-27) tmp = (b - (a * (d / c))) / c; elseif (c <= 3.4e+87) tmp = ((b * (c / d)) - a) / d; else tmp = (b + (a * (d * (-1.0 / c)))) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -5.9e-27], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[c, 3.4e+87], N[(N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], N[(N[(b + N[(a * N[(d * N[(-1.0 / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -5.9 \cdot 10^{-27}:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\
\mathbf{elif}\;c \leq 3.4 \cdot 10^{+87}:\\
\;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b + a \cdot \left(d \cdot \frac{-1}{c}\right)}{c}\\
\end{array}
\end{array}
if c < -5.8999999999999998e-27Initial program 59.4%
*-un-lft-identity59.4%
add-sqr-sqrt59.4%
times-frac59.4%
hypot-define59.4%
hypot-define76.6%
Applied egg-rr76.6%
Taylor expanded in b around inf 67.8%
mul-1-neg67.8%
unsub-neg67.8%
*-commutative67.8%
associate-/l*63.4%
Simplified63.4%
Taylor expanded in c around inf 79.9%
mul-1-neg79.9%
unsub-neg79.9%
associate-/l*81.4%
Simplified81.4%
if -5.8999999999999998e-27 < c < 3.4000000000000002e87Initial program 71.0%
Taylor expanded in c around 0 68.5%
+-commutative68.5%
mul-1-neg68.5%
unsub-neg68.5%
unpow268.5%
associate-/r*76.2%
div-sub77.1%
*-commutative77.1%
associate-/l*76.4%
Simplified76.4%
clear-num76.4%
un-div-inv76.5%
Applied egg-rr76.5%
associate-/r/77.8%
Simplified77.8%
if 3.4000000000000002e87 < c Initial program 32.9%
Taylor expanded in c around inf 79.0%
mul-1-neg79.0%
unsub-neg79.0%
*-commutative79.0%
Simplified79.0%
div-inv78.9%
*-commutative78.9%
associate-*l*88.2%
Applied egg-rr88.2%
Final simplification80.6%
(FPCore (a b c d) :precision binary64 (if (or (<= c -1.15e-33) (not (<= c 1.18e+86))) (/ (- b (* a (/ d c))) c) (/ (- (* b (/ c d)) a) d)))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -1.15e-33) || !(c <= 1.18e+86)) {
tmp = (b - (a * (d / c))) / c;
} else {
tmp = ((b * (c / d)) - a) / d;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if ((c <= (-1.15d-33)) .or. (.not. (c <= 1.18d+86))) then
tmp = (b - (a * (d / c))) / c
else
tmp = ((b * (c / d)) - a) / d
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -1.15e-33) || !(c <= 1.18e+86)) {
tmp = (b - (a * (d / c))) / c;
} else {
tmp = ((b * (c / d)) - a) / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -1.15e-33) or not (c <= 1.18e+86): tmp = (b - (a * (d / c))) / c else: tmp = ((b * (c / d)) - a) / d return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -1.15e-33) || !(c <= 1.18e+86)) tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c); else tmp = Float64(Float64(Float64(b * Float64(c / d)) - a) / d); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((c <= -1.15e-33) || ~((c <= 1.18e+86))) tmp = (b - (a * (d / c))) / c; else tmp = ((b * (c / d)) - a) / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -1.15e-33], N[Not[LessEqual[c, 1.18e+86]], $MachinePrecision]], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], N[(N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.15 \cdot 10^{-33} \lor \neg \left(c \leq 1.18 \cdot 10^{+86}\right):\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\
\end{array}
\end{array}
if c < -1.14999999999999993e-33 or 1.18e86 < c Initial program 48.6%
*-un-lft-identity48.6%
add-sqr-sqrt48.6%
times-frac48.6%
hypot-define48.6%
hypot-define69.7%
Applied egg-rr69.7%
Taylor expanded in b around inf 61.9%
mul-1-neg61.9%
unsub-neg61.9%
*-commutative61.9%
associate-/l*55.9%
Simplified55.9%
Taylor expanded in c around inf 79.5%
mul-1-neg79.5%
unsub-neg79.5%
associate-/l*84.1%
Simplified84.1%
if -1.14999999999999993e-33 < c < 1.18e86Initial program 71.0%
Taylor expanded in c around 0 68.5%
+-commutative68.5%
mul-1-neg68.5%
unsub-neg68.5%
unpow268.5%
associate-/r*76.2%
div-sub77.1%
*-commutative77.1%
associate-/l*76.4%
Simplified76.4%
clear-num76.4%
un-div-inv76.5%
Applied egg-rr76.5%
associate-/r/77.8%
Simplified77.8%
Final simplification80.6%
(FPCore (a b c d) :precision binary64 (if (or (<= d -2.7e-20) (not (<= d 2.3e-50))) (/ (- (* c (/ b d)) a) d) (/ (- b (* a (/ d c))) c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -2.7e-20) || !(d <= 2.3e-50)) {
tmp = ((c * (b / 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 ((d <= (-2.7d-20)) .or. (.not. (d <= 2.3d-50))) then
tmp = ((c * (b / 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 ((d <= -2.7e-20) || !(d <= 2.3e-50)) {
tmp = ((c * (b / d)) - a) / d;
} else {
tmp = (b - (a * (d / c))) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -2.7e-20) or not (d <= 2.3e-50): tmp = ((c * (b / d)) - a) / d else: tmp = (b - (a * (d / c))) / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -2.7e-20) || !(d <= 2.3e-50)) tmp = Float64(Float64(Float64(c * Float64(b / 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 ((d <= -2.7e-20) || ~((d <= 2.3e-50))) tmp = ((c * (b / d)) - a) / d; else tmp = (b - (a * (d / c))) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -2.7e-20], N[Not[LessEqual[d, 2.3e-50]], $MachinePrecision]], N[(N[(N[(c * N[(b / 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}\;d \leq -2.7 \cdot 10^{-20} \lor \neg \left(d \leq 2.3 \cdot 10^{-50}\right):\\
\;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\
\end{array}
\end{array}
if d < -2.7e-20 or 2.3000000000000002e-50 < d Initial program 49.7%
Taylor expanded in c around 0 69.3%
+-commutative69.3%
mul-1-neg69.3%
unsub-neg69.3%
unpow269.3%
associate-/r*73.0%
div-sub73.0%
*-commutative73.0%
associate-/l*75.4%
Simplified75.4%
if -2.7e-20 < d < 2.3000000000000002e-50Initial program 72.7%
*-un-lft-identity72.7%
add-sqr-sqrt72.7%
times-frac72.6%
hypot-define72.7%
hypot-define88.0%
Applied egg-rr88.0%
Taylor expanded in b around inf 84.9%
mul-1-neg84.9%
unsub-neg84.9%
*-commutative84.9%
associate-/l*78.0%
Simplified78.0%
Taylor expanded in c around inf 85.2%
mul-1-neg85.2%
unsub-neg85.2%
associate-/l*85.4%
Simplified85.4%
Final simplification80.4%
(FPCore (a b c d) :precision binary64 (if (or (<= d -3e-20) (not (<= d 1.45e-53))) (/ a (- d)) (/ (- b (* a (/ d c))) c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -3e-20) || !(d <= 1.45e-53)) {
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 <= (-3d-20)) .or. (.not. (d <= 1.45d-53))) 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 <= -3e-20) || !(d <= 1.45e-53)) {
tmp = a / -d;
} else {
tmp = (b - (a * (d / c))) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -3e-20) or not (d <= 1.45e-53): tmp = a / -d else: tmp = (b - (a * (d / c))) / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -3e-20) || !(d <= 1.45e-53)) 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 <= -3e-20) || ~((d <= 1.45e-53))) tmp = a / -d; else tmp = (b - (a * (d / c))) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -3e-20], N[Not[LessEqual[d, 1.45e-53]], $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 -3 \cdot 10^{-20} \lor \neg \left(d \leq 1.45 \cdot 10^{-53}\right):\\
\;\;\;\;\frac{a}{-d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\
\end{array}
\end{array}
if d < -3.00000000000000029e-20 or 1.4499999999999999e-53 < d Initial program 49.7%
Taylor expanded in c around 0 65.0%
associate-*r/65.0%
neg-mul-165.0%
Simplified65.0%
if -3.00000000000000029e-20 < d < 1.4499999999999999e-53Initial program 72.7%
*-un-lft-identity72.7%
add-sqr-sqrt72.7%
times-frac72.6%
hypot-define72.7%
hypot-define88.0%
Applied egg-rr88.0%
Taylor expanded in b around inf 84.9%
mul-1-neg84.9%
unsub-neg84.9%
*-commutative84.9%
associate-/l*78.0%
Simplified78.0%
Taylor expanded in c around inf 85.2%
mul-1-neg85.2%
unsub-neg85.2%
associate-/l*85.4%
Simplified85.4%
Final simplification75.2%
(FPCore (a b c d) :precision binary64 (if (or (<= c -1.9e-32) (not (<= c 7e+45))) (/ b c) (/ a (- d))))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -1.9e-32) || !(c <= 7e+45)) {
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 <= (-1.9d-32)) .or. (.not. (c <= 7d+45))) 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 <= -1.9e-32) || !(c <= 7e+45)) {
tmp = b / c;
} else {
tmp = a / -d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -1.9e-32) or not (c <= 7e+45): tmp = b / c else: tmp = a / -d return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -1.9e-32) || !(c <= 7e+45)) 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 <= -1.9e-32) || ~((c <= 7e+45))) tmp = b / c; else tmp = a / -d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -1.9e-32], N[Not[LessEqual[c, 7e+45]], $MachinePrecision]], N[(b / c), $MachinePrecision], N[(a / (-d)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.9 \cdot 10^{-32} \lor \neg \left(c \leq 7 \cdot 10^{+45}\right):\\
\;\;\;\;\frac{b}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{-d}\\
\end{array}
\end{array}
if c < -1.90000000000000004e-32 or 7.00000000000000046e45 < c Initial program 48.0%
Taylor expanded in c around inf 68.1%
if -1.90000000000000004e-32 < c < 7.00000000000000046e45Initial program 72.5%
Taylor expanded in c around 0 62.6%
associate-*r/62.6%
neg-mul-162.6%
Simplified62.6%
Final simplification65.1%
(FPCore (a b c d) :precision binary64 (if (or (<= d -5.7e+124) (not (<= d 6e+107))) (/ a d) (/ a c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -5.7e+124) || !(d <= 6e+107)) {
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 <= (-5.7d+124)) .or. (.not. (d <= 6d+107))) 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 <= -5.7e+124) || !(d <= 6e+107)) {
tmp = a / d;
} else {
tmp = a / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -5.7e+124) or not (d <= 6e+107): tmp = a / d else: tmp = a / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -5.7e+124) || !(d <= 6e+107)) 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 <= -5.7e+124) || ~((d <= 6e+107))) tmp = a / d; else tmp = a / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -5.7e+124], N[Not[LessEqual[d, 6e+107]], $MachinePrecision]], N[(a / d), $MachinePrecision], N[(a / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -5.7 \cdot 10^{+124} \lor \neg \left(d \leq 6 \cdot 10^{+107}\right):\\
\;\;\;\;\frac{a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c}\\
\end{array}
\end{array}
if d < -5.70000000000000021e124 or 6.00000000000000046e107 < d Initial program 32.1%
*-un-lft-identity32.1%
add-sqr-sqrt32.1%
times-frac32.1%
hypot-define32.1%
hypot-define55.6%
Applied egg-rr55.6%
Taylor expanded in c around 0 52.5%
neg-mul-152.5%
Simplified52.5%
Taylor expanded in d around -inf 24.4%
if -5.70000000000000021e124 < d < 6.00000000000000046e107Initial program 73.6%
*-un-lft-identity73.6%
add-sqr-sqrt73.6%
times-frac73.6%
hypot-define73.6%
hypot-define86.0%
Applied egg-rr86.0%
Taylor expanded in c around 0 20.8%
neg-mul-120.8%
Simplified20.8%
Taylor expanded in c around -inf 11.4%
Final simplification15.3%
(FPCore (a b c d) :precision binary64 (if (<= d 3.2e+210) (/ b c) (/ a d)))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= 3.2e+210) {
tmp = b / c;
} else {
tmp = a / d;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (d <= 3.2d+210) then
tmp = b / c
else
tmp = a / d
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (d <= 3.2e+210) {
tmp = b / c;
} else {
tmp = a / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= 3.2e+210: tmp = b / c else: tmp = a / d return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= 3.2e+210) tmp = Float64(b / c); else tmp = Float64(a / d); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= 3.2e+210) tmp = b / c; else tmp = a / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, 3.2e+210], N[(b / c), $MachinePrecision], N[(a / d), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq 3.2 \cdot 10^{+210}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{d}\\
\end{array}
\end{array}
if d < 3.2000000000000002e210Initial program 63.3%
Taylor expanded in c around inf 44.8%
if 3.2000000000000002e210 < d Initial program 36.4%
*-un-lft-identity36.4%
add-sqr-sqrt36.4%
times-frac36.4%
hypot-define36.4%
hypot-define44.2%
Applied egg-rr44.2%
Taylor expanded in c around 0 86.6%
neg-mul-186.6%
Simplified86.6%
Taylor expanded in d around -inf 38.1%
(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 61.1%
*-un-lft-identity61.1%
add-sqr-sqrt61.1%
times-frac61.1%
hypot-define61.1%
hypot-define76.8%
Applied egg-rr76.8%
Taylor expanded in c around 0 30.4%
neg-mul-130.4%
Simplified30.4%
Taylor expanded in c around -inf 9.9%
(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 2024149
(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))))