
(FPCore (a b_2 c) :precision binary64 (/ (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))
double code(double a, double b_2, double c) {
return (-b_2 + sqrt(((b_2 * b_2) - (a * c)))) / 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_2, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
code = (-b_2 + sqrt(((b_2 * b_2) - (a * c)))) / a
end function
public static double code(double a, double b_2, double c) {
return (-b_2 + Math.sqrt(((b_2 * b_2) - (a * c)))) / a;
}
def code(a, b_2, c): return (-b_2 + math.sqrt(((b_2 * b_2) - (a * c)))) / a
function code(a, b_2, c) return Float64(Float64(Float64(-b_2) + sqrt(Float64(Float64(b_2 * b_2) - Float64(a * c)))) / a) end
function tmp = code(a, b_2, c) tmp = (-b_2 + sqrt(((b_2 * b_2) - (a * c)))) / a; end
code[a_, b$95$2_, c_] := N[(N[((-b$95$2) + N[Sqrt[N[(N[(b$95$2 * b$95$2), $MachinePrecision] - N[(a * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\_2\right) + \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b_2 c) :precision binary64 (/ (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))
double code(double a, double b_2, double c) {
return (-b_2 + sqrt(((b_2 * b_2) - (a * c)))) / 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_2, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
code = (-b_2 + sqrt(((b_2 * b_2) - (a * c)))) / a
end function
public static double code(double a, double b_2, double c) {
return (-b_2 + Math.sqrt(((b_2 * b_2) - (a * c)))) / a;
}
def code(a, b_2, c): return (-b_2 + math.sqrt(((b_2 * b_2) - (a * c)))) / a
function code(a, b_2, c) return Float64(Float64(Float64(-b_2) + sqrt(Float64(Float64(b_2 * b_2) - Float64(a * c)))) / a) end
function tmp = code(a, b_2, c) tmp = (-b_2 + sqrt(((b_2 * b_2) - (a * c)))) / a; end
code[a_, b$95$2_, c_] := N[(N[((-b$95$2) + N[Sqrt[N[(N[(b$95$2 * b$95$2), $MachinePrecision] - N[(a * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\_2\right) + \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a}
\end{array}
(FPCore (a b_2 c)
:precision binary64
(if (<= b_2 -5.1e+107)
(* (- b_2) (+ (/ 2.0 a) (* (/ (/ c b_2) b_2) -0.5)))
(if (<= b_2 1.45e-71)
(+ (/ (- b_2) a) (/ (sqrt (- (* b_2 b_2) (* c a))) a))
(/ (+ (* (* a (ratio-of-squares c b_2)) -0.125) (* -0.5 c)) b_2))))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b\_2 \leq -5.1 \cdot 10^{+107}:\\
\;\;\;\;\left(-b\_2\right) \cdot \left(\frac{2}{a} + \frac{\frac{c}{b\_2}}{b\_2} \cdot -0.5\right)\\
\mathbf{elif}\;b\_2 \leq 1.45 \cdot 10^{-71}:\\
\;\;\;\;\frac{-b\_2}{a} + \frac{\sqrt{b\_2 \cdot b\_2 - c \cdot a}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(a \cdot \mathsf{ratio\_of\_squares}\left(c, b\_2\right)\right) \cdot -0.125 + -0.5 \cdot c}{b\_2}\\
\end{array}
\end{array}
if b_2 < -5.1000000000000002e107Initial program 52.3%
Taylor expanded in b_2 around inf
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
unpow2N/A
pow2N/A
lower-ratio-of-squares.f64N/A
lower-*.f642.6
Applied rewrites2.6%
Taylor expanded in c around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f642.6
Applied rewrites2.6%
Taylor expanded in b_2 around -inf
associate-*r*N/A
mul-1-negN/A
lift-neg.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6494.7
Applied rewrites94.7%
if -5.1000000000000002e107 < b_2 < 1.4499999999999999e-71Initial program 85.0%
lift-/.f64N/A
lift-neg.f64N/A
lift-+.f64N/A
lift-sqrt.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
div-addN/A
mul-1-negN/A
associate-*r/N/A
lower-+.f64N/A
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lift-neg.f64N/A
lower-/.f64N/A
Applied rewrites85.0%
if 1.4499999999999999e-71 < b_2 Initial program 15.0%
Taylor expanded in b_2 around inf
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
unpow2N/A
pow2N/A
lower-ratio-of-squares.f64N/A
lower-*.f6489.2
Applied rewrites89.2%
(FPCore (a b_2 c)
:precision binary64
(if (<= b_2 -5.1e+107)
(* (- b_2) (+ (/ 2.0 a) (* (/ (/ c b_2) b_2) -0.5)))
(if (<= b_2 1.45e-71)
(/ (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a)
(/ (+ (* (* a (ratio-of-squares c b_2)) -0.125) (* -0.5 c)) b_2))))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b\_2 \leq -5.1 \cdot 10^{+107}:\\
\;\;\;\;\left(-b\_2\right) \cdot \left(\frac{2}{a} + \frac{\frac{c}{b\_2}}{b\_2} \cdot -0.5\right)\\
\mathbf{elif}\;b\_2 \leq 1.45 \cdot 10^{-71}:\\
\;\;\;\;\frac{\left(-b\_2\right) + \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(a \cdot \mathsf{ratio\_of\_squares}\left(c, b\_2\right)\right) \cdot -0.125 + -0.5 \cdot c}{b\_2}\\
\end{array}
\end{array}
if b_2 < -5.1000000000000002e107Initial program 52.3%
Taylor expanded in b_2 around inf
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
unpow2N/A
pow2N/A
lower-ratio-of-squares.f64N/A
lower-*.f642.6
Applied rewrites2.6%
Taylor expanded in c around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f642.6
Applied rewrites2.6%
Taylor expanded in b_2 around -inf
associate-*r*N/A
mul-1-negN/A
lift-neg.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6494.7
Applied rewrites94.7%
if -5.1000000000000002e107 < b_2 < 1.4499999999999999e-71Initial program 85.0%
if 1.4499999999999999e-71 < b_2 Initial program 15.0%
Taylor expanded in b_2 around inf
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
unpow2N/A
pow2N/A
lower-ratio-of-squares.f64N/A
lower-*.f6489.2
Applied rewrites89.2%
(FPCore (a b_2 c)
:precision binary64
(if (<= b_2 -5.1e+107)
(* -2.0 (/ b_2 a))
(if (<= b_2 1.45e-71)
(/ (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a)
(/ (+ (* (* a (ratio-of-squares c b_2)) -0.125) (* -0.5 c)) b_2))))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b\_2 \leq -5.1 \cdot 10^{+107}:\\
\;\;\;\;-2 \cdot \frac{b\_2}{a}\\
\mathbf{elif}\;b\_2 \leq 1.45 \cdot 10^{-71}:\\
\;\;\;\;\frac{\left(-b\_2\right) + \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(a \cdot \mathsf{ratio\_of\_squares}\left(c, b\_2\right)\right) \cdot -0.125 + -0.5 \cdot c}{b\_2}\\
\end{array}
\end{array}
if b_2 < -5.1000000000000002e107Initial program 52.3%
Taylor expanded in b_2 around -inf
lower-*.f64N/A
lower-/.f6494.2
Applied rewrites94.2%
if -5.1000000000000002e107 < b_2 < 1.4499999999999999e-71Initial program 85.0%
if 1.4499999999999999e-71 < b_2 Initial program 15.0%
Taylor expanded in b_2 around inf
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
unpow2N/A
pow2N/A
lower-ratio-of-squares.f64N/A
lower-*.f6489.2
Applied rewrites89.2%
(FPCore (a b_2 c)
:precision binary64
(if (<= b_2 -3.3e-103)
(* -2.0 (/ b_2 a))
(if (<= b_2 1.45e-71)
(/ (+ (- b_2) (sqrt (* (- a) c))) a)
(/ (+ (* (* a (ratio-of-squares c b_2)) -0.125) (* -0.5 c)) b_2))))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b\_2 \leq -3.3 \cdot 10^{-103}:\\
\;\;\;\;-2 \cdot \frac{b\_2}{a}\\
\mathbf{elif}\;b\_2 \leq 1.45 \cdot 10^{-71}:\\
\;\;\;\;\frac{\left(-b\_2\right) + \sqrt{\left(-a\right) \cdot c}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(a \cdot \mathsf{ratio\_of\_squares}\left(c, b\_2\right)\right) \cdot -0.125 + -0.5 \cdot c}{b\_2}\\
\end{array}
\end{array}
if b_2 < -3.2999999999999999e-103Initial program 75.3%
Taylor expanded in b_2 around -inf
lower-*.f64N/A
lower-/.f6488.3
Applied rewrites88.3%
if -3.2999999999999999e-103 < b_2 < 1.4499999999999999e-71Initial program 78.3%
Taylor expanded in a around inf
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f6474.6
Applied rewrites74.6%
if 1.4499999999999999e-71 < b_2 Initial program 15.0%
Taylor expanded in b_2 around inf
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
unpow2N/A
pow2N/A
lower-ratio-of-squares.f64N/A
lower-*.f6489.2
Applied rewrites89.2%
(FPCore (a b_2 c)
:precision binary64
(if (<= b_2 -1.75e-124)
(* -2.0 (/ b_2 a))
(if (<= b_2 1.45e-71)
(/ (sqrt (* (- a) c)) a)
(/ (+ (* (* a (ratio-of-squares c b_2)) -0.125) (* -0.5 c)) b_2))))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b\_2 \leq -1.75 \cdot 10^{-124}:\\
\;\;\;\;-2 \cdot \frac{b\_2}{a}\\
\mathbf{elif}\;b\_2 \leq 1.45 \cdot 10^{-71}:\\
\;\;\;\;\frac{\sqrt{\left(-a\right) \cdot c}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(a \cdot \mathsf{ratio\_of\_squares}\left(c, b\_2\right)\right) \cdot -0.125 + -0.5 \cdot c}{b\_2}\\
\end{array}
\end{array}
if b_2 < -1.7499999999999999e-124Initial program 76.3%
Taylor expanded in b_2 around -inf
lower-*.f64N/A
lower-/.f6486.9
Applied rewrites86.9%
if -1.7499999999999999e-124 < b_2 < 1.4499999999999999e-71Initial program 77.0%
Taylor expanded in a around inf
sqrt-unprodN/A
*-commutativeN/A
lower-sqrt.f64N/A
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f6474.8
Applied rewrites74.8%
if 1.4499999999999999e-71 < b_2 Initial program 15.0%
Taylor expanded in b_2 around inf
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
unpow2N/A
pow2N/A
lower-ratio-of-squares.f64N/A
lower-*.f6489.2
Applied rewrites89.2%
(FPCore (a b_2 c)
:precision binary64
(let* ((t_0 (sqrt (/ (- c) a))))
(if (<= b_2 -7.8e-135)
(* -2.0 (/ b_2 a))
(if (<= b_2 2.5e-203)
(- t_0)
(if (<= b_2 2.7e-138) t_0 (/ (* -0.5 c) b_2))))))
double code(double a, double b_2, double c) {
double t_0 = sqrt((-c / a));
double tmp;
if (b_2 <= -7.8e-135) {
tmp = -2.0 * (b_2 / a);
} else if (b_2 <= 2.5e-203) {
tmp = -t_0;
} else if (b_2 <= 2.7e-138) {
tmp = t_0;
} else {
tmp = (-0.5 * c) / b_2;
}
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_2, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt((-c / a))
if (b_2 <= (-7.8d-135)) then
tmp = (-2.0d0) * (b_2 / a)
else if (b_2 <= 2.5d-203) then
tmp = -t_0
else if (b_2 <= 2.7d-138) then
tmp = t_0
else
tmp = ((-0.5d0) * c) / b_2
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double t_0 = Math.sqrt((-c / a));
double tmp;
if (b_2 <= -7.8e-135) {
tmp = -2.0 * (b_2 / a);
} else if (b_2 <= 2.5e-203) {
tmp = -t_0;
} else if (b_2 <= 2.7e-138) {
tmp = t_0;
} else {
tmp = (-0.5 * c) / b_2;
}
return tmp;
}
def code(a, b_2, c): t_0 = math.sqrt((-c / a)) tmp = 0 if b_2 <= -7.8e-135: tmp = -2.0 * (b_2 / a) elif b_2 <= 2.5e-203: tmp = -t_0 elif b_2 <= 2.7e-138: tmp = t_0 else: tmp = (-0.5 * c) / b_2 return tmp
function code(a, b_2, c) t_0 = sqrt(Float64(Float64(-c) / a)) tmp = 0.0 if (b_2 <= -7.8e-135) tmp = Float64(-2.0 * Float64(b_2 / a)); elseif (b_2 <= 2.5e-203) tmp = Float64(-t_0); elseif (b_2 <= 2.7e-138) tmp = t_0; else tmp = Float64(Float64(-0.5 * c) / b_2); end return tmp end
function tmp_2 = code(a, b_2, c) t_0 = sqrt((-c / a)); tmp = 0.0; if (b_2 <= -7.8e-135) tmp = -2.0 * (b_2 / a); elseif (b_2 <= 2.5e-203) tmp = -t_0; elseif (b_2 <= 2.7e-138) tmp = t_0; else tmp = (-0.5 * c) / b_2; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := Block[{t$95$0 = N[Sqrt[N[((-c) / a), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b$95$2, -7.8e-135], N[(-2.0 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, 2.5e-203], (-t$95$0), If[LessEqual[b$95$2, 2.7e-138], t$95$0, N[(N[(-0.5 * c), $MachinePrecision] / b$95$2), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\frac{-c}{a}}\\
\mathbf{if}\;b\_2 \leq -7.8 \cdot 10^{-135}:\\
\;\;\;\;-2 \cdot \frac{b\_2}{a}\\
\mathbf{elif}\;b\_2 \leq 2.5 \cdot 10^{-203}:\\
\;\;\;\;-t\_0\\
\mathbf{elif}\;b\_2 \leq 2.7 \cdot 10^{-138}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.5 \cdot c}{b\_2}\\
\end{array}
\end{array}
if b_2 < -7.80000000000000043e-135Initial program 76.6%
Taylor expanded in b_2 around -inf
lower-*.f64N/A
lower-/.f6486.0
Applied rewrites86.0%
if -7.80000000000000043e-135 < b_2 < 2.5000000000000001e-203Initial program 72.9%
Taylor expanded in a around inf
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6417.1
Applied rewrites17.1%
Taylor expanded in c around -inf
mul-1-negN/A
lower-neg.f64N/A
sqrt-prodN/A
lower-sqrt.f64N/A
*-commutativeN/A
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lift-neg.f6436.3
Applied rewrites36.3%
if 2.5000000000000001e-203 < b_2 < 2.70000000000000029e-138Initial program 100.0%
Taylor expanded in a around inf
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6458.2
Applied rewrites58.2%
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lift-neg.f6458.2
Applied rewrites58.2%
if 2.70000000000000029e-138 < b_2 Initial program 19.1%
Taylor expanded in b_2 around inf
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
unpow2N/A
pow2N/A
lower-ratio-of-squares.f64N/A
lower-*.f6484.9
Applied rewrites84.9%
Taylor expanded in a around 0
lift-*.f6485.0
Applied rewrites85.0%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -1.75e-124) (* -2.0 (/ b_2 a)) (if (<= b_2 1.35e-71) (/ (sqrt (* (- a) c)) a) (/ (* -0.5 c) b_2))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -1.75e-124) {
tmp = -2.0 * (b_2 / a);
} else if (b_2 <= 1.35e-71) {
tmp = sqrt((-a * c)) / a;
} else {
tmp = (-0.5 * c) / b_2;
}
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_2, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
real(8) :: tmp
if (b_2 <= (-1.75d-124)) then
tmp = (-2.0d0) * (b_2 / a)
else if (b_2 <= 1.35d-71) then
tmp = sqrt((-a * c)) / a
else
tmp = ((-0.5d0) * c) / b_2
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -1.75e-124) {
tmp = -2.0 * (b_2 / a);
} else if (b_2 <= 1.35e-71) {
tmp = Math.sqrt((-a * c)) / a;
} else {
tmp = (-0.5 * c) / b_2;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -1.75e-124: tmp = -2.0 * (b_2 / a) elif b_2 <= 1.35e-71: tmp = math.sqrt((-a * c)) / a else: tmp = (-0.5 * c) / b_2 return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -1.75e-124) tmp = Float64(-2.0 * Float64(b_2 / a)); elseif (b_2 <= 1.35e-71) tmp = Float64(sqrt(Float64(Float64(-a) * c)) / a); else tmp = Float64(Float64(-0.5 * c) / b_2); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -1.75e-124) tmp = -2.0 * (b_2 / a); elseif (b_2 <= 1.35e-71) tmp = sqrt((-a * c)) / a; else tmp = (-0.5 * c) / b_2; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -1.75e-124], N[(-2.0 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, 1.35e-71], N[(N[Sqrt[N[((-a) * c), $MachinePrecision]], $MachinePrecision] / a), $MachinePrecision], N[(N[(-0.5 * c), $MachinePrecision] / b$95$2), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b\_2 \leq -1.75 \cdot 10^{-124}:\\
\;\;\;\;-2 \cdot \frac{b\_2}{a}\\
\mathbf{elif}\;b\_2 \leq 1.35 \cdot 10^{-71}:\\
\;\;\;\;\frac{\sqrt{\left(-a\right) \cdot c}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.5 \cdot c}{b\_2}\\
\end{array}
\end{array}
if b_2 < -1.7499999999999999e-124Initial program 76.3%
Taylor expanded in b_2 around -inf
lower-*.f64N/A
lower-/.f6486.9
Applied rewrites86.9%
if -1.7499999999999999e-124 < b_2 < 1.3500000000000001e-71Initial program 77.0%
Taylor expanded in a around inf
sqrt-unprodN/A
*-commutativeN/A
lower-sqrt.f64N/A
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f6474.8
Applied rewrites74.8%
if 1.3500000000000001e-71 < b_2 Initial program 15.0%
Taylor expanded in b_2 around inf
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
unpow2N/A
pow2N/A
lower-ratio-of-squares.f64N/A
lower-*.f6489.2
Applied rewrites89.2%
Taylor expanded in a around 0
lift-*.f6488.9
Applied rewrites88.9%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -3.3e-237) (* -2.0 (/ b_2 a)) (if (<= b_2 2.7e-138) (sqrt (/ (- c) a)) (/ (* -0.5 c) b_2))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -3.3e-237) {
tmp = -2.0 * (b_2 / a);
} else if (b_2 <= 2.7e-138) {
tmp = sqrt((-c / a));
} else {
tmp = (-0.5 * c) / b_2;
}
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_2, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
real(8) :: tmp
if (b_2 <= (-3.3d-237)) then
tmp = (-2.0d0) * (b_2 / a)
else if (b_2 <= 2.7d-138) then
tmp = sqrt((-c / a))
else
tmp = ((-0.5d0) * c) / b_2
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -3.3e-237) {
tmp = -2.0 * (b_2 / a);
} else if (b_2 <= 2.7e-138) {
tmp = Math.sqrt((-c / a));
} else {
tmp = (-0.5 * c) / b_2;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -3.3e-237: tmp = -2.0 * (b_2 / a) elif b_2 <= 2.7e-138: tmp = math.sqrt((-c / a)) else: tmp = (-0.5 * c) / b_2 return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -3.3e-237) tmp = Float64(-2.0 * Float64(b_2 / a)); elseif (b_2 <= 2.7e-138) tmp = sqrt(Float64(Float64(-c) / a)); else tmp = Float64(Float64(-0.5 * c) / b_2); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -3.3e-237) tmp = -2.0 * (b_2 / a); elseif (b_2 <= 2.7e-138) tmp = sqrt((-c / a)); else tmp = (-0.5 * c) / b_2; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -3.3e-237], N[(-2.0 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, 2.7e-138], N[Sqrt[N[((-c) / a), $MachinePrecision]], $MachinePrecision], N[(N[(-0.5 * c), $MachinePrecision] / b$95$2), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b\_2 \leq -3.3 \cdot 10^{-237}:\\
\;\;\;\;-2 \cdot \frac{b\_2}{a}\\
\mathbf{elif}\;b\_2 \leq 2.7 \cdot 10^{-138}:\\
\;\;\;\;\sqrt{\frac{-c}{a}}\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.5 \cdot c}{b\_2}\\
\end{array}
\end{array}
if b_2 < -3.3000000000000001e-237Initial program 77.0%
Taylor expanded in b_2 around -inf
lower-*.f64N/A
lower-/.f6475.8
Applied rewrites75.8%
if -3.3000000000000001e-237 < b_2 < 2.70000000000000029e-138Initial program 76.1%
Taylor expanded in a around inf
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6430.5
Applied rewrites30.5%
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lift-neg.f6430.5
Applied rewrites30.5%
if 2.70000000000000029e-138 < b_2 Initial program 19.1%
Taylor expanded in b_2 around inf
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
unpow2N/A
pow2N/A
lower-ratio-of-squares.f64N/A
lower-*.f6484.9
Applied rewrites84.9%
Taylor expanded in a around 0
lift-*.f6485.0
Applied rewrites85.0%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -5e-310) (* -2.0 (/ b_2 a)) (/ (* -0.5 c) b_2)))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -5e-310) {
tmp = -2.0 * (b_2 / a);
} else {
tmp = (-0.5 * c) / b_2;
}
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_2, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
real(8) :: tmp
if (b_2 <= (-5d-310)) then
tmp = (-2.0d0) * (b_2 / a)
else
tmp = ((-0.5d0) * c) / b_2
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -5e-310) {
tmp = -2.0 * (b_2 / a);
} else {
tmp = (-0.5 * c) / b_2;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -5e-310: tmp = -2.0 * (b_2 / a) else: tmp = (-0.5 * c) / b_2 return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -5e-310) tmp = Float64(-2.0 * Float64(b_2 / a)); else tmp = Float64(Float64(-0.5 * c) / b_2); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -5e-310) tmp = -2.0 * (b_2 / a); else tmp = (-0.5 * c) / b_2; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -5e-310], N[(-2.0 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision], N[(N[(-0.5 * c), $MachinePrecision] / b$95$2), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b\_2 \leq -5 \cdot 10^{-310}:\\
\;\;\;\;-2 \cdot \frac{b\_2}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.5 \cdot c}{b\_2}\\
\end{array}
\end{array}
if b_2 < -4.999999999999985e-310Initial program 76.2%
Taylor expanded in b_2 around -inf
lower-*.f64N/A
lower-/.f6471.2
Applied rewrites71.2%
if -4.999999999999985e-310 < b_2 Initial program 33.5%
Taylor expanded in b_2 around inf
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
unpow2N/A
pow2N/A
lower-ratio-of-squares.f64N/A
lower-*.f6466.1
Applied rewrites66.1%
Taylor expanded in a around 0
lift-*.f6466.9
Applied rewrites66.9%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -5e-310) (* -2.0 (/ b_2 a)) (* (/ c b_2) -0.5)))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -5e-310) {
tmp = -2.0 * (b_2 / a);
} else {
tmp = (c / b_2) * -0.5;
}
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_2, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
real(8) :: tmp
if (b_2 <= (-5d-310)) then
tmp = (-2.0d0) * (b_2 / a)
else
tmp = (c / b_2) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -5e-310) {
tmp = -2.0 * (b_2 / a);
} else {
tmp = (c / b_2) * -0.5;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -5e-310: tmp = -2.0 * (b_2 / a) else: tmp = (c / b_2) * -0.5 return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -5e-310) tmp = Float64(-2.0 * Float64(b_2 / a)); else tmp = Float64(Float64(c / b_2) * -0.5); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -5e-310) tmp = -2.0 * (b_2 / a); else tmp = (c / b_2) * -0.5; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -5e-310], N[(-2.0 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b$95$2), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b\_2 \leq -5 \cdot 10^{-310}:\\
\;\;\;\;-2 \cdot \frac{b\_2}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b\_2} \cdot -0.5\\
\end{array}
\end{array}
if b_2 < -4.999999999999985e-310Initial program 76.2%
Taylor expanded in b_2 around -inf
lower-*.f64N/A
lower-/.f6471.2
Applied rewrites71.2%
if -4.999999999999985e-310 < b_2 Initial program 33.5%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6466.9
Applied rewrites66.9%
(FPCore (a b_2 c) :precision binary64 (* -2.0 (/ b_2 a)))
double code(double a, double b_2, double c) {
return -2.0 * (b_2 / 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_2, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
code = (-2.0d0) * (b_2 / a)
end function
public static double code(double a, double b_2, double c) {
return -2.0 * (b_2 / a);
}
def code(a, b_2, c): return -2.0 * (b_2 / a)
function code(a, b_2, c) return Float64(-2.0 * Float64(b_2 / a)) end
function tmp = code(a, b_2, c) tmp = -2.0 * (b_2 / a); end
code[a_, b$95$2_, c_] := N[(-2.0 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-2 \cdot \frac{b\_2}{a}
\end{array}
Initial program 54.2%
Taylor expanded in b_2 around -inf
lower-*.f64N/A
lower-/.f6436.2
Applied rewrites36.2%
(FPCore (a b_2 c) :precision binary64 (/ (- b_2) a))
double code(double a, double b_2, double c) {
return -b_2 / 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_2, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
code = -b_2 / a
end function
public static double code(double a, double b_2, double c) {
return -b_2 / a;
}
def code(a, b_2, c): return -b_2 / a
function code(a, b_2, c) return Float64(Float64(-b_2) / a) end
function tmp = code(a, b_2, c) tmp = -b_2 / a; end
code[a_, b$95$2_, c_] := N[((-b$95$2) / a), $MachinePrecision]
\begin{array}{l}
\\
\frac{-b\_2}{a}
\end{array}
Initial program 54.2%
Taylor expanded in c around -inf
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-+.f64N/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6415.7
Applied rewrites15.7%
Taylor expanded in b_2 around inf
mul-1-negN/A
lift-neg.f6414.6
Applied rewrites14.6%
herbie shell --seed 2025058
(FPCore (a b_2 c)
:name "quad2p (problem 3.2.1, positive)"
:precision binary64
:herbie-expected 10
:alt
(! :herbie-platform default (let ((sqtD (let ((x (* (sqrt (fabs a)) (sqrt (fabs c))))) (if (== (copysign a c) a) (* (sqrt (- (fabs b_2) x)) (sqrt (+ (fabs b_2) x))) (hypot b_2 x))))) (if (< b_2 0) (/ (- sqtD b_2) a) (/ (- c) (+ b_2 sqtD)))))
(/ (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))