
(FPCore (x.re x.im y.re y.im) :precision binary64 (/ (- (* x.im y.re) (* x.re 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_im * y_46_re) - (x_46_re * 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_46im * y_46re) - (x_46re * 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_im * y_46_re) - (x_46_re * 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_im * y_46_re) - (x_46_re * 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_im * y_46_re) - Float64(x_46_re * 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_im * y_46_re) - (x_46_re * 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$im * y$46$re), $MachinePrecision] - N[(x$46$re * y$46$im), $MachinePrecision]), $MachinePrecision] / N[(N[(y$46$re * y$46$re), $MachinePrecision] + N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x.re x.im y.re y.im) :precision binary64 (/ (- (* x.im y.re) (* x.re 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_im * y_46_re) - (x_46_re * 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_46im * y_46re) - (x_46re * 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_im * y_46_re) - (x_46_re * 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_im * y_46_re) - (x_46_re * 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_im * y_46_re) - Float64(x_46_re * 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_im * y_46_re) - (x_46_re * 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$im * y$46$re), $MachinePrecision] - N[(x$46$re * y$46$im), $MachinePrecision]), $MachinePrecision] / N[(N[(y$46$re * y$46$re), $MachinePrecision] + N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (fma y.im y.im (* y.re y.re))))
(if (<= y.re -2.4e+113)
(fma (/ (- y.im) y.re) (/ x.re y.re) (/ x.im y.re))
(if (<= y.re 5.3e-12)
(/
(- (/ (* y.re x.im) y.im) x.re)
(fma (/ y.re y.im) y.re y.im))
(if (<= y.re 8.5e+116)
(- (* (/ x.im t_0) y.re) (* (/ x.re t_0) y.im))
(/ (fma (/ x.re y.re) (- y.im) x.im) y.re))))))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 tmp;
if (y_46_re <= -2.4e+113) {
tmp = fma((-y_46_im / y_46_re), (x_46_re / y_46_re), (x_46_im / y_46_re));
} else if (y_46_re <= 5.3e-12) {
tmp = (((y_46_re * x_46_im) / y_46_im) - x_46_re) / fma((y_46_re / y_46_im), y_46_re, y_46_im);
} else if (y_46_re <= 8.5e+116) {
tmp = ((x_46_im / t_0) * y_46_re) - ((x_46_re / t_0) * y_46_im);
} else {
tmp = fma((x_46_re / y_46_re), -y_46_im, x_46_im) / y_46_re;
}
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)) tmp = 0.0 if (y_46_re <= -2.4e+113) tmp = fma(Float64(Float64(-y_46_im) / y_46_re), Float64(x_46_re / y_46_re), Float64(x_46_im / y_46_re)); elseif (y_46_re <= 5.3e-12) tmp = Float64(Float64(Float64(Float64(y_46_re * x_46_im) / y_46_im) - x_46_re) / fma(Float64(y_46_re / y_46_im), y_46_re, y_46_im)); elseif (y_46_re <= 8.5e+116) tmp = Float64(Float64(Float64(x_46_im / t_0) * y_46_re) - Float64(Float64(x_46_re / t_0) * y_46_im)); else tmp = Float64(fma(Float64(x_46_re / y_46_re), Float64(-y_46_im), x_46_im) / y_46_re); 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]}, If[LessEqual[y$46$re, -2.4e+113], N[(N[((-y$46$im) / y$46$re), $MachinePrecision] * N[(x$46$re / y$46$re), $MachinePrecision] + N[(x$46$im / y$46$re), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$re, 5.3e-12], N[(N[(N[(N[(y$46$re * x$46$im), $MachinePrecision] / y$46$im), $MachinePrecision] - x$46$re), $MachinePrecision] / N[(N[(y$46$re / y$46$im), $MachinePrecision] * y$46$re + y$46$im), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$re, 8.5e+116], N[(N[(N[(x$46$im / t$95$0), $MachinePrecision] * y$46$re), $MachinePrecision] - N[(N[(x$46$re / t$95$0), $MachinePrecision] * y$46$im), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x$46$re / y$46$re), $MachinePrecision] * (-y$46$im) + x$46$im), $MachinePrecision] / y$46$re), $MachinePrecision]]]]]
\begin{array}{l}
t_0 := \mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)\\
\mathbf{if}\;y.re \leq -2.4 \cdot 10^{+113}:\\
\;\;\;\;\mathsf{fma}\left(\frac{-y.im}{y.re}, \frac{x.re}{y.re}, \frac{x.im}{y.re}\right)\\
\mathbf{elif}\;y.re \leq 5.3 \cdot 10^{-12}:\\
\;\;\;\;\frac{\frac{y.re \cdot x.im}{y.im} - x.re}{\mathsf{fma}\left(\frac{y.re}{y.im}, y.re, y.im\right)}\\
\mathbf{elif}\;y.re \leq 8.5 \cdot 10^{+116}:\\
\;\;\;\;\frac{x.im}{t\_0} \cdot y.re - \frac{x.re}{t\_0} \cdot y.im\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{x.re}{y.re}, -y.im, x.im\right)}{y.re}\\
\end{array}
if y.re < -2.3999999999999998e113Initial program 62.0%
Taylor expanded in y.re around inf
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6452.8%
Applied rewrites52.8%
lift-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
div-addN/A
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
distribute-neg-fracN/A
associate-/l/N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
times-fracN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-neg.f64N/A
lower-/.f64N/A
lower-/.f6453.4%
Applied rewrites53.4%
if -2.3999999999999998e113 < y.re < 5.2999999999999996e-12Initial program 62.0%
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
remove-double-negN/A
remove-double-negN/A
*-rgt-identityN/A
lft-mult-inverseN/A
associate-*l*N/A
mult-flipN/A
distribute-rgt-neg-outN/A
lift-*.f64N/A
remove-double-negN/A
distribute-rgt-neg-outN/A
distribute-lft-neg-inN/A
distribute-rgt-neg-inN/A
distribute-lft-neg-outN/A
fp-cancel-sub-sign-invN/A
fp-cancel-sign-subN/A
lift-*.f64N/A
Applied rewrites62.0%
Applied rewrites74.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6474.5%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6474.5%
Applied rewrites74.5%
if 5.2999999999999996e-12 < y.re < 8.5000000000000002e116Initial program 62.0%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
lower--.f64N/A
Applied rewrites58.7%
if 8.5000000000000002e116 < y.re Initial program 62.0%
Taylor expanded in y.re around inf
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6452.8%
Applied rewrites52.8%
lift-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
div-addN/A
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
distribute-neg-fracN/A
associate-/l/N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
times-fracN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-neg.f64N/A
lower-/.f64N/A
lower-/.f6453.4%
Applied rewrites53.4%
lift-fma.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-/.f64N/A
div-add-revN/A
lower-/.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-*r/N/A
lift-/.f64N/A
*-commutativeN/A
lower-fma.f6454.0%
Applied rewrites54.0%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(if (<= y.re -2.4e+113)
(fma (/ (- y.im) y.re) (/ x.re y.re) (/ x.im y.re))
(if (<= y.re 5.8e+81)
(/ (- (/ (* y.re x.im) y.im) x.re) (fma (/ y.re y.im) y.re y.im))
(/ (fma (/ x.re y.re) (- y.im) x.im) 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 <= -2.4e+113) {
tmp = fma((-y_46_im / y_46_re), (x_46_re / y_46_re), (x_46_im / y_46_re));
} else if (y_46_re <= 5.8e+81) {
tmp = (((y_46_re * x_46_im) / y_46_im) - x_46_re) / fma((y_46_re / y_46_im), y_46_re, y_46_im);
} else {
tmp = fma((x_46_re / y_46_re), -y_46_im, x_46_im) / 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 <= -2.4e+113) tmp = fma(Float64(Float64(-y_46_im) / y_46_re), Float64(x_46_re / y_46_re), Float64(x_46_im / y_46_re)); elseif (y_46_re <= 5.8e+81) tmp = Float64(Float64(Float64(Float64(y_46_re * x_46_im) / y_46_im) - x_46_re) / fma(Float64(y_46_re / y_46_im), y_46_re, y_46_im)); else tmp = Float64(fma(Float64(x_46_re / y_46_re), Float64(-y_46_im), x_46_im) / 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, -2.4e+113], N[(N[((-y$46$im) / y$46$re), $MachinePrecision] * N[(x$46$re / y$46$re), $MachinePrecision] + N[(x$46$im / y$46$re), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$re, 5.8e+81], N[(N[(N[(N[(y$46$re * x$46$im), $MachinePrecision] / y$46$im), $MachinePrecision] - x$46$re), $MachinePrecision] / N[(N[(y$46$re / y$46$im), $MachinePrecision] * y$46$re + y$46$im), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x$46$re / y$46$re), $MachinePrecision] * (-y$46$im) + x$46$im), $MachinePrecision] / y$46$re), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;y.re \leq -2.4 \cdot 10^{+113}:\\
\;\;\;\;\mathsf{fma}\left(\frac{-y.im}{y.re}, \frac{x.re}{y.re}, \frac{x.im}{y.re}\right)\\
\mathbf{elif}\;y.re \leq 5.8 \cdot 10^{+81}:\\
\;\;\;\;\frac{\frac{y.re \cdot x.im}{y.im} - x.re}{\mathsf{fma}\left(\frac{y.re}{y.im}, y.re, y.im\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{x.re}{y.re}, -y.im, x.im\right)}{y.re}\\
\end{array}
if y.re < -2.3999999999999998e113Initial program 62.0%
Taylor expanded in y.re around inf
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6452.8%
Applied rewrites52.8%
lift-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
div-addN/A
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
distribute-neg-fracN/A
associate-/l/N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
times-fracN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-neg.f64N/A
lower-/.f64N/A
lower-/.f6453.4%
Applied rewrites53.4%
if -2.3999999999999998e113 < y.re < 5.7999999999999999e81Initial program 62.0%
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
remove-double-negN/A
remove-double-negN/A
*-rgt-identityN/A
lft-mult-inverseN/A
associate-*l*N/A
mult-flipN/A
distribute-rgt-neg-outN/A
lift-*.f64N/A
remove-double-negN/A
distribute-rgt-neg-outN/A
distribute-lft-neg-inN/A
distribute-rgt-neg-inN/A
distribute-lft-neg-outN/A
fp-cancel-sub-sign-invN/A
fp-cancel-sign-subN/A
lift-*.f64N/A
Applied rewrites62.0%
Applied rewrites74.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6474.5%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6474.5%
Applied rewrites74.5%
if 5.7999999999999999e81 < y.re Initial program 62.0%
Taylor expanded in y.re around inf
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6452.8%
Applied rewrites52.8%
lift-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
div-addN/A
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
distribute-neg-fracN/A
associate-/l/N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
times-fracN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-neg.f64N/A
lower-/.f64N/A
lower-/.f6453.4%
Applied rewrites53.4%
lift-fma.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-/.f64N/A
div-add-revN/A
lower-/.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-*r/N/A
lift-/.f64N/A
*-commutativeN/A
lower-fma.f6454.0%
Applied rewrites54.0%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0
(/
(fma (- y.im) x.re (* y.re x.im))
(fma y.re y.re (* y.im y.im)))))
(if (<= y.re -8.8e+92)
(fma (/ (- y.im) y.re) (/ x.re y.re) (/ x.im y.re))
(if (<= y.re -2.6e-92)
t_0
(if (<= y.re 8.2e-91)
(/ (- (* (/ y.re y.im) x.im) x.re) y.im)
(if (<= y.re 5.8e+81)
t_0
(/ (fma (/ x.re y.re) (- y.im) x.im) y.re)))))))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, x_46_re, (y_46_re * x_46_im)) / fma(y_46_re, y_46_re, (y_46_im * y_46_im));
double tmp;
if (y_46_re <= -8.8e+92) {
tmp = fma((-y_46_im / y_46_re), (x_46_re / y_46_re), (x_46_im / y_46_re));
} else if (y_46_re <= -2.6e-92) {
tmp = t_0;
} else if (y_46_re <= 8.2e-91) {
tmp = (((y_46_re / y_46_im) * x_46_im) - x_46_re) / y_46_im;
} else if (y_46_re <= 5.8e+81) {
tmp = t_0;
} else {
tmp = fma((x_46_re / y_46_re), -y_46_im, x_46_im) / y_46_re;
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = Float64(fma(Float64(-y_46_im), x_46_re, Float64(y_46_re * x_46_im)) / fma(y_46_re, y_46_re, Float64(y_46_im * y_46_im))) tmp = 0.0 if (y_46_re <= -8.8e+92) tmp = fma(Float64(Float64(-y_46_im) / y_46_re), Float64(x_46_re / y_46_re), Float64(x_46_im / y_46_re)); elseif (y_46_re <= -2.6e-92) tmp = t_0; elseif (y_46_re <= 8.2e-91) tmp = Float64(Float64(Float64(Float64(y_46_re / y_46_im) * x_46_im) - x_46_re) / y_46_im); elseif (y_46_re <= 5.8e+81) tmp = t_0; else tmp = Float64(fma(Float64(x_46_re / y_46_re), Float64(-y_46_im), x_46_im) / y_46_re); end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(N[((-y$46$im) * x$46$re + N[(y$46$re * x$46$im), $MachinePrecision]), $MachinePrecision] / N[(y$46$re * y$46$re + N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y$46$re, -8.8e+92], N[(N[((-y$46$im) / y$46$re), $MachinePrecision] * N[(x$46$re / y$46$re), $MachinePrecision] + N[(x$46$im / y$46$re), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$re, -2.6e-92], t$95$0, If[LessEqual[y$46$re, 8.2e-91], N[(N[(N[(N[(y$46$re / y$46$im), $MachinePrecision] * x$46$im), $MachinePrecision] - x$46$re), $MachinePrecision] / y$46$im), $MachinePrecision], If[LessEqual[y$46$re, 5.8e+81], t$95$0, N[(N[(N[(x$46$re / y$46$re), $MachinePrecision] * (-y$46$im) + x$46$im), $MachinePrecision] / y$46$re), $MachinePrecision]]]]]]
\begin{array}{l}
t_0 := \frac{\mathsf{fma}\left(-y.im, x.re, y.re \cdot x.im\right)}{\mathsf{fma}\left(y.re, y.re, y.im \cdot y.im\right)}\\
\mathbf{if}\;y.re \leq -8.8 \cdot 10^{+92}:\\
\;\;\;\;\mathsf{fma}\left(\frac{-y.im}{y.re}, \frac{x.re}{y.re}, \frac{x.im}{y.re}\right)\\
\mathbf{elif}\;y.re \leq -2.6 \cdot 10^{-92}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y.re \leq 8.2 \cdot 10^{-91}:\\
\;\;\;\;\frac{\frac{y.re}{y.im} \cdot x.im - x.re}{y.im}\\
\mathbf{elif}\;y.re \leq 5.8 \cdot 10^{+81}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{x.re}{y.re}, -y.im, x.im\right)}{y.re}\\
\end{array}
if y.re < -8.7999999999999997e92Initial program 62.0%
Taylor expanded in y.re around inf
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6452.8%
Applied rewrites52.8%
lift-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
div-addN/A
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
distribute-neg-fracN/A
associate-/l/N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
times-fracN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-neg.f64N/A
lower-/.f64N/A
lower-/.f6453.4%
Applied rewrites53.4%
if -8.7999999999999997e92 < y.re < -2.6e-92 or 8.2000000000000005e-91 < y.re < 5.7999999999999999e81Initial program 62.0%
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
remove-double-negN/A
remove-double-negN/A
*-rgt-identityN/A
lft-mult-inverseN/A
associate-*l*N/A
mult-flipN/A
distribute-rgt-neg-outN/A
lift-*.f64N/A
remove-double-negN/A
distribute-rgt-neg-outN/A
distribute-lft-neg-inN/A
distribute-rgt-neg-inN/A
distribute-lft-neg-outN/A
fp-cancel-sub-sign-invN/A
fp-cancel-sign-subN/A
lift-*.f64N/A
Applied rewrites62.0%
lift-+.f64N/A
add-flipN/A
sub-flipN/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-neg-inN/A
lift-neg.f64N/A
distribute-lft-neg-outN/A
lift-neg.f64N/A
sqr-neg-revN/A
lift-*.f64N/A
lower-fma.f6462.0%
Applied rewrites62.0%
if -2.6e-92 < y.re < 8.2000000000000005e-91Initial program 62.0%
Taylor expanded in y.im around inf
lower-/.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f6452.1%
Applied rewrites52.1%
lift-fma.f64N/A
+-commutativeN/A
mul-1-negN/A
sub-flip-reverseN/A
lower--.f6452.1%
Applied rewrites52.1%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f6453.9%
Applied rewrites53.9%
if 5.7999999999999999e81 < y.re Initial program 62.0%
Taylor expanded in y.re around inf
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6452.8%
Applied rewrites52.8%
lift-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
div-addN/A
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
distribute-neg-fracN/A
associate-/l/N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
times-fracN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-neg.f64N/A
lower-/.f64N/A
lower-/.f6453.4%
Applied rewrites53.4%
lift-fma.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-/.f64N/A
div-add-revN/A
lower-/.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-*r/N/A
lift-/.f64N/A
*-commutativeN/A
lower-fma.f6454.0%
Applied rewrites54.0%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(if (<= y.im -5800.0)
(/ (- (* y.re (/ x.im y.im)) x.re) y.im)
(if (<= y.im 620.0)
(/ (- x.im (/ (* x.re y.im) y.re)) y.re)
(fma (/ y.re y.im) (/ x.im y.im) (/ (- x.re) 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 <= -5800.0) {
tmp = ((y_46_re * (x_46_im / y_46_im)) - x_46_re) / y_46_im;
} else if (y_46_im <= 620.0) {
tmp = (x_46_im - ((x_46_re * y_46_im) / y_46_re)) / y_46_re;
} else {
tmp = fma((y_46_re / y_46_im), (x_46_im / y_46_im), (-x_46_re / 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 <= -5800.0) tmp = Float64(Float64(Float64(y_46_re * Float64(x_46_im / y_46_im)) - x_46_re) / y_46_im); elseif (y_46_im <= 620.0) tmp = Float64(Float64(x_46_im - Float64(Float64(x_46_re * y_46_im) / y_46_re)) / y_46_re); else tmp = fma(Float64(y_46_re / y_46_im), Float64(x_46_im / y_46_im), Float64(Float64(-x_46_re) / 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, -5800.0], N[(N[(N[(y$46$re * N[(x$46$im / y$46$im), $MachinePrecision]), $MachinePrecision] - x$46$re), $MachinePrecision] / y$46$im), $MachinePrecision], If[LessEqual[y$46$im, 620.0], N[(N[(x$46$im - N[(N[(x$46$re * y$46$im), $MachinePrecision] / y$46$re), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision], N[(N[(y$46$re / y$46$im), $MachinePrecision] * N[(x$46$im / y$46$im), $MachinePrecision] + N[((-x$46$re) / y$46$im), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;y.im \leq -5800:\\
\;\;\;\;\frac{y.re \cdot \frac{x.im}{y.im} - x.re}{y.im}\\
\mathbf{elif}\;y.im \leq 620:\\
\;\;\;\;\frac{x.im - \frac{x.re \cdot y.im}{y.re}}{y.re}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y.re}{y.im}, \frac{x.im}{y.im}, \frac{-x.re}{y.im}\right)\\
\end{array}
if y.im < -5800Initial program 62.0%
Taylor expanded in y.im around inf
lower-/.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f6452.1%
Applied rewrites52.1%
lift-fma.f64N/A
+-commutativeN/A
mul-1-negN/A
sub-flip-reverseN/A
lower--.f6452.1%
Applied rewrites52.1%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6453.2%
Applied rewrites53.2%
if -5800 < y.im < 620Initial program 62.0%
Taylor expanded in y.re around inf
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6452.8%
Applied rewrites52.8%
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
distribute-neg-fracN/A
distribute-frac-neg2N/A
frac-2negN/A
lift-/.f6452.8%
Applied rewrites52.8%
if 620 < y.im Initial program 62.0%
Taylor expanded in y.im around inf
lower-/.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f6452.1%
Applied rewrites52.1%
lift-fma.f64N/A
+-commutativeN/A
mul-1-negN/A
sub-flip-reverseN/A
lower--.f6452.1%
Applied rewrites52.1%
lift-/.f64N/A
lift--.f64N/A
sub-flipN/A
lift-neg.f64N/A
div-addN/A
lift-/.f64N/A
associate-/l/N/A
lift-*.f64N/A
*-commutativeN/A
times-fracN/A
lift-/.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f6452.2%
Applied rewrites52.2%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (/ (- (* y.re (/ x.im y.im)) x.re) y.im)))
(if (<= y.im -5800.0)
t_0
(if (<= y.im 620.0)
(/ (- x.im (/ (* x.re 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 = ((y_46_re * (x_46_im / y_46_im)) - x_46_re) / y_46_im;
double tmp;
if (y_46_im <= -5800.0) {
tmp = t_0;
} else if (y_46_im <= 620.0) {
tmp = (x_46_im - ((x_46_re * y_46_im) / y_46_re)) / y_46_re;
} else {
tmp = t_0;
}
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) :: t_0
real(8) :: tmp
t_0 = ((y_46re * (x_46im / y_46im)) - x_46re) / y_46im
if (y_46im <= (-5800.0d0)) then
tmp = t_0
else if (y_46im <= 620.0d0) then
tmp = (x_46im - ((x_46re * y_46im) / y_46re)) / y_46re
else
tmp = t_0
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 t_0 = ((y_46_re * (x_46_im / y_46_im)) - x_46_re) / y_46_im;
double tmp;
if (y_46_im <= -5800.0) {
tmp = t_0;
} else if (y_46_im <= 620.0) {
tmp = (x_46_im - ((x_46_re * y_46_im) / y_46_re)) / y_46_re;
} else {
tmp = t_0;
}
return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): t_0 = ((y_46_re * (x_46_im / y_46_im)) - x_46_re) / y_46_im tmp = 0 if y_46_im <= -5800.0: tmp = t_0 elif y_46_im <= 620.0: tmp = (x_46_im - ((x_46_re * 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(Float64(Float64(y_46_re * Float64(x_46_im / y_46_im)) - x_46_re) / y_46_im) tmp = 0.0 if (y_46_im <= -5800.0) tmp = t_0; elseif (y_46_im <= 620.0) tmp = Float64(Float64(x_46_im - Float64(Float64(x_46_re * y_46_im) / y_46_re)) / y_46_re); else tmp = t_0; end return tmp end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = ((y_46_re * (x_46_im / y_46_im)) - x_46_re) / y_46_im; tmp = 0.0; if (y_46_im <= -5800.0) tmp = t_0; elseif (y_46_im <= 620.0) tmp = (x_46_im - ((x_46_re * y_46_im) / y_46_re)) / y_46_re; else tmp = t_0; end tmp_2 = tmp; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(N[(N[(y$46$re * N[(x$46$im / y$46$im), $MachinePrecision]), $MachinePrecision] - x$46$re), $MachinePrecision] / y$46$im), $MachinePrecision]}, If[LessEqual[y$46$im, -5800.0], t$95$0, If[LessEqual[y$46$im, 620.0], N[(N[(x$46$im - N[(N[(x$46$re * y$46$im), $MachinePrecision] / y$46$re), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := \frac{y.re \cdot \frac{x.im}{y.im} - x.re}{y.im}\\
\mathbf{if}\;y.im \leq -5800:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y.im \leq 620:\\
\;\;\;\;\frac{x.im - \frac{x.re \cdot y.im}{y.re}}{y.re}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if y.im < -5800 or 620 < y.im Initial program 62.0%
Taylor expanded in y.im around inf
lower-/.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f6452.1%
Applied rewrites52.1%
lift-fma.f64N/A
+-commutativeN/A
mul-1-negN/A
sub-flip-reverseN/A
lower--.f6452.1%
Applied rewrites52.1%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6453.2%
Applied rewrites53.2%
if -5800 < y.im < 620Initial program 62.0%
Taylor expanded in y.re around inf
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6452.8%
Applied rewrites52.8%
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
distribute-neg-fracN/A
distribute-frac-neg2N/A
frac-2negN/A
lift-/.f6452.8%
Applied rewrites52.8%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (/ (- x.re) y.im)))
(if (<= y.im -1.35e+42)
t_0
(if (<= y.im 5e+101)
(/ (- x.im (/ (* x.re 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 = -x_46_re / y_46_im;
double tmp;
if (y_46_im <= -1.35e+42) {
tmp = t_0;
} else if (y_46_im <= 5e+101) {
tmp = (x_46_im - ((x_46_re * y_46_im) / y_46_re)) / y_46_re;
} else {
tmp = t_0;
}
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) :: t_0
real(8) :: tmp
t_0 = -x_46re / y_46im
if (y_46im <= (-1.35d+42)) then
tmp = t_0
else if (y_46im <= 5d+101) then
tmp = (x_46im - ((x_46re * y_46im) / y_46re)) / y_46re
else
tmp = t_0
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 t_0 = -x_46_re / y_46_im;
double tmp;
if (y_46_im <= -1.35e+42) {
tmp = t_0;
} else if (y_46_im <= 5e+101) {
tmp = (x_46_im - ((x_46_re * y_46_im) / y_46_re)) / y_46_re;
} else {
tmp = t_0;
}
return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): t_0 = -x_46_re / y_46_im tmp = 0 if y_46_im <= -1.35e+42: tmp = t_0 elif y_46_im <= 5e+101: tmp = (x_46_im - ((x_46_re * 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(Float64(-x_46_re) / y_46_im) tmp = 0.0 if (y_46_im <= -1.35e+42) tmp = t_0; elseif (y_46_im <= 5e+101) tmp = Float64(Float64(x_46_im - Float64(Float64(x_46_re * y_46_im) / y_46_re)) / y_46_re); else tmp = t_0; end return tmp end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = -x_46_re / y_46_im; tmp = 0.0; if (y_46_im <= -1.35e+42) tmp = t_0; elseif (y_46_im <= 5e+101) tmp = (x_46_im - ((x_46_re * y_46_im) / y_46_re)) / y_46_re; else tmp = t_0; end tmp_2 = tmp; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[((-x$46$re) / y$46$im), $MachinePrecision]}, If[LessEqual[y$46$im, -1.35e+42], t$95$0, If[LessEqual[y$46$im, 5e+101], N[(N[(x$46$im - N[(N[(x$46$re * y$46$im), $MachinePrecision] / y$46$re), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := \frac{-x.re}{y.im}\\
\mathbf{if}\;y.im \leq -1.35 \cdot 10^{+42}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y.im \leq 5 \cdot 10^{+101}:\\
\;\;\;\;\frac{x.im - \frac{x.re \cdot y.im}{y.re}}{y.re}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if y.im < -1.35e42 or 4.9999999999999999e101 < y.im Initial program 62.0%
Taylor expanded in y.im around inf
lower-/.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f6452.1%
Applied rewrites52.1%
Taylor expanded in x.re around inf
lower-*.f6441.5%
Applied rewrites41.5%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6441.5%
Applied rewrites41.5%
if -1.35e42 < y.im < 4.9999999999999999e101Initial program 62.0%
Taylor expanded in y.re around inf
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6452.8%
Applied rewrites52.8%
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
distribute-neg-fracN/A
distribute-frac-neg2N/A
frac-2negN/A
lift-/.f6452.8%
Applied rewrites52.8%
(FPCore (x.re x.im y.re y.im) :precision binary64 (let* ((t_0 (/ (- x.re) y.im))) (if (<= y.im -1.05e-33) t_0 (if (<= y.im 620.0) (/ x.im 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 = -x_46_re / y_46_im;
double tmp;
if (y_46_im <= -1.05e-33) {
tmp = t_0;
} else if (y_46_im <= 620.0) {
tmp = x_46_im / y_46_re;
} else {
tmp = t_0;
}
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) :: t_0
real(8) :: tmp
t_0 = -x_46re / y_46im
if (y_46im <= (-1.05d-33)) then
tmp = t_0
else if (y_46im <= 620.0d0) then
tmp = x_46im / y_46re
else
tmp = t_0
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 t_0 = -x_46_re / y_46_im;
double tmp;
if (y_46_im <= -1.05e-33) {
tmp = t_0;
} else if (y_46_im <= 620.0) {
tmp = x_46_im / y_46_re;
} else {
tmp = t_0;
}
return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): t_0 = -x_46_re / y_46_im tmp = 0 if y_46_im <= -1.05e-33: tmp = t_0 elif y_46_im <= 620.0: tmp = x_46_im / 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(Float64(-x_46_re) / y_46_im) tmp = 0.0 if (y_46_im <= -1.05e-33) tmp = t_0; elseif (y_46_im <= 620.0) tmp = Float64(x_46_im / y_46_re); else tmp = t_0; end return tmp end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = -x_46_re / y_46_im; tmp = 0.0; if (y_46_im <= -1.05e-33) tmp = t_0; elseif (y_46_im <= 620.0) tmp = x_46_im / y_46_re; else tmp = t_0; end tmp_2 = tmp; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[((-x$46$re) / y$46$im), $MachinePrecision]}, If[LessEqual[y$46$im, -1.05e-33], t$95$0, If[LessEqual[y$46$im, 620.0], N[(x$46$im / y$46$re), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := \frac{-x.re}{y.im}\\
\mathbf{if}\;y.im \leq -1.05 \cdot 10^{-33}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y.im \leq 620:\\
\;\;\;\;\frac{x.im}{y.re}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if y.im < -1.05e-33 or 620 < y.im Initial program 62.0%
Taylor expanded in y.im around inf
lower-/.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f6452.1%
Applied rewrites52.1%
Taylor expanded in x.re around inf
lower-*.f6441.5%
Applied rewrites41.5%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6441.5%
Applied rewrites41.5%
if -1.05e-33 < y.im < 620Initial program 62.0%
Taylor expanded in y.re around inf
lower-/.f6443.3%
Applied rewrites43.3%
(FPCore (x.re x.im y.re y.im) :precision binary64 (/ x.im y.re))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return x_46_im / y_46_re;
}
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_46re
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_re;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): return x_46_im / y_46_re
function code(x_46_re, x_46_im, y_46_re, y_46_im) return Float64(x_46_im / y_46_re) end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = x_46_im / y_46_re; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(x$46$im / y$46$re), $MachinePrecision]
\frac{x.im}{y.re}
Initial program 62.0%
Taylor expanded in y.re around inf
lower-/.f6443.3%
Applied rewrites43.3%
herbie shell --seed 2025212
(FPCore (x.re x.im y.re y.im)
:name "_divideComplex, imaginary part"
:precision binary64
(/ (- (* x.im y.re) (* x.re y.im)) (+ (* y.re y.re) (* y.im y.im))))