
(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 (if (<= (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))) 5e+306) (/ (/ (fma a c (* b d)) (hypot c d)) (hypot c d)) (+ (/ b d) (/ (* a (/ c d)) d))))
double code(double a, double b, double c, double d) {
double tmp;
if ((((a * c) + (b * d)) / ((c * c) + (d * d))) <= 5e+306) {
tmp = (fma(a, c, (b * d)) / hypot(c, d)) / hypot(c, d);
} else {
tmp = (b / d) + ((a * (c / d)) / d);
}
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))) <= 5e+306) tmp = Float64(Float64(fma(a, c, Float64(b * d)) / hypot(c, d)) / hypot(c, d)); else tmp = Float64(Float64(b / d) + Float64(Float64(a * Float64(c / d)) / d)); 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], 5e+306], N[(N[(N[(a * c + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision], N[(N[(b / d), $MachinePrecision] + N[(N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \leq 5 \cdot 10^{+306}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d} + \frac{a \cdot \frac{c}{d}}{d}\\
\end{array}
\end{array}
if (/.f64 (+.f64 (*.f64 a c) (*.f64 b d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 4.99999999999999993e306Initial program 76.8%
*-un-lft-identity76.8%
add-sqr-sqrt76.8%
times-frac76.8%
hypot-def76.8%
fma-def76.8%
hypot-def96.5%
Applied egg-rr96.5%
associate-*l/96.7%
*-un-lft-identity96.7%
Applied egg-rr96.7%
if 4.99999999999999993e306 < (/.f64 (+.f64 (*.f64 a c) (*.f64 b d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 9.1%
Taylor expanded in c around 0 38.9%
unpow238.9%
times-frac57.0%
Simplified57.0%
associate-*r/57.1%
Applied egg-rr57.1%
Final simplification85.7%
(FPCore (a b c d)
:precision binary64
(if (<= c -5.4e+89)
(/ (/ c (hypot c d)) (/ (hypot c d) a))
(if (<= c -4.4e-71)
(/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))
(if (<= c 2.85e+24)
(+ (/ b d) (/ (* a (/ c d)) d))
(+ (/ a c) (/ (* d (/ b c)) c))))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -5.4e+89) {
tmp = (c / hypot(c, d)) / (hypot(c, d) / a);
} else if (c <= -4.4e-71) {
tmp = ((a * c) + (b * d)) / ((c * c) + (d * d));
} else if (c <= 2.85e+24) {
tmp = (b / d) + ((a * (c / d)) / d);
} else {
tmp = (a / c) + ((d * (b / c)) / c);
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -5.4e+89) {
tmp = (c / Math.hypot(c, d)) / (Math.hypot(c, d) / a);
} else if (c <= -4.4e-71) {
tmp = ((a * c) + (b * d)) / ((c * c) + (d * d));
} else if (c <= 2.85e+24) {
tmp = (b / d) + ((a * (c / d)) / d);
} else {
tmp = (a / c) + ((d * (b / c)) / c);
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -5.4e+89: tmp = (c / math.hypot(c, d)) / (math.hypot(c, d) / a) elif c <= -4.4e-71: tmp = ((a * c) + (b * d)) / ((c * c) + (d * d)) elif c <= 2.85e+24: tmp = (b / d) + ((a * (c / d)) / d) else: tmp = (a / c) + ((d * (b / c)) / c) return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -5.4e+89) tmp = Float64(Float64(c / hypot(c, d)) / Float64(hypot(c, d) / a)); elseif (c <= -4.4e-71) tmp = Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d))); elseif (c <= 2.85e+24) tmp = Float64(Float64(b / d) + Float64(Float64(a * Float64(c / d)) / d)); else tmp = Float64(Float64(a / c) + Float64(Float64(d * Float64(b / c)) / c)); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -5.4e+89) tmp = (c / hypot(c, d)) / (hypot(c, d) / a); elseif (c <= -4.4e-71) tmp = ((a * c) + (b * d)) / ((c * c) + (d * d)); elseif (c <= 2.85e+24) tmp = (b / d) + ((a * (c / d)) / d); else tmp = (a / c) + ((d * (b / c)) / c); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -5.4e+89], N[(N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] / N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -4.4e-71], N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 2.85e+24], N[(N[(b / d), $MachinePrecision] + N[(N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], N[(N[(a / c), $MachinePrecision] + N[(N[(d * N[(b / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -5.4 \cdot 10^{+89}:\\
\;\;\;\;\frac{\frac{c}{\mathsf{hypot}\left(c, d\right)}}{\frac{\mathsf{hypot}\left(c, d\right)}{a}}\\
\mathbf{elif}\;c \leq -4.4 \cdot 10^{-71}:\\
\;\;\;\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;c \leq 2.85 \cdot 10^{+24}:\\
\;\;\;\;\frac{b}{d} + \frac{a \cdot \frac{c}{d}}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{d \cdot \frac{b}{c}}{c}\\
\end{array}
\end{array}
if c < -5.4e89Initial program 31.4%
*-un-lft-identity31.4%
add-sqr-sqrt31.4%
times-frac31.4%
hypot-def31.4%
fma-def31.4%
hypot-def54.2%
Applied egg-rr54.2%
Taylor expanded in a around inf 50.7%
*-un-lft-identity50.7%
times-frac80.9%
Applied egg-rr80.9%
frac-times50.7%
*-un-lft-identity50.7%
associate-/l*81.0%
associate-*r/80.8%
associate-*l/81.0%
*-un-lft-identity81.0%
Applied egg-rr81.0%
if -5.4e89 < c < -4.39999999999999995e-71Initial program 84.9%
if -4.39999999999999995e-71 < c < 2.8500000000000002e24Initial program 67.7%
Taylor expanded in c around 0 80.5%
unpow280.5%
times-frac86.0%
Simplified86.0%
associate-*r/87.8%
Applied egg-rr87.8%
if 2.8500000000000002e24 < c Initial program 48.9%
Taylor expanded in c around inf 74.0%
unpow274.0%
times-frac81.9%
Simplified81.9%
associate-*l/83.4%
Applied egg-rr83.4%
Final simplification85.0%
(FPCore (a b c d)
:precision binary64
(if (<= c -2.35e+95)
(+ (/ a c) (/ d (* c (/ c b))))
(if (<= c -3.8e-71)
(/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))
(if (<= c 4.5e+28)
(+ (/ b d) (/ (* a (/ c d)) d))
(+ (/ a c) (/ (* d (/ b c)) c))))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -2.35e+95) {
tmp = (a / c) + (d / (c * (c / b)));
} else if (c <= -3.8e-71) {
tmp = ((a * c) + (b * d)) / ((c * c) + (d * d));
} else if (c <= 4.5e+28) {
tmp = (b / d) + ((a * (c / d)) / d);
} else {
tmp = (a / c) + ((d * (b / c)) / c);
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (c <= (-2.35d+95)) then
tmp = (a / c) + (d / (c * (c / b)))
else if (c <= (-3.8d-71)) then
tmp = ((a * c) + (b * d)) / ((c * c) + (d * d))
else if (c <= 4.5d+28) then
tmp = (b / d) + ((a * (c / d)) / d)
else
tmp = (a / c) + ((d * (b / c)) / c)
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -2.35e+95) {
tmp = (a / c) + (d / (c * (c / b)));
} else if (c <= -3.8e-71) {
tmp = ((a * c) + (b * d)) / ((c * c) + (d * d));
} else if (c <= 4.5e+28) {
tmp = (b / d) + ((a * (c / d)) / d);
} else {
tmp = (a / c) + ((d * (b / c)) / c);
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -2.35e+95: tmp = (a / c) + (d / (c * (c / b))) elif c <= -3.8e-71: tmp = ((a * c) + (b * d)) / ((c * c) + (d * d)) elif c <= 4.5e+28: tmp = (b / d) + ((a * (c / d)) / d) else: tmp = (a / c) + ((d * (b / c)) / c) return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -2.35e+95) tmp = Float64(Float64(a / c) + Float64(d / Float64(c * Float64(c / b)))); elseif (c <= -3.8e-71) tmp = Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d))); elseif (c <= 4.5e+28) tmp = Float64(Float64(b / d) + Float64(Float64(a * Float64(c / d)) / d)); else tmp = Float64(Float64(a / c) + Float64(Float64(d * Float64(b / c)) / c)); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -2.35e+95) tmp = (a / c) + (d / (c * (c / b))); elseif (c <= -3.8e-71) tmp = ((a * c) + (b * d)) / ((c * c) + (d * d)); elseif (c <= 4.5e+28) tmp = (b / d) + ((a * (c / d)) / d); else tmp = (a / c) + ((d * (b / c)) / c); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -2.35e+95], N[(N[(a / c), $MachinePrecision] + N[(d / N[(c * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -3.8e-71], N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 4.5e+28], N[(N[(b / d), $MachinePrecision] + N[(N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], N[(N[(a / c), $MachinePrecision] + N[(N[(d * N[(b / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -2.35 \cdot 10^{+95}:\\
\;\;\;\;\frac{a}{c} + \frac{d}{c \cdot \frac{c}{b}}\\
\mathbf{elif}\;c \leq -3.8 \cdot 10^{-71}:\\
\;\;\;\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;c \leq 4.5 \cdot 10^{+28}:\\
\;\;\;\;\frac{b}{d} + \frac{a \cdot \frac{c}{d}}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{d \cdot \frac{b}{c}}{c}\\
\end{array}
\end{array}
if c < -2.34999999999999986e95Initial program 31.2%
Taylor expanded in c around inf 73.8%
unpow273.8%
times-frac78.5%
Simplified78.5%
*-commutative78.5%
clear-num78.5%
frac-times82.3%
*-un-lft-identity82.3%
Applied egg-rr82.3%
if -2.34999999999999986e95 < c < -3.79999999999999992e-71Initial program 80.8%
if -3.79999999999999992e-71 < c < 4.4999999999999997e28Initial program 67.7%
Taylor expanded in c around 0 80.5%
unpow280.5%
times-frac86.0%
Simplified86.0%
associate-*r/87.8%
Applied egg-rr87.8%
if 4.4999999999999997e28 < c Initial program 48.9%
Taylor expanded in c around inf 74.0%
unpow274.0%
times-frac81.9%
Simplified81.9%
associate-*l/83.4%
Applied egg-rr83.4%
Final simplification84.7%
(FPCore (a b c d)
:precision binary64
(if (<= c -5.5e+45)
(/ a c)
(if (<= c 2.75e-129)
(/ b d)
(if (<= c 1.65e-91)
(/ 1.0 (* (/ d c) (/ d a)))
(if (<= c 1.65e+26) (/ b d) (/ a c))))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -5.5e+45) {
tmp = a / c;
} else if (c <= 2.75e-129) {
tmp = b / d;
} else if (c <= 1.65e-91) {
tmp = 1.0 / ((d / c) * (d / a));
} else if (c <= 1.65e+26) {
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.5d+45)) then
tmp = a / c
else if (c <= 2.75d-129) then
tmp = b / d
else if (c <= 1.65d-91) then
tmp = 1.0d0 / ((d / c) * (d / a))
else if (c <= 1.65d+26) 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.5e+45) {
tmp = a / c;
} else if (c <= 2.75e-129) {
tmp = b / d;
} else if (c <= 1.65e-91) {
tmp = 1.0 / ((d / c) * (d / a));
} else if (c <= 1.65e+26) {
tmp = b / d;
} else {
tmp = a / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -5.5e+45: tmp = a / c elif c <= 2.75e-129: tmp = b / d elif c <= 1.65e-91: tmp = 1.0 / ((d / c) * (d / a)) elif c <= 1.65e+26: tmp = b / d else: tmp = a / c return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -5.5e+45) tmp = Float64(a / c); elseif (c <= 2.75e-129) tmp = Float64(b / d); elseif (c <= 1.65e-91) tmp = Float64(1.0 / Float64(Float64(d / c) * Float64(d / a))); elseif (c <= 1.65e+26) 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.5e+45) tmp = a / c; elseif (c <= 2.75e-129) tmp = b / d; elseif (c <= 1.65e-91) tmp = 1.0 / ((d / c) * (d / a)); elseif (c <= 1.65e+26) tmp = b / d; else tmp = a / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -5.5e+45], N[(a / c), $MachinePrecision], If[LessEqual[c, 2.75e-129], N[(b / d), $MachinePrecision], If[LessEqual[c, 1.65e-91], N[(1.0 / N[(N[(d / c), $MachinePrecision] * N[(d / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.65e+26], N[(b / d), $MachinePrecision], N[(a / c), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -5.5 \cdot 10^{+45}:\\
\;\;\;\;\frac{a}{c}\\
\mathbf{elif}\;c \leq 2.75 \cdot 10^{-129}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{elif}\;c \leq 1.65 \cdot 10^{-91}:\\
\;\;\;\;\frac{1}{\frac{d}{c} \cdot \frac{d}{a}}\\
\mathbf{elif}\;c \leq 1.65 \cdot 10^{+26}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c}\\
\end{array}
\end{array}
if c < -5.5000000000000001e45 or 1.64999999999999997e26 < c Initial program 45.4%
Taylor expanded in c around inf 69.6%
if -5.5000000000000001e45 < c < 2.75000000000000012e-129 or 1.65000000000000006e-91 < c < 1.64999999999999997e26Initial program 69.3%
Taylor expanded in c around 0 68.9%
if 2.75000000000000012e-129 < c < 1.65000000000000006e-91Initial program 80.9%
Taylor expanded in c around 0 61.1%
unpow261.1%
Simplified61.1%
Taylor expanded in a around inf 61.1%
clear-num60.9%
inv-pow60.9%
*-commutative60.9%
times-frac71.4%
Applied egg-rr71.4%
unpow-171.4%
*-commutative71.4%
Simplified71.4%
Final simplification69.4%
(FPCore (a b c d) :precision binary64 (if (or (<= d -9e+52) (not (<= d 1.85e+168))) (/ b d) (+ (/ a c) (* (/ b c) (/ d c)))))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -9e+52) || !(d <= 1.85e+168)) {
tmp = b / 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 <= (-9d+52)) .or. (.not. (d <= 1.85d+168))) then
tmp = b / 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 <= -9e+52) || !(d <= 1.85e+168)) {
tmp = b / d;
} else {
tmp = (a / c) + ((b / c) * (d / c));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -9e+52) or not (d <= 1.85e+168): tmp = b / d else: tmp = (a / c) + ((b / c) * (d / c)) return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -9e+52) || !(d <= 1.85e+168)) tmp = Float64(b / 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 <= -9e+52) || ~((d <= 1.85e+168))) tmp = b / d; else tmp = (a / c) + ((b / c) * (d / c)); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -9e+52], N[Not[LessEqual[d, 1.85e+168]], $MachinePrecision]], N[(b / d), $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 -9 \cdot 10^{+52} \lor \neg \left(d \leq 1.85 \cdot 10^{+168}\right):\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{b}{c} \cdot \frac{d}{c}\\
\end{array}
\end{array}
if d < -8.9999999999999999e52 or 1.85000000000000005e168 < d Initial program 39.2%
Taylor expanded in c around 0 74.3%
if -8.9999999999999999e52 < d < 1.85000000000000005e168Initial program 67.4%
Taylor expanded in c around inf 64.5%
unpow264.5%
times-frac70.7%
Simplified70.7%
Final simplification71.9%
(FPCore (a b c d) :precision binary64 (if (<= d -1.1e+53) (/ b d) (if (<= d 1.85e+168) (+ (/ a c) (/ (* d (/ b c)) c)) (/ b d))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -1.1e+53) {
tmp = b / d;
} else if (d <= 1.85e+168) {
tmp = (a / c) + ((d * (b / c)) / 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 <= (-1.1d+53)) then
tmp = b / d
else if (d <= 1.85d+168) then
tmp = (a / c) + ((d * (b / c)) / 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 <= -1.1e+53) {
tmp = b / d;
} else if (d <= 1.85e+168) {
tmp = (a / c) + ((d * (b / c)) / c);
} else {
tmp = b / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -1.1e+53: tmp = b / d elif d <= 1.85e+168: tmp = (a / c) + ((d * (b / c)) / c) else: tmp = b / d return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -1.1e+53) tmp = Float64(b / d); elseif (d <= 1.85e+168) tmp = Float64(Float64(a / c) + Float64(Float64(d * Float64(b / c)) / c)); else tmp = Float64(b / d); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= -1.1e+53) tmp = b / d; elseif (d <= 1.85e+168) tmp = (a / c) + ((d * (b / c)) / c); else tmp = b / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -1.1e+53], N[(b / d), $MachinePrecision], If[LessEqual[d, 1.85e+168], N[(N[(a / c), $MachinePrecision] + N[(N[(d * N[(b / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision], N[(b / d), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.1 \cdot 10^{+53}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{elif}\;d \leq 1.85 \cdot 10^{+168}:\\
\;\;\;\;\frac{a}{c} + \frac{d \cdot \frac{b}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d}\\
\end{array}
\end{array}
if d < -1.09999999999999999e53 or 1.85000000000000005e168 < d Initial program 39.2%
Taylor expanded in c around 0 74.3%
if -1.09999999999999999e53 < d < 1.85000000000000005e168Initial program 67.4%
Taylor expanded in c around inf 64.5%
unpow264.5%
times-frac70.7%
Simplified70.7%
associate-*l/71.8%
Applied egg-rr71.8%
Final simplification72.7%
(FPCore (a b c d)
:precision binary64
(if (<= c -6e+45)
(+ (/ a c) (/ d (* c (/ c b))))
(if (<= c 1.85e+25)
(+ (/ b d) (* (/ c d) (/ a d)))
(+ (/ a c) (/ (* d (/ b c)) c)))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -6e+45) {
tmp = (a / c) + (d / (c * (c / b)));
} else if (c <= 1.85e+25) {
tmp = (b / d) + ((c / d) * (a / d));
} else {
tmp = (a / c) + ((d * (b / c)) / c);
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (c <= (-6d+45)) then
tmp = (a / c) + (d / (c * (c / b)))
else if (c <= 1.85d+25) then
tmp = (b / d) + ((c / d) * (a / d))
else
tmp = (a / c) + ((d * (b / c)) / c)
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -6e+45) {
tmp = (a / c) + (d / (c * (c / b)));
} else if (c <= 1.85e+25) {
tmp = (b / d) + ((c / d) * (a / d));
} else {
tmp = (a / c) + ((d * (b / c)) / c);
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -6e+45: tmp = (a / c) + (d / (c * (c / b))) elif c <= 1.85e+25: tmp = (b / d) + ((c / d) * (a / d)) else: tmp = (a / c) + ((d * (b / c)) / c) return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -6e+45) tmp = Float64(Float64(a / c) + Float64(d / Float64(c * Float64(c / b)))); elseif (c <= 1.85e+25) tmp = Float64(Float64(b / d) + Float64(Float64(c / d) * Float64(a / d))); else tmp = Float64(Float64(a / c) + Float64(Float64(d * Float64(b / c)) / c)); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -6e+45) tmp = (a / c) + (d / (c * (c / b))); elseif (c <= 1.85e+25) tmp = (b / d) + ((c / d) * (a / d)); else tmp = (a / c) + ((d * (b / c)) / c); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -6e+45], N[(N[(a / c), $MachinePrecision] + N[(d / N[(c * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.85e+25], N[(N[(b / d), $MachinePrecision] + N[(N[(c / d), $MachinePrecision] * N[(a / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a / c), $MachinePrecision] + N[(N[(d * N[(b / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -6 \cdot 10^{+45}:\\
\;\;\;\;\frac{a}{c} + \frac{d}{c \cdot \frac{c}{b}}\\
\mathbf{elif}\;c \leq 1.85 \cdot 10^{+25}:\\
\;\;\;\;\frac{b}{d} + \frac{c}{d} \cdot \frac{a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{d \cdot \frac{b}{c}}{c}\\
\end{array}
\end{array}
if c < -6.00000000000000021e45Initial program 41.9%
Taylor expanded in c around inf 72.8%
unpow272.8%
times-frac75.0%
Simplified75.0%
*-commutative75.0%
clear-num75.0%
frac-times79.4%
*-un-lft-identity79.4%
Applied egg-rr79.4%
if -6.00000000000000021e45 < c < 1.8499999999999999e25Initial program 70.1%
Taylor expanded in c around 0 77.2%
unpow277.2%
times-frac83.2%
Simplified83.2%
if 1.8499999999999999e25 < c Initial program 48.9%
Taylor expanded in c around inf 74.0%
unpow274.0%
times-frac81.9%
Simplified81.9%
associate-*l/83.4%
Applied egg-rr83.4%
Final simplification82.3%
(FPCore (a b c d)
:precision binary64
(if (<= c -5.5e+45)
(+ (/ a c) (/ d (* c (/ c b))))
(if (<= c 1e+27)
(+ (/ b d) (/ (* c (/ a d)) d))
(+ (/ a c) (/ (* d (/ b c)) c)))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -5.5e+45) {
tmp = (a / c) + (d / (c * (c / b)));
} else if (c <= 1e+27) {
tmp = (b / d) + ((c * (a / d)) / d);
} else {
tmp = (a / c) + ((d * (b / c)) / c);
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (c <= (-5.5d+45)) then
tmp = (a / c) + (d / (c * (c / b)))
else if (c <= 1d+27) then
tmp = (b / d) + ((c * (a / d)) / d)
else
tmp = (a / c) + ((d * (b / c)) / c)
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -5.5e+45) {
tmp = (a / c) + (d / (c * (c / b)));
} else if (c <= 1e+27) {
tmp = (b / d) + ((c * (a / d)) / d);
} else {
tmp = (a / c) + ((d * (b / c)) / c);
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -5.5e+45: tmp = (a / c) + (d / (c * (c / b))) elif c <= 1e+27: tmp = (b / d) + ((c * (a / d)) / d) else: tmp = (a / c) + ((d * (b / c)) / c) return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -5.5e+45) tmp = Float64(Float64(a / c) + Float64(d / Float64(c * Float64(c / b)))); elseif (c <= 1e+27) tmp = Float64(Float64(b / d) + Float64(Float64(c * Float64(a / d)) / d)); else tmp = Float64(Float64(a / c) + Float64(Float64(d * Float64(b / c)) / c)); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -5.5e+45) tmp = (a / c) + (d / (c * (c / b))); elseif (c <= 1e+27) tmp = (b / d) + ((c * (a / d)) / d); else tmp = (a / c) + ((d * (b / c)) / c); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -5.5e+45], N[(N[(a / c), $MachinePrecision] + N[(d / N[(c * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1e+27], N[(N[(b / d), $MachinePrecision] + N[(N[(c * N[(a / d), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], N[(N[(a / c), $MachinePrecision] + N[(N[(d * N[(b / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -5.5 \cdot 10^{+45}:\\
\;\;\;\;\frac{a}{c} + \frac{d}{c \cdot \frac{c}{b}}\\
\mathbf{elif}\;c \leq 10^{+27}:\\
\;\;\;\;\frac{b}{d} + \frac{c \cdot \frac{a}{d}}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{d \cdot \frac{b}{c}}{c}\\
\end{array}
\end{array}
if c < -5.5000000000000001e45Initial program 41.9%
Taylor expanded in c around inf 72.8%
unpow272.8%
times-frac75.0%
Simplified75.0%
*-commutative75.0%
clear-num75.0%
frac-times79.4%
*-un-lft-identity79.4%
Applied egg-rr79.4%
if -5.5000000000000001e45 < c < 1e27Initial program 70.1%
Taylor expanded in c around 0 77.2%
unpow277.2%
times-frac83.2%
Simplified83.2%
associate-*l/83.6%
Applied egg-rr83.6%
if 1e27 < c Initial program 48.9%
Taylor expanded in c around inf 74.0%
unpow274.0%
times-frac81.9%
Simplified81.9%
associate-*l/83.4%
Applied egg-rr83.4%
Final simplification82.5%
(FPCore (a b c d)
:precision binary64
(if (<= c -6.2e+45)
(+ (/ a c) (/ d (* c (/ c b))))
(if (<= c 3.2e+26)
(+ (/ b d) (/ (* a (/ c d)) d))
(+ (/ a c) (/ (* d (/ b c)) c)))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -6.2e+45) {
tmp = (a / c) + (d / (c * (c / b)));
} else if (c <= 3.2e+26) {
tmp = (b / d) + ((a * (c / d)) / d);
} else {
tmp = (a / c) + ((d * (b / c)) / c);
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (c <= (-6.2d+45)) then
tmp = (a / c) + (d / (c * (c / b)))
else if (c <= 3.2d+26) then
tmp = (b / d) + ((a * (c / d)) / d)
else
tmp = (a / c) + ((d * (b / c)) / c)
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -6.2e+45) {
tmp = (a / c) + (d / (c * (c / b)));
} else if (c <= 3.2e+26) {
tmp = (b / d) + ((a * (c / d)) / d);
} else {
tmp = (a / c) + ((d * (b / c)) / c);
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -6.2e+45: tmp = (a / c) + (d / (c * (c / b))) elif c <= 3.2e+26: tmp = (b / d) + ((a * (c / d)) / d) else: tmp = (a / c) + ((d * (b / c)) / c) return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -6.2e+45) tmp = Float64(Float64(a / c) + Float64(d / Float64(c * Float64(c / b)))); elseif (c <= 3.2e+26) tmp = Float64(Float64(b / d) + Float64(Float64(a * Float64(c / d)) / d)); else tmp = Float64(Float64(a / c) + Float64(Float64(d * Float64(b / c)) / c)); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -6.2e+45) tmp = (a / c) + (d / (c * (c / b))); elseif (c <= 3.2e+26) tmp = (b / d) + ((a * (c / d)) / d); else tmp = (a / c) + ((d * (b / c)) / c); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -6.2e+45], N[(N[(a / c), $MachinePrecision] + N[(d / N[(c * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 3.2e+26], N[(N[(b / d), $MachinePrecision] + N[(N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], N[(N[(a / c), $MachinePrecision] + N[(N[(d * N[(b / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -6.2 \cdot 10^{+45}:\\
\;\;\;\;\frac{a}{c} + \frac{d}{c \cdot \frac{c}{b}}\\
\mathbf{elif}\;c \leq 3.2 \cdot 10^{+26}:\\
\;\;\;\;\frac{b}{d} + \frac{a \cdot \frac{c}{d}}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{d \cdot \frac{b}{c}}{c}\\
\end{array}
\end{array}
if c < -6.19999999999999975e45Initial program 41.9%
Taylor expanded in c around inf 72.8%
unpow272.8%
times-frac75.0%
Simplified75.0%
*-commutative75.0%
clear-num75.0%
frac-times79.4%
*-un-lft-identity79.4%
Applied egg-rr79.4%
if -6.19999999999999975e45 < c < 3.20000000000000029e26Initial program 70.1%
Taylor expanded in c around 0 77.2%
unpow277.2%
times-frac83.2%
Simplified83.2%
associate-*r/84.7%
Applied egg-rr84.7%
if 3.20000000000000029e26 < c Initial program 48.9%
Taylor expanded in c around inf 74.0%
unpow274.0%
times-frac81.9%
Simplified81.9%
associate-*l/83.4%
Applied egg-rr83.4%
Final simplification83.1%
(FPCore (a b c d)
:precision binary64
(if (<= c -5.5e+45)
(/ a c)
(if (<= c 9.5e-129)
(/ b d)
(if (<= c 6.5e-85)
(* (/ c d) (/ a d))
(if (<= c 7.6e+24) (/ b d) (/ a c))))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -5.5e+45) {
tmp = a / c;
} else if (c <= 9.5e-129) {
tmp = b / d;
} else if (c <= 6.5e-85) {
tmp = (c / d) * (a / d);
} else if (c <= 7.6e+24) {
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.5d+45)) then
tmp = a / c
else if (c <= 9.5d-129) then
tmp = b / d
else if (c <= 6.5d-85) then
tmp = (c / d) * (a / d)
else if (c <= 7.6d+24) 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.5e+45) {
tmp = a / c;
} else if (c <= 9.5e-129) {
tmp = b / d;
} else if (c <= 6.5e-85) {
tmp = (c / d) * (a / d);
} else if (c <= 7.6e+24) {
tmp = b / d;
} else {
tmp = a / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -5.5e+45: tmp = a / c elif c <= 9.5e-129: tmp = b / d elif c <= 6.5e-85: tmp = (c / d) * (a / d) elif c <= 7.6e+24: tmp = b / d else: tmp = a / c return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -5.5e+45) tmp = Float64(a / c); elseif (c <= 9.5e-129) tmp = Float64(b / d); elseif (c <= 6.5e-85) tmp = Float64(Float64(c / d) * Float64(a / d)); elseif (c <= 7.6e+24) 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.5e+45) tmp = a / c; elseif (c <= 9.5e-129) tmp = b / d; elseif (c <= 6.5e-85) tmp = (c / d) * (a / d); elseif (c <= 7.6e+24) tmp = b / d; else tmp = a / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -5.5e+45], N[(a / c), $MachinePrecision], If[LessEqual[c, 9.5e-129], N[(b / d), $MachinePrecision], If[LessEqual[c, 6.5e-85], N[(N[(c / d), $MachinePrecision] * N[(a / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 7.6e+24], N[(b / d), $MachinePrecision], N[(a / c), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -5.5 \cdot 10^{+45}:\\
\;\;\;\;\frac{a}{c}\\
\mathbf{elif}\;c \leq 9.5 \cdot 10^{-129}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{elif}\;c \leq 6.5 \cdot 10^{-85}:\\
\;\;\;\;\frac{c}{d} \cdot \frac{a}{d}\\
\mathbf{elif}\;c \leq 7.6 \cdot 10^{+24}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c}\\
\end{array}
\end{array}
if c < -5.5000000000000001e45 or 7.6000000000000003e24 < c Initial program 45.4%
Taylor expanded in c around inf 69.6%
if -5.5000000000000001e45 < c < 9.5000000000000006e-129 or 6.5e-85 < c < 7.6000000000000003e24Initial program 69.3%
Taylor expanded in c around 0 68.9%
if 9.5000000000000006e-129 < c < 6.5e-85Initial program 80.9%
Taylor expanded in c around 0 68.8%
unpow268.8%
times-frac78.8%
Simplified78.8%
frac-times68.8%
*-commutative68.8%
frac-add37.0%
Applied egg-rr37.0%
Taylor expanded in b around 0 61.1%
unpow261.1%
times-frac71.1%
Simplified71.1%
Final simplification69.3%
(FPCore (a b c d) :precision binary64 (if (<= c -5.5e+45) (/ a c) (if (<= c 1.8e+24) (/ b d) (/ a c))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -5.5e+45) {
tmp = a / c;
} else if (c <= 1.8e+24) {
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.5d+45)) then
tmp = a / c
else if (c <= 1.8d+24) 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.5e+45) {
tmp = a / c;
} else if (c <= 1.8e+24) {
tmp = b / d;
} else {
tmp = a / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -5.5e+45: tmp = a / c elif c <= 1.8e+24: tmp = b / d else: tmp = a / c return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -5.5e+45) tmp = Float64(a / c); elseif (c <= 1.8e+24) 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.5e+45) tmp = a / c; elseif (c <= 1.8e+24) tmp = b / d; else tmp = a / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -5.5e+45], N[(a / c), $MachinePrecision], If[LessEqual[c, 1.8e+24], N[(b / d), $MachinePrecision], N[(a / c), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -5.5 \cdot 10^{+45}:\\
\;\;\;\;\frac{a}{c}\\
\mathbf{elif}\;c \leq 1.8 \cdot 10^{+24}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c}\\
\end{array}
\end{array}
if c < -5.5000000000000001e45 or 1.79999999999999992e24 < c Initial program 45.4%
Taylor expanded in c around inf 69.6%
if -5.5000000000000001e45 < c < 1.79999999999999992e24Initial program 70.1%
Taylor expanded in c around 0 66.0%
Final simplification67.8%
(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.0%
Taylor expanded in c around inf 42.3%
Final simplification42.3%
(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 2023192
(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))))