
(FPCore (a b c d) :precision binary64 (/ (- (* b c) (* a d)) (+ (* c c) (* d d))))
double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
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(a, b, c, d)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = ((b * c) - (a * d)) / ((c * c) + (d * d))
end function
public static double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
def code(a, b, c, d): return ((b * c) - (a * d)) / ((c * c) + (d * d))
function code(a, b, c, d) return Float64(Float64(Float64(b * c) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d))) end
function tmp = code(a, b, c, d) tmp = ((b * c) - (a * d)) / ((c * c) + (d * d)); end
code[a_, b_, c_, d_] := N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}
\end{array}
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b c d) :precision binary64 (/ (- (* b c) (* a d)) (+ (* c c) (* d d))))
double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
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(a, b, c, d)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = ((b * c) - (a * d)) / ((c * c) + (d * d))
end function
public static double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
def code(a, b, c, d): return ((b * c) - (a * d)) / ((c * c) + (d * d))
function code(a, b, c, d) return Float64(Float64(Float64(b * c) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d))) end
function tmp = code(a, b, c, d) tmp = ((b * c) - (a * d)) / ((c * c) + (d * d)); end
code[a_, b_, c_, d_] := N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}
\end{array}
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (fma d d (* c c)))
(t_1 (* a (/ d t_0)))
(t_2 (- (/ (fma a (/ d c) (- b)) c))))
(if (<= d -3.3e+153)
(/ (- (/ (* c b) d) a) d)
(if (<= d -6.2e-10)
(- (* (/ b t_0) c) t_1)
(if (<= d 1.25e-97)
t_2
(if (<= d 5.5e+123)
(- (* b (/ c t_0)) t_1)
(if (<= d 4e+154) t_2 (/ (- a) d))))))))
double code(double a, double b, double c, double d) {
double t_0 = fma(d, d, (c * c));
double t_1 = a * (d / t_0);
double t_2 = -(fma(a, (d / c), -b) / c);
double tmp;
if (d <= -3.3e+153) {
tmp = (((c * b) / d) - a) / d;
} else if (d <= -6.2e-10) {
tmp = ((b / t_0) * c) - t_1;
} else if (d <= 1.25e-97) {
tmp = t_2;
} else if (d <= 5.5e+123) {
tmp = (b * (c / t_0)) - t_1;
} else if (d <= 4e+154) {
tmp = t_2;
} else {
tmp = -a / d;
}
return tmp;
}
function code(a, b, c, d) t_0 = fma(d, d, Float64(c * c)) t_1 = Float64(a * Float64(d / t_0)) t_2 = Float64(-Float64(fma(a, Float64(d / c), Float64(-b)) / c)) tmp = 0.0 if (d <= -3.3e+153) tmp = Float64(Float64(Float64(Float64(c * b) / d) - a) / d); elseif (d <= -6.2e-10) tmp = Float64(Float64(Float64(b / t_0) * c) - t_1); elseif (d <= 1.25e-97) tmp = t_2; elseif (d <= 5.5e+123) tmp = Float64(Float64(b * Float64(c / t_0)) - t_1); elseif (d <= 4e+154) tmp = t_2; else tmp = Float64(Float64(-a) / d); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(a * N[(d / t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = (-N[(N[(a * N[(d / c), $MachinePrecision] + (-b)), $MachinePrecision] / c), $MachinePrecision])}, If[LessEqual[d, -3.3e+153], N[(N[(N[(N[(c * b), $MachinePrecision] / d), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, -6.2e-10], N[(N[(N[(b / t$95$0), $MachinePrecision] * c), $MachinePrecision] - t$95$1), $MachinePrecision], If[LessEqual[d, 1.25e-97], t$95$2, If[LessEqual[d, 5.5e+123], N[(N[(b * N[(c / t$95$0), $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision], If[LessEqual[d, 4e+154], t$95$2, N[((-a) / d), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(d, d, c \cdot c\right)\\
t_1 := a \cdot \frac{d}{t\_0}\\
t_2 := -\frac{\mathsf{fma}\left(a, \frac{d}{c}, -b\right)}{c}\\
\mathbf{if}\;d \leq -3.3 \cdot 10^{+153}:\\
\;\;\;\;\frac{\frac{c \cdot b}{d} - a}{d}\\
\mathbf{elif}\;d \leq -6.2 \cdot 10^{-10}:\\
\;\;\;\;\frac{b}{t\_0} \cdot c - t\_1\\
\mathbf{elif}\;d \leq 1.25 \cdot 10^{-97}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;d \leq 5.5 \cdot 10^{+123}:\\
\;\;\;\;b \cdot \frac{c}{t\_0} - t\_1\\
\mathbf{elif}\;d \leq 4 \cdot 10^{+154}:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;\frac{-a}{d}\\
\end{array}
\end{array}
if d < -3.29999999999999994e153Initial program 62.4%
lift-/.f64N/A
lift--.f64N/A
sub-flipN/A
div-addN/A
lift-*.f64N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f6463.0
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
Applied rewrites63.0%
lift-fma.f64N/A
lift-/.f64N/A
associate-*r/N/A
associate-*l/N/A
lift-/.f64N/A
*-commutativeN/A
add-flipN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
distribute-neg-frac2N/A
lift-*.f64N/A
lift-neg.f64N/A
distribute-lft-neg-outN/A
lift-*.f64N/A
frac-2negN/A
lift-*.f64N/A
*-commutativeN/A
Applied rewrites62.1%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6465.1
Applied rewrites65.1%
Taylor expanded in d around inf
lower-/.f64N/A
lower--.f64N/A
lower-/.f64N/A
*-commutativeN/A
lift-*.f6452.7
Applied rewrites52.7%
if -3.29999999999999994e153 < d < -6.2000000000000003e-10Initial program 62.4%
lift-/.f64N/A
lift--.f64N/A
sub-flipN/A
div-addN/A
lift-*.f64N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f6463.0
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
Applied rewrites63.0%
lift-fma.f64N/A
lift-/.f64N/A
associate-*r/N/A
associate-*l/N/A
lift-/.f64N/A
*-commutativeN/A
add-flipN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
distribute-neg-frac2N/A
lift-*.f64N/A
lift-neg.f64N/A
distribute-lft-neg-outN/A
lift-*.f64N/A
frac-2negN/A
lift-*.f64N/A
*-commutativeN/A
Applied rewrites62.1%
if -6.2000000000000003e-10 < d < 1.2499999999999999e-97 or 5.5000000000000002e123 < d < 4.00000000000000015e154Initial program 62.4%
lift-/.f64N/A
lift--.f64N/A
sub-flipN/A
div-addN/A
lift-*.f64N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f6463.0
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
Applied rewrites63.0%
lift-fma.f64N/A
lift-/.f64N/A
associate-*r/N/A
associate-*l/N/A
lift-/.f64N/A
*-commutativeN/A
add-flipN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
distribute-neg-frac2N/A
lift-*.f64N/A
lift-neg.f64N/A
distribute-lft-neg-outN/A
lift-*.f64N/A
frac-2negN/A
lift-*.f64N/A
*-commutativeN/A
Applied rewrites62.1%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6465.1
Applied rewrites65.1%
Taylor expanded in c around -inf
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6453.6
Applied rewrites53.6%
if 1.2499999999999999e-97 < d < 5.5000000000000002e123Initial program 62.4%
lift-/.f64N/A
lift--.f64N/A
sub-flipN/A
div-addN/A
lift-*.f64N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f6463.0
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
Applied rewrites63.0%
lift-fma.f64N/A
lift-/.f64N/A
associate-*r/N/A
associate-*l/N/A
lift-/.f64N/A
*-commutativeN/A
add-flipN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
distribute-neg-frac2N/A
lift-*.f64N/A
lift-neg.f64N/A
distribute-lft-neg-outN/A
lift-*.f64N/A
frac-2negN/A
lift-*.f64N/A
*-commutativeN/A
Applied rewrites62.1%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6465.1
Applied rewrites65.1%
if 4.00000000000000015e154 < d Initial program 62.4%
lift-/.f64N/A
lift--.f64N/A
sub-flipN/A
div-addN/A
lift-*.f64N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f6463.0
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
Applied rewrites63.0%
lift-fma.f64N/A
lift-/.f64N/A
associate-*r/N/A
associate-*l/N/A
lift-/.f64N/A
*-commutativeN/A
add-flipN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
distribute-neg-frac2N/A
lift-*.f64N/A
lift-neg.f64N/A
distribute-lft-neg-outN/A
lift-*.f64N/A
frac-2negN/A
lift-*.f64N/A
*-commutativeN/A
Applied rewrites62.1%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6465.1
Applied rewrites65.1%
Taylor expanded in c around 0
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6443.4
Applied rewrites43.4%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (fma d d (* c c)))
(t_1 (- (* b (/ c t_0)) (* a (/ d t_0))))
(t_2 (- (/ (fma a (/ d c) (- b)) c))))
(if (<= d -3.3e+153)
(/ (- (/ (* c b) d) a) d)
(if (<= d -6.2e-10)
t_1
(if (<= d 1.25e-97)
t_2
(if (<= d 5.5e+123) t_1 (if (<= d 4e+154) t_2 (/ (- a) d))))))))
double code(double a, double b, double c, double d) {
double t_0 = fma(d, d, (c * c));
double t_1 = (b * (c / t_0)) - (a * (d / t_0));
double t_2 = -(fma(a, (d / c), -b) / c);
double tmp;
if (d <= -3.3e+153) {
tmp = (((c * b) / d) - a) / d;
} else if (d <= -6.2e-10) {
tmp = t_1;
} else if (d <= 1.25e-97) {
tmp = t_2;
} else if (d <= 5.5e+123) {
tmp = t_1;
} else if (d <= 4e+154) {
tmp = t_2;
} else {
tmp = -a / d;
}
return tmp;
}
function code(a, b, c, d) t_0 = fma(d, d, Float64(c * c)) t_1 = Float64(Float64(b * Float64(c / t_0)) - Float64(a * Float64(d / t_0))) t_2 = Float64(-Float64(fma(a, Float64(d / c), Float64(-b)) / c)) tmp = 0.0 if (d <= -3.3e+153) tmp = Float64(Float64(Float64(Float64(c * b) / d) - a) / d); elseif (d <= -6.2e-10) tmp = t_1; elseif (d <= 1.25e-97) tmp = t_2; elseif (d <= 5.5e+123) tmp = t_1; elseif (d <= 4e+154) tmp = t_2; else tmp = Float64(Float64(-a) / d); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(b * N[(c / t$95$0), $MachinePrecision]), $MachinePrecision] - N[(a * N[(d / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = (-N[(N[(a * N[(d / c), $MachinePrecision] + (-b)), $MachinePrecision] / c), $MachinePrecision])}, If[LessEqual[d, -3.3e+153], N[(N[(N[(N[(c * b), $MachinePrecision] / d), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, -6.2e-10], t$95$1, If[LessEqual[d, 1.25e-97], t$95$2, If[LessEqual[d, 5.5e+123], t$95$1, If[LessEqual[d, 4e+154], t$95$2, N[((-a) / d), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(d, d, c \cdot c\right)\\
t_1 := b \cdot \frac{c}{t\_0} - a \cdot \frac{d}{t\_0}\\
t_2 := -\frac{\mathsf{fma}\left(a, \frac{d}{c}, -b\right)}{c}\\
\mathbf{if}\;d \leq -3.3 \cdot 10^{+153}:\\
\;\;\;\;\frac{\frac{c \cdot b}{d} - a}{d}\\
\mathbf{elif}\;d \leq -6.2 \cdot 10^{-10}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d \leq 1.25 \cdot 10^{-97}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;d \leq 5.5 \cdot 10^{+123}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d \leq 4 \cdot 10^{+154}:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;\frac{-a}{d}\\
\end{array}
\end{array}
if d < -3.29999999999999994e153Initial program 62.4%
lift-/.f64N/A
lift--.f64N/A
sub-flipN/A
div-addN/A
lift-*.f64N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f6463.0
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
Applied rewrites63.0%
lift-fma.f64N/A
lift-/.f64N/A
associate-*r/N/A
associate-*l/N/A
lift-/.f64N/A
*-commutativeN/A
add-flipN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
distribute-neg-frac2N/A
lift-*.f64N/A
lift-neg.f64N/A
distribute-lft-neg-outN/A
lift-*.f64N/A
frac-2negN/A
lift-*.f64N/A
*-commutativeN/A
Applied rewrites62.1%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6465.1
Applied rewrites65.1%
Taylor expanded in d around inf
lower-/.f64N/A
lower--.f64N/A
lower-/.f64N/A
*-commutativeN/A
lift-*.f6452.7
Applied rewrites52.7%
if -3.29999999999999994e153 < d < -6.2000000000000003e-10 or 1.2499999999999999e-97 < d < 5.5000000000000002e123Initial program 62.4%
lift-/.f64N/A
lift--.f64N/A
sub-flipN/A
div-addN/A
lift-*.f64N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f6463.0
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
Applied rewrites63.0%
lift-fma.f64N/A
lift-/.f64N/A
associate-*r/N/A
associate-*l/N/A
lift-/.f64N/A
*-commutativeN/A
add-flipN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
distribute-neg-frac2N/A
lift-*.f64N/A
lift-neg.f64N/A
distribute-lft-neg-outN/A
lift-*.f64N/A
frac-2negN/A
lift-*.f64N/A
*-commutativeN/A
Applied rewrites62.1%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6465.1
Applied rewrites65.1%
if -6.2000000000000003e-10 < d < 1.2499999999999999e-97 or 5.5000000000000002e123 < d < 4.00000000000000015e154Initial program 62.4%
lift-/.f64N/A
lift--.f64N/A
sub-flipN/A
div-addN/A
lift-*.f64N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f6463.0
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
Applied rewrites63.0%
lift-fma.f64N/A
lift-/.f64N/A
associate-*r/N/A
associate-*l/N/A
lift-/.f64N/A
*-commutativeN/A
add-flipN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
distribute-neg-frac2N/A
lift-*.f64N/A
lift-neg.f64N/A
distribute-lft-neg-outN/A
lift-*.f64N/A
frac-2negN/A
lift-*.f64N/A
*-commutativeN/A
Applied rewrites62.1%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6465.1
Applied rewrites65.1%
Taylor expanded in c around -inf
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6453.6
Applied rewrites53.6%
if 4.00000000000000015e154 < d Initial program 62.4%
lift-/.f64N/A
lift--.f64N/A
sub-flipN/A
div-addN/A
lift-*.f64N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f6463.0
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
Applied rewrites63.0%
lift-fma.f64N/A
lift-/.f64N/A
associate-*r/N/A
associate-*l/N/A
lift-/.f64N/A
*-commutativeN/A
add-flipN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
distribute-neg-frac2N/A
lift-*.f64N/A
lift-neg.f64N/A
distribute-lft-neg-outN/A
lift-*.f64N/A
frac-2negN/A
lift-*.f64N/A
*-commutativeN/A
Applied rewrites62.1%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6465.1
Applied rewrites65.1%
Taylor expanded in c around 0
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6443.4
Applied rewrites43.4%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* c b) (* d a)) (fma d d (* c c)))))
(if (<= d -7e+85)
(/ (- (/ (* c b) d) a) d)
(if (<= d -6.2e-10)
t_0
(if (<= d 1.55e-111)
(- (/ (fma a (/ d c) (- b)) c))
(if (<= d 6.5e+65) t_0 (- (* b (/ c (* d d))) (/ a d))))))))
double code(double a, double b, double c, double d) {
double t_0 = ((c * b) - (d * a)) / fma(d, d, (c * c));
double tmp;
if (d <= -7e+85) {
tmp = (((c * b) / d) - a) / d;
} else if (d <= -6.2e-10) {
tmp = t_0;
} else if (d <= 1.55e-111) {
tmp = -(fma(a, (d / c), -b) / c);
} else if (d <= 6.5e+65) {
tmp = t_0;
} else {
tmp = (b * (c / (d * d))) - (a / d);
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(Float64(c * b) - Float64(d * a)) / fma(d, d, Float64(c * c))) tmp = 0.0 if (d <= -7e+85) tmp = Float64(Float64(Float64(Float64(c * b) / d) - a) / d); elseif (d <= -6.2e-10) tmp = t_0; elseif (d <= 1.55e-111) tmp = Float64(-Float64(fma(a, Float64(d / c), Float64(-b)) / c)); elseif (d <= 6.5e+65) tmp = t_0; else tmp = Float64(Float64(b * Float64(c / Float64(d * d))) - Float64(a / d)); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -7e+85], N[(N[(N[(N[(c * b), $MachinePrecision] / d), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, -6.2e-10], t$95$0, If[LessEqual[d, 1.55e-111], (-N[(N[(a * N[(d / c), $MachinePrecision] + (-b)), $MachinePrecision] / c), $MachinePrecision]), If[LessEqual[d, 6.5e+65], t$95$0, N[(N[(b * N[(c / N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c \cdot b - d \cdot a}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\
\mathbf{if}\;d \leq -7 \cdot 10^{+85}:\\
\;\;\;\;\frac{\frac{c \cdot b}{d} - a}{d}\\
\mathbf{elif}\;d \leq -6.2 \cdot 10^{-10}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 1.55 \cdot 10^{-111}:\\
\;\;\;\;-\frac{\mathsf{fma}\left(a, \frac{d}{c}, -b\right)}{c}\\
\mathbf{elif}\;d \leq 6.5 \cdot 10^{+65}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;b \cdot \frac{c}{d \cdot d} - \frac{a}{d}\\
\end{array}
\end{array}
if d < -7.0000000000000001e85Initial program 62.4%
lift-/.f64N/A
lift--.f64N/A
sub-flipN/A
div-addN/A
lift-*.f64N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f6463.0
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
Applied rewrites63.0%
lift-fma.f64N/A
lift-/.f64N/A
associate-*r/N/A
associate-*l/N/A
lift-/.f64N/A
*-commutativeN/A
add-flipN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
distribute-neg-frac2N/A
lift-*.f64N/A
lift-neg.f64N/A
distribute-lft-neg-outN/A
lift-*.f64N/A
frac-2negN/A
lift-*.f64N/A
*-commutativeN/A
Applied rewrites62.1%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6465.1
Applied rewrites65.1%
Taylor expanded in d around inf
lower-/.f64N/A
lower--.f64N/A
lower-/.f64N/A
*-commutativeN/A
lift-*.f6452.7
Applied rewrites52.7%
if -7.0000000000000001e85 < d < -6.2000000000000003e-10 or 1.55000000000000007e-111 < d < 6.5000000000000003e65Initial program 62.4%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6462.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6462.4
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6462.4
Applied rewrites62.4%
if -6.2000000000000003e-10 < d < 1.55000000000000007e-111Initial program 62.4%
lift-/.f64N/A
lift--.f64N/A
sub-flipN/A
div-addN/A
lift-*.f64N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f6463.0
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
Applied rewrites63.0%
lift-fma.f64N/A
lift-/.f64N/A
associate-*r/N/A
associate-*l/N/A
lift-/.f64N/A
*-commutativeN/A
add-flipN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
distribute-neg-frac2N/A
lift-*.f64N/A
lift-neg.f64N/A
distribute-lft-neg-outN/A
lift-*.f64N/A
frac-2negN/A
lift-*.f64N/A
*-commutativeN/A
Applied rewrites62.1%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6465.1
Applied rewrites65.1%
Taylor expanded in c around -inf
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6453.6
Applied rewrites53.6%
if 6.5000000000000003e65 < d Initial program 62.4%
lift-/.f64N/A
lift--.f64N/A
sub-flipN/A
div-addN/A
lift-*.f64N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f6463.0
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
Applied rewrites63.0%
lift-fma.f64N/A
lift-/.f64N/A
associate-*r/N/A
associate-*l/N/A
lift-/.f64N/A
*-commutativeN/A
add-flipN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
distribute-neg-frac2N/A
lift-*.f64N/A
lift-neg.f64N/A
distribute-lft-neg-outN/A
lift-*.f64N/A
frac-2negN/A
lift-*.f64N/A
*-commutativeN/A
Applied rewrites62.1%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6465.1
Applied rewrites65.1%
Taylor expanded in c around 0
lower--.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f64N/A
lower-/.f6449.2
Applied rewrites49.2%
(FPCore (a b c d) :precision binary64 (let* ((t_0 (- (/ (fma a (/ d c) (- b)) c)))) (if (<= c -9.6e-23) t_0 (if (<= c 8.5e+26) (/ (- (/ (* c b) d) a) d) t_0))))
double code(double a, double b, double c, double d) {
double t_0 = -(fma(a, (d / c), -b) / c);
double tmp;
if (c <= -9.6e-23) {
tmp = t_0;
} else if (c <= 8.5e+26) {
tmp = (((c * b) / d) - a) / d;
} else {
tmp = t_0;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(-Float64(fma(a, Float64(d / c), Float64(-b)) / c)) tmp = 0.0 if (c <= -9.6e-23) tmp = t_0; elseif (c <= 8.5e+26) tmp = Float64(Float64(Float64(Float64(c * b) / d) - a) / d); else tmp = t_0; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = (-N[(N[(a * N[(d / c), $MachinePrecision] + (-b)), $MachinePrecision] / c), $MachinePrecision])}, If[LessEqual[c, -9.6e-23], t$95$0, If[LessEqual[c, 8.5e+26], N[(N[(N[(N[(c * b), $MachinePrecision] / d), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -\frac{\mathsf{fma}\left(a, \frac{d}{c}, -b\right)}{c}\\
\mathbf{if}\;c \leq -9.6 \cdot 10^{-23}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq 8.5 \cdot 10^{+26}:\\
\;\;\;\;\frac{\frac{c \cdot b}{d} - a}{d}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if c < -9.59999999999999986e-23 or 8.5e26 < c Initial program 62.4%
lift-/.f64N/A
lift--.f64N/A
sub-flipN/A
div-addN/A
lift-*.f64N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f6463.0
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
Applied rewrites63.0%
lift-fma.f64N/A
lift-/.f64N/A
associate-*r/N/A
associate-*l/N/A
lift-/.f64N/A
*-commutativeN/A
add-flipN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
distribute-neg-frac2N/A
lift-*.f64N/A
lift-neg.f64N/A
distribute-lft-neg-outN/A
lift-*.f64N/A
frac-2negN/A
lift-*.f64N/A
*-commutativeN/A
Applied rewrites62.1%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6465.1
Applied rewrites65.1%
Taylor expanded in c around -inf
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6453.6
Applied rewrites53.6%
if -9.59999999999999986e-23 < c < 8.5e26Initial program 62.4%
lift-/.f64N/A
lift--.f64N/A
sub-flipN/A
div-addN/A
lift-*.f64N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f6463.0
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
Applied rewrites63.0%
lift-fma.f64N/A
lift-/.f64N/A
associate-*r/N/A
associate-*l/N/A
lift-/.f64N/A
*-commutativeN/A
add-flipN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
distribute-neg-frac2N/A
lift-*.f64N/A
lift-neg.f64N/A
distribute-lft-neg-outN/A
lift-*.f64N/A
frac-2negN/A
lift-*.f64N/A
*-commutativeN/A
Applied rewrites62.1%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6465.1
Applied rewrites65.1%
Taylor expanded in d around inf
lower-/.f64N/A
lower--.f64N/A
lower-/.f64N/A
*-commutativeN/A
lift-*.f6452.7
Applied rewrites52.7%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (/ (* c b) d) a) d)))
(if (<= d -0.021)
t_0
(if (<= d 1.05e+48) (/ (+ (/ (* (- a) d) c) b) c) t_0))))
double code(double a, double b, double c, double d) {
double t_0 = (((c * b) / d) - a) / d;
double tmp;
if (d <= -0.021) {
tmp = t_0;
} else if (d <= 1.05e+48) {
tmp = (((-a * d) / c) + b) / c;
} 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(a, b, c, d)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: tmp
t_0 = (((c * b) / d) - a) / d
if (d <= (-0.021d0)) then
tmp = t_0
else if (d <= 1.05d+48) then
tmp = (((-a * d) / c) + b) / c
else
tmp = t_0
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = (((c * b) / d) - a) / d;
double tmp;
if (d <= -0.021) {
tmp = t_0;
} else if (d <= 1.05e+48) {
tmp = (((-a * d) / c) + b) / c;
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b, c, d): t_0 = (((c * b) / d) - a) / d tmp = 0 if d <= -0.021: tmp = t_0 elif d <= 1.05e+48: tmp = (((-a * d) / c) + b) / c else: tmp = t_0 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(Float64(Float64(c * b) / d) - a) / d) tmp = 0.0 if (d <= -0.021) tmp = t_0; elseif (d <= 1.05e+48) tmp = Float64(Float64(Float64(Float64(Float64(-a) * d) / c) + b) / c); else tmp = t_0; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (((c * b) / d) - a) / d; tmp = 0.0; if (d <= -0.021) tmp = t_0; elseif (d <= 1.05e+48) tmp = (((-a * d) / c) + b) / c; else tmp = t_0; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(N[(c * b), $MachinePrecision] / d), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -0.021], t$95$0, If[LessEqual[d, 1.05e+48], N[(N[(N[(N[((-a) * d), $MachinePrecision] / c), $MachinePrecision] + b), $MachinePrecision] / c), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\frac{c \cdot b}{d} - a}{d}\\
\mathbf{if}\;d \leq -0.021:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 1.05 \cdot 10^{+48}:\\
\;\;\;\;\frac{\frac{\left(-a\right) \cdot d}{c} + b}{c}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d < -0.0210000000000000013 or 1.0499999999999999e48 < d Initial program 62.4%
lift-/.f64N/A
lift--.f64N/A
sub-flipN/A
div-addN/A
lift-*.f64N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f6463.0
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
Applied rewrites63.0%
lift-fma.f64N/A
lift-/.f64N/A
associate-*r/N/A
associate-*l/N/A
lift-/.f64N/A
*-commutativeN/A
add-flipN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
distribute-neg-frac2N/A
lift-*.f64N/A
lift-neg.f64N/A
distribute-lft-neg-outN/A
lift-*.f64N/A
frac-2negN/A
lift-*.f64N/A
*-commutativeN/A
Applied rewrites62.1%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6465.1
Applied rewrites65.1%
Taylor expanded in d around inf
lower-/.f64N/A
lower--.f64N/A
lower-/.f64N/A
*-commutativeN/A
lift-*.f6452.7
Applied rewrites52.7%
if -0.0210000000000000013 < d < 1.0499999999999999e48Initial program 62.4%
lift-/.f64N/A
lift--.f64N/A
sub-flipN/A
div-addN/A
lift-*.f64N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f6463.0
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
Applied rewrites63.0%
lift-fma.f64N/A
lift-/.f64N/A
associate-*r/N/A
associate-*l/N/A
lift-/.f64N/A
*-commutativeN/A
add-flipN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
distribute-neg-frac2N/A
lift-*.f64N/A
lift-neg.f64N/A
distribute-lft-neg-outN/A
lift-*.f64N/A
frac-2negN/A
lift-*.f64N/A
*-commutativeN/A
Applied rewrites62.1%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6465.1
Applied rewrites65.1%
Taylor expanded in c around inf
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
associate-*r/N/A
lower-/.f64N/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6451.7
Applied rewrites51.7%
(FPCore (a b c d) :precision binary64 (if (<= c -14500000000.0) (/ b c) (if (<= c 1e+29) (/ (- (/ (* c b) d) a) d) (/ b c))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -14500000000.0) {
tmp = b / c;
} else if (c <= 1e+29) {
tmp = (((c * b) / d) - a) / d;
} else {
tmp = b / c;
}
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(a, b, c, d)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (c <= (-14500000000.0d0)) then
tmp = b / c
else if (c <= 1d+29) then
tmp = (((c * b) / d) - a) / d
else
tmp = b / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -14500000000.0) {
tmp = b / c;
} else if (c <= 1e+29) {
tmp = (((c * b) / d) - a) / d;
} else {
tmp = b / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -14500000000.0: tmp = b / c elif c <= 1e+29: tmp = (((c * b) / d) - a) / d else: tmp = b / c return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -14500000000.0) tmp = Float64(b / c); elseif (c <= 1e+29) tmp = Float64(Float64(Float64(Float64(c * b) / d) - a) / d); else tmp = Float64(b / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -14500000000.0) tmp = b / c; elseif (c <= 1e+29) tmp = (((c * b) / d) - a) / d; else tmp = b / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -14500000000.0], N[(b / c), $MachinePrecision], If[LessEqual[c, 1e+29], N[(N[(N[(N[(c * b), $MachinePrecision] / d), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], N[(b / c), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -14500000000:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{elif}\;c \leq 10^{+29}:\\
\;\;\;\;\frac{\frac{c \cdot b}{d} - a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if c < -1.45e10 or 9.99999999999999914e28 < c Initial program 62.4%
lift-/.f64N/A
lift--.f64N/A
sub-flipN/A
div-addN/A
lift-*.f64N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f6463.0
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
Applied rewrites63.0%
lift-fma.f64N/A
lift-/.f64N/A
associate-*r/N/A
associate-*l/N/A
lift-/.f64N/A
*-commutativeN/A
add-flipN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
distribute-neg-frac2N/A
lift-*.f64N/A
lift-neg.f64N/A
distribute-lft-neg-outN/A
lift-*.f64N/A
frac-2negN/A
lift-*.f64N/A
*-commutativeN/A
Applied rewrites62.1%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6465.1
Applied rewrites65.1%
Taylor expanded in c around inf
lower-/.f6442.1
Applied rewrites42.1%
if -1.45e10 < c < 9.99999999999999914e28Initial program 62.4%
lift-/.f64N/A
lift--.f64N/A
sub-flipN/A
div-addN/A
lift-*.f64N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f6463.0
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
Applied rewrites63.0%
lift-fma.f64N/A
lift-/.f64N/A
associate-*r/N/A
associate-*l/N/A
lift-/.f64N/A
*-commutativeN/A
add-flipN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
distribute-neg-frac2N/A
lift-*.f64N/A
lift-neg.f64N/A
distribute-lft-neg-outN/A
lift-*.f64N/A
frac-2negN/A
lift-*.f64N/A
*-commutativeN/A
Applied rewrites62.1%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6465.1
Applied rewrites65.1%
Taylor expanded in d around inf
lower-/.f64N/A
lower--.f64N/A
lower-/.f64N/A
*-commutativeN/A
lift-*.f6452.7
Applied rewrites52.7%
(FPCore (a b c d) :precision binary64 (if (<= c -360000.0) (/ b c) (if (<= c 7.8e+27) (/ (- a) d) (/ b c))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -360000.0) {
tmp = b / c;
} else if (c <= 7.8e+27) {
tmp = -a / d;
} else {
tmp = b / c;
}
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(a, b, c, d)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (c <= (-360000.0d0)) then
tmp = b / c
else if (c <= 7.8d+27) then
tmp = -a / d
else
tmp = b / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -360000.0) {
tmp = b / c;
} else if (c <= 7.8e+27) {
tmp = -a / d;
} else {
tmp = b / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -360000.0: tmp = b / c elif c <= 7.8e+27: tmp = -a / d else: tmp = b / c return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -360000.0) tmp = Float64(b / c); elseif (c <= 7.8e+27) tmp = Float64(Float64(-a) / d); else tmp = Float64(b / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -360000.0) tmp = b / c; elseif (c <= 7.8e+27) tmp = -a / d; else tmp = b / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -360000.0], N[(b / c), $MachinePrecision], If[LessEqual[c, 7.8e+27], N[((-a) / d), $MachinePrecision], N[(b / c), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -360000:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{elif}\;c \leq 7.8 \cdot 10^{+27}:\\
\;\;\;\;\frac{-a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if c < -3.6e5 or 7.7999999999999997e27 < c Initial program 62.4%
lift-/.f64N/A
lift--.f64N/A
sub-flipN/A
div-addN/A
lift-*.f64N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f6463.0
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
Applied rewrites63.0%
lift-fma.f64N/A
lift-/.f64N/A
associate-*r/N/A
associate-*l/N/A
lift-/.f64N/A
*-commutativeN/A
add-flipN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
distribute-neg-frac2N/A
lift-*.f64N/A
lift-neg.f64N/A
distribute-lft-neg-outN/A
lift-*.f64N/A
frac-2negN/A
lift-*.f64N/A
*-commutativeN/A
Applied rewrites62.1%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6465.1
Applied rewrites65.1%
Taylor expanded in c around inf
lower-/.f6442.1
Applied rewrites42.1%
if -3.6e5 < c < 7.7999999999999997e27Initial program 62.4%
lift-/.f64N/A
lift--.f64N/A
sub-flipN/A
div-addN/A
lift-*.f64N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f6463.0
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
Applied rewrites63.0%
lift-fma.f64N/A
lift-/.f64N/A
associate-*r/N/A
associate-*l/N/A
lift-/.f64N/A
*-commutativeN/A
add-flipN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
distribute-neg-frac2N/A
lift-*.f64N/A
lift-neg.f64N/A
distribute-lft-neg-outN/A
lift-*.f64N/A
frac-2negN/A
lift-*.f64N/A
*-commutativeN/A
Applied rewrites62.1%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6465.1
Applied rewrites65.1%
Taylor expanded in c around 0
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6443.4
Applied rewrites43.4%
(FPCore (a b c d) :precision binary64 (/ b c))
double code(double a, double b, double c, double d) {
return b / c;
}
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(a, b, c, d)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = b / c
end function
public static double code(double a, double b, double c, double d) {
return b / c;
}
def code(a, b, c, d): return b / c
function code(a, b, c, d) return Float64(b / c) end
function tmp = code(a, b, c, d) tmp = b / c; end
code[a_, b_, c_, d_] := N[(b / c), $MachinePrecision]
\begin{array}{l}
\\
\frac{b}{c}
\end{array}
Initial program 62.4%
lift-/.f64N/A
lift--.f64N/A
sub-flipN/A
div-addN/A
lift-*.f64N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f6463.0
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
Applied rewrites63.0%
lift-fma.f64N/A
lift-/.f64N/A
associate-*r/N/A
associate-*l/N/A
lift-/.f64N/A
*-commutativeN/A
add-flipN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
distribute-neg-frac2N/A
lift-*.f64N/A
lift-neg.f64N/A
distribute-lft-neg-outN/A
lift-*.f64N/A
frac-2negN/A
lift-*.f64N/A
*-commutativeN/A
Applied rewrites62.1%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6465.1
Applied rewrites65.1%
Taylor expanded in c around inf
lower-/.f6442.1
Applied rewrites42.1%
(FPCore (a b c d) :precision binary64 (if (< (fabs d) (fabs c)) (/ (- b (* a (/ d c))) (+ c (* d (/ d c)))) (/ (+ (- a) (* b (/ c d))) (+ d (* c (/ c d))))))
double code(double a, double b, double c, double d) {
double tmp;
if (fabs(d) < fabs(c)) {
tmp = (b - (a * (d / c))) / (c + (d * (d / c)));
} else {
tmp = (-a + (b * (c / d))) / (d + (c * (c / d)));
}
return tmp;
}
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(a, b, c, d)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (abs(d) < abs(c)) then
tmp = (b - (a * (d / c))) / (c + (d * (d / c)))
else
tmp = (-a + (b * (c / d))) / (d + (c * (c / d)))
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (Math.abs(d) < Math.abs(c)) {
tmp = (b - (a * (d / c))) / (c + (d * (d / c)));
} else {
tmp = (-a + (b * (c / d))) / (d + (c * (c / d)));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if math.fabs(d) < math.fabs(c): tmp = (b - (a * (d / c))) / (c + (d * (d / c))) else: tmp = (-a + (b * (c / d))) / (d + (c * (c / d))) return tmp
function code(a, b, c, d) tmp = 0.0 if (abs(d) < abs(c)) tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / Float64(c + Float64(d * Float64(d / c)))); else tmp = Float64(Float64(Float64(-a) + Float64(b * Float64(c / d))) / Float64(d + Float64(c * Float64(c / d)))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (abs(d) < abs(c)) tmp = (b - (a * (d / c))) / (c + (d * (d / c))); else tmp = (-a + (b * (c / d))) / (d + (c * (c / d))); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Less[N[Abs[d], $MachinePrecision], N[Abs[c], $MachinePrecision]], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(c + N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[((-a) + N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(d + N[(c * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left|d\right| < \left|c\right|:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c + d \cdot \frac{d}{c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-a\right) + b \cdot \frac{c}{d}}{d + c \cdot \frac{c}{d}}\\
\end{array}
\end{array}
herbie shell --seed 2025136
(FPCore (a b c d)
:name "Complex division, imag part"
:precision binary64
:alt
(! :herbie-platform c (if (< (fabs d) (fabs c)) (/ (- b (* a (/ d c))) (+ c (* d (/ d c)))) (/ (+ (- a) (* b (/ c d))) (+ d (* c (/ c d))))))
(/ (- (* b c) (* a d)) (+ (* c c) (* d d))))