
(FPCore (a b c) :precision binary64 (/ (- (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))
double code(double a, double b, double c) {
return (-b - sqrt(((b * b) - (4.0 * (a * c))))) / (2.0 * a);
}
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)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-b - sqrt(((b * b) - (4.0d0 * (a * c))))) / (2.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b - Math.sqrt(((b * b) - (4.0 * (a * c))))) / (2.0 * a);
}
def code(a, b, c): return (-b - math.sqrt(((b * b) - (4.0 * (a * c))))) / (2.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) - sqrt(Float64(Float64(b * b) - Float64(4.0 * Float64(a * c))))) / Float64(2.0 * a)) end
function tmp = code(a, b, c) tmp = (-b - sqrt(((b * b) - (4.0 * (a * c))))) / (2.0 * a); end
code[a_, b_, c_] := N[(N[((-b) - N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(4.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}
\end{array}
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b c) :precision binary64 (/ (- (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))
double code(double a, double b, double c) {
return (-b - sqrt(((b * b) - (4.0 * (a * c))))) / (2.0 * a);
}
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)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-b - sqrt(((b * b) - (4.0d0 * (a * c))))) / (2.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b - Math.sqrt(((b * b) - (4.0 * (a * c))))) / (2.0 * a);
}
def code(a, b, c): return (-b - math.sqrt(((b * b) - (4.0 * (a * c))))) / (2.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) - sqrt(Float64(Float64(b * b) - Float64(4.0 * Float64(a * c))))) / Float64(2.0 * a)) end
function tmp = code(a, b, c) tmp = (-b - sqrt(((b * b) - (4.0 * (a * c))))) / (2.0 * a); end
code[a_, b_, c_] := N[(N[((-b) - N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(4.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}
\end{array}
(FPCore (a b c)
:precision binary64
(if (<= b -38.0)
(- (/ c b))
(if (<= b 1.26e+82)
(/ (- (- b) (sqrt (fma (* c a) -4.0 (* b b)))) (+ a a))
(+ (/ (- b) a) (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -38.0) {
tmp = -(c / b);
} else if (b <= 1.26e+82) {
tmp = (-b - sqrt(fma((c * a), -4.0, (b * b)))) / (a + a);
} else {
tmp = (-b / a) + (c / b);
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -38.0) tmp = Float64(-Float64(c / b)); elseif (b <= 1.26e+82) tmp = Float64(Float64(Float64(-b) - sqrt(fma(Float64(c * a), -4.0, Float64(b * b)))) / Float64(a + a)); else tmp = Float64(Float64(Float64(-b) / a) + Float64(c / b)); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -38.0], (-N[(c / b), $MachinePrecision]), If[LessEqual[b, 1.26e+82], N[(N[((-b) - N[Sqrt[N[(N[(c * a), $MachinePrecision] * -4.0 + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(a + a), $MachinePrecision]), $MachinePrecision], N[(N[((-b) / a), $MachinePrecision] + N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -38:\\
\;\;\;\;-\frac{c}{b}\\
\mathbf{elif}\;b \leq 1.26 \cdot 10^{+82}:\\
\;\;\;\;\frac{\left(-b\right) - \sqrt{\mathsf{fma}\left(c \cdot a, -4, b \cdot b\right)}}{a + a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-b}{a} + \frac{c}{b}\\
\end{array}
\end{array}
if b < -38Initial program 14.3%
Taylor expanded in b around -inf
mul-1-negN/A
lower-neg.f64N/A
lower-/.f6490.5
Applied rewrites90.5%
if -38 < b < 1.2600000000000001e82Initial program 74.1%
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6474.1
Applied rewrites74.1%
lift-*.f64N/A
count-2-revN/A
lower-+.f6474.1
Applied rewrites74.1%
if 1.2600000000000001e82 < b Initial program 58.2%
Taylor expanded in c around 0
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f6495.5
Applied rewrites95.5%
lift-/.f64N/A
lift-/.f64N/A
lift-fma.f64N/A
*-commutativeN/A
lower-+.f64N/A
associate-*r/N/A
mul-1-negN/A
lift-neg.f64N/A
lower-/.f64N/A
lift-/.f6495.5
Applied rewrites95.5%
(FPCore (a b c)
:precision binary64
(if (<= b -1.05e-122)
(- (/ c b))
(if (<= b 1.62e-54)
(/ (- (- b) (sqrt (* (* a c) -4.0))) (+ a a))
(+ (/ (- b) a) (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.05e-122) {
tmp = -(c / b);
} else if (b <= 1.62e-54) {
tmp = (-b - sqrt(((a * c) * -4.0))) / (a + a);
} else {
tmp = (-b / a) + (c / b);
}
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)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-1.05d-122)) then
tmp = -(c / b)
else if (b <= 1.62d-54) then
tmp = (-b - sqrt(((a * c) * (-4.0d0)))) / (a + a)
else
tmp = (-b / a) + (c / b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1.05e-122) {
tmp = -(c / b);
} else if (b <= 1.62e-54) {
tmp = (-b - Math.sqrt(((a * c) * -4.0))) / (a + a);
} else {
tmp = (-b / a) + (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.05e-122: tmp = -(c / b) elif b <= 1.62e-54: tmp = (-b - math.sqrt(((a * c) * -4.0))) / (a + a) else: tmp = (-b / a) + (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.05e-122) tmp = Float64(-Float64(c / b)); elseif (b <= 1.62e-54) tmp = Float64(Float64(Float64(-b) - sqrt(Float64(Float64(a * c) * -4.0))) / Float64(a + a)); else tmp = Float64(Float64(Float64(-b) / a) + Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.05e-122) tmp = -(c / b); elseif (b <= 1.62e-54) tmp = (-b - sqrt(((a * c) * -4.0))) / (a + a); else tmp = (-b / a) + (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.05e-122], (-N[(c / b), $MachinePrecision]), If[LessEqual[b, 1.62e-54], N[(N[((-b) - N[Sqrt[N[(N[(a * c), $MachinePrecision] * -4.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(a + a), $MachinePrecision]), $MachinePrecision], N[(N[((-b) / a), $MachinePrecision] + N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.05 \cdot 10^{-122}:\\
\;\;\;\;-\frac{c}{b}\\
\mathbf{elif}\;b \leq 1.62 \cdot 10^{-54}:\\
\;\;\;\;\frac{\left(-b\right) - \sqrt{\left(a \cdot c\right) \cdot -4}}{a + a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-b}{a} + \frac{c}{b}\\
\end{array}
\end{array}
if b < -1.04999999999999996e-122Initial program 20.7%
Taylor expanded in b around -inf
mul-1-negN/A
lower-neg.f64N/A
lower-/.f6482.0
Applied rewrites82.0%
if -1.04999999999999996e-122 < b < 1.6200000000000001e-54Initial program 76.1%
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6476.1
Applied rewrites76.1%
lift-*.f64N/A
count-2-revN/A
lower-+.f6476.1
Applied rewrites76.1%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f6467.9
Applied rewrites67.9%
if 1.6200000000000001e-54 < b Initial program 69.0%
Taylor expanded in c around 0
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f6487.8
Applied rewrites87.8%
lift-/.f64N/A
lift-/.f64N/A
lift-fma.f64N/A
*-commutativeN/A
lower-+.f64N/A
associate-*r/N/A
mul-1-negN/A
lift-neg.f64N/A
lower-/.f64N/A
lift-/.f6487.8
Applied rewrites87.8%
(FPCore (a b c)
:precision binary64
(if (<= b -10.2)
(- (/ c b))
(if (<= b 1.4e-125)
(/ (- (sqrt (* (* a c) -4.0))) (+ a a))
(+ (/ (- b) a) (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -10.2) {
tmp = -(c / b);
} else if (b <= 1.4e-125) {
tmp = -sqrt(((a * c) * -4.0)) / (a + a);
} else {
tmp = (-b / a) + (c / b);
}
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)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-10.2d0)) then
tmp = -(c / b)
else if (b <= 1.4d-125) then
tmp = -sqrt(((a * c) * (-4.0d0))) / (a + a)
else
tmp = (-b / a) + (c / b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -10.2) {
tmp = -(c / b);
} else if (b <= 1.4e-125) {
tmp = -Math.sqrt(((a * c) * -4.0)) / (a + a);
} else {
tmp = (-b / a) + (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -10.2: tmp = -(c / b) elif b <= 1.4e-125: tmp = -math.sqrt(((a * c) * -4.0)) / (a + a) else: tmp = (-b / a) + (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -10.2) tmp = Float64(-Float64(c / b)); elseif (b <= 1.4e-125) tmp = Float64(Float64(-sqrt(Float64(Float64(a * c) * -4.0))) / Float64(a + a)); else tmp = Float64(Float64(Float64(-b) / a) + Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -10.2) tmp = -(c / b); elseif (b <= 1.4e-125) tmp = -sqrt(((a * c) * -4.0)) / (a + a); else tmp = (-b / a) + (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -10.2], (-N[(c / b), $MachinePrecision]), If[LessEqual[b, 1.4e-125], N[((-N[Sqrt[N[(N[(a * c), $MachinePrecision] * -4.0), $MachinePrecision]], $MachinePrecision]) / N[(a + a), $MachinePrecision]), $MachinePrecision], N[(N[((-b) / a), $MachinePrecision] + N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -10.2:\\
\;\;\;\;-\frac{c}{b}\\
\mathbf{elif}\;b \leq 1.4 \cdot 10^{-125}:\\
\;\;\;\;\frac{-\sqrt{\left(a \cdot c\right) \cdot -4}}{a + a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-b}{a} + \frac{c}{b}\\
\end{array}
\end{array}
if b < -10.199999999999999Initial program 14.3%
Taylor expanded in b around -inf
mul-1-negN/A
lower-neg.f64N/A
lower-/.f6490.5
Applied rewrites90.5%
if -10.199999999999999 < b < 1.4e-125Initial program 64.6%
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6464.6
Applied rewrites64.6%
lift-*.f64N/A
count-2-revN/A
lower-+.f6464.6
Applied rewrites64.6%
Taylor expanded in a around inf
pow2N/A
+-commutativeN/A
*-commutativeN/A
*-commutativeN/A
metadata-evalN/A
fp-cancel-sub-sign-invN/A
pow2N/A
mul-1-negN/A
lower-neg.f64N/A
sqrt-unprodN/A
*-commutativeN/A
lower-sqrt.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6461.4
Applied rewrites61.4%
if 1.4e-125 < b Initial program 71.7%
Taylor expanded in c around 0
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f6482.0
Applied rewrites82.0%
lift-/.f64N/A
lift-/.f64N/A
lift-fma.f64N/A
*-commutativeN/A
lower-+.f64N/A
associate-*r/N/A
mul-1-negN/A
lift-neg.f64N/A
lower-/.f64N/A
lift-/.f6482.0
Applied rewrites82.0%
(FPCore (a b c)
:precision binary64
(if (<= b -10.2)
(- (/ c b))
(if (<= b 1.4e-125)
(- (* (- (sqrt (/ -1.0 (* a c)))) c))
(+ (/ (- b) a) (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -10.2) {
tmp = -(c / b);
} else if (b <= 1.4e-125) {
tmp = -(-sqrt((-1.0 / (a * c))) * c);
} else {
tmp = (-b / a) + (c / b);
}
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)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-10.2d0)) then
tmp = -(c / b)
else if (b <= 1.4d-125) then
tmp = -(-sqrt(((-1.0d0) / (a * c))) * c)
else
tmp = (-b / a) + (c / b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -10.2) {
tmp = -(c / b);
} else if (b <= 1.4e-125) {
tmp = -(-Math.sqrt((-1.0 / (a * c))) * c);
} else {
tmp = (-b / a) + (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -10.2: tmp = -(c / b) elif b <= 1.4e-125: tmp = -(-math.sqrt((-1.0 / (a * c))) * c) else: tmp = (-b / a) + (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -10.2) tmp = Float64(-Float64(c / b)); elseif (b <= 1.4e-125) tmp = Float64(-Float64(Float64(-sqrt(Float64(-1.0 / Float64(a * c)))) * c)); else tmp = Float64(Float64(Float64(-b) / a) + Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -10.2) tmp = -(c / b); elseif (b <= 1.4e-125) tmp = -(-sqrt((-1.0 / (a * c))) * c); else tmp = (-b / a) + (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -10.2], (-N[(c / b), $MachinePrecision]), If[LessEqual[b, 1.4e-125], (-N[((-N[Sqrt[N[(-1.0 / N[(a * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) * c), $MachinePrecision]), N[(N[((-b) / a), $MachinePrecision] + N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -10.2:\\
\;\;\;\;-\frac{c}{b}\\
\mathbf{elif}\;b \leq 1.4 \cdot 10^{-125}:\\
\;\;\;\;-\left(-\sqrt{\frac{-1}{a \cdot c}}\right) \cdot c\\
\mathbf{else}:\\
\;\;\;\;\frac{-b}{a} + \frac{c}{b}\\
\end{array}
\end{array}
if b < -10.199999999999999Initial program 14.3%
Taylor expanded in b around -inf
mul-1-negN/A
lower-neg.f64N/A
lower-/.f6490.5
Applied rewrites90.5%
if -10.199999999999999 < b < 1.4e-125Initial program 64.6%
Taylor expanded in c around -inf
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites60.7%
Taylor expanded in a around inf
mul-1-negN/A
*-commutativeN/A
sqrt-prodN/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
lift-neg.f6460.7
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
metadata-evalN/A
*-commutativeN/A
lower-/.f64N/A
lift-*.f6460.7
Applied rewrites60.7%
if 1.4e-125 < b Initial program 71.7%
Taylor expanded in c around 0
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f6482.0
Applied rewrites82.0%
lift-/.f64N/A
lift-/.f64N/A
lift-fma.f64N/A
*-commutativeN/A
lower-+.f64N/A
associate-*r/N/A
mul-1-negN/A
lift-neg.f64N/A
lower-/.f64N/A
lift-/.f6482.0
Applied rewrites82.0%
(FPCore (a b c) :precision binary64 (if (<= b -3.4e-163) (- (/ c b)) (if (<= b 1.25e-158) (- (sqrt (- (/ c a)))) (+ (/ (- b) a) (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -3.4e-163) {
tmp = -(c / b);
} else if (b <= 1.25e-158) {
tmp = -sqrt(-(c / a));
} else {
tmp = (-b / a) + (c / b);
}
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)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-3.4d-163)) then
tmp = -(c / b)
else if (b <= 1.25d-158) then
tmp = -sqrt(-(c / a))
else
tmp = (-b / a) + (c / b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -3.4e-163) {
tmp = -(c / b);
} else if (b <= 1.25e-158) {
tmp = -Math.sqrt(-(c / a));
} else {
tmp = (-b / a) + (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -3.4e-163: tmp = -(c / b) elif b <= 1.25e-158: tmp = -math.sqrt(-(c / a)) else: tmp = (-b / a) + (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -3.4e-163) tmp = Float64(-Float64(c / b)); elseif (b <= 1.25e-158) tmp = Float64(-sqrt(Float64(-Float64(c / a)))); else tmp = Float64(Float64(Float64(-b) / a) + Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -3.4e-163) tmp = -(c / b); elseif (b <= 1.25e-158) tmp = -sqrt(-(c / a)); else tmp = (-b / a) + (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -3.4e-163], (-N[(c / b), $MachinePrecision]), If[LessEqual[b, 1.25e-158], (-N[Sqrt[(-N[(c / a), $MachinePrecision])], $MachinePrecision]), N[(N[((-b) / a), $MachinePrecision] + N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.4 \cdot 10^{-163}:\\
\;\;\;\;-\frac{c}{b}\\
\mathbf{elif}\;b \leq 1.25 \cdot 10^{-158}:\\
\;\;\;\;-\sqrt{-\frac{c}{a}}\\
\mathbf{else}:\\
\;\;\;\;\frac{-b}{a} + \frac{c}{b}\\
\end{array}
\end{array}
if b < -3.40000000000000014e-163Initial program 23.3%
Taylor expanded in b around -inf
mul-1-negN/A
lower-neg.f64N/A
lower-/.f6478.7
Applied rewrites78.7%
if -3.40000000000000014e-163 < b < 1.24999999999999993e-158Initial program 72.5%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6437.8
Applied rewrites37.8%
Taylor expanded in a around -inf
mul-1-negN/A
lower-neg.f64N/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lift-/.f6437.8
Applied rewrites37.8%
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
mul-1-negN/A
lower-neg.f64N/A
lift-/.f6437.8
Applied rewrites37.8%
if 1.24999999999999993e-158 < b Initial program 72.7%
Taylor expanded in c around 0
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f6479.4
Applied rewrites79.4%
lift-/.f64N/A
lift-/.f64N/A
lift-fma.f64N/A
*-commutativeN/A
lower-+.f64N/A
associate-*r/N/A
mul-1-negN/A
lift-neg.f64N/A
lower-/.f64N/A
lift-/.f6479.4
Applied rewrites79.4%
(FPCore (a b c) :precision binary64 (if (<= b -3.4e-163) (- (/ c b)) (if (<= b 1.25e-158) (- (sqrt (- (/ c a)))) (/ (- b) a))))
double code(double a, double b, double c) {
double tmp;
if (b <= -3.4e-163) {
tmp = -(c / b);
} else if (b <= 1.25e-158) {
tmp = -sqrt(-(c / a));
} else {
tmp = -b / a;
}
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)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-3.4d-163)) then
tmp = -(c / b)
else if (b <= 1.25d-158) then
tmp = -sqrt(-(c / a))
else
tmp = -b / a
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -3.4e-163) {
tmp = -(c / b);
} else if (b <= 1.25e-158) {
tmp = -Math.sqrt(-(c / a));
} else {
tmp = -b / a;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -3.4e-163: tmp = -(c / b) elif b <= 1.25e-158: tmp = -math.sqrt(-(c / a)) else: tmp = -b / a return tmp
function code(a, b, c) tmp = 0.0 if (b <= -3.4e-163) tmp = Float64(-Float64(c / b)); elseif (b <= 1.25e-158) tmp = Float64(-sqrt(Float64(-Float64(c / a)))); else tmp = Float64(Float64(-b) / a); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -3.4e-163) tmp = -(c / b); elseif (b <= 1.25e-158) tmp = -sqrt(-(c / a)); else tmp = -b / a; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -3.4e-163], (-N[(c / b), $MachinePrecision]), If[LessEqual[b, 1.25e-158], (-N[Sqrt[(-N[(c / a), $MachinePrecision])], $MachinePrecision]), N[((-b) / a), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.4 \cdot 10^{-163}:\\
\;\;\;\;-\frac{c}{b}\\
\mathbf{elif}\;b \leq 1.25 \cdot 10^{-158}:\\
\;\;\;\;-\sqrt{-\frac{c}{a}}\\
\mathbf{else}:\\
\;\;\;\;\frac{-b}{a}\\
\end{array}
\end{array}
if b < -3.40000000000000014e-163Initial program 23.3%
Taylor expanded in b around -inf
mul-1-negN/A
lower-neg.f64N/A
lower-/.f6478.7
Applied rewrites78.7%
if -3.40000000000000014e-163 < b < 1.24999999999999993e-158Initial program 72.5%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6437.8
Applied rewrites37.8%
Taylor expanded in a around -inf
mul-1-negN/A
lower-neg.f64N/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lift-/.f6437.8
Applied rewrites37.8%
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
mul-1-negN/A
lower-neg.f64N/A
lift-/.f6437.8
Applied rewrites37.8%
if 1.24999999999999993e-158 < b Initial program 72.7%
Taylor expanded in a around 0
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lift-neg.f6479.2
Applied rewrites79.2%
(FPCore (a b c) :precision binary64 (if (<= b -2e-199) (- (/ c b)) (if (<= b 1.15e-107) (sqrt (- (/ c a))) (/ (- b) a))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2e-199) {
tmp = -(c / b);
} else if (b <= 1.15e-107) {
tmp = sqrt(-(c / a));
} else {
tmp = -b / a;
}
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)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-2d-199)) then
tmp = -(c / b)
else if (b <= 1.15d-107) then
tmp = sqrt(-(c / a))
else
tmp = -b / a
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -2e-199) {
tmp = -(c / b);
} else if (b <= 1.15e-107) {
tmp = Math.sqrt(-(c / a));
} else {
tmp = -b / a;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2e-199: tmp = -(c / b) elif b <= 1.15e-107: tmp = math.sqrt(-(c / a)) else: tmp = -b / a return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2e-199) tmp = Float64(-Float64(c / b)); elseif (b <= 1.15e-107) tmp = sqrt(Float64(-Float64(c / a))); else tmp = Float64(Float64(-b) / a); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2e-199) tmp = -(c / b); elseif (b <= 1.15e-107) tmp = sqrt(-(c / a)); else tmp = -b / a; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2e-199], (-N[(c / b), $MachinePrecision]), If[LessEqual[b, 1.15e-107], N[Sqrt[(-N[(c / a), $MachinePrecision])], $MachinePrecision], N[((-b) / a), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2 \cdot 10^{-199}:\\
\;\;\;\;-\frac{c}{b}\\
\mathbf{elif}\;b \leq 1.15 \cdot 10^{-107}:\\
\;\;\;\;\sqrt{-\frac{c}{a}}\\
\mathbf{else}:\\
\;\;\;\;\frac{-b}{a}\\
\end{array}
\end{array}
if b < -1.99999999999999996e-199Initial program 25.7%
Taylor expanded in b around -inf
mul-1-negN/A
lower-neg.f64N/A
lower-/.f6475.9
Applied rewrites75.9%
if -1.99999999999999996e-199 < b < 1.15000000000000002e-107Initial program 75.9%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6436.8
Applied rewrites36.8%
Taylor expanded in a around -inf
mul-1-negN/A
lower-neg.f64N/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lift-/.f6436.9
Applied rewrites36.9%
Taylor expanded in c around -inf
sqrt-prodN/A
lower-sqrt.f64N/A
*-commutativeN/A
mul-1-negN/A
lower-neg.f64N/A
lift-/.f6434.4
Applied rewrites34.4%
if 1.15000000000000002e-107 < b Initial program 71.1%
Taylor expanded in a around 0
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lift-neg.f6483.2
Applied rewrites83.2%
(FPCore (a b c) :precision binary64 (if (<= b -1.02e-305) (- (/ c b)) (/ (- b) a)))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.02e-305) {
tmp = -(c / b);
} else {
tmp = -b / a;
}
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)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-1.02d-305)) then
tmp = -(c / b)
else
tmp = -b / a
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1.02e-305) {
tmp = -(c / b);
} else {
tmp = -b / a;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.02e-305: tmp = -(c / b) else: tmp = -b / a return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.02e-305) tmp = Float64(-Float64(c / b)); else tmp = Float64(Float64(-b) / a); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.02e-305) tmp = -(c / b); else tmp = -b / a; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.02e-305], (-N[(c / b), $MachinePrecision]), N[((-b) / a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.02 \cdot 10^{-305}:\\
\;\;\;\;-\frac{c}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{-b}{a}\\
\end{array}
\end{array}
if b < -1.01999999999999994e-305Initial program 31.8%
Taylor expanded in b around -inf
mul-1-negN/A
lower-neg.f64N/A
lower-/.f6467.6
Applied rewrites67.6%
if -1.01999999999999994e-305 < b Initial program 72.3%
Taylor expanded in a around 0
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lift-neg.f6467.9
Applied rewrites67.9%
(FPCore (a b c) :precision binary64 (- (/ c b)))
double code(double a, double b, double c) {
return -(c / b);
}
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)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = -(c / b)
end function
public static double code(double a, double b, double c) {
return -(c / b);
}
def code(a, b, c): return -(c / b)
function code(a, b, c) return Float64(-Float64(c / b)) end
function tmp = code(a, b, c) tmp = -(c / b); end
code[a_, b_, c_] := (-N[(c / b), $MachinePrecision])
\begin{array}{l}
\\
-\frac{c}{b}
\end{array}
Initial program 52.3%
Taylor expanded in b around -inf
mul-1-negN/A
lower-neg.f64N/A
lower-/.f6434.6
Applied rewrites34.6%
(FPCore (a b c) :precision binary64 (/ c b))
double code(double a, double b, double c) {
return c / b;
}
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)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = c / b
end function
public static double code(double a, double b, double c) {
return c / b;
}
def code(a, b, c): return c / b
function code(a, b, c) return Float64(c / b) end
function tmp = code(a, b, c) tmp = c / b; end
code[a_, b_, c_] := N[(c / b), $MachinePrecision]
\begin{array}{l}
\\
\frac{c}{b}
\end{array}
Initial program 52.3%
Taylor expanded in c around 0
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f6435.6
Applied rewrites35.6%
Taylor expanded in a around inf
lift-/.f6410.8
Applied rewrites10.8%
herbie shell --seed 2025092
(FPCore (a b c)
:name "quadm (p42, negative)"
:precision binary64
:herbie-expected 10
(/ (- (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))