
(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}
Herbie found 11 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 -1.15e+115)
(/ (* -2.0 b_2) a)
(if (<= b_2 4.5e-50)
(+ (/ (- b_2) a) (/ (sqrt (fma (- a) c (* b_2 b_2))) a))
(* (/ c b_2) -0.5))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -1.15e+115) {
tmp = (-2.0 * b_2) / a;
} else if (b_2 <= 4.5e-50) {
tmp = (-b_2 / a) + (sqrt(fma(-a, c, (b_2 * b_2))) / a);
} else {
tmp = (c / b_2) * -0.5;
}
return tmp;
}
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -1.15e+115) tmp = Float64(Float64(-2.0 * b_2) / a); elseif (b_2 <= 4.5e-50) tmp = Float64(Float64(Float64(-b_2) / a) + Float64(sqrt(fma(Float64(-a), c, Float64(b_2 * b_2))) / a)); else tmp = Float64(Float64(c / b_2) * -0.5); end return tmp end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -1.15e+115], N[(N[(-2.0 * b$95$2), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b$95$2, 4.5e-50], N[(N[((-b$95$2) / a), $MachinePrecision] + N[(N[Sqrt[N[((-a) * c + N[(b$95$2 * b$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b$95$2), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b\_2 \leq -1.15 \cdot 10^{+115}:\\
\;\;\;\;\frac{-2 \cdot b\_2}{a}\\
\mathbf{elif}\;b\_2 \leq 4.5 \cdot 10^{-50}:\\
\;\;\;\;\frac{-b\_2}{a} + \frac{\sqrt{\mathsf{fma}\left(-a, c, b\_2 \cdot b\_2\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b\_2} \cdot -0.5\\
\end{array}
\end{array}
if b_2 < -1.15000000000000002e115Initial program 48.6%
Taylor expanded in b_2 around -inf
lower-*.f6496.3
Applied rewrites96.3%
if -1.15000000000000002e115 < b_2 < 4.49999999999999962e-50Initial program 78.8%
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 rewrites78.8%
if 4.49999999999999962e-50 < b_2 Initial program 16.6%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6486.7
Applied rewrites86.7%
(FPCore (a b_2 c)
:precision binary64
(if (<= b_2 -1.15e+115)
(/ (* -2.0 b_2) a)
(if (<= b_2 4.5e-50)
(/ (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a)
(* (/ c b_2) -0.5))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -1.15e+115) {
tmp = (-2.0 * b_2) / a;
} else if (b_2 <= 4.5e-50) {
tmp = (-b_2 + sqrt(((b_2 * b_2) - (a * c)))) / 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 <= (-1.15d+115)) then
tmp = ((-2.0d0) * b_2) / a
else if (b_2 <= 4.5d-50) then
tmp = (-b_2 + sqrt(((b_2 * b_2) - (a * c)))) / 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 <= -1.15e+115) {
tmp = (-2.0 * b_2) / a;
} else if (b_2 <= 4.5e-50) {
tmp = (-b_2 + Math.sqrt(((b_2 * b_2) - (a * c)))) / a;
} else {
tmp = (c / b_2) * -0.5;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -1.15e+115: tmp = (-2.0 * b_2) / a elif b_2 <= 4.5e-50: tmp = (-b_2 + math.sqrt(((b_2 * b_2) - (a * c)))) / a else: tmp = (c / b_2) * -0.5 return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -1.15e+115) tmp = Float64(Float64(-2.0 * b_2) / a); elseif (b_2 <= 4.5e-50) tmp = Float64(Float64(Float64(-b_2) + sqrt(Float64(Float64(b_2 * b_2) - Float64(a * c)))) / 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 <= -1.15e+115) tmp = (-2.0 * b_2) / a; elseif (b_2 <= 4.5e-50) tmp = (-b_2 + sqrt(((b_2 * b_2) - (a * c)))) / a; else tmp = (c / b_2) * -0.5; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -1.15e+115], N[(N[(-2.0 * b$95$2), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b$95$2, 4.5e-50], 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], N[(N[(c / b$95$2), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b\_2 \leq -1.15 \cdot 10^{+115}:\\
\;\;\;\;\frac{-2 \cdot b\_2}{a}\\
\mathbf{elif}\;b\_2 \leq 4.5 \cdot 10^{-50}:\\
\;\;\;\;\frac{\left(-b\_2\right) + \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b\_2} \cdot -0.5\\
\end{array}
\end{array}
if b_2 < -1.15000000000000002e115Initial program 48.6%
Taylor expanded in b_2 around -inf
lower-*.f6496.3
Applied rewrites96.3%
if -1.15000000000000002e115 < b_2 < 4.49999999999999962e-50Initial program 78.8%
if 4.49999999999999962e-50 < b_2 Initial program 16.6%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6486.7
Applied rewrites86.7%
(FPCore (a b_2 c)
:precision binary64
(if (<= b_2 -5.9e-114)
(/ (fma (* (/ c b_2) a) 0.5 (* -2.0 b_2)) a)
(if (<= b_2 4.5e-50)
(/ (+ (- b_2) (sqrt (* (- a) c))) a)
(* (/ c b_2) -0.5))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -5.9e-114) {
tmp = fma(((c / b_2) * a), 0.5, (-2.0 * b_2)) / a;
} else if (b_2 <= 4.5e-50) {
tmp = (-b_2 + sqrt((-a * c))) / a;
} else {
tmp = (c / b_2) * -0.5;
}
return tmp;
}
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -5.9e-114) tmp = Float64(fma(Float64(Float64(c / b_2) * a), 0.5, Float64(-2.0 * b_2)) / a); elseif (b_2 <= 4.5e-50) tmp = Float64(Float64(Float64(-b_2) + sqrt(Float64(Float64(-a) * c))) / a); else tmp = Float64(Float64(c / b_2) * -0.5); end return tmp end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -5.9e-114], N[(N[(N[(N[(c / b$95$2), $MachinePrecision] * a), $MachinePrecision] * 0.5 + N[(-2.0 * b$95$2), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b$95$2, 4.5e-50], N[(N[((-b$95$2) + N[Sqrt[N[((-a) * c), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(N[(c / b$95$2), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b\_2 \leq -5.9 \cdot 10^{-114}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{c}{b\_2} \cdot a, 0.5, -2 \cdot b\_2\right)}{a}\\
\mathbf{elif}\;b\_2 \leq 4.5 \cdot 10^{-50}:\\
\;\;\;\;\frac{\left(-b\_2\right) + \sqrt{\left(-a\right) \cdot c}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b\_2} \cdot -0.5\\
\end{array}
\end{array}
if b_2 < -5.9000000000000001e-114Initial program 69.5%
Taylor expanded in b_2 around -inf
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lift-neg.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f6483.0
Applied rewrites83.0%
Taylor expanded in a around 0
+-commutativeN/A
associate-*r/N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
lower-*.f6483.1
Applied rewrites83.1%
if -5.9000000000000001e-114 < b_2 < 4.49999999999999962e-50Initial program 70.0%
Taylor expanded in a around inf
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f6467.3
Applied rewrites67.3%
if 4.49999999999999962e-50 < b_2 Initial program 16.6%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6486.7
Applied rewrites86.7%
(FPCore (a b_2 c)
:precision binary64
(if (<= b_2 -5.9e-114)
(/ (* -2.0 b_2) a)
(if (<= b_2 4.5e-50)
(/ (+ (- b_2) (sqrt (* (- a) c))) a)
(* (/ c b_2) -0.5))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -5.9e-114) {
tmp = (-2.0 * b_2) / a;
} else if (b_2 <= 4.5e-50) {
tmp = (-b_2 + sqrt((-a * c))) / 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 <= (-5.9d-114)) then
tmp = ((-2.0d0) * b_2) / a
else if (b_2 <= 4.5d-50) then
tmp = (-b_2 + sqrt((-a * c))) / 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 <= -5.9e-114) {
tmp = (-2.0 * b_2) / a;
} else if (b_2 <= 4.5e-50) {
tmp = (-b_2 + Math.sqrt((-a * c))) / a;
} else {
tmp = (c / b_2) * -0.5;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -5.9e-114: tmp = (-2.0 * b_2) / a elif b_2 <= 4.5e-50: tmp = (-b_2 + math.sqrt((-a * c))) / a else: tmp = (c / b_2) * -0.5 return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -5.9e-114) tmp = Float64(Float64(-2.0 * b_2) / a); elseif (b_2 <= 4.5e-50) tmp = Float64(Float64(Float64(-b_2) + sqrt(Float64(Float64(-a) * c))) / 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 <= -5.9e-114) tmp = (-2.0 * b_2) / a; elseif (b_2 <= 4.5e-50) tmp = (-b_2 + sqrt((-a * c))) / a; else tmp = (c / b_2) * -0.5; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -5.9e-114], N[(N[(-2.0 * b$95$2), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b$95$2, 4.5e-50], N[(N[((-b$95$2) + N[Sqrt[N[((-a) * c), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(N[(c / b$95$2), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b\_2 \leq -5.9 \cdot 10^{-114}:\\
\;\;\;\;\frac{-2 \cdot b\_2}{a}\\
\mathbf{elif}\;b\_2 \leq 4.5 \cdot 10^{-50}:\\
\;\;\;\;\frac{\left(-b\_2\right) + \sqrt{\left(-a\right) \cdot c}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b\_2} \cdot -0.5\\
\end{array}
\end{array}
if b_2 < -5.9000000000000001e-114Initial program 69.5%
Taylor expanded in b_2 around -inf
lower-*.f6482.7
Applied rewrites82.7%
if -5.9000000000000001e-114 < b_2 < 4.49999999999999962e-50Initial program 70.0%
Taylor expanded in a around inf
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f6467.3
Applied rewrites67.3%
if 4.49999999999999962e-50 < b_2 Initial program 16.6%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6486.7
Applied rewrites86.7%
(FPCore (a b_2 c)
:precision binary64
(let* ((t_0 (sqrt (/ (- c) a))))
(if (<= b_2 -5.5e-167)
(/ (* -2.0 b_2) a)
(if (<= b_2 -7e-247)
(- t_0)
(if (<= b_2 1.45e-133) t_0 (* (/ c b_2) -0.5))))))
double code(double a, double b_2, double c) {
double t_0 = sqrt((-c / a));
double tmp;
if (b_2 <= -5.5e-167) {
tmp = (-2.0 * b_2) / a;
} else if (b_2 <= -7e-247) {
tmp = -t_0;
} else if (b_2 <= 1.45e-133) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = sqrt((-c / a))
if (b_2 <= (-5.5d-167)) then
tmp = ((-2.0d0) * b_2) / a
else if (b_2 <= (-7d-247)) then
tmp = -t_0
else if (b_2 <= 1.45d-133) then
tmp = t_0
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 t_0 = Math.sqrt((-c / a));
double tmp;
if (b_2 <= -5.5e-167) {
tmp = (-2.0 * b_2) / a;
} else if (b_2 <= -7e-247) {
tmp = -t_0;
} else if (b_2 <= 1.45e-133) {
tmp = t_0;
} else {
tmp = (c / b_2) * -0.5;
}
return tmp;
}
def code(a, b_2, c): t_0 = math.sqrt((-c / a)) tmp = 0 if b_2 <= -5.5e-167: tmp = (-2.0 * b_2) / a elif b_2 <= -7e-247: tmp = -t_0 elif b_2 <= 1.45e-133: tmp = t_0 else: tmp = (c / b_2) * -0.5 return tmp
function code(a, b_2, c) t_0 = sqrt(Float64(Float64(-c) / a)) tmp = 0.0 if (b_2 <= -5.5e-167) tmp = Float64(Float64(-2.0 * b_2) / a); elseif (b_2 <= -7e-247) tmp = Float64(-t_0); elseif (b_2 <= 1.45e-133) tmp = t_0; else tmp = Float64(Float64(c / b_2) * -0.5); end return tmp end
function tmp_2 = code(a, b_2, c) t_0 = sqrt((-c / a)); tmp = 0.0; if (b_2 <= -5.5e-167) tmp = (-2.0 * b_2) / a; elseif (b_2 <= -7e-247) tmp = -t_0; elseif (b_2 <= 1.45e-133) tmp = t_0; else tmp = (c / b_2) * -0.5; 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, -5.5e-167], N[(N[(-2.0 * b$95$2), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b$95$2, -7e-247], (-t$95$0), If[LessEqual[b$95$2, 1.45e-133], t$95$0, N[(N[(c / b$95$2), $MachinePrecision] * -0.5), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\frac{-c}{a}}\\
\mathbf{if}\;b\_2 \leq -5.5 \cdot 10^{-167}:\\
\;\;\;\;\frac{-2 \cdot b\_2}{a}\\
\mathbf{elif}\;b\_2 \leq -7 \cdot 10^{-247}:\\
\;\;\;\;-t\_0\\
\mathbf{elif}\;b\_2 \leq 1.45 \cdot 10^{-133}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b\_2} \cdot -0.5\\
\end{array}
\end{array}
if b_2 < -5.5000000000000003e-167Initial program 70.7%
Taylor expanded in b_2 around -inf
lower-*.f6478.2
Applied rewrites78.2%
if -5.5000000000000003e-167 < b_2 < -6.9999999999999998e-247Initial program 77.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 rewrites77.0%
Taylor expanded in a around -inf
div-add-revN/A
lift-neg.f64N/A
lift-*.f64N/A
pow2N/A
+-commutativeN/A
lift-*.f64N/A
lift-neg.f64N/A
fp-cancel-sub-sign-invN/A
pow2N/A
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
Applied rewrites31.3%
if -6.9999999999999998e-247 < b_2 < 1.4499999999999999e-133Initial program 71.5%
Taylor expanded in a around inf
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6438.5
Applied rewrites38.5%
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6438.5
Applied rewrites38.5%
if 1.4499999999999999e-133 < b_2 Initial program 22.0%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6480.4
Applied rewrites80.4%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -5.9e-114) (/ (* -2.0 b_2) a) (if (<= b_2 4.5e-50) (/ (sqrt (* (- a) c)) a) (* (/ c b_2) -0.5))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -5.9e-114) {
tmp = (-2.0 * b_2) / a;
} else if (b_2 <= 4.5e-50) {
tmp = sqrt((-a * c)) / 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 <= (-5.9d-114)) then
tmp = ((-2.0d0) * b_2) / a
else if (b_2 <= 4.5d-50) then
tmp = sqrt((-a * c)) / 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 <= -5.9e-114) {
tmp = (-2.0 * b_2) / a;
} else if (b_2 <= 4.5e-50) {
tmp = Math.sqrt((-a * c)) / a;
} else {
tmp = (c / b_2) * -0.5;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -5.9e-114: tmp = (-2.0 * b_2) / a elif b_2 <= 4.5e-50: tmp = math.sqrt((-a * c)) / a else: tmp = (c / b_2) * -0.5 return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -5.9e-114) tmp = Float64(Float64(-2.0 * b_2) / a); elseif (b_2 <= 4.5e-50) tmp = Float64(sqrt(Float64(Float64(-a) * c)) / 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 <= -5.9e-114) tmp = (-2.0 * b_2) / a; elseif (b_2 <= 4.5e-50) tmp = sqrt((-a * c)) / a; else tmp = (c / b_2) * -0.5; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -5.9e-114], N[(N[(-2.0 * b$95$2), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b$95$2, 4.5e-50], N[(N[Sqrt[N[((-a) * c), $MachinePrecision]], $MachinePrecision] / a), $MachinePrecision], N[(N[(c / b$95$2), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b\_2 \leq -5.9 \cdot 10^{-114}:\\
\;\;\;\;\frac{-2 \cdot b\_2}{a}\\
\mathbf{elif}\;b\_2 \leq 4.5 \cdot 10^{-50}:\\
\;\;\;\;\frac{\sqrt{\left(-a\right) \cdot c}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b\_2} \cdot -0.5\\
\end{array}
\end{array}
if b_2 < -5.9000000000000001e-114Initial program 69.5%
Taylor expanded in b_2 around -inf
lower-*.f6482.7
Applied rewrites82.7%
if -5.9000000000000001e-114 < b_2 < 4.49999999999999962e-50Initial program 70.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.f6466.5
Applied rewrites66.5%
if 4.49999999999999962e-50 < b_2 Initial program 16.6%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6486.7
Applied rewrites86.7%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -6.4e-239) (/ (* -2.0 b_2) a) (if (<= b_2 1.45e-133) (sqrt (/ (- c) a)) (* (/ c b_2) -0.5))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -6.4e-239) {
tmp = (-2.0 * b_2) / a;
} else if (b_2 <= 1.45e-133) {
tmp = sqrt((-c / 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 <= (-6.4d-239)) then
tmp = ((-2.0d0) * b_2) / a
else if (b_2 <= 1.45d-133) then
tmp = sqrt((-c / 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 <= -6.4e-239) {
tmp = (-2.0 * b_2) / a;
} else if (b_2 <= 1.45e-133) {
tmp = Math.sqrt((-c / a));
} else {
tmp = (c / b_2) * -0.5;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -6.4e-239: tmp = (-2.0 * b_2) / a elif b_2 <= 1.45e-133: tmp = math.sqrt((-c / a)) else: tmp = (c / b_2) * -0.5 return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -6.4e-239) tmp = Float64(Float64(-2.0 * b_2) / a); elseif (b_2 <= 1.45e-133) tmp = sqrt(Float64(Float64(-c) / 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 <= -6.4e-239) tmp = (-2.0 * b_2) / a; elseif (b_2 <= 1.45e-133) tmp = sqrt((-c / a)); else tmp = (c / b_2) * -0.5; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -6.4e-239], N[(N[(-2.0 * b$95$2), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b$95$2, 1.45e-133], N[Sqrt[N[((-c) / a), $MachinePrecision]], $MachinePrecision], N[(N[(c / b$95$2), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b\_2 \leq -6.4 \cdot 10^{-239}:\\
\;\;\;\;\frac{-2 \cdot b\_2}{a}\\
\mathbf{elif}\;b\_2 \leq 1.45 \cdot 10^{-133}:\\
\;\;\;\;\sqrt{\frac{-c}{a}}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b\_2} \cdot -0.5\\
\end{array}
\end{array}
if b_2 < -6.3999999999999998e-239Initial program 71.3%
Taylor expanded in b_2 around -inf
lower-*.f6472.3
Applied rewrites72.3%
if -6.3999999999999998e-239 < b_2 < 1.4499999999999999e-133Initial program 71.7%
Taylor expanded in a around inf
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6439.2
Applied rewrites39.2%
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6439.2
Applied rewrites39.2%
if 1.4499999999999999e-133 < b_2 Initial program 22.0%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6480.4
Applied rewrites80.4%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -4e-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 <= -4e-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 <= (-4d-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 <= -4e-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 <= -4e-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 <= -4e-310) tmp = Float64(Float64(-2.0 * 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 <= -4e-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, -4e-310], N[(N[(-2.0 * b$95$2), $MachinePrecision] / a), $MachinePrecision], N[(N[(c / b$95$2), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b\_2 \leq -4 \cdot 10^{-310}:\\
\;\;\;\;\frac{-2 \cdot b\_2}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b\_2} \cdot -0.5\\
\end{array}
\end{array}
if b_2 < -3.999999999999988e-310Initial program 71.7%
Taylor expanded in b_2 around -inf
lower-*.f6467.4
Applied rewrites67.4%
if -3.999999999999988e-310 < b_2 Initial program 31.6%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6467.2
Applied rewrites67.2%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -4e-310) (/ (- b_2) a) (* (/ c b_2) -0.5)))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -4e-310) {
tmp = -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 <= (-4d-310)) then
tmp = -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 <= -4e-310) {
tmp = -b_2 / a;
} else {
tmp = (c / b_2) * -0.5;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -4e-310: tmp = -b_2 / a else: tmp = (c / b_2) * -0.5 return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -4e-310) tmp = Float64(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 <= -4e-310) tmp = -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, -4e-310], N[((-b$95$2) / a), $MachinePrecision], N[(N[(c / b$95$2), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b\_2 \leq -4 \cdot 10^{-310}:\\
\;\;\;\;\frac{-b\_2}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b\_2} \cdot -0.5\\
\end{array}
\end{array}
if b_2 < -3.999999999999988e-310Initial program 71.7%
Taylor expanded in a around -inf
*-commutativeN/A
lower-fma.f64N/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f64N/A
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lift-neg.f6424.8
Applied rewrites24.8%
Taylor expanded in b_2 around inf
mul-1-negN/A
distribute-frac-negN/A
lift-/.f64N/A
lift-neg.f6426.9
Applied rewrites26.9%
if -3.999999999999988e-310 < b_2 Initial program 31.6%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6467.2
Applied rewrites67.2%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -4e-310) (/ (- b_2) a) (* (/ -0.5 b_2) c)))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -4e-310) {
tmp = -b_2 / a;
} else {
tmp = (-0.5 / b_2) * 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_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 <= (-4d-310)) then
tmp = -b_2 / a
else
tmp = ((-0.5d0) / b_2) * c
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -4e-310) {
tmp = -b_2 / a;
} else {
tmp = (-0.5 / b_2) * c;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -4e-310: tmp = -b_2 / a else: tmp = (-0.5 / b_2) * c return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -4e-310) tmp = Float64(Float64(-b_2) / a); else tmp = Float64(Float64(-0.5 / b_2) * c); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -4e-310) tmp = -b_2 / a; else tmp = (-0.5 / b_2) * c; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -4e-310], N[((-b$95$2) / a), $MachinePrecision], N[(N[(-0.5 / b$95$2), $MachinePrecision] * c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b\_2 \leq -4 \cdot 10^{-310}:\\
\;\;\;\;\frac{-b\_2}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.5}{b\_2} \cdot c\\
\end{array}
\end{array}
if b_2 < -3.999999999999988e-310Initial program 71.7%
Taylor expanded in a around -inf
*-commutativeN/A
lower-fma.f64N/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f64N/A
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lift-neg.f6424.8
Applied rewrites24.8%
Taylor expanded in b_2 around inf
mul-1-negN/A
distribute-frac-negN/A
lift-/.f64N/A
lift-neg.f6426.9
Applied rewrites26.9%
if -3.999999999999988e-310 < b_2 Initial program 31.6%
Taylor expanded in c around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow3N/A
pow2N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f6459.5
Applied rewrites59.5%
Taylor expanded in a around 0
lower-/.f6467.0
Applied rewrites67.0%
(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 51.3%
Taylor expanded in a around -inf
*-commutativeN/A
lower-fma.f64N/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f64N/A
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lift-neg.f6419.4
Applied rewrites19.4%
Taylor expanded in b_2 around inf
mul-1-negN/A
distribute-frac-negN/A
lift-/.f64N/A
lift-neg.f6414.6
Applied rewrites14.6%
herbie shell --seed 2025092
(FPCore (a b_2 c)
:name "quad2p (problem 3.2.1, positive)"
:precision binary64
:herbie-expected 10
(/ (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))