
(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 12 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
(let* ((t_0 (+ (* c c) (* d d))) (t_1 (fma d d (* c c))))
(if (<= c -3.2e+101)
(* (/ -1.0 c) (- (* d (- (/ b c))) a))
(if (<= c -1.75e-143)
(+ (/ b (/ t_0 d)) (/ a (/ t_0 c)))
(if (<= c 5.8e-161)
(* (/ d d) (/ (+ b (* c (/ a d))) d))
(if (<= c 3.9e+138)
(+ (/ b (/ t_1 d)) (* c (/ a t_1)))
(+ (/ a c) (* (/ b c) (/ d c)))))))))
double code(double a, double b, double c, double d) {
double t_0 = (c * c) + (d * d);
double t_1 = fma(d, d, (c * c));
double tmp;
if (c <= -3.2e+101) {
tmp = (-1.0 / c) * ((d * -(b / c)) - a);
} else if (c <= -1.75e-143) {
tmp = (b / (t_0 / d)) + (a / (t_0 / c));
} else if (c <= 5.8e-161) {
tmp = (d / d) * ((b + (c * (a / d))) / d);
} else if (c <= 3.9e+138) {
tmp = (b / (t_1 / d)) + (c * (a / t_1));
} else {
tmp = (a / c) + ((b / c) * (d / c));
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(c * c) + Float64(d * d)) t_1 = fma(d, d, Float64(c * c)) tmp = 0.0 if (c <= -3.2e+101) tmp = Float64(Float64(-1.0 / c) * Float64(Float64(d * Float64(-Float64(b / c))) - a)); elseif (c <= -1.75e-143) tmp = Float64(Float64(b / Float64(t_0 / d)) + Float64(a / Float64(t_0 / c))); elseif (c <= 5.8e-161) tmp = Float64(Float64(d / d) * Float64(Float64(b + Float64(c * Float64(a / d))) / d)); elseif (c <= 3.9e+138) tmp = Float64(Float64(b / Float64(t_1 / d)) + Float64(c * Float64(a / t_1))); else tmp = Float64(Float64(a / c) + Float64(Float64(b / c) * Float64(d / c))); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -3.2e+101], N[(N[(-1.0 / c), $MachinePrecision] * N[(N[(d * (-N[(b / c), $MachinePrecision])), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -1.75e-143], N[(N[(b / N[(t$95$0 / d), $MachinePrecision]), $MachinePrecision] + N[(a / N[(t$95$0 / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 5.8e-161], N[(N[(d / d), $MachinePrecision] * N[(N[(b + N[(c * N[(a / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 3.9e+138], N[(N[(b / N[(t$95$1 / d), $MachinePrecision]), $MachinePrecision] + N[(c * N[(a / t$95$1), $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}
t_0 := c \cdot c + d \cdot d\\
t_1 := \mathsf{fma}\left(d, d, c \cdot c\right)\\
\mathbf{if}\;c \leq -3.2 \cdot 10^{+101}:\\
\;\;\;\;\frac{-1}{c} \cdot \left(d \cdot \left(-\frac{b}{c}\right) - a\right)\\
\mathbf{elif}\;c \leq -1.75 \cdot 10^{-143}:\\
\;\;\;\;\frac{b}{\frac{t_0}{d}} + \frac{a}{\frac{t_0}{c}}\\
\mathbf{elif}\;c \leq 5.8 \cdot 10^{-161}:\\
\;\;\;\;\frac{d}{d} \cdot \frac{b + c \cdot \frac{a}{d}}{d}\\
\mathbf{elif}\;c \leq 3.9 \cdot 10^{+138}:\\
\;\;\;\;\frac{b}{\frac{t_1}{d}} + c \cdot \frac{a}{t_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{b}{c} \cdot \frac{d}{c}\\
\end{array}
\end{array}
if c < -3.20000000000000005e101Initial program 25.4%
*-un-lft-identity25.4%
add-sqr-sqrt25.4%
times-frac25.3%
hypot-def25.3%
fma-def25.3%
hypot-def42.1%
Applied egg-rr42.1%
Taylor expanded in c around -inf 78.8%
distribute-lft-out78.8%
associate-/l*84.0%
Simplified84.0%
Taylor expanded in c around -inf 83.7%
associate-/r/86.2%
Applied egg-rr86.2%
if -3.20000000000000005e101 < c < -1.75000000000000003e-143Initial program 83.9%
*-un-lft-identity83.9%
add-sqr-sqrt83.9%
times-frac84.0%
hypot-def84.0%
fma-def84.0%
hypot-def92.4%
Applied egg-rr92.4%
Taylor expanded in a around 0 83.9%
+-commutative83.9%
associate-/l*84.3%
unpow284.3%
unpow284.3%
associate-/l*88.0%
unpow288.0%
unpow288.0%
Simplified88.0%
if -1.75000000000000003e-143 < c < 5.8e-161Initial program 68.4%
Taylor expanded in c around 0 82.9%
*-commutative82.9%
unpow282.9%
Simplified82.9%
+-commutative82.9%
associate-/r*89.0%
frac-add68.4%
*-commutative68.4%
*-commutative68.4%
Applied egg-rr68.4%
distribute-rgt-out68.4%
+-commutative68.4%
times-frac90.5%
*-commutative90.5%
associate-*r/90.5%
Simplified90.5%
if 5.8e-161 < c < 3.8999999999999998e138Initial program 72.0%
Taylor expanded in a around 0 72.0%
+-commutative72.0%
associate-/l*77.4%
+-commutative77.4%
unpow277.4%
fma-def77.4%
unpow277.4%
associate-/l*81.1%
associate-/r/81.1%
+-commutative81.1%
unpow281.1%
fma-def81.1%
unpow281.1%
Simplified81.1%
if 3.8999999999999998e138 < c Initial program 23.7%
*-un-lft-identity23.7%
add-sqr-sqrt23.7%
times-frac23.7%
hypot-def23.7%
fma-def23.7%
hypot-def36.8%
Applied egg-rr36.8%
Taylor expanded in c around inf 85.6%
*-commutative85.6%
unpow285.6%
times-frac97.6%
Simplified97.6%
Final simplification88.4%
(FPCore (a b c d) :precision binary64 (if (<= (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))) 2.5e+245) (* (/ 1.0 (hypot c d)) (/ (fma a c (* b d)) (hypot c d))) (* (/ -1.0 c) (- (* d (- (/ b c))) a))))
double code(double a, double b, double c, double d) {
double tmp;
if ((((a * c) + (b * d)) / ((c * c) + (d * d))) <= 2.5e+245) {
tmp = (1.0 / hypot(c, d)) * (fma(a, c, (b * d)) / hypot(c, d));
} else {
tmp = (-1.0 / c) * ((d * -(b / c)) - a);
}
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))) <= 2.5e+245) tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(fma(a, c, Float64(b * d)) / hypot(c, d))); else tmp = Float64(Float64(-1.0 / c) * Float64(Float64(d * Float64(-Float64(b / c))) - a)); 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], 2.5e+245], 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[(N[(-1.0 / c), $MachinePrecision] * N[(N[(d * (-N[(b / c), $MachinePrecision])), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \leq 2.5 \cdot 10^{+245}:\\
\;\;\;\;\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}:\\
\;\;\;\;\frac{-1}{c} \cdot \left(d \cdot \left(-\frac{b}{c}\right) - a\right)\\
\end{array}
\end{array}
if (/.f64 (+.f64 (*.f64 a c) (*.f64 b d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 2.50000000000000017e245Initial program 77.2%
*-un-lft-identity77.2%
add-sqr-sqrt77.2%
times-frac77.3%
hypot-def77.3%
fma-def77.3%
hypot-def94.8%
Applied egg-rr94.8%
if 2.50000000000000017e245 < (/.f64 (+.f64 (*.f64 a c) (*.f64 b d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 18.3%
*-un-lft-identity18.3%
add-sqr-sqrt18.3%
times-frac18.3%
hypot-def18.3%
fma-def18.3%
hypot-def21.6%
Applied egg-rr21.6%
Taylor expanded in c around -inf 33.3%
distribute-lft-out33.3%
associate-/l*36.9%
Simplified36.9%
Taylor expanded in c around -inf 73.5%
associate-/r/73.5%
Applied egg-rr73.5%
Final simplification88.3%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (+ (* c c) (* d d))) (t_1 (+ (/ b (/ t_0 d)) (/ a (/ t_0 c)))))
(if (<= c -7.5e+103)
(* (/ -1.0 c) (- (* d (- (/ b c))) a))
(if (<= c -3.8e-143)
t_1
(if (<= c 5.5e-161)
(* (/ d d) (/ (+ b (* c (/ a d))) d))
(if (<= c 3.6e+138) t_1 (+ (/ a c) (* (/ b c) (/ d c)))))))))
double code(double a, double b, double c, double d) {
double t_0 = (c * c) + (d * d);
double t_1 = (b / (t_0 / d)) + (a / (t_0 / c));
double tmp;
if (c <= -7.5e+103) {
tmp = (-1.0 / c) * ((d * -(b / c)) - a);
} else if (c <= -3.8e-143) {
tmp = t_1;
} else if (c <= 5.5e-161) {
tmp = (d / d) * ((b + (c * (a / d))) / d);
} else if (c <= 3.6e+138) {
tmp = t_1;
} 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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (c * c) + (d * d)
t_1 = (b / (t_0 / d)) + (a / (t_0 / c))
if (c <= (-7.5d+103)) then
tmp = ((-1.0d0) / c) * ((d * -(b / c)) - a)
else if (c <= (-3.8d-143)) then
tmp = t_1
else if (c <= 5.5d-161) then
tmp = (d / d) * ((b + (c * (a / d))) / d)
else if (c <= 3.6d+138) then
tmp = t_1
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 t_0 = (c * c) + (d * d);
double t_1 = (b / (t_0 / d)) + (a / (t_0 / c));
double tmp;
if (c <= -7.5e+103) {
tmp = (-1.0 / c) * ((d * -(b / c)) - a);
} else if (c <= -3.8e-143) {
tmp = t_1;
} else if (c <= 5.5e-161) {
tmp = (d / d) * ((b + (c * (a / d))) / d);
} else if (c <= 3.6e+138) {
tmp = t_1;
} else {
tmp = (a / c) + ((b / c) * (d / c));
}
return tmp;
}
def code(a, b, c, d): t_0 = (c * c) + (d * d) t_1 = (b / (t_0 / d)) + (a / (t_0 / c)) tmp = 0 if c <= -7.5e+103: tmp = (-1.0 / c) * ((d * -(b / c)) - a) elif c <= -3.8e-143: tmp = t_1 elif c <= 5.5e-161: tmp = (d / d) * ((b + (c * (a / d))) / d) elif c <= 3.6e+138: tmp = t_1 else: tmp = (a / c) + ((b / c) * (d / c)) return tmp
function code(a, b, c, d) t_0 = Float64(Float64(c * c) + Float64(d * d)) t_1 = Float64(Float64(b / Float64(t_0 / d)) + Float64(a / Float64(t_0 / c))) tmp = 0.0 if (c <= -7.5e+103) tmp = Float64(Float64(-1.0 / c) * Float64(Float64(d * Float64(-Float64(b / c))) - a)); elseif (c <= -3.8e-143) tmp = t_1; elseif (c <= 5.5e-161) tmp = Float64(Float64(d / d) * Float64(Float64(b + Float64(c * Float64(a / d))) / d)); elseif (c <= 3.6e+138) tmp = t_1; 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) t_0 = (c * c) + (d * d); t_1 = (b / (t_0 / d)) + (a / (t_0 / c)); tmp = 0.0; if (c <= -7.5e+103) tmp = (-1.0 / c) * ((d * -(b / c)) - a); elseif (c <= -3.8e-143) tmp = t_1; elseif (c <= 5.5e-161) tmp = (d / d) * ((b + (c * (a / d))) / d); elseif (c <= 3.6e+138) tmp = t_1; else tmp = (a / c) + ((b / c) * (d / c)); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(b / N[(t$95$0 / d), $MachinePrecision]), $MachinePrecision] + N[(a / N[(t$95$0 / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -7.5e+103], N[(N[(-1.0 / c), $MachinePrecision] * N[(N[(d * (-N[(b / c), $MachinePrecision])), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -3.8e-143], t$95$1, If[LessEqual[c, 5.5e-161], N[(N[(d / d), $MachinePrecision] * N[(N[(b + N[(c * N[(a / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 3.6e+138], t$95$1, N[(N[(a / c), $MachinePrecision] + N[(N[(b / c), $MachinePrecision] * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := c \cdot c + d \cdot d\\
t_1 := \frac{b}{\frac{t_0}{d}} + \frac{a}{\frac{t_0}{c}}\\
\mathbf{if}\;c \leq -7.5 \cdot 10^{+103}:\\
\;\;\;\;\frac{-1}{c} \cdot \left(d \cdot \left(-\frac{b}{c}\right) - a\right)\\
\mathbf{elif}\;c \leq -3.8 \cdot 10^{-143}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;c \leq 5.5 \cdot 10^{-161}:\\
\;\;\;\;\frac{d}{d} \cdot \frac{b + c \cdot \frac{a}{d}}{d}\\
\mathbf{elif}\;c \leq 3.6 \cdot 10^{+138}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{b}{c} \cdot \frac{d}{c}\\
\end{array}
\end{array}
if c < -7.49999999999999922e103Initial program 25.4%
*-un-lft-identity25.4%
add-sqr-sqrt25.4%
times-frac25.3%
hypot-def25.3%
fma-def25.3%
hypot-def42.1%
Applied egg-rr42.1%
Taylor expanded in c around -inf 78.8%
distribute-lft-out78.8%
associate-/l*84.0%
Simplified84.0%
Taylor expanded in c around -inf 83.7%
associate-/r/86.2%
Applied egg-rr86.2%
if -7.49999999999999922e103 < c < -3.79999999999999981e-143 or 5.5e-161 < c < 3.6000000000000001e138Initial program 77.9%
*-un-lft-identity77.9%
add-sqr-sqrt77.9%
times-frac77.9%
hypot-def77.9%
fma-def77.9%
hypot-def86.5%
Applied egg-rr86.5%
Taylor expanded in a around 0 77.8%
+-commutative77.8%
associate-/l*80.8%
unpow280.8%
unpow280.8%
associate-/l*84.5%
unpow284.5%
unpow284.5%
Simplified84.5%
if -3.79999999999999981e-143 < c < 5.5e-161Initial program 68.4%
Taylor expanded in c around 0 82.9%
*-commutative82.9%
unpow282.9%
Simplified82.9%
+-commutative82.9%
associate-/r*89.0%
frac-add68.4%
*-commutative68.4%
*-commutative68.4%
Applied egg-rr68.4%
distribute-rgt-out68.4%
+-commutative68.4%
times-frac90.5%
*-commutative90.5%
associate-*r/90.5%
Simplified90.5%
if 3.6000000000000001e138 < c Initial program 23.7%
*-un-lft-identity23.7%
add-sqr-sqrt23.7%
times-frac23.7%
hypot-def23.7%
fma-def23.7%
hypot-def36.8%
Applied egg-rr36.8%
Taylor expanded in c around inf 85.6%
*-commutative85.6%
unpow285.6%
times-frac97.6%
Simplified97.6%
Final simplification88.4%
(FPCore (a b c d)
:precision binary64
(if (<= d -2e+32)
(+ (/ b d) (/ (/ a d) (/ d c)))
(if (<= d 4.8e+80)
(* (/ -1.0 c) (- (* d (- (/ b c))) a))
(/ b (+ d (* c (/ c d)))))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -2e+32) {
tmp = (b / d) + ((a / d) / (d / c));
} else if (d <= 4.8e+80) {
tmp = (-1.0 / c) * ((d * -(b / c)) - a);
} else {
tmp = b / (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 (d <= (-2d+32)) then
tmp = (b / d) + ((a / d) / (d / c))
else if (d <= 4.8d+80) then
tmp = ((-1.0d0) / c) * ((d * -(b / c)) - a)
else
tmp = b / (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 (d <= -2e+32) {
tmp = (b / d) + ((a / d) / (d / c));
} else if (d <= 4.8e+80) {
tmp = (-1.0 / c) * ((d * -(b / c)) - a);
} else {
tmp = b / (d + (c * (c / d)));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -2e+32: tmp = (b / d) + ((a / d) / (d / c)) elif d <= 4.8e+80: tmp = (-1.0 / c) * ((d * -(b / c)) - a) else: tmp = b / (d + (c * (c / d))) return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -2e+32) tmp = Float64(Float64(b / d) + Float64(Float64(a / d) / Float64(d / c))); elseif (d <= 4.8e+80) tmp = Float64(Float64(-1.0 / c) * Float64(Float64(d * Float64(-Float64(b / c))) - a)); else tmp = Float64(b / Float64(d + Float64(c * Float64(c / d)))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= -2e+32) tmp = (b / d) + ((a / d) / (d / c)); elseif (d <= 4.8e+80) tmp = (-1.0 / c) * ((d * -(b / c)) - a); else tmp = b / (d + (c * (c / d))); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -2e+32], N[(N[(b / d), $MachinePrecision] + N[(N[(a / d), $MachinePrecision] / N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 4.8e+80], N[(N[(-1.0 / c), $MachinePrecision] * N[(N[(d * (-N[(b / c), $MachinePrecision])), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], N[(b / N[(d + N[(c * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -2 \cdot 10^{+32}:\\
\;\;\;\;\frac{b}{d} + \frac{\frac{a}{d}}{\frac{d}{c}}\\
\mathbf{elif}\;d \leq 4.8 \cdot 10^{+80}:\\
\;\;\;\;\frac{-1}{c} \cdot \left(d \cdot \left(-\frac{b}{c}\right) - a\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d + c \cdot \frac{c}{d}}\\
\end{array}
\end{array}
if d < -2.00000000000000011e32Initial program 53.9%
Taylor expanded in c around 0 74.5%
*-commutative74.5%
unpow274.5%
Simplified74.5%
times-frac84.0%
Applied egg-rr84.0%
*-commutative84.0%
clear-num84.0%
un-div-inv84.0%
Applied egg-rr84.0%
if -2.00000000000000011e32 < d < 4.79999999999999958e80Initial program 67.7%
*-un-lft-identity67.7%
add-sqr-sqrt67.7%
times-frac67.7%
hypot-def67.7%
fma-def67.7%
hypot-def76.3%
Applied egg-rr76.3%
Taylor expanded in c around -inf 49.4%
distribute-lft-out49.4%
associate-/l*48.8%
Simplified48.8%
Taylor expanded in c around -inf 82.4%
associate-/r/80.6%
Applied egg-rr80.6%
if 4.79999999999999958e80 < d Initial program 33.4%
Taylor expanded in a around 0 33.5%
associate-/l*42.1%
unpow242.1%
unpow242.1%
Simplified42.1%
Taylor expanded in c around 0 74.9%
unpow274.9%
*-lft-identity74.9%
times-frac85.0%
/-rgt-identity85.0%
Simplified85.0%
Final simplification82.0%
(FPCore (a b c d)
:precision binary64
(if (<= d -2e+31)
(+ (/ b d) (/ (/ a d) (/ d c)))
(if (<= d 3.3e+80)
(* (/ -1.0 c) (- (- a) (/ b (/ c d))))
(/ b (+ d (* c (/ c d)))))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -2e+31) {
tmp = (b / d) + ((a / d) / (d / c));
} else if (d <= 3.3e+80) {
tmp = (-1.0 / c) * (-a - (b / (c / d)));
} else {
tmp = b / (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 (d <= (-2d+31)) then
tmp = (b / d) + ((a / d) / (d / c))
else if (d <= 3.3d+80) then
tmp = ((-1.0d0) / c) * (-a - (b / (c / d)))
else
tmp = b / (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 (d <= -2e+31) {
tmp = (b / d) + ((a / d) / (d / c));
} else if (d <= 3.3e+80) {
tmp = (-1.0 / c) * (-a - (b / (c / d)));
} else {
tmp = b / (d + (c * (c / d)));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -2e+31: tmp = (b / d) + ((a / d) / (d / c)) elif d <= 3.3e+80: tmp = (-1.0 / c) * (-a - (b / (c / d))) else: tmp = b / (d + (c * (c / d))) return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -2e+31) tmp = Float64(Float64(b / d) + Float64(Float64(a / d) / Float64(d / c))); elseif (d <= 3.3e+80) tmp = Float64(Float64(-1.0 / c) * Float64(Float64(-a) - Float64(b / Float64(c / d)))); else tmp = Float64(b / Float64(d + Float64(c * Float64(c / d)))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= -2e+31) tmp = (b / d) + ((a / d) / (d / c)); elseif (d <= 3.3e+80) tmp = (-1.0 / c) * (-a - (b / (c / d))); else tmp = b / (d + (c * (c / d))); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -2e+31], N[(N[(b / d), $MachinePrecision] + N[(N[(a / d), $MachinePrecision] / N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 3.3e+80], N[(N[(-1.0 / c), $MachinePrecision] * N[((-a) - N[(b / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(b / N[(d + N[(c * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -2 \cdot 10^{+31}:\\
\;\;\;\;\frac{b}{d} + \frac{\frac{a}{d}}{\frac{d}{c}}\\
\mathbf{elif}\;d \leq 3.3 \cdot 10^{+80}:\\
\;\;\;\;\frac{-1}{c} \cdot \left(\left(-a\right) - \frac{b}{\frac{c}{d}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d + c \cdot \frac{c}{d}}\\
\end{array}
\end{array}
if d < -1.9999999999999999e31Initial program 53.9%
Taylor expanded in c around 0 74.5%
*-commutative74.5%
unpow274.5%
Simplified74.5%
times-frac84.0%
Applied egg-rr84.0%
*-commutative84.0%
clear-num84.0%
un-div-inv84.0%
Applied egg-rr84.0%
if -1.9999999999999999e31 < d < 3.29999999999999991e80Initial program 67.7%
*-un-lft-identity67.7%
add-sqr-sqrt67.7%
times-frac67.7%
hypot-def67.7%
fma-def67.7%
hypot-def76.3%
Applied egg-rr76.3%
Taylor expanded in c around -inf 49.4%
distribute-lft-out49.4%
associate-/l*48.8%
Simplified48.8%
Taylor expanded in c around -inf 82.4%
if 3.29999999999999991e80 < d Initial program 33.4%
Taylor expanded in a around 0 33.5%
associate-/l*42.1%
unpow242.1%
unpow242.1%
Simplified42.1%
Taylor expanded in c around 0 74.9%
unpow274.9%
*-lft-identity74.9%
times-frac85.0%
/-rgt-identity85.0%
Simplified85.0%
Final simplification83.2%
(FPCore (a b c d) :precision binary64 (if (or (<= d -12000000000000.0) (not (<= d 3.9e+80))) (/ b (+ d (* c (/ c d)))) (+ (/ a c) (* (/ b c) (/ d c)))))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -12000000000000.0) || !(d <= 3.9e+80)) {
tmp = b / (d + (c * (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 ((d <= (-12000000000000.0d0)) .or. (.not. (d <= 3.9d+80))) then
tmp = b / (d + (c * (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 ((d <= -12000000000000.0) || !(d <= 3.9e+80)) {
tmp = b / (d + (c * (c / d)));
} else {
tmp = (a / c) + ((b / c) * (d / c));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -12000000000000.0) or not (d <= 3.9e+80): tmp = b / (d + (c * (c / d))) else: tmp = (a / c) + ((b / c) * (d / c)) return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -12000000000000.0) || !(d <= 3.9e+80)) tmp = Float64(b / Float64(d + Float64(c * 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 ((d <= -12000000000000.0) || ~((d <= 3.9e+80))) tmp = b / (d + (c * (c / d))); else tmp = (a / c) + ((b / c) * (d / c)); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -12000000000000.0], N[Not[LessEqual[d, 3.9e+80]], $MachinePrecision]], N[(b / N[(d + N[(c * N[(c / d), $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}\;d \leq -12000000000000 \lor \neg \left(d \leq 3.9 \cdot 10^{+80}\right):\\
\;\;\;\;\frac{b}{d + c \cdot \frac{c}{d}}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{b}{c} \cdot \frac{d}{c}\\
\end{array}
\end{array}
if d < -1.2e13 or 3.89999999999999999e80 < d Initial program 48.2%
Taylor expanded in a around 0 41.3%
associate-/l*44.9%
unpow244.9%
unpow244.9%
Simplified44.9%
Taylor expanded in c around 0 67.5%
unpow267.5%
*-lft-identity67.5%
times-frac74.0%
/-rgt-identity74.0%
Simplified74.0%
if -1.2e13 < d < 3.89999999999999999e80Initial program 67.0%
*-un-lft-identity67.0%
add-sqr-sqrt67.0%
times-frac67.0%
hypot-def67.1%
fma-def67.1%
hypot-def75.4%
Applied egg-rr75.4%
Taylor expanded in c around inf 75.7%
*-commutative75.7%
unpow275.7%
times-frac80.0%
Simplified80.0%
Final simplification77.5%
(FPCore (a b c d)
:precision binary64
(if (<= d -5e+32)
(+ (/ b d) (* a (/ (/ c d) d)))
(if (<= d 3.4e+80)
(+ (/ a c) (* (/ b c) (/ d c)))
(/ b (+ d (* c (/ c d)))))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -5e+32) {
tmp = (b / d) + (a * ((c / d) / d));
} else if (d <= 3.4e+80) {
tmp = (a / c) + ((b / c) * (d / c));
} else {
tmp = b / (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 (d <= (-5d+32)) then
tmp = (b / d) + (a * ((c / d) / d))
else if (d <= 3.4d+80) then
tmp = (a / c) + ((b / c) * (d / c))
else
tmp = b / (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 (d <= -5e+32) {
tmp = (b / d) + (a * ((c / d) / d));
} else if (d <= 3.4e+80) {
tmp = (a / c) + ((b / c) * (d / c));
} else {
tmp = b / (d + (c * (c / d)));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -5e+32: tmp = (b / d) + (a * ((c / d) / d)) elif d <= 3.4e+80: tmp = (a / c) + ((b / c) * (d / c)) else: tmp = b / (d + (c * (c / d))) return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -5e+32) tmp = Float64(Float64(b / d) + Float64(a * Float64(Float64(c / d) / d))); elseif (d <= 3.4e+80) tmp = Float64(Float64(a / c) + Float64(Float64(b / c) * Float64(d / c))); else tmp = Float64(b / Float64(d + Float64(c * Float64(c / d)))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= -5e+32) tmp = (b / d) + (a * ((c / d) / d)); elseif (d <= 3.4e+80) tmp = (a / c) + ((b / c) * (d / c)); else tmp = b / (d + (c * (c / d))); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -5e+32], N[(N[(b / d), $MachinePrecision] + N[(a * N[(N[(c / d), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 3.4e+80], N[(N[(a / c), $MachinePrecision] + N[(N[(b / c), $MachinePrecision] * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(b / N[(d + N[(c * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -5 \cdot 10^{+32}:\\
\;\;\;\;\frac{b}{d} + a \cdot \frac{\frac{c}{d}}{d}\\
\mathbf{elif}\;d \leq 3.4 \cdot 10^{+80}:\\
\;\;\;\;\frac{a}{c} + \frac{b}{c} \cdot \frac{d}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d + c \cdot \frac{c}{d}}\\
\end{array}
\end{array}
if d < -4.9999999999999997e32Initial program 53.9%
*-un-lft-identity53.9%
add-sqr-sqrt53.9%
times-frac53.9%
hypot-def53.9%
fma-def53.9%
hypot-def71.0%
Applied egg-rr71.0%
Taylor expanded in c around 0 74.5%
unpow274.5%
associate-*r/76.3%
associate-/r*77.9%
Simplified77.9%
if -4.9999999999999997e32 < d < 3.39999999999999992e80Initial program 67.7%
*-un-lft-identity67.7%
add-sqr-sqrt67.7%
times-frac67.7%
hypot-def67.7%
fma-def67.7%
hypot-def76.3%
Applied egg-rr76.3%
Taylor expanded in c around inf 75.4%
*-commutative75.4%
unpow275.4%
times-frac79.6%
Simplified79.6%
if 3.39999999999999992e80 < d Initial program 33.4%
Taylor expanded in a around 0 33.5%
associate-/l*42.1%
unpow242.1%
unpow242.1%
Simplified42.1%
Taylor expanded in c around 0 74.9%
unpow274.9%
*-lft-identity74.9%
times-frac85.0%
/-rgt-identity85.0%
Simplified85.0%
Final simplification80.0%
(FPCore (a b c d)
:precision binary64
(if (<= d -1.5e+31)
(+ (/ b d) (* (/ a d) (/ c d)))
(if (<= d 7.8e+80)
(+ (/ a c) (* (/ b c) (/ d c)))
(/ b (+ d (* c (/ c d)))))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -1.5e+31) {
tmp = (b / d) + ((a / d) * (c / d));
} else if (d <= 7.8e+80) {
tmp = (a / c) + ((b / c) * (d / c));
} else {
tmp = b / (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 (d <= (-1.5d+31)) then
tmp = (b / d) + ((a / d) * (c / d))
else if (d <= 7.8d+80) then
tmp = (a / c) + ((b / c) * (d / c))
else
tmp = b / (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 (d <= -1.5e+31) {
tmp = (b / d) + ((a / d) * (c / d));
} else if (d <= 7.8e+80) {
tmp = (a / c) + ((b / c) * (d / c));
} else {
tmp = b / (d + (c * (c / d)));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -1.5e+31: tmp = (b / d) + ((a / d) * (c / d)) elif d <= 7.8e+80: tmp = (a / c) + ((b / c) * (d / c)) else: tmp = b / (d + (c * (c / d))) return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -1.5e+31) tmp = Float64(Float64(b / d) + Float64(Float64(a / d) * Float64(c / d))); elseif (d <= 7.8e+80) tmp = Float64(Float64(a / c) + Float64(Float64(b / c) * Float64(d / c))); else tmp = Float64(b / Float64(d + Float64(c * Float64(c / d)))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= -1.5e+31) tmp = (b / d) + ((a / d) * (c / d)); elseif (d <= 7.8e+80) tmp = (a / c) + ((b / c) * (d / c)); else tmp = b / (d + (c * (c / d))); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -1.5e+31], N[(N[(b / d), $MachinePrecision] + N[(N[(a / d), $MachinePrecision] * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 7.8e+80], N[(N[(a / c), $MachinePrecision] + N[(N[(b / c), $MachinePrecision] * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(b / N[(d + N[(c * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.5 \cdot 10^{+31}:\\
\;\;\;\;\frac{b}{d} + \frac{a}{d} \cdot \frac{c}{d}\\
\mathbf{elif}\;d \leq 7.8 \cdot 10^{+80}:\\
\;\;\;\;\frac{a}{c} + \frac{b}{c} \cdot \frac{d}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d + c \cdot \frac{c}{d}}\\
\end{array}
\end{array}
if d < -1.49999999999999995e31Initial program 53.9%
Taylor expanded in c around 0 74.5%
*-commutative74.5%
unpow274.5%
Simplified74.5%
times-frac84.0%
Applied egg-rr84.0%
if -1.49999999999999995e31 < d < 7.79999999999999998e80Initial program 67.7%
*-un-lft-identity67.7%
add-sqr-sqrt67.7%
times-frac67.7%
hypot-def67.7%
fma-def67.7%
hypot-def76.3%
Applied egg-rr76.3%
Taylor expanded in c around inf 75.4%
*-commutative75.4%
unpow275.4%
times-frac79.6%
Simplified79.6%
if 7.79999999999999998e80 < d Initial program 33.4%
Taylor expanded in a around 0 33.5%
associate-/l*42.1%
unpow242.1%
unpow242.1%
Simplified42.1%
Taylor expanded in c around 0 74.9%
unpow274.9%
*-lft-identity74.9%
times-frac85.0%
/-rgt-identity85.0%
Simplified85.0%
Final simplification81.4%
(FPCore (a b c d)
:precision binary64
(if (<= d -2.6e+31)
(+ (/ b d) (/ (/ a d) (/ d c)))
(if (<= d 3.3e+80)
(+ (/ a c) (* (/ b c) (/ d c)))
(/ b (+ d (* c (/ c d)))))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -2.6e+31) {
tmp = (b / d) + ((a / d) / (d / c));
} else if (d <= 3.3e+80) {
tmp = (a / c) + ((b / c) * (d / c));
} else {
tmp = b / (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 (d <= (-2.6d+31)) then
tmp = (b / d) + ((a / d) / (d / c))
else if (d <= 3.3d+80) then
tmp = (a / c) + ((b / c) * (d / c))
else
tmp = b / (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 (d <= -2.6e+31) {
tmp = (b / d) + ((a / d) / (d / c));
} else if (d <= 3.3e+80) {
tmp = (a / c) + ((b / c) * (d / c));
} else {
tmp = b / (d + (c * (c / d)));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -2.6e+31: tmp = (b / d) + ((a / d) / (d / c)) elif d <= 3.3e+80: tmp = (a / c) + ((b / c) * (d / c)) else: tmp = b / (d + (c * (c / d))) return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -2.6e+31) tmp = Float64(Float64(b / d) + Float64(Float64(a / d) / Float64(d / c))); elseif (d <= 3.3e+80) tmp = Float64(Float64(a / c) + Float64(Float64(b / c) * Float64(d / c))); else tmp = Float64(b / Float64(d + Float64(c * Float64(c / d)))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= -2.6e+31) tmp = (b / d) + ((a / d) / (d / c)); elseif (d <= 3.3e+80) tmp = (a / c) + ((b / c) * (d / c)); else tmp = b / (d + (c * (c / d))); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -2.6e+31], N[(N[(b / d), $MachinePrecision] + N[(N[(a / d), $MachinePrecision] / N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 3.3e+80], N[(N[(a / c), $MachinePrecision] + N[(N[(b / c), $MachinePrecision] * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(b / N[(d + N[(c * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -2.6 \cdot 10^{+31}:\\
\;\;\;\;\frac{b}{d} + \frac{\frac{a}{d}}{\frac{d}{c}}\\
\mathbf{elif}\;d \leq 3.3 \cdot 10^{+80}:\\
\;\;\;\;\frac{a}{c} + \frac{b}{c} \cdot \frac{d}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d + c \cdot \frac{c}{d}}\\
\end{array}
\end{array}
if d < -2.6e31Initial program 53.9%
Taylor expanded in c around 0 74.5%
*-commutative74.5%
unpow274.5%
Simplified74.5%
times-frac84.0%
Applied egg-rr84.0%
*-commutative84.0%
clear-num84.0%
un-div-inv84.0%
Applied egg-rr84.0%
if -2.6e31 < d < 3.29999999999999991e80Initial program 67.7%
*-un-lft-identity67.7%
add-sqr-sqrt67.7%
times-frac67.7%
hypot-def67.7%
fma-def67.7%
hypot-def76.3%
Applied egg-rr76.3%
Taylor expanded in c around inf 75.4%
*-commutative75.4%
unpow275.4%
times-frac79.6%
Simplified79.6%
if 3.29999999999999991e80 < d Initial program 33.4%
Taylor expanded in a around 0 33.5%
associate-/l*42.1%
unpow242.1%
unpow242.1%
Simplified42.1%
Taylor expanded in c around 0 74.9%
unpow274.9%
*-lft-identity74.9%
times-frac85.0%
/-rgt-identity85.0%
Simplified85.0%
Final simplification81.4%
(FPCore (a b c d) :precision binary64 (if (<= a -8.6e+63) (/ a c) (if (<= a 8e+111) (/ b (+ d (* c (/ c d)))) (/ a c))))
double code(double a, double b, double c, double d) {
double tmp;
if (a <= -8.6e+63) {
tmp = a / c;
} else if (a <= 8e+111) {
tmp = b / (d + (c * (c / 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 (a <= (-8.6d+63)) then
tmp = a / c
else if (a <= 8d+111) then
tmp = b / (d + (c * (c / 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 (a <= -8.6e+63) {
tmp = a / c;
} else if (a <= 8e+111) {
tmp = b / (d + (c * (c / d)));
} else {
tmp = a / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if a <= -8.6e+63: tmp = a / c elif a <= 8e+111: tmp = b / (d + (c * (c / d))) else: tmp = a / c return tmp
function code(a, b, c, d) tmp = 0.0 if (a <= -8.6e+63) tmp = Float64(a / c); elseif (a <= 8e+111) tmp = Float64(b / Float64(d + Float64(c * Float64(c / d)))); else tmp = Float64(a / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (a <= -8.6e+63) tmp = a / c; elseif (a <= 8e+111) tmp = b / (d + (c * (c / d))); else tmp = a / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[a, -8.6e+63], N[(a / c), $MachinePrecision], If[LessEqual[a, 8e+111], N[(b / N[(d + N[(c * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a / c), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -8.6 \cdot 10^{+63}:\\
\;\;\;\;\frac{a}{c}\\
\mathbf{elif}\;a \leq 8 \cdot 10^{+111}:\\
\;\;\;\;\frac{b}{d + c \cdot \frac{c}{d}}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c}\\
\end{array}
\end{array}
if a < -8.6000000000000001e63 or 7.99999999999999965e111 < a Initial program 47.7%
Taylor expanded in c around inf 68.2%
if -8.6000000000000001e63 < a < 7.99999999999999965e111Initial program 66.7%
Taylor expanded in a around 0 53.0%
associate-/l*55.3%
unpow255.3%
unpow255.3%
Simplified55.3%
Taylor expanded in c around 0 70.9%
unpow270.9%
*-lft-identity70.9%
times-frac75.2%
/-rgt-identity75.2%
Simplified75.2%
Final simplification72.5%
(FPCore (a b c d)
:precision binary64
(if (<= c -9e+28)
(/ a c)
(if (or (<= c -1.75e-32) (and (not (<= c -3.05e-64)) (<= c 900000000.0)))
(/ b d)
(/ a c))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -9e+28) {
tmp = a / c;
} else if ((c <= -1.75e-32) || (!(c <= -3.05e-64) && (c <= 900000000.0))) {
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 <= (-9d+28)) then
tmp = a / c
else if ((c <= (-1.75d-32)) .or. (.not. (c <= (-3.05d-64))) .and. (c <= 900000000.0d0)) 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 <= -9e+28) {
tmp = a / c;
} else if ((c <= -1.75e-32) || (!(c <= -3.05e-64) && (c <= 900000000.0))) {
tmp = b / d;
} else {
tmp = a / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -9e+28: tmp = a / c elif (c <= -1.75e-32) or (not (c <= -3.05e-64) and (c <= 900000000.0)): tmp = b / d else: tmp = a / c return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -9e+28) tmp = Float64(a / c); elseif ((c <= -1.75e-32) || (!(c <= -3.05e-64) && (c <= 900000000.0))) 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 <= -9e+28) tmp = a / c; elseif ((c <= -1.75e-32) || (~((c <= -3.05e-64)) && (c <= 900000000.0))) tmp = b / d; else tmp = a / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -9e+28], N[(a / c), $MachinePrecision], If[Or[LessEqual[c, -1.75e-32], And[N[Not[LessEqual[c, -3.05e-64]], $MachinePrecision], LessEqual[c, 900000000.0]]], N[(b / d), $MachinePrecision], N[(a / c), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -9 \cdot 10^{+28}:\\
\;\;\;\;\frac{a}{c}\\
\mathbf{elif}\;c \leq -1.75 \cdot 10^{-32} \lor \neg \left(c \leq -3.05 \cdot 10^{-64}\right) \land c \leq 900000000:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c}\\
\end{array}
\end{array}
if c < -8.9999999999999994e28 or -1.7499999999999999e-32 < c < -3.0499999999999998e-64 or 9e8 < c Initial program 45.8%
Taylor expanded in c around inf 72.8%
if -8.9999999999999994e28 < c < -1.7499999999999999e-32 or -3.0499999999999998e-64 < c < 9e8Initial program 71.2%
Taylor expanded in c around 0 67.5%
Final simplification70.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 59.3%
Taylor expanded in c around inf 45.9%
Final simplification45.9%
(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 2023292
(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))))