
(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 10 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 (<= c -2.1e+139)
(/ (- b (/ a (/ c d))) c)
(if (<= c -7.2e-54)
(/ (- (* c b) (* a d)) (+ (* c c) (* d d)))
(if (<= c 7.2e+15)
(/ (- (/ b (/ d c)) a) d)
(/ (+ b (* d (* a (/ -1.0 c)))) c)))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -2.1e+139) {
tmp = (b - (a / (c / d))) / c;
} else if (c <= -7.2e-54) {
tmp = ((c * b) - (a * d)) / ((c * c) + (d * d));
} else if (c <= 7.2e+15) {
tmp = ((b / (d / c)) - a) / d;
} else {
tmp = (b + (d * (a * (-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 <= (-2.1d+139)) then
tmp = (b - (a / (c / d))) / c
else if (c <= (-7.2d-54)) then
tmp = ((c * b) - (a * d)) / ((c * c) + (d * d))
else if (c <= 7.2d+15) then
tmp = ((b / (d / c)) - a) / d
else
tmp = (b + (d * (a * ((-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 <= -2.1e+139) {
tmp = (b - (a / (c / d))) / c;
} else if (c <= -7.2e-54) {
tmp = ((c * b) - (a * d)) / ((c * c) + (d * d));
} else if (c <= 7.2e+15) {
tmp = ((b / (d / c)) - a) / d;
} else {
tmp = (b + (d * (a * (-1.0 / c)))) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -2.1e+139: tmp = (b - (a / (c / d))) / c elif c <= -7.2e-54: tmp = ((c * b) - (a * d)) / ((c * c) + (d * d)) elif c <= 7.2e+15: tmp = ((b / (d / c)) - a) / d else: tmp = (b + (d * (a * (-1.0 / c)))) / c return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -2.1e+139) tmp = Float64(Float64(b - Float64(a / Float64(c / d))) / c); elseif (c <= -7.2e-54) tmp = Float64(Float64(Float64(c * b) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d))); elseif (c <= 7.2e+15) tmp = Float64(Float64(Float64(b / Float64(d / c)) - a) / d); else tmp = Float64(Float64(b + Float64(d * Float64(a * Float64(-1.0 / c)))) / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -2.1e+139) tmp = (b - (a / (c / d))) / c; elseif (c <= -7.2e-54) tmp = ((c * b) - (a * d)) / ((c * c) + (d * d)); elseif (c <= 7.2e+15) tmp = ((b / (d / c)) - a) / d; else tmp = (b + (d * (a * (-1.0 / c)))) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -2.1e+139], N[(N[(b - N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[c, -7.2e-54], N[(N[(N[(c * b), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 7.2e+15], N[(N[(N[(b / N[(d / c), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], N[(N[(b + N[(d * N[(a * N[(-1.0 / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -2.1 \cdot 10^{+139}:\\
\;\;\;\;\frac{b - \frac{a}{\frac{c}{d}}}{c}\\
\mathbf{elif}\;c \leq -7.2 \cdot 10^{-54}:\\
\;\;\;\;\frac{c \cdot b - a \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;c \leq 7.2 \cdot 10^{+15}:\\
\;\;\;\;\frac{\frac{b}{\frac{d}{c}} - a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b + d \cdot \left(a \cdot \frac{-1}{c}\right)}{c}\\
\end{array}
\end{array}
if c < -2.0999999999999999e139Initial program 31.1%
Taylor expanded in c around inf 89.0%
mul-1-neg89.0%
unsub-neg89.0%
associate-/l*95.6%
Simplified95.6%
clear-num95.6%
un-div-inv95.6%
Applied egg-rr95.6%
if -2.0999999999999999e139 < c < -7.19999999999999953e-54Initial program 79.6%
if -7.19999999999999953e-54 < c < 7.2e15Initial program 70.6%
Taylor expanded in d around -inf 86.0%
mul-1-neg86.0%
distribute-neg-frac286.0%
mul-1-neg86.0%
unsub-neg86.0%
associate-/l*86.0%
Simplified86.0%
clear-num86.0%
un-div-inv86.1%
Applied egg-rr86.1%
if 7.2e15 < c Initial program 43.6%
Taylor expanded in c around inf 78.9%
associate-*r/86.1%
*-commutative86.1%
div-inv86.1%
associate-*l*86.2%
Applied egg-rr86.2%
Final simplification86.7%
(FPCore (a b c d)
:precision binary64
(if (<= c -41000000.0)
(/ (- b (/ a (/ c d))) c)
(if (<= c 4.4e+15)
(/ (- (/ b (/ d c)) a) d)
(/ (+ b (* d (* a (/ -1.0 c)))) c))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -41000000.0) {
tmp = (b - (a / (c / d))) / c;
} else if (c <= 4.4e+15) {
tmp = ((b / (d / c)) - a) / d;
} else {
tmp = (b + (d * (a * (-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 <= (-41000000.0d0)) then
tmp = (b - (a / (c / d))) / c
else if (c <= 4.4d+15) then
tmp = ((b / (d / c)) - a) / d
else
tmp = (b + (d * (a * ((-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 <= -41000000.0) {
tmp = (b - (a / (c / d))) / c;
} else if (c <= 4.4e+15) {
tmp = ((b / (d / c)) - a) / d;
} else {
tmp = (b + (d * (a * (-1.0 / c)))) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -41000000.0: tmp = (b - (a / (c / d))) / c elif c <= 4.4e+15: tmp = ((b / (d / c)) - a) / d else: tmp = (b + (d * (a * (-1.0 / c)))) / c return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -41000000.0) tmp = Float64(Float64(b - Float64(a / Float64(c / d))) / c); elseif (c <= 4.4e+15) tmp = Float64(Float64(Float64(b / Float64(d / c)) - a) / d); else tmp = Float64(Float64(b + Float64(d * Float64(a * Float64(-1.0 / c)))) / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -41000000.0) tmp = (b - (a / (c / d))) / c; elseif (c <= 4.4e+15) tmp = ((b / (d / c)) - a) / d; else tmp = (b + (d * (a * (-1.0 / c)))) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -41000000.0], N[(N[(b - N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[c, 4.4e+15], N[(N[(N[(b / N[(d / c), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], N[(N[(b + N[(d * N[(a * N[(-1.0 / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -41000000:\\
\;\;\;\;\frac{b - \frac{a}{\frac{c}{d}}}{c}\\
\mathbf{elif}\;c \leq 4.4 \cdot 10^{+15}:\\
\;\;\;\;\frac{\frac{b}{\frac{d}{c}} - a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b + d \cdot \left(a \cdot \frac{-1}{c}\right)}{c}\\
\end{array}
\end{array}
if c < -4.1e7Initial program 50.5%
Taylor expanded in c around inf 78.8%
mul-1-neg78.8%
unsub-neg78.8%
associate-/l*82.6%
Simplified82.6%
clear-num82.5%
un-div-inv82.6%
Applied egg-rr82.6%
if -4.1e7 < c < 4.4e15Initial program 72.2%
Taylor expanded in d around -inf 84.1%
mul-1-neg84.1%
distribute-neg-frac284.1%
mul-1-neg84.1%
unsub-neg84.1%
associate-/l*84.2%
Simplified84.2%
clear-num84.2%
un-div-inv84.2%
Applied egg-rr84.2%
if 4.4e15 < c Initial program 43.6%
Taylor expanded in c around inf 78.9%
associate-*r/86.1%
*-commutative86.1%
div-inv86.1%
associate-*l*86.2%
Applied egg-rr86.2%
Final simplification84.1%
(FPCore (a b c d) :precision binary64 (if (or (<= c -11600.0) (not (<= c 2.9e+17))) (/ (- b (/ a (/ c d))) c) (/ (- (/ b (/ d c)) a) d)))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -11600.0) || !(c <= 2.9e+17)) {
tmp = (b - (a / (c / d))) / c;
} else {
tmp = ((b / (d / c)) - 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 <= (-11600.0d0)) .or. (.not. (c <= 2.9d+17))) then
tmp = (b - (a / (c / d))) / c
else
tmp = ((b / (d / c)) - a) / d
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -11600.0) || !(c <= 2.9e+17)) {
tmp = (b - (a / (c / d))) / c;
} else {
tmp = ((b / (d / c)) - a) / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -11600.0) or not (c <= 2.9e+17): tmp = (b - (a / (c / d))) / c else: tmp = ((b / (d / c)) - a) / d return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -11600.0) || !(c <= 2.9e+17)) tmp = Float64(Float64(b - Float64(a / Float64(c / d))) / c); else tmp = Float64(Float64(Float64(b / Float64(d / c)) - a) / d); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((c <= -11600.0) || ~((c <= 2.9e+17))) tmp = (b - (a / (c / d))) / c; else tmp = ((b / (d / c)) - a) / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -11600.0], N[Not[LessEqual[c, 2.9e+17]], $MachinePrecision]], N[(N[(b - N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], N[(N[(N[(b / N[(d / c), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -11600 \lor \neg \left(c \leq 2.9 \cdot 10^{+17}\right):\\
\;\;\;\;\frac{b - \frac{a}{\frac{c}{d}}}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{b}{\frac{d}{c}} - a}{d}\\
\end{array}
\end{array}
if c < -11600 or 2.9e17 < c Initial program 47.7%
Taylor expanded in c around inf 78.9%
mul-1-neg78.9%
unsub-neg78.9%
associate-/l*84.0%
Simplified84.0%
clear-num84.0%
un-div-inv84.1%
Applied egg-rr84.1%
if -11600 < c < 2.9e17Initial program 72.2%
Taylor expanded in d around -inf 84.1%
mul-1-neg84.1%
distribute-neg-frac284.1%
mul-1-neg84.1%
unsub-neg84.1%
associate-/l*84.2%
Simplified84.2%
clear-num84.2%
un-div-inv84.2%
Applied egg-rr84.2%
Final simplification84.1%
(FPCore (a b c d) :precision binary64 (if (or (<= c -112000000.0) (not (<= c 3.5e+17))) (/ (- b (/ a (/ c d))) c) (/ (- (* b (/ c d)) a) d)))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -112000000.0) || !(c <= 3.5e+17)) {
tmp = (b - (a / (c / d))) / 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 <= (-112000000.0d0)) .or. (.not. (c <= 3.5d+17))) then
tmp = (b - (a / (c / d))) / 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 <= -112000000.0) || !(c <= 3.5e+17)) {
tmp = (b - (a / (c / d))) / c;
} else {
tmp = ((b * (c / d)) - a) / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -112000000.0) or not (c <= 3.5e+17): tmp = (b - (a / (c / d))) / c else: tmp = ((b * (c / d)) - a) / d return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -112000000.0) || !(c <= 3.5e+17)) tmp = Float64(Float64(b - Float64(a / Float64(c / d))) / 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 <= -112000000.0) || ~((c <= 3.5e+17))) tmp = (b - (a / (c / d))) / c; else tmp = ((b * (c / d)) - a) / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -112000000.0], N[Not[LessEqual[c, 3.5e+17]], $MachinePrecision]], N[(N[(b - N[(a / N[(c / d), $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 -112000000 \lor \neg \left(c \leq 3.5 \cdot 10^{+17}\right):\\
\;\;\;\;\frac{b - \frac{a}{\frac{c}{d}}}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\
\end{array}
\end{array}
if c < -1.12e8 or 3.5e17 < c Initial program 47.7%
Taylor expanded in c around inf 78.9%
mul-1-neg78.9%
unsub-neg78.9%
associate-/l*84.0%
Simplified84.0%
clear-num84.0%
un-div-inv84.1%
Applied egg-rr84.1%
if -1.12e8 < c < 3.5e17Initial program 72.2%
Taylor expanded in d around -inf 84.1%
mul-1-neg84.1%
distribute-neg-frac284.1%
mul-1-neg84.1%
unsub-neg84.1%
associate-/l*84.2%
Simplified84.2%
Final simplification84.1%
(FPCore (a b c d) :precision binary64 (if (or (<= c -135000.0) (not (<= c 2.5e+16))) (/ (- b (/ a (/ c d))) c) (/ (- (* c (/ b d)) a) d)))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -135000.0) || !(c <= 2.5e+16)) {
tmp = (b - (a / (c / d))) / c;
} else {
tmp = ((c * (b / d)) - a) / d;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if ((c <= (-135000.0d0)) .or. (.not. (c <= 2.5d+16))) then
tmp = (b - (a / (c / d))) / c
else
tmp = ((c * (b / d)) - a) / d
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -135000.0) || !(c <= 2.5e+16)) {
tmp = (b - (a / (c / d))) / c;
} else {
tmp = ((c * (b / d)) - a) / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -135000.0) or not (c <= 2.5e+16): tmp = (b - (a / (c / d))) / c else: tmp = ((c * (b / d)) - a) / d return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -135000.0) || !(c <= 2.5e+16)) tmp = Float64(Float64(b - Float64(a / Float64(c / d))) / c); 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 ((c <= -135000.0) || ~((c <= 2.5e+16))) tmp = (b - (a / (c / d))) / c; else tmp = ((c * (b / d)) - a) / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -135000.0], N[Not[LessEqual[c, 2.5e+16]], $MachinePrecision]], N[(N[(b - N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], N[(N[(N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -135000 \lor \neg \left(c \leq 2.5 \cdot 10^{+16}\right):\\
\;\;\;\;\frac{b - \frac{a}{\frac{c}{d}}}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\
\end{array}
\end{array}
if c < -135000 or 2.5e16 < c Initial program 47.7%
Taylor expanded in c around inf 78.9%
mul-1-neg78.9%
unsub-neg78.9%
associate-/l*84.0%
Simplified84.0%
clear-num84.0%
un-div-inv84.1%
Applied egg-rr84.1%
if -135000 < c < 2.5e16Initial program 72.2%
Taylor expanded in d around -inf 84.1%
mul-1-neg84.1%
distribute-neg-frac284.1%
mul-1-neg84.1%
unsub-neg84.1%
associate-/l*84.2%
Simplified84.2%
Taylor expanded in d around inf 84.1%
neg-mul-184.1%
associate-*r/84.2%
+-commutative84.2%
unsub-neg84.2%
associate-*r/84.1%
*-commutative84.1%
associate-/l*82.6%
Simplified82.6%
Final simplification83.4%
(FPCore (a b c d) :precision binary64 (if (or (<= c -9e-73) (not (<= c 6500.0))) (/ (- b (/ a (/ c d))) c) (/ a (- d))))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -9e-73) || !(c <= 6500.0)) {
tmp = (b - (a / (c / d))) / 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-73)) .or. (.not. (c <= 6500.0d0))) then
tmp = (b - (a / (c / d))) / 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-73) || !(c <= 6500.0)) {
tmp = (b - (a / (c / d))) / c;
} else {
tmp = a / -d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -9e-73) or not (c <= 6500.0): tmp = (b - (a / (c / d))) / c else: tmp = a / -d return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -9e-73) || !(c <= 6500.0)) tmp = Float64(Float64(b - Float64(a / Float64(c / d))) / c); else tmp = Float64(a / Float64(-d)); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((c <= -9e-73) || ~((c <= 6500.0))) tmp = (b - (a / (c / d))) / c; else tmp = a / -d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -9e-73], N[Not[LessEqual[c, 6500.0]], $MachinePrecision]], N[(N[(b - N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], N[(a / (-d)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -9 \cdot 10^{-73} \lor \neg \left(c \leq 6500\right):\\
\;\;\;\;\frac{b - \frac{a}{\frac{c}{d}}}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{-d}\\
\end{array}
\end{array}
if c < -9e-73 or 6500 < c Initial program 51.7%
Taylor expanded in c around inf 75.8%
mul-1-neg75.8%
unsub-neg75.8%
associate-/l*80.5%
Simplified80.5%
clear-num80.4%
un-div-inv80.5%
Applied egg-rr80.5%
if -9e-73 < c < 6500Initial program 70.2%
Taylor expanded in c around 0 72.2%
associate-*r/72.2%
neg-mul-172.2%
Simplified72.2%
Final simplification76.9%
(FPCore (a b c d) :precision binary64 (if (or (<= c -1.35e-72) (not (<= c 2600.0))) (/ (- b (* a (/ d c))) c) (/ a (- d))))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -1.35e-72) || !(c <= 2600.0)) {
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 <= (-1.35d-72)) .or. (.not. (c <= 2600.0d0))) 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 <= -1.35e-72) || !(c <= 2600.0)) {
tmp = (b - (a * (d / c))) / c;
} else {
tmp = a / -d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -1.35e-72) or not (c <= 2600.0): tmp = (b - (a * (d / c))) / c else: tmp = a / -d return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -1.35e-72) || !(c <= 2600.0)) tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / 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.35e-72) || ~((c <= 2600.0))) tmp = (b - (a * (d / c))) / c; else tmp = a / -d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -1.35e-72], N[Not[LessEqual[c, 2600.0]], $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 -1.35 \cdot 10^{-72} \lor \neg \left(c \leq 2600\right):\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{-d}\\
\end{array}
\end{array}
if c < -1.35e-72 or 2600 < c Initial program 51.7%
Taylor expanded in c around inf 75.8%
mul-1-neg75.8%
unsub-neg75.8%
associate-/l*80.5%
Simplified80.5%
if -1.35e-72 < c < 2600Initial program 70.2%
Taylor expanded in c around 0 72.2%
associate-*r/72.2%
neg-mul-172.2%
Simplified72.2%
Final simplification76.9%
(FPCore (a b c d) :precision binary64 (if (or (<= c -1.06e-94) (not (<= c 480000.0))) (/ b c) (/ a (- d))))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -1.06e-94) || !(c <= 480000.0)) {
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.06d-94)) .or. (.not. (c <= 480000.0d0))) 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.06e-94) || !(c <= 480000.0)) {
tmp = b / c;
} else {
tmp = a / -d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -1.06e-94) or not (c <= 480000.0): tmp = b / c else: tmp = a / -d return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -1.06e-94) || !(c <= 480000.0)) 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.06e-94) || ~((c <= 480000.0))) tmp = b / c; else tmp = a / -d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -1.06e-94], N[Not[LessEqual[c, 480000.0]], $MachinePrecision]], N[(b / c), $MachinePrecision], N[(a / (-d)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.06 \cdot 10^{-94} \lor \neg \left(c \leq 480000\right):\\
\;\;\;\;\frac{b}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{-d}\\
\end{array}
\end{array}
if c < -1.06e-94 or 4.8e5 < c Initial program 52.6%
Taylor expanded in c around inf 67.3%
if -1.06e-94 < c < 4.8e5Initial program 69.7%
Taylor expanded in c around 0 74.5%
associate-*r/74.5%
neg-mul-174.5%
Simplified74.5%
Final simplification70.3%
(FPCore (a b c d) :precision binary64 (if (or (<= d -8.8e+178) (not (<= d 4.7e+120))) (/ a d) (/ b c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -8.8e+178) || !(d <= 4.7e+120)) {
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.8d+178)) .or. (.not. (d <= 4.7d+120))) 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.8e+178) || !(d <= 4.7e+120)) {
tmp = a / d;
} else {
tmp = b / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -8.8e+178) or not (d <= 4.7e+120): tmp = a / d else: tmp = b / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -8.8e+178) || !(d <= 4.7e+120)) 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.8e+178) || ~((d <= 4.7e+120))) tmp = a / d; else tmp = b / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -8.8e+178], N[Not[LessEqual[d, 4.7e+120]], $MachinePrecision]], N[(a / d), $MachinePrecision], N[(b / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -8.8 \cdot 10^{+178} \lor \neg \left(d \leq 4.7 \cdot 10^{+120}\right):\\
\;\;\;\;\frac{a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if d < -8.79999999999999989e178 or 4.69999999999999993e120 < d Initial program 43.2%
Taylor expanded in c around 0 87.3%
associate-*r/87.3%
neg-mul-187.3%
Simplified87.3%
neg-sub087.3%
sub-neg87.3%
add-sqr-sqrt46.0%
sqrt-unprod52.3%
sqr-neg52.3%
sqrt-unprod14.9%
add-sqr-sqrt43.9%
Applied egg-rr43.9%
+-lft-identity43.9%
Simplified43.9%
if -8.79999999999999989e178 < d < 4.69999999999999993e120Initial program 65.6%
Taylor expanded in c around inf 55.3%
Final simplification52.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 59.6%
Taylor expanded in c around 0 42.5%
associate-*r/42.5%
neg-mul-142.5%
Simplified42.5%
neg-sub042.5%
sub-neg42.5%
add-sqr-sqrt20.8%
sqrt-unprod23.1%
sqr-neg23.1%
sqrt-unprod5.9%
add-sqr-sqrt14.4%
Applied egg-rr14.4%
+-lft-identity14.4%
Simplified14.4%
(FPCore (a b c d) :precision binary64 (if (< (fabs d) (fabs c)) (/ (- b (* a (/ d c))) (+ c (* d (/ d c)))) (/ (+ (- a) (* b (/ c d))) (+ d (* c (/ c d))))))
double code(double a, double b, double c, double d) {
double tmp;
if (fabs(d) < fabs(c)) {
tmp = (b - (a * (d / c))) / (c + (d * (d / c)));
} else {
tmp = (-a + (b * (c / d))) / (d + (c * (c / d)));
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (abs(d) < abs(c)) then
tmp = (b - (a * (d / c))) / (c + (d * (d / c)))
else
tmp = (-a + (b * (c / d))) / (d + (c * (c / d)))
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (Math.abs(d) < Math.abs(c)) {
tmp = (b - (a * (d / c))) / (c + (d * (d / c)));
} else {
tmp = (-a + (b * (c / d))) / (d + (c * (c / d)));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if math.fabs(d) < math.fabs(c): tmp = (b - (a * (d / c))) / (c + (d * (d / c))) else: tmp = (-a + (b * (c / d))) / (d + (c * (c / d))) return tmp
function code(a, b, c, d) tmp = 0.0 if (abs(d) < abs(c)) tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / Float64(c + Float64(d * Float64(d / c)))); else tmp = Float64(Float64(Float64(-a) + Float64(b * Float64(c / d))) / Float64(d + Float64(c * Float64(c / d)))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (abs(d) < abs(c)) tmp = (b - (a * (d / c))) / (c + (d * (d / c))); else tmp = (-a + (b * (c / d))) / (d + (c * (c / d))); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Less[N[Abs[d], $MachinePrecision], N[Abs[c], $MachinePrecision]], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(c + N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[((-a) + N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(d + N[(c * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left|d\right| < \left|c\right|:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c + d \cdot \frac{d}{c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-a\right) + b \cdot \frac{c}{d}}{d + c \cdot \frac{c}{d}}\\
\end{array}
\end{array}
herbie shell --seed 2024110
(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))))