
(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(Float64(4.0 * 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[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\end{array}
Herbie found 9 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(Float64(4.0 * 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[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\end{array}
(FPCore (a b c)
:precision binary64
(if (<= b -1.06e+95)
(/ (- b) a)
(if (<= b 9e-85)
(/ (+ (sqrt (fma (* -4.0 a) c (* b b))) (- b)) (+ a a))
(- (/ (* (fma a (/ c (* b b)) 1.0) c) b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.06e+95) {
tmp = -b / a;
} else if (b <= 9e-85) {
tmp = (sqrt(fma((-4.0 * a), c, (b * b))) + -b) / (a + a);
} else {
tmp = -((fma(a, (c / (b * b)), 1.0) * c) / b);
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -1.06e+95) tmp = Float64(Float64(-b) / a); elseif (b <= 9e-85) tmp = Float64(Float64(sqrt(fma(Float64(-4.0 * a), c, Float64(b * b))) + Float64(-b)) / Float64(a + a)); else tmp = Float64(-Float64(Float64(fma(a, Float64(c / Float64(b * b)), 1.0) * c) / b)); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -1.06e+95], N[((-b) / a), $MachinePrecision], If[LessEqual[b, 9e-85], N[(N[(N[Sqrt[N[(N[(-4.0 * a), $MachinePrecision] * c + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + (-b)), $MachinePrecision] / N[(a + a), $MachinePrecision]), $MachinePrecision], (-N[(N[(N[(a * N[(c / N[(b * b), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * c), $MachinePrecision] / b), $MachinePrecision])]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.06 \cdot 10^{+95}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{elif}\;b \leq 9 \cdot 10^{-85}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(-4 \cdot a, c, b \cdot b\right)} + \left(-b\right)}{a + a}\\
\mathbf{else}:\\
\;\;\;\;-\frac{\mathsf{fma}\left(a, \frac{c}{b \cdot b}, 1\right) \cdot c}{b}\\
\end{array}
\end{array}
if b < -1.06000000000000001e95Initial program 52.4%
Taylor expanded in b around -inf
associate-*r/N/A
mul-1-negN/A
lift-neg.f64N/A
lower-/.f6495.9
Applied rewrites95.9%
if -1.06000000000000001e95 < b < 9.00000000000000008e-85Initial program 80.6%
Applied rewrites80.6%
if 9.00000000000000008e-85 < b Initial program 17.3%
Applied rewrites17.4%
Taylor expanded in a around 0
distribute-lft-outN/A
*-commutativeN/A
pow2N/A
lift-*.f64N/A
lift-*.f64N/A
pow3N/A
pow2N/A
associate-/r*N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
*-commutativeN/A
div-addN/A
mul-1-negN/A
Applied rewrites69.9%
Taylor expanded in c around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f6485.6
Applied rewrites85.6%
(FPCore (a b c)
:precision binary64
(if (<= b -5.5e-48)
(/ (- b) a)
(if (<= b 9e-85)
(* (- c) (sqrt (/ (/ -1.0 a) c)))
(- (/ (* (fma a (/ c (* b b)) 1.0) c) b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5.5e-48) {
tmp = -b / a;
} else if (b <= 9e-85) {
tmp = -c * sqrt(((-1.0 / a) / c));
} else {
tmp = -((fma(a, (c / (b * b)), 1.0) * c) / b);
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -5.5e-48) tmp = Float64(Float64(-b) / a); elseif (b <= 9e-85) tmp = Float64(Float64(-c) * sqrt(Float64(Float64(-1.0 / a) / c))); else tmp = Float64(-Float64(Float64(fma(a, Float64(c / Float64(b * b)), 1.0) * c) / b)); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -5.5e-48], N[((-b) / a), $MachinePrecision], If[LessEqual[b, 9e-85], N[((-c) * N[Sqrt[N[(N[(-1.0 / a), $MachinePrecision] / c), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], (-N[(N[(N[(a * N[(c / N[(b * b), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * c), $MachinePrecision] / b), $MachinePrecision])]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5.5 \cdot 10^{-48}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{elif}\;b \leq 9 \cdot 10^{-85}:\\
\;\;\;\;\left(-c\right) \cdot \sqrt{\frac{\frac{-1}{a}}{c}}\\
\mathbf{else}:\\
\;\;\;\;-\frac{\mathsf{fma}\left(a, \frac{c}{b \cdot b}, 1\right) \cdot c}{b}\\
\end{array}
\end{array}
if b < -5.50000000000000047e-48Initial program 66.2%
Taylor expanded in b around -inf
associate-*r/N/A
mul-1-negN/A
lift-neg.f64N/A
lower-/.f6488.1
Applied rewrites88.1%
if -5.50000000000000047e-48 < b < 9.00000000000000008e-85Initial program 76.2%
Applied rewrites76.2%
Taylor expanded in c around -inf
associate-*r*N/A
mul-1-negN/A
lift-neg.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6465.9
Applied rewrites65.9%
Taylor expanded in a around inf
*-commutativeN/A
sqrt-prodN/A
lower-sqrt.f64N/A
associate-*l/N/A
metadata-evalN/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lift-*.f6465.7
Applied rewrites65.7%
lift-*.f64N/A
*-commutativeN/A
lower-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6466.2
Applied rewrites66.2%
if 9.00000000000000008e-85 < b Initial program 17.3%
Applied rewrites17.4%
Taylor expanded in a around 0
distribute-lft-outN/A
*-commutativeN/A
pow2N/A
lift-*.f64N/A
lift-*.f64N/A
pow3N/A
pow2N/A
associate-/r*N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
*-commutativeN/A
div-addN/A
mul-1-negN/A
Applied rewrites69.9%
Taylor expanded in c around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f6485.6
Applied rewrites85.6%
(FPCore (a b c) :precision binary64 (if (<= b -5.5e-48) (/ (- b) a) (if (<= b 9e-85) (* (- c) (sqrt (/ (/ -1.0 a) c))) (/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5.5e-48) {
tmp = -b / a;
} else if (b <= 9e-85) {
tmp = -c * sqrt(((-1.0 / a) / c));
} else {
tmp = -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 <= (-5.5d-48)) then
tmp = -b / a
else if (b <= 9d-85) then
tmp = -c * sqrt((((-1.0d0) / a) / c))
else
tmp = -c / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -5.5e-48) {
tmp = -b / a;
} else if (b <= 9e-85) {
tmp = -c * Math.sqrt(((-1.0 / a) / c));
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5.5e-48: tmp = -b / a elif b <= 9e-85: tmp = -c * math.sqrt(((-1.0 / a) / c)) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5.5e-48) tmp = Float64(Float64(-b) / a); elseif (b <= 9e-85) tmp = Float64(Float64(-c) * sqrt(Float64(Float64(-1.0 / a) / c))); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5.5e-48) tmp = -b / a; elseif (b <= 9e-85) tmp = -c * sqrt(((-1.0 / a) / c)); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5.5e-48], N[((-b) / a), $MachinePrecision], If[LessEqual[b, 9e-85], N[((-c) * N[Sqrt[N[(N[(-1.0 / a), $MachinePrecision] / c), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5.5 \cdot 10^{-48}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{elif}\;b \leq 9 \cdot 10^{-85}:\\
\;\;\;\;\left(-c\right) \cdot \sqrt{\frac{\frac{-1}{a}}{c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -5.50000000000000047e-48Initial program 66.2%
Taylor expanded in b around -inf
associate-*r/N/A
mul-1-negN/A
lift-neg.f64N/A
lower-/.f6488.1
Applied rewrites88.1%
if -5.50000000000000047e-48 < b < 9.00000000000000008e-85Initial program 76.2%
Applied rewrites76.2%
Taylor expanded in c around -inf
associate-*r*N/A
mul-1-negN/A
lift-neg.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6465.9
Applied rewrites65.9%
Taylor expanded in a around inf
*-commutativeN/A
sqrt-prodN/A
lower-sqrt.f64N/A
associate-*l/N/A
metadata-evalN/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lift-*.f6465.7
Applied rewrites65.7%
lift-*.f64N/A
*-commutativeN/A
lower-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6466.2
Applied rewrites66.2%
if 9.00000000000000008e-85 < b Initial program 17.3%
Taylor expanded in a around 0
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6486.1
Applied rewrites86.1%
(FPCore (a b c) :precision binary64 (if (<= b -5.5e-48) (/ (- b) a) (if (<= b 9e-85) (* (- c) (sqrt (/ -1.0 (* c a)))) (/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5.5e-48) {
tmp = -b / a;
} else if (b <= 9e-85) {
tmp = -c * sqrt((-1.0 / (c * a)));
} else {
tmp = -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 <= (-5.5d-48)) then
tmp = -b / a
else if (b <= 9d-85) then
tmp = -c * sqrt(((-1.0d0) / (c * a)))
else
tmp = -c / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -5.5e-48) {
tmp = -b / a;
} else if (b <= 9e-85) {
tmp = -c * Math.sqrt((-1.0 / (c * a)));
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5.5e-48: tmp = -b / a elif b <= 9e-85: tmp = -c * math.sqrt((-1.0 / (c * a))) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5.5e-48) tmp = Float64(Float64(-b) / a); elseif (b <= 9e-85) tmp = Float64(Float64(-c) * sqrt(Float64(-1.0 / Float64(c * a)))); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5.5e-48) tmp = -b / a; elseif (b <= 9e-85) tmp = -c * sqrt((-1.0 / (c * a))); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5.5e-48], N[((-b) / a), $MachinePrecision], If[LessEqual[b, 9e-85], N[((-c) * N[Sqrt[N[(-1.0 / N[(c * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5.5 \cdot 10^{-48}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{elif}\;b \leq 9 \cdot 10^{-85}:\\
\;\;\;\;\left(-c\right) \cdot \sqrt{\frac{-1}{c \cdot a}}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -5.50000000000000047e-48Initial program 66.2%
Taylor expanded in b around -inf
associate-*r/N/A
mul-1-negN/A
lift-neg.f64N/A
lower-/.f6488.1
Applied rewrites88.1%
if -5.50000000000000047e-48 < b < 9.00000000000000008e-85Initial program 76.2%
Applied rewrites76.2%
Taylor expanded in c around -inf
associate-*r*N/A
mul-1-negN/A
lift-neg.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6465.9
Applied rewrites65.9%
Taylor expanded in a around inf
*-commutativeN/A
sqrt-prodN/A
lower-sqrt.f64N/A
associate-*l/N/A
metadata-evalN/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lift-*.f6465.7
Applied rewrites65.7%
if 9.00000000000000008e-85 < b Initial program 17.3%
Taylor expanded in a around 0
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6486.1
Applied rewrites86.1%
(FPCore (a b c) :precision binary64 (if (<= b -1.35e-65) (/ (- b) a) (if (<= b 1.85e-131) (/ (sqrt (- c)) (sqrt a)) (/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.35e-65) {
tmp = -b / a;
} else if (b <= 1.85e-131) {
tmp = sqrt(-c) / sqrt(a);
} else {
tmp = -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.35d-65)) then
tmp = -b / a
else if (b <= 1.85d-131) then
tmp = sqrt(-c) / sqrt(a)
else
tmp = -c / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1.35e-65) {
tmp = -b / a;
} else if (b <= 1.85e-131) {
tmp = Math.sqrt(-c) / Math.sqrt(a);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.35e-65: tmp = -b / a elif b <= 1.85e-131: tmp = math.sqrt(-c) / math.sqrt(a) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.35e-65) tmp = Float64(Float64(-b) / a); elseif (b <= 1.85e-131) tmp = Float64(sqrt(Float64(-c)) / sqrt(a)); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.35e-65) tmp = -b / a; elseif (b <= 1.85e-131) tmp = sqrt(-c) / sqrt(a); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.35e-65], N[((-b) / a), $MachinePrecision], If[LessEqual[b, 1.85e-131], N[(N[Sqrt[(-c)], $MachinePrecision] / N[Sqrt[a], $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.35 \cdot 10^{-65}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{elif}\;b \leq 1.85 \cdot 10^{-131}:\\
\;\;\;\;\frac{\sqrt{-c}}{\sqrt{a}}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -1.3499999999999999e-65Initial program 67.0%
Taylor expanded in b around -inf
associate-*r/N/A
mul-1-negN/A
lift-neg.f64N/A
lower-/.f6486.9
Applied rewrites86.9%
if -1.3499999999999999e-65 < b < 1.8500000000000001e-131Initial program 78.1%
Taylor expanded in a around inf
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6433.5
Applied rewrites33.5%
Taylor expanded in a around -inf
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lift-/.f6432.6
Applied rewrites32.6%
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
associate-*r/N/A
mul-1-negN/A
lift-neg.f64N/A
lower-/.f6432.6
Applied rewrites32.6%
lift-sqrt.f64N/A
lift-/.f64N/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6441.1
Applied rewrites41.1%
if 1.8500000000000001e-131 < b Initial program 20.4%
Taylor expanded in a around 0
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6482.5
Applied rewrites82.5%
(FPCore (a b c) :precision binary64 (if (<= b -2.1e-138) (/ (- b) a) (if (<= b 7e-85) (- (sqrt (/ (- c) a))) (/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.1e-138) {
tmp = -b / a;
} else if (b <= 7e-85) {
tmp = -sqrt((-c / a));
} else {
tmp = -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 <= (-2.1d-138)) then
tmp = -b / a
else if (b <= 7d-85) then
tmp = -sqrt((-c / a))
else
tmp = -c / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -2.1e-138) {
tmp = -b / a;
} else if (b <= 7e-85) {
tmp = -Math.sqrt((-c / a));
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.1e-138: tmp = -b / a elif b <= 7e-85: tmp = -math.sqrt((-c / a)) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.1e-138) tmp = Float64(Float64(-b) / a); elseif (b <= 7e-85) tmp = Float64(-sqrt(Float64(Float64(-c) / a))); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2.1e-138) tmp = -b / a; elseif (b <= 7e-85) tmp = -sqrt((-c / a)); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.1e-138], N[((-b) / a), $MachinePrecision], If[LessEqual[b, 7e-85], (-N[Sqrt[N[((-c) / a), $MachinePrecision]], $MachinePrecision]), N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.1 \cdot 10^{-138}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{elif}\;b \leq 7 \cdot 10^{-85}:\\
\;\;\;\;-\sqrt{\frac{-c}{a}}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -2.09999999999999986e-138Initial program 70.0%
Taylor expanded in b around -inf
associate-*r/N/A
mul-1-negN/A
lift-neg.f64N/A
lower-/.f6480.9
Applied rewrites80.9%
if -2.09999999999999986e-138 < b < 6.99999999999999956e-85Initial program 72.6%
Applied rewrites72.6%
Taylor expanded in a around 0
mul-1-negN/A
distribute-frac-negN/A
lift-neg.f64N/A
lift-/.f6412.0
Applied rewrites12.0%
Taylor expanded in a around -inf
mul-1-negN/A
lower-neg.f64N/A
sqrt-prodN/A
*-commutativeN/A
lower-sqrt.f64N/A
associate-*r/N/A
mul-1-negN/A
lift-neg.f64N/A
lower-/.f6435.0
Applied rewrites35.0%
if 6.99999999999999956e-85 < b Initial program 17.3%
Taylor expanded in a around 0
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6486.1
Applied rewrites86.1%
(FPCore (a b c) :precision binary64 (if (<= b -6e-152) (/ (- b) a) (if (<= b 1.85e-131) (sqrt (/ (- c) a)) (/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -6e-152) {
tmp = -b / a;
} else if (b <= 1.85e-131) {
tmp = sqrt((-c / a));
} else {
tmp = -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 <= (-6d-152)) then
tmp = -b / a
else if (b <= 1.85d-131) then
tmp = sqrt((-c / a))
else
tmp = -c / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -6e-152) {
tmp = -b / a;
} else if (b <= 1.85e-131) {
tmp = Math.sqrt((-c / a));
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -6e-152: tmp = -b / a elif b <= 1.85e-131: tmp = math.sqrt((-c / a)) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -6e-152) tmp = Float64(Float64(-b) / a); elseif (b <= 1.85e-131) tmp = sqrt(Float64(Float64(-c) / a)); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -6e-152) tmp = -b / a; elseif (b <= 1.85e-131) tmp = sqrt((-c / a)); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -6e-152], N[((-b) / a), $MachinePrecision], If[LessEqual[b, 1.85e-131], N[Sqrt[N[((-c) / a), $MachinePrecision]], $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -6 \cdot 10^{-152}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{elif}\;b \leq 1.85 \cdot 10^{-131}:\\
\;\;\;\;\sqrt{\frac{-c}{a}}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -6e-152Initial program 70.4%
Taylor expanded in b around -inf
associate-*r/N/A
mul-1-negN/A
lift-neg.f64N/A
lower-/.f6479.7
Applied rewrites79.7%
if -6e-152 < b < 1.8500000000000001e-131Initial program 74.3%
Taylor expanded in a around inf
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6434.5
Applied rewrites34.5%
Taylor expanded in a around -inf
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lift-/.f6434.2
Applied rewrites34.2%
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
associate-*r/N/A
mul-1-negN/A
lift-neg.f64N/A
lower-/.f6434.2
Applied rewrites34.2%
if 1.8500000000000001e-131 < b Initial program 20.4%
Taylor expanded in a around 0
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6482.5
Applied rewrites82.5%
(FPCore (a b c) :precision binary64 (if (<= b -2e-310) (/ (- b) a) (/ (- c) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -2e-310) {
tmp = -b / a;
} else {
tmp = -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 <= (-2d-310)) then
tmp = -b / a
else
tmp = -c / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -2e-310) {
tmp = -b / a;
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2e-310: tmp = -b / a else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2e-310) tmp = Float64(Float64(-b) / a); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2e-310) tmp = -b / a; else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2e-310], N[((-b) / a), $MachinePrecision], N[((-c) / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -1.999999999999994e-310Initial program 71.6%
Taylor expanded in b around -inf
associate-*r/N/A
mul-1-negN/A
lift-neg.f64N/A
lower-/.f6467.7
Applied rewrites67.7%
if -1.999999999999994e-310 < b Initial program 31.0%
Taylor expanded in a around 0
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6468.3
Applied rewrites68.3%
(FPCore (a b c) :precision binary64 (/ (- b) a))
double code(double a, double b, double c) {
return -b / 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 / a
end function
public static double code(double a, double b, double c) {
return -b / a;
}
def code(a, b, c): return -b / a
function code(a, b, c) return Float64(Float64(-b) / a) end
function tmp = code(a, b, c) tmp = -b / a; end
code[a_, b_, c_] := N[((-b) / a), $MachinePrecision]
\begin{array}{l}
\\
\frac{-b}{a}
\end{array}
Initial program 50.9%
Taylor expanded in b around -inf
associate-*r/N/A
mul-1-negN/A
lift-neg.f64N/A
lower-/.f6434.6
Applied rewrites34.6%
herbie shell --seed 2025120
(FPCore (a b c)
:name "Quadratic roots, full range"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))