
(FPCore (x.re x.im y.re y.im) :precision binary64 (/ (+ (* x.re y.re) (* x.im y.im)) (+ (* y.re y.re) (* y.im y.im))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return ((x_46_re * y_46_re) + (x_46_im * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x_46re, x_46im, y_46re, y_46im)
use fmin_fmax_functions
real(8), intent (in) :: x_46re
real(8), intent (in) :: x_46im
real(8), intent (in) :: y_46re
real(8), intent (in) :: y_46im
code = ((x_46re * y_46re) + (x_46im * y_46im)) / ((y_46re * y_46re) + (y_46im * y_46im))
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return ((x_46_re * y_46_re) + (x_46_im * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): return ((x_46_re * y_46_re) + (x_46_im * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im))
function code(x_46_re, x_46_im, y_46_re, y_46_im) return Float64(Float64(Float64(x_46_re * y_46_re) + Float64(x_46_im * y_46_im)) / Float64(Float64(y_46_re * y_46_re) + Float64(y_46_im * y_46_im))) end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = ((x_46_re * y_46_re) + (x_46_im * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im)); end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(N[(N[(x$46$re * y$46$re), $MachinePrecision] + N[(x$46$im * y$46$im), $MachinePrecision]), $MachinePrecision] / N[(N[(y$46$re * y$46$re), $MachinePrecision] + N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x.re x.im y.re y.im) :precision binary64 (/ (+ (* x.re y.re) (* x.im y.im)) (+ (* y.re y.re) (* y.im y.im))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return ((x_46_re * y_46_re) + (x_46_im * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x_46re, x_46im, y_46re, y_46im)
use fmin_fmax_functions
real(8), intent (in) :: x_46re
real(8), intent (in) :: x_46im
real(8), intent (in) :: y_46re
real(8), intent (in) :: y_46im
code = ((x_46re * y_46re) + (x_46im * y_46im)) / ((y_46re * y_46re) + (y_46im * y_46im))
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return ((x_46_re * y_46_re) + (x_46_im * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): return ((x_46_re * y_46_re) + (x_46_im * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im))
function code(x_46_re, x_46_im, y_46_re, y_46_im) return Float64(Float64(Float64(x_46_re * y_46_re) + Float64(x_46_im * y_46_im)) / Float64(Float64(y_46_re * y_46_re) + Float64(y_46_im * y_46_im))) end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = ((x_46_re * y_46_re) + (x_46_im * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im)); end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(N[(N[(x$46$re * y$46$re), $MachinePrecision] + N[(x$46$im * y$46$im), $MachinePrecision]), $MachinePrecision] / N[(N[(y$46$re * y$46$re), $MachinePrecision] + N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}
\end{array}
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (fma y.im y.im (* y.re y.re)))
(t_1 (fma (/ x.im y.re) (/ y.im y.re) (/ x.re y.re))))
(if (<= y.re -1.25e+150)
t_1
(if (<= y.re -2.3e-83)
(* (/ (fma x.im (/ y.im x.re) y.re) t_0) x.re)
(if (<= y.re 7.5e-118)
(/
(fma
(/ (fma y.re x.re (/ (* (* y.re y.re) x.im) (- y.im))) y.im)
-1.0
(- x.im))
(- y.im))
(if (<= y.re 5.1e+75) (/ (fma y.im x.im (* y.re x.re)) t_0) t_1))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = fma(y_46_im, y_46_im, (y_46_re * y_46_re));
double t_1 = fma((x_46_im / y_46_re), (y_46_im / y_46_re), (x_46_re / y_46_re));
double tmp;
if (y_46_re <= -1.25e+150) {
tmp = t_1;
} else if (y_46_re <= -2.3e-83) {
tmp = (fma(x_46_im, (y_46_im / x_46_re), y_46_re) / t_0) * x_46_re;
} else if (y_46_re <= 7.5e-118) {
tmp = fma((fma(y_46_re, x_46_re, (((y_46_re * y_46_re) * x_46_im) / -y_46_im)) / y_46_im), -1.0, -x_46_im) / -y_46_im;
} else if (y_46_re <= 5.1e+75) {
tmp = fma(y_46_im, x_46_im, (y_46_re * x_46_re)) / t_0;
} else {
tmp = t_1;
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = fma(y_46_im, y_46_im, Float64(y_46_re * y_46_re)) t_1 = fma(Float64(x_46_im / y_46_re), Float64(y_46_im / y_46_re), Float64(x_46_re / y_46_re)) tmp = 0.0 if (y_46_re <= -1.25e+150) tmp = t_1; elseif (y_46_re <= -2.3e-83) tmp = Float64(Float64(fma(x_46_im, Float64(y_46_im / x_46_re), y_46_re) / t_0) * x_46_re); elseif (y_46_re <= 7.5e-118) tmp = Float64(fma(Float64(fma(y_46_re, x_46_re, Float64(Float64(Float64(y_46_re * y_46_re) * x_46_im) / Float64(-y_46_im))) / y_46_im), -1.0, Float64(-x_46_im)) / Float64(-y_46_im)); elseif (y_46_re <= 5.1e+75) tmp = Float64(fma(y_46_im, x_46_im, Float64(y_46_re * x_46_re)) / t_0); else tmp = t_1; end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(y$46$im * y$46$im + N[(y$46$re * y$46$re), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x$46$im / y$46$re), $MachinePrecision] * N[(y$46$im / y$46$re), $MachinePrecision] + N[(x$46$re / y$46$re), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y$46$re, -1.25e+150], t$95$1, If[LessEqual[y$46$re, -2.3e-83], N[(N[(N[(x$46$im * N[(y$46$im / x$46$re), $MachinePrecision] + y$46$re), $MachinePrecision] / t$95$0), $MachinePrecision] * x$46$re), $MachinePrecision], If[LessEqual[y$46$re, 7.5e-118], N[(N[(N[(N[(y$46$re * x$46$re + N[(N[(N[(y$46$re * y$46$re), $MachinePrecision] * x$46$im), $MachinePrecision] / (-y$46$im)), $MachinePrecision]), $MachinePrecision] / y$46$im), $MachinePrecision] * -1.0 + (-x$46$im)), $MachinePrecision] / (-y$46$im)), $MachinePrecision], If[LessEqual[y$46$re, 5.1e+75], N[(N[(y$46$im * x$46$im + N[(y$46$re * x$46$re), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)\\
t_1 := \mathsf{fma}\left(\frac{x.im}{y.re}, \frac{y.im}{y.re}, \frac{x.re}{y.re}\right)\\
\mathbf{if}\;y.re \leq -1.25 \cdot 10^{+150}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y.re \leq -2.3 \cdot 10^{-83}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x.im, \frac{y.im}{x.re}, y.re\right)}{t\_0} \cdot x.re\\
\mathbf{elif}\;y.re \leq 7.5 \cdot 10^{-118}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{\mathsf{fma}\left(y.re, x.re, \frac{\left(y.re \cdot y.re\right) \cdot x.im}{-y.im}\right)}{y.im}, -1, -x.im\right)}{-y.im}\\
\mathbf{elif}\;y.re \leq 5.1 \cdot 10^{+75}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y.im, x.im, y.re \cdot x.re\right)}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y.re < -1.25000000000000002e150 or 5.10000000000000037e75 < y.re Initial program 34.6%
Taylor expanded in y.im around 0
+-commutativeN/A
pow2N/A
times-fracN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-/.f6490.5
Applied rewrites90.5%
if -1.25000000000000002e150 < y.re < -2.2999999999999999e-83Initial program 74.8%
Taylor expanded in x.re around inf
*-commutativeN/A
lower-*.f64N/A
associate-/r*N/A
div-add-revN/A
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
pow2N/A
lower-fma.f64N/A
pow2N/A
lift-*.f6480.2
Applied rewrites80.2%
if -2.2999999999999999e-83 < y.re < 7.49999999999999978e-118Initial program 67.2%
Taylor expanded in y.im around -inf
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
Applied rewrites89.4%
if 7.49999999999999978e-118 < y.re < 5.10000000000000037e75Initial program 84.1%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6484.1
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
pow2N/A
+-commutativeN/A
pow2N/A
lower-fma.f64N/A
pow2N/A
lift-*.f6484.1
Applied rewrites84.1%
Final simplification87.2%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (fma y.im y.im (* y.re y.re)))
(t_1 (fma (/ x.im y.re) (/ y.im y.re) (/ x.re y.re))))
(if (<= y.re -1.25e+150)
t_1
(if (<= y.re -2.3e-83)
(* (/ (fma x.im (/ y.im x.re) y.re) t_0) x.re)
(if (<= y.re 6.6e-117)
(/ (fma x.re (/ y.re y.im) x.im) y.im)
(if (<= y.re 5.1e+75) (/ (fma y.im x.im (* y.re x.re)) t_0) t_1))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = fma(y_46_im, y_46_im, (y_46_re * y_46_re));
double t_1 = fma((x_46_im / y_46_re), (y_46_im / y_46_re), (x_46_re / y_46_re));
double tmp;
if (y_46_re <= -1.25e+150) {
tmp = t_1;
} else if (y_46_re <= -2.3e-83) {
tmp = (fma(x_46_im, (y_46_im / x_46_re), y_46_re) / t_0) * x_46_re;
} else if (y_46_re <= 6.6e-117) {
tmp = fma(x_46_re, (y_46_re / y_46_im), x_46_im) / y_46_im;
} else if (y_46_re <= 5.1e+75) {
tmp = fma(y_46_im, x_46_im, (y_46_re * x_46_re)) / t_0;
} else {
tmp = t_1;
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = fma(y_46_im, y_46_im, Float64(y_46_re * y_46_re)) t_1 = fma(Float64(x_46_im / y_46_re), Float64(y_46_im / y_46_re), Float64(x_46_re / y_46_re)) tmp = 0.0 if (y_46_re <= -1.25e+150) tmp = t_1; elseif (y_46_re <= -2.3e-83) tmp = Float64(Float64(fma(x_46_im, Float64(y_46_im / x_46_re), y_46_re) / t_0) * x_46_re); elseif (y_46_re <= 6.6e-117) tmp = Float64(fma(x_46_re, Float64(y_46_re / y_46_im), x_46_im) / y_46_im); elseif (y_46_re <= 5.1e+75) tmp = Float64(fma(y_46_im, x_46_im, Float64(y_46_re * x_46_re)) / t_0); else tmp = t_1; end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(y$46$im * y$46$im + N[(y$46$re * y$46$re), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x$46$im / y$46$re), $MachinePrecision] * N[(y$46$im / y$46$re), $MachinePrecision] + N[(x$46$re / y$46$re), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y$46$re, -1.25e+150], t$95$1, If[LessEqual[y$46$re, -2.3e-83], N[(N[(N[(x$46$im * N[(y$46$im / x$46$re), $MachinePrecision] + y$46$re), $MachinePrecision] / t$95$0), $MachinePrecision] * x$46$re), $MachinePrecision], If[LessEqual[y$46$re, 6.6e-117], N[(N[(x$46$re * N[(y$46$re / y$46$im), $MachinePrecision] + x$46$im), $MachinePrecision] / y$46$im), $MachinePrecision], If[LessEqual[y$46$re, 5.1e+75], N[(N[(y$46$im * x$46$im + N[(y$46$re * x$46$re), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)\\
t_1 := \mathsf{fma}\left(\frac{x.im}{y.re}, \frac{y.im}{y.re}, \frac{x.re}{y.re}\right)\\
\mathbf{if}\;y.re \leq -1.25 \cdot 10^{+150}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y.re \leq -2.3 \cdot 10^{-83}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x.im, \frac{y.im}{x.re}, y.re\right)}{t\_0} \cdot x.re\\
\mathbf{elif}\;y.re \leq 6.6 \cdot 10^{-117}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x.re, \frac{y.re}{y.im}, x.im\right)}{y.im}\\
\mathbf{elif}\;y.re \leq 5.1 \cdot 10^{+75}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y.im, x.im, y.re \cdot x.re\right)}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y.re < -1.25000000000000002e150 or 5.10000000000000037e75 < y.re Initial program 34.6%
Taylor expanded in y.im around 0
+-commutativeN/A
pow2N/A
times-fracN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-/.f6490.5
Applied rewrites90.5%
if -1.25000000000000002e150 < y.re < -2.2999999999999999e-83Initial program 74.8%
Taylor expanded in x.re around inf
*-commutativeN/A
lower-*.f64N/A
associate-/r*N/A
div-add-revN/A
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
pow2N/A
lower-fma.f64N/A
pow2N/A
lift-*.f6480.2
Applied rewrites80.2%
if -2.2999999999999999e-83 < y.re < 6.6000000000000003e-117Initial program 67.2%
Taylor expanded in y.im around inf
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6487.4
Applied rewrites87.4%
if 6.6000000000000003e-117 < y.re < 5.10000000000000037e75Initial program 84.1%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6484.1
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
pow2N/A
+-commutativeN/A
pow2N/A
lower-fma.f64N/A
pow2N/A
lift-*.f6484.1
Applied rewrites84.1%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(if (<= y.im -9e+38)
(/ (+ x.im (* (/ x.re y.im) y.re)) y.im)
(if (<= y.im 9.8e-172)
(/ (fma x.im (/ y.im y.re) x.re) y.re)
(if (<= y.im 4.2e+68)
(/ (+ (* x.re y.re) (* x.im y.im)) (+ (* y.re y.re) (* y.im y.im)))
(/ (fma (/ x.re y.im) y.re x.im) y.im)))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double tmp;
if (y_46_im <= -9e+38) {
tmp = (x_46_im + ((x_46_re / y_46_im) * y_46_re)) / y_46_im;
} else if (y_46_im <= 9.8e-172) {
tmp = fma(x_46_im, (y_46_im / y_46_re), x_46_re) / y_46_re;
} else if (y_46_im <= 4.2e+68) {
tmp = ((x_46_re * y_46_re) + (x_46_im * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
} else {
tmp = fma((x_46_re / y_46_im), y_46_re, x_46_im) / y_46_im;
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0 if (y_46_im <= -9e+38) tmp = Float64(Float64(x_46_im + Float64(Float64(x_46_re / y_46_im) * y_46_re)) / y_46_im); elseif (y_46_im <= 9.8e-172) tmp = Float64(fma(x_46_im, Float64(y_46_im / y_46_re), x_46_re) / y_46_re); elseif (y_46_im <= 4.2e+68) tmp = Float64(Float64(Float64(x_46_re * y_46_re) + Float64(x_46_im * y_46_im)) / Float64(Float64(y_46_re * y_46_re) + Float64(y_46_im * y_46_im))); else tmp = Float64(fma(Float64(x_46_re / y_46_im), y_46_re, x_46_im) / y_46_im); end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[LessEqual[y$46$im, -9e+38], N[(N[(x$46$im + N[(N[(x$46$re / y$46$im), $MachinePrecision] * y$46$re), $MachinePrecision]), $MachinePrecision] / y$46$im), $MachinePrecision], If[LessEqual[y$46$im, 9.8e-172], N[(N[(x$46$im * N[(y$46$im / y$46$re), $MachinePrecision] + x$46$re), $MachinePrecision] / y$46$re), $MachinePrecision], If[LessEqual[y$46$im, 4.2e+68], N[(N[(N[(x$46$re * y$46$re), $MachinePrecision] + N[(x$46$im * y$46$im), $MachinePrecision]), $MachinePrecision] / N[(N[(y$46$re * y$46$re), $MachinePrecision] + N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x$46$re / y$46$im), $MachinePrecision] * y$46$re + x$46$im), $MachinePrecision] / y$46$im), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.im \leq -9 \cdot 10^{+38}:\\
\;\;\;\;\frac{x.im + \frac{x.re}{y.im} \cdot y.re}{y.im}\\
\mathbf{elif}\;y.im \leq 9.8 \cdot 10^{-172}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x.im, \frac{y.im}{y.re}, x.re\right)}{y.re}\\
\mathbf{elif}\;y.im \leq 4.2 \cdot 10^{+68}:\\
\;\;\;\;\frac{x.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{x.re}{y.im}, y.re, x.im\right)}{y.im}\\
\end{array}
\end{array}
if y.im < -8.99999999999999961e38Initial program 48.5%
Taylor expanded in y.re around 0
+-commutativeN/A
pow2N/A
times-fracN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-/.f6482.5
Applied rewrites82.5%
lift-/.f64N/A
lift-/.f64N/A
lift-/.f64N/A
lift-fma.f64N/A
frac-timesN/A
pow2N/A
+-commutativeN/A
pow2N/A
frac-timesN/A
associate-*r/N/A
div-add-revN/A
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lift-/.f6484.0
Applied rewrites84.0%
if -8.99999999999999961e38 < y.im < 9.8000000000000001e-172Initial program 68.1%
Taylor expanded in y.re around inf
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6492.3
Applied rewrites92.3%
if 9.8000000000000001e-172 < y.im < 4.20000000000000002e68Initial program 84.6%
if 4.20000000000000002e68 < y.im Initial program 38.6%
Taylor expanded in y.re around 0
+-commutativeN/A
pow2N/A
times-fracN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-/.f6471.8
Applied rewrites71.8%
lift-/.f64N/A
lift-/.f64N/A
lift-/.f64N/A
lift-fma.f64N/A
associate-*r/N/A
div-add-revN/A
lower-/.f64N/A
lower-fma.f64N/A
lift-/.f6473.5
Applied rewrites73.5%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(if (<= y.re -5.6e-15)
(/ x.re y.re)
(if (<= y.re 7.5e-117)
(/ x.im y.im)
(if (<= y.re 8e+79)
(* x.re (/ y.re (fma y.im y.im (* y.re y.re))))
(if (<= y.re 1.2e+131)
(/ (fma x.re y.re (* x.im y.im)) (* y.re y.re))
(/ x.re y.re))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double tmp;
if (y_46_re <= -5.6e-15) {
tmp = x_46_re / y_46_re;
} else if (y_46_re <= 7.5e-117) {
tmp = x_46_im / y_46_im;
} else if (y_46_re <= 8e+79) {
tmp = x_46_re * (y_46_re / fma(y_46_im, y_46_im, (y_46_re * y_46_re)));
} else if (y_46_re <= 1.2e+131) {
tmp = fma(x_46_re, y_46_re, (x_46_im * y_46_im)) / (y_46_re * y_46_re);
} else {
tmp = x_46_re / y_46_re;
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0 if (y_46_re <= -5.6e-15) tmp = Float64(x_46_re / y_46_re); elseif (y_46_re <= 7.5e-117) tmp = Float64(x_46_im / y_46_im); elseif (y_46_re <= 8e+79) tmp = Float64(x_46_re * Float64(y_46_re / fma(y_46_im, y_46_im, Float64(y_46_re * y_46_re)))); elseif (y_46_re <= 1.2e+131) tmp = Float64(fma(x_46_re, y_46_re, Float64(x_46_im * y_46_im)) / Float64(y_46_re * y_46_re)); else tmp = Float64(x_46_re / y_46_re); end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[LessEqual[y$46$re, -5.6e-15], N[(x$46$re / y$46$re), $MachinePrecision], If[LessEqual[y$46$re, 7.5e-117], N[(x$46$im / y$46$im), $MachinePrecision], If[LessEqual[y$46$re, 8e+79], N[(x$46$re * N[(y$46$re / N[(y$46$im * y$46$im + N[(y$46$re * y$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$re, 1.2e+131], N[(N[(x$46$re * y$46$re + N[(x$46$im * y$46$im), $MachinePrecision]), $MachinePrecision] / N[(y$46$re * y$46$re), $MachinePrecision]), $MachinePrecision], N[(x$46$re / y$46$re), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.re \leq -5.6 \cdot 10^{-15}:\\
\;\;\;\;\frac{x.re}{y.re}\\
\mathbf{elif}\;y.re \leq 7.5 \cdot 10^{-117}:\\
\;\;\;\;\frac{x.im}{y.im}\\
\mathbf{elif}\;y.re \leq 8 \cdot 10^{+79}:\\
\;\;\;\;x.re \cdot \frac{y.re}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}\\
\mathbf{elif}\;y.re \leq 1.2 \cdot 10^{+131}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right)}{y.re \cdot y.re}\\
\mathbf{else}:\\
\;\;\;\;\frac{x.re}{y.re}\\
\end{array}
\end{array}
if y.re < -5.60000000000000028e-15 or 1.2e131 < y.re Initial program 41.8%
Taylor expanded in y.re around inf
lower-/.f6471.3
Applied rewrites71.3%
if -5.60000000000000028e-15 < y.re < 7.50000000000000066e-117Initial program 69.9%
Taylor expanded in y.re around 0
lower-/.f6474.0
Applied rewrites74.0%
if 7.50000000000000066e-117 < y.re < 7.99999999999999974e79Initial program 82.0%
Taylor expanded in x.re around inf
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lower-fma.f64N/A
pow2N/A
lift-*.f6471.1
Applied rewrites71.1%
if 7.99999999999999974e79 < y.re < 1.2e131Initial program 84.9%
Taylor expanded in y.re around inf
pow2N/A
lift-*.f6484.6
Applied rewrites84.6%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lower-fma.f64N/A
lift-*.f6484.8
Applied rewrites84.8%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(if (<= y.im -9e+38)
(/ (+ x.im (* (/ x.re y.im) y.re)) y.im)
(if (<= y.im 9.8e-172)
(/ (fma x.im (/ y.im y.re) x.re) y.re)
(if (<= y.im 4.2e+68)
(/ (fma y.im x.im (* y.re x.re)) (fma y.im y.im (* y.re y.re)))
(/ (fma (/ x.re y.im) y.re x.im) y.im)))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double tmp;
if (y_46_im <= -9e+38) {
tmp = (x_46_im + ((x_46_re / y_46_im) * y_46_re)) / y_46_im;
} else if (y_46_im <= 9.8e-172) {
tmp = fma(x_46_im, (y_46_im / y_46_re), x_46_re) / y_46_re;
} else if (y_46_im <= 4.2e+68) {
tmp = fma(y_46_im, x_46_im, (y_46_re * x_46_re)) / fma(y_46_im, y_46_im, (y_46_re * y_46_re));
} else {
tmp = fma((x_46_re / y_46_im), y_46_re, x_46_im) / y_46_im;
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0 if (y_46_im <= -9e+38) tmp = Float64(Float64(x_46_im + Float64(Float64(x_46_re / y_46_im) * y_46_re)) / y_46_im); elseif (y_46_im <= 9.8e-172) tmp = Float64(fma(x_46_im, Float64(y_46_im / y_46_re), x_46_re) / y_46_re); elseif (y_46_im <= 4.2e+68) tmp = Float64(fma(y_46_im, x_46_im, Float64(y_46_re * x_46_re)) / fma(y_46_im, y_46_im, Float64(y_46_re * y_46_re))); else tmp = Float64(fma(Float64(x_46_re / y_46_im), y_46_re, x_46_im) / y_46_im); end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[LessEqual[y$46$im, -9e+38], N[(N[(x$46$im + N[(N[(x$46$re / y$46$im), $MachinePrecision] * y$46$re), $MachinePrecision]), $MachinePrecision] / y$46$im), $MachinePrecision], If[LessEqual[y$46$im, 9.8e-172], N[(N[(x$46$im * N[(y$46$im / y$46$re), $MachinePrecision] + x$46$re), $MachinePrecision] / y$46$re), $MachinePrecision], If[LessEqual[y$46$im, 4.2e+68], N[(N[(y$46$im * x$46$im + N[(y$46$re * x$46$re), $MachinePrecision]), $MachinePrecision] / N[(y$46$im * y$46$im + N[(y$46$re * y$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x$46$re / y$46$im), $MachinePrecision] * y$46$re + x$46$im), $MachinePrecision] / y$46$im), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.im \leq -9 \cdot 10^{+38}:\\
\;\;\;\;\frac{x.im + \frac{x.re}{y.im} \cdot y.re}{y.im}\\
\mathbf{elif}\;y.im \leq 9.8 \cdot 10^{-172}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x.im, \frac{y.im}{y.re}, x.re\right)}{y.re}\\
\mathbf{elif}\;y.im \leq 4.2 \cdot 10^{+68}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y.im, x.im, y.re \cdot x.re\right)}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{x.re}{y.im}, y.re, x.im\right)}{y.im}\\
\end{array}
\end{array}
if y.im < -8.99999999999999961e38Initial program 48.5%
Taylor expanded in y.re around 0
+-commutativeN/A
pow2N/A
times-fracN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-/.f6482.5
Applied rewrites82.5%
lift-/.f64N/A
lift-/.f64N/A
lift-/.f64N/A
lift-fma.f64N/A
frac-timesN/A
pow2N/A
+-commutativeN/A
pow2N/A
frac-timesN/A
associate-*r/N/A
div-add-revN/A
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lift-/.f6484.0
Applied rewrites84.0%
if -8.99999999999999961e38 < y.im < 9.8000000000000001e-172Initial program 68.1%
Taylor expanded in y.re around inf
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6492.3
Applied rewrites92.3%
if 9.8000000000000001e-172 < y.im < 4.20000000000000002e68Initial program 84.6%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6484.6
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
pow2N/A
+-commutativeN/A
pow2N/A
lower-fma.f64N/A
pow2N/A
lift-*.f6484.6
Applied rewrites84.6%
if 4.20000000000000002e68 < y.im Initial program 38.6%
Taylor expanded in y.re around 0
+-commutativeN/A
pow2N/A
times-fracN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-/.f6471.8
Applied rewrites71.8%
lift-/.f64N/A
lift-/.f64N/A
lift-/.f64N/A
lift-fma.f64N/A
associate-*r/N/A
div-add-revN/A
lower-/.f64N/A
lower-fma.f64N/A
lift-/.f6473.5
Applied rewrites73.5%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (/ (fma x.im (/ y.im y.re) x.re) y.re)))
(if (<= y.re -3.6e-15)
t_0
(if (<= y.re 7.5e-117)
(/ x.im y.im)
(if (<= y.re 7.2e+79)
(* x.re (/ y.re (fma y.im y.im (* y.re y.re))))
t_0)))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = fma(x_46_im, (y_46_im / y_46_re), x_46_re) / y_46_re;
double tmp;
if (y_46_re <= -3.6e-15) {
tmp = t_0;
} else if (y_46_re <= 7.5e-117) {
tmp = x_46_im / y_46_im;
} else if (y_46_re <= 7.2e+79) {
tmp = x_46_re * (y_46_re / fma(y_46_im, y_46_im, (y_46_re * y_46_re)));
} else {
tmp = t_0;
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = Float64(fma(x_46_im, Float64(y_46_im / y_46_re), x_46_re) / y_46_re) tmp = 0.0 if (y_46_re <= -3.6e-15) tmp = t_0; elseif (y_46_re <= 7.5e-117) tmp = Float64(x_46_im / y_46_im); elseif (y_46_re <= 7.2e+79) tmp = Float64(x_46_re * Float64(y_46_re / fma(y_46_im, y_46_im, Float64(y_46_re * y_46_re)))); else tmp = t_0; end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(N[(x$46$im * N[(y$46$im / y$46$re), $MachinePrecision] + x$46$re), $MachinePrecision] / y$46$re), $MachinePrecision]}, If[LessEqual[y$46$re, -3.6e-15], t$95$0, If[LessEqual[y$46$re, 7.5e-117], N[(x$46$im / y$46$im), $MachinePrecision], If[LessEqual[y$46$re, 7.2e+79], N[(x$46$re * N[(y$46$re / N[(y$46$im * y$46$im + N[(y$46$re * y$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\mathsf{fma}\left(x.im, \frac{y.im}{y.re}, x.re\right)}{y.re}\\
\mathbf{if}\;y.re \leq -3.6 \cdot 10^{-15}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y.re \leq 7.5 \cdot 10^{-117}:\\
\;\;\;\;\frac{x.im}{y.im}\\
\mathbf{elif}\;y.re \leq 7.2 \cdot 10^{+79}:\\
\;\;\;\;x.re \cdot \frac{y.re}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y.re < -3.6000000000000001e-15 or 7.1999999999999999e79 < y.re Initial program 46.6%
Taylor expanded in y.re around inf
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6482.6
Applied rewrites82.6%
if -3.6000000000000001e-15 < y.re < 7.50000000000000066e-117Initial program 69.9%
Taylor expanded in y.re around 0
lower-/.f6474.0
Applied rewrites74.0%
if 7.50000000000000066e-117 < y.re < 7.1999999999999999e79Initial program 82.0%
Taylor expanded in x.re around inf
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lower-fma.f64N/A
pow2N/A
lift-*.f6471.1
Applied rewrites71.1%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(if (<= y.re -5.6e-15)
(/ x.re y.re)
(if (<= y.re 7.5e-117)
(/ x.im y.im)
(if (<= y.re 8e+79)
(* x.re (/ y.re (fma y.im y.im (* y.re y.re))))
(/ x.re y.re)))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double tmp;
if (y_46_re <= -5.6e-15) {
tmp = x_46_re / y_46_re;
} else if (y_46_re <= 7.5e-117) {
tmp = x_46_im / y_46_im;
} else if (y_46_re <= 8e+79) {
tmp = x_46_re * (y_46_re / fma(y_46_im, y_46_im, (y_46_re * y_46_re)));
} else {
tmp = x_46_re / y_46_re;
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0 if (y_46_re <= -5.6e-15) tmp = Float64(x_46_re / y_46_re); elseif (y_46_re <= 7.5e-117) tmp = Float64(x_46_im / y_46_im); elseif (y_46_re <= 8e+79) tmp = Float64(x_46_re * Float64(y_46_re / fma(y_46_im, y_46_im, Float64(y_46_re * y_46_re)))); else tmp = Float64(x_46_re / y_46_re); end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[LessEqual[y$46$re, -5.6e-15], N[(x$46$re / y$46$re), $MachinePrecision], If[LessEqual[y$46$re, 7.5e-117], N[(x$46$im / y$46$im), $MachinePrecision], If[LessEqual[y$46$re, 8e+79], N[(x$46$re * N[(y$46$re / N[(y$46$im * y$46$im + N[(y$46$re * y$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$46$re / y$46$re), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.re \leq -5.6 \cdot 10^{-15}:\\
\;\;\;\;\frac{x.re}{y.re}\\
\mathbf{elif}\;y.re \leq 7.5 \cdot 10^{-117}:\\
\;\;\;\;\frac{x.im}{y.im}\\
\mathbf{elif}\;y.re \leq 8 \cdot 10^{+79}:\\
\;\;\;\;x.re \cdot \frac{y.re}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{x.re}{y.re}\\
\end{array}
\end{array}
if y.re < -5.60000000000000028e-15 or 7.99999999999999974e79 < y.re Initial program 46.6%
Taylor expanded in y.re around inf
lower-/.f6469.4
Applied rewrites69.4%
if -5.60000000000000028e-15 < y.re < 7.50000000000000066e-117Initial program 69.9%
Taylor expanded in y.re around 0
lower-/.f6474.0
Applied rewrites74.0%
if 7.50000000000000066e-117 < y.re < 7.99999999999999974e79Initial program 82.0%
Taylor expanded in x.re around inf
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lower-fma.f64N/A
pow2N/A
lift-*.f6471.1
Applied rewrites71.1%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (or (<= y.im -9e+38) (not (<= y.im 2.7e-8))) (/ (fma (/ x.re y.im) y.re x.im) y.im) (/ (fma x.im (/ y.im y.re) x.re) y.re)))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double tmp;
if ((y_46_im <= -9e+38) || !(y_46_im <= 2.7e-8)) {
tmp = fma((x_46_re / y_46_im), y_46_re, x_46_im) / y_46_im;
} else {
tmp = fma(x_46_im, (y_46_im / y_46_re), x_46_re) / y_46_re;
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0 if ((y_46_im <= -9e+38) || !(y_46_im <= 2.7e-8)) tmp = Float64(fma(Float64(x_46_re / y_46_im), y_46_re, x_46_im) / y_46_im); else tmp = Float64(fma(x_46_im, Float64(y_46_im / y_46_re), x_46_re) / y_46_re); end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[Or[LessEqual[y$46$im, -9e+38], N[Not[LessEqual[y$46$im, 2.7e-8]], $MachinePrecision]], N[(N[(N[(x$46$re / y$46$im), $MachinePrecision] * y$46$re + x$46$im), $MachinePrecision] / y$46$im), $MachinePrecision], N[(N[(x$46$im * N[(y$46$im / y$46$re), $MachinePrecision] + x$46$re), $MachinePrecision] / y$46$re), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.im \leq -9 \cdot 10^{+38} \lor \neg \left(y.im \leq 2.7 \cdot 10^{-8}\right):\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{x.re}{y.im}, y.re, x.im\right)}{y.im}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x.im, \frac{y.im}{y.re}, x.re\right)}{y.re}\\
\end{array}
\end{array}
if y.im < -8.99999999999999961e38 or 2.70000000000000002e-8 < y.im Initial program 48.6%
Taylor expanded in y.re around 0
+-commutativeN/A
pow2N/A
times-fracN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-/.f6476.2
Applied rewrites76.2%
lift-/.f64N/A
lift-/.f64N/A
lift-/.f64N/A
lift-fma.f64N/A
associate-*r/N/A
div-add-revN/A
lower-/.f64N/A
lower-fma.f64N/A
lift-/.f6477.6
Applied rewrites77.6%
if -8.99999999999999961e38 < y.im < 2.70000000000000002e-8Initial program 73.6%
Taylor expanded in y.re around inf
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6487.2
Applied rewrites87.2%
Final simplification82.3%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (or (<= y.im -1e+39) (not (<= y.im 2.7e-8))) (/ (fma x.re (/ y.re y.im) x.im) y.im) (/ (fma x.im (/ y.im y.re) x.re) y.re)))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double tmp;
if ((y_46_im <= -1e+39) || !(y_46_im <= 2.7e-8)) {
tmp = fma(x_46_re, (y_46_re / y_46_im), x_46_im) / y_46_im;
} else {
tmp = fma(x_46_im, (y_46_im / y_46_re), x_46_re) / y_46_re;
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0 if ((y_46_im <= -1e+39) || !(y_46_im <= 2.7e-8)) tmp = Float64(fma(x_46_re, Float64(y_46_re / y_46_im), x_46_im) / y_46_im); else tmp = Float64(fma(x_46_im, Float64(y_46_im / y_46_re), x_46_re) / y_46_re); end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[Or[LessEqual[y$46$im, -1e+39], N[Not[LessEqual[y$46$im, 2.7e-8]], $MachinePrecision]], N[(N[(x$46$re * N[(y$46$re / y$46$im), $MachinePrecision] + x$46$im), $MachinePrecision] / y$46$im), $MachinePrecision], N[(N[(x$46$im * N[(y$46$im / y$46$re), $MachinePrecision] + x$46$re), $MachinePrecision] / y$46$re), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.im \leq -1 \cdot 10^{+39} \lor \neg \left(y.im \leq 2.7 \cdot 10^{-8}\right):\\
\;\;\;\;\frac{\mathsf{fma}\left(x.re, \frac{y.re}{y.im}, x.im\right)}{y.im}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x.im, \frac{y.im}{y.re}, x.re\right)}{y.re}\\
\end{array}
\end{array}
if y.im < -9.9999999999999994e38 or 2.70000000000000002e-8 < y.im Initial program 48.6%
Taylor expanded in y.im around inf
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6476.1
Applied rewrites76.1%
if -9.9999999999999994e38 < y.im < 2.70000000000000002e-8Initial program 73.6%
Taylor expanded in y.re around inf
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6487.2
Applied rewrites87.2%
Final simplification81.5%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(if (<= y.im -9e+38)
(/ (+ x.im (* (/ x.re y.im) y.re)) y.im)
(if (<= y.im 2.7e-8)
(/ (fma x.im (/ y.im y.re) x.re) y.re)
(/ (fma (/ x.re y.im) y.re x.im) y.im))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double tmp;
if (y_46_im <= -9e+38) {
tmp = (x_46_im + ((x_46_re / y_46_im) * y_46_re)) / y_46_im;
} else if (y_46_im <= 2.7e-8) {
tmp = fma(x_46_im, (y_46_im / y_46_re), x_46_re) / y_46_re;
} else {
tmp = fma((x_46_re / y_46_im), y_46_re, x_46_im) / y_46_im;
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0 if (y_46_im <= -9e+38) tmp = Float64(Float64(x_46_im + Float64(Float64(x_46_re / y_46_im) * y_46_re)) / y_46_im); elseif (y_46_im <= 2.7e-8) tmp = Float64(fma(x_46_im, Float64(y_46_im / y_46_re), x_46_re) / y_46_re); else tmp = Float64(fma(Float64(x_46_re / y_46_im), y_46_re, x_46_im) / y_46_im); end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[LessEqual[y$46$im, -9e+38], N[(N[(x$46$im + N[(N[(x$46$re / y$46$im), $MachinePrecision] * y$46$re), $MachinePrecision]), $MachinePrecision] / y$46$im), $MachinePrecision], If[LessEqual[y$46$im, 2.7e-8], N[(N[(x$46$im * N[(y$46$im / y$46$re), $MachinePrecision] + x$46$re), $MachinePrecision] / y$46$re), $MachinePrecision], N[(N[(N[(x$46$re / y$46$im), $MachinePrecision] * y$46$re + x$46$im), $MachinePrecision] / y$46$im), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.im \leq -9 \cdot 10^{+38}:\\
\;\;\;\;\frac{x.im + \frac{x.re}{y.im} \cdot y.re}{y.im}\\
\mathbf{elif}\;y.im \leq 2.7 \cdot 10^{-8}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x.im, \frac{y.im}{y.re}, x.re\right)}{y.re}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{x.re}{y.im}, y.re, x.im\right)}{y.im}\\
\end{array}
\end{array}
if y.im < -8.99999999999999961e38Initial program 48.5%
Taylor expanded in y.re around 0
+-commutativeN/A
pow2N/A
times-fracN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-/.f6482.5
Applied rewrites82.5%
lift-/.f64N/A
lift-/.f64N/A
lift-/.f64N/A
lift-fma.f64N/A
frac-timesN/A
pow2N/A
+-commutativeN/A
pow2N/A
frac-timesN/A
associate-*r/N/A
div-add-revN/A
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lift-/.f6484.0
Applied rewrites84.0%
if -8.99999999999999961e38 < y.im < 2.70000000000000002e-8Initial program 73.6%
Taylor expanded in y.re around inf
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6487.2
Applied rewrites87.2%
if 2.70000000000000002e-8 < y.im Initial program 48.7%
Taylor expanded in y.re around 0
+-commutativeN/A
pow2N/A
times-fracN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-/.f6470.9
Applied rewrites70.9%
lift-/.f64N/A
lift-/.f64N/A
lift-/.f64N/A
lift-fma.f64N/A
associate-*r/N/A
div-add-revN/A
lower-/.f64N/A
lower-fma.f64N/A
lift-/.f6472.2
Applied rewrites72.2%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (or (<= y.re -5.6e-15) (not (<= y.re 8.5e-117))) (/ x.re y.re) (/ x.im y.im)))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double tmp;
if ((y_46_re <= -5.6e-15) || !(y_46_re <= 8.5e-117)) {
tmp = x_46_re / y_46_re;
} else {
tmp = x_46_im / y_46_im;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x_46re, x_46im, y_46re, y_46im)
use fmin_fmax_functions
real(8), intent (in) :: x_46re
real(8), intent (in) :: x_46im
real(8), intent (in) :: y_46re
real(8), intent (in) :: y_46im
real(8) :: tmp
if ((y_46re <= (-5.6d-15)) .or. (.not. (y_46re <= 8.5d-117))) then
tmp = x_46re / y_46re
else
tmp = x_46im / y_46im
end if
code = tmp
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double tmp;
if ((y_46_re <= -5.6e-15) || !(y_46_re <= 8.5e-117)) {
tmp = x_46_re / y_46_re;
} else {
tmp = x_46_im / y_46_im;
}
return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): tmp = 0 if (y_46_re <= -5.6e-15) or not (y_46_re <= 8.5e-117): tmp = x_46_re / y_46_re else: tmp = x_46_im / y_46_im return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0 if ((y_46_re <= -5.6e-15) || !(y_46_re <= 8.5e-117)) tmp = Float64(x_46_re / y_46_re); else tmp = Float64(x_46_im / y_46_im); end return tmp end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0; if ((y_46_re <= -5.6e-15) || ~((y_46_re <= 8.5e-117))) tmp = x_46_re / y_46_re; else tmp = x_46_im / y_46_im; end tmp_2 = tmp; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[Or[LessEqual[y$46$re, -5.6e-15], N[Not[LessEqual[y$46$re, 8.5e-117]], $MachinePrecision]], N[(x$46$re / y$46$re), $MachinePrecision], N[(x$46$im / y$46$im), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.re \leq -5.6 \cdot 10^{-15} \lor \neg \left(y.re \leq 8.5 \cdot 10^{-117}\right):\\
\;\;\;\;\frac{x.re}{y.re}\\
\mathbf{else}:\\
\;\;\;\;\frac{x.im}{y.im}\\
\end{array}
\end{array}
if y.re < -5.60000000000000028e-15 or 8.49999999999999981e-117 < y.re Initial program 55.2%
Taylor expanded in y.re around inf
lower-/.f6463.4
Applied rewrites63.4%
if -5.60000000000000028e-15 < y.re < 8.49999999999999981e-117Initial program 69.9%
Taylor expanded in y.re around 0
lower-/.f6474.0
Applied rewrites74.0%
Final simplification67.5%
(FPCore (x.re x.im y.re y.im) :precision binary64 (/ x.im y.im))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return x_46_im / y_46_im;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x_46re, x_46im, y_46re, y_46im)
use fmin_fmax_functions
real(8), intent (in) :: x_46re
real(8), intent (in) :: x_46im
real(8), intent (in) :: y_46re
real(8), intent (in) :: y_46im
code = x_46im / y_46im
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return x_46_im / y_46_im;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): return x_46_im / y_46_im
function code(x_46_re, x_46_im, y_46_re, y_46_im) return Float64(x_46_im / y_46_im) end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = x_46_im / y_46_im; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(x$46$im / y$46$im), $MachinePrecision]
\begin{array}{l}
\\
\frac{x.im}{y.im}
\end{array}
Initial program 60.9%
Taylor expanded in y.re around 0
lower-/.f6440.8
Applied rewrites40.8%
herbie shell --seed 2025056
(FPCore (x.re x.im y.re y.im)
:name "_divideComplex, real part"
:precision binary64
(/ (+ (* x.re y.re) (* x.im y.im)) (+ (* y.re y.re) (* y.im y.im))))