
(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 15 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 (/ (fma d b (* c a)) (fma d d (* c c)))))
(if (<= d -5.2e+131)
(/
(fma (/ (- b) d) (* c (/ c d)) (fma a (- (/ c d) (pow (/ c d) 3.0)) b))
d)
(if (<= d -9e-161)
t_0
(if (<= d 1.9e-135)
(/ (+ (/ (fma (- a) (/ (* d d) c) (* b d)) c) a) c)
(if (<= d 1e+90) t_0 (/ (fma (/ c d) a b) d)))))))
double code(double a, double b, double c, double d) {
double t_0 = fma(d, b, (c * a)) / fma(d, d, (c * c));
double tmp;
if (d <= -5.2e+131) {
tmp = fma((-b / d), (c * (c / d)), fma(a, ((c / d) - pow((c / d), 3.0)), b)) / d;
} else if (d <= -9e-161) {
tmp = t_0;
} else if (d <= 1.9e-135) {
tmp = ((fma(-a, ((d * d) / c), (b * d)) / c) + a) / c;
} else if (d <= 1e+90) {
tmp = t_0;
} else {
tmp = fma((c / d), a, b) / d;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(fma(d, b, Float64(c * a)) / fma(d, d, Float64(c * c))) tmp = 0.0 if (d <= -5.2e+131) tmp = Float64(fma(Float64(Float64(-b) / d), Float64(c * Float64(c / d)), fma(a, Float64(Float64(c / d) - (Float64(c / d) ^ 3.0)), b)) / d); elseif (d <= -9e-161) tmp = t_0; elseif (d <= 1.9e-135) tmp = Float64(Float64(Float64(fma(Float64(-a), Float64(Float64(d * d) / c), Float64(b * d)) / c) + a) / c); elseif (d <= 1e+90) tmp = t_0; else tmp = Float64(fma(Float64(c / d), a, b) / d); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(d * b + N[(c * a), $MachinePrecision]), $MachinePrecision] / N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -5.2e+131], N[(N[(N[((-b) / d), $MachinePrecision] * N[(c * N[(c / d), $MachinePrecision]), $MachinePrecision] + N[(a * N[(N[(c / d), $MachinePrecision] - N[Power[N[(c / d), $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision] + b), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, -9e-161], t$95$0, If[LessEqual[d, 1.9e-135], N[(N[(N[(N[((-a) * N[(N[(d * d), $MachinePrecision] / c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision] + a), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 1e+90], t$95$0, N[(N[(N[(c / d), $MachinePrecision] * a + b), $MachinePrecision] / d), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\
\mathbf{if}\;d \leq -5.2 \cdot 10^{+131}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{-b}{d}, c \cdot \frac{c}{d}, \mathsf{fma}\left(a, \frac{c}{d} - {\left(\frac{c}{d}\right)}^{3}, b\right)\right)}{d}\\
\mathbf{elif}\;d \leq -9 \cdot 10^{-161}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 1.9 \cdot 10^{-135}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(-a, \frac{d \cdot d}{c}, b \cdot d\right)}{c} + a}{c}\\
\mathbf{elif}\;d \leq 10^{+90}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{c}{d}, a, b\right)}{d}\\
\end{array}
\end{array}
if d < -5.2e131Initial program 21.5%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6421.5
lift-*.f64N/A
*-commutativeN/A
lower-*.f6421.5
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6421.5
Applied rewrites21.5%
Taylor expanded in c around inf
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f649.0
Applied rewrites9.0%
Taylor expanded in d around inf
lower-/.f64N/A
+-commutativeN/A
associate-*l/N/A
lower-fma.f64N/A
lower-/.f6496.7
Applied rewrites96.7%
Taylor expanded in d around inf
lower-/.f64N/A
Applied rewrites97.3%
if -5.2e131 < d < -8.9999999999999993e-161 or 1.9000000000000001e-135 < d < 9.99999999999999966e89Initial program 76.0%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6476.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f6476.0
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6476.0
Applied rewrites76.0%
if -8.9999999999999993e-161 < d < 1.9000000000000001e-135Initial program 79.5%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6479.5
lift-*.f64N/A
*-commutativeN/A
lower-*.f6479.5
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6479.5
Applied rewrites79.5%
Taylor expanded in c around inf
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
unpow2N/A
associate-/r*N/A
div-subN/A
unsub-negN/A
mul-1-negN/A
+-commutativeN/A
lower-/.f64N/A
Applied rewrites97.3%
if 9.99999999999999966e89 < d Initial program 41.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6441.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6441.8
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6441.8
Applied rewrites41.8%
Taylor expanded in d around inf
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6484.5
Applied rewrites84.5%
(FPCore (a b c d)
:precision binary64
(if (<= d -1.6e+132)
(/ b d)
(if (<= d -4.2e-87)
(/ (fma d b (* c a)) (* d d))
(if (<= d 3.8e-232)
(/ (fma a c (* b d)) (* c c))
(if (<= d 2.55e+42) (/ a c) (pow (/ d b) -1.0))))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -1.6e+132) {
tmp = b / d;
} else if (d <= -4.2e-87) {
tmp = fma(d, b, (c * a)) / (d * d);
} else if (d <= 3.8e-232) {
tmp = fma(a, c, (b * d)) / (c * c);
} else if (d <= 2.55e+42) {
tmp = a / c;
} else {
tmp = pow((d / b), -1.0);
}
return tmp;
}
function code(a, b, c, d) tmp = 0.0 if (d <= -1.6e+132) tmp = Float64(b / d); elseif (d <= -4.2e-87) tmp = Float64(fma(d, b, Float64(c * a)) / Float64(d * d)); elseif (d <= 3.8e-232) tmp = Float64(fma(a, c, Float64(b * d)) / Float64(c * c)); elseif (d <= 2.55e+42) tmp = Float64(a / c); else tmp = Float64(d / b) ^ -1.0; end return tmp end
code[a_, b_, c_, d_] := If[LessEqual[d, -1.6e+132], N[(b / d), $MachinePrecision], If[LessEqual[d, -4.2e-87], N[(N[(d * b + N[(c * a), $MachinePrecision]), $MachinePrecision] / N[(d * d), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 3.8e-232], N[(N[(a * c + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(c * c), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.55e+42], N[(a / c), $MachinePrecision], N[Power[N[(d / b), $MachinePrecision], -1.0], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.6 \cdot 10^{+132}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{elif}\;d \leq -4.2 \cdot 10^{-87}:\\
\;\;\;\;\frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{d \cdot d}\\
\mathbf{elif}\;d \leq 3.8 \cdot 10^{-232}:\\
\;\;\;\;\frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{c \cdot c}\\
\mathbf{elif}\;d \leq 2.55 \cdot 10^{+42}:\\
\;\;\;\;\frac{a}{c}\\
\mathbf{else}:\\
\;\;\;\;{\left(\frac{d}{b}\right)}^{-1}\\
\end{array}
\end{array}
if d < -1.5999999999999999e132Initial program 21.5%
Taylor expanded in c around 0
lower-/.f6480.5
Applied rewrites80.5%
if -1.5999999999999999e132 < d < -4.20000000000000014e-87Initial program 72.3%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6472.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f6472.3
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6472.3
Applied rewrites72.3%
Taylor expanded in c around 0
unpow2N/A
lower-*.f6458.0
Applied rewrites58.0%
if -4.20000000000000014e-87 < d < 3.8000000000000001e-232Initial program 88.2%
Taylor expanded in c around inf
unpow2N/A
lower-*.f6484.0
Applied rewrites84.0%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6484.0
Applied rewrites84.0%
if 3.8000000000000001e-232 < d < 2.55e42Initial program 67.8%
Taylor expanded in c around inf
lower-/.f6463.2
Applied rewrites63.2%
if 2.55e42 < d Initial program 50.0%
lift-/.f64N/A
clear-numN/A
lower-/.f64N/A
lower-/.f6450.0
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6450.0
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6450.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f6450.0
Applied rewrites50.0%
Taylor expanded in c around 0
lower-/.f6463.6
Applied rewrites63.6%
Final simplification70.7%
(FPCore (a b c d)
:precision binary64
(if (<= d -1.75e-34)
(/ b d)
(if (<= d 3.8e-232)
(/ (fma a c (* b d)) (* c c))
(if (<= d 2.55e+42) (/ a c) (pow (/ d b) -1.0)))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -1.75e-34) {
tmp = b / d;
} else if (d <= 3.8e-232) {
tmp = fma(a, c, (b * d)) / (c * c);
} else if (d <= 2.55e+42) {
tmp = a / c;
} else {
tmp = pow((d / b), -1.0);
}
return tmp;
}
function code(a, b, c, d) tmp = 0.0 if (d <= -1.75e-34) tmp = Float64(b / d); elseif (d <= 3.8e-232) tmp = Float64(fma(a, c, Float64(b * d)) / Float64(c * c)); elseif (d <= 2.55e+42) tmp = Float64(a / c); else tmp = Float64(d / b) ^ -1.0; end return tmp end
code[a_, b_, c_, d_] := If[LessEqual[d, -1.75e-34], N[(b / d), $MachinePrecision], If[LessEqual[d, 3.8e-232], N[(N[(a * c + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(c * c), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.55e+42], N[(a / c), $MachinePrecision], N[Power[N[(d / b), $MachinePrecision], -1.0], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.75 \cdot 10^{-34}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{elif}\;d \leq 3.8 \cdot 10^{-232}:\\
\;\;\;\;\frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{c \cdot c}\\
\mathbf{elif}\;d \leq 2.55 \cdot 10^{+42}:\\
\;\;\;\;\frac{a}{c}\\
\mathbf{else}:\\
\;\;\;\;{\left(\frac{d}{b}\right)}^{-1}\\
\end{array}
\end{array}
if d < -1.75e-34Initial program 42.9%
Taylor expanded in c around 0
lower-/.f6465.0
Applied rewrites65.0%
if -1.75e-34 < d < 3.8000000000000001e-232Initial program 89.1%
Taylor expanded in c around inf
unpow2N/A
lower-*.f6480.2
Applied rewrites80.2%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6480.2
Applied rewrites80.2%
if 3.8000000000000001e-232 < d < 2.55e42Initial program 67.8%
Taylor expanded in c around inf
lower-/.f6463.2
Applied rewrites63.2%
if 2.55e42 < d Initial program 50.0%
lift-/.f64N/A
clear-numN/A
lower-/.f64N/A
lower-/.f6450.0
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6450.0
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6450.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f6450.0
Applied rewrites50.0%
Taylor expanded in c around 0
lower-/.f6463.6
Applied rewrites63.6%
Final simplification68.8%
(FPCore (a b c d)
:precision binary64
(if (<= d -2.2e+80)
(/ b d)
(if (<= d -6.3e-105)
(* (/ d (fma c c (* d d))) b)
(if (<= d 2.55e+42) (/ a c) (pow (/ d b) -1.0)))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -2.2e+80) {
tmp = b / d;
} else if (d <= -6.3e-105) {
tmp = (d / fma(c, c, (d * d))) * b;
} else if (d <= 2.55e+42) {
tmp = a / c;
} else {
tmp = pow((d / b), -1.0);
}
return tmp;
}
function code(a, b, c, d) tmp = 0.0 if (d <= -2.2e+80) tmp = Float64(b / d); elseif (d <= -6.3e-105) tmp = Float64(Float64(d / fma(c, c, Float64(d * d))) * b); elseif (d <= 2.55e+42) tmp = Float64(a / c); else tmp = Float64(d / b) ^ -1.0; end return tmp end
code[a_, b_, c_, d_] := If[LessEqual[d, -2.2e+80], N[(b / d), $MachinePrecision], If[LessEqual[d, -6.3e-105], N[(N[(d / N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision], If[LessEqual[d, 2.55e+42], N[(a / c), $MachinePrecision], N[Power[N[(d / b), $MachinePrecision], -1.0], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -2.2 \cdot 10^{+80}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{elif}\;d \leq -6.3 \cdot 10^{-105}:\\
\;\;\;\;\frac{d}{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot b\\
\mathbf{elif}\;d \leq 2.55 \cdot 10^{+42}:\\
\;\;\;\;\frac{a}{c}\\
\mathbf{else}:\\
\;\;\;\;{\left(\frac{d}{b}\right)}^{-1}\\
\end{array}
\end{array}
if d < -2.20000000000000003e80Initial program 27.3%
Taylor expanded in c around 0
lower-/.f6477.1
Applied rewrites77.1%
if -2.20000000000000003e80 < d < -6.3e-105Initial program 78.0%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6478.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f6478.0
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6478.0
Applied rewrites78.0%
Taylor expanded in a around 0
*-commutativeN/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6454.1
Applied rewrites54.1%
if -6.3e-105 < d < 2.55e42Initial program 78.0%
Taylor expanded in c around inf
lower-/.f6470.6
Applied rewrites70.6%
if 2.55e42 < d Initial program 50.0%
lift-/.f64N/A
clear-numN/A
lower-/.f64N/A
lower-/.f6450.0
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6450.0
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6450.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f6450.0
Applied rewrites50.0%
Taylor expanded in c around 0
lower-/.f6463.6
Applied rewrites63.6%
Final simplification68.1%
(FPCore (a b c d)
:precision binary64
(if (<= d -2.15e+93)
(/ b d)
(if (<= d -6.3e-105)
(* (/ b (fma d d (* c c))) d)
(if (<= d 2.55e+42) (/ a c) (pow (/ d b) -1.0)))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -2.15e+93) {
tmp = b / d;
} else if (d <= -6.3e-105) {
tmp = (b / fma(d, d, (c * c))) * d;
} else if (d <= 2.55e+42) {
tmp = a / c;
} else {
tmp = pow((d / b), -1.0);
}
return tmp;
}
function code(a, b, c, d) tmp = 0.0 if (d <= -2.15e+93) tmp = Float64(b / d); elseif (d <= -6.3e-105) tmp = Float64(Float64(b / fma(d, d, Float64(c * c))) * d); elseif (d <= 2.55e+42) tmp = Float64(a / c); else tmp = Float64(d / b) ^ -1.0; end return tmp end
code[a_, b_, c_, d_] := If[LessEqual[d, -2.15e+93], N[(b / d), $MachinePrecision], If[LessEqual[d, -6.3e-105], N[(N[(b / N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * d), $MachinePrecision], If[LessEqual[d, 2.55e+42], N[(a / c), $MachinePrecision], N[Power[N[(d / b), $MachinePrecision], -1.0], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -2.15 \cdot 10^{+93}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{elif}\;d \leq -6.3 \cdot 10^{-105}:\\
\;\;\;\;\frac{b}{\mathsf{fma}\left(d, d, c \cdot c\right)} \cdot d\\
\mathbf{elif}\;d \leq 2.55 \cdot 10^{+42}:\\
\;\;\;\;\frac{a}{c}\\
\mathbf{else}:\\
\;\;\;\;{\left(\frac{d}{b}\right)}^{-1}\\
\end{array}
\end{array}
if d < -2.15e93Initial program 25.7%
Taylor expanded in c around 0
lower-/.f6476.6
Applied rewrites76.6%
if -2.15e93 < d < -6.3e-105Initial program 78.6%
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-*.f6452.9
Applied rewrites52.9%
if -6.3e-105 < d < 2.55e42Initial program 78.0%
Taylor expanded in c around inf
lower-/.f6470.6
Applied rewrites70.6%
if 2.55e42 < d Initial program 50.0%
lift-/.f64N/A
clear-numN/A
lower-/.f64N/A
lower-/.f6450.0
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6450.0
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6450.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f6450.0
Applied rewrites50.0%
Taylor expanded in c around 0
lower-/.f6463.6
Applied rewrites63.6%
Final simplification67.8%
(FPCore (a b c d) :precision binary64 (if (<= d -9e+27) (/ b d) (if (<= d 2.55e+42) (/ a c) (pow (/ d b) -1.0))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -9e+27) {
tmp = b / d;
} else if (d <= 2.55e+42) {
tmp = a / c;
} else {
tmp = pow((d / b), -1.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) :: tmp
if (d <= (-9d+27)) then
tmp = b / d
else if (d <= 2.55d+42) then
tmp = a / c
else
tmp = (d / b) ** (-1.0d0)
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (d <= -9e+27) {
tmp = b / d;
} else if (d <= 2.55e+42) {
tmp = a / c;
} else {
tmp = Math.pow((d / b), -1.0);
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -9e+27: tmp = b / d elif d <= 2.55e+42: tmp = a / c else: tmp = math.pow((d / b), -1.0) return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -9e+27) tmp = Float64(b / d); elseif (d <= 2.55e+42) tmp = Float64(a / c); else tmp = Float64(d / b) ^ -1.0; end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= -9e+27) tmp = b / d; elseif (d <= 2.55e+42) tmp = a / c; else tmp = (d / b) ^ -1.0; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -9e+27], N[(b / d), $MachinePrecision], If[LessEqual[d, 2.55e+42], N[(a / c), $MachinePrecision], N[Power[N[(d / b), $MachinePrecision], -1.0], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -9 \cdot 10^{+27}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{elif}\;d \leq 2.55 \cdot 10^{+42}:\\
\;\;\;\;\frac{a}{c}\\
\mathbf{else}:\\
\;\;\;\;{\left(\frac{d}{b}\right)}^{-1}\\
\end{array}
\end{array}
if d < -8.9999999999999998e27Initial program 34.5%
Taylor expanded in c around 0
lower-/.f6473.6
Applied rewrites73.6%
if -8.9999999999999998e27 < d < 2.55e42Initial program 77.3%
Taylor expanded in c around inf
lower-/.f6464.4
Applied rewrites64.4%
if 2.55e42 < d Initial program 50.0%
lift-/.f64N/A
clear-numN/A
lower-/.f64N/A
lower-/.f6450.0
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6450.0
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6450.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f6450.0
Applied rewrites50.0%
Taylor expanded in c around 0
lower-/.f6463.6
Applied rewrites63.6%
Final simplification66.0%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (fma d b (* c a)) (fma d d (* c c))))
(t_1 (/ (fma (/ c d) a b) d)))
(if (<= d -1.45e+94)
t_1
(if (<= d -9e-161)
t_0
(if (<= d 1.9e-135)
(/ (+ (/ (fma (- a) (/ (* d d) c) (* b d)) c) a) c)
(if (<= d 1e+90) t_0 t_1))))))
double code(double a, double b, double c, double d) {
double t_0 = fma(d, b, (c * a)) / fma(d, d, (c * c));
double t_1 = fma((c / d), a, b) / d;
double tmp;
if (d <= -1.45e+94) {
tmp = t_1;
} else if (d <= -9e-161) {
tmp = t_0;
} else if (d <= 1.9e-135) {
tmp = ((fma(-a, ((d * d) / c), (b * d)) / c) + a) / c;
} else if (d <= 1e+90) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(fma(d, b, Float64(c * a)) / fma(d, d, Float64(c * c))) t_1 = Float64(fma(Float64(c / d), a, b) / d) tmp = 0.0 if (d <= -1.45e+94) tmp = t_1; elseif (d <= -9e-161) tmp = t_0; elseif (d <= 1.9e-135) tmp = Float64(Float64(Float64(fma(Float64(-a), Float64(Float64(d * d) / c), Float64(b * d)) / c) + a) / c); elseif (d <= 1e+90) tmp = t_0; else tmp = t_1; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(d * b + N[(c * a), $MachinePrecision]), $MachinePrecision] / N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(c / d), $MachinePrecision] * a + b), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -1.45e+94], t$95$1, If[LessEqual[d, -9e-161], t$95$0, If[LessEqual[d, 1.9e-135], N[(N[(N[(N[((-a) * N[(N[(d * d), $MachinePrecision] / c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision] + a), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 1e+90], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\
t_1 := \frac{\mathsf{fma}\left(\frac{c}{d}, a, b\right)}{d}\\
\mathbf{if}\;d \leq -1.45 \cdot 10^{+94}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d \leq -9 \cdot 10^{-161}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 1.9 \cdot 10^{-135}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(-a, \frac{d \cdot d}{c}, b \cdot d\right)}{c} + a}{c}\\
\mathbf{elif}\;d \leq 10^{+90}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if d < -1.4499999999999999e94 or 9.99999999999999966e89 < d Initial program 32.2%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6432.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6432.2
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6432.2
Applied rewrites32.2%
Taylor expanded in d around inf
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6487.8
Applied rewrites87.8%
if -1.4499999999999999e94 < d < -8.9999999999999993e-161 or 1.9000000000000001e-135 < d < 9.99999999999999966e89Initial program 77.6%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6477.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f6477.6
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6477.6
Applied rewrites77.6%
if -8.9999999999999993e-161 < d < 1.9000000000000001e-135Initial program 79.5%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6479.5
lift-*.f64N/A
*-commutativeN/A
lower-*.f6479.5
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6479.5
Applied rewrites79.5%
Taylor expanded in c around inf
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
unpow2N/A
associate-/r*N/A
div-subN/A
unsub-negN/A
mul-1-negN/A
+-commutativeN/A
lower-/.f64N/A
Applied rewrites97.3%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (fma d b (* c a)) (fma d d (* c c))))
(t_1 (/ (fma (/ c d) a b) d)))
(if (<= d -1.45e+94)
t_1
(if (<= d -9e-161)
t_0
(if (<= d 1.9e-135)
(/ (- a (/ (fma (- b) d (/ (* (* d d) a) c)) c)) c)
(if (<= d 1e+90) t_0 t_1))))))
double code(double a, double b, double c, double d) {
double t_0 = fma(d, b, (c * a)) / fma(d, d, (c * c));
double t_1 = fma((c / d), a, b) / d;
double tmp;
if (d <= -1.45e+94) {
tmp = t_1;
} else if (d <= -9e-161) {
tmp = t_0;
} else if (d <= 1.9e-135) {
tmp = (a - (fma(-b, d, (((d * d) * a) / c)) / c)) / c;
} else if (d <= 1e+90) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(fma(d, b, Float64(c * a)) / fma(d, d, Float64(c * c))) t_1 = Float64(fma(Float64(c / d), a, b) / d) tmp = 0.0 if (d <= -1.45e+94) tmp = t_1; elseif (d <= -9e-161) tmp = t_0; elseif (d <= 1.9e-135) tmp = Float64(Float64(a - Float64(fma(Float64(-b), d, Float64(Float64(Float64(d * d) * a) / c)) / c)) / c); elseif (d <= 1e+90) tmp = t_0; else tmp = t_1; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(d * b + N[(c * a), $MachinePrecision]), $MachinePrecision] / N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(c / d), $MachinePrecision] * a + b), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -1.45e+94], t$95$1, If[LessEqual[d, -9e-161], t$95$0, If[LessEqual[d, 1.9e-135], N[(N[(a - N[(N[((-b) * d + N[(N[(N[(d * d), $MachinePrecision] * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 1e+90], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\
t_1 := \frac{\mathsf{fma}\left(\frac{c}{d}, a, b\right)}{d}\\
\mathbf{if}\;d \leq -1.45 \cdot 10^{+94}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d \leq -9 \cdot 10^{-161}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 1.9 \cdot 10^{-135}:\\
\;\;\;\;\frac{a - \frac{\mathsf{fma}\left(-b, d, \frac{\left(d \cdot d\right) \cdot a}{c}\right)}{c}}{c}\\
\mathbf{elif}\;d \leq 10^{+90}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if d < -1.4499999999999999e94 or 9.99999999999999966e89 < d Initial program 32.2%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6432.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6432.2
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6432.2
Applied rewrites32.2%
Taylor expanded in d around inf
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6487.8
Applied rewrites87.8%
if -1.4499999999999999e94 < d < -8.9999999999999993e-161 or 1.9000000000000001e-135 < d < 9.99999999999999966e89Initial program 77.6%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6477.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f6477.6
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6477.6
Applied rewrites77.6%
if -8.9999999999999993e-161 < d < 1.9000000000000001e-135Initial program 79.5%
Taylor expanded in c around inf
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
unpow2N/A
associate-/r*N/A
div-subN/A
unsub-negN/A
mul-1-negN/A
+-commutativeN/A
lower-/.f64N/A
Applied rewrites97.3%
Final simplification86.2%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (fma d b (* c a)) (fma d d (* c c))))
(t_1 (/ (fma (/ c d) a b) d)))
(if (<= d -1.45e+94)
t_1
(if (<= d -9e-161)
t_0
(if (<= d 2.5e-92)
(/ (fma (/ d c) b a) c)
(if (<= d 1e+90) t_0 t_1))))))
double code(double a, double b, double c, double d) {
double t_0 = fma(d, b, (c * a)) / fma(d, d, (c * c));
double t_1 = fma((c / d), a, b) / d;
double tmp;
if (d <= -1.45e+94) {
tmp = t_1;
} else if (d <= -9e-161) {
tmp = t_0;
} else if (d <= 2.5e-92) {
tmp = fma((d / c), b, a) / c;
} else if (d <= 1e+90) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(fma(d, b, Float64(c * a)) / fma(d, d, Float64(c * c))) t_1 = Float64(fma(Float64(c / d), a, b) / d) tmp = 0.0 if (d <= -1.45e+94) tmp = t_1; elseif (d <= -9e-161) tmp = t_0; elseif (d <= 2.5e-92) tmp = Float64(fma(Float64(d / c), b, a) / c); elseif (d <= 1e+90) tmp = t_0; else tmp = t_1; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(d * b + N[(c * a), $MachinePrecision]), $MachinePrecision] / N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(c / d), $MachinePrecision] * a + b), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -1.45e+94], t$95$1, If[LessEqual[d, -9e-161], t$95$0, If[LessEqual[d, 2.5e-92], N[(N[(N[(d / c), $MachinePrecision] * b + a), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 1e+90], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\
t_1 := \frac{\mathsf{fma}\left(\frac{c}{d}, a, b\right)}{d}\\
\mathbf{if}\;d \leq -1.45 \cdot 10^{+94}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d \leq -9 \cdot 10^{-161}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 2.5 \cdot 10^{-92}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{d}{c}, b, a\right)}{c}\\
\mathbf{elif}\;d \leq 10^{+90}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if d < -1.4499999999999999e94 or 9.99999999999999966e89 < d Initial program 32.2%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6432.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6432.2
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6432.2
Applied rewrites32.2%
Taylor expanded in d around inf
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6487.8
Applied rewrites87.8%
if -1.4499999999999999e94 < d < -8.9999999999999993e-161 or 2.50000000000000006e-92 < d < 9.99999999999999966e89Initial program 78.1%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6478.1
lift-*.f64N/A
*-commutativeN/A
lower-*.f6478.1
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6478.1
Applied rewrites78.1%
if -8.9999999999999993e-161 < d < 2.50000000000000006e-92Initial program 78.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6478.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6478.7
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6478.7
Applied rewrites78.7%
Taylor expanded in c around inf
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6493.5
Applied rewrites93.5%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (fma (/ a d) c b) d)))
(if (<= d -2.05e-86)
t_0
(if (<= d 3.8e-232)
(/ (fma a c (* b d)) (* c c))
(if (<= d 1.25e+21) (/ a c) t_0)))))
double code(double a, double b, double c, double d) {
double t_0 = fma((a / d), c, b) / d;
double tmp;
if (d <= -2.05e-86) {
tmp = t_0;
} else if (d <= 3.8e-232) {
tmp = fma(a, c, (b * d)) / (c * c);
} else if (d <= 1.25e+21) {
tmp = a / c;
} else {
tmp = t_0;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(fma(Float64(a / d), c, b) / d) tmp = 0.0 if (d <= -2.05e-86) tmp = t_0; elseif (d <= 3.8e-232) tmp = Float64(fma(a, c, Float64(b * d)) / Float64(c * c)); elseif (d <= 1.25e+21) tmp = Float64(a / c); else tmp = t_0; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(a / d), $MachinePrecision] * c + b), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -2.05e-86], t$95$0, If[LessEqual[d, 3.8e-232], N[(N[(a * c + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(c * c), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.25e+21], N[(a / c), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\mathsf{fma}\left(\frac{a}{d}, c, b\right)}{d}\\
\mathbf{if}\;d \leq -2.05 \cdot 10^{-86}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 3.8 \cdot 10^{-232}:\\
\;\;\;\;\frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{c \cdot c}\\
\mathbf{elif}\;d \leq 1.25 \cdot 10^{+21}:\\
\;\;\;\;\frac{a}{c}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d < -2.0499999999999999e-86 or 1.25e21 < d Initial program 48.4%
Taylor expanded in d around inf
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6476.2
Applied rewrites76.2%
if -2.0499999999999999e-86 < d < 3.8000000000000001e-232Initial program 88.2%
Taylor expanded in c around inf
unpow2N/A
lower-*.f6484.0
Applied rewrites84.0%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6484.0
Applied rewrites84.0%
if 3.8000000000000001e-232 < d < 1.25e21Initial program 69.6%
Taylor expanded in c around inf
lower-/.f6466.1
Applied rewrites66.1%
Final simplification76.1%
(FPCore (a b c d) :precision binary64 (if (or (<= c -3.45e+50) (not (<= c 3.85e-13))) (/ (fma (/ b c) d a) c) (/ (fma (/ c d) a b) d)))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -3.45e+50) || !(c <= 3.85e-13)) {
tmp = fma((b / c), d, a) / c;
} else {
tmp = fma((c / d), a, b) / d;
}
return tmp;
}
function code(a, b, c, d) tmp = 0.0 if ((c <= -3.45e+50) || !(c <= 3.85e-13)) tmp = Float64(fma(Float64(b / c), d, a) / c); else tmp = Float64(fma(Float64(c / d), a, b) / d); end return tmp end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -3.45e+50], N[Not[LessEqual[c, 3.85e-13]], $MachinePrecision]], N[(N[(N[(b / c), $MachinePrecision] * d + a), $MachinePrecision] / c), $MachinePrecision], N[(N[(N[(c / d), $MachinePrecision] * a + b), $MachinePrecision] / d), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -3.45 \cdot 10^{+50} \lor \neg \left(c \leq 3.85 \cdot 10^{-13}\right):\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{b}{c}, d, a\right)}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{c}{d}, a, b\right)}{d}\\
\end{array}
\end{array}
if c < -3.45000000000000016e50 or 3.8499999999999998e-13 < c Initial program 50.3%
Taylor expanded in c around inf
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6479.7
Applied rewrites79.7%
if -3.45000000000000016e50 < c < 3.8499999999999998e-13Initial program 76.2%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6476.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6476.2
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6476.2
Applied rewrites76.2%
Taylor expanded in d around inf
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6478.5
Applied rewrites78.5%
Final simplification79.1%
(FPCore (a b c d) :precision binary64 (if (or (<= d -3.2e-83) (not (<= d 7e+84))) (/ (fma (/ a d) c b) d) (/ (fma (/ b c) d a) c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -3.2e-83) || !(d <= 7e+84)) {
tmp = fma((a / d), c, b) / d;
} else {
tmp = fma((b / c), d, a) / c;
}
return tmp;
}
function code(a, b, c, d) tmp = 0.0 if ((d <= -3.2e-83) || !(d <= 7e+84)) tmp = Float64(fma(Float64(a / d), c, b) / d); else tmp = Float64(fma(Float64(b / c), d, a) / c); end return tmp end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -3.2e-83], N[Not[LessEqual[d, 7e+84]], $MachinePrecision]], N[(N[(N[(a / d), $MachinePrecision] * c + b), $MachinePrecision] / d), $MachinePrecision], N[(N[(N[(b / c), $MachinePrecision] * d + a), $MachinePrecision] / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -3.2 \cdot 10^{-83} \lor \neg \left(d \leq 7 \cdot 10^{+84}\right):\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{a}{d}, c, b\right)}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{b}{c}, d, a\right)}{c}\\
\end{array}
\end{array}
if d < -3.2000000000000001e-83 or 6.9999999999999998e84 < d Initial program 45.5%
Taylor expanded in d around inf
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6480.4
Applied rewrites80.4%
if -3.2000000000000001e-83 < d < 6.9999999999999998e84Initial program 78.7%
Taylor expanded in c around inf
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6476.3
Applied rewrites76.3%
Final simplification78.1%
(FPCore (a b c d) :precision binary64 (if (<= d -3.2e-83) (/ (fma (/ a d) c b) d) (if (<= d 7e+84) (/ (fma (/ d c) b a) c) (/ (fma (/ c d) a b) d))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -3.2e-83) {
tmp = fma((a / d), c, b) / d;
} else if (d <= 7e+84) {
tmp = fma((d / c), b, a) / c;
} else {
tmp = fma((c / d), a, b) / d;
}
return tmp;
}
function code(a, b, c, d) tmp = 0.0 if (d <= -3.2e-83) tmp = Float64(fma(Float64(a / d), c, b) / d); elseif (d <= 7e+84) tmp = Float64(fma(Float64(d / c), b, a) / c); else tmp = Float64(fma(Float64(c / d), a, b) / d); end return tmp end
code[a_, b_, c_, d_] := If[LessEqual[d, -3.2e-83], N[(N[(N[(a / d), $MachinePrecision] * c + b), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, 7e+84], N[(N[(N[(d / c), $MachinePrecision] * b + a), $MachinePrecision] / c), $MachinePrecision], N[(N[(N[(c / d), $MachinePrecision] * a + b), $MachinePrecision] / d), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -3.2 \cdot 10^{-83}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{a}{d}, c, b\right)}{d}\\
\mathbf{elif}\;d \leq 7 \cdot 10^{+84}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{d}{c}, b, a\right)}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{c}{d}, a, b\right)}{d}\\
\end{array}
\end{array}
if d < -3.2000000000000001e-83Initial program 47.3%
Taylor expanded in d around inf
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6478.4
Applied rewrites78.4%
if -3.2000000000000001e-83 < d < 6.9999999999999998e84Initial program 78.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6478.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6478.7
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6478.7
Applied rewrites78.7%
Taylor expanded in c around inf
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6481.2
Applied rewrites81.2%
if 6.9999999999999998e84 < d Initial program 41.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6441.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6441.8
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6441.8
Applied rewrites41.8%
Taylor expanded in d around inf
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6484.5
Applied rewrites84.5%
Final simplification80.9%
(FPCore (a b c d) :precision binary64 (if (or (<= d -9e+27) (not (<= d 5.5e+69))) (/ b d) (/ a c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -9e+27) || !(d <= 5.5e+69)) {
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 ((d <= (-9d+27)) .or. (.not. (d <= 5.5d+69))) 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 ((d <= -9e+27) || !(d <= 5.5e+69)) {
tmp = b / d;
} else {
tmp = a / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -9e+27) or not (d <= 5.5e+69): tmp = b / d else: tmp = a / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -9e+27) || !(d <= 5.5e+69)) 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 ((d <= -9e+27) || ~((d <= 5.5e+69))) tmp = b / d; else tmp = a / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -9e+27], N[Not[LessEqual[d, 5.5e+69]], $MachinePrecision]], N[(b / d), $MachinePrecision], N[(a / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -9 \cdot 10^{+27} \lor \neg \left(d \leq 5.5 \cdot 10^{+69}\right):\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c}\\
\end{array}
\end{array}
if d < -8.9999999999999998e27 or 5.50000000000000002e69 < d Initial program 37.6%
Taylor expanded in c around 0
lower-/.f6471.9
Applied rewrites71.9%
if -8.9999999999999998e27 < d < 5.50000000000000002e69Initial program 77.5%
Taylor expanded in c around inf
lower-/.f6463.0
Applied rewrites63.0%
Final simplification66.0%
(FPCore (a b c d) :precision binary64 (/ a c))
double code(double a, double b, double c, double d) {
return a / c;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = a / c
end function
public static double code(double a, double b, double c, double d) {
return a / c;
}
def code(a, b, c, d): return a / c
function code(a, b, c, d) return Float64(a / c) end
function tmp = code(a, b, c, d) tmp = a / c; end
code[a_, b_, c_, d_] := N[(a / c), $MachinePrecision]
\begin{array}{l}
\\
\frac{a}{c}
\end{array}
Initial program 63.9%
Taylor expanded in c around inf
lower-/.f6446.2
Applied rewrites46.2%
Final simplification46.2%
(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 2024302
(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))))