
(FPCore (a b c d) :precision binary64 (/ (- (* b c) (* a d)) (+ (* c c) (* d d))))
double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = ((b * c) - (a * d)) / ((c * c) + (d * d))
end function
public static double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
def code(a, b, c, d): return ((b * c) - (a * d)) / ((c * c) + (d * d))
function code(a, b, c, d) return Float64(Float64(Float64(b * c) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d))) end
function tmp = code(a, b, c, d) tmp = ((b * c) - (a * d)) / ((c * c) + (d * d)); end
code[a_, b_, c_, d_] := N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 15 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b c d) :precision binary64 (/ (- (* b c) (* a d)) (+ (* c c) (* d d))))
double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = ((b * c) - (a * d)) / ((c * c) + (d * d))
end function
public static double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
def code(a, b, c, d): return ((b * c) - (a * d)) / ((c * c) + (d * d))
function code(a, b, c, d) return Float64(Float64(Float64(b * c) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d))) end
function tmp = code(a, b, c, d) tmp = ((b * c) - (a * d)) / ((c * c) + (d * d)); end
code[a_, b_, c_, d_] := N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}
\end{array}
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* b c) (* d a)) (+ (* d d) (* c c)))))
(if (<= c -8e+101)
(/ (- b (* (* (pow c -1.0) a) d)) c)
(if (<= c -9.5e-38)
t_0
(if (<= c 1.22e-119)
(/ (- (/ (* b c) d) a) d)
(if (<= c 5.6e+75)
t_0
(fma
(fma
(- (* (/ a (pow c 4.0)) d) (/ b (pow c 3.0)))
d
(/ (/ (- a) c) c))
d
(/ b c))))))))
double code(double a, double b, double c, double d) {
double t_0 = ((b * c) - (d * a)) / ((d * d) + (c * c));
double tmp;
if (c <= -8e+101) {
tmp = (b - ((pow(c, -1.0) * a) * d)) / c;
} else if (c <= -9.5e-38) {
tmp = t_0;
} else if (c <= 1.22e-119) {
tmp = (((b * c) / d) - a) / d;
} else if (c <= 5.6e+75) {
tmp = t_0;
} else {
tmp = fma(fma((((a / pow(c, 4.0)) * d) - (b / pow(c, 3.0))), d, ((-a / c) / c)), d, (b / c));
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(Float64(b * c) - Float64(d * a)) / Float64(Float64(d * d) + Float64(c * c))) tmp = 0.0 if (c <= -8e+101) tmp = Float64(Float64(b - Float64(Float64((c ^ -1.0) * a) * d)) / c); elseif (c <= -9.5e-38) tmp = t_0; elseif (c <= 1.22e-119) tmp = Float64(Float64(Float64(Float64(b * c) / d) - a) / d); elseif (c <= 5.6e+75) tmp = t_0; else tmp = fma(fma(Float64(Float64(Float64(a / (c ^ 4.0)) * d) - Float64(b / (c ^ 3.0))), d, Float64(Float64(Float64(-a) / c) / c)), d, Float64(b / c)); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(b * c), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(d * d), $MachinePrecision] + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -8e+101], N[(N[(b - N[(N[(N[Power[c, -1.0], $MachinePrecision] * a), $MachinePrecision] * d), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[c, -9.5e-38], t$95$0, If[LessEqual[c, 1.22e-119], N[(N[(N[(N[(b * c), $MachinePrecision] / d), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 5.6e+75], t$95$0, N[(N[(N[(N[(N[(a / N[Power[c, 4.0], $MachinePrecision]), $MachinePrecision] * d), $MachinePrecision] - N[(b / N[Power[c, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * d + N[(N[((-a) / c), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] * d + N[(b / c), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b \cdot c - d \cdot a}{d \cdot d + c \cdot c}\\
\mathbf{if}\;c \leq -8 \cdot 10^{+101}:\\
\;\;\;\;\frac{b - \left({c}^{-1} \cdot a\right) \cdot d}{c}\\
\mathbf{elif}\;c \leq -9.5 \cdot 10^{-38}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq 1.22 \cdot 10^{-119}:\\
\;\;\;\;\frac{\frac{b \cdot c}{d} - a}{d}\\
\mathbf{elif}\;c \leq 5.6 \cdot 10^{+75}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\frac{a}{{c}^{4}} \cdot d - \frac{b}{{c}^{3}}, d, \frac{\frac{-a}{c}}{c}\right), d, \frac{b}{c}\right)\\
\end{array}
\end{array}
if c < -7.9999999999999998e101Initial program 39.1%
Taylor expanded in c around inf
lower-/.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6480.9
Applied rewrites80.9%
Applied rewrites86.1%
if -7.9999999999999998e101 < c < -9.5000000000000009e-38 or 1.22e-119 < c < 5.60000000000000023e75Initial program 86.7%
if -9.5000000000000009e-38 < c < 1.22e-119Initial program 71.3%
Taylor expanded in c around 0
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
unpow2N/A
associate-/r*N/A
div-subN/A
lower-/.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6492.7
Applied rewrites92.7%
if 5.60000000000000023e75 < c Initial program 44.5%
Taylor expanded in d around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites86.9%
Final simplification88.7%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* b c) (* d a)) (+ (* d d) (* c c))))
(t_1 (/ (- b (* (* (pow c -1.0) a) d)) c)))
(if (<= c -8e+101)
t_1
(if (<= c -9.5e-38)
t_0
(if (<= c 1.22e-119)
(/ (- (/ (* b c) d) a) d)
(if (<= c 2.6e+63) t_0 t_1))))))
double code(double a, double b, double c, double d) {
double t_0 = ((b * c) - (d * a)) / ((d * d) + (c * c));
double t_1 = (b - ((pow(c, -1.0) * a) * d)) / c;
double tmp;
if (c <= -8e+101) {
tmp = t_1;
} else if (c <= -9.5e-38) {
tmp = t_0;
} else if (c <= 1.22e-119) {
tmp = (((b * c) / d) - a) / d;
} else if (c <= 2.6e+63) {
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 = ((b * c) - (d * a)) / ((d * d) + (c * c))
t_1 = (b - (((c ** (-1.0d0)) * a) * d)) / c
if (c <= (-8d+101)) then
tmp = t_1
else if (c <= (-9.5d-38)) then
tmp = t_0
else if (c <= 1.22d-119) then
tmp = (((b * c) / d) - a) / d
else if (c <= 2.6d+63) 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 = ((b * c) - (d * a)) / ((d * d) + (c * c));
double t_1 = (b - ((Math.pow(c, -1.0) * a) * d)) / c;
double tmp;
if (c <= -8e+101) {
tmp = t_1;
} else if (c <= -9.5e-38) {
tmp = t_0;
} else if (c <= 1.22e-119) {
tmp = (((b * c) / d) - a) / d;
} else if (c <= 2.6e+63) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(a, b, c, d): t_0 = ((b * c) - (d * a)) / ((d * d) + (c * c)) t_1 = (b - ((math.pow(c, -1.0) * a) * d)) / c tmp = 0 if c <= -8e+101: tmp = t_1 elif c <= -9.5e-38: tmp = t_0 elif c <= 1.22e-119: tmp = (((b * c) / d) - a) / d elif c <= 2.6e+63: tmp = t_0 else: tmp = t_1 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(Float64(b * c) - Float64(d * a)) / Float64(Float64(d * d) + Float64(c * c))) t_1 = Float64(Float64(b - Float64(Float64((c ^ -1.0) * a) * d)) / c) tmp = 0.0 if (c <= -8e+101) tmp = t_1; elseif (c <= -9.5e-38) tmp = t_0; elseif (c <= 1.22e-119) tmp = Float64(Float64(Float64(Float64(b * c) / d) - a) / d); elseif (c <= 2.6e+63) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((b * c) - (d * a)) / ((d * d) + (c * c)); t_1 = (b - (((c ^ -1.0) * a) * d)) / c; tmp = 0.0; if (c <= -8e+101) tmp = t_1; elseif (c <= -9.5e-38) tmp = t_0; elseif (c <= 1.22e-119) tmp = (((b * c) / d) - a) / d; elseif (c <= 2.6e+63) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(b * c), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(d * d), $MachinePrecision] + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(b - N[(N[(N[Power[c, -1.0], $MachinePrecision] * a), $MachinePrecision] * d), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]}, If[LessEqual[c, -8e+101], t$95$1, If[LessEqual[c, -9.5e-38], t$95$0, If[LessEqual[c, 1.22e-119], N[(N[(N[(N[(b * c), $MachinePrecision] / d), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 2.6e+63], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b \cdot c - d \cdot a}{d \cdot d + c \cdot c}\\
t_1 := \frac{b - \left({c}^{-1} \cdot a\right) \cdot d}{c}\\
\mathbf{if}\;c \leq -8 \cdot 10^{+101}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;c \leq -9.5 \cdot 10^{-38}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq 1.22 \cdot 10^{-119}:\\
\;\;\;\;\frac{\frac{b \cdot c}{d} - a}{d}\\
\mathbf{elif}\;c \leq 2.6 \cdot 10^{+63}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if c < -7.9999999999999998e101 or 2.6000000000000001e63 < c Initial program 42.3%
Taylor expanded in c around inf
lower-/.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6481.6
Applied rewrites81.6%
Applied rewrites84.9%
if -7.9999999999999998e101 < c < -9.5000000000000009e-38 or 1.22e-119 < c < 2.6000000000000001e63Initial program 89.2%
if -9.5000000000000009e-38 < c < 1.22e-119Initial program 71.3%
Taylor expanded in c around 0
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
unpow2N/A
associate-/r*N/A
div-subN/A
lower-/.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6492.7
Applied rewrites92.7%
Final simplification88.5%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* b c) (* d a)) (+ (* d d) (* c c))))
(t_1 (* (/ -1.0 c) (fma b -1.0 (* (/ a c) d)))))
(if (<= c -8e+101)
t_1
(if (<= c -9.5e-38)
t_0
(if (<= c 1.22e-119)
(/ (- (/ (* b c) d) a) d)
(if (<= c 4.4e+86) t_0 t_1))))))
double code(double a, double b, double c, double d) {
double t_0 = ((b * c) - (d * a)) / ((d * d) + (c * c));
double t_1 = (-1.0 / c) * fma(b, -1.0, ((a / c) * d));
double tmp;
if (c <= -8e+101) {
tmp = t_1;
} else if (c <= -9.5e-38) {
tmp = t_0;
} else if (c <= 1.22e-119) {
tmp = (((b * c) / d) - a) / d;
} else if (c <= 4.4e+86) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(Float64(b * c) - Float64(d * a)) / Float64(Float64(d * d) + Float64(c * c))) t_1 = Float64(Float64(-1.0 / c) * fma(b, -1.0, Float64(Float64(a / c) * d))) tmp = 0.0 if (c <= -8e+101) tmp = t_1; elseif (c <= -9.5e-38) tmp = t_0; elseif (c <= 1.22e-119) tmp = Float64(Float64(Float64(Float64(b * c) / d) - a) / d); elseif (c <= 4.4e+86) tmp = t_0; else tmp = t_1; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(b * c), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(d * d), $MachinePrecision] + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(-1.0 / c), $MachinePrecision] * N[(b * -1.0 + N[(N[(a / c), $MachinePrecision] * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -8e+101], t$95$1, If[LessEqual[c, -9.5e-38], t$95$0, If[LessEqual[c, 1.22e-119], N[(N[(N[(N[(b * c), $MachinePrecision] / d), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 4.4e+86], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b \cdot c - d \cdot a}{d \cdot d + c \cdot c}\\
t_1 := \frac{-1}{c} \cdot \mathsf{fma}\left(b, -1, \frac{a}{c} \cdot d\right)\\
\mathbf{if}\;c \leq -8 \cdot 10^{+101}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;c \leq -9.5 \cdot 10^{-38}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq 1.22 \cdot 10^{-119}:\\
\;\;\;\;\frac{\frac{b \cdot c}{d} - a}{d}\\
\mathbf{elif}\;c \leq 4.4 \cdot 10^{+86}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if c < -7.9999999999999998e101 or 4.40000000000000006e86 < c Initial program 41.4%
Taylor expanded in c around inf
lower-/.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6482.6
Applied rewrites82.6%
Applied rewrites86.0%
Applied rewrites85.8%
if -7.9999999999999998e101 < c < -9.5000000000000009e-38 or 1.22e-119 < c < 4.40000000000000006e86Initial program 86.9%
if -9.5000000000000009e-38 < c < 1.22e-119Initial program 71.3%
Taylor expanded in c around 0
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
unpow2N/A
associate-/r*N/A
div-subN/A
lower-/.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6492.7
Applied rewrites92.7%
Final simplification88.5%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* b c) (* d a)) (+ (* d d) (* c c))))
(t_1 (/ (- b (/ (* d a) c)) c)))
(if (<= c -3.4e+111)
t_1
(if (<= c -9.5e-38)
t_0
(if (<= c 1.22e-119)
(/ (- (/ (* b c) d) a) d)
(if (<= c 2.6e+63) t_0 t_1))))))
double code(double a, double b, double c, double d) {
double t_0 = ((b * c) - (d * a)) / ((d * d) + (c * c));
double t_1 = (b - ((d * a) / c)) / c;
double tmp;
if (c <= -3.4e+111) {
tmp = t_1;
} else if (c <= -9.5e-38) {
tmp = t_0;
} else if (c <= 1.22e-119) {
tmp = (((b * c) / d) - a) / d;
} else if (c <= 2.6e+63) {
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 = ((b * c) - (d * a)) / ((d * d) + (c * c))
t_1 = (b - ((d * a) / c)) / c
if (c <= (-3.4d+111)) then
tmp = t_1
else if (c <= (-9.5d-38)) then
tmp = t_0
else if (c <= 1.22d-119) then
tmp = (((b * c) / d) - a) / d
else if (c <= 2.6d+63) 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 = ((b * c) - (d * a)) / ((d * d) + (c * c));
double t_1 = (b - ((d * a) / c)) / c;
double tmp;
if (c <= -3.4e+111) {
tmp = t_1;
} else if (c <= -9.5e-38) {
tmp = t_0;
} else if (c <= 1.22e-119) {
tmp = (((b * c) / d) - a) / d;
} else if (c <= 2.6e+63) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(a, b, c, d): t_0 = ((b * c) - (d * a)) / ((d * d) + (c * c)) t_1 = (b - ((d * a) / c)) / c tmp = 0 if c <= -3.4e+111: tmp = t_1 elif c <= -9.5e-38: tmp = t_0 elif c <= 1.22e-119: tmp = (((b * c) / d) - a) / d elif c <= 2.6e+63: tmp = t_0 else: tmp = t_1 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(Float64(b * c) - Float64(d * a)) / Float64(Float64(d * d) + Float64(c * c))) t_1 = Float64(Float64(b - Float64(Float64(d * a) / c)) / c) tmp = 0.0 if (c <= -3.4e+111) tmp = t_1; elseif (c <= -9.5e-38) tmp = t_0; elseif (c <= 1.22e-119) tmp = Float64(Float64(Float64(Float64(b * c) / d) - a) / d); elseif (c <= 2.6e+63) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((b * c) - (d * a)) / ((d * d) + (c * c)); t_1 = (b - ((d * a) / c)) / c; tmp = 0.0; if (c <= -3.4e+111) tmp = t_1; elseif (c <= -9.5e-38) tmp = t_0; elseif (c <= 1.22e-119) tmp = (((b * c) / d) - a) / d; elseif (c <= 2.6e+63) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(b * c), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(d * d), $MachinePrecision] + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]}, If[LessEqual[c, -3.4e+111], t$95$1, If[LessEqual[c, -9.5e-38], t$95$0, If[LessEqual[c, 1.22e-119], N[(N[(N[(N[(b * c), $MachinePrecision] / d), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 2.6e+63], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b \cdot c - d \cdot a}{d \cdot d + c \cdot c}\\
t_1 := \frac{b - \frac{d \cdot a}{c}}{c}\\
\mathbf{if}\;c \leq -3.4 \cdot 10^{+111}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;c \leq -9.5 \cdot 10^{-38}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq 1.22 \cdot 10^{-119}:\\
\;\;\;\;\frac{\frac{b \cdot c}{d} - a}{d}\\
\mathbf{elif}\;c \leq 2.6 \cdot 10^{+63}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if c < -3.4000000000000001e111 or 2.6000000000000001e63 < c Initial program 42.5%
Taylor expanded in c around inf
lower-/.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6483.8
Applied rewrites83.8%
if -3.4000000000000001e111 < c < -9.5000000000000009e-38 or 1.22e-119 < c < 2.6000000000000001e63Initial program 86.5%
if -9.5000000000000009e-38 < c < 1.22e-119Initial program 71.3%
Taylor expanded in c around 0
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
unpow2N/A
associate-/r*N/A
div-subN/A
lower-/.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6492.7
Applied rewrites92.7%
Final simplification87.5%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (fma (- d) a (* b c))))
(if (<= c -1.25e+123)
(/ 1.0 (/ c b))
(if (<= c -2.1e-14)
(* (/ b (fma d d (* c c))) c)
(if (<= c 1e-67)
(/ t_0 (* d d))
(if (<= c 3.8e+88) (/ t_0 (* c c)) (/ b c)))))))
double code(double a, double b, double c, double d) {
double t_0 = fma(-d, a, (b * c));
double tmp;
if (c <= -1.25e+123) {
tmp = 1.0 / (c / b);
} else if (c <= -2.1e-14) {
tmp = (b / fma(d, d, (c * c))) * c;
} else if (c <= 1e-67) {
tmp = t_0 / (d * d);
} else if (c <= 3.8e+88) {
tmp = t_0 / (c * c);
} else {
tmp = b / c;
}
return tmp;
}
function code(a, b, c, d) t_0 = fma(Float64(-d), a, Float64(b * c)) tmp = 0.0 if (c <= -1.25e+123) tmp = Float64(1.0 / Float64(c / b)); elseif (c <= -2.1e-14) tmp = Float64(Float64(b / fma(d, d, Float64(c * c))) * c); elseif (c <= 1e-67) tmp = Float64(t_0 / Float64(d * d)); elseif (c <= 3.8e+88) tmp = Float64(t_0 / Float64(c * c)); else tmp = Float64(b / c); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[((-d) * a + N[(b * c), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -1.25e+123], N[(1.0 / N[(c / b), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -2.1e-14], N[(N[(b / N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * c), $MachinePrecision], If[LessEqual[c, 1e-67], N[(t$95$0 / N[(d * d), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 3.8e+88], N[(t$95$0 / N[(c * c), $MachinePrecision]), $MachinePrecision], N[(b / c), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(-d, a, b \cdot c\right)\\
\mathbf{if}\;c \leq -1.25 \cdot 10^{+123}:\\
\;\;\;\;\frac{1}{\frac{c}{b}}\\
\mathbf{elif}\;c \leq -2.1 \cdot 10^{-14}:\\
\;\;\;\;\frac{b}{\mathsf{fma}\left(d, d, c \cdot c\right)} \cdot c\\
\mathbf{elif}\;c \leq 10^{-67}:\\
\;\;\;\;\frac{t\_0}{d \cdot d}\\
\mathbf{elif}\;c \leq 3.8 \cdot 10^{+88}:\\
\;\;\;\;\frac{t\_0}{c \cdot c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if c < -1.24999999999999994e123Initial program 39.5%
Taylor expanded in c around inf
lower-/.f6476.7
Applied rewrites76.7%
Applied rewrites77.5%
if -1.24999999999999994e123 < c < -2.0999999999999999e-14Initial program 74.9%
Taylor expanded in a around 0
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
+-commutativeN/A
unpow2N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6480.9
Applied rewrites80.9%
if -2.0999999999999999e-14 < c < 9.99999999999999943e-68Initial program 74.2%
Taylor expanded in c around 0
unpow2N/A
lower-*.f6467.7
Applied rewrites67.7%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f6467.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6467.7
Applied rewrites67.7%
if 9.99999999999999943e-68 < c < 3.7999999999999997e88Initial program 88.7%
Taylor expanded in c around inf
unpow2N/A
lower-*.f6475.3
Applied rewrites75.3%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-outN/A
lift-neg.f64N/A
lower-fma.f6475.3
Applied rewrites75.3%
if 3.7999999999999997e88 < c Initial program 43.5%
Taylor expanded in c around inf
lower-/.f6478.3
Applied rewrites78.3%
Final simplification74.1%
(FPCore (a b c d)
:precision binary64
(if (<= c -1.25e+123)
(/ 1.0 (/ c b))
(if (<= c -2.1e-14)
(* (/ b (fma d d (* c c))) c)
(if (<= c 1e-67)
(/ (- (* b c) (* d a)) (* d d))
(if (<= c 3.8e+88) (/ (fma (- d) a (* b c)) (* c c)) (/ b c))))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -1.25e+123) {
tmp = 1.0 / (c / b);
} else if (c <= -2.1e-14) {
tmp = (b / fma(d, d, (c * c))) * c;
} else if (c <= 1e-67) {
tmp = ((b * c) - (d * a)) / (d * d);
} else if (c <= 3.8e+88) {
tmp = fma(-d, a, (b * c)) / (c * c);
} else {
tmp = b / c;
}
return tmp;
}
function code(a, b, c, d) tmp = 0.0 if (c <= -1.25e+123) tmp = Float64(1.0 / Float64(c / b)); elseif (c <= -2.1e-14) tmp = Float64(Float64(b / fma(d, d, Float64(c * c))) * c); elseif (c <= 1e-67) tmp = Float64(Float64(Float64(b * c) - Float64(d * a)) / Float64(d * d)); elseif (c <= 3.8e+88) tmp = Float64(fma(Float64(-d), a, Float64(b * c)) / Float64(c * c)); else tmp = Float64(b / c); end return tmp end
code[a_, b_, c_, d_] := If[LessEqual[c, -1.25e+123], N[(1.0 / N[(c / b), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -2.1e-14], N[(N[(b / N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * c), $MachinePrecision], If[LessEqual[c, 1e-67], N[(N[(N[(b * c), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(d * d), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 3.8e+88], N[(N[((-d) * a + N[(b * c), $MachinePrecision]), $MachinePrecision] / N[(c * c), $MachinePrecision]), $MachinePrecision], N[(b / c), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.25 \cdot 10^{+123}:\\
\;\;\;\;\frac{1}{\frac{c}{b}}\\
\mathbf{elif}\;c \leq -2.1 \cdot 10^{-14}:\\
\;\;\;\;\frac{b}{\mathsf{fma}\left(d, d, c \cdot c\right)} \cdot c\\
\mathbf{elif}\;c \leq 10^{-67}:\\
\;\;\;\;\frac{b \cdot c - d \cdot a}{d \cdot d}\\
\mathbf{elif}\;c \leq 3.8 \cdot 10^{+88}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-d, a, b \cdot c\right)}{c \cdot c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if c < -1.24999999999999994e123Initial program 39.5%
Taylor expanded in c around inf
lower-/.f6476.7
Applied rewrites76.7%
Applied rewrites77.5%
if -1.24999999999999994e123 < c < -2.0999999999999999e-14Initial program 74.9%
Taylor expanded in a around 0
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
+-commutativeN/A
unpow2N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6480.9
Applied rewrites80.9%
if -2.0999999999999999e-14 < c < 9.99999999999999943e-68Initial program 74.2%
Taylor expanded in c around 0
unpow2N/A
lower-*.f6467.7
Applied rewrites67.7%
if 9.99999999999999943e-68 < c < 3.7999999999999997e88Initial program 88.7%
Taylor expanded in c around inf
unpow2N/A
lower-*.f6475.3
Applied rewrites75.3%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-outN/A
lift-neg.f64N/A
lower-fma.f6475.3
Applied rewrites75.3%
if 3.7999999999999997e88 < c Initial program 43.5%
Taylor expanded in c around inf
lower-/.f6478.3
Applied rewrites78.3%
Final simplification74.0%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (- (* b c) (* d a))))
(if (<= c -1.25e+123)
(/ 1.0 (/ c b))
(if (<= c -2.1e-14)
(* (/ b (fma d d (* c c))) c)
(if (<= c 1e-67)
(/ t_0 (* d d))
(if (<= c 3.8e+88) (/ t_0 (* c c)) (/ b c)))))))
double code(double a, double b, double c, double d) {
double t_0 = (b * c) - (d * a);
double tmp;
if (c <= -1.25e+123) {
tmp = 1.0 / (c / b);
} else if (c <= -2.1e-14) {
tmp = (b / fma(d, d, (c * c))) * c;
} else if (c <= 1e-67) {
tmp = t_0 / (d * d);
} else if (c <= 3.8e+88) {
tmp = t_0 / (c * c);
} else {
tmp = b / c;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(b * c) - Float64(d * a)) tmp = 0.0 if (c <= -1.25e+123) tmp = Float64(1.0 / Float64(c / b)); elseif (c <= -2.1e-14) tmp = Float64(Float64(b / fma(d, d, Float64(c * c))) * c); elseif (c <= 1e-67) tmp = Float64(t_0 / Float64(d * d)); elseif (c <= 3.8e+88) tmp = Float64(t_0 / Float64(c * c)); else tmp = Float64(b / c); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(b * c), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -1.25e+123], N[(1.0 / N[(c / b), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -2.1e-14], N[(N[(b / N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * c), $MachinePrecision], If[LessEqual[c, 1e-67], N[(t$95$0 / N[(d * d), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 3.8e+88], N[(t$95$0 / N[(c * c), $MachinePrecision]), $MachinePrecision], N[(b / c), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := b \cdot c - d \cdot a\\
\mathbf{if}\;c \leq -1.25 \cdot 10^{+123}:\\
\;\;\;\;\frac{1}{\frac{c}{b}}\\
\mathbf{elif}\;c \leq -2.1 \cdot 10^{-14}:\\
\;\;\;\;\frac{b}{\mathsf{fma}\left(d, d, c \cdot c\right)} \cdot c\\
\mathbf{elif}\;c \leq 10^{-67}:\\
\;\;\;\;\frac{t\_0}{d \cdot d}\\
\mathbf{elif}\;c \leq 3.8 \cdot 10^{+88}:\\
\;\;\;\;\frac{t\_0}{c \cdot c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if c < -1.24999999999999994e123Initial program 39.5%
Taylor expanded in c around inf
lower-/.f6476.7
Applied rewrites76.7%
Applied rewrites77.5%
if -1.24999999999999994e123 < c < -2.0999999999999999e-14Initial program 74.9%
Taylor expanded in a around 0
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
+-commutativeN/A
unpow2N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6480.9
Applied rewrites80.9%
if -2.0999999999999999e-14 < c < 9.99999999999999943e-68Initial program 74.2%
Taylor expanded in c around 0
unpow2N/A
lower-*.f6467.7
Applied rewrites67.7%
if 9.99999999999999943e-68 < c < 3.7999999999999997e88Initial program 88.7%
Taylor expanded in c around inf
unpow2N/A
lower-*.f6475.3
Applied rewrites75.3%
if 3.7999999999999997e88 < c Initial program 43.5%
Taylor expanded in c around inf
lower-/.f6478.3
Applied rewrites78.3%
Final simplification74.0%
(FPCore (a b c d)
:precision binary64
(if (<= c -1.25e+123)
(/ 1.0 (/ c b))
(if (<= c -2.65e-14)
(* (/ b (fma d d (* c c))) c)
(if (<= c 8e-74)
(/ (- a) d)
(if (<= c 3.8e+88) (/ (- (* b c) (* d a)) (* c c)) (/ b c))))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -1.25e+123) {
tmp = 1.0 / (c / b);
} else if (c <= -2.65e-14) {
tmp = (b / fma(d, d, (c * c))) * c;
} else if (c <= 8e-74) {
tmp = -a / d;
} else if (c <= 3.8e+88) {
tmp = ((b * c) - (d * a)) / (c * c);
} else {
tmp = b / c;
}
return tmp;
}
function code(a, b, c, d) tmp = 0.0 if (c <= -1.25e+123) tmp = Float64(1.0 / Float64(c / b)); elseif (c <= -2.65e-14) tmp = Float64(Float64(b / fma(d, d, Float64(c * c))) * c); elseif (c <= 8e-74) tmp = Float64(Float64(-a) / d); elseif (c <= 3.8e+88) tmp = Float64(Float64(Float64(b * c) - Float64(d * a)) / Float64(c * c)); else tmp = Float64(b / c); end return tmp end
code[a_, b_, c_, d_] := If[LessEqual[c, -1.25e+123], N[(1.0 / N[(c / b), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -2.65e-14], N[(N[(b / N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * c), $MachinePrecision], If[LessEqual[c, 8e-74], N[((-a) / d), $MachinePrecision], If[LessEqual[c, 3.8e+88], N[(N[(N[(b * c), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(c * c), $MachinePrecision]), $MachinePrecision], N[(b / c), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.25 \cdot 10^{+123}:\\
\;\;\;\;\frac{1}{\frac{c}{b}}\\
\mathbf{elif}\;c \leq -2.65 \cdot 10^{-14}:\\
\;\;\;\;\frac{b}{\mathsf{fma}\left(d, d, c \cdot c\right)} \cdot c\\
\mathbf{elif}\;c \leq 8 \cdot 10^{-74}:\\
\;\;\;\;\frac{-a}{d}\\
\mathbf{elif}\;c \leq 3.8 \cdot 10^{+88}:\\
\;\;\;\;\frac{b \cdot c - d \cdot a}{c \cdot c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if c < -1.24999999999999994e123Initial program 39.5%
Taylor expanded in c around inf
lower-/.f6476.7
Applied rewrites76.7%
Applied rewrites77.5%
if -1.24999999999999994e123 < c < -2.6500000000000001e-14Initial program 74.9%
Taylor expanded in a around 0
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
+-commutativeN/A
unpow2N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6480.9
Applied rewrites80.9%
if -2.6500000000000001e-14 < c < 7.99999999999999966e-74Initial program 73.9%
Taylor expanded in c around 0
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6465.3
Applied rewrites65.3%
if 7.99999999999999966e-74 < c < 3.7999999999999997e88Initial program 89.2%
Taylor expanded in c around inf
unpow2N/A
lower-*.f6472.0
Applied rewrites72.0%
if 3.7999999999999997e88 < c Initial program 43.5%
Taylor expanded in c around inf
lower-/.f6478.3
Applied rewrites78.3%
Final simplification72.8%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (* (/ b (fma d d (* c c))) c)))
(if (<= c -1.25e+123)
(/ 1.0 (/ c b))
(if (<= c -2.65e-14)
t_0
(if (<= c 1.12e-92) (/ (- a) d) (if (<= c 4.1e+119) t_0 (/ b c)))))))
double code(double a, double b, double c, double d) {
double t_0 = (b / fma(d, d, (c * c))) * c;
double tmp;
if (c <= -1.25e+123) {
tmp = 1.0 / (c / b);
} else if (c <= -2.65e-14) {
tmp = t_0;
} else if (c <= 1.12e-92) {
tmp = -a / d;
} else if (c <= 4.1e+119) {
tmp = t_0;
} else {
tmp = b / c;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(b / fma(d, d, Float64(c * c))) * c) tmp = 0.0 if (c <= -1.25e+123) tmp = Float64(1.0 / Float64(c / b)); elseif (c <= -2.65e-14) tmp = t_0; elseif (c <= 1.12e-92) tmp = Float64(Float64(-a) / d); elseif (c <= 4.1e+119) tmp = t_0; else tmp = Float64(b / c); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(b / N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * c), $MachinePrecision]}, If[LessEqual[c, -1.25e+123], N[(1.0 / N[(c / b), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -2.65e-14], t$95$0, If[LessEqual[c, 1.12e-92], N[((-a) / d), $MachinePrecision], If[LessEqual[c, 4.1e+119], t$95$0, N[(b / c), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b}{\mathsf{fma}\left(d, d, c \cdot c\right)} \cdot c\\
\mathbf{if}\;c \leq -1.25 \cdot 10^{+123}:\\
\;\;\;\;\frac{1}{\frac{c}{b}}\\
\mathbf{elif}\;c \leq -2.65 \cdot 10^{-14}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq 1.12 \cdot 10^{-92}:\\
\;\;\;\;\frac{-a}{d}\\
\mathbf{elif}\;c \leq 4.1 \cdot 10^{+119}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if c < -1.24999999999999994e123Initial program 39.5%
Taylor expanded in c around inf
lower-/.f6476.7
Applied rewrites76.7%
Applied rewrites77.5%
if -1.24999999999999994e123 < c < -2.6500000000000001e-14 or 1.11999999999999999e-92 < c < 4.0999999999999997e119Initial program 77.2%
Taylor expanded in a around 0
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
+-commutativeN/A
unpow2N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6472.8
Applied rewrites72.8%
if -2.6500000000000001e-14 < c < 1.11999999999999999e-92Initial program 73.4%
Taylor expanded in c around 0
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6466.0
Applied rewrites66.0%
if 4.0999999999999997e119 < c Initial program 42.2%
Taylor expanded in c around inf
lower-/.f6482.3
Applied rewrites82.3%
Final simplification72.8%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- b (/ (* d a) c)) c)))
(if (<= c -7.6e+121)
t_0
(if (<= c -1.85e-8)
(* (/ b (fma d d (* c c))) c)
(if (<= c 2e-67) (/ (- (/ (* b c) d) a) d) t_0)))))
double code(double a, double b, double c, double d) {
double t_0 = (b - ((d * a) / c)) / c;
double tmp;
if (c <= -7.6e+121) {
tmp = t_0;
} else if (c <= -1.85e-8) {
tmp = (b / fma(d, d, (c * c))) * c;
} else if (c <= 2e-67) {
tmp = (((b * c) / d) - a) / d;
} else {
tmp = t_0;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(b - Float64(Float64(d * a) / c)) / c) tmp = 0.0 if (c <= -7.6e+121) tmp = t_0; elseif (c <= -1.85e-8) tmp = Float64(Float64(b / fma(d, d, Float64(c * c))) * c); elseif (c <= 2e-67) tmp = Float64(Float64(Float64(Float64(b * c) / d) - a) / d); else tmp = t_0; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]}, If[LessEqual[c, -7.6e+121], t$95$0, If[LessEqual[c, -1.85e-8], N[(N[(b / N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * c), $MachinePrecision], If[LessEqual[c, 2e-67], N[(N[(N[(N[(b * c), $MachinePrecision] / d), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b - \frac{d \cdot a}{c}}{c}\\
\mathbf{if}\;c \leq -7.6 \cdot 10^{+121}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq -1.85 \cdot 10^{-8}:\\
\;\;\;\;\frac{b}{\mathsf{fma}\left(d, d, c \cdot c\right)} \cdot c\\
\mathbf{elif}\;c \leq 2 \cdot 10^{-67}:\\
\;\;\;\;\frac{\frac{b \cdot c}{d} - a}{d}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if c < -7.6e121 or 1.99999999999999989e-67 < c Initial program 49.3%
Taylor expanded in c around inf
lower-/.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6483.5
Applied rewrites83.5%
if -7.6e121 < c < -1.85e-8Initial program 76.4%
Taylor expanded in a around 0
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
+-commutativeN/A
unpow2N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6479.8
Applied rewrites79.8%
if -1.85e-8 < c < 1.99999999999999989e-67Initial program 74.4%
Taylor expanded in c around 0
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
unpow2N/A
associate-/r*N/A
div-subN/A
lower-/.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6489.1
Applied rewrites89.1%
Final simplification85.3%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- b (/ (* d a) c)) c)))
(if (<= c -7.6e+121)
t_0
(if (<= c -1.85e-8)
(* (/ b (fma d d (* c c))) c)
(if (<= c 2e-67) (/ (- (* (/ b d) c) a) d) t_0)))))
double code(double a, double b, double c, double d) {
double t_0 = (b - ((d * a) / c)) / c;
double tmp;
if (c <= -7.6e+121) {
tmp = t_0;
} else if (c <= -1.85e-8) {
tmp = (b / fma(d, d, (c * c))) * c;
} else if (c <= 2e-67) {
tmp = (((b / d) * c) - a) / d;
} else {
tmp = t_0;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(b - Float64(Float64(d * a) / c)) / c) tmp = 0.0 if (c <= -7.6e+121) tmp = t_0; elseif (c <= -1.85e-8) tmp = Float64(Float64(b / fma(d, d, Float64(c * c))) * c); elseif (c <= 2e-67) tmp = Float64(Float64(Float64(Float64(b / d) * c) - a) / d); else tmp = t_0; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]}, If[LessEqual[c, -7.6e+121], t$95$0, If[LessEqual[c, -1.85e-8], N[(N[(b / N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * c), $MachinePrecision], If[LessEqual[c, 2e-67], N[(N[(N[(N[(b / d), $MachinePrecision] * c), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b - \frac{d \cdot a}{c}}{c}\\
\mathbf{if}\;c \leq -7.6 \cdot 10^{+121}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq -1.85 \cdot 10^{-8}:\\
\;\;\;\;\frac{b}{\mathsf{fma}\left(d, d, c \cdot c\right)} \cdot c\\
\mathbf{elif}\;c \leq 2 \cdot 10^{-67}:\\
\;\;\;\;\frac{\frac{b}{d} \cdot c - a}{d}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if c < -7.6e121 or 1.99999999999999989e-67 < c Initial program 49.3%
Taylor expanded in c around inf
lower-/.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6483.5
Applied rewrites83.5%
if -7.6e121 < c < -1.85e-8Initial program 76.4%
Taylor expanded in a around 0
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
+-commutativeN/A
unpow2N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6479.8
Applied rewrites79.8%
if -1.85e-8 < c < 1.99999999999999989e-67Initial program 74.4%
Taylor expanded in c around 0
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
unpow2N/A
associate-/r*N/A
div-subN/A
lower-/.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6489.1
Applied rewrites89.1%
Applied rewrites86.4%
Final simplification84.2%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- b (/ (* d a) c)) c)))
(if (<= c -7.6e+121)
t_0
(if (<= c -2.1e-14)
(* (/ b (fma d d (* c c))) c)
(if (<= c 1e-67) (/ (fma (- d) a (* b c)) (* d d)) t_0)))))
double code(double a, double b, double c, double d) {
double t_0 = (b - ((d * a) / c)) / c;
double tmp;
if (c <= -7.6e+121) {
tmp = t_0;
} else if (c <= -2.1e-14) {
tmp = (b / fma(d, d, (c * c))) * c;
} else if (c <= 1e-67) {
tmp = fma(-d, a, (b * c)) / (d * d);
} else {
tmp = t_0;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(b - Float64(Float64(d * a) / c)) / c) tmp = 0.0 if (c <= -7.6e+121) tmp = t_0; elseif (c <= -2.1e-14) tmp = Float64(Float64(b / fma(d, d, Float64(c * c))) * c); elseif (c <= 1e-67) tmp = Float64(fma(Float64(-d), a, Float64(b * c)) / Float64(d * d)); else tmp = t_0; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]}, If[LessEqual[c, -7.6e+121], t$95$0, If[LessEqual[c, -2.1e-14], N[(N[(b / N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * c), $MachinePrecision], If[LessEqual[c, 1e-67], N[(N[((-d) * a + N[(b * c), $MachinePrecision]), $MachinePrecision] / N[(d * d), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b - \frac{d \cdot a}{c}}{c}\\
\mathbf{if}\;c \leq -7.6 \cdot 10^{+121}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq -2.1 \cdot 10^{-14}:\\
\;\;\;\;\frac{b}{\mathsf{fma}\left(d, d, c \cdot c\right)} \cdot c\\
\mathbf{elif}\;c \leq 10^{-67}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-d, a, b \cdot c\right)}{d \cdot d}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if c < -7.6e121 or 9.99999999999999943e-68 < c Initial program 49.3%
Taylor expanded in c around inf
lower-/.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6483.5
Applied rewrites83.5%
if -7.6e121 < c < -2.0999999999999999e-14Initial program 77.0%
Taylor expanded in a around 0
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
+-commutativeN/A
unpow2N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6480.4
Applied rewrites80.4%
if -2.0999999999999999e-14 < c < 9.99999999999999943e-68Initial program 74.2%
Taylor expanded in c around 0
unpow2N/A
lower-*.f6467.7
Applied rewrites67.7%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f6467.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6467.7
Applied rewrites67.7%
Final simplification76.8%
(FPCore (a b c d) :precision binary64 (if (<= c -5.3e-14) (/ 1.0 (/ c b)) (if (<= c 8e-74) (/ (- a) d) (/ b c))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -5.3e-14) {
tmp = 1.0 / (c / b);
} else if (c <= 8e-74) {
tmp = -a / d;
} else {
tmp = b / c;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (c <= (-5.3d-14)) then
tmp = 1.0d0 / (c / b)
else if (c <= 8d-74) then
tmp = -a / d
else
tmp = b / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -5.3e-14) {
tmp = 1.0 / (c / b);
} else if (c <= 8e-74) {
tmp = -a / d;
} else {
tmp = b / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -5.3e-14: tmp = 1.0 / (c / b) elif c <= 8e-74: tmp = -a / d else: tmp = b / c return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -5.3e-14) tmp = Float64(1.0 / Float64(c / b)); elseif (c <= 8e-74) tmp = Float64(Float64(-a) / d); else tmp = Float64(b / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -5.3e-14) tmp = 1.0 / (c / b); elseif (c <= 8e-74) tmp = -a / d; else tmp = b / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -5.3e-14], N[(1.0 / N[(c / b), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 8e-74], N[((-a) / d), $MachinePrecision], N[(b / c), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -5.3 \cdot 10^{-14}:\\
\;\;\;\;\frac{1}{\frac{c}{b}}\\
\mathbf{elif}\;c \leq 8 \cdot 10^{-74}:\\
\;\;\;\;\frac{-a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if c < -5.3000000000000001e-14Initial program 55.2%
Taylor expanded in c around inf
lower-/.f6471.4
Applied rewrites71.4%
Applied rewrites71.6%
if -5.3000000000000001e-14 < c < 7.99999999999999966e-74Initial program 73.9%
Taylor expanded in c around 0
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6465.3
Applied rewrites65.3%
if 7.99999999999999966e-74 < c Initial program 56.2%
Taylor expanded in c around inf
lower-/.f6470.5
Applied rewrites70.5%
Final simplification68.8%
(FPCore (a b c d) :precision binary64 (if (<= c -5.3e-14) (/ b c) (if (<= c 8e-74) (/ (- a) d) (/ b c))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -5.3e-14) {
tmp = b / c;
} else if (c <= 8e-74) {
tmp = -a / d;
} else {
tmp = b / c;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (c <= (-5.3d-14)) then
tmp = b / c
else if (c <= 8d-74) then
tmp = -a / d
else
tmp = b / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -5.3e-14) {
tmp = b / c;
} else if (c <= 8e-74) {
tmp = -a / d;
} else {
tmp = b / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -5.3e-14: tmp = b / c elif c <= 8e-74: tmp = -a / d else: tmp = b / c return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -5.3e-14) tmp = Float64(b / c); elseif (c <= 8e-74) tmp = Float64(Float64(-a) / d); else tmp = Float64(b / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -5.3e-14) tmp = b / c; elseif (c <= 8e-74) tmp = -a / d; else tmp = b / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -5.3e-14], N[(b / c), $MachinePrecision], If[LessEqual[c, 8e-74], N[((-a) / d), $MachinePrecision], N[(b / c), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -5.3 \cdot 10^{-14}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{elif}\;c \leq 8 \cdot 10^{-74}:\\
\;\;\;\;\frac{-a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if c < -5.3000000000000001e-14 or 7.99999999999999966e-74 < c Initial program 55.7%
Taylor expanded in c around inf
lower-/.f6471.0
Applied rewrites71.0%
if -5.3000000000000001e-14 < c < 7.99999999999999966e-74Initial program 73.9%
Taylor expanded in c around 0
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6465.3
Applied rewrites65.3%
Final simplification68.7%
(FPCore (a b c d) :precision binary64 (/ b c))
double code(double a, double b, double c, double d) {
return b / c;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = b / c
end function
public static double code(double a, double b, double c, double d) {
return b / c;
}
def code(a, b, c, d): return b / c
function code(a, b, c, d) return Float64(b / c) end
function tmp = code(a, b, c, d) tmp = b / c; end
code[a_, b_, c_, d_] := N[(b / c), $MachinePrecision]
\begin{array}{l}
\\
\frac{b}{c}
\end{array}
Initial program 62.9%
Taylor expanded in c around inf
lower-/.f6450.3
Applied rewrites50.3%
(FPCore (a b c d) :precision binary64 (if (< (fabs d) (fabs c)) (/ (- b (* a (/ d c))) (+ c (* d (/ d c)))) (/ (+ (- a) (* b (/ c d))) (+ d (* c (/ c d))))))
double code(double a, double b, double c, double d) {
double tmp;
if (fabs(d) < fabs(c)) {
tmp = (b - (a * (d / c))) / (c + (d * (d / c)));
} else {
tmp = (-a + (b * (c / d))) / (d + (c * (c / d)));
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (abs(d) < abs(c)) then
tmp = (b - (a * (d / c))) / (c + (d * (d / c)))
else
tmp = (-a + (b * (c / d))) / (d + (c * (c / d)))
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (Math.abs(d) < Math.abs(c)) {
tmp = (b - (a * (d / c))) / (c + (d * (d / c)));
} else {
tmp = (-a + (b * (c / d))) / (d + (c * (c / d)));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if math.fabs(d) < math.fabs(c): tmp = (b - (a * (d / c))) / (c + (d * (d / c))) else: tmp = (-a + (b * (c / d))) / (d + (c * (c / d))) return tmp
function code(a, b, c, d) tmp = 0.0 if (abs(d) < abs(c)) tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / Float64(c + Float64(d * Float64(d / c)))); else tmp = Float64(Float64(Float64(-a) + Float64(b * Float64(c / d))) / Float64(d + Float64(c * Float64(c / d)))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (abs(d) < abs(c)) tmp = (b - (a * (d / c))) / (c + (d * (d / c))); else tmp = (-a + (b * (c / d))) / (d + (c * (c / d))); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Less[N[Abs[d], $MachinePrecision], N[Abs[c], $MachinePrecision]], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(c + N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[((-a) + N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(d + N[(c * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left|d\right| < \left|c\right|:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c + d \cdot \frac{d}{c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-a\right) + b \cdot \frac{c}{d}}{d + c \cdot \frac{c}{d}}\\
\end{array}
\end{array}
herbie shell --seed 2024295
(FPCore (a b c d)
:name "Complex division, imag part"
:precision binary64
:alt
(! :herbie-platform default (if (< (fabs d) (fabs c)) (/ (- b (* a (/ d c))) (+ c (* d (/ d c)))) (/ (+ (- a) (* b (/ c d))) (+ d (* c (/ c d))))))
(/ (- (* b c) (* a d)) (+ (* c c) (* d d))))