
(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 13 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 (fma c c (* d d)))
(t_2 (/ (- b (* (/ a c) d)) c)))
(if (<= c -2.7e+84)
t_2
(if (<= c -7.2e-99)
(fma (/ (- d) t_0) a (* (/ b t_0) c))
(if (<= c 5.2e-155)
(/ (fma (/ c d) b (- a)) d)
(if (<= c 4.5e+83) (- (* (/ c t_1) b) (* (/ d t_1) a)) t_2))))))
double code(double a, double b, double c, double d) {
double t_0 = fma(d, d, (c * c));
double t_1 = fma(c, c, (d * d));
double t_2 = (b - ((a / c) * d)) / c;
double tmp;
if (c <= -2.7e+84) {
tmp = t_2;
} else if (c <= -7.2e-99) {
tmp = fma((-d / t_0), a, ((b / t_0) * c));
} else if (c <= 5.2e-155) {
tmp = fma((c / d), b, -a) / d;
} else if (c <= 4.5e+83) {
tmp = ((c / t_1) * b) - ((d / t_1) * a);
} else {
tmp = t_2;
}
return tmp;
}
function code(a, b, c, d) t_0 = fma(d, d, Float64(c * c)) t_1 = fma(c, c, Float64(d * d)) t_2 = Float64(Float64(b - Float64(Float64(a / c) * d)) / c) tmp = 0.0 if (c <= -2.7e+84) tmp = t_2; elseif (c <= -7.2e-99) tmp = fma(Float64(Float64(-d) / t_0), a, Float64(Float64(b / t_0) * c)); elseif (c <= 5.2e-155) tmp = Float64(fma(Float64(c / d), b, Float64(-a)) / d); elseif (c <= 4.5e+83) tmp = Float64(Float64(Float64(c / t_1) * b) - Float64(Float64(d / t_1) * a)); else tmp = t_2; 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[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(b - N[(N[(a / c), $MachinePrecision] * d), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]}, If[LessEqual[c, -2.7e+84], t$95$2, If[LessEqual[c, -7.2e-99], N[(N[((-d) / t$95$0), $MachinePrecision] * a + N[(N[(b / t$95$0), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 5.2e-155], N[(N[(N[(c / d), $MachinePrecision] * b + (-a)), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 4.5e+83], N[(N[(N[(c / t$95$1), $MachinePrecision] * b), $MachinePrecision] - N[(N[(d / t$95$1), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision], t$95$2]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(d, d, c \cdot c\right)\\
t_1 := \mathsf{fma}\left(c, c, d \cdot d\right)\\
t_2 := \frac{b - \frac{a}{c} \cdot d}{c}\\
\mathbf{if}\;c \leq -2.7 \cdot 10^{+84}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;c \leq -7.2 \cdot 10^{-99}:\\
\;\;\;\;\mathsf{fma}\left(\frac{-d}{t\_0}, a, \frac{b}{t\_0} \cdot c\right)\\
\mathbf{elif}\;c \leq 5.2 \cdot 10^{-155}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{c}{d}, b, -a\right)}{d}\\
\mathbf{elif}\;c \leq 4.5 \cdot 10^{+83}:\\
\;\;\;\;\frac{c}{t\_1} \cdot b - \frac{d}{t\_1} \cdot a\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if c < -2.7e84 or 4.4999999999999999e83 < c Initial program 61.2%
Taylor expanded in c around inf
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6451.8
Applied rewrites51.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-/.f6451.8
Applied rewrites51.8%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6453.0
Applied rewrites53.0%
if -2.7e84 < c < -7.2000000000000001e-99Initial program 61.2%
lift-/.f64N/A
frac-2negN/A
lift--.f64N/A
sub-negate-revN/A
sub-flipN/A
div-addN/A
frac-2negN/A
distribute-neg-frac2N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
distribute-lft-neg-inN/A
distribute-neg-frac2N/A
lower-fma.f64N/A
Applied rewrites61.2%
if -7.2000000000000001e-99 < c < 5.20000000000000016e-155Initial program 61.2%
Taylor expanded in d around inf
lower-/.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f6452.6
Applied rewrites52.6%
lift-fma.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
metadata-evalN/A
distribute-lft-neg-outN/A
metadata-evalN/A
distribute-lft-neg-outN/A
lower-neg.f64N/A
distribute-lft-neg-outN/A
metadata-evalN/A
*-lft-identity54.5
Applied rewrites54.5%
if 5.20000000000000016e-155 < c < 4.4999999999999999e83Initial program 61.2%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6461.0
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
sqr-abs-revN/A
sqr-neg-revN/A
fp-cancel-sign-sub-invN/A
fp-cancel-sub-sign-invN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
distribute-lft-neg-inN/A
sqr-neg-revN/A
sqr-abs-revN/A
lift-*.f64N/A
remove-double-negN/A
lower-fma.f6461.0
Applied rewrites61.0%
lift-/.f64N/A
lift-/.f64N/A
associate-/r/N/A
lift-fma.f64N/A
lift-*.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-fma.f64N/A
lift--.f64N/A
sub-flipN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
distribute-rgt-inN/A
mult-flipN/A
fp-cancel-sub-sign-invN/A
Applied rewrites64.4%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (fma c c (* d d)))
(t_1 (- (* (/ c t_0) b) (* (/ d t_0) a)))
(t_2 (/ (- b (* (/ a c) d)) c)))
(if (<= c -1.3e+87)
t_2
(if (<= c -7.2e-99)
t_1
(if (<= c 5.2e-155)
(/ (fma (/ c d) b (- a)) d)
(if (<= c 4.5e+83) t_1 t_2))))))
double code(double a, double b, double c, double d) {
double t_0 = fma(c, c, (d * d));
double t_1 = ((c / t_0) * b) - ((d / t_0) * a);
double t_2 = (b - ((a / c) * d)) / c;
double tmp;
if (c <= -1.3e+87) {
tmp = t_2;
} else if (c <= -7.2e-99) {
tmp = t_1;
} else if (c <= 5.2e-155) {
tmp = fma((c / d), b, -a) / d;
} else if (c <= 4.5e+83) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
function code(a, b, c, d) t_0 = fma(c, c, Float64(d * d)) t_1 = Float64(Float64(Float64(c / t_0) * b) - Float64(Float64(d / t_0) * a)) t_2 = Float64(Float64(b - Float64(Float64(a / c) * d)) / c) tmp = 0.0 if (c <= -1.3e+87) tmp = t_2; elseif (c <= -7.2e-99) tmp = t_1; elseif (c <= 5.2e-155) tmp = Float64(fma(Float64(c / d), b, Float64(-a)) / d); elseif (c <= 4.5e+83) tmp = t_1; else tmp = t_2; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(c / t$95$0), $MachinePrecision] * b), $MachinePrecision] - N[(N[(d / t$95$0), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(b - N[(N[(a / c), $MachinePrecision] * d), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]}, If[LessEqual[c, -1.3e+87], t$95$2, If[LessEqual[c, -7.2e-99], t$95$1, If[LessEqual[c, 5.2e-155], N[(N[(N[(c / d), $MachinePrecision] * b + (-a)), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 4.5e+83], t$95$1, t$95$2]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(c, c, d \cdot d\right)\\
t_1 := \frac{c}{t\_0} \cdot b - \frac{d}{t\_0} \cdot a\\
t_2 := \frac{b - \frac{a}{c} \cdot d}{c}\\
\mathbf{if}\;c \leq -1.3 \cdot 10^{+87}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;c \leq -7.2 \cdot 10^{-99}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;c \leq 5.2 \cdot 10^{-155}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{c}{d}, b, -a\right)}{d}\\
\mathbf{elif}\;c \leq 4.5 \cdot 10^{+83}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if c < -1.29999999999999999e87 or 4.4999999999999999e83 < c Initial program 61.2%
Taylor expanded in c around inf
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6451.8
Applied rewrites51.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-/.f6451.8
Applied rewrites51.8%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6453.0
Applied rewrites53.0%
if -1.29999999999999999e87 < c < -7.2000000000000001e-99 or 5.20000000000000016e-155 < c < 4.4999999999999999e83Initial program 61.2%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6461.0
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
sqr-abs-revN/A
sqr-neg-revN/A
fp-cancel-sign-sub-invN/A
fp-cancel-sub-sign-invN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
distribute-lft-neg-inN/A
sqr-neg-revN/A
sqr-abs-revN/A
lift-*.f64N/A
remove-double-negN/A
lower-fma.f6461.0
Applied rewrites61.0%
lift-/.f64N/A
lift-/.f64N/A
associate-/r/N/A
lift-fma.f64N/A
lift-*.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-fma.f64N/A
lift--.f64N/A
sub-flipN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
distribute-rgt-inN/A
mult-flipN/A
fp-cancel-sub-sign-invN/A
Applied rewrites64.4%
if -7.2000000000000001e-99 < c < 5.20000000000000016e-155Initial program 61.2%
Taylor expanded in d around inf
lower-/.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f6452.6
Applied rewrites52.6%
lift-fma.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
metadata-evalN/A
distribute-lft-neg-outN/A
metadata-evalN/A
distribute-lft-neg-outN/A
lower-neg.f64N/A
distribute-lft-neg-outN/A
metadata-evalN/A
*-lft-identity54.5
Applied rewrites54.5%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (fma d d (* c c))) (t_1 (/ a (- d))))
(if (<= d -1.15e+111)
(fma (/ c d) (/ 1.0 (/ d b)) t_1)
(if (<= d -2.3e-151)
(/ (- (* b c) (* a d)) (fma c c (* d d)))
(if (<= d 2.15e-29)
(/ (- b (/ (* a d) c)) c)
(if (<= d 2.35e+101)
(- (* (/ b t_0) c) (* (/ a t_0) d))
(fma (/ c d) (/ b d) t_1)))))))
double code(double a, double b, double c, double d) {
double t_0 = fma(d, d, (c * c));
double t_1 = a / -d;
double tmp;
if (d <= -1.15e+111) {
tmp = fma((c / d), (1.0 / (d / b)), t_1);
} else if (d <= -2.3e-151) {
tmp = ((b * c) - (a * d)) / fma(c, c, (d * d));
} else if (d <= 2.15e-29) {
tmp = (b - ((a * d) / c)) / c;
} else if (d <= 2.35e+101) {
tmp = ((b / t_0) * c) - ((a / t_0) * d);
} else {
tmp = fma((c / d), (b / d), t_1);
}
return tmp;
}
function code(a, b, c, d) t_0 = fma(d, d, Float64(c * c)) t_1 = Float64(a / Float64(-d)) tmp = 0.0 if (d <= -1.15e+111) tmp = fma(Float64(c / d), Float64(1.0 / Float64(d / b)), t_1); elseif (d <= -2.3e-151) tmp = Float64(Float64(Float64(b * c) - Float64(a * d)) / fma(c, c, Float64(d * d))); elseif (d <= 2.15e-29) tmp = Float64(Float64(b - Float64(Float64(a * d) / c)) / c); elseif (d <= 2.35e+101) tmp = Float64(Float64(Float64(b / t_0) * c) - Float64(Float64(a / t_0) * d)); else tmp = fma(Float64(c / d), Float64(b / d), t_1); 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 / (-d)), $MachinePrecision]}, If[LessEqual[d, -1.15e+111], N[(N[(c / d), $MachinePrecision] * N[(1.0 / N[(d / b), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision], If[LessEqual[d, -2.3e-151], N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.15e-29], N[(N[(b - N[(N[(a * d), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 2.35e+101], N[(N[(N[(b / t$95$0), $MachinePrecision] * c), $MachinePrecision] - N[(N[(a / t$95$0), $MachinePrecision] * d), $MachinePrecision]), $MachinePrecision], N[(N[(c / d), $MachinePrecision] * N[(b / d), $MachinePrecision] + t$95$1), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(d, d, c \cdot c\right)\\
t_1 := \frac{a}{-d}\\
\mathbf{if}\;d \leq -1.15 \cdot 10^{+111}:\\
\;\;\;\;\mathsf{fma}\left(\frac{c}{d}, \frac{1}{\frac{d}{b}}, t\_1\right)\\
\mathbf{elif}\;d \leq -2.3 \cdot 10^{-151}:\\
\;\;\;\;\frac{b \cdot c - a \cdot d}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\
\mathbf{elif}\;d \leq 2.15 \cdot 10^{-29}:\\
\;\;\;\;\frac{b - \frac{a \cdot d}{c}}{c}\\
\mathbf{elif}\;d \leq 2.35 \cdot 10^{+101}:\\
\;\;\;\;\frac{b}{t\_0} \cdot c - \frac{a}{t\_0} \cdot d\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{c}{d}, \frac{b}{d}, t\_1\right)\\
\end{array}
\end{array}
if d < -1.15000000000000001e111Initial program 61.2%
Taylor expanded in d around inf
lower-/.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f6452.6
Applied rewrites52.6%
lift-/.f64N/A
lift-fma.f64N/A
+-commutativeN/A
div-addN/A
lift-/.f64N/A
associate-/l/N/A
lift-*.f64N/A
*-commutativeN/A
times-fracN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f64N/A
frac-2negN/A
lift-neg.f64N/A
lower-/.f64N/A
distribute-lft-neg-outN/A
metadata-evalN/A
*-lft-identity52.9
Applied rewrites52.9%
lift-/.f64N/A
div-flipN/A
metadata-evalN/A
lower-unsound-/.f64N/A
metadata-evalN/A
lower-unsound-/.f6452.9
Applied rewrites52.9%
if -1.15000000000000001e111 < d < -2.29999999999999996e-151Initial program 61.2%
lift-+.f64N/A
add-flipN/A
sub-flipN/A
lift-*.f64N/A
sqr-abs-revN/A
distribute-lft-neg-inN/A
distribute-rgt-neg-outN/A
fp-cancel-sign-sub-invN/A
fp-cancel-sub-sign-invN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
distribute-lft-neg-inN/A
sqr-neg-revN/A
sqr-abs-revN/A
lift-*.f64N/A
remove-double-negN/A
lower-fma.f6461.2
Applied rewrites61.2%
if -2.29999999999999996e-151 < d < 2.1499999999999999e-29Initial program 61.2%
Taylor expanded in c around inf
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6451.8
Applied rewrites51.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-/.f6451.8
Applied rewrites51.8%
if 2.1499999999999999e-29 < d < 2.34999999999999985e101Initial program 61.2%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
lower--.f64N/A
Applied rewrites58.4%
if 2.34999999999999985e101 < d Initial program 61.2%
Taylor expanded in d around inf
lower-/.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f6452.6
Applied rewrites52.6%
lift-/.f64N/A
lift-fma.f64N/A
+-commutativeN/A
div-addN/A
lift-/.f64N/A
associate-/l/N/A
lift-*.f64N/A
*-commutativeN/A
times-fracN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f64N/A
frac-2negN/A
lift-neg.f64N/A
lower-/.f64N/A
distribute-lft-neg-outN/A
metadata-evalN/A
*-lft-identity52.9
Applied rewrites52.9%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- b (* (/ a c) d)) c)))
(if (<= c -3.4e+86)
t_0
(if (<= c -7.2e-99)
(/ (- (* b c) (* a d)) (fma c c (* d d)))
(if (<= c 2.45e-115)
(/ (fma (/ c d) b (- a)) d)
(if (<= c 1.85e+50)
(/ 1.0 (/ (fma d d (* c c)) (- (* c b) (* d a))))
t_0))))))
double code(double a, double b, double c, double d) {
double t_0 = (b - ((a / c) * d)) / c;
double tmp;
if (c <= -3.4e+86) {
tmp = t_0;
} else if (c <= -7.2e-99) {
tmp = ((b * c) - (a * d)) / fma(c, c, (d * d));
} else if (c <= 2.45e-115) {
tmp = fma((c / d), b, -a) / d;
} else if (c <= 1.85e+50) {
tmp = 1.0 / (fma(d, d, (c * c)) / ((c * b) - (d * a)));
} else {
tmp = t_0;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(b - Float64(Float64(a / c) * d)) / c) tmp = 0.0 if (c <= -3.4e+86) tmp = t_0; elseif (c <= -7.2e-99) tmp = Float64(Float64(Float64(b * c) - Float64(a * d)) / fma(c, c, Float64(d * d))); elseif (c <= 2.45e-115) tmp = Float64(fma(Float64(c / d), b, Float64(-a)) / d); elseif (c <= 1.85e+50) tmp = Float64(1.0 / Float64(fma(d, d, Float64(c * c)) / Float64(Float64(c * b) - Float64(d * a)))); else tmp = t_0; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(b - N[(N[(a / c), $MachinePrecision] * d), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]}, If[LessEqual[c, -3.4e+86], t$95$0, If[LessEqual[c, -7.2e-99], N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 2.45e-115], N[(N[(N[(c / d), $MachinePrecision] * b + (-a)), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 1.85e+50], N[(1.0 / N[(N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision] / N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b - \frac{a}{c} \cdot d}{c}\\
\mathbf{if}\;c \leq -3.4 \cdot 10^{+86}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq -7.2 \cdot 10^{-99}:\\
\;\;\;\;\frac{b \cdot c - a \cdot d}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\
\mathbf{elif}\;c \leq 2.45 \cdot 10^{-115}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{c}{d}, b, -a\right)}{d}\\
\mathbf{elif}\;c \leq 1.85 \cdot 10^{+50}:\\
\;\;\;\;\frac{1}{\frac{\mathsf{fma}\left(d, d, c \cdot c\right)}{c \cdot b - d \cdot a}}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if c < -3.3999999999999998e86 or 1.85e50 < c Initial program 61.2%
Taylor expanded in c around inf
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6451.8
Applied rewrites51.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-/.f6451.8
Applied rewrites51.8%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6453.0
Applied rewrites53.0%
if -3.3999999999999998e86 < c < -7.2000000000000001e-99Initial program 61.2%
lift-+.f64N/A
add-flipN/A
sub-flipN/A
lift-*.f64N/A
sqr-abs-revN/A
distribute-lft-neg-inN/A
distribute-rgt-neg-outN/A
fp-cancel-sign-sub-invN/A
fp-cancel-sub-sign-invN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
distribute-lft-neg-inN/A
sqr-neg-revN/A
sqr-abs-revN/A
lift-*.f64N/A
remove-double-negN/A
lower-fma.f6461.2
Applied rewrites61.2%
if -7.2000000000000001e-99 < c < 2.44999999999999994e-115Initial program 61.2%
Taylor expanded in d around inf
lower-/.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f6452.6
Applied rewrites52.6%
lift-fma.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
metadata-evalN/A
distribute-lft-neg-outN/A
metadata-evalN/A
distribute-lft-neg-outN/A
lower-neg.f64N/A
distribute-lft-neg-outN/A
metadata-evalN/A
*-lft-identity54.5
Applied rewrites54.5%
if 2.44999999999999994e-115 < c < 1.85e50Initial program 61.2%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6461.0
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
sqr-abs-revN/A
sqr-neg-revN/A
fp-cancel-sign-sub-invN/A
fp-cancel-sub-sign-invN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
distribute-lft-neg-inN/A
sqr-neg-revN/A
sqr-abs-revN/A
lift-*.f64N/A
remove-double-negN/A
lower-fma.f6461.0
Applied rewrites61.0%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* b c) (* a d)) (fma c c (* d d))))
(t_1 (/ (- b (* (/ a c) d)) c)))
(if (<= c -3.4e+86)
t_1
(if (<= c -7.2e-99)
t_0
(if (<= c 5.9e-117)
(/ (fma (/ c d) b (- a)) d)
(if (<= c 1.85e+50) t_0 t_1))))))
double code(double a, double b, double c, double d) {
double t_0 = ((b * c) - (a * d)) / fma(c, c, (d * d));
double t_1 = (b - ((a / c) * d)) / c;
double tmp;
if (c <= -3.4e+86) {
tmp = t_1;
} else if (c <= -7.2e-99) {
tmp = t_0;
} else if (c <= 5.9e-117) {
tmp = fma((c / d), b, -a) / d;
} else if (c <= 1.85e+50) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(Float64(b * c) - Float64(a * d)) / fma(c, c, Float64(d * d))) t_1 = Float64(Float64(b - Float64(Float64(a / c) * d)) / c) tmp = 0.0 if (c <= -3.4e+86) tmp = t_1; elseif (c <= -7.2e-99) tmp = t_0; elseif (c <= 5.9e-117) tmp = Float64(fma(Float64(c / d), b, Float64(-a)) / d); elseif (c <= 1.85e+50) tmp = t_0; else tmp = t_1; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(b - N[(N[(a / c), $MachinePrecision] * d), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]}, If[LessEqual[c, -3.4e+86], t$95$1, If[LessEqual[c, -7.2e-99], t$95$0, If[LessEqual[c, 5.9e-117], N[(N[(N[(c / d), $MachinePrecision] * b + (-a)), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 1.85e+50], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b \cdot c - a \cdot d}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\
t_1 := \frac{b - \frac{a}{c} \cdot d}{c}\\
\mathbf{if}\;c \leq -3.4 \cdot 10^{+86}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;c \leq -7.2 \cdot 10^{-99}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq 5.9 \cdot 10^{-117}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{c}{d}, b, -a\right)}{d}\\
\mathbf{elif}\;c \leq 1.85 \cdot 10^{+50}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if c < -3.3999999999999998e86 or 1.85e50 < c Initial program 61.2%
Taylor expanded in c around inf
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6451.8
Applied rewrites51.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-/.f6451.8
Applied rewrites51.8%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6453.0
Applied rewrites53.0%
if -3.3999999999999998e86 < c < -7.2000000000000001e-99 or 5.9000000000000003e-117 < c < 1.85e50Initial program 61.2%
lift-+.f64N/A
add-flipN/A
sub-flipN/A
lift-*.f64N/A
sqr-abs-revN/A
distribute-lft-neg-inN/A
distribute-rgt-neg-outN/A
fp-cancel-sign-sub-invN/A
fp-cancel-sub-sign-invN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
distribute-lft-neg-inN/A
sqr-neg-revN/A
sqr-abs-revN/A
lift-*.f64N/A
remove-double-negN/A
lower-fma.f6461.2
Applied rewrites61.2%
if -7.2000000000000001e-99 < c < 5.9000000000000003e-117Initial program 61.2%
Taylor expanded in d around inf
lower-/.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f6452.6
Applied rewrites52.6%
lift-fma.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
metadata-evalN/A
distribute-lft-neg-outN/A
metadata-evalN/A
distribute-lft-neg-outN/A
lower-neg.f64N/A
distribute-lft-neg-outN/A
metadata-evalN/A
*-lft-identity54.5
Applied rewrites54.5%
(FPCore (a b c d) :precision binary64 (if (<= c -14500.0) (/ (- b (* (/ 1.0 (/ c a)) d)) c) (if (<= c 7.5e-8) (/ (fma (/ c d) b (- a)) d) (/ (- b (* (/ a c) d)) c))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -14500.0) {
tmp = (b - ((1.0 / (c / a)) * d)) / c;
} else if (c <= 7.5e-8) {
tmp = fma((c / d), b, -a) / d;
} else {
tmp = (b - ((a / c) * d)) / c;
}
return tmp;
}
function code(a, b, c, d) tmp = 0.0 if (c <= -14500.0) tmp = Float64(Float64(b - Float64(Float64(1.0 / Float64(c / a)) * d)) / c); elseif (c <= 7.5e-8) tmp = Float64(fma(Float64(c / d), b, Float64(-a)) / d); else tmp = Float64(Float64(b - Float64(Float64(a / c) * d)) / c); end return tmp end
code[a_, b_, c_, d_] := If[LessEqual[c, -14500.0], N[(N[(b - N[(N[(1.0 / N[(c / a), $MachinePrecision]), $MachinePrecision] * d), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[c, 7.5e-8], N[(N[(N[(c / d), $MachinePrecision] * b + (-a)), $MachinePrecision] / d), $MachinePrecision], N[(N[(b - N[(N[(a / c), $MachinePrecision] * d), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -14500:\\
\;\;\;\;\frac{b - \frac{1}{\frac{c}{a}} \cdot d}{c}\\
\mathbf{elif}\;c \leq 7.5 \cdot 10^{-8}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{c}{d}, b, -a\right)}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - \frac{a}{c} \cdot d}{c}\\
\end{array}
\end{array}
if c < -14500Initial program 61.2%
Taylor expanded in c around inf
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6451.8
Applied rewrites51.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-/.f6451.8
Applied rewrites51.8%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6453.0
Applied rewrites53.0%
lift-/.f64N/A
div-flipN/A
metadata-evalN/A
lower-unsound-/.f64N/A
metadata-evalN/A
lower-unsound-/.f6453.0
Applied rewrites53.0%
if -14500 < c < 7.4999999999999997e-8Initial program 61.2%
Taylor expanded in d around inf
lower-/.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f6452.6
Applied rewrites52.6%
lift-fma.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
metadata-evalN/A
distribute-lft-neg-outN/A
metadata-evalN/A
distribute-lft-neg-outN/A
lower-neg.f64N/A
distribute-lft-neg-outN/A
metadata-evalN/A
*-lft-identity54.5
Applied rewrites54.5%
if 7.4999999999999997e-8 < c Initial program 61.2%
Taylor expanded in c around inf
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6451.8
Applied rewrites51.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-/.f6451.8
Applied rewrites51.8%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6453.0
Applied rewrites53.0%
(FPCore (a b c d) :precision binary64 (if (<= c -14500.0) (/ (fma d (* a (/ -1.0 c)) b) c) (if (<= c 7.5e-8) (/ (fma (/ c d) b (- a)) d) (/ (- b (* (/ a c) d)) c))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -14500.0) {
tmp = fma(d, (a * (-1.0 / c)), b) / c;
} else if (c <= 7.5e-8) {
tmp = fma((c / d), b, -a) / d;
} else {
tmp = (b - ((a / c) * d)) / c;
}
return tmp;
}
function code(a, b, c, d) tmp = 0.0 if (c <= -14500.0) tmp = Float64(fma(d, Float64(a * Float64(-1.0 / c)), b) / c); elseif (c <= 7.5e-8) tmp = Float64(fma(Float64(c / d), b, Float64(-a)) / d); else tmp = Float64(Float64(b - Float64(Float64(a / c) * d)) / c); end return tmp end
code[a_, b_, c_, d_] := If[LessEqual[c, -14500.0], N[(N[(d * N[(a * N[(-1.0 / c), $MachinePrecision]), $MachinePrecision] + b), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[c, 7.5e-8], N[(N[(N[(c / d), $MachinePrecision] * b + (-a)), $MachinePrecision] / d), $MachinePrecision], N[(N[(b - N[(N[(a / c), $MachinePrecision] * d), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -14500:\\
\;\;\;\;\frac{\mathsf{fma}\left(d, a \cdot \frac{-1}{c}, b\right)}{c}\\
\mathbf{elif}\;c \leq 7.5 \cdot 10^{-8}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{c}{d}, b, -a\right)}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - \frac{a}{c} \cdot d}{c}\\
\end{array}
\end{array}
if c < -14500Initial program 61.2%
Taylor expanded in c around inf
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6451.8
Applied rewrites51.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-/.f64N/A
frac-2negN/A
associate-*r/N/A
mult-flipN/A
mul-1-negN/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
distribute-rgt-neg-inN/A
associate-*l*N/A
lower-fma.f64N/A
lower-*.f64N/A
distribute-lft-neg-outN/A
metadata-evalN/A
*-lft-identityN/A
metadata-evalN/A
frac-2neg-revN/A
lower-/.f6453.0
Applied rewrites53.0%
if -14500 < c < 7.4999999999999997e-8Initial program 61.2%
Taylor expanded in d around inf
lower-/.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f6452.6
Applied rewrites52.6%
lift-fma.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
metadata-evalN/A
distribute-lft-neg-outN/A
metadata-evalN/A
distribute-lft-neg-outN/A
lower-neg.f64N/A
distribute-lft-neg-outN/A
metadata-evalN/A
*-lft-identity54.5
Applied rewrites54.5%
if 7.4999999999999997e-8 < c Initial program 61.2%
Taylor expanded in c around inf
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6451.8
Applied rewrites51.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-/.f6451.8
Applied rewrites51.8%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6453.0
Applied rewrites53.0%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- b (* (/ a c) d)) c)))
(if (<= c -14500.0)
t_0
(if (<= c 7.5e-8) (/ (fma (/ c d) b (- a)) d) t_0))))
double code(double a, double b, double c, double d) {
double t_0 = (b - ((a / c) * d)) / c;
double tmp;
if (c <= -14500.0) {
tmp = t_0;
} else if (c <= 7.5e-8) {
tmp = fma((c / d), b, -a) / d;
} else {
tmp = t_0;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(b - Float64(Float64(a / c) * d)) / c) tmp = 0.0 if (c <= -14500.0) tmp = t_0; elseif (c <= 7.5e-8) tmp = Float64(fma(Float64(c / d), b, Float64(-a)) / d); else tmp = t_0; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(b - N[(N[(a / c), $MachinePrecision] * d), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]}, If[LessEqual[c, -14500.0], t$95$0, If[LessEqual[c, 7.5e-8], N[(N[(N[(c / d), $MachinePrecision] * b + (-a)), $MachinePrecision] / d), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b - \frac{a}{c} \cdot d}{c}\\
\mathbf{if}\;c \leq -14500:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq 7.5 \cdot 10^{-8}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{c}{d}, b, -a\right)}{d}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if c < -14500 or 7.4999999999999997e-8 < c Initial program 61.2%
Taylor expanded in c around inf
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6451.8
Applied rewrites51.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-/.f6451.8
Applied rewrites51.8%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6453.0
Applied rewrites53.0%
if -14500 < c < 7.4999999999999997e-8Initial program 61.2%
Taylor expanded in d around inf
lower-/.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f6452.6
Applied rewrites52.6%
lift-fma.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
metadata-evalN/A
distribute-lft-neg-outN/A
metadata-evalN/A
distribute-lft-neg-outN/A
lower-neg.f64N/A
distribute-lft-neg-outN/A
metadata-evalN/A
*-lft-identity54.5
Applied rewrites54.5%
(FPCore (a b c d) :precision binary64 (let* ((t_0 (/ (- b (* (/ a c) d)) c))) (if (<= c -14500.0) t_0 (if (<= c 7.5e-8) (/ (- (/ (* b c) d) a) d) t_0))))
double code(double a, double b, double c, double d) {
double t_0 = (b - ((a / c) * d)) / c;
double tmp;
if (c <= -14500.0) {
tmp = t_0;
} else if (c <= 7.5e-8) {
tmp = (((b * c) / d) - a) / d;
} 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 = (b - ((a / c) * d)) / c
if (c <= (-14500.0d0)) then
tmp = t_0
else if (c <= 7.5d-8) then
tmp = (((b * c) / d) - a) / d
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 = (b - ((a / c) * d)) / c;
double tmp;
if (c <= -14500.0) {
tmp = t_0;
} else if (c <= 7.5e-8) {
tmp = (((b * c) / d) - a) / d;
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b, c, d): t_0 = (b - ((a / c) * d)) / c tmp = 0 if c <= -14500.0: tmp = t_0 elif c <= 7.5e-8: tmp = (((b * c) / d) - a) / d else: tmp = t_0 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(b - Float64(Float64(a / c) * d)) / c) tmp = 0.0 if (c <= -14500.0) tmp = t_0; elseif (c <= 7.5e-8) tmp = Float64(Float64(Float64(Float64(b * c) / d) - a) / d); else tmp = t_0; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (b - ((a / c) * d)) / c; tmp = 0.0; if (c <= -14500.0) tmp = t_0; elseif (c <= 7.5e-8) tmp = (((b * c) / d) - a) / d; else tmp = t_0; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(b - N[(N[(a / c), $MachinePrecision] * d), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]}, If[LessEqual[c, -14500.0], t$95$0, If[LessEqual[c, 7.5e-8], N[(N[(N[(N[(b * c), $MachinePrecision] / d), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b - \frac{a}{c} \cdot d}{c}\\
\mathbf{if}\;c \leq -14500:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq 7.5 \cdot 10^{-8}:\\
\;\;\;\;\frac{\frac{b \cdot c}{d} - a}{d}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if c < -14500 or 7.4999999999999997e-8 < c Initial program 61.2%
Taylor expanded in c around inf
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6451.8
Applied rewrites51.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-/.f6451.8
Applied rewrites51.8%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6453.0
Applied rewrites53.0%
if -14500 < c < 7.4999999999999997e-8Initial program 61.2%
Taylor expanded in d around inf
lower-/.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f6452.6
Applied rewrites52.6%
lift-fma.f64N/A
+-commutativeN/A
add-flipN/A
lower--.f64N/A
distribute-lft-neg-outN/A
metadata-evalN/A
*-lft-identity52.6
Applied rewrites52.6%
(FPCore (a b c d) :precision binary64 (let* ((t_0 (/ (- a) d))) (if (<= d -3e+44) t_0 (if (<= d 2.75e+52) (/ (- b (/ (* a d) c)) c) t_0))))
double code(double a, double b, double c, double d) {
double t_0 = -a / d;
double tmp;
if (d <= -3e+44) {
tmp = t_0;
} else if (d <= 2.75e+52) {
tmp = (b - ((a * d) / c)) / 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 = -a / d
if (d <= (-3d+44)) then
tmp = t_0
else if (d <= 2.75d+52) then
tmp = (b - ((a * d) / c)) / 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 = -a / d;
double tmp;
if (d <= -3e+44) {
tmp = t_0;
} else if (d <= 2.75e+52) {
tmp = (b - ((a * d) / c)) / c;
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b, c, d): t_0 = -a / d tmp = 0 if d <= -3e+44: tmp = t_0 elif d <= 2.75e+52: tmp = (b - ((a * d) / c)) / c else: tmp = t_0 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(-a) / d) tmp = 0.0 if (d <= -3e+44) tmp = t_0; elseif (d <= 2.75e+52) tmp = Float64(Float64(b - Float64(Float64(a * d) / c)) / c); else tmp = t_0; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = -a / d; tmp = 0.0; if (d <= -3e+44) tmp = t_0; elseif (d <= 2.75e+52) tmp = (b - ((a * d) / c)) / c; else tmp = t_0; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[((-a) / d), $MachinePrecision]}, If[LessEqual[d, -3e+44], t$95$0, If[LessEqual[d, 2.75e+52], N[(N[(b - N[(N[(a * d), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-a}{d}\\
\mathbf{if}\;d \leq -3 \cdot 10^{+44}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 2.75 \cdot 10^{+52}:\\
\;\;\;\;\frac{b - \frac{a \cdot d}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d < -2.99999999999999987e44 or 2.74999999999999998e52 < d Initial program 61.2%
Taylor expanded in d around inf
lower-/.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f6452.6
Applied rewrites52.6%
Taylor expanded in a around inf
lower-*.f6442.6
Applied rewrites42.6%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6442.6
Applied rewrites42.6%
if -2.99999999999999987e44 < d < 2.74999999999999998e52Initial program 61.2%
Taylor expanded in c around inf
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6451.8
Applied rewrites51.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-/.f6451.8
Applied rewrites51.8%
(FPCore (a b c d) :precision binary64 (let* ((t_0 (/ (- a) d))) (if (<= d -3e+44) t_0 (if (<= d 8e+89) (/ (- b (* (/ a c) d)) c) t_0))))
double code(double a, double b, double c, double d) {
double t_0 = -a / d;
double tmp;
if (d <= -3e+44) {
tmp = t_0;
} else if (d <= 8e+89) {
tmp = (b - ((a / c) * d)) / 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 = -a / d
if (d <= (-3d+44)) then
tmp = t_0
else if (d <= 8d+89) then
tmp = (b - ((a / c) * d)) / 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 = -a / d;
double tmp;
if (d <= -3e+44) {
tmp = t_0;
} else if (d <= 8e+89) {
tmp = (b - ((a / c) * d)) / c;
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b, c, d): t_0 = -a / d tmp = 0 if d <= -3e+44: tmp = t_0 elif d <= 8e+89: tmp = (b - ((a / c) * d)) / c else: tmp = t_0 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(-a) / d) tmp = 0.0 if (d <= -3e+44) tmp = t_0; elseif (d <= 8e+89) tmp = Float64(Float64(b - Float64(Float64(a / c) * d)) / c); else tmp = t_0; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = -a / d; tmp = 0.0; if (d <= -3e+44) tmp = t_0; elseif (d <= 8e+89) tmp = (b - ((a / c) * d)) / c; else tmp = t_0; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[((-a) / d), $MachinePrecision]}, If[LessEqual[d, -3e+44], t$95$0, If[LessEqual[d, 8e+89], N[(N[(b - N[(N[(a / c), $MachinePrecision] * d), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-a}{d}\\
\mathbf{if}\;d \leq -3 \cdot 10^{+44}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 8 \cdot 10^{+89}:\\
\;\;\;\;\frac{b - \frac{a}{c} \cdot d}{c}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d < -2.99999999999999987e44 or 7.99999999999999996e89 < d Initial program 61.2%
Taylor expanded in d around inf
lower-/.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f6452.6
Applied rewrites52.6%
Taylor expanded in a around inf
lower-*.f6442.6
Applied rewrites42.6%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6442.6
Applied rewrites42.6%
if -2.99999999999999987e44 < d < 7.99999999999999996e89Initial program 61.2%
Taylor expanded in c around inf
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6451.8
Applied rewrites51.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-/.f6451.8
Applied rewrites51.8%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6453.0
Applied rewrites53.0%
(FPCore (a b c d) :precision binary64 (if (<= c -4.8e+60) (/ b c) (if (<= c 1.25e+19) (/ (- a) d) (/ b c))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -4.8e+60) {
tmp = b / c;
} else if (c <= 1.25e+19) {
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 <= (-4.8d+60)) then
tmp = b / c
else if (c <= 1.25d+19) 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 <= -4.8e+60) {
tmp = b / c;
} else if (c <= 1.25e+19) {
tmp = -a / d;
} else {
tmp = b / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -4.8e+60: tmp = b / c elif c <= 1.25e+19: tmp = -a / d else: tmp = b / c return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -4.8e+60) tmp = Float64(b / c); elseif (c <= 1.25e+19) 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 <= -4.8e+60) tmp = b / c; elseif (c <= 1.25e+19) tmp = -a / d; else tmp = b / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -4.8e+60], N[(b / c), $MachinePrecision], If[LessEqual[c, 1.25e+19], N[((-a) / d), $MachinePrecision], N[(b / c), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -4.8 \cdot 10^{+60}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{elif}\;c \leq 1.25 \cdot 10^{+19}:\\
\;\;\;\;\frac{-a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if c < -4.8e60 or 1.25e19 < c Initial program 61.2%
Taylor expanded in c around inf
lower-/.f6442.0
Applied rewrites42.0%
if -4.8e60 < c < 1.25e19Initial program 61.2%
Taylor expanded in d around inf
lower-/.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f6452.6
Applied rewrites52.6%
Taylor expanded in a around inf
lower-*.f6442.6
Applied rewrites42.6%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6442.6
Applied rewrites42.6%
(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 61.2%
Taylor expanded in c around inf
lower-/.f6442.0
Applied rewrites42.0%
(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 2025155
(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))))