
(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
(let* ((t_0 (/ a (fma c (/ c d) d)))
(t_1 (- (* c (/ b (pow (hypot c d) 2.0))) t_0)))
(if (<= c -1.25e+154)
(- (/ b c) (* (/ a c) (/ d c)))
(if (<= c -1.3e-131)
t_1
(if (<= c 2.8e-255)
(/ (- (* c (/ b d)) a) d)
(if (<= c 4.1e+102) t_1 (- (/ b c) t_0)))))))
double code(double a, double b, double c, double d) {
double t_0 = a / fma(c, (c / d), d);
double t_1 = (c * (b / pow(hypot(c, d), 2.0))) - t_0;
double tmp;
if (c <= -1.25e+154) {
tmp = (b / c) - ((a / c) * (d / c));
} else if (c <= -1.3e-131) {
tmp = t_1;
} else if (c <= 2.8e-255) {
tmp = ((c * (b / d)) - a) / d;
} else if (c <= 4.1e+102) {
tmp = t_1;
} else {
tmp = (b / c) - t_0;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(a / fma(c, Float64(c / d), d)) t_1 = Float64(Float64(c * Float64(b / (hypot(c, d) ^ 2.0))) - t_0) tmp = 0.0 if (c <= -1.25e+154) tmp = Float64(Float64(b / c) - Float64(Float64(a / c) * Float64(d / c))); elseif (c <= -1.3e-131) tmp = t_1; elseif (c <= 2.8e-255) tmp = Float64(Float64(Float64(c * Float64(b / d)) - a) / d); elseif (c <= 4.1e+102) tmp = t_1; else tmp = Float64(Float64(b / c) - t_0); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(a / N[(c * N[(c / d), $MachinePrecision] + d), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(c * N[(b / N[Power[N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]}, If[LessEqual[c, -1.25e+154], N[(N[(b / c), $MachinePrecision] - N[(N[(a / c), $MachinePrecision] * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -1.3e-131], t$95$1, If[LessEqual[c, 2.8e-255], N[(N[(N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 4.1e+102], t$95$1, N[(N[(b / c), $MachinePrecision] - t$95$0), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a}{\mathsf{fma}\left(c, \frac{c}{d}, d\right)}\\
t_1 := c \cdot \frac{b}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}} - t\_0\\
\mathbf{if}\;c \leq -1.25 \cdot 10^{+154}:\\
\;\;\;\;\frac{b}{c} - \frac{a}{c} \cdot \frac{d}{c}\\
\mathbf{elif}\;c \leq -1.3 \cdot 10^{-131}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;c \leq 2.8 \cdot 10^{-255}:\\
\;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\
\mathbf{elif}\;c \leq 4.1 \cdot 10^{+102}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c} - t\_0\\
\end{array}
\end{array}
if c < -1.25000000000000001e154Initial program 30.6%
Taylor expanded in c around inf 79.6%
+-commutative79.6%
mul-1-neg79.6%
unsub-neg79.6%
associate-/l*80.2%
Simplified80.2%
*-un-lft-identity80.2%
pow280.2%
add-sqr-sqrt27.0%
times-frac27.0%
sqrt-div27.0%
sqrt-prod0.0%
add-sqr-sqrt27.0%
sqrt-div27.0%
sqrt-prod0.0%
add-sqr-sqrt31.8%
Applied egg-rr31.8%
associate-*l/31.8%
*-lft-identity31.8%
associate-/r/31.8%
Simplified31.8%
expm1-log1p-u31.8%
expm1-udef27.0%
associate-/l*27.0%
div-inv27.0%
associate-/r*27.0%
add-sqr-sqrt80.2%
clear-num80.2%
Applied egg-rr80.2%
expm1-def90.2%
expm1-log1p90.2%
Simplified90.2%
if -1.25000000000000001e154 < c < -1.29999999999999998e-131 or 2.80000000000000011e-255 < c < 4.1e102Initial program 76.0%
div-sub75.2%
sub-neg75.2%
associate-/l*77.4%
fma-def77.4%
add-sqr-sqrt77.4%
pow277.4%
fma-def77.4%
hypot-def77.4%
fma-def77.4%
add-sqr-sqrt77.4%
pow277.4%
fma-def77.4%
hypot-def77.4%
Applied egg-rr77.4%
sub-neg77.4%
associate-/r/74.9%
associate-/l*76.2%
Simplified76.2%
Taylor expanded in c around 0 93.2%
+-commutative93.2%
unpow293.2%
associate-*r/93.2%
fma-def93.2%
Simplified93.2%
if -1.29999999999999998e-131 < c < 2.80000000000000011e-255Initial program 53.4%
Taylor expanded in c around 0 71.8%
+-commutative71.8%
mul-1-neg71.8%
unsub-neg71.8%
associate-/l*67.9%
associate-/r/70.0%
Simplified70.0%
*-un-lft-identity70.0%
pow270.0%
times-frac78.8%
Applied egg-rr78.8%
associate-*l/78.8%
*-lft-identity78.8%
Simplified78.8%
associate-*l/83.1%
sub-div85.3%
Applied egg-rr85.3%
if 4.1e102 < c Initial program 39.4%
div-sub39.4%
sub-neg39.4%
associate-/l*43.1%
fma-def43.1%
add-sqr-sqrt43.1%
pow243.1%
fma-def43.1%
hypot-def43.1%
fma-def43.1%
add-sqr-sqrt43.1%
pow243.1%
fma-def43.1%
hypot-def43.1%
Applied egg-rr43.1%
sub-neg43.1%
associate-/r/37.8%
associate-/l*41.2%
Simplified41.2%
Taylor expanded in c around 0 46.9%
+-commutative46.9%
unpow246.9%
associate-*r/55.2%
fma-def55.2%
Simplified55.2%
Taylor expanded in c around inf 90.3%
Final simplification91.0%
(FPCore (a b c d)
:precision binary64
(if (<= d -1e+85)
(- (/ c (* d (/ d b))) (/ a d))
(if (<= d 1.6e-21)
(- (/ b c) (/ a (fma c (/ c d) d)))
(if (<= d 2.25e+52)
(/ (- (* c b) (* a d)) (+ (* c c) (* d d)))
(if (<= d 7.3e+92)
(+ (/ b c) (/ -1.0 (* (/ c d) (/ c a))))
(/ (- (* c (/ b d)) a) d))))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -1e+85) {
tmp = (c / (d * (d / b))) - (a / d);
} else if (d <= 1.6e-21) {
tmp = (b / c) - (a / fma(c, (c / d), d));
} else if (d <= 2.25e+52) {
tmp = ((c * b) - (a * d)) / ((c * c) + (d * d));
} else if (d <= 7.3e+92) {
tmp = (b / c) + (-1.0 / ((c / d) * (c / a)));
} else {
tmp = ((c * (b / d)) - a) / d;
}
return tmp;
}
function code(a, b, c, d) tmp = 0.0 if (d <= -1e+85) tmp = Float64(Float64(c / Float64(d * Float64(d / b))) - Float64(a / d)); elseif (d <= 1.6e-21) tmp = Float64(Float64(b / c) - Float64(a / fma(c, Float64(c / d), d))); elseif (d <= 2.25e+52) tmp = Float64(Float64(Float64(c * b) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d))); elseif (d <= 7.3e+92) tmp = Float64(Float64(b / c) + Float64(-1.0 / Float64(Float64(c / d) * Float64(c / a)))); else tmp = Float64(Float64(Float64(c * Float64(b / d)) - a) / d); end return tmp end
code[a_, b_, c_, d_] := If[LessEqual[d, -1e+85], N[(N[(c / N[(d * N[(d / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.6e-21], N[(N[(b / c), $MachinePrecision] - N[(a / N[(c * N[(c / d), $MachinePrecision] + d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.25e+52], N[(N[(N[(c * b), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 7.3e+92], N[(N[(b / c), $MachinePrecision] + N[(-1.0 / N[(N[(c / d), $MachinePrecision] * N[(c / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -1 \cdot 10^{+85}:\\
\;\;\;\;\frac{c}{d \cdot \frac{d}{b}} - \frac{a}{d}\\
\mathbf{elif}\;d \leq 1.6 \cdot 10^{-21}:\\
\;\;\;\;\frac{b}{c} - \frac{a}{\mathsf{fma}\left(c, \frac{c}{d}, d\right)}\\
\mathbf{elif}\;d \leq 2.25 \cdot 10^{+52}:\\
\;\;\;\;\frac{c \cdot b - a \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;d \leq 7.3 \cdot 10^{+92}:\\
\;\;\;\;\frac{b}{c} + \frac{-1}{\frac{c}{d} \cdot \frac{c}{a}}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\
\end{array}
\end{array}
if d < -1e85Initial program 43.8%
Taylor expanded in c around 0 75.0%
+-commutative75.0%
mul-1-neg75.0%
unsub-neg75.0%
associate-/l*80.4%
associate-/r/82.6%
Simplified82.6%
*-un-lft-identity82.6%
pow282.6%
times-frac84.9%
Applied egg-rr84.9%
associate-*l/84.9%
*-lft-identity84.9%
Simplified84.9%
*-commutative84.9%
clear-num84.9%
un-div-inv84.9%
div-inv84.9%
clear-num84.9%
Applied egg-rr84.9%
if -1e85 < d < 1.6000000000000001e-21Initial program 71.2%
div-sub68.1%
sub-neg68.1%
associate-/l*69.9%
fma-def69.9%
add-sqr-sqrt69.9%
pow269.9%
fma-def69.9%
hypot-def69.9%
fma-def69.9%
add-sqr-sqrt69.9%
pow269.9%
fma-def69.9%
hypot-def69.9%
Applied egg-rr69.9%
sub-neg69.9%
associate-/r/66.6%
associate-/l*66.8%
Simplified66.8%
Taylor expanded in c around 0 67.3%
+-commutative67.3%
unpow267.3%
associate-*r/67.3%
fma-def67.3%
Simplified67.3%
Taylor expanded in c around inf 87.0%
if 1.6000000000000001e-21 < d < 2.25e52Initial program 82.1%
if 2.25e52 < d < 7.30000000000000049e92Initial program 36.0%
Taylor expanded in c around inf 52.5%
+-commutative52.5%
mul-1-neg52.5%
unsub-neg52.5%
associate-/l*65.9%
Simplified65.9%
*-un-lft-identity65.9%
pow265.9%
add-sqr-sqrt65.9%
times-frac65.9%
sqrt-div65.9%
sqrt-prod32.2%
add-sqr-sqrt49.9%
sqrt-div50.0%
sqrt-prod47.5%
add-sqr-sqrt81.3%
Applied egg-rr81.3%
associate-*l/81.3%
*-lft-identity81.3%
associate-/r/81.6%
Simplified81.6%
clear-num81.6%
inv-pow81.6%
*-un-lft-identity81.6%
times-frac81.3%
clear-num81.3%
associate-/r*81.3%
add-sqr-sqrt81.6%
Applied egg-rr81.6%
unpow-181.6%
*-commutative81.6%
Simplified81.6%
if 7.30000000000000049e92 < d Initial program 40.1%
Taylor expanded in c around 0 88.7%
+-commutative88.7%
mul-1-neg88.7%
unsub-neg88.7%
associate-/l*90.8%
associate-/r/94.5%
Simplified94.5%
*-un-lft-identity94.5%
pow294.5%
times-frac96.3%
Applied egg-rr96.3%
associate-*l/96.3%
*-lft-identity96.3%
Simplified96.3%
associate-*l/96.3%
sub-div96.3%
Applied egg-rr96.3%
Final simplification88.1%
(FPCore (a b c d)
:precision binary64
(if (<= d -1.06e+73)
(/ (- a) (fma c (/ c d) d))
(if (<= d -1.52e-86)
(/ (- (* c b) (* a d)) (+ (* c c) (* d d)))
(if (<= d 1.5)
(+ (/ b c) (* (/ a (/ c d)) (/ -1.0 c)))
(/ (- (* c (/ b d)) a) d)))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -1.06e+73) {
tmp = -a / fma(c, (c / d), d);
} else if (d <= -1.52e-86) {
tmp = ((c * b) - (a * d)) / ((c * c) + (d * d));
} else if (d <= 1.5) {
tmp = (b / c) + ((a / (c / d)) * (-1.0 / c));
} else {
tmp = ((c * (b / d)) - a) / d;
}
return tmp;
}
function code(a, b, c, d) tmp = 0.0 if (d <= -1.06e+73) tmp = Float64(Float64(-a) / fma(c, Float64(c / d), d)); elseif (d <= -1.52e-86) tmp = Float64(Float64(Float64(c * b) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d))); elseif (d <= 1.5) tmp = Float64(Float64(b / c) + Float64(Float64(a / Float64(c / d)) * Float64(-1.0 / c))); else tmp = Float64(Float64(Float64(c * Float64(b / d)) - a) / d); end return tmp end
code[a_, b_, c_, d_] := If[LessEqual[d, -1.06e+73], N[((-a) / N[(c * N[(c / d), $MachinePrecision] + d), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -1.52e-86], N[(N[(N[(c * b), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.5], N[(N[(b / c), $MachinePrecision] + N[(N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision] * N[(-1.0 / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.06 \cdot 10^{+73}:\\
\;\;\;\;\frac{-a}{\mathsf{fma}\left(c, \frac{c}{d}, d\right)}\\
\mathbf{elif}\;d \leq -1.52 \cdot 10^{-86}:\\
\;\;\;\;\frac{c \cdot b - a \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;d \leq 1.5:\\
\;\;\;\;\frac{b}{c} + \frac{a}{\frac{c}{d}} \cdot \frac{-1}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\
\end{array}
\end{array}
if d < -1.0600000000000001e73Initial program 41.1%
div-sub41.1%
sub-neg41.1%
associate-/l*41.4%
fma-def41.4%
add-sqr-sqrt41.4%
pow241.4%
fma-def41.4%
hypot-def41.4%
fma-def41.4%
add-sqr-sqrt41.4%
pow241.4%
fma-def41.4%
hypot-def41.4%
Applied egg-rr41.4%
sub-neg41.4%
associate-/r/41.4%
associate-/l*50.7%
Simplified50.7%
Taylor expanded in c around 0 78.3%
+-commutative78.3%
unpow278.3%
associate-*r/84.6%
fma-def84.6%
Simplified84.6%
Taylor expanded in c around inf 51.6%
Taylor expanded in b around 0 76.2%
associate-*r/76.2%
neg-mul-176.2%
+-commutative76.2%
*-lft-identity76.2%
unpow276.2%
times-frac82.5%
/-rgt-identity82.5%
fma-udef82.5%
Simplified82.5%
if -1.0600000000000001e73 < d < -1.52e-86Initial program 77.2%
if -1.52e-86 < d < 1.5Initial program 71.1%
Taylor expanded in c around inf 83.1%
+-commutative83.1%
mul-1-neg83.1%
unsub-neg83.1%
associate-/l*81.6%
Simplified81.6%
pow281.6%
*-un-lft-identity81.6%
times-frac86.9%
Applied egg-rr86.9%
/-rgt-identity86.9%
*-un-lft-identity86.9%
times-frac88.7%
Applied egg-rr88.7%
if 1.5 < d Initial program 49.3%
Taylor expanded in c around 0 81.4%
+-commutative81.4%
mul-1-neg81.4%
unsub-neg81.4%
associate-/l*82.9%
associate-/r/85.5%
Simplified85.5%
*-un-lft-identity85.5%
pow285.5%
times-frac86.8%
Applied egg-rr86.8%
associate-*l/86.8%
*-lft-identity86.8%
Simplified86.8%
associate-*l/86.8%
sub-div86.8%
Applied egg-rr86.8%
Final simplification85.7%
(FPCore (a b c d)
:precision binary64
(if (<= d -8e+35)
(- (/ c (* d (/ d b))) (/ a d))
(if (<= d 0.018)
(+ (/ b c) (* (/ a (/ c d)) (/ -1.0 c)))
(/ (- (* c (/ b d)) a) d))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -8e+35) {
tmp = (c / (d * (d / b))) - (a / d);
} else if (d <= 0.018) {
tmp = (b / c) + ((a / (c / d)) * (-1.0 / 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 (d <= (-8d+35)) then
tmp = (c / (d * (d / b))) - (a / d)
else if (d <= 0.018d0) then
tmp = (b / c) + ((a / (c / d)) * ((-1.0d0) / 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 (d <= -8e+35) {
tmp = (c / (d * (d / b))) - (a / d);
} else if (d <= 0.018) {
tmp = (b / c) + ((a / (c / d)) * (-1.0 / c));
} else {
tmp = ((c * (b / d)) - a) / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -8e+35: tmp = (c / (d * (d / b))) - (a / d) elif d <= 0.018: tmp = (b / c) + ((a / (c / d)) * (-1.0 / c)) else: tmp = ((c * (b / d)) - a) / d return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -8e+35) tmp = Float64(Float64(c / Float64(d * Float64(d / b))) - Float64(a / d)); elseif (d <= 0.018) tmp = Float64(Float64(b / c) + Float64(Float64(a / Float64(c / d)) * Float64(-1.0 / 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 (d <= -8e+35) tmp = (c / (d * (d / b))) - (a / d); elseif (d <= 0.018) tmp = (b / c) + ((a / (c / d)) * (-1.0 / c)); else tmp = ((c * (b / d)) - a) / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -8e+35], N[(N[(c / N[(d * N[(d / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 0.018], N[(N[(b / c), $MachinePrecision] + N[(N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision] * N[(-1.0 / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -8 \cdot 10^{+35}:\\
\;\;\;\;\frac{c}{d \cdot \frac{d}{b}} - \frac{a}{d}\\
\mathbf{elif}\;d \leq 0.018:\\
\;\;\;\;\frac{b}{c} + \frac{a}{\frac{c}{d}} \cdot \frac{-1}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\
\end{array}
\end{array}
if d < -7.9999999999999997e35Initial program 50.0%
Taylor expanded in c around 0 70.5%
+-commutative70.5%
mul-1-neg70.5%
unsub-neg70.5%
associate-/l*72.9%
associate-/r/76.3%
Simplified76.3%
*-un-lft-identity76.3%
pow276.3%
times-frac78.0%
Applied egg-rr78.0%
associate-*l/78.0%
*-lft-identity78.0%
Simplified78.0%
*-commutative78.0%
clear-num78.0%
un-div-inv78.0%
div-inv78.0%
clear-num78.1%
Applied egg-rr78.1%
if -7.9999999999999997e35 < d < 0.0179999999999999986Initial program 71.1%
Taylor expanded in c around inf 79.7%
+-commutative79.7%
mul-1-neg79.7%
unsub-neg79.7%
associate-/l*78.4%
Simplified78.4%
pow278.4%
*-un-lft-identity78.4%
times-frac82.9%
Applied egg-rr82.9%
/-rgt-identity82.9%
*-un-lft-identity82.9%
times-frac85.2%
Applied egg-rr85.2%
if 0.0179999999999999986 < d Initial program 49.3%
Taylor expanded in c around 0 81.4%
+-commutative81.4%
mul-1-neg81.4%
unsub-neg81.4%
associate-/l*82.9%
associate-/r/85.5%
Simplified85.5%
*-un-lft-identity85.5%
pow285.5%
times-frac86.8%
Applied egg-rr86.8%
associate-*l/86.8%
*-lft-identity86.8%
Simplified86.8%
associate-*l/86.8%
sub-div86.8%
Applied egg-rr86.8%
Final simplification84.1%
(FPCore (a b c d) :precision binary64 (if (<= d -1.5e+34) (- (* c (/ (/ b d) d)) (/ a d)) (if (<= d 0.17) (- (/ b c) (* (/ a c) (/ d c))) (/ (- (* c (/ b d)) a) d))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -1.5e+34) {
tmp = (c * ((b / d) / d)) - (a / d);
} else if (d <= 0.17) {
tmp = (b / c) - ((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 (d <= (-1.5d+34)) then
tmp = (c * ((b / d) / d)) - (a / d)
else if (d <= 0.17d0) then
tmp = (b / c) - ((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 (d <= -1.5e+34) {
tmp = (c * ((b / d) / d)) - (a / d);
} else if (d <= 0.17) {
tmp = (b / c) - ((a / c) * (d / c));
} else {
tmp = ((c * (b / d)) - a) / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -1.5e+34: tmp = (c * ((b / d) / d)) - (a / d) elif d <= 0.17: tmp = (b / c) - ((a / c) * (d / c)) else: tmp = ((c * (b / d)) - a) / d return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -1.5e+34) tmp = Float64(Float64(c * Float64(Float64(b / d) / d)) - Float64(a / d)); elseif (d <= 0.17) tmp = Float64(Float64(b / c) - Float64(Float64(a / c) * Float64(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 (d <= -1.5e+34) tmp = (c * ((b / d) / d)) - (a / d); elseif (d <= 0.17) tmp = (b / c) - ((a / c) * (d / c)); else tmp = ((c * (b / d)) - a) / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -1.5e+34], N[(N[(c * N[(N[(b / d), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 0.17], N[(N[(b / c), $MachinePrecision] - N[(N[(a / c), $MachinePrecision] * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.5 \cdot 10^{+34}:\\
\;\;\;\;c \cdot \frac{\frac{b}{d}}{d} - \frac{a}{d}\\
\mathbf{elif}\;d \leq 0.17:\\
\;\;\;\;\frac{b}{c} - \frac{a}{c} \cdot \frac{d}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\
\end{array}
\end{array}
if d < -1.50000000000000009e34Initial program 50.0%
Taylor expanded in c around 0 70.5%
+-commutative70.5%
mul-1-neg70.5%
unsub-neg70.5%
associate-/l*72.9%
associate-/r/76.3%
Simplified76.3%
*-un-lft-identity76.3%
pow276.3%
times-frac78.0%
Applied egg-rr78.0%
associate-*l/78.0%
*-lft-identity78.0%
Simplified78.0%
if -1.50000000000000009e34 < d < 0.170000000000000012Initial program 71.1%
Taylor expanded in c around inf 79.7%
+-commutative79.7%
mul-1-neg79.7%
unsub-neg79.7%
associate-/l*78.4%
Simplified78.4%
*-un-lft-identity78.4%
pow278.4%
add-sqr-sqrt37.2%
times-frac37.2%
sqrt-div37.0%
sqrt-prod19.7%
add-sqr-sqrt35.3%
sqrt-div36.7%
sqrt-prod24.0%
add-sqr-sqrt42.1%
Applied egg-rr42.1%
associate-*l/42.1%
*-lft-identity42.1%
associate-/r/41.3%
Simplified41.3%
expm1-log1p-u35.7%
expm1-udef32.1%
associate-/l*32.1%
div-inv32.1%
associate-/r*32.1%
add-sqr-sqrt69.7%
clear-num69.7%
Applied egg-rr69.7%
expm1-def75.4%
expm1-log1p85.1%
Simplified85.1%
if 0.170000000000000012 < d Initial program 49.3%
Taylor expanded in c around 0 81.4%
+-commutative81.4%
mul-1-neg81.4%
unsub-neg81.4%
associate-/l*82.9%
associate-/r/85.5%
Simplified85.5%
*-un-lft-identity85.5%
pow285.5%
times-frac86.8%
Applied egg-rr86.8%
associate-*l/86.8%
*-lft-identity86.8%
Simplified86.8%
associate-*l/86.8%
sub-div86.8%
Applied egg-rr86.8%
Final simplification84.0%
(FPCore (a b c d)
:precision binary64
(if (<= d -2e+34)
(- (/ c (* d (/ d b))) (/ a d))
(if (<= d 0.235)
(- (/ b c) (* (/ a c) (/ d c)))
(/ (- (* c (/ b d)) a) d))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -2e+34) {
tmp = (c / (d * (d / b))) - (a / d);
} else if (d <= 0.235) {
tmp = (b / c) - ((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 (d <= (-2d+34)) then
tmp = (c / (d * (d / b))) - (a / d)
else if (d <= 0.235d0) then
tmp = (b / c) - ((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 (d <= -2e+34) {
tmp = (c / (d * (d / b))) - (a / d);
} else if (d <= 0.235) {
tmp = (b / c) - ((a / c) * (d / c));
} else {
tmp = ((c * (b / d)) - a) / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -2e+34: tmp = (c / (d * (d / b))) - (a / d) elif d <= 0.235: tmp = (b / c) - ((a / c) * (d / c)) else: tmp = ((c * (b / d)) - a) / d return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -2e+34) tmp = Float64(Float64(c / Float64(d * Float64(d / b))) - Float64(a / d)); elseif (d <= 0.235) tmp = Float64(Float64(b / c) - Float64(Float64(a / c) * Float64(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 (d <= -2e+34) tmp = (c / (d * (d / b))) - (a / d); elseif (d <= 0.235) tmp = (b / c) - ((a / c) * (d / c)); else tmp = ((c * (b / d)) - a) / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -2e+34], N[(N[(c / N[(d * N[(d / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 0.235], N[(N[(b / c), $MachinePrecision] - N[(N[(a / c), $MachinePrecision] * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -2 \cdot 10^{+34}:\\
\;\;\;\;\frac{c}{d \cdot \frac{d}{b}} - \frac{a}{d}\\
\mathbf{elif}\;d \leq 0.235:\\
\;\;\;\;\frac{b}{c} - \frac{a}{c} \cdot \frac{d}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\
\end{array}
\end{array}
if d < -1.99999999999999989e34Initial program 50.0%
Taylor expanded in c around 0 70.5%
+-commutative70.5%
mul-1-neg70.5%
unsub-neg70.5%
associate-/l*72.9%
associate-/r/76.3%
Simplified76.3%
*-un-lft-identity76.3%
pow276.3%
times-frac78.0%
Applied egg-rr78.0%
associate-*l/78.0%
*-lft-identity78.0%
Simplified78.0%
*-commutative78.0%
clear-num78.0%
un-div-inv78.0%
div-inv78.0%
clear-num78.1%
Applied egg-rr78.1%
if -1.99999999999999989e34 < d < 0.23499999999999999Initial program 71.1%
Taylor expanded in c around inf 79.7%
+-commutative79.7%
mul-1-neg79.7%
unsub-neg79.7%
associate-/l*78.4%
Simplified78.4%
*-un-lft-identity78.4%
pow278.4%
add-sqr-sqrt37.2%
times-frac37.2%
sqrt-div37.0%
sqrt-prod19.7%
add-sqr-sqrt35.3%
sqrt-div36.7%
sqrt-prod24.0%
add-sqr-sqrt42.1%
Applied egg-rr42.1%
associate-*l/42.1%
*-lft-identity42.1%
associate-/r/41.3%
Simplified41.3%
expm1-log1p-u35.7%
expm1-udef32.1%
associate-/l*32.1%
div-inv32.1%
associate-/r*32.1%
add-sqr-sqrt69.7%
clear-num69.7%
Applied egg-rr69.7%
expm1-def75.4%
expm1-log1p85.1%
Simplified85.1%
if 0.23499999999999999 < d Initial program 49.3%
Taylor expanded in c around 0 81.4%
+-commutative81.4%
mul-1-neg81.4%
unsub-neg81.4%
associate-/l*82.9%
associate-/r/85.5%
Simplified85.5%
*-un-lft-identity85.5%
pow285.5%
times-frac86.8%
Applied egg-rr86.8%
associate-*l/86.8%
*-lft-identity86.8%
Simplified86.8%
associate-*l/86.8%
sub-div86.8%
Applied egg-rr86.8%
Final simplification84.1%
(FPCore (a b c d) :precision binary64 (if (or (<= d -1.35e+20) (not (<= d 1.56e-44))) (/ (- (* c (/ b d)) a) d) (/ b c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -1.35e+20) || !(d <= 1.56e-44)) {
tmp = ((c * (b / d)) - 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 <= (-1.35d+20)) .or. (.not. (d <= 1.56d-44))) then
tmp = ((c * (b / d)) - 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 <= -1.35e+20) || !(d <= 1.56e-44)) {
tmp = ((c * (b / d)) - a) / d;
} else {
tmp = b / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -1.35e+20) or not (d <= 1.56e-44): tmp = ((c * (b / d)) - a) / d else: tmp = b / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -1.35e+20) || !(d <= 1.56e-44)) tmp = Float64(Float64(Float64(c * Float64(b / d)) - a) / d); else tmp = Float64(b / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -1.35e+20) || ~((d <= 1.56e-44))) tmp = ((c * (b / d)) - a) / d; else tmp = b / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -1.35e+20], N[Not[LessEqual[d, 1.56e-44]], $MachinePrecision]], N[(N[(N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], N[(b / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.35 \cdot 10^{+20} \lor \neg \left(d \leq 1.56 \cdot 10^{-44}\right):\\
\;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if d < -1.35e20 or 1.56e-44 < d Initial program 51.1%
Taylor expanded in c around 0 75.2%
+-commutative75.2%
mul-1-neg75.2%
unsub-neg75.2%
associate-/l*77.0%
associate-/r/79.8%
Simplified79.8%
*-un-lft-identity79.8%
pow279.8%
times-frac81.2%
Applied egg-rr81.2%
associate-*l/81.1%
*-lft-identity81.1%
Simplified81.1%
associate-*l/80.7%
sub-div80.7%
Applied egg-rr80.7%
if -1.35e20 < d < 1.56e-44Initial program 70.8%
Taylor expanded in c around inf 73.0%
Final simplification77.0%
(FPCore (a b c d) :precision binary64 (if (<= d -1.8e+35) (- (* c (/ (/ b d) d)) (/ a d)) (if (<= d 1e-44) (/ b c) (/ (- (* c (/ b d)) a) d))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -1.8e+35) {
tmp = (c * ((b / d) / d)) - (a / d);
} else if (d <= 1e-44) {
tmp = b / 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 (d <= (-1.8d+35)) then
tmp = (c * ((b / d) / d)) - (a / d)
else if (d <= 1d-44) then
tmp = b / 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 (d <= -1.8e+35) {
tmp = (c * ((b / d) / d)) - (a / d);
} else if (d <= 1e-44) {
tmp = b / c;
} else {
tmp = ((c * (b / d)) - a) / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -1.8e+35: tmp = (c * ((b / d) / d)) - (a / d) elif d <= 1e-44: tmp = b / c else: tmp = ((c * (b / d)) - a) / d return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -1.8e+35) tmp = Float64(Float64(c * Float64(Float64(b / d) / d)) - Float64(a / d)); elseif (d <= 1e-44) tmp = Float64(b / 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 (d <= -1.8e+35) tmp = (c * ((b / d) / d)) - (a / d); elseif (d <= 1e-44) tmp = b / c; else tmp = ((c * (b / d)) - a) / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -1.8e+35], N[(N[(c * N[(N[(b / d), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1e-44], N[(b / c), $MachinePrecision], N[(N[(N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.8 \cdot 10^{+35}:\\
\;\;\;\;c \cdot \frac{\frac{b}{d}}{d} - \frac{a}{d}\\
\mathbf{elif}\;d \leq 10^{-44}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\
\end{array}
\end{array}
if d < -1.8e35Initial program 50.0%
Taylor expanded in c around 0 70.5%
+-commutative70.5%
mul-1-neg70.5%
unsub-neg70.5%
associate-/l*72.9%
associate-/r/76.3%
Simplified76.3%
*-un-lft-identity76.3%
pow276.3%
times-frac78.0%
Applied egg-rr78.0%
associate-*l/78.0%
*-lft-identity78.0%
Simplified78.0%
if -1.8e35 < d < 9.99999999999999953e-45Initial program 70.7%
Taylor expanded in c around inf 72.1%
if 9.99999999999999953e-45 < d Initial program 51.4%
Taylor expanded in c around 0 80.1%
+-commutative80.1%
mul-1-neg80.1%
unsub-neg80.1%
associate-/l*81.5%
associate-/r/83.9%
Simplified83.9%
*-un-lft-identity83.9%
pow283.9%
times-frac85.1%
Applied egg-rr85.1%
associate-*l/85.1%
*-lft-identity85.1%
Simplified85.1%
associate-*l/85.2%
sub-div85.2%
Applied egg-rr85.2%
Final simplification77.3%
(FPCore (a b c d) :precision binary64 (if (or (<= d -1.7e+66) (not (<= d 2.1e-46))) (/ (- a) d) (/ b c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -1.7e+66) || !(d <= 2.1e-46)) {
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 <= (-1.7d+66)) .or. (.not. (d <= 2.1d-46))) 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 <= -1.7e+66) || !(d <= 2.1e-46)) {
tmp = -a / d;
} else {
tmp = b / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -1.7e+66) or not (d <= 2.1e-46): tmp = -a / d else: tmp = b / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -1.7e+66) || !(d <= 2.1e-46)) tmp = Float64(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 <= -1.7e+66) || ~((d <= 2.1e-46))) tmp = -a / d; else tmp = b / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -1.7e+66], N[Not[LessEqual[d, 2.1e-46]], $MachinePrecision]], N[((-a) / d), $MachinePrecision], N[(b / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.7 \cdot 10^{+66} \lor \neg \left(d \leq 2.1 \cdot 10^{-46}\right):\\
\;\;\;\;\frac{-a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if d < -1.70000000000000015e66 or 2.09999999999999987e-46 < d Initial program 48.0%
Taylor expanded in c around 0 77.1%
associate-*r/77.1%
mul-1-neg77.1%
Simplified77.1%
if -1.70000000000000015e66 < d < 2.09999999999999987e-46Initial program 71.9%
Taylor expanded in c around inf 70.1%
Final simplification73.5%
(FPCore (a b c d) :precision binary64 (/ b c))
double code(double a, double b, double c, double d) {
return b / c;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = b / c
end function
public static double code(double a, double b, double c, double d) {
return b / c;
}
def code(a, b, c, d): return b / c
function code(a, b, c, d) return Float64(b / c) end
function tmp = code(a, b, c, d) tmp = b / c; end
code[a_, b_, c_, d_] := N[(b / c), $MachinePrecision]
\begin{array}{l}
\\
\frac{b}{c}
\end{array}
Initial program 60.4%
Taylor expanded in c around inf 45.6%
Final simplification45.6%
(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 2024041
(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))))