
(FPCore (a b c d) :precision binary64 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))))
double code(double a, double b, double c, double d) {
return ((a * c) + (b * 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 = ((a * c) + (b * d)) / ((c * c) + (d * d))
end function
public static double code(double a, double b, double c, double d) {
return ((a * c) + (b * d)) / ((c * c) + (d * d));
}
def code(a, b, c, d): return ((a * c) + (b * d)) / ((c * c) + (d * d))
function code(a, b, c, d) return Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d))) end
function tmp = code(a, b, c, d) tmp = ((a * c) + (b * d)) / ((c * c) + (d * d)); end
code[a_, b_, c_, d_] := N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 14 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b c d) :precision binary64 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))))
double code(double a, double b, double c, double d) {
return ((a * c) + (b * 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 = ((a * c) + (b * d)) / ((c * c) + (d * d))
end function
public static double code(double a, double b, double c, double d) {
return ((a * c) + (b * d)) / ((c * c) + (d * d));
}
def code(a, b, c, d): return ((a * c) + (b * d)) / ((c * c) + (d * d))
function code(a, b, c, d) return Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d))) end
function tmp = code(a, b, c, d) tmp = ((a * c) + (b * d)) / ((c * c) + (d * d)); end
code[a_, b_, c_, d_] := N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}
\end{array}
(FPCore (a b c d) :precision binary64 (if (<= (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))) INFINITY) (* (/ 1.0 (hypot c d)) (/ (fma a c (* b d)) (hypot c d))) (* b (* (/ 1.0 (hypot d c)) (/ d (hypot d c))))))
double code(double a, double b, double c, double d) {
double tmp;
if ((((a * c) + (b * d)) / ((c * c) + (d * d))) <= ((double) INFINITY)) {
tmp = (1.0 / hypot(c, d)) * (fma(a, c, (b * d)) / hypot(c, d));
} else {
tmp = b * ((1.0 / hypot(d, c)) * (d / hypot(d, c)));
}
return tmp;
}
function code(a, b, c, d) tmp = 0.0 if (Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d))) <= Inf) tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(fma(a, c, Float64(b * d)) / hypot(c, d))); else tmp = Float64(b * Float64(Float64(1.0 / hypot(d, c)) * Float64(d / hypot(d, c)))); end return tmp end
code[a_, b_, c_, d_] := If[LessEqual[N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(N[(a * c + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(b * N[(N[(1.0 / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision] * N[(d / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \leq \infty:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;b \cdot \left(\frac{1}{\mathsf{hypot}\left(d, c\right)} \cdot \frac{d}{\mathsf{hypot}\left(d, c\right)}\right)\\
\end{array}
\end{array}
if (/.f64 (+.f64 (*.f64 a c) (*.f64 b d)) (+.f64 (*.f64 c c) (*.f64 d d))) < +inf.0Initial program 75.3%
*-un-lft-identity75.3%
add-sqr-sqrt75.3%
times-frac75.4%
hypot-def75.4%
fma-def75.4%
hypot-def92.4%
Applied egg-rr92.4%
if +inf.0 < (/.f64 (+.f64 (*.f64 a c) (*.f64 b d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 0.0%
Taylor expanded in a around 0 1.2%
associate-/l*3.6%
associate-/r/3.6%
unpow23.6%
unpow23.6%
fma-udef3.6%
Simplified3.6%
*-un-lft-identity3.6%
add-sqr-sqrt3.6%
times-frac3.6%
fma-udef3.6%
hypot-def3.6%
fma-udef3.6%
hypot-def62.8%
Applied egg-rr62.8%
Final simplification85.7%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (fma d d (* c c)))
(t_1 (+ (/ (* b d) t_0) (/ a (/ t_0 c))))
(t_2 (+ (/ b d) (/ (* c (/ a d)) d))))
(if (<= d -5e+65)
t_2
(if (<= d -9e-160)
t_1
(if (<= d 2.7e-162)
(+ (/ a c) (/ 1.0 (/ c (/ b (/ c d)))))
(if (<= d 4.9e+61) t_1 t_2))))))
double code(double a, double b, double c, double d) {
double t_0 = fma(d, d, (c * c));
double t_1 = ((b * d) / t_0) + (a / (t_0 / c));
double t_2 = (b / d) + ((c * (a / d)) / d);
double tmp;
if (d <= -5e+65) {
tmp = t_2;
} else if (d <= -9e-160) {
tmp = t_1;
} else if (d <= 2.7e-162) {
tmp = (a / c) + (1.0 / (c / (b / (c / d))));
} else if (d <= 4.9e+61) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
function code(a, b, c, d) t_0 = fma(d, d, Float64(c * c)) t_1 = Float64(Float64(Float64(b * d) / t_0) + Float64(a / Float64(t_0 / c))) t_2 = Float64(Float64(b / d) + Float64(Float64(c * Float64(a / d)) / d)) tmp = 0.0 if (d <= -5e+65) tmp = t_2; elseif (d <= -9e-160) tmp = t_1; elseif (d <= 2.7e-162) tmp = Float64(Float64(a / c) + Float64(1.0 / Float64(c / Float64(b / Float64(c / d))))); elseif (d <= 4.9e+61) tmp = t_1; else tmp = t_2; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(b * d), $MachinePrecision] / t$95$0), $MachinePrecision] + N[(a / N[(t$95$0 / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(b / d), $MachinePrecision] + N[(N[(c * N[(a / d), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -5e+65], t$95$2, If[LessEqual[d, -9e-160], t$95$1, If[LessEqual[d, 2.7e-162], N[(N[(a / c), $MachinePrecision] + N[(1.0 / N[(c / N[(b / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 4.9e+61], t$95$1, t$95$2]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(d, d, c \cdot c\right)\\
t_1 := \frac{b \cdot d}{t_0} + \frac{a}{\frac{t_0}{c}}\\
t_2 := \frac{b}{d} + \frac{c \cdot \frac{a}{d}}{d}\\
\mathbf{if}\;d \leq -5 \cdot 10^{+65}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;d \leq -9 \cdot 10^{-160}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d \leq 2.7 \cdot 10^{-162}:\\
\;\;\;\;\frac{a}{c} + \frac{1}{\frac{c}{\frac{b}{\frac{c}{d}}}}\\
\mathbf{elif}\;d \leq 4.9 \cdot 10^{+61}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\end{array}
if d < -4.99999999999999973e65 or 4.90000000000000025e61 < d Initial program 35.3%
Taylor expanded in c around 0 67.8%
unpow267.8%
times-frac80.8%
Simplified80.8%
associate-*l/81.9%
Applied egg-rr81.9%
if -4.99999999999999973e65 < d < -9.00000000000000053e-160 or 2.69999999999999984e-162 < d < 4.90000000000000025e61Initial program 76.1%
Taylor expanded in a around 0 76.1%
unpow276.1%
unpow276.1%
fma-udef76.1%
*-commutative76.1%
associate-/l*79.7%
unpow279.7%
unpow279.7%
fma-udef79.7%
Simplified79.7%
if -9.00000000000000053e-160 < d < 2.69999999999999984e-162Initial program 67.4%
Taylor expanded in c around inf 72.4%
unpow272.4%
associate-/l*69.2%
Simplified69.2%
clear-num69.1%
inv-pow69.1%
Applied egg-rr69.1%
unpow-169.1%
unpow269.1%
associate-/r*72.4%
unpow272.4%
times-frac84.9%
Simplified84.9%
associate-*l/86.6%
associate-/l*86.8%
Applied egg-rr86.8%
Final simplification81.9%
(FPCore (a b c d)
:precision binary64
(if (<= c -1.15e+91)
(+ (/ a c) (/ d (/ c (/ b c))))
(if (<= c 8e-138)
(+ (/ b d) (/ (* c (/ a d)) d))
(if (<= c 1.15e+57)
(/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))
(* (/ 1.0 (hypot c d)) (+ a (/ d (/ c b))))))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -1.15e+91) {
tmp = (a / c) + (d / (c / (b / c)));
} else if (c <= 8e-138) {
tmp = (b / d) + ((c * (a / d)) / d);
} else if (c <= 1.15e+57) {
tmp = ((a * c) + (b * d)) / ((c * c) + (d * d));
} else {
tmp = (1.0 / hypot(c, d)) * (a + (d / (c / b)));
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -1.15e+91) {
tmp = (a / c) + (d / (c / (b / c)));
} else if (c <= 8e-138) {
tmp = (b / d) + ((c * (a / d)) / d);
} else if (c <= 1.15e+57) {
tmp = ((a * c) + (b * d)) / ((c * c) + (d * d));
} else {
tmp = (1.0 / Math.hypot(c, d)) * (a + (d / (c / b)));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -1.15e+91: tmp = (a / c) + (d / (c / (b / c))) elif c <= 8e-138: tmp = (b / d) + ((c * (a / d)) / d) elif c <= 1.15e+57: tmp = ((a * c) + (b * d)) / ((c * c) + (d * d)) else: tmp = (1.0 / math.hypot(c, d)) * (a + (d / (c / b))) return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -1.15e+91) tmp = Float64(Float64(a / c) + Float64(d / Float64(c / Float64(b / c)))); elseif (c <= 8e-138) tmp = Float64(Float64(b / d) + Float64(Float64(c * Float64(a / d)) / d)); elseif (c <= 1.15e+57) tmp = Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d))); else tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(a + Float64(d / Float64(c / b)))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -1.15e+91) tmp = (a / c) + (d / (c / (b / c))); elseif (c <= 8e-138) tmp = (b / d) + ((c * (a / d)) / d); elseif (c <= 1.15e+57) tmp = ((a * c) + (b * d)) / ((c * c) + (d * d)); else tmp = (1.0 / hypot(c, d)) * (a + (d / (c / b))); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -1.15e+91], N[(N[(a / c), $MachinePrecision] + N[(d / N[(c / N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 8e-138], N[(N[(b / d), $MachinePrecision] + N[(N[(c * N[(a / d), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.15e+57], N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(a + N[(d / N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.15 \cdot 10^{+91}:\\
\;\;\;\;\frac{a}{c} + \frac{d}{\frac{c}{\frac{b}{c}}}\\
\mathbf{elif}\;c \leq 8 \cdot 10^{-138}:\\
\;\;\;\;\frac{b}{d} + \frac{c \cdot \frac{a}{d}}{d}\\
\mathbf{elif}\;c \leq 1.15 \cdot 10^{+57}:\\
\;\;\;\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(a + \frac{d}{\frac{c}{b}}\right)\\
\end{array}
\end{array}
if c < -1.14999999999999996e91Initial program 35.6%
Taylor expanded in c around inf 64.1%
unpow264.1%
associate-/l*67.4%
Simplified67.4%
Taylor expanded in c around 0 67.4%
*-rgt-identity67.4%
associate-*r/67.4%
unpow267.4%
associate-*l*77.1%
associate-*r/77.0%
*-rgt-identity77.0%
Simplified77.0%
clear-num77.1%
un-div-inv77.1%
Applied egg-rr77.1%
if -1.14999999999999996e91 < c < 8.00000000000000054e-138Initial program 66.8%
Taylor expanded in c around 0 70.9%
unpow270.9%
times-frac77.8%
Simplified77.8%
associate-*l/78.7%
Applied egg-rr78.7%
if 8.00000000000000054e-138 < c < 1.1499999999999999e57Initial program 80.4%
if 1.1499999999999999e57 < c Initial program 37.8%
*-un-lft-identity37.8%
add-sqr-sqrt37.8%
times-frac37.8%
hypot-def37.8%
fma-def37.8%
hypot-def54.9%
Applied egg-rr54.9%
Taylor expanded in c around inf 73.9%
associate-/l*82.9%
Simplified82.9%
Final simplification79.6%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (* b (/ d (+ (* c c) (* d d))))))
(if (<= d -2.3e+121)
(/ b d)
(if (<= d -9.5e+29)
(/ (* a c) (* d d))
(if (<= d -2.1e-81)
t_0
(if (<= d 1.25e-145) (/ a c) (if (<= d 1.7e+87) t_0 (/ b d))))))))
double code(double a, double b, double c, double d) {
double t_0 = b * (d / ((c * c) + (d * d)));
double tmp;
if (d <= -2.3e+121) {
tmp = b / d;
} else if (d <= -9.5e+29) {
tmp = (a * c) / (d * d);
} else if (d <= -2.1e-81) {
tmp = t_0;
} else if (d <= 1.25e-145) {
tmp = a / c;
} else if (d <= 1.7e+87) {
tmp = t_0;
} else {
tmp = b / 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) :: t_0
real(8) :: tmp
t_0 = b * (d / ((c * c) + (d * d)))
if (d <= (-2.3d+121)) then
tmp = b / d
else if (d <= (-9.5d+29)) then
tmp = (a * c) / (d * d)
else if (d <= (-2.1d-81)) then
tmp = t_0
else if (d <= 1.25d-145) then
tmp = a / c
else if (d <= 1.7d+87) then
tmp = t_0
else
tmp = b / d
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = b * (d / ((c * c) + (d * d)));
double tmp;
if (d <= -2.3e+121) {
tmp = b / d;
} else if (d <= -9.5e+29) {
tmp = (a * c) / (d * d);
} else if (d <= -2.1e-81) {
tmp = t_0;
} else if (d <= 1.25e-145) {
tmp = a / c;
} else if (d <= 1.7e+87) {
tmp = t_0;
} else {
tmp = b / d;
}
return tmp;
}
def code(a, b, c, d): t_0 = b * (d / ((c * c) + (d * d))) tmp = 0 if d <= -2.3e+121: tmp = b / d elif d <= -9.5e+29: tmp = (a * c) / (d * d) elif d <= -2.1e-81: tmp = t_0 elif d <= 1.25e-145: tmp = a / c elif d <= 1.7e+87: tmp = t_0 else: tmp = b / d return tmp
function code(a, b, c, d) t_0 = Float64(b * Float64(d / Float64(Float64(c * c) + Float64(d * d)))) tmp = 0.0 if (d <= -2.3e+121) tmp = Float64(b / d); elseif (d <= -9.5e+29) tmp = Float64(Float64(a * c) / Float64(d * d)); elseif (d <= -2.1e-81) tmp = t_0; elseif (d <= 1.25e-145) tmp = Float64(a / c); elseif (d <= 1.7e+87) tmp = t_0; else tmp = Float64(b / d); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = b * (d / ((c * c) + (d * d))); tmp = 0.0; if (d <= -2.3e+121) tmp = b / d; elseif (d <= -9.5e+29) tmp = (a * c) / (d * d); elseif (d <= -2.1e-81) tmp = t_0; elseif (d <= 1.25e-145) tmp = a / c; elseif (d <= 1.7e+87) tmp = t_0; else tmp = b / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(b * N[(d / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -2.3e+121], N[(b / d), $MachinePrecision], If[LessEqual[d, -9.5e+29], N[(N[(a * c), $MachinePrecision] / N[(d * d), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -2.1e-81], t$95$0, If[LessEqual[d, 1.25e-145], N[(a / c), $MachinePrecision], If[LessEqual[d, 1.7e+87], t$95$0, N[(b / d), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := b \cdot \frac{d}{c \cdot c + d \cdot d}\\
\mathbf{if}\;d \leq -2.3 \cdot 10^{+121}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{elif}\;d \leq -9.5 \cdot 10^{+29}:\\
\;\;\;\;\frac{a \cdot c}{d \cdot d}\\
\mathbf{elif}\;d \leq -2.1 \cdot 10^{-81}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 1.25 \cdot 10^{-145}:\\
\;\;\;\;\frac{a}{c}\\
\mathbf{elif}\;d \leq 1.7 \cdot 10^{+87}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d}\\
\end{array}
\end{array}
if d < -2.2999999999999999e121 or 1.7000000000000001e87 < d Initial program 30.5%
Taylor expanded in c around 0 67.8%
if -2.2999999999999999e121 < d < -9.5000000000000003e29Initial program 58.5%
Taylor expanded in c around 0 58.5%
unpow258.5%
Simplified58.5%
Taylor expanded in a around inf 51.3%
unpow251.3%
Simplified51.3%
if -9.5000000000000003e29 < d < -2.0999999999999999e-81 or 1.2499999999999999e-145 < d < 1.7000000000000001e87Initial program 78.9%
Taylor expanded in a around 0 56.2%
associate-/l*58.5%
associate-/r/60.6%
unpow260.6%
unpow260.6%
fma-udef60.6%
Simplified60.6%
fma-udef60.6%
Applied egg-rr60.6%
if -2.0999999999999999e-81 < d < 1.2499999999999999e-145Initial program 67.3%
Taylor expanded in c around inf 64.2%
Final simplification63.5%
(FPCore (a b c d)
:precision binary64
(if (<= c -1.2e+91)
(+ (/ a c) (/ d (/ c (/ b c))))
(if (<= c 1.3e-136)
(+ (/ b d) (/ (* c (/ a d)) d))
(if (<= c 1e+57)
(/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))
(+ (/ a c) (/ 1.0 (/ c (/ b (/ c d)))))))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -1.2e+91) {
tmp = (a / c) + (d / (c / (b / c)));
} else if (c <= 1.3e-136) {
tmp = (b / d) + ((c * (a / d)) / d);
} else if (c <= 1e+57) {
tmp = ((a * c) + (b * d)) / ((c * c) + (d * d));
} else {
tmp = (a / c) + (1.0 / (c / (b / (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 (c <= (-1.2d+91)) then
tmp = (a / c) + (d / (c / (b / c)))
else if (c <= 1.3d-136) then
tmp = (b / d) + ((c * (a / d)) / d)
else if (c <= 1d+57) then
tmp = ((a * c) + (b * d)) / ((c * c) + (d * d))
else
tmp = (a / c) + (1.0d0 / (c / (b / (c / 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+91) {
tmp = (a / c) + (d / (c / (b / c)));
} else if (c <= 1.3e-136) {
tmp = (b / d) + ((c * (a / d)) / d);
} else if (c <= 1e+57) {
tmp = ((a * c) + (b * d)) / ((c * c) + (d * d));
} else {
tmp = (a / c) + (1.0 / (c / (b / (c / d))));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -1.2e+91: tmp = (a / c) + (d / (c / (b / c))) elif c <= 1.3e-136: tmp = (b / d) + ((c * (a / d)) / d) elif c <= 1e+57: tmp = ((a * c) + (b * d)) / ((c * c) + (d * d)) else: tmp = (a / c) + (1.0 / (c / (b / (c / d)))) return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -1.2e+91) tmp = Float64(Float64(a / c) + Float64(d / Float64(c / Float64(b / c)))); elseif (c <= 1.3e-136) tmp = Float64(Float64(b / d) + Float64(Float64(c * Float64(a / d)) / d)); elseif (c <= 1e+57) tmp = Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d))); else tmp = Float64(Float64(a / c) + Float64(1.0 / Float64(c / Float64(b / Float64(c / d))))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -1.2e+91) tmp = (a / c) + (d / (c / (b / c))); elseif (c <= 1.3e-136) tmp = (b / d) + ((c * (a / d)) / d); elseif (c <= 1e+57) tmp = ((a * c) + (b * d)) / ((c * c) + (d * d)); else tmp = (a / c) + (1.0 / (c / (b / (c / d)))); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -1.2e+91], N[(N[(a / c), $MachinePrecision] + N[(d / N[(c / N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.3e-136], N[(N[(b / d), $MachinePrecision] + N[(N[(c * N[(a / d), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1e+57], N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a / c), $MachinePrecision] + N[(1.0 / N[(c / N[(b / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.2 \cdot 10^{+91}:\\
\;\;\;\;\frac{a}{c} + \frac{d}{\frac{c}{\frac{b}{c}}}\\
\mathbf{elif}\;c \leq 1.3 \cdot 10^{-136}:\\
\;\;\;\;\frac{b}{d} + \frac{c \cdot \frac{a}{d}}{d}\\
\mathbf{elif}\;c \leq 10^{+57}:\\
\;\;\;\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{1}{\frac{c}{\frac{b}{\frac{c}{d}}}}\\
\end{array}
\end{array}
if c < -1.19999999999999991e91Initial program 35.6%
Taylor expanded in c around inf 64.1%
unpow264.1%
associate-/l*67.4%
Simplified67.4%
Taylor expanded in c around 0 67.4%
*-rgt-identity67.4%
associate-*r/67.4%
unpow267.4%
associate-*l*77.1%
associate-*r/77.0%
*-rgt-identity77.0%
Simplified77.0%
clear-num77.1%
un-div-inv77.1%
Applied egg-rr77.1%
if -1.19999999999999991e91 < c < 1.29999999999999998e-136Initial program 66.8%
Taylor expanded in c around 0 70.9%
unpow270.9%
times-frac77.8%
Simplified77.8%
associate-*l/78.7%
Applied egg-rr78.7%
if 1.29999999999999998e-136 < c < 1.00000000000000005e57Initial program 80.4%
if 1.00000000000000005e57 < c Initial program 37.8%
Taylor expanded in c around inf 67.4%
unpow267.4%
associate-/l*69.9%
Simplified69.9%
clear-num69.9%
inv-pow69.9%
Applied egg-rr69.9%
unpow-169.9%
unpow269.9%
associate-/r*67.5%
unpow267.5%
times-frac82.6%
Simplified82.6%
associate-*l/79.2%
associate-/l*82.6%
Applied egg-rr82.6%
Final simplification79.6%
(FPCore (a b c d)
:precision binary64
(if (<= c -1.15e+91)
(+ (/ a c) (/ d (/ c (/ b c))))
(if (<= c 450000000.0)
(+ (/ b d) (/ (* c (/ a d)) d))
(+ (/ a c) (/ 1.0 (* (/ c d) (/ c b)))))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -1.15e+91) {
tmp = (a / c) + (d / (c / (b / c)));
} else if (c <= 450000000.0) {
tmp = (b / d) + ((c * (a / d)) / d);
} else {
tmp = (a / c) + (1.0 / ((c / d) * (c / b)));
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (c <= (-1.15d+91)) then
tmp = (a / c) + (d / (c / (b / c)))
else if (c <= 450000000.0d0) then
tmp = (b / d) + ((c * (a / d)) / d)
else
tmp = (a / c) + (1.0d0 / ((c / d) * (c / b)))
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -1.15e+91) {
tmp = (a / c) + (d / (c / (b / c)));
} else if (c <= 450000000.0) {
tmp = (b / d) + ((c * (a / d)) / d);
} else {
tmp = (a / c) + (1.0 / ((c / d) * (c / b)));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -1.15e+91: tmp = (a / c) + (d / (c / (b / c))) elif c <= 450000000.0: tmp = (b / d) + ((c * (a / d)) / d) else: tmp = (a / c) + (1.0 / ((c / d) * (c / b))) return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -1.15e+91) tmp = Float64(Float64(a / c) + Float64(d / Float64(c / Float64(b / c)))); elseif (c <= 450000000.0) tmp = Float64(Float64(b / d) + Float64(Float64(c * Float64(a / d)) / d)); else tmp = Float64(Float64(a / c) + Float64(1.0 / Float64(Float64(c / d) * Float64(c / b)))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -1.15e+91) tmp = (a / c) + (d / (c / (b / c))); elseif (c <= 450000000.0) tmp = (b / d) + ((c * (a / d)) / d); else tmp = (a / c) + (1.0 / ((c / d) * (c / b))); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -1.15e+91], N[(N[(a / c), $MachinePrecision] + N[(d / N[(c / N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 450000000.0], N[(N[(b / d), $MachinePrecision] + N[(N[(c * N[(a / d), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], N[(N[(a / c), $MachinePrecision] + N[(1.0 / N[(N[(c / d), $MachinePrecision] * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.15 \cdot 10^{+91}:\\
\;\;\;\;\frac{a}{c} + \frac{d}{\frac{c}{\frac{b}{c}}}\\
\mathbf{elif}\;c \leq 450000000:\\
\;\;\;\;\frac{b}{d} + \frac{c \cdot \frac{a}{d}}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{1}{\frac{c}{d} \cdot \frac{c}{b}}\\
\end{array}
\end{array}
if c < -1.14999999999999996e91Initial program 35.6%
Taylor expanded in c around inf 64.1%
unpow264.1%
associate-/l*67.4%
Simplified67.4%
Taylor expanded in c around 0 67.4%
*-rgt-identity67.4%
associate-*r/67.4%
unpow267.4%
associate-*l*77.1%
associate-*r/77.0%
*-rgt-identity77.0%
Simplified77.0%
clear-num77.1%
un-div-inv77.1%
Applied egg-rr77.1%
if -1.14999999999999996e91 < c < 4.5e8Initial program 68.9%
Taylor expanded in c around 0 69.2%
unpow269.2%
times-frac75.5%
Simplified75.5%
associate-*l/76.2%
Applied egg-rr76.2%
if 4.5e8 < c Initial program 43.4%
Taylor expanded in c around inf 68.0%
unpow268.0%
associate-/l*70.1%
Simplified70.1%
clear-num70.2%
inv-pow70.2%
Applied egg-rr70.2%
unpow-170.2%
unpow270.2%
associate-/r*68.0%
unpow268.0%
times-frac81.4%
Simplified81.4%
Final simplification77.6%
(FPCore (a b c d)
:precision binary64
(if (<= c -1.15e+91)
(+ (/ a c) (/ d (/ c (/ b c))))
(if (<= c 31000000.0)
(+ (/ b d) (/ (* c (/ a d)) d))
(+ (/ a c) (/ 1.0 (/ c (/ b (/ c d))))))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -1.15e+91) {
tmp = (a / c) + (d / (c / (b / c)));
} else if (c <= 31000000.0) {
tmp = (b / d) + ((c * (a / d)) / d);
} else {
tmp = (a / c) + (1.0 / (c / (b / (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 (c <= (-1.15d+91)) then
tmp = (a / c) + (d / (c / (b / c)))
else if (c <= 31000000.0d0) then
tmp = (b / d) + ((c * (a / d)) / d)
else
tmp = (a / c) + (1.0d0 / (c / (b / (c / d))))
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -1.15e+91) {
tmp = (a / c) + (d / (c / (b / c)));
} else if (c <= 31000000.0) {
tmp = (b / d) + ((c * (a / d)) / d);
} else {
tmp = (a / c) + (1.0 / (c / (b / (c / d))));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -1.15e+91: tmp = (a / c) + (d / (c / (b / c))) elif c <= 31000000.0: tmp = (b / d) + ((c * (a / d)) / d) else: tmp = (a / c) + (1.0 / (c / (b / (c / d)))) return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -1.15e+91) tmp = Float64(Float64(a / c) + Float64(d / Float64(c / Float64(b / c)))); elseif (c <= 31000000.0) tmp = Float64(Float64(b / d) + Float64(Float64(c * Float64(a / d)) / d)); else tmp = Float64(Float64(a / c) + Float64(1.0 / Float64(c / Float64(b / Float64(c / d))))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -1.15e+91) tmp = (a / c) + (d / (c / (b / c))); elseif (c <= 31000000.0) tmp = (b / d) + ((c * (a / d)) / d); else tmp = (a / c) + (1.0 / (c / (b / (c / d)))); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -1.15e+91], N[(N[(a / c), $MachinePrecision] + N[(d / N[(c / N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 31000000.0], N[(N[(b / d), $MachinePrecision] + N[(N[(c * N[(a / d), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], N[(N[(a / c), $MachinePrecision] + N[(1.0 / N[(c / N[(b / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.15 \cdot 10^{+91}:\\
\;\;\;\;\frac{a}{c} + \frac{d}{\frac{c}{\frac{b}{c}}}\\
\mathbf{elif}\;c \leq 31000000:\\
\;\;\;\;\frac{b}{d} + \frac{c \cdot \frac{a}{d}}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{1}{\frac{c}{\frac{b}{\frac{c}{d}}}}\\
\end{array}
\end{array}
if c < -1.14999999999999996e91Initial program 35.6%
Taylor expanded in c around inf 64.1%
unpow264.1%
associate-/l*67.4%
Simplified67.4%
Taylor expanded in c around 0 67.4%
*-rgt-identity67.4%
associate-*r/67.4%
unpow267.4%
associate-*l*77.1%
associate-*r/77.0%
*-rgt-identity77.0%
Simplified77.0%
clear-num77.1%
un-div-inv77.1%
Applied egg-rr77.1%
if -1.14999999999999996e91 < c < 3.1e7Initial program 68.9%
Taylor expanded in c around 0 69.2%
unpow269.2%
times-frac75.5%
Simplified75.5%
associate-*l/76.2%
Applied egg-rr76.2%
if 3.1e7 < c Initial program 43.4%
Taylor expanded in c around inf 68.0%
unpow268.0%
associate-/l*70.1%
Simplified70.1%
clear-num70.2%
inv-pow70.2%
Applied egg-rr70.2%
unpow-170.2%
unpow270.2%
associate-/r*68.0%
unpow268.0%
times-frac81.4%
Simplified81.4%
associate-*l/78.4%
associate-/l*81.5%
Applied egg-rr81.5%
Final simplification77.6%
(FPCore (a b c d) :precision binary64 (if (<= d -6.5e+142) (/ b d) (if (<= d 3.05e+66) (+ (/ a c) (* (/ b c) (/ d c))) (/ b d))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -6.5e+142) {
tmp = b / d;
} else if (d <= 3.05e+66) {
tmp = (a / c) + ((b / c) * (d / c));
} else {
tmp = b / 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 <= (-6.5d+142)) then
tmp = b / d
else if (d <= 3.05d+66) then
tmp = (a / c) + ((b / c) * (d / c))
else
tmp = b / d
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (d <= -6.5e+142) {
tmp = b / d;
} else if (d <= 3.05e+66) {
tmp = (a / c) + ((b / c) * (d / c));
} else {
tmp = b / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -6.5e+142: tmp = b / d elif d <= 3.05e+66: tmp = (a / c) + ((b / c) * (d / c)) else: tmp = b / d return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -6.5e+142) tmp = Float64(b / d); elseif (d <= 3.05e+66) tmp = Float64(Float64(a / c) + Float64(Float64(b / c) * Float64(d / c))); else tmp = Float64(b / d); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= -6.5e+142) tmp = b / d; elseif (d <= 3.05e+66) tmp = (a / c) + ((b / c) * (d / c)); else tmp = b / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -6.5e+142], N[(b / d), $MachinePrecision], If[LessEqual[d, 3.05e+66], N[(N[(a / c), $MachinePrecision] + N[(N[(b / c), $MachinePrecision] * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(b / d), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -6.5 \cdot 10^{+142}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{elif}\;d \leq 3.05 \cdot 10^{+66}:\\
\;\;\;\;\frac{a}{c} + \frac{b}{c} \cdot \frac{d}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d}\\
\end{array}
\end{array}
if d < -6.4999999999999997e142 or 3.0500000000000001e66 < d Initial program 34.6%
Taylor expanded in c around 0 69.3%
if -6.4999999999999997e142 < d < 3.0500000000000001e66Initial program 71.3%
Taylor expanded in c around inf 57.8%
unpow257.8%
times-frac65.3%
Simplified65.3%
Final simplification66.7%
(FPCore (a b c d)
:precision binary64
(if (<= c -1.15e+91)
(+ (/ a c) (/ d (/ c (/ b c))))
(if (<= c 15000000.0)
(+ (/ b d) (* (/ a d) (/ c d)))
(+ (/ a c) (* (/ b c) (/ d c))))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -1.15e+91) {
tmp = (a / c) + (d / (c / (b / c)));
} else if (c <= 15000000.0) {
tmp = (b / d) + ((a / d) * (c / d));
} else {
tmp = (a / c) + ((b / c) * (d / 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.15d+91)) then
tmp = (a / c) + (d / (c / (b / c)))
else if (c <= 15000000.0d0) then
tmp = (b / d) + ((a / d) * (c / d))
else
tmp = (a / c) + ((b / c) * (d / c))
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -1.15e+91) {
tmp = (a / c) + (d / (c / (b / c)));
} else if (c <= 15000000.0) {
tmp = (b / d) + ((a / d) * (c / d));
} else {
tmp = (a / c) + ((b / c) * (d / c));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -1.15e+91: tmp = (a / c) + (d / (c / (b / c))) elif c <= 15000000.0: tmp = (b / d) + ((a / d) * (c / d)) else: tmp = (a / c) + ((b / c) * (d / c)) return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -1.15e+91) tmp = Float64(Float64(a / c) + Float64(d / Float64(c / Float64(b / c)))); elseif (c <= 15000000.0) tmp = Float64(Float64(b / d) + Float64(Float64(a / d) * Float64(c / d))); else tmp = Float64(Float64(a / c) + Float64(Float64(b / c) * Float64(d / c))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -1.15e+91) tmp = (a / c) + (d / (c / (b / c))); elseif (c <= 15000000.0) tmp = (b / d) + ((a / d) * (c / d)); else tmp = (a / c) + ((b / c) * (d / c)); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -1.15e+91], N[(N[(a / c), $MachinePrecision] + N[(d / N[(c / N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 15000000.0], N[(N[(b / d), $MachinePrecision] + N[(N[(a / d), $MachinePrecision] * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a / c), $MachinePrecision] + N[(N[(b / c), $MachinePrecision] * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.15 \cdot 10^{+91}:\\
\;\;\;\;\frac{a}{c} + \frac{d}{\frac{c}{\frac{b}{c}}}\\
\mathbf{elif}\;c \leq 15000000:\\
\;\;\;\;\frac{b}{d} + \frac{a}{d} \cdot \frac{c}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{b}{c} \cdot \frac{d}{c}\\
\end{array}
\end{array}
if c < -1.14999999999999996e91Initial program 35.6%
Taylor expanded in c around inf 64.1%
unpow264.1%
associate-/l*67.4%
Simplified67.4%
Taylor expanded in c around 0 67.4%
*-rgt-identity67.4%
associate-*r/67.4%
unpow267.4%
associate-*l*77.1%
associate-*r/77.0%
*-rgt-identity77.0%
Simplified77.0%
clear-num77.1%
un-div-inv77.1%
Applied egg-rr77.1%
if -1.14999999999999996e91 < c < 1.5e7Initial program 68.9%
Taylor expanded in c around 0 69.2%
unpow269.2%
times-frac75.5%
Simplified75.5%
if 1.5e7 < c Initial program 43.4%
Taylor expanded in c around inf 68.0%
unpow268.0%
times-frac81.4%
Simplified81.4%
Final simplification77.1%
(FPCore (a b c d)
:precision binary64
(if (<= c -1.15e+91)
(+ (/ a c) (/ d (/ c (/ b c))))
(if (<= c 5.2e-51)
(+ (/ b d) (/ a (* d (/ d c))))
(+ (/ a c) (* (/ b c) (/ d c))))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -1.15e+91) {
tmp = (a / c) + (d / (c / (b / c)));
} else if (c <= 5.2e-51) {
tmp = (b / d) + (a / (d * (d / c)));
} else {
tmp = (a / c) + ((b / c) * (d / 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.15d+91)) then
tmp = (a / c) + (d / (c / (b / c)))
else if (c <= 5.2d-51) then
tmp = (b / d) + (a / (d * (d / c)))
else
tmp = (a / c) + ((b / c) * (d / c))
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -1.15e+91) {
tmp = (a / c) + (d / (c / (b / c)));
} else if (c <= 5.2e-51) {
tmp = (b / d) + (a / (d * (d / c)));
} else {
tmp = (a / c) + ((b / c) * (d / c));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -1.15e+91: tmp = (a / c) + (d / (c / (b / c))) elif c <= 5.2e-51: tmp = (b / d) + (a / (d * (d / c))) else: tmp = (a / c) + ((b / c) * (d / c)) return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -1.15e+91) tmp = Float64(Float64(a / c) + Float64(d / Float64(c / Float64(b / c)))); elseif (c <= 5.2e-51) tmp = Float64(Float64(b / d) + Float64(a / Float64(d * Float64(d / c)))); else tmp = Float64(Float64(a / c) + Float64(Float64(b / c) * Float64(d / c))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -1.15e+91) tmp = (a / c) + (d / (c / (b / c))); elseif (c <= 5.2e-51) tmp = (b / d) + (a / (d * (d / c))); else tmp = (a / c) + ((b / c) * (d / c)); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -1.15e+91], N[(N[(a / c), $MachinePrecision] + N[(d / N[(c / N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 5.2e-51], N[(N[(b / d), $MachinePrecision] + N[(a / N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a / c), $MachinePrecision] + N[(N[(b / c), $MachinePrecision] * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.15 \cdot 10^{+91}:\\
\;\;\;\;\frac{a}{c} + \frac{d}{\frac{c}{\frac{b}{c}}}\\
\mathbf{elif}\;c \leq 5.2 \cdot 10^{-51}:\\
\;\;\;\;\frac{b}{d} + \frac{a}{d \cdot \frac{d}{c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{b}{c} \cdot \frac{d}{c}\\
\end{array}
\end{array}
if c < -1.14999999999999996e91Initial program 35.6%
Taylor expanded in c around inf 64.1%
unpow264.1%
associate-/l*67.4%
Simplified67.4%
Taylor expanded in c around 0 67.4%
*-rgt-identity67.4%
associate-*r/67.4%
unpow267.4%
associate-*l*77.1%
associate-*r/77.0%
*-rgt-identity77.0%
Simplified77.0%
clear-num77.1%
un-div-inv77.1%
Applied egg-rr77.1%
if -1.14999999999999996e91 < c < 5.2e-51Initial program 69.3%
Taylor expanded in c around 0 71.4%
unpow271.4%
times-frac77.7%
Simplified77.7%
clear-num76.6%
frac-times78.5%
*-un-lft-identity78.5%
Applied egg-rr78.5%
if 5.2e-51 < c Initial program 47.5%
Taylor expanded in c around inf 64.9%
unpow264.9%
times-frac75.8%
Simplified75.8%
Final simplification77.5%
(FPCore (a b c d)
:precision binary64
(if (<= c -1.15e+91)
(+ (/ a c) (/ d (/ c (/ b c))))
(if (<= c 175000000.0)
(+ (/ b d) (/ (* c (/ a d)) d))
(+ (/ a c) (* (/ b c) (/ d c))))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -1.15e+91) {
tmp = (a / c) + (d / (c / (b / c)));
} else if (c <= 175000000.0) {
tmp = (b / d) + ((c * (a / d)) / d);
} else {
tmp = (a / c) + ((b / c) * (d / 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.15d+91)) then
tmp = (a / c) + (d / (c / (b / c)))
else if (c <= 175000000.0d0) then
tmp = (b / d) + ((c * (a / d)) / d)
else
tmp = (a / c) + ((b / c) * (d / c))
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -1.15e+91) {
tmp = (a / c) + (d / (c / (b / c)));
} else if (c <= 175000000.0) {
tmp = (b / d) + ((c * (a / d)) / d);
} else {
tmp = (a / c) + ((b / c) * (d / c));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -1.15e+91: tmp = (a / c) + (d / (c / (b / c))) elif c <= 175000000.0: tmp = (b / d) + ((c * (a / d)) / d) else: tmp = (a / c) + ((b / c) * (d / c)) return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -1.15e+91) tmp = Float64(Float64(a / c) + Float64(d / Float64(c / Float64(b / c)))); elseif (c <= 175000000.0) tmp = Float64(Float64(b / d) + Float64(Float64(c * Float64(a / d)) / d)); else tmp = Float64(Float64(a / c) + Float64(Float64(b / c) * Float64(d / c))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -1.15e+91) tmp = (a / c) + (d / (c / (b / c))); elseif (c <= 175000000.0) tmp = (b / d) + ((c * (a / d)) / d); else tmp = (a / c) + ((b / c) * (d / c)); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -1.15e+91], N[(N[(a / c), $MachinePrecision] + N[(d / N[(c / N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 175000000.0], N[(N[(b / d), $MachinePrecision] + N[(N[(c * N[(a / d), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], N[(N[(a / c), $MachinePrecision] + N[(N[(b / c), $MachinePrecision] * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.15 \cdot 10^{+91}:\\
\;\;\;\;\frac{a}{c} + \frac{d}{\frac{c}{\frac{b}{c}}}\\
\mathbf{elif}\;c \leq 175000000:\\
\;\;\;\;\frac{b}{d} + \frac{c \cdot \frac{a}{d}}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{b}{c} \cdot \frac{d}{c}\\
\end{array}
\end{array}
if c < -1.14999999999999996e91Initial program 35.6%
Taylor expanded in c around inf 64.1%
unpow264.1%
associate-/l*67.4%
Simplified67.4%
Taylor expanded in c around 0 67.4%
*-rgt-identity67.4%
associate-*r/67.4%
unpow267.4%
associate-*l*77.1%
associate-*r/77.0%
*-rgt-identity77.0%
Simplified77.0%
clear-num77.1%
un-div-inv77.1%
Applied egg-rr77.1%
if -1.14999999999999996e91 < c < 1.75e8Initial program 68.9%
Taylor expanded in c around 0 69.2%
unpow269.2%
times-frac75.5%
Simplified75.5%
associate-*l/76.2%
Applied egg-rr76.2%
if 1.75e8 < c Initial program 43.4%
Taylor expanded in c around inf 68.0%
unpow268.0%
times-frac81.4%
Simplified81.4%
Final simplification77.6%
(FPCore (a b c d)
:precision binary64
(if (<= c -1.15e+91)
(/ a c)
(if (<= c 1.15e-144)
(/ b d)
(if (<= c 7.2e-110)
(/ a (/ (* d d) c))
(if (<= c 1.3e-50) (/ b d) (/ a c))))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -1.15e+91) {
tmp = a / c;
} else if (c <= 1.15e-144) {
tmp = b / d;
} else if (c <= 7.2e-110) {
tmp = a / ((d * d) / c);
} else if (c <= 1.3e-50) {
tmp = b / d;
} else {
tmp = a / c;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (c <= (-1.15d+91)) then
tmp = a / c
else if (c <= 1.15d-144) then
tmp = b / d
else if (c <= 7.2d-110) then
tmp = a / ((d * d) / c)
else if (c <= 1.3d-50) then
tmp = b / d
else
tmp = a / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -1.15e+91) {
tmp = a / c;
} else if (c <= 1.15e-144) {
tmp = b / d;
} else if (c <= 7.2e-110) {
tmp = a / ((d * d) / c);
} else if (c <= 1.3e-50) {
tmp = b / d;
} else {
tmp = a / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -1.15e+91: tmp = a / c elif c <= 1.15e-144: tmp = b / d elif c <= 7.2e-110: tmp = a / ((d * d) / c) elif c <= 1.3e-50: tmp = b / d else: tmp = a / c return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -1.15e+91) tmp = Float64(a / c); elseif (c <= 1.15e-144) tmp = Float64(b / d); elseif (c <= 7.2e-110) tmp = Float64(a / Float64(Float64(d * d) / c)); elseif (c <= 1.3e-50) tmp = Float64(b / d); else tmp = Float64(a / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -1.15e+91) tmp = a / c; elseif (c <= 1.15e-144) tmp = b / d; elseif (c <= 7.2e-110) tmp = a / ((d * d) / c); elseif (c <= 1.3e-50) tmp = b / d; else tmp = a / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -1.15e+91], N[(a / c), $MachinePrecision], If[LessEqual[c, 1.15e-144], N[(b / d), $MachinePrecision], If[LessEqual[c, 7.2e-110], N[(a / N[(N[(d * d), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.3e-50], N[(b / d), $MachinePrecision], N[(a / c), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.15 \cdot 10^{+91}:\\
\;\;\;\;\frac{a}{c}\\
\mathbf{elif}\;c \leq 1.15 \cdot 10^{-144}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{elif}\;c \leq 7.2 \cdot 10^{-110}:\\
\;\;\;\;\frac{a}{\frac{d \cdot d}{c}}\\
\mathbf{elif}\;c \leq 1.3 \cdot 10^{-50}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c}\\
\end{array}
\end{array}
if c < -1.14999999999999996e91 or 1.3000000000000001e-50 < c Initial program 43.2%
Taylor expanded in c around inf 60.1%
if -1.14999999999999996e91 < c < 1.15e-144 or 7.1999999999999999e-110 < c < 1.3000000000000001e-50Initial program 68.4%
Taylor expanded in c around 0 60.1%
if 1.15e-144 < c < 7.1999999999999999e-110Initial program 99.7%
Taylor expanded in a around inf 99.7%
*-commutative99.7%
associate-/l*99.7%
unpow299.7%
unpow299.7%
fma-udef99.7%
Simplified99.7%
Taylor expanded in d around inf 99.7%
unpow299.7%
Simplified99.7%
Final simplification60.9%
(FPCore (a b c d) :precision binary64 (if (<= c -5.8e+91) (/ a c) (if (<= c 1.3e-50) (/ b d) (/ a c))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -5.8e+91) {
tmp = a / c;
} else if (c <= 1.3e-50) {
tmp = b / d;
} else {
tmp = a / c;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (c <= (-5.8d+91)) then
tmp = a / c
else if (c <= 1.3d-50) then
tmp = b / d
else
tmp = a / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -5.8e+91) {
tmp = a / c;
} else if (c <= 1.3e-50) {
tmp = b / d;
} else {
tmp = a / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -5.8e+91: tmp = a / c elif c <= 1.3e-50: tmp = b / d else: tmp = a / c return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -5.8e+91) tmp = Float64(a / c); elseif (c <= 1.3e-50) tmp = Float64(b / d); else tmp = Float64(a / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -5.8e+91) tmp = a / c; elseif (c <= 1.3e-50) tmp = b / d; else tmp = a / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -5.8e+91], N[(a / c), $MachinePrecision], If[LessEqual[c, 1.3e-50], N[(b / d), $MachinePrecision], N[(a / c), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -5.8 \cdot 10^{+91}:\\
\;\;\;\;\frac{a}{c}\\
\mathbf{elif}\;c \leq 1.3 \cdot 10^{-50}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c}\\
\end{array}
\end{array}
if c < -5.80000000000000028e91 or 1.3000000000000001e-50 < c Initial program 43.2%
Taylor expanded in c around inf 60.1%
if -5.80000000000000028e91 < c < 1.3000000000000001e-50Initial program 69.5%
Taylor expanded in c around 0 58.2%
Final simplification59.0%
(FPCore (a b c d) :precision binary64 (/ a c))
double code(double a, double b, double c, double d) {
return a / c;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = a / c
end function
public static double code(double a, double b, double c, double d) {
return a / c;
}
def code(a, b, c, d): return a / c
function code(a, b, c, d) return Float64(a / c) end
function tmp = code(a, b, c, d) tmp = a / c; end
code[a_, b_, c_, d_] := N[(a / c), $MachinePrecision]
\begin{array}{l}
\\
\frac{a}{c}
\end{array}
Initial program 58.3%
Taylor expanded in c around inf 36.0%
Final simplification36.0%
(FPCore (a b c d) :precision binary64 (if (< (fabs d) (fabs c)) (/ (+ a (* b (/ d c))) (+ c (* d (/ d c)))) (/ (+ b (* a (/ c d))) (+ d (* c (/ c d))))))
double code(double a, double b, double c, double d) {
double tmp;
if (fabs(d) < fabs(c)) {
tmp = (a + (b * (d / c))) / (c + (d * (d / c)));
} else {
tmp = (b + (a * (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 = (a + (b * (d / c))) / (c + (d * (d / c)))
else
tmp = (b + (a * (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 = (a + (b * (d / c))) / (c + (d * (d / c)));
} else {
tmp = (b + (a * (c / d))) / (d + (c * (c / d)));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if math.fabs(d) < math.fabs(c): tmp = (a + (b * (d / c))) / (c + (d * (d / c))) else: tmp = (b + (a * (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(a + Float64(b * Float64(d / c))) / Float64(c + Float64(d * Float64(d / c)))); else tmp = Float64(Float64(b + Float64(a * 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 = (a + (b * (d / c))) / (c + (d * (d / c))); else tmp = (b + (a * (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[(a + N[(b * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(c + N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b + N[(a * 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{a + b \cdot \frac{d}{c}}{c + d \cdot \frac{d}{c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d + c \cdot \frac{c}{d}}\\
\end{array}
\end{array}
herbie shell --seed 2023238
(FPCore (a b c d)
:name "Complex division, real part"
:precision binary64
:herbie-target
(if (< (fabs d) (fabs c)) (/ (+ a (* b (/ d c))) (+ c (* d (/ d c)))) (/ (+ b (* a (/ c d))) (+ d (* c (/ c d)))))
(/ (+ (* a c) (* b d)) (+ (* c c) (* d d))))