
(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 (pow (hypot d c) 2.0)) (t_1 (- (* c (/ b t_0)) (* a (/ d t_0)))))
(if (<= c -2e+109)
(/ (- b (* a (/ d c))) c)
(if (<= c -1.4e-91)
t_1
(if (<= c 4.8e-23)
(/ (- (/ (* c b) d) a) d)
(if (<= c 7.2e+96) t_1 (/ (- b (* d (/ a c))) c)))))))
double code(double a, double b, double c, double d) {
double t_0 = pow(hypot(d, c), 2.0);
double t_1 = (c * (b / t_0)) - (a * (d / t_0));
double tmp;
if (c <= -2e+109) {
tmp = (b - (a * (d / c))) / c;
} else if (c <= -1.4e-91) {
tmp = t_1;
} else if (c <= 4.8e-23) {
tmp = (((c * b) / d) - a) / d;
} else if (c <= 7.2e+96) {
tmp = t_1;
} else {
tmp = (b - (d * (a / c))) / c;
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = Math.pow(Math.hypot(d, c), 2.0);
double t_1 = (c * (b / t_0)) - (a * (d / t_0));
double tmp;
if (c <= -2e+109) {
tmp = (b - (a * (d / c))) / c;
} else if (c <= -1.4e-91) {
tmp = t_1;
} else if (c <= 4.8e-23) {
tmp = (((c * b) / d) - a) / d;
} else if (c <= 7.2e+96) {
tmp = t_1;
} else {
tmp = (b - (d * (a / c))) / c;
}
return tmp;
}
def code(a, b, c, d): t_0 = math.pow(math.hypot(d, c), 2.0) t_1 = (c * (b / t_0)) - (a * (d / t_0)) tmp = 0 if c <= -2e+109: tmp = (b - (a * (d / c))) / c elif c <= -1.4e-91: tmp = t_1 elif c <= 4.8e-23: tmp = (((c * b) / d) - a) / d elif c <= 7.2e+96: tmp = t_1 else: tmp = (b - (d * (a / c))) / c return tmp
function code(a, b, c, d) t_0 = hypot(d, c) ^ 2.0 t_1 = Float64(Float64(c * Float64(b / t_0)) - Float64(a * Float64(d / t_0))) tmp = 0.0 if (c <= -2e+109) tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c); elseif (c <= -1.4e-91) tmp = t_1; elseif (c <= 4.8e-23) tmp = Float64(Float64(Float64(Float64(c * b) / d) - a) / d); elseif (c <= 7.2e+96) tmp = t_1; else tmp = Float64(Float64(b - Float64(d * Float64(a / c))) / c); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = hypot(d, c) ^ 2.0; t_1 = (c * (b / t_0)) - (a * (d / t_0)); tmp = 0.0; if (c <= -2e+109) tmp = (b - (a * (d / c))) / c; elseif (c <= -1.4e-91) tmp = t_1; elseif (c <= 4.8e-23) tmp = (((c * b) / d) - a) / d; elseif (c <= 7.2e+96) tmp = t_1; else tmp = (b - (d * (a / c))) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[Power[N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(N[(c * N[(b / t$95$0), $MachinePrecision]), $MachinePrecision] - N[(a * N[(d / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -2e+109], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[c, -1.4e-91], t$95$1, If[LessEqual[c, 4.8e-23], N[(N[(N[(N[(c * b), $MachinePrecision] / d), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 7.2e+96], t$95$1, N[(N[(b - N[(d * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\mathsf{hypot}\left(d, c\right)\right)}^{2}\\
t_1 := c \cdot \frac{b}{t\_0} - a \cdot \frac{d}{t\_0}\\
\mathbf{if}\;c \leq -2 \cdot 10^{+109}:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\
\mathbf{elif}\;c \leq -1.4 \cdot 10^{-91}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;c \leq 4.8 \cdot 10^{-23}:\\
\;\;\;\;\frac{\frac{c \cdot b}{d} - a}{d}\\
\mathbf{elif}\;c \leq 7.2 \cdot 10^{+96}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\
\end{array}
\end{array}
if c < -1.99999999999999996e109Initial program 41.1%
Taylor expanded in c around inf 80.7%
mul-1-neg80.7%
unsub-neg80.7%
associate-/l*87.3%
Simplified87.3%
if -1.99999999999999996e109 < c < -1.4e-91 or 4.79999999999999993e-23 < c < 7.20000000000000026e96Initial program 75.2%
Taylor expanded in b around 0 75.2%
+-commutative75.2%
mul-1-neg75.2%
unsub-neg75.2%
Simplified83.2%
if -1.4e-91 < c < 4.79999999999999993e-23Initial program 63.4%
Taylor expanded in c around 0 79.7%
+-commutative79.7%
mul-1-neg79.7%
unsub-neg79.7%
unpow279.7%
associate-/r*89.0%
div-sub90.9%
associate-/l*90.1%
Simplified90.1%
Taylor expanded in b around 0 90.9%
if 7.20000000000000026e96 < c Initial program 30.8%
Taylor expanded in c around inf 81.4%
remove-double-neg81.4%
mul-1-neg81.4%
neg-mul-181.4%
distribute-lft-in81.4%
distribute-lft-in81.4%
neg-mul-181.4%
mul-1-neg81.4%
remove-double-neg81.4%
associate-*r/81.4%
associate-*r*81.4%
neg-mul-181.4%
Simplified81.4%
Taylor expanded in a around 0 81.4%
mul-1-neg81.4%
*-commutative81.4%
associate-*r/91.7%
distribute-rgt-neg-in91.7%
Simplified91.7%
Final simplification88.4%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- b (* a (/ d c))) c)))
(if (<= c -1.75e+64)
t_0
(if (<= c -6.9e-74)
(/ (* c b) (+ (* c c) (* d d)))
(if (<= c -1.05e-84)
t_0
(if (<= c 3.4e-14)
(/ (- (/ (* c b) d) a) d)
(/ (- b (* d (/ a c))) c)))))))
double code(double a, double b, double c, double d) {
double t_0 = (b - (a * (d / c))) / c;
double tmp;
if (c <= -1.75e+64) {
tmp = t_0;
} else if (c <= -6.9e-74) {
tmp = (c * b) / ((c * c) + (d * d));
} else if (c <= -1.05e-84) {
tmp = t_0;
} else if (c <= 3.4e-14) {
tmp = (((c * b) / d) - a) / d;
} else {
tmp = (b - (d * (a / c))) / c;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: tmp
t_0 = (b - (a * (d / c))) / c
if (c <= (-1.75d+64)) then
tmp = t_0
else if (c <= (-6.9d-74)) then
tmp = (c * b) / ((c * c) + (d * d))
else if (c <= (-1.05d-84)) then
tmp = t_0
else if (c <= 3.4d-14) then
tmp = (((c * b) / d) - a) / d
else
tmp = (b - (d * (a / c))) / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = (b - (a * (d / c))) / c;
double tmp;
if (c <= -1.75e+64) {
tmp = t_0;
} else if (c <= -6.9e-74) {
tmp = (c * b) / ((c * c) + (d * d));
} else if (c <= -1.05e-84) {
tmp = t_0;
} else if (c <= 3.4e-14) {
tmp = (((c * b) / d) - a) / d;
} else {
tmp = (b - (d * (a / c))) / c;
}
return tmp;
}
def code(a, b, c, d): t_0 = (b - (a * (d / c))) / c tmp = 0 if c <= -1.75e+64: tmp = t_0 elif c <= -6.9e-74: tmp = (c * b) / ((c * c) + (d * d)) elif c <= -1.05e-84: tmp = t_0 elif c <= 3.4e-14: tmp = (((c * b) / d) - a) / d else: tmp = (b - (d * (a / c))) / c return tmp
function code(a, b, c, d) t_0 = Float64(Float64(b - Float64(a * Float64(d / c))) / c) tmp = 0.0 if (c <= -1.75e+64) tmp = t_0; elseif (c <= -6.9e-74) tmp = Float64(Float64(c * b) / Float64(Float64(c * c) + Float64(d * d))); elseif (c <= -1.05e-84) tmp = t_0; elseif (c <= 3.4e-14) tmp = Float64(Float64(Float64(Float64(c * b) / d) - a) / d); else tmp = Float64(Float64(b - Float64(d * Float64(a / c))) / c); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (b - (a * (d / c))) / c; tmp = 0.0; if (c <= -1.75e+64) tmp = t_0; elseif (c <= -6.9e-74) tmp = (c * b) / ((c * c) + (d * d)); elseif (c <= -1.05e-84) tmp = t_0; elseif (c <= 3.4e-14) tmp = (((c * b) / d) - a) / d; else tmp = (b - (d * (a / c))) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]}, If[LessEqual[c, -1.75e+64], t$95$0, If[LessEqual[c, -6.9e-74], N[(N[(c * b), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -1.05e-84], t$95$0, If[LessEqual[c, 3.4e-14], N[(N[(N[(N[(c * b), $MachinePrecision] / d), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], N[(N[(b - N[(d * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b - a \cdot \frac{d}{c}}{c}\\
\mathbf{if}\;c \leq -1.75 \cdot 10^{+64}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq -6.9 \cdot 10^{-74}:\\
\;\;\;\;\frac{c \cdot b}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;c \leq -1.05 \cdot 10^{-84}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq 3.4 \cdot 10^{-14}:\\
\;\;\;\;\frac{\frac{c \cdot b}{d} - a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\
\end{array}
\end{array}
if c < -1.7499999999999999e64 or -6.89999999999999981e-74 < c < -1.04999999999999999e-84Initial program 46.2%
Taylor expanded in c around inf 74.7%
mul-1-neg74.7%
unsub-neg74.7%
associate-/l*81.7%
Simplified81.7%
if -1.7499999999999999e64 < c < -6.89999999999999981e-74Initial program 88.2%
Taylor expanded in b around inf 77.8%
*-commutative77.8%
Simplified77.8%
if -1.04999999999999999e-84 < c < 3.40000000000000003e-14Initial program 63.8%
Taylor expanded in c around 0 79.8%
+-commutative79.8%
mul-1-neg79.8%
unsub-neg79.8%
unpow279.8%
associate-/r*89.0%
div-sub90.9%
associate-/l*90.1%
Simplified90.1%
Taylor expanded in b around 0 90.9%
if 3.40000000000000003e-14 < c Initial program 45.1%
Taylor expanded in c around inf 72.5%
remove-double-neg72.5%
mul-1-neg72.5%
neg-mul-172.5%
distribute-lft-in72.5%
distribute-lft-in72.5%
neg-mul-172.5%
mul-1-neg72.5%
remove-double-neg72.5%
associate-*r/72.5%
associate-*r*72.5%
neg-mul-172.5%
Simplified72.5%
Taylor expanded in a around 0 72.5%
mul-1-neg72.5%
*-commutative72.5%
associate-*r/81.2%
distribute-rgt-neg-in81.2%
Simplified81.2%
Final simplification84.9%
(FPCore (a b c d)
:precision binary64
(if (<= c -1.2e+78)
(/ (- b (* a (/ d c))) c)
(if (<= c -6e-119)
(/ (- (* c b) (* a d)) (+ (* c c) (* d d)))
(if (<= c 1.8e-19) (/ (- (/ (* c b) d) a) d) (/ (- b (* d (/ a c))) c)))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -1.2e+78) {
tmp = (b - (a * (d / c))) / c;
} else if (c <= -6e-119) {
tmp = ((c * b) - (a * d)) / ((c * c) + (d * d));
} else if (c <= 1.8e-19) {
tmp = (((c * b) / d) - a) / d;
} else {
tmp = (b - (d * (a / c))) / c;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (c <= (-1.2d+78)) then
tmp = (b - (a * (d / c))) / c
else if (c <= (-6d-119)) then
tmp = ((c * b) - (a * d)) / ((c * c) + (d * d))
else if (c <= 1.8d-19) then
tmp = (((c * b) / d) - a) / d
else
tmp = (b - (d * (a / c))) / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -1.2e+78) {
tmp = (b - (a * (d / c))) / c;
} else if (c <= -6e-119) {
tmp = ((c * b) - (a * d)) / ((c * c) + (d * d));
} else if (c <= 1.8e-19) {
tmp = (((c * b) / d) - a) / d;
} else {
tmp = (b - (d * (a / c))) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -1.2e+78: tmp = (b - (a * (d / c))) / c elif c <= -6e-119: tmp = ((c * b) - (a * d)) / ((c * c) + (d * d)) elif c <= 1.8e-19: tmp = (((c * b) / d) - a) / d else: tmp = (b - (d * (a / c))) / c return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -1.2e+78) tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c); elseif (c <= -6e-119) tmp = Float64(Float64(Float64(c * b) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d))); elseif (c <= 1.8e-19) tmp = Float64(Float64(Float64(Float64(c * b) / d) - a) / d); else tmp = Float64(Float64(b - Float64(d * Float64(a / c))) / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -1.2e+78) tmp = (b - (a * (d / c))) / c; elseif (c <= -6e-119) tmp = ((c * b) - (a * d)) / ((c * c) + (d * d)); elseif (c <= 1.8e-19) tmp = (((c * b) / d) - a) / d; else tmp = (b - (d * (a / c))) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -1.2e+78], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[c, -6e-119], 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, 1.8e-19], N[(N[(N[(N[(c * b), $MachinePrecision] / d), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], N[(N[(b - N[(d * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.2 \cdot 10^{+78}:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\
\mathbf{elif}\;c \leq -6 \cdot 10^{-119}:\\
\;\;\;\;\frac{c \cdot b - a \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;c \leq 1.8 \cdot 10^{-19}:\\
\;\;\;\;\frac{\frac{c \cdot b}{d} - a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\
\end{array}
\end{array}
if c < -1.1999999999999999e78Initial program 39.9%
Taylor expanded in c around inf 73.2%
mul-1-neg73.2%
unsub-neg73.2%
associate-/l*78.7%
Simplified78.7%
if -1.1999999999999999e78 < c < -6.0000000000000004e-119Initial program 88.7%
if -6.0000000000000004e-119 < c < 1.8000000000000001e-19Initial program 62.3%
Taylor expanded in c around 0 79.0%
+-commutative79.0%
mul-1-neg79.0%
unsub-neg79.0%
unpow279.0%
associate-/r*88.6%
div-sub90.6%
associate-/l*89.7%
Simplified89.7%
Taylor expanded in b around 0 90.6%
if 1.8000000000000001e-19 < c Initial program 45.1%
Taylor expanded in c around inf 72.5%
remove-double-neg72.5%
mul-1-neg72.5%
neg-mul-172.5%
distribute-lft-in72.5%
distribute-lft-in72.5%
neg-mul-172.5%
mul-1-neg72.5%
remove-double-neg72.5%
associate-*r/72.5%
associate-*r*72.5%
neg-mul-172.5%
Simplified72.5%
Taylor expanded in a around 0 72.5%
mul-1-neg72.5%
*-commutative72.5%
associate-*r/81.2%
distribute-rgt-neg-in81.2%
Simplified81.2%
Final simplification85.8%
(FPCore (a b c d)
:precision binary64
(if (<= c -6.5e-34)
(/ b c)
(if (<= c 8.6e-12)
(/ a (- d))
(if (<= c 3.7e+17) (* d (* (/ a c) (/ -1.0 c))) (/ b c)))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -6.5e-34) {
tmp = b / c;
} else if (c <= 8.6e-12) {
tmp = a / -d;
} else if (c <= 3.7e+17) {
tmp = d * ((a / c) * (-1.0 / c));
} else {
tmp = b / c;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (c <= (-6.5d-34)) then
tmp = b / c
else if (c <= 8.6d-12) then
tmp = a / -d
else if (c <= 3.7d+17) then
tmp = d * ((a / c) * ((-1.0d0) / c))
else
tmp = b / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -6.5e-34) {
tmp = b / c;
} else if (c <= 8.6e-12) {
tmp = a / -d;
} else if (c <= 3.7e+17) {
tmp = d * ((a / c) * (-1.0 / c));
} else {
tmp = b / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -6.5e-34: tmp = b / c elif c <= 8.6e-12: tmp = a / -d elif c <= 3.7e+17: tmp = d * ((a / c) * (-1.0 / c)) else: tmp = b / c return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -6.5e-34) tmp = Float64(b / c); elseif (c <= 8.6e-12) tmp = Float64(a / Float64(-d)); elseif (c <= 3.7e+17) tmp = Float64(d * Float64(Float64(a / c) * Float64(-1.0 / c))); else tmp = Float64(b / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -6.5e-34) tmp = b / c; elseif (c <= 8.6e-12) tmp = a / -d; elseif (c <= 3.7e+17) tmp = d * ((a / c) * (-1.0 / c)); else tmp = b / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -6.5e-34], N[(b / c), $MachinePrecision], If[LessEqual[c, 8.6e-12], N[(a / (-d)), $MachinePrecision], If[LessEqual[c, 3.7e+17], N[(d * N[(N[(a / c), $MachinePrecision] * N[(-1.0 / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(b / c), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -6.5 \cdot 10^{-34}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{elif}\;c \leq 8.6 \cdot 10^{-12}:\\
\;\;\;\;\frac{a}{-d}\\
\mathbf{elif}\;c \leq 3.7 \cdot 10^{+17}:\\
\;\;\;\;d \cdot \left(\frac{a}{c} \cdot \frac{-1}{c}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if c < -6.49999999999999985e-34 or 3.7e17 < c Initial program 50.6%
Taylor expanded in c around inf 69.3%
if -6.49999999999999985e-34 < c < 8.59999999999999971e-12Initial program 64.8%
Taylor expanded in c around 0 64.8%
associate-*r/64.8%
neg-mul-164.8%
Simplified64.8%
if 8.59999999999999971e-12 < c < 3.7e17Initial program 86.0%
Taylor expanded in c around inf 85.6%
remove-double-neg85.6%
mul-1-neg85.6%
neg-mul-185.6%
distribute-lft-in85.6%
distribute-lft-in85.6%
neg-mul-185.6%
mul-1-neg85.6%
remove-double-neg85.6%
associate-*r/85.6%
associate-*r*85.6%
neg-mul-185.6%
Simplified85.6%
Taylor expanded in a around 0 85.6%
mul-1-neg85.6%
*-commutative85.6%
associate-*r/85.6%
distribute-rgt-neg-in85.6%
Simplified85.6%
Taylor expanded in b around 0 76.6%
associate-*l/76.8%
associate-*l*76.8%
*-commutative76.8%
associate-*r/76.8%
mul-1-neg76.8%
Simplified76.8%
neg-mul-176.8%
*-commutative76.8%
pow276.8%
times-frac76.6%
Applied egg-rr76.6%
Final simplification67.4%
(FPCore (a b c d) :precision binary64 (if (or (<= d -2.02e+18) (not (<= d 7e+61))) (/ a (- d)) (/ (- b (* a (/ d c))) c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -2.02e+18) || !(d <= 7e+61)) {
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 <= (-2.02d+18)) .or. (.not. (d <= 7d+61))) 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 <= -2.02e+18) || !(d <= 7e+61)) {
tmp = a / -d;
} else {
tmp = (b - (a * (d / c))) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -2.02e+18) or not (d <= 7e+61): tmp = a / -d else: tmp = (b - (a * (d / c))) / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -2.02e+18) || !(d <= 7e+61)) 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 <= -2.02e+18) || ~((d <= 7e+61))) tmp = a / -d; else tmp = (b - (a * (d / c))) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -2.02e+18], N[Not[LessEqual[d, 7e+61]], $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 -2.02 \cdot 10^{+18} \lor \neg \left(d \leq 7 \cdot 10^{+61}\right):\\
\;\;\;\;\frac{a}{-d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\
\end{array}
\end{array}
if d < -2.02e18 or 7.00000000000000036e61 < d Initial program 35.7%
Taylor expanded in c around 0 69.6%
associate-*r/69.6%
neg-mul-169.6%
Simplified69.6%
if -2.02e18 < d < 7.00000000000000036e61Initial program 74.9%
Taylor expanded in c around inf 75.8%
mul-1-neg75.8%
unsub-neg75.8%
associate-/l*76.5%
Simplified76.5%
Final simplification73.6%
(FPCore (a b c d) :precision binary64 (if (or (<= c -4e-43) (not (<= c 1.04e-13))) (/ (- b (* a (/ d c))) c) (/ (- (* b (/ c d)) a) d)))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -4e-43) || !(c <= 1.04e-13)) {
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 <= (-4d-43)) .or. (.not. (c <= 1.04d-13))) 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 <= -4e-43) || !(c <= 1.04e-13)) {
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 <= -4e-43) or not (c <= 1.04e-13): 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 <= -4e-43) || !(c <= 1.04e-13)) 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 <= -4e-43) || ~((c <= 1.04e-13))) 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, -4e-43], N[Not[LessEqual[c, 1.04e-13]], $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 -4 \cdot 10^{-43} \lor \neg \left(c \leq 1.04 \cdot 10^{-13}\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 < -4.00000000000000031e-43 or 1.03999999999999999e-13 < c Initial program 52.4%
Taylor expanded in c around inf 72.3%
mul-1-neg72.3%
unsub-neg72.3%
associate-/l*77.3%
Simplified77.3%
if -4.00000000000000031e-43 < c < 1.03999999999999999e-13Initial program 65.2%
Taylor expanded in c around 0 77.4%
+-commutative77.4%
mul-1-neg77.4%
unsub-neg77.4%
unpow277.4%
associate-/r*85.8%
div-sub88.4%
associate-/l*87.6%
Simplified87.6%
Final simplification81.9%
(FPCore (a b c d) :precision binary64 (if (or (<= c -2.8e-42) (not (<= c 8e-12))) (/ (- b (* a (/ d c))) c) (/ (- (/ (* c b) d) a) d)))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -2.8e-42) || !(c <= 8e-12)) {
tmp = (b - (a * (d / c))) / 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 <= (-2.8d-42)) .or. (.not. (c <= 8d-12))) then
tmp = (b - (a * (d / c))) / 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 <= -2.8e-42) || !(c <= 8e-12)) {
tmp = (b - (a * (d / c))) / c;
} else {
tmp = (((c * b) / d) - a) / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -2.8e-42) or not (c <= 8e-12): tmp = (b - (a * (d / c))) / c else: tmp = (((c * b) / d) - a) / d return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -2.8e-42) || !(c <= 8e-12)) tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c); else tmp = Float64(Float64(Float64(Float64(c * b) / d) - a) / d); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((c <= -2.8e-42) || ~((c <= 8e-12))) tmp = (b - (a * (d / c))) / c; else tmp = (((c * b) / d) - a) / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -2.8e-42], N[Not[LessEqual[c, 8e-12]], $MachinePrecision]], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], N[(N[(N[(N[(c * b), $MachinePrecision] / d), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -2.8 \cdot 10^{-42} \lor \neg \left(c \leq 8 \cdot 10^{-12}\right):\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{c \cdot b}{d} - a}{d}\\
\end{array}
\end{array}
if c < -2.79999999999999998e-42 or 7.99999999999999984e-12 < c Initial program 52.4%
Taylor expanded in c around inf 72.3%
mul-1-neg72.3%
unsub-neg72.3%
associate-/l*77.3%
Simplified77.3%
if -2.79999999999999998e-42 < c < 7.99999999999999984e-12Initial program 65.2%
Taylor expanded in c around 0 77.4%
+-commutative77.4%
mul-1-neg77.4%
unsub-neg77.4%
unpow277.4%
associate-/r*85.8%
div-sub88.4%
associate-/l*87.6%
Simplified87.6%
Taylor expanded in b around 0 88.4%
Final simplification82.3%
(FPCore (a b c d) :precision binary64 (if (<= c -3.4e-43) (/ (- b (* a (/ d c))) c) (if (<= c 5.3e-21) (/ (- (/ (* c b) d) a) d) (/ (- b (* d (/ a c))) c))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -3.4e-43) {
tmp = (b - (a * (d / c))) / c;
} else if (c <= 5.3e-21) {
tmp = (((c * b) / d) - a) / d;
} else {
tmp = (b - (d * (a / c))) / c;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (c <= (-3.4d-43)) then
tmp = (b - (a * (d / c))) / c
else if (c <= 5.3d-21) then
tmp = (((c * b) / d) - a) / d
else
tmp = (b - (d * (a / c))) / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -3.4e-43) {
tmp = (b - (a * (d / c))) / c;
} else if (c <= 5.3e-21) {
tmp = (((c * b) / d) - a) / d;
} else {
tmp = (b - (d * (a / c))) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -3.4e-43: tmp = (b - (a * (d / c))) / c elif c <= 5.3e-21: tmp = (((c * b) / d) - a) / d else: tmp = (b - (d * (a / c))) / c return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -3.4e-43) tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c); elseif (c <= 5.3e-21) tmp = Float64(Float64(Float64(Float64(c * b) / d) - a) / d); else tmp = Float64(Float64(b - Float64(d * Float64(a / c))) / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -3.4e-43) tmp = (b - (a * (d / c))) / c; elseif (c <= 5.3e-21) tmp = (((c * b) / d) - a) / d; else tmp = (b - (d * (a / c))) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -3.4e-43], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[c, 5.3e-21], N[(N[(N[(N[(c * b), $MachinePrecision] / d), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], N[(N[(b - N[(d * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -3.4 \cdot 10^{-43}:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\
\mathbf{elif}\;c \leq 5.3 \cdot 10^{-21}:\\
\;\;\;\;\frac{\frac{c \cdot b}{d} - a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\
\end{array}
\end{array}
if c < -3.4000000000000001e-43Initial program 61.3%
Taylor expanded in c around inf 72.0%
mul-1-neg72.0%
unsub-neg72.0%
associate-/l*75.4%
Simplified75.4%
if -3.4000000000000001e-43 < c < 5.2999999999999999e-21Initial program 65.2%
Taylor expanded in c around 0 77.4%
+-commutative77.4%
mul-1-neg77.4%
unsub-neg77.4%
unpow277.4%
associate-/r*85.8%
div-sub88.4%
associate-/l*87.6%
Simplified87.6%
Taylor expanded in b around 0 88.4%
if 5.2999999999999999e-21 < c Initial program 45.1%
Taylor expanded in c around inf 72.5%
remove-double-neg72.5%
mul-1-neg72.5%
neg-mul-172.5%
distribute-lft-in72.5%
distribute-lft-in72.5%
neg-mul-172.5%
mul-1-neg72.5%
remove-double-neg72.5%
associate-*r/72.5%
associate-*r*72.5%
neg-mul-172.5%
Simplified72.5%
Taylor expanded in a around 0 72.5%
mul-1-neg72.5%
*-commutative72.5%
associate-*r/81.2%
distribute-rgt-neg-in81.2%
Simplified81.2%
Final simplification83.0%
(FPCore (a b c d) :precision binary64 (if (or (<= c -1.45e-33) (not (<= c 2.55e+21))) (/ b c) (/ a (- d))))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -1.45e-33) || !(c <= 2.55e+21)) {
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.45d-33)) .or. (.not. (c <= 2.55d+21))) 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.45e-33) || !(c <= 2.55e+21)) {
tmp = b / c;
} else {
tmp = a / -d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -1.45e-33) or not (c <= 2.55e+21): tmp = b / c else: tmp = a / -d return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -1.45e-33) || !(c <= 2.55e+21)) 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.45e-33) || ~((c <= 2.55e+21))) tmp = b / c; else tmp = a / -d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -1.45e-33], N[Not[LessEqual[c, 2.55e+21]], $MachinePrecision]], N[(b / c), $MachinePrecision], N[(a / (-d)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.45 \cdot 10^{-33} \lor \neg \left(c \leq 2.55 \cdot 10^{+21}\right):\\
\;\;\;\;\frac{b}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{-d}\\
\end{array}
\end{array}
if c < -1.45000000000000001e-33 or 2.55e21 < c Initial program 50.6%
Taylor expanded in c around inf 69.3%
if -1.45000000000000001e-33 < c < 2.55e21Initial program 66.0%
Taylor expanded in c around 0 62.3%
associate-*r/62.3%
neg-mul-162.3%
Simplified62.3%
Final simplification65.8%
(FPCore (a b c d) :precision binary64 (if (<= d 9e+114) (/ b c) (/ a d)))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= 9e+114) {
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 <= 9d+114) 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 <= 9e+114) {
tmp = b / c;
} else {
tmp = a / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= 9e+114: tmp = b / c else: tmp = a / d return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= 9e+114) 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 <= 9e+114) tmp = b / c; else tmp = a / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, 9e+114], N[(b / c), $MachinePrecision], N[(a / d), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq 9 \cdot 10^{+114}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{d}\\
\end{array}
\end{array}
if d < 9.0000000000000001e114Initial program 63.0%
Taylor expanded in c around inf 48.6%
if 9.0000000000000001e114 < d Initial program 30.1%
Taylor expanded in b around 0 30.3%
mul-1-neg30.3%
associate-/l*36.9%
distribute-rgt-neg-in36.9%
rem-square-sqrt36.9%
unpow236.9%
unpow236.9%
hypot-undefine36.9%
unpow236.9%
unpow236.9%
hypot-undefine36.9%
unpow236.9%
distribute-frac-neg36.9%
Simplified36.9%
Taylor expanded in d around inf 80.8%
associate-*r/80.9%
*-commutative80.9%
neg-mul-180.9%
add-sqr-sqrt37.7%
sqrt-unprod41.3%
sqr-neg41.3%
sqrt-unprod14.1%
add-sqr-sqrt31.0%
Applied egg-rr31.0%
Final simplification46.1%
(FPCore (a b c d) :precision binary64 (/ a d))
double code(double a, double b, double c, double d) {
return a / d;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = a / d
end function
public static double code(double a, double b, double c, double d) {
return a / d;
}
def code(a, b, c, d): return a / d
function code(a, b, c, d) return Float64(a / d) end
function tmp = code(a, b, c, d) tmp = a / d; end
code[a_, b_, c_, d_] := N[(a / d), $MachinePrecision]
\begin{array}{l}
\\
\frac{a}{d}
\end{array}
Initial program 58.2%
Taylor expanded in b around 0 32.8%
mul-1-neg32.8%
associate-/l*37.0%
distribute-rgt-neg-in37.0%
rem-square-sqrt37.0%
unpow237.0%
unpow237.0%
hypot-undefine37.0%
unpow237.0%
unpow237.0%
hypot-undefine37.0%
unpow237.0%
distribute-frac-neg37.0%
Simplified37.0%
Taylor expanded in d around inf 41.7%
associate-*r/41.9%
*-commutative41.9%
neg-mul-141.9%
add-sqr-sqrt22.4%
sqrt-unprod21.6%
sqr-neg21.6%
sqrt-unprod3.6%
add-sqr-sqrt9.8%
Applied egg-rr9.8%
Final simplification9.8%
(FPCore (a b c d) :precision binary64 (if (< (fabs d) (fabs c)) (/ (- b (* a (/ d c))) (+ c (* d (/ d c)))) (/ (+ (- a) (* b (/ c d))) (+ d (* c (/ c d))))))
double code(double a, double b, double c, double d) {
double tmp;
if (fabs(d) < fabs(c)) {
tmp = (b - (a * (d / c))) / (c + (d * (d / c)));
} else {
tmp = (-a + (b * (c / d))) / (d + (c * (c / d)));
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (abs(d) < abs(c)) then
tmp = (b - (a * (d / c))) / (c + (d * (d / c)))
else
tmp = (-a + (b * (c / d))) / (d + (c * (c / d)))
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (Math.abs(d) < Math.abs(c)) {
tmp = (b - (a * (d / c))) / (c + (d * (d / c)));
} else {
tmp = (-a + (b * (c / d))) / (d + (c * (c / d)));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if math.fabs(d) < math.fabs(c): tmp = (b - (a * (d / c))) / (c + (d * (d / c))) else: tmp = (-a + (b * (c / d))) / (d + (c * (c / d))) return tmp
function code(a, b, c, d) tmp = 0.0 if (abs(d) < abs(c)) tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / Float64(c + Float64(d * Float64(d / c)))); else tmp = Float64(Float64(Float64(-a) + Float64(b * Float64(c / d))) / Float64(d + Float64(c * Float64(c / d)))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (abs(d) < abs(c)) tmp = (b - (a * (d / c))) / (c + (d * (d / c))); else tmp = (-a + (b * (c / d))) / (d + (c * (c / d))); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Less[N[Abs[d], $MachinePrecision], N[Abs[c], $MachinePrecision]], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(c + N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[((-a) + N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(d + N[(c * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left|d\right| < \left|c\right|:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c + d \cdot \frac{d}{c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-a\right) + b \cdot \frac{c}{d}}{d + c \cdot \frac{c}{d}}\\
\end{array}
\end{array}
herbie shell --seed 2024071
(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))))