
(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 11 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 (* (/ 1.0 c) d) (/ b c) (/ a c)))
(t_2 (+ (* c a) (* d b))))
(if (<= c -1.4e+89)
t_1
(if (<= c -2.5e-29)
(* (/ 1.0 t_0) t_2)
(if (<= c 6e-145)
(/ (+ b (/ 1.0 (/ d (* c a)))) d)
(if (<= c 4e+53) (/ 1.0 (/ t_0 t_2)) t_1))))))
double code(double a, double b, double c, double d) {
double t_0 = (c * c) + (d * d);
double t_1 = fma(((1.0 / c) * d), (b / c), (a / c));
double t_2 = (c * a) + (d * b);
double tmp;
if (c <= -1.4e+89) {
tmp = t_1;
} else if (c <= -2.5e-29) {
tmp = (1.0 / t_0) * t_2;
} else if (c <= 6e-145) {
tmp = (b + (1.0 / (d / (c * a)))) / d;
} else if (c <= 4e+53) {
tmp = 1.0 / (t_0 / t_2);
} else {
tmp = t_1;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(c * c) + Float64(d * d)) t_1 = fma(Float64(Float64(1.0 / c) * d), Float64(b / c), Float64(a / c)) t_2 = Float64(Float64(c * a) + Float64(d * b)) tmp = 0.0 if (c <= -1.4e+89) tmp = t_1; elseif (c <= -2.5e-29) tmp = Float64(Float64(1.0 / t_0) * t_2); elseif (c <= 6e-145) tmp = Float64(Float64(b + Float64(1.0 / Float64(d / Float64(c * a)))) / d); elseif (c <= 4e+53) tmp = Float64(1.0 / Float64(t_0 / t_2)); else tmp = t_1; 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[(N[(N[(1.0 / c), $MachinePrecision] * d), $MachinePrecision] * N[(b / c), $MachinePrecision] + N[(a / c), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(c * a), $MachinePrecision] + N[(d * b), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -1.4e+89], t$95$1, If[LessEqual[c, -2.5e-29], N[(N[(1.0 / t$95$0), $MachinePrecision] * t$95$2), $MachinePrecision], If[LessEqual[c, 6e-145], N[(N[(b + N[(1.0 / N[(d / N[(c * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 4e+53], N[(1.0 / N[(t$95$0 / t$95$2), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := c \cdot c + d \cdot d\\
t_1 := \mathsf{fma}\left(\frac{1}{c} \cdot d, \frac{b}{c}, \frac{a}{c}\right)\\
t_2 := c \cdot a + d \cdot b\\
\mathbf{if}\;c \leq -1.4 \cdot 10^{+89}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;c \leq -2.5 \cdot 10^{-29}:\\
\;\;\;\;\frac{1}{t\_0} \cdot t\_2\\
\mathbf{elif}\;c \leq 6 \cdot 10^{-145}:\\
\;\;\;\;\frac{b + \frac{1}{\frac{d}{c \cdot a}}}{d}\\
\mathbf{elif}\;c \leq 4 \cdot 10^{+53}:\\
\;\;\;\;\frac{1}{\frac{t\_0}{t\_2}}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if c < -1.3999999999999999e89 or 4e53 < c Initial program 39.8%
Taylor expanded in c around inf
/-lowering-/.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f6480.5%
Simplified80.5%
clear-numN/A
associate-/r/N/A
+-commutativeN/A
distribute-lft-inN/A
*-commutativeN/A
associate-/l*N/A
associate-*r*N/A
associate-/r/N/A
clear-numN/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
/-lowering-/.f6484.9%
Applied egg-rr84.9%
if -1.3999999999999999e89 < c < -2.49999999999999993e-29Initial program 89.3%
div-invN/A
flip-+N/A
clear-numN/A
*-commutativeN/A
*-lowering-*.f64N/A
clear-numN/A
flip-+N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f6489.4%
Applied egg-rr89.4%
if -2.49999999999999993e-29 < c < 5.99999999999999985e-145Initial program 66.1%
Taylor expanded in c around 0
remove-double-negN/A
mul-1-negN/A
distribute-frac-negN/A
distribute-frac-neg2N/A
mul-1-negN/A
unpow2N/A
associate-/r*N/A
associate-/l*N/A
associate-/l*N/A
remove-double-negN/A
mul-1-negN/A
distribute-frac-negN/A
mul-1-negN/A
distribute-frac-negN/A
distribute-frac-neg2N/A
mul-1-negN/A
sub-negN/A
div-subN/A
Simplified96.2%
clear-numN/A
/-lowering-/.f64N/A
*-commutativeN/A
/-lowering-/.f64N/A
*-lowering-*.f6496.2%
Applied egg-rr96.2%
if 5.99999999999999985e-145 < c < 4e53Initial program 88.9%
clear-numN/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f6488.9%
Applied egg-rr88.9%
Final simplification89.2%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (+ (* c c) (* d d)))
(t_1 (/ (+ a (/ b (/ c d))) c))
(t_2 (+ (* c a) (* d b))))
(if (<= c -3.5e+88)
t_1
(if (<= c -2.35e-26)
(* (/ 1.0 t_0) t_2)
(if (<= c 4e-143)
(/ (+ b (/ 1.0 (/ d (* c a)))) d)
(if (<= c 2.5e+108) (/ 1.0 (/ t_0 t_2)) t_1))))))
double code(double a, double b, double c, double d) {
double t_0 = (c * c) + (d * d);
double t_1 = (a + (b / (c / d))) / c;
double t_2 = (c * a) + (d * b);
double tmp;
if (c <= -3.5e+88) {
tmp = t_1;
} else if (c <= -2.35e-26) {
tmp = (1.0 / t_0) * t_2;
} else if (c <= 4e-143) {
tmp = (b + (1.0 / (d / (c * a)))) / d;
} else if (c <= 2.5e+108) {
tmp = 1.0 / (t_0 / t_2);
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = (c * c) + (d * d)
t_1 = (a + (b / (c / d))) / c
t_2 = (c * a) + (d * b)
if (c <= (-3.5d+88)) then
tmp = t_1
else if (c <= (-2.35d-26)) then
tmp = (1.0d0 / t_0) * t_2
else if (c <= 4d-143) then
tmp = (b + (1.0d0 / (d / (c * a)))) / d
else if (c <= 2.5d+108) then
tmp = 1.0d0 / (t_0 / t_2)
else
tmp = t_1
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = (c * c) + (d * d);
double t_1 = (a + (b / (c / d))) / c;
double t_2 = (c * a) + (d * b);
double tmp;
if (c <= -3.5e+88) {
tmp = t_1;
} else if (c <= -2.35e-26) {
tmp = (1.0 / t_0) * t_2;
} else if (c <= 4e-143) {
tmp = (b + (1.0 / (d / (c * a)))) / d;
} else if (c <= 2.5e+108) {
tmp = 1.0 / (t_0 / t_2);
} else {
tmp = t_1;
}
return tmp;
}
def code(a, b, c, d): t_0 = (c * c) + (d * d) t_1 = (a + (b / (c / d))) / c t_2 = (c * a) + (d * b) tmp = 0 if c <= -3.5e+88: tmp = t_1 elif c <= -2.35e-26: tmp = (1.0 / t_0) * t_2 elif c <= 4e-143: tmp = (b + (1.0 / (d / (c * a)))) / d elif c <= 2.5e+108: tmp = 1.0 / (t_0 / t_2) else: tmp = t_1 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(c * c) + Float64(d * d)) t_1 = Float64(Float64(a + Float64(b / Float64(c / d))) / c) t_2 = Float64(Float64(c * a) + Float64(d * b)) tmp = 0.0 if (c <= -3.5e+88) tmp = t_1; elseif (c <= -2.35e-26) tmp = Float64(Float64(1.0 / t_0) * t_2); elseif (c <= 4e-143) tmp = Float64(Float64(b + Float64(1.0 / Float64(d / Float64(c * a)))) / d); elseif (c <= 2.5e+108) tmp = Float64(1.0 / Float64(t_0 / t_2)); else tmp = t_1; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (c * c) + (d * d); t_1 = (a + (b / (c / d))) / c; t_2 = (c * a) + (d * b); tmp = 0.0; if (c <= -3.5e+88) tmp = t_1; elseif (c <= -2.35e-26) tmp = (1.0 / t_0) * t_2; elseif (c <= 4e-143) tmp = (b + (1.0 / (d / (c * a)))) / d; elseif (c <= 2.5e+108) tmp = 1.0 / (t_0 / t_2); else tmp = t_1; 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[(a + N[(b / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]}, Block[{t$95$2 = N[(N[(c * a), $MachinePrecision] + N[(d * b), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -3.5e+88], t$95$1, If[LessEqual[c, -2.35e-26], N[(N[(1.0 / t$95$0), $MachinePrecision] * t$95$2), $MachinePrecision], If[LessEqual[c, 4e-143], N[(N[(b + N[(1.0 / N[(d / N[(c * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 2.5e+108], N[(1.0 / N[(t$95$0 / t$95$2), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := c \cdot c + d \cdot d\\
t_1 := \frac{a + \frac{b}{\frac{c}{d}}}{c}\\
t_2 := c \cdot a + d \cdot b\\
\mathbf{if}\;c \leq -3.5 \cdot 10^{+88}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;c \leq -2.35 \cdot 10^{-26}:\\
\;\;\;\;\frac{1}{t\_0} \cdot t\_2\\
\mathbf{elif}\;c \leq 4 \cdot 10^{-143}:\\
\;\;\;\;\frac{b + \frac{1}{\frac{d}{c \cdot a}}}{d}\\
\mathbf{elif}\;c \leq 2.5 \cdot 10^{+108}:\\
\;\;\;\;\frac{1}{\frac{t\_0}{t\_2}}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if c < -3.4999999999999998e88 or 2.49999999999999995e108 < c Initial program 35.3%
Taylor expanded in c around inf
/-lowering-/.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f6484.0%
Simplified84.0%
associate-/l*N/A
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
/-lowering-/.f6488.0%
Applied egg-rr88.0%
if -3.4999999999999998e88 < c < -2.34999999999999995e-26Initial program 89.3%
div-invN/A
flip-+N/A
clear-numN/A
*-commutativeN/A
*-lowering-*.f64N/A
clear-numN/A
flip-+N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f6489.4%
Applied egg-rr89.4%
if -2.34999999999999995e-26 < c < 3.9999999999999998e-143Initial program 66.1%
Taylor expanded in c around 0
remove-double-negN/A
mul-1-negN/A
distribute-frac-negN/A
distribute-frac-neg2N/A
mul-1-negN/A
unpow2N/A
associate-/r*N/A
associate-/l*N/A
associate-/l*N/A
remove-double-negN/A
mul-1-negN/A
distribute-frac-negN/A
mul-1-negN/A
distribute-frac-negN/A
distribute-frac-neg2N/A
mul-1-negN/A
sub-negN/A
div-subN/A
Simplified96.2%
clear-numN/A
/-lowering-/.f64N/A
*-commutativeN/A
/-lowering-/.f64N/A
*-lowering-*.f6496.2%
Applied egg-rr96.2%
if 3.9999999999999998e-143 < c < 2.49999999999999995e108Initial program 82.2%
clear-numN/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f6482.2%
Applied egg-rr82.2%
Final simplification89.2%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (+ (* c c) (* d d)))
(t_1 (/ (+ a (/ b (/ c d))) c))
(t_2 (+ (* c a) (* d b))))
(if (<= c -9e+88)
t_1
(if (<= c -6e-32)
(* (/ 1.0 t_0) t_2)
(if (<= c 3.8e-146)
(/ (+ b (/ 1.0 (/ d (* c a)))) d)
(if (<= c 6e+111) (/ t_2 t_0) t_1))))))
double code(double a, double b, double c, double d) {
double t_0 = (c * c) + (d * d);
double t_1 = (a + (b / (c / d))) / c;
double t_2 = (c * a) + (d * b);
double tmp;
if (c <= -9e+88) {
tmp = t_1;
} else if (c <= -6e-32) {
tmp = (1.0 / t_0) * t_2;
} else if (c <= 3.8e-146) {
tmp = (b + (1.0 / (d / (c * a)))) / d;
} else if (c <= 6e+111) {
tmp = t_2 / t_0;
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = (c * c) + (d * d)
t_1 = (a + (b / (c / d))) / c
t_2 = (c * a) + (d * b)
if (c <= (-9d+88)) then
tmp = t_1
else if (c <= (-6d-32)) then
tmp = (1.0d0 / t_0) * t_2
else if (c <= 3.8d-146) then
tmp = (b + (1.0d0 / (d / (c * a)))) / d
else if (c <= 6d+111) then
tmp = t_2 / t_0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = (c * c) + (d * d);
double t_1 = (a + (b / (c / d))) / c;
double t_2 = (c * a) + (d * b);
double tmp;
if (c <= -9e+88) {
tmp = t_1;
} else if (c <= -6e-32) {
tmp = (1.0 / t_0) * t_2;
} else if (c <= 3.8e-146) {
tmp = (b + (1.0 / (d / (c * a)))) / d;
} else if (c <= 6e+111) {
tmp = t_2 / t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(a, b, c, d): t_0 = (c * c) + (d * d) t_1 = (a + (b / (c / d))) / c t_2 = (c * a) + (d * b) tmp = 0 if c <= -9e+88: tmp = t_1 elif c <= -6e-32: tmp = (1.0 / t_0) * t_2 elif c <= 3.8e-146: tmp = (b + (1.0 / (d / (c * a)))) / d elif c <= 6e+111: tmp = t_2 / t_0 else: tmp = t_1 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(c * c) + Float64(d * d)) t_1 = Float64(Float64(a + Float64(b / Float64(c / d))) / c) t_2 = Float64(Float64(c * a) + Float64(d * b)) tmp = 0.0 if (c <= -9e+88) tmp = t_1; elseif (c <= -6e-32) tmp = Float64(Float64(1.0 / t_0) * t_2); elseif (c <= 3.8e-146) tmp = Float64(Float64(b + Float64(1.0 / Float64(d / Float64(c * a)))) / d); elseif (c <= 6e+111) tmp = Float64(t_2 / t_0); else tmp = t_1; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (c * c) + (d * d); t_1 = (a + (b / (c / d))) / c; t_2 = (c * a) + (d * b); tmp = 0.0; if (c <= -9e+88) tmp = t_1; elseif (c <= -6e-32) tmp = (1.0 / t_0) * t_2; elseif (c <= 3.8e-146) tmp = (b + (1.0 / (d / (c * a)))) / d; elseif (c <= 6e+111) tmp = t_2 / t_0; else tmp = t_1; 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[(a + N[(b / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]}, Block[{t$95$2 = N[(N[(c * a), $MachinePrecision] + N[(d * b), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -9e+88], t$95$1, If[LessEqual[c, -6e-32], N[(N[(1.0 / t$95$0), $MachinePrecision] * t$95$2), $MachinePrecision], If[LessEqual[c, 3.8e-146], N[(N[(b + N[(1.0 / N[(d / N[(c * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 6e+111], N[(t$95$2 / t$95$0), $MachinePrecision], t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := c \cdot c + d \cdot d\\
t_1 := \frac{a + \frac{b}{\frac{c}{d}}}{c}\\
t_2 := c \cdot a + d \cdot b\\
\mathbf{if}\;c \leq -9 \cdot 10^{+88}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;c \leq -6 \cdot 10^{-32}:\\
\;\;\;\;\frac{1}{t\_0} \cdot t\_2\\
\mathbf{elif}\;c \leq 3.8 \cdot 10^{-146}:\\
\;\;\;\;\frac{b + \frac{1}{\frac{d}{c \cdot a}}}{d}\\
\mathbf{elif}\;c \leq 6 \cdot 10^{+111}:\\
\;\;\;\;\frac{t\_2}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if c < -9e88 or 6e111 < c Initial program 35.3%
Taylor expanded in c around inf
/-lowering-/.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f6484.0%
Simplified84.0%
associate-/l*N/A
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
/-lowering-/.f6488.0%
Applied egg-rr88.0%
if -9e88 < c < -6.0000000000000001e-32Initial program 89.3%
div-invN/A
flip-+N/A
clear-numN/A
*-commutativeN/A
*-lowering-*.f64N/A
clear-numN/A
flip-+N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f6489.4%
Applied egg-rr89.4%
if -6.0000000000000001e-32 < c < 3.79999999999999994e-146Initial program 66.1%
Taylor expanded in c around 0
remove-double-negN/A
mul-1-negN/A
distribute-frac-negN/A
distribute-frac-neg2N/A
mul-1-negN/A
unpow2N/A
associate-/r*N/A
associate-/l*N/A
associate-/l*N/A
remove-double-negN/A
mul-1-negN/A
distribute-frac-negN/A
mul-1-negN/A
distribute-frac-negN/A
distribute-frac-neg2N/A
mul-1-negN/A
sub-negN/A
div-subN/A
Simplified96.2%
clear-numN/A
/-lowering-/.f64N/A
*-commutativeN/A
/-lowering-/.f64N/A
*-lowering-*.f6496.2%
Applied egg-rr96.2%
if 3.79999999999999994e-146 < c < 6e111Initial program 82.2%
Final simplification89.2%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (+ (* c a) (* d b)) (+ (* c c) (* d d))))
(t_1 (/ (+ a (/ b (/ c d))) c)))
(if (<= c -1.6e+85)
t_1
(if (<= c -8.6e-30)
t_0
(if (<= c 1.12e-141)
(/ (+ b (/ 1.0 (/ d (* c a)))) d)
(if (<= c 1.65e+109) t_0 t_1))))))
double code(double a, double b, double c, double d) {
double t_0 = ((c * a) + (d * b)) / ((c * c) + (d * d));
double t_1 = (a + (b / (c / d))) / c;
double tmp;
if (c <= -1.6e+85) {
tmp = t_1;
} else if (c <= -8.6e-30) {
tmp = t_0;
} else if (c <= 1.12e-141) {
tmp = (b + (1.0 / (d / (c * a)))) / d;
} else if (c <= 1.65e+109) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = ((c * a) + (d * b)) / ((c * c) + (d * d))
t_1 = (a + (b / (c / d))) / c
if (c <= (-1.6d+85)) then
tmp = t_1
else if (c <= (-8.6d-30)) then
tmp = t_0
else if (c <= 1.12d-141) then
tmp = (b + (1.0d0 / (d / (c * a)))) / d
else if (c <= 1.65d+109) then
tmp = t_0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = ((c * a) + (d * b)) / ((c * c) + (d * d));
double t_1 = (a + (b / (c / d))) / c;
double tmp;
if (c <= -1.6e+85) {
tmp = t_1;
} else if (c <= -8.6e-30) {
tmp = t_0;
} else if (c <= 1.12e-141) {
tmp = (b + (1.0 / (d / (c * a)))) / d;
} else if (c <= 1.65e+109) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(a, b, c, d): t_0 = ((c * a) + (d * b)) / ((c * c) + (d * d)) t_1 = (a + (b / (c / d))) / c tmp = 0 if c <= -1.6e+85: tmp = t_1 elif c <= -8.6e-30: tmp = t_0 elif c <= 1.12e-141: tmp = (b + (1.0 / (d / (c * a)))) / d elif c <= 1.65e+109: tmp = t_0 else: tmp = t_1 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(Float64(c * a) + Float64(d * b)) / Float64(Float64(c * c) + Float64(d * d))) t_1 = Float64(Float64(a + Float64(b / Float64(c / d))) / c) tmp = 0.0 if (c <= -1.6e+85) tmp = t_1; elseif (c <= -8.6e-30) tmp = t_0; elseif (c <= 1.12e-141) tmp = Float64(Float64(b + Float64(1.0 / Float64(d / Float64(c * a)))) / d); elseif (c <= 1.65e+109) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((c * a) + (d * b)) / ((c * c) + (d * d)); t_1 = (a + (b / (c / d))) / c; tmp = 0.0; if (c <= -1.6e+85) tmp = t_1; elseif (c <= -8.6e-30) tmp = t_0; elseif (c <= 1.12e-141) tmp = (b + (1.0 / (d / (c * a)))) / d; elseif (c <= 1.65e+109) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(c * a), $MachinePrecision] + N[(d * b), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(a + N[(b / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]}, If[LessEqual[c, -1.6e+85], t$95$1, If[LessEqual[c, -8.6e-30], t$95$0, If[LessEqual[c, 1.12e-141], N[(N[(b + N[(1.0 / N[(d / N[(c * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 1.65e+109], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c \cdot a + d \cdot b}{c \cdot c + d \cdot d}\\
t_1 := \frac{a + \frac{b}{\frac{c}{d}}}{c}\\
\mathbf{if}\;c \leq -1.6 \cdot 10^{+85}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;c \leq -8.6 \cdot 10^{-30}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq 1.12 \cdot 10^{-141}:\\
\;\;\;\;\frac{b + \frac{1}{\frac{d}{c \cdot a}}}{d}\\
\mathbf{elif}\;c \leq 1.65 \cdot 10^{+109}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if c < -1.60000000000000009e85 or 1.6499999999999999e109 < c Initial program 35.3%
Taylor expanded in c around inf
/-lowering-/.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f6484.0%
Simplified84.0%
associate-/l*N/A
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
/-lowering-/.f6488.0%
Applied egg-rr88.0%
if -1.60000000000000009e85 < c < -8.59999999999999932e-30 or 1.12000000000000002e-141 < c < 1.6499999999999999e109Initial program 84.4%
if -8.59999999999999932e-30 < c < 1.12000000000000002e-141Initial program 66.1%
Taylor expanded in c around 0
remove-double-negN/A
mul-1-negN/A
distribute-frac-negN/A
distribute-frac-neg2N/A
mul-1-negN/A
unpow2N/A
associate-/r*N/A
associate-/l*N/A
associate-/l*N/A
remove-double-negN/A
mul-1-negN/A
distribute-frac-negN/A
mul-1-negN/A
distribute-frac-negN/A
distribute-frac-neg2N/A
mul-1-negN/A
sub-negN/A
div-subN/A
Simplified96.2%
clear-numN/A
/-lowering-/.f64N/A
*-commutativeN/A
/-lowering-/.f64N/A
*-lowering-*.f6496.2%
Applied egg-rr96.2%
Final simplification89.1%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (+ a (/ b (/ c d))) c)))
(if (<= c -4.7e+24)
t_0
(if (<= c 3.6e-56)
(/ (+ b (/ 1.0 (/ d (* c a)))) d)
(if (<= c 9.5e+48) (/ (* c a) (+ (* c c) (* d d))) t_0)))))
double code(double a, double b, double c, double d) {
double t_0 = (a + (b / (c / d))) / c;
double tmp;
if (c <= -4.7e+24) {
tmp = t_0;
} else if (c <= 3.6e-56) {
tmp = (b + (1.0 / (d / (c * a)))) / d;
} else if (c <= 9.5e+48) {
tmp = (c * a) / ((c * c) + (d * d));
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: tmp
t_0 = (a + (b / (c / d))) / c
if (c <= (-4.7d+24)) then
tmp = t_0
else if (c <= 3.6d-56) then
tmp = (b + (1.0d0 / (d / (c * a)))) / d
else if (c <= 9.5d+48) then
tmp = (c * a) / ((c * c) + (d * d))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = (a + (b / (c / d))) / c;
double tmp;
if (c <= -4.7e+24) {
tmp = t_0;
} else if (c <= 3.6e-56) {
tmp = (b + (1.0 / (d / (c * a)))) / d;
} else if (c <= 9.5e+48) {
tmp = (c * a) / ((c * c) + (d * d));
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b, c, d): t_0 = (a + (b / (c / d))) / c tmp = 0 if c <= -4.7e+24: tmp = t_0 elif c <= 3.6e-56: tmp = (b + (1.0 / (d / (c * a)))) / d elif c <= 9.5e+48: tmp = (c * a) / ((c * c) + (d * d)) else: tmp = t_0 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(a + Float64(b / Float64(c / d))) / c) tmp = 0.0 if (c <= -4.7e+24) tmp = t_0; elseif (c <= 3.6e-56) tmp = Float64(Float64(b + Float64(1.0 / Float64(d / Float64(c * a)))) / d); elseif (c <= 9.5e+48) tmp = Float64(Float64(c * a) / Float64(Float64(c * c) + Float64(d * d))); else tmp = t_0; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (a + (b / (c / d))) / c; tmp = 0.0; if (c <= -4.7e+24) tmp = t_0; elseif (c <= 3.6e-56) tmp = (b + (1.0 / (d / (c * a)))) / d; elseif (c <= 9.5e+48) tmp = (c * a) / ((c * c) + (d * d)); else tmp = t_0; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(a + N[(b / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]}, If[LessEqual[c, -4.7e+24], t$95$0, If[LessEqual[c, 3.6e-56], N[(N[(b + N[(1.0 / N[(d / N[(c * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 9.5e+48], N[(N[(c * a), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a + \frac{b}{\frac{c}{d}}}{c}\\
\mathbf{if}\;c \leq -4.7 \cdot 10^{+24}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq 3.6 \cdot 10^{-56}:\\
\;\;\;\;\frac{b + \frac{1}{\frac{d}{c \cdot a}}}{d}\\
\mathbf{elif}\;c \leq 9.5 \cdot 10^{+48}:\\
\;\;\;\;\frac{c \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if c < -4.7e24 or 9.4999999999999997e48 < c Initial program 45.4%
Taylor expanded in c around inf
/-lowering-/.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f6481.2%
Simplified81.2%
associate-/l*N/A
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
/-lowering-/.f6484.4%
Applied egg-rr84.4%
if -4.7e24 < c < 3.59999999999999978e-56Initial program 73.6%
Taylor expanded in c around 0
remove-double-negN/A
mul-1-negN/A
distribute-frac-negN/A
distribute-frac-neg2N/A
mul-1-negN/A
unpow2N/A
associate-/r*N/A
associate-/l*N/A
associate-/l*N/A
remove-double-negN/A
mul-1-negN/A
distribute-frac-negN/A
mul-1-negN/A
distribute-frac-negN/A
distribute-frac-neg2N/A
mul-1-negN/A
sub-negN/A
div-subN/A
Simplified85.3%
clear-numN/A
/-lowering-/.f64N/A
*-commutativeN/A
/-lowering-/.f64N/A
*-lowering-*.f6485.3%
Applied egg-rr85.3%
if 3.59999999999999978e-56 < c < 9.4999999999999997e48Initial program 91.1%
Taylor expanded in a around inf
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
unpow2N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6480.3%
Simplified80.3%
Final simplification84.5%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (+ a (/ b (/ c d))) c)))
(if (<= c -4.5e+25)
t_0
(if (<= c 3.6e-56)
(/ (+ b (/ (* c a) d)) d)
(if (<= c 1.8e+53) (/ (* c a) (+ (* c c) (* d d))) t_0)))))
double code(double a, double b, double c, double d) {
double t_0 = (a + (b / (c / d))) / c;
double tmp;
if (c <= -4.5e+25) {
tmp = t_0;
} else if (c <= 3.6e-56) {
tmp = (b + ((c * a) / d)) / d;
} else if (c <= 1.8e+53) {
tmp = (c * a) / ((c * c) + (d * d));
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: tmp
t_0 = (a + (b / (c / d))) / c
if (c <= (-4.5d+25)) then
tmp = t_0
else if (c <= 3.6d-56) then
tmp = (b + ((c * a) / d)) / d
else if (c <= 1.8d+53) then
tmp = (c * a) / ((c * c) + (d * d))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = (a + (b / (c / d))) / c;
double tmp;
if (c <= -4.5e+25) {
tmp = t_0;
} else if (c <= 3.6e-56) {
tmp = (b + ((c * a) / d)) / d;
} else if (c <= 1.8e+53) {
tmp = (c * a) / ((c * c) + (d * d));
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b, c, d): t_0 = (a + (b / (c / d))) / c tmp = 0 if c <= -4.5e+25: tmp = t_0 elif c <= 3.6e-56: tmp = (b + ((c * a) / d)) / d elif c <= 1.8e+53: tmp = (c * a) / ((c * c) + (d * d)) else: tmp = t_0 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(a + Float64(b / Float64(c / d))) / c) tmp = 0.0 if (c <= -4.5e+25) tmp = t_0; elseif (c <= 3.6e-56) tmp = Float64(Float64(b + Float64(Float64(c * a) / d)) / d); elseif (c <= 1.8e+53) tmp = Float64(Float64(c * a) / Float64(Float64(c * c) + Float64(d * d))); else tmp = t_0; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (a + (b / (c / d))) / c; tmp = 0.0; if (c <= -4.5e+25) tmp = t_0; elseif (c <= 3.6e-56) tmp = (b + ((c * a) / d)) / d; elseif (c <= 1.8e+53) tmp = (c * a) / ((c * c) + (d * d)); else tmp = t_0; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(a + N[(b / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]}, If[LessEqual[c, -4.5e+25], t$95$0, If[LessEqual[c, 3.6e-56], N[(N[(b + N[(N[(c * a), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 1.8e+53], N[(N[(c * a), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a + \frac{b}{\frac{c}{d}}}{c}\\
\mathbf{if}\;c \leq -4.5 \cdot 10^{+25}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq 3.6 \cdot 10^{-56}:\\
\;\;\;\;\frac{b + \frac{c \cdot a}{d}}{d}\\
\mathbf{elif}\;c \leq 1.8 \cdot 10^{+53}:\\
\;\;\;\;\frac{c \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if c < -4.5000000000000003e25 or 1.8e53 < c Initial program 45.4%
Taylor expanded in c around inf
/-lowering-/.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f6481.2%
Simplified81.2%
associate-/l*N/A
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
/-lowering-/.f6484.4%
Applied egg-rr84.4%
if -4.5000000000000003e25 < c < 3.59999999999999978e-56Initial program 73.6%
Taylor expanded in c around 0
remove-double-negN/A
mul-1-negN/A
distribute-frac-negN/A
distribute-frac-neg2N/A
mul-1-negN/A
unpow2N/A
associate-/r*N/A
associate-/l*N/A
associate-/l*N/A
remove-double-negN/A
mul-1-negN/A
distribute-frac-negN/A
mul-1-negN/A
distribute-frac-negN/A
distribute-frac-neg2N/A
mul-1-negN/A
sub-negN/A
div-subN/A
Simplified85.3%
if 3.59999999999999978e-56 < c < 1.8e53Initial program 91.1%
Taylor expanded in a around inf
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
unpow2N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6480.3%
Simplified80.3%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (+ a (/ b (/ c d))) c)))
(if (<= c -1.42e+25)
t_0
(if (<= c 1.9e-57) (/ (+ b (/ (* c a) d)) d) t_0))))
double code(double a, double b, double c, double d) {
double t_0 = (a + (b / (c / d))) / c;
double tmp;
if (c <= -1.42e+25) {
tmp = t_0;
} else if (c <= 1.9e-57) {
tmp = (b + ((c * a) / d)) / d;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: tmp
t_0 = (a + (b / (c / d))) / c
if (c <= (-1.42d+25)) then
tmp = t_0
else if (c <= 1.9d-57) then
tmp = (b + ((c * a) / d)) / d
else
tmp = t_0
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = (a + (b / (c / d))) / c;
double tmp;
if (c <= -1.42e+25) {
tmp = t_0;
} else if (c <= 1.9e-57) {
tmp = (b + ((c * a) / d)) / d;
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b, c, d): t_0 = (a + (b / (c / d))) / c tmp = 0 if c <= -1.42e+25: tmp = t_0 elif c <= 1.9e-57: tmp = (b + ((c * a) / d)) / d else: tmp = t_0 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(a + Float64(b / Float64(c / d))) / c) tmp = 0.0 if (c <= -1.42e+25) tmp = t_0; elseif (c <= 1.9e-57) tmp = Float64(Float64(b + Float64(Float64(c * a) / d)) / d); else tmp = t_0; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (a + (b / (c / d))) / c; tmp = 0.0; if (c <= -1.42e+25) tmp = t_0; elseif (c <= 1.9e-57) tmp = (b + ((c * a) / d)) / d; else tmp = t_0; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(a + N[(b / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]}, If[LessEqual[c, -1.42e+25], t$95$0, If[LessEqual[c, 1.9e-57], N[(N[(b + N[(N[(c * a), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a + \frac{b}{\frac{c}{d}}}{c}\\
\mathbf{if}\;c \leq -1.42 \cdot 10^{+25}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq 1.9 \cdot 10^{-57}:\\
\;\;\;\;\frac{b + \frac{c \cdot a}{d}}{d}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if c < -1.4199999999999999e25 or 1.8999999999999999e-57 < c Initial program 51.0%
Taylor expanded in c around inf
/-lowering-/.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f6478.3%
Simplified78.3%
associate-/l*N/A
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
/-lowering-/.f6481.1%
Applied egg-rr81.1%
if -1.4199999999999999e25 < c < 1.8999999999999999e-57Initial program 73.6%
Taylor expanded in c around 0
remove-double-negN/A
mul-1-negN/A
distribute-frac-negN/A
distribute-frac-neg2N/A
mul-1-negN/A
unpow2N/A
associate-/r*N/A
associate-/l*N/A
associate-/l*N/A
remove-double-negN/A
mul-1-negN/A
distribute-frac-negN/A
mul-1-negN/A
distribute-frac-negN/A
distribute-frac-neg2N/A
mul-1-negN/A
sub-negN/A
div-subN/A
Simplified85.3%
(FPCore (a b c d) :precision binary64 (let* ((t_0 (/ (+ a (/ b (/ c d))) c))) (if (<= c -8.2e+24) t_0 (if (<= c 3.5e-56) (/ (+ b (/ c (/ d a))) d) t_0))))
double code(double a, double b, double c, double d) {
double t_0 = (a + (b / (c / d))) / c;
double tmp;
if (c <= -8.2e+24) {
tmp = t_0;
} else if (c <= 3.5e-56) {
tmp = (b + (c / (d / a))) / d;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: tmp
t_0 = (a + (b / (c / d))) / c
if (c <= (-8.2d+24)) then
tmp = t_0
else if (c <= 3.5d-56) then
tmp = (b + (c / (d / a))) / d
else
tmp = t_0
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = (a + (b / (c / d))) / c;
double tmp;
if (c <= -8.2e+24) {
tmp = t_0;
} else if (c <= 3.5e-56) {
tmp = (b + (c / (d / a))) / d;
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b, c, d): t_0 = (a + (b / (c / d))) / c tmp = 0 if c <= -8.2e+24: tmp = t_0 elif c <= 3.5e-56: tmp = (b + (c / (d / a))) / d else: tmp = t_0 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(a + Float64(b / Float64(c / d))) / c) tmp = 0.0 if (c <= -8.2e+24) tmp = t_0; elseif (c <= 3.5e-56) tmp = Float64(Float64(b + Float64(c / Float64(d / a))) / d); else tmp = t_0; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (a + (b / (c / d))) / c; tmp = 0.0; if (c <= -8.2e+24) tmp = t_0; elseif (c <= 3.5e-56) tmp = (b + (c / (d / a))) / d; else tmp = t_0; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(a + N[(b / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]}, If[LessEqual[c, -8.2e+24], t$95$0, If[LessEqual[c, 3.5e-56], N[(N[(b + N[(c / N[(d / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a + \frac{b}{\frac{c}{d}}}{c}\\
\mathbf{if}\;c \leq -8.2 \cdot 10^{+24}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq 3.5 \cdot 10^{-56}:\\
\;\;\;\;\frac{b + \frac{c}{\frac{d}{a}}}{d}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if c < -8.2000000000000002e24 or 3.4999999999999998e-56 < c Initial program 51.0%
Taylor expanded in c around inf
/-lowering-/.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f6478.3%
Simplified78.3%
associate-/l*N/A
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
/-lowering-/.f6481.1%
Applied egg-rr81.1%
if -8.2000000000000002e24 < c < 3.4999999999999998e-56Initial program 73.6%
Taylor expanded in c around 0
remove-double-negN/A
mul-1-negN/A
distribute-frac-negN/A
distribute-frac-neg2N/A
mul-1-negN/A
unpow2N/A
associate-/r*N/A
associate-/l*N/A
associate-/l*N/A
remove-double-negN/A
mul-1-negN/A
distribute-frac-negN/A
mul-1-negN/A
distribute-frac-negN/A
distribute-frac-neg2N/A
mul-1-negN/A
sub-negN/A
div-subN/A
Simplified85.3%
associate-/l*N/A
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
/-lowering-/.f6484.5%
Applied egg-rr84.5%
(FPCore (a b c d) :precision binary64 (if (<= d -7.5e+74) (/ b d) (if (<= d 5.8e+70) (/ (+ a (/ b (/ c d))) c) (/ b d))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -7.5e+74) {
tmp = b / d;
} else if (d <= 5.8e+70) {
tmp = (a + (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 <= (-7.5d+74)) then
tmp = b / d
else if (d <= 5.8d+70) then
tmp = (a + (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 <= -7.5e+74) {
tmp = b / d;
} else if (d <= 5.8e+70) {
tmp = (a + (b / (c / d))) / c;
} else {
tmp = b / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -7.5e+74: tmp = b / d elif d <= 5.8e+70: tmp = (a + (b / (c / d))) / c else: tmp = b / d return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -7.5e+74) tmp = Float64(b / d); elseif (d <= 5.8e+70) tmp = Float64(Float64(a + Float64(b / Float64(c / d))) / c); else tmp = Float64(b / d); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= -7.5e+74) tmp = b / d; elseif (d <= 5.8e+70) tmp = (a + (b / (c / d))) / c; else tmp = b / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -7.5e+74], N[(b / d), $MachinePrecision], If[LessEqual[d, 5.8e+70], N[(N[(a + N[(b / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], N[(b / d), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -7.5 \cdot 10^{+74}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{elif}\;d \leq 5.8 \cdot 10^{+70}:\\
\;\;\;\;\frac{a + \frac{b}{\frac{c}{d}}}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d}\\
\end{array}
\end{array}
if d < -7.5e74 or 5.7999999999999997e70 < d Initial program 45.7%
Taylor expanded in c around 0
/-lowering-/.f6477.5%
Simplified77.5%
if -7.5e74 < d < 5.7999999999999997e70Initial program 70.0%
Taylor expanded in c around inf
/-lowering-/.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f6479.5%
Simplified79.5%
associate-/l*N/A
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
/-lowering-/.f6480.2%
Applied egg-rr80.2%
(FPCore (a b c d) :precision binary64 (if (<= d -1.65e+58) (/ b d) (if (<= d 225000000.0) (/ a c) (/ b d))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -1.65e+58) {
tmp = b / d;
} else if (d <= 225000000.0) {
tmp = a / 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.65d+58)) then
tmp = b / d
else if (d <= 225000000.0d0) then
tmp = a / 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.65e+58) {
tmp = b / d;
} else if (d <= 225000000.0) {
tmp = a / c;
} else {
tmp = b / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -1.65e+58: tmp = b / d elif d <= 225000000.0: tmp = a / c else: tmp = b / d return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -1.65e+58) tmp = Float64(b / d); elseif (d <= 225000000.0) tmp = Float64(a / c); else tmp = Float64(b / d); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= -1.65e+58) tmp = b / d; elseif (d <= 225000000.0) tmp = a / c; else tmp = b / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -1.65e+58], N[(b / d), $MachinePrecision], If[LessEqual[d, 225000000.0], N[(a / c), $MachinePrecision], N[(b / d), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.65 \cdot 10^{+58}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{elif}\;d \leq 225000000:\\
\;\;\;\;\frac{a}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d}\\
\end{array}
\end{array}
if d < -1.64999999999999991e58 or 2.25e8 < d Initial program 50.2%
Taylor expanded in c around 0
/-lowering-/.f6471.9%
Simplified71.9%
if -1.64999999999999991e58 < d < 2.25e8Initial program 69.2%
Taylor expanded in c around inf
/-lowering-/.f6465.9%
Simplified65.9%
(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 60.6%
Taylor expanded in c around inf
/-lowering-/.f6445.0%
Simplified45.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 2024192
(FPCore (a b c d)
:name "Complex division, real part"
:precision binary64
:alt
(! :herbie-platform default (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))))