
(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 (if (<= (/ (- (* b c) (* a d)) (+ (* c c) (* d d))) 2e+271) (* (/ 1.0 (hypot c d)) (/ (fma b c (* a (- d))) (hypot c d))) (- (/ b c) (* (/ d c) (/ a c)))))
double code(double a, double b, double c, double d) {
double tmp;
if ((((b * c) - (a * d)) / ((c * c) + (d * d))) <= 2e+271) {
tmp = (1.0 / hypot(c, d)) * (fma(b, c, (a * -d)) / hypot(c, d));
} else {
tmp = (b / c) - ((d / c) * (a / c));
}
return tmp;
}
function code(a, b, c, d) tmp = 0.0 if (Float64(Float64(Float64(b * c) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d))) <= 2e+271) tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(fma(b, c, Float64(a * Float64(-d))) / hypot(c, d))); else tmp = Float64(Float64(b / c) - Float64(Float64(d / c) * Float64(a / c))); end return tmp end
code[a_, b_, c_, d_] := If[LessEqual[N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2e+271], N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(N[(b * c + N[(a * (-d)), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b / c), $MachinePrecision] - N[(N[(d / c), $MachinePrecision] * N[(a / c), $MachinePrecision]), $MachinePrecision]), $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^{+271}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c} - \frac{d}{c} \cdot \frac{a}{c}\\
\end{array}
\end{array}
if (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 1.99999999999999991e271Initial program 80.7%
*-un-lft-identity80.7%
add-sqr-sqrt80.7%
times-frac80.7%
hypot-define80.7%
fma-neg80.7%
distribute-rgt-neg-in80.7%
hypot-define96.7%
Applied egg-rr96.7%
if 1.99999999999999991e271 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 14.8%
Taylor expanded in c around inf 52.8%
*-commutative52.8%
pow252.8%
times-frac67.3%
Applied egg-rr67.3%
Final simplification90.3%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (fma (/ c (hypot c d)) (/ b (hypot c d)) (/ a (- d)))))
(if (<= d -7.6e-22)
t_0
(if (<= d -8e-193)
(/ (- (* b c) (* a d)) (+ (* c c) (* d d)))
(if (<= d 7e-125)
(+ (/ b c) (* (/ (* a d) c) (/ -1.0 c)))
(if (<= d 1.2e+48)
(* (fma b c (* a (- d))) (/ 1.0 (pow (hypot c d) 2.0)))
t_0))))))
double code(double a, double b, double c, double d) {
double t_0 = fma((c / hypot(c, d)), (b / hypot(c, d)), (a / -d));
double tmp;
if (d <= -7.6e-22) {
tmp = t_0;
} else if (d <= -8e-193) {
tmp = ((b * c) - (a * d)) / ((c * c) + (d * d));
} else if (d <= 7e-125) {
tmp = (b / c) + (((a * d) / c) * (-1.0 / c));
} else if (d <= 1.2e+48) {
tmp = fma(b, c, (a * -d)) * (1.0 / pow(hypot(c, d), 2.0));
} else {
tmp = t_0;
}
return tmp;
}
function code(a, b, c, d) t_0 = fma(Float64(c / hypot(c, d)), Float64(b / hypot(c, d)), Float64(a / Float64(-d))) tmp = 0.0 if (d <= -7.6e-22) tmp = t_0; elseif (d <= -8e-193) tmp = Float64(Float64(Float64(b * c) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d))); elseif (d <= 7e-125) tmp = Float64(Float64(b / c) + Float64(Float64(Float64(a * d) / c) * Float64(-1.0 / c))); elseif (d <= 1.2e+48) tmp = Float64(fma(b, c, Float64(a * Float64(-d))) * Float64(1.0 / (hypot(c, d) ^ 2.0))); else tmp = t_0; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] + N[(a / (-d)), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -7.6e-22], t$95$0, If[LessEqual[d, -8e-193], N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 7e-125], N[(N[(b / c), $MachinePrecision] + N[(N[(N[(a * d), $MachinePrecision] / c), $MachinePrecision] * N[(-1.0 / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.2e+48], N[(N[(b * c + N[(a * (-d)), $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[Power[N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, \frac{a}{-d}\right)\\
\mathbf{if}\;d \leq -7.6 \cdot 10^{-22}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq -8 \cdot 10^{-193}:\\
\;\;\;\;\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;d \leq 7 \cdot 10^{-125}:\\
\;\;\;\;\frac{b}{c} + \frac{a \cdot d}{c} \cdot \frac{-1}{c}\\
\mathbf{elif}\;d \leq 1.2 \cdot 10^{+48}:\\
\;\;\;\;\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right) \cdot \frac{1}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d < -7.60000000000000046e-22 or 1.2000000000000001e48 < d Initial program 48.8%
div-sub48.8%
*-commutative48.8%
add-sqr-sqrt48.8%
times-frac51.7%
fma-neg51.7%
hypot-define51.7%
hypot-define66.2%
associate-/l*72.5%
add-sqr-sqrt72.5%
pow272.5%
hypot-define72.5%
Applied egg-rr72.5%
Taylor expanded in d around inf 89.7%
if -7.60000000000000046e-22 < d < -8.0000000000000004e-193Initial program 88.6%
if -8.0000000000000004e-193 < d < 6.99999999999999995e-125Initial program 71.5%
Taylor expanded in c around inf 87.9%
*-un-lft-identity87.9%
pow287.9%
times-frac92.7%
*-commutative92.7%
Applied egg-rr92.7%
if 6.99999999999999995e-125 < d < 1.2000000000000001e48Initial program 85.6%
div-inv85.7%
fma-neg85.7%
distribute-rgt-neg-in85.7%
add-sqr-sqrt85.7%
pow285.7%
hypot-define85.7%
Applied egg-rr85.7%
Final simplification89.6%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* b c) (* a d)) (+ (* c c) (* d d))))
(t_1 (- (/ b c) (* d (/ (/ a c) c)))))
(if (<= c -7.3e+53)
t_1
(if (<= c -1.08e-190)
t_0
(if (<= c 3.3e-105)
(- (* b (* (/ 1.0 d) (/ c d))) (/ a d))
(if (<= c 5.8e+140) t_0 t_1))))))
double code(double a, double b, double c, double d) {
double t_0 = ((b * c) - (a * d)) / ((c * c) + (d * d));
double t_1 = (b / c) - (d * ((a / c) / c));
double tmp;
if (c <= -7.3e+53) {
tmp = t_1;
} else if (c <= -1.08e-190) {
tmp = t_0;
} else if (c <= 3.3e-105) {
tmp = (b * ((1.0 / d) * (c / d))) - (a / d);
} else if (c <= 5.8e+140) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = ((b * c) - (a * d)) / ((c * c) + (d * d))
t_1 = (b / c) - (d * ((a / c) / c))
if (c <= (-7.3d+53)) then
tmp = t_1
else if (c <= (-1.08d-190)) then
tmp = t_0
else if (c <= 3.3d-105) then
tmp = (b * ((1.0d0 / d) * (c / d))) - (a / d)
else if (c <= 5.8d+140) then
tmp = t_0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = ((b * c) - (a * d)) / ((c * c) + (d * d));
double t_1 = (b / c) - (d * ((a / c) / c));
double tmp;
if (c <= -7.3e+53) {
tmp = t_1;
} else if (c <= -1.08e-190) {
tmp = t_0;
} else if (c <= 3.3e-105) {
tmp = (b * ((1.0 / d) * (c / d))) - (a / d);
} else if (c <= 5.8e+140) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(a, b, c, d): t_0 = ((b * c) - (a * d)) / ((c * c) + (d * d)) t_1 = (b / c) - (d * ((a / c) / c)) tmp = 0 if c <= -7.3e+53: tmp = t_1 elif c <= -1.08e-190: tmp = t_0 elif c <= 3.3e-105: tmp = (b * ((1.0 / d) * (c / d))) - (a / d) elif c <= 5.8e+140: tmp = t_0 else: tmp = t_1 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))) t_1 = Float64(Float64(b / c) - Float64(d * Float64(Float64(a / c) / c))) tmp = 0.0 if (c <= -7.3e+53) tmp = t_1; elseif (c <= -1.08e-190) tmp = t_0; elseif (c <= 3.3e-105) tmp = Float64(Float64(b * Float64(Float64(1.0 / d) * Float64(c / d))) - Float64(a / d)); elseif (c <= 5.8e+140) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((b * c) - (a * d)) / ((c * c) + (d * d)); t_1 = (b / c) - (d * ((a / c) / c)); tmp = 0.0; if (c <= -7.3e+53) tmp = t_1; elseif (c <= -1.08e-190) tmp = t_0; elseif (c <= 3.3e-105) tmp = (b * ((1.0 / d) * (c / d))) - (a / d); elseif (c <= 5.8e+140) tmp = t_0; else tmp = t_1; 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]}, Block[{t$95$1 = N[(N[(b / c), $MachinePrecision] - N[(d * N[(N[(a / c), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -7.3e+53], t$95$1, If[LessEqual[c, -1.08e-190], t$95$0, If[LessEqual[c, 3.3e-105], N[(N[(b * N[(N[(1.0 / d), $MachinePrecision] * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 5.8e+140], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\\
t_1 := \frac{b}{c} - d \cdot \frac{\frac{a}{c}}{c}\\
\mathbf{if}\;c \leq -7.3 \cdot 10^{+53}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;c \leq -1.08 \cdot 10^{-190}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq 3.3 \cdot 10^{-105}:\\
\;\;\;\;b \cdot \left(\frac{1}{d} \cdot \frac{c}{d}\right) - \frac{a}{d}\\
\mathbf{elif}\;c \leq 5.8 \cdot 10^{+140}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if c < -7.30000000000000016e53 or 5.7999999999999998e140 < c Initial program 39.3%
Taylor expanded in c around inf 78.6%
*-un-lft-identity78.6%
pow278.6%
times-frac78.8%
*-commutative78.8%
Applied egg-rr78.8%
associate-*l/78.8%
*-un-lft-identity78.8%
associate-/l*85.6%
Applied egg-rr85.6%
associate-/l*87.4%
Applied egg-rr87.4%
if -7.30000000000000016e53 < c < -1.08e-190 or 3.2999999999999999e-105 < c < 5.7999999999999998e140Initial program 84.5%
if -1.08e-190 < c < 3.2999999999999999e-105Initial program 74.4%
*-un-lft-identity74.4%
add-sqr-sqrt74.4%
times-frac74.4%
hypot-define74.4%
fma-neg74.4%
distribute-rgt-neg-in74.4%
hypot-define87.2%
Applied egg-rr87.2%
Taylor expanded in c around 0 88.4%
+-commutative88.4%
mul-1-neg88.4%
unsub-neg88.4%
associate-/l*91.1%
Simplified91.1%
*-un-lft-identity91.1%
unpow291.1%
times-frac94.8%
Applied egg-rr94.8%
Final simplification88.6%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ a (- d))))
(if (<= c -2.8e-82)
(/ b c)
(if (<= c 2.6e-80)
t_0
(if (<= c 5.8e+51)
(/ (* b c) (+ (* c c) (* d d)))
(if (<= c 2e+62) t_0 (/ b c)))))))
double code(double a, double b, double c, double d) {
double t_0 = a / -d;
double tmp;
if (c <= -2.8e-82) {
tmp = b / c;
} else if (c <= 2.6e-80) {
tmp = t_0;
} else if (c <= 5.8e+51) {
tmp = (b * c) / ((c * c) + (d * d));
} else if (c <= 2e+62) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = a / -d
if (c <= (-2.8d-82)) then
tmp = b / c
else if (c <= 2.6d-80) then
tmp = t_0
else if (c <= 5.8d+51) then
tmp = (b * c) / ((c * c) + (d * d))
else if (c <= 2d+62) then
tmp = t_0
else
tmp = b / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = a / -d;
double tmp;
if (c <= -2.8e-82) {
tmp = b / c;
} else if (c <= 2.6e-80) {
tmp = t_0;
} else if (c <= 5.8e+51) {
tmp = (b * c) / ((c * c) + (d * d));
} else if (c <= 2e+62) {
tmp = t_0;
} else {
tmp = b / c;
}
return tmp;
}
def code(a, b, c, d): t_0 = a / -d tmp = 0 if c <= -2.8e-82: tmp = b / c elif c <= 2.6e-80: tmp = t_0 elif c <= 5.8e+51: tmp = (b * c) / ((c * c) + (d * d)) elif c <= 2e+62: tmp = t_0 else: tmp = b / c return tmp
function code(a, b, c, d) t_0 = Float64(a / Float64(-d)) tmp = 0.0 if (c <= -2.8e-82) tmp = Float64(b / c); elseif (c <= 2.6e-80) tmp = t_0; elseif (c <= 5.8e+51) tmp = Float64(Float64(b * c) / Float64(Float64(c * c) + Float64(d * d))); elseif (c <= 2e+62) tmp = t_0; else tmp = Float64(b / c); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = a / -d; tmp = 0.0; if (c <= -2.8e-82) tmp = b / c; elseif (c <= 2.6e-80) tmp = t_0; elseif (c <= 5.8e+51) tmp = (b * c) / ((c * c) + (d * d)); elseif (c <= 2e+62) tmp = t_0; else tmp = b / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(a / (-d)), $MachinePrecision]}, If[LessEqual[c, -2.8e-82], N[(b / c), $MachinePrecision], If[LessEqual[c, 2.6e-80], t$95$0, If[LessEqual[c, 5.8e+51], N[(N[(b * c), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 2e+62], t$95$0, N[(b / c), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a}{-d}\\
\mathbf{if}\;c \leq -2.8 \cdot 10^{-82}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{elif}\;c \leq 2.6 \cdot 10^{-80}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq 5.8 \cdot 10^{+51}:\\
\;\;\;\;\frac{b \cdot c}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;c \leq 2 \cdot 10^{+62}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if c < -2.80000000000000024e-82 or 2.00000000000000007e62 < c Initial program 51.5%
Taylor expanded in c around inf 67.5%
if -2.80000000000000024e-82 < c < 2.6000000000000001e-80 or 5.7999999999999997e51 < c < 2.00000000000000007e62Initial program 77.7%
Taylor expanded in c around 0 73.6%
associate-*r/73.6%
neg-mul-173.6%
Simplified73.6%
if 2.6000000000000001e-80 < c < 5.7999999999999997e51Initial program 95.3%
Taylor expanded in b around inf 57.7%
*-commutative57.7%
Simplified57.7%
Final simplification69.1%
(FPCore (a b c d) :precision binary64 (if (or (<= c -0.0034) (not (<= c 2.5e-44))) (- (/ b c) (* d (/ (/ a c) c))) (- (* b (* (/ 1.0 d) (/ c d))) (/ a d))))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -0.0034) || !(c <= 2.5e-44)) {
tmp = (b / c) - (d * ((a / c) / c));
} else {
tmp = (b * ((1.0 / d) * (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 <= (-0.0034d0)) .or. (.not. (c <= 2.5d-44))) then
tmp = (b / c) - (d * ((a / c) / c))
else
tmp = (b * ((1.0d0 / d) * (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 <= -0.0034) || !(c <= 2.5e-44)) {
tmp = (b / c) - (d * ((a / c) / c));
} else {
tmp = (b * ((1.0 / d) * (c / d))) - (a / d);
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -0.0034) or not (c <= 2.5e-44): tmp = (b / c) - (d * ((a / c) / c)) else: tmp = (b * ((1.0 / d) * (c / d))) - (a / d) return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -0.0034) || !(c <= 2.5e-44)) tmp = Float64(Float64(b / c) - Float64(d * Float64(Float64(a / c) / c))); else tmp = Float64(Float64(b * Float64(Float64(1.0 / d) * Float64(c / d))) - Float64(a / d)); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((c <= -0.0034) || ~((c <= 2.5e-44))) tmp = (b / c) - (d * ((a / c) / c)); else tmp = (b * ((1.0 / d) * (c / d))) - (a / d); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -0.0034], N[Not[LessEqual[c, 2.5e-44]], $MachinePrecision]], N[(N[(b / c), $MachinePrecision] - N[(d * N[(N[(a / c), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b * N[(N[(1.0 / d), $MachinePrecision] * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -0.0034 \lor \neg \left(c \leq 2.5 \cdot 10^{-44}\right):\\
\;\;\;\;\frac{b}{c} - d \cdot \frac{\frac{a}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;b \cdot \left(\frac{1}{d} \cdot \frac{c}{d}\right) - \frac{a}{d}\\
\end{array}
\end{array}
if c < -0.00339999999999999981 or 2.50000000000000019e-44 < c Initial program 53.0%
Taylor expanded in c around inf 73.5%
*-un-lft-identity73.5%
pow273.5%
times-frac73.6%
*-commutative73.6%
Applied egg-rr73.6%
associate-*l/73.6%
*-un-lft-identity73.6%
associate-/l*78.1%
Applied egg-rr78.1%
associate-/l*79.2%
Applied egg-rr79.2%
if -0.00339999999999999981 < c < 2.50000000000000019e-44Initial program 80.2%
*-un-lft-identity80.2%
add-sqr-sqrt80.2%
times-frac80.3%
hypot-define80.3%
fma-neg80.3%
distribute-rgt-neg-in80.3%
hypot-define90.4%
Applied egg-rr90.4%
Taylor expanded in c around 0 82.1%
+-commutative82.1%
mul-1-neg82.1%
unsub-neg82.1%
associate-/l*83.0%
Simplified83.0%
*-un-lft-identity83.0%
unpow283.0%
times-frac85.3%
Applied egg-rr85.3%
Final simplification82.1%
(FPCore (a b c d)
:precision binary64
(if (<= c -7.5e-74)
(+ (/ b c) (* (/ (* a d) c) (/ -1.0 c)))
(if (<= c 6.6e-44)
(- (* b (* (/ 1.0 d) (/ c d))) (/ a d))
(- (/ b c) (* d (/ (/ a c) c))))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -7.5e-74) {
tmp = (b / c) + (((a * d) / c) * (-1.0 / c));
} else if (c <= 6.6e-44) {
tmp = (b * ((1.0 / d) * (c / d))) - (a / d);
} else {
tmp = (b / c) - (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 <= (-7.5d-74)) then
tmp = (b / c) + (((a * d) / c) * ((-1.0d0) / c))
else if (c <= 6.6d-44) then
tmp = (b * ((1.0d0 / d) * (c / d))) - (a / d)
else
tmp = (b / c) - (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 <= -7.5e-74) {
tmp = (b / c) + (((a * d) / c) * (-1.0 / c));
} else if (c <= 6.6e-44) {
tmp = (b * ((1.0 / d) * (c / d))) - (a / d);
} else {
tmp = (b / c) - (d * ((a / c) / c));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -7.5e-74: tmp = (b / c) + (((a * d) / c) * (-1.0 / c)) elif c <= 6.6e-44: tmp = (b * ((1.0 / d) * (c / d))) - (a / d) else: tmp = (b / c) - (d * ((a / c) / c)) return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -7.5e-74) tmp = Float64(Float64(b / c) + Float64(Float64(Float64(a * d) / c) * Float64(-1.0 / c))); elseif (c <= 6.6e-44) tmp = Float64(Float64(b * Float64(Float64(1.0 / d) * Float64(c / d))) - Float64(a / d)); else tmp = Float64(Float64(b / c) - Float64(d * Float64(Float64(a / c) / c))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -7.5e-74) tmp = (b / c) + (((a * d) / c) * (-1.0 / c)); elseif (c <= 6.6e-44) tmp = (b * ((1.0 / d) * (c / d))) - (a / d); else tmp = (b / c) - (d * ((a / c) / c)); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -7.5e-74], N[(N[(b / c), $MachinePrecision] + N[(N[(N[(a * d), $MachinePrecision] / c), $MachinePrecision] * N[(-1.0 / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 6.6e-44], N[(N[(b * N[(N[(1.0 / d), $MachinePrecision] * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], N[(N[(b / c), $MachinePrecision] - N[(d * N[(N[(a / c), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -7.5 \cdot 10^{-74}:\\
\;\;\;\;\frac{b}{c} + \frac{a \cdot d}{c} \cdot \frac{-1}{c}\\
\mathbf{elif}\;c \leq 6.6 \cdot 10^{-44}:\\
\;\;\;\;b \cdot \left(\frac{1}{d} \cdot \frac{c}{d}\right) - \frac{a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c} - d \cdot \frac{\frac{a}{c}}{c}\\
\end{array}
\end{array}
if c < -7.5e-74Initial program 58.3%
Taylor expanded in c around inf 73.6%
*-un-lft-identity73.6%
pow273.6%
times-frac74.8%
*-commutative74.8%
Applied egg-rr74.8%
if -7.5e-74 < c < 6.60000000000000011e-44Initial program 80.4%
*-un-lft-identity80.4%
add-sqr-sqrt80.4%
times-frac80.4%
hypot-define80.4%
fma-neg80.4%
distribute-rgt-neg-in80.4%
hypot-define90.2%
Applied egg-rr90.2%
Taylor expanded in c around 0 87.7%
+-commutative87.7%
mul-1-neg87.7%
unsub-neg87.7%
associate-/l*88.6%
Simplified88.6%
*-un-lft-identity88.6%
unpow288.6%
times-frac91.2%
Applied egg-rr91.2%
if 6.60000000000000011e-44 < c Initial program 51.9%
Taylor expanded in c around inf 70.2%
*-un-lft-identity70.2%
pow270.2%
times-frac68.9%
*-commutative68.9%
Applied egg-rr68.9%
associate-*l/68.9%
*-un-lft-identity68.9%
associate-/l*76.4%
Applied egg-rr76.4%
associate-/l*77.1%
Applied egg-rr77.1%
Final simplification82.5%
(FPCore (a b c d) :precision binary64 (if (or (<= c -3.05e-105) (not (<= c 9e-44))) (- (/ b c) (* d (/ (/ a c) c))) (/ a (- d))))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -3.05e-105) || !(c <= 9e-44)) {
tmp = (b / c) - (d * ((a / 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 <= (-3.05d-105)) .or. (.not. (c <= 9d-44))) then
tmp = (b / c) - (d * ((a / 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 <= -3.05e-105) || !(c <= 9e-44)) {
tmp = (b / c) - (d * ((a / c) / c));
} else {
tmp = a / -d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -3.05e-105) or not (c <= 9e-44): tmp = (b / c) - (d * ((a / c) / c)) else: tmp = a / -d return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -3.05e-105) || !(c <= 9e-44)) tmp = Float64(Float64(b / c) - Float64(d * Float64(Float64(a / 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 <= -3.05e-105) || ~((c <= 9e-44))) tmp = (b / c) - (d * ((a / c) / c)); else tmp = a / -d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -3.05e-105], N[Not[LessEqual[c, 9e-44]], $MachinePrecision]], N[(N[(b / c), $MachinePrecision] - N[(d * N[(N[(a / c), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a / (-d)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -3.05 \cdot 10^{-105} \lor \neg \left(c \leq 9 \cdot 10^{-44}\right):\\
\;\;\;\;\frac{b}{c} - d \cdot \frac{\frac{a}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{-d}\\
\end{array}
\end{array}
if c < -3.04999999999999992e-105 or 8.9999999999999997e-44 < c Initial program 57.5%
Taylor expanded in c around inf 70.9%
*-un-lft-identity70.9%
pow270.9%
times-frac70.9%
*-commutative70.9%
Applied egg-rr70.9%
associate-*l/71.0%
*-un-lft-identity71.0%
associate-/l*72.8%
Applied egg-rr72.8%
associate-/l*73.8%
Applied egg-rr73.8%
if -3.04999999999999992e-105 < c < 8.9999999999999997e-44Initial program 79.1%
Taylor expanded in c around 0 72.2%
associate-*r/72.2%
neg-mul-172.2%
Simplified72.2%
Final simplification73.2%
(FPCore (a b c d) :precision binary64 (if (<= c -7.2e-103) (- (/ b c) (* d (/ (/ a c) c))) (if (<= c 9.5e-61) (/ a (- d)) (- (/ b c) (* (/ d c) (/ a c))))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -7.2e-103) {
tmp = (b / c) - (d * ((a / c) / c));
} else if (c <= 9.5e-61) {
tmp = a / -d;
} else {
tmp = (b / c) - ((d / c) * (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 (c <= (-7.2d-103)) then
tmp = (b / c) - (d * ((a / c) / c))
else if (c <= 9.5d-61) then
tmp = a / -d
else
tmp = (b / c) - ((d / c) * (a / c))
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -7.2e-103) {
tmp = (b / c) - (d * ((a / c) / c));
} else if (c <= 9.5e-61) {
tmp = a / -d;
} else {
tmp = (b / c) - ((d / c) * (a / c));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -7.2e-103: tmp = (b / c) - (d * ((a / c) / c)) elif c <= 9.5e-61: tmp = a / -d else: tmp = (b / c) - ((d / c) * (a / c)) return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -7.2e-103) tmp = Float64(Float64(b / c) - Float64(d * Float64(Float64(a / c) / c))); elseif (c <= 9.5e-61) tmp = Float64(a / Float64(-d)); else tmp = Float64(Float64(b / c) - Float64(Float64(d / c) * Float64(a / c))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -7.2e-103) tmp = (b / c) - (d * ((a / c) / c)); elseif (c <= 9.5e-61) tmp = a / -d; else tmp = (b / c) - ((d / c) * (a / c)); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -7.2e-103], N[(N[(b / c), $MachinePrecision] - N[(d * N[(N[(a / c), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 9.5e-61], N[(a / (-d)), $MachinePrecision], N[(N[(b / c), $MachinePrecision] - N[(N[(d / c), $MachinePrecision] * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -7.2 \cdot 10^{-103}:\\
\;\;\;\;\frac{b}{c} - d \cdot \frac{\frac{a}{c}}{c}\\
\mathbf{elif}\;c \leq 9.5 \cdot 10^{-61}:\\
\;\;\;\;\frac{a}{-d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c} - \frac{d}{c} \cdot \frac{a}{c}\\
\end{array}
\end{array}
if c < -7.1999999999999996e-103Initial program 61.6%
Taylor expanded in c around inf 71.4%
*-un-lft-identity71.4%
pow271.4%
times-frac72.5%
*-commutative72.5%
Applied egg-rr72.5%
associate-*l/72.5%
*-un-lft-identity72.5%
associate-/l*70.2%
Applied egg-rr70.2%
associate-/l*71.4%
Applied egg-rr71.4%
if -7.1999999999999996e-103 < c < 9.49999999999999986e-61Initial program 78.1%
Taylor expanded in c around 0 73.6%
associate-*r/73.6%
neg-mul-173.6%
Simplified73.6%
if 9.49999999999999986e-61 < c Initial program 55.3%
Taylor expanded in c around inf 69.6%
*-commutative69.6%
pow269.6%
times-frac75.4%
Applied egg-rr75.4%
Final simplification73.4%
(FPCore (a b c d) :precision binary64 (if (or (<= c -1.2e-82) (not (<= c 2.9e-9))) (/ b c) (/ a (- d))))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -1.2e-82) || !(c <= 2.9e-9)) {
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.2d-82)) .or. (.not. (c <= 2.9d-9))) 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.2e-82) || !(c <= 2.9e-9)) {
tmp = b / c;
} else {
tmp = a / -d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -1.2e-82) or not (c <= 2.9e-9): tmp = b / c else: tmp = a / -d return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -1.2e-82) || !(c <= 2.9e-9)) 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.2e-82) || ~((c <= 2.9e-9))) tmp = b / c; else tmp = a / -d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -1.2e-82], N[Not[LessEqual[c, 2.9e-9]], $MachinePrecision]], N[(b / c), $MachinePrecision], N[(a / (-d)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.2 \cdot 10^{-82} \lor \neg \left(c \leq 2.9 \cdot 10^{-9}\right):\\
\;\;\;\;\frac{b}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{-d}\\
\end{array}
\end{array}
if c < -1.20000000000000004e-82 or 2.89999999999999991e-9 < c Initial program 54.9%
Taylor expanded in c around inf 65.3%
if -1.20000000000000004e-82 < c < 2.89999999999999991e-9Initial program 80.2%
Taylor expanded in c around 0 69.0%
associate-*r/69.0%
neg-mul-169.0%
Simplified69.0%
Final simplification67.0%
(FPCore (a b c d) :precision binary64 (if (or (<= d -3.3e+166) (not (<= d 1.36e+167))) (/ a d) (/ b c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -3.3e+166) || !(d <= 1.36e+167)) {
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 <= (-3.3d+166)) .or. (.not. (d <= 1.36d+167))) 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 <= -3.3e+166) || !(d <= 1.36e+167)) {
tmp = a / d;
} else {
tmp = b / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -3.3e+166) or not (d <= 1.36e+167): tmp = a / d else: tmp = b / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -3.3e+166) || !(d <= 1.36e+167)) 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 <= -3.3e+166) || ~((d <= 1.36e+167))) tmp = a / d; else tmp = b / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -3.3e+166], N[Not[LessEqual[d, 1.36e+167]], $MachinePrecision]], N[(a / d), $MachinePrecision], N[(b / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -3.3 \cdot 10^{+166} \lor \neg \left(d \leq 1.36 \cdot 10^{+167}\right):\\
\;\;\;\;\frac{a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if d < -3.3000000000000002e166 or 1.36e167 < d Initial program 36.9%
Taylor expanded in b around 0 37.2%
mul-1-neg37.2%
distribute-rgt-neg-out37.2%
Simplified37.2%
*-commutative37.2%
add-sqr-sqrt37.2%
hypot-undefine37.2%
hypot-undefine37.2%
times-frac83.0%
add-sqr-sqrt41.2%
sqrt-unprod0.9%
sqr-neg0.9%
sqrt-prod15.9%
add-sqr-sqrt37.3%
hypot-undefine38.1%
+-commutative38.1%
hypot-define37.3%
hypot-undefine38.1%
+-commutative38.1%
hypot-define37.3%
Applied egg-rr37.3%
Taylor expanded in d around inf 35.9%
if -3.3000000000000002e166 < d < 1.36e167Initial program 75.9%
Taylor expanded in c around inf 52.7%
Final simplification48.6%
(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 66.3%
Taylor expanded in b around 0 43.2%
mul-1-neg43.2%
distribute-rgt-neg-out43.2%
Simplified43.2%
*-commutative43.2%
add-sqr-sqrt43.2%
hypot-undefine43.2%
hypot-undefine43.2%
times-frac55.9%
add-sqr-sqrt25.9%
sqrt-unprod17.6%
sqr-neg17.6%
sqrt-prod8.9%
add-sqr-sqrt16.9%
hypot-undefine17.8%
+-commutative17.8%
hypot-define16.9%
hypot-undefine17.8%
+-commutative17.8%
hypot-define16.9%
Applied egg-rr16.9%
Taylor expanded in d around inf 11.4%
Final simplification11.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 2024046
(FPCore (a b c d)
:name "Complex division, imag part"
:precision binary64
:herbie-target
(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))))