
(FPCore (a b c) :precision binary64 (/ (- (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))
double code(double a, double b, double c) {
return (-b - sqrt(((b * b) - (4.0 * (a * c))))) / (2.0 * a);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-b - sqrt(((b * b) - (4.0d0 * (a * c))))) / (2.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b - Math.sqrt(((b * b) - (4.0 * (a * c))))) / (2.0 * a);
}
def code(a, b, c): return (-b - math.sqrt(((b * b) - (4.0 * (a * c))))) / (2.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) - sqrt(Float64(Float64(b * b) - Float64(4.0 * Float64(a * c))))) / Float64(2.0 * a)) end
function tmp = code(a, b, c) tmp = (-b - sqrt(((b * b) - (4.0 * (a * c))))) / (2.0 * a); end
code[a_, b_, c_] := N[(N[((-b) - N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(4.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]
\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b c) :precision binary64 (/ (- (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))
double code(double a, double b, double c) {
return (-b - sqrt(((b * b) - (4.0 * (a * c))))) / (2.0 * a);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-b - sqrt(((b * b) - (4.0d0 * (a * c))))) / (2.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b - Math.sqrt(((b * b) - (4.0 * (a * c))))) / (2.0 * a);
}
def code(a, b, c): return (-b - math.sqrt(((b * b) - (4.0 * (a * c))))) / (2.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) - sqrt(Float64(Float64(b * b) - Float64(4.0 * Float64(a * c))))) / Float64(2.0 * a)) end
function tmp = code(a, b, c) tmp = (-b - sqrt(((b * b) - (4.0 * (a * c))))) / (2.0 * a); end
code[a_, b_, c_] := N[(N[((-b) - N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(4.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]
\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}
(FPCore (a b c)
:precision binary64
(if (<= b -0.0003)
(/ (- c) b)
(if (<= b 1.4e+48)
(/ (- (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a))
(/ (- b) a))))double code(double a, double b, double c) {
double tmp;
if (b <= -0.0003) {
tmp = -c / b;
} else if (b <= 1.4e+48) {
tmp = (-b - sqrt(((b * b) - (4.0 * (a * c))))) / (2.0 * a);
} else {
tmp = -b / a;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-0.0003d0)) then
tmp = -c / b
else if (b <= 1.4d+48) then
tmp = (-b - sqrt(((b * b) - (4.0d0 * (a * c))))) / (2.0d0 * a)
else
tmp = -b / a
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -0.0003) {
tmp = -c / b;
} else if (b <= 1.4e+48) {
tmp = (-b - Math.sqrt(((b * b) - (4.0 * (a * c))))) / (2.0 * a);
} else {
tmp = -b / a;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -0.0003: tmp = -c / b elif b <= 1.4e+48: tmp = (-b - math.sqrt(((b * b) - (4.0 * (a * c))))) / (2.0 * a) else: tmp = -b / a return tmp
function code(a, b, c) tmp = 0.0 if (b <= -0.0003) tmp = Float64(Float64(-c) / b); elseif (b <= 1.4e+48) tmp = Float64(Float64(Float64(-b) - sqrt(Float64(Float64(b * b) - Float64(4.0 * Float64(a * c))))) / Float64(2.0 * a)); else tmp = Float64(Float64(-b) / a); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -0.0003) tmp = -c / b; elseif (b <= 1.4e+48) tmp = (-b - sqrt(((b * b) - (4.0 * (a * c))))) / (2.0 * a); else tmp = -b / a; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -0.0003], N[((-c) / b), $MachinePrecision], If[LessEqual[b, 1.4e+48], N[(N[((-b) - N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(4.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[((-b) / a), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;b \leq -0.0003:\\
\;\;\;\;\frac{-c}{b}\\
\mathbf{elif}\;b \leq 1.4 \cdot 10^{+48}:\\
\;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-b}{a}\\
\end{array}
if b < -2.9999999999999997e-4Initial program 52.5%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6435.1%
Applied rewrites35.1%
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
distribute-neg-fracN/A
lift-neg.f64N/A
lower-/.f6435.1%
Applied rewrites35.1%
if -2.9999999999999997e-4 < b < 1.4000000000000001e48Initial program 52.5%
if 1.4000000000000001e48 < b Initial program 52.5%
Taylor expanded in b around inf
lower-*.f64N/A
lower-/.f6434.9%
Applied rewrites34.9%
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
distribute-neg-fracN/A
lift-neg.f64N/A
lower-/.f6434.9%
Applied rewrites34.9%
(FPCore (a b c)
:precision binary64
(if (<= b -0.0003)
(/ (- c) b)
(if (<= b 1.4e+48)
(* (/ -0.5 a) (+ b (sqrt (- (* b b) (* (* c a) 4.0)))))
(/ (- b) a))))double code(double a, double b, double c) {
double tmp;
if (b <= -0.0003) {
tmp = -c / b;
} else if (b <= 1.4e+48) {
tmp = (-0.5 / a) * (b + sqrt(((b * b) - ((c * a) * 4.0))));
} else {
tmp = -b / a;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-0.0003d0)) then
tmp = -c / b
else if (b <= 1.4d+48) then
tmp = ((-0.5d0) / a) * (b + sqrt(((b * b) - ((c * a) * 4.0d0))))
else
tmp = -b / a
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -0.0003) {
tmp = -c / b;
} else if (b <= 1.4e+48) {
tmp = (-0.5 / a) * (b + Math.sqrt(((b * b) - ((c * a) * 4.0))));
} else {
tmp = -b / a;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -0.0003: tmp = -c / b elif b <= 1.4e+48: tmp = (-0.5 / a) * (b + math.sqrt(((b * b) - ((c * a) * 4.0)))) else: tmp = -b / a return tmp
function code(a, b, c) tmp = 0.0 if (b <= -0.0003) tmp = Float64(Float64(-c) / b); elseif (b <= 1.4e+48) tmp = Float64(Float64(-0.5 / a) * Float64(b + sqrt(Float64(Float64(b * b) - Float64(Float64(c * a) * 4.0))))); else tmp = Float64(Float64(-b) / a); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -0.0003) tmp = -c / b; elseif (b <= 1.4e+48) tmp = (-0.5 / a) * (b + sqrt(((b * b) - ((c * a) * 4.0)))); else tmp = -b / a; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -0.0003], N[((-c) / b), $MachinePrecision], If[LessEqual[b, 1.4e+48], N[(N[(-0.5 / a), $MachinePrecision] * N[(b + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(c * a), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-b) / a), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;b \leq -0.0003:\\
\;\;\;\;\frac{-c}{b}\\
\mathbf{elif}\;b \leq 1.4 \cdot 10^{+48}:\\
\;\;\;\;\frac{-0.5}{a} \cdot \left(b + \sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{-b}{a}\\
\end{array}
if b < -2.9999999999999997e-4Initial program 52.5%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6435.1%
Applied rewrites35.1%
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
distribute-neg-fracN/A
lift-neg.f64N/A
lower-/.f6435.1%
Applied rewrites35.1%
if -2.9999999999999997e-4 < b < 1.4000000000000001e48Initial program 52.5%
lift-/.f64N/A
frac-2negN/A
mult-flipN/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
associate-/r*N/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
lower-/.f64N/A
metadata-evalN/A
lift--.f64N/A
sub-negate-revN/A
sub-flipN/A
+-commutativeN/A
lower-+.f64N/A
Applied rewrites52.4%
if 1.4000000000000001e48 < b Initial program 52.5%
Taylor expanded in b around inf
lower-*.f64N/A
lower-/.f6434.9%
Applied rewrites34.9%
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
distribute-neg-fracN/A
lift-neg.f64N/A
lower-/.f6434.9%
Applied rewrites34.9%
(FPCore (a b c)
:precision binary64
(if (<= b -2.95e-34)
(/ (- c) b)
(if (<= b 5.4e-110)
(/ (- (- b) (sqrt (* (* c a) -4.0))) (+ a a))
(/ (- b) a))))double code(double a, double b, double c) {
double tmp;
if (b <= -2.95e-34) {
tmp = -c / b;
} else if (b <= 5.4e-110) {
tmp = (-b - sqrt(((c * a) * -4.0))) / (a + a);
} else {
tmp = -b / a;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-2.95d-34)) then
tmp = -c / b
else if (b <= 5.4d-110) then
tmp = (-b - sqrt(((c * a) * (-4.0d0)))) / (a + a)
else
tmp = -b / a
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -2.95e-34) {
tmp = -c / b;
} else if (b <= 5.4e-110) {
tmp = (-b - Math.sqrt(((c * a) * -4.0))) / (a + a);
} else {
tmp = -b / a;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.95e-34: tmp = -c / b elif b <= 5.4e-110: tmp = (-b - math.sqrt(((c * a) * -4.0))) / (a + a) else: tmp = -b / a return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.95e-34) tmp = Float64(Float64(-c) / b); elseif (b <= 5.4e-110) tmp = Float64(Float64(Float64(-b) - sqrt(Float64(Float64(c * a) * -4.0))) / Float64(a + a)); else tmp = Float64(Float64(-b) / a); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2.95e-34) tmp = -c / b; elseif (b <= 5.4e-110) tmp = (-b - sqrt(((c * a) * -4.0))) / (a + a); else tmp = -b / a; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.95e-34], N[((-c) / b), $MachinePrecision], If[LessEqual[b, 5.4e-110], N[(N[((-b) - N[Sqrt[N[(N[(c * a), $MachinePrecision] * -4.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(a + a), $MachinePrecision]), $MachinePrecision], N[((-b) / a), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;b \leq -2.95 \cdot 10^{-34}:\\
\;\;\;\;\frac{-c}{b}\\
\mathbf{elif}\;b \leq 5.4 \cdot 10^{-110}:\\
\;\;\;\;\frac{\left(-b\right) - \sqrt{\left(c \cdot a\right) \cdot -4}}{a + a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-b}{a}\\
\end{array}
if b < -2.9500000000000001e-34Initial program 52.5%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6435.1%
Applied rewrites35.1%
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
distribute-neg-fracN/A
lift-neg.f64N/A
lower-/.f6435.1%
Applied rewrites35.1%
if -2.9500000000000001e-34 < b < 5.3999999999999996e-110Initial program 52.5%
Taylor expanded in a around inf
lower-*.f64N/A
lower-*.f6433.8%
Applied rewrites33.8%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6433.8%
lift-*.f64N/A
*-commutativeN/A
lift-*.f6433.8%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
Applied rewrites33.8%
if 5.3999999999999996e-110 < b Initial program 52.5%
Taylor expanded in b around inf
lower-*.f64N/A
lower-/.f6434.9%
Applied rewrites34.9%
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
distribute-neg-fracN/A
lift-neg.f64N/A
lower-/.f6434.9%
Applied rewrites34.9%
(FPCore (a b c)
:precision binary64
(if (<= b -5.9e-34)
(/ (- c) b)
(if (<= b 5.4e-110)
(* -0.5 (/ (sqrt (* -4.0 (* a c))) a))
(/ (- b) a))))double code(double a, double b, double c) {
double tmp;
if (b <= -5.9e-34) {
tmp = -c / b;
} else if (b <= 5.4e-110) {
tmp = -0.5 * (sqrt((-4.0 * (a * c))) / a);
} else {
tmp = -b / a;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-5.9d-34)) then
tmp = -c / b
else if (b <= 5.4d-110) then
tmp = (-0.5d0) * (sqrt(((-4.0d0) * (a * c))) / a)
else
tmp = -b / a
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -5.9e-34) {
tmp = -c / b;
} else if (b <= 5.4e-110) {
tmp = -0.5 * (Math.sqrt((-4.0 * (a * c))) / a);
} else {
tmp = -b / a;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5.9e-34: tmp = -c / b elif b <= 5.4e-110: tmp = -0.5 * (math.sqrt((-4.0 * (a * c))) / a) else: tmp = -b / a return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5.9e-34) tmp = Float64(Float64(-c) / b); elseif (b <= 5.4e-110) tmp = Float64(-0.5 * Float64(sqrt(Float64(-4.0 * Float64(a * c))) / a)); else tmp = Float64(Float64(-b) / a); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5.9e-34) tmp = -c / b; elseif (b <= 5.4e-110) tmp = -0.5 * (sqrt((-4.0 * (a * c))) / a); else tmp = -b / a; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5.9e-34], N[((-c) / b), $MachinePrecision], If[LessEqual[b, 5.4e-110], N[(-0.5 * N[(N[Sqrt[N[(-4.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[((-b) / a), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;b \leq -5.9 \cdot 10^{-34}:\\
\;\;\;\;\frac{-c}{b}\\
\mathbf{elif}\;b \leq 5.4 \cdot 10^{-110}:\\
\;\;\;\;-0.5 \cdot \frac{\sqrt{-4 \cdot \left(a \cdot c\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-b}{a}\\
\end{array}
if b < -5.9000000000000002e-34Initial program 52.5%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6435.1%
Applied rewrites35.1%
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
distribute-neg-fracN/A
lift-neg.f64N/A
lower-/.f6435.1%
Applied rewrites35.1%
if -5.9000000000000002e-34 < b < 5.3999999999999996e-110Initial program 52.5%
Taylor expanded in a around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6417.4%
Applied rewrites17.4%
Taylor expanded in a around 0
lower-/.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-*.f6429.4%
Applied rewrites29.4%
if 5.3999999999999996e-110 < b Initial program 52.5%
Taylor expanded in b around inf
lower-*.f64N/A
lower-/.f6434.9%
Applied rewrites34.9%
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
distribute-neg-fracN/A
lift-neg.f64N/A
lower-/.f6434.9%
Applied rewrites34.9%
(FPCore (a b c) :precision binary64 (if (<= b -5.5e-73) (/ (- c) b) (if (<= b 7.5e-77) (* 0.5 (sqrt (/ (* -4.0 c) a))) (/ (- b) a))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5.5e-73) {
tmp = -c / b;
} else if (b <= 7.5e-77) {
tmp = 0.5 * sqrt(((-4.0 * c) / a));
} else {
tmp = -b / a;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-5.5d-73)) then
tmp = -c / b
else if (b <= 7.5d-77) then
tmp = 0.5d0 * sqrt((((-4.0d0) * c) / a))
else
tmp = -b / a
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -5.5e-73) {
tmp = -c / b;
} else if (b <= 7.5e-77) {
tmp = 0.5 * Math.sqrt(((-4.0 * c) / a));
} else {
tmp = -b / a;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5.5e-73: tmp = -c / b elif b <= 7.5e-77: tmp = 0.5 * math.sqrt(((-4.0 * c) / a)) else: tmp = -b / a return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5.5e-73) tmp = Float64(Float64(-c) / b); elseif (b <= 7.5e-77) tmp = Float64(0.5 * sqrt(Float64(Float64(-4.0 * c) / a))); else tmp = Float64(Float64(-b) / a); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5.5e-73) tmp = -c / b; elseif (b <= 7.5e-77) tmp = 0.5 * sqrt(((-4.0 * c) / a)); else tmp = -b / a; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5.5e-73], N[((-c) / b), $MachinePrecision], If[LessEqual[b, 7.5e-77], N[(0.5 * N[Sqrt[N[(N[(-4.0 * c), $MachinePrecision] / a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[((-b) / a), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;b \leq -5.5 \cdot 10^{-73}:\\
\;\;\;\;\frac{-c}{b}\\
\mathbf{elif}\;b \leq 7.5 \cdot 10^{-77}:\\
\;\;\;\;0.5 \cdot \sqrt{\frac{-4 \cdot c}{a}}\\
\mathbf{else}:\\
\;\;\;\;\frac{-b}{a}\\
\end{array}
if b < -5.5000000000000001e-73Initial program 52.5%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6435.1%
Applied rewrites35.1%
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
distribute-neg-fracN/A
lift-neg.f64N/A
lower-/.f6435.1%
Applied rewrites35.1%
if -5.5000000000000001e-73 < b < 7.5000000000000006e-77Initial program 52.5%
Taylor expanded in a around -inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6417.3%
Applied rewrites17.3%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f6417.3%
Applied rewrites17.3%
if 7.5000000000000006e-77 < b Initial program 52.5%
Taylor expanded in b around inf
lower-*.f64N/A
lower-/.f6434.9%
Applied rewrites34.9%
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
distribute-neg-fracN/A
lift-neg.f64N/A
lower-/.f6434.9%
Applied rewrites34.9%
(FPCore (a b c) :precision binary64 (if (<= b -5.5e-73) (/ (- c) b) (if (<= b 7.5e-77) (* 0.5 (sqrt (* (/ -4.0 a) c))) (/ (- b) a))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5.5e-73) {
tmp = -c / b;
} else if (b <= 7.5e-77) {
tmp = 0.5 * sqrt(((-4.0 / a) * c));
} else {
tmp = -b / a;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-5.5d-73)) then
tmp = -c / b
else if (b <= 7.5d-77) then
tmp = 0.5d0 * sqrt((((-4.0d0) / a) * c))
else
tmp = -b / a
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -5.5e-73) {
tmp = -c / b;
} else if (b <= 7.5e-77) {
tmp = 0.5 * Math.sqrt(((-4.0 / a) * c));
} else {
tmp = -b / a;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5.5e-73: tmp = -c / b elif b <= 7.5e-77: tmp = 0.5 * math.sqrt(((-4.0 / a) * c)) else: tmp = -b / a return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5.5e-73) tmp = Float64(Float64(-c) / b); elseif (b <= 7.5e-77) tmp = Float64(0.5 * sqrt(Float64(Float64(-4.0 / a) * c))); else tmp = Float64(Float64(-b) / a); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5.5e-73) tmp = -c / b; elseif (b <= 7.5e-77) tmp = 0.5 * sqrt(((-4.0 / a) * c)); else tmp = -b / a; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5.5e-73], N[((-c) / b), $MachinePrecision], If[LessEqual[b, 7.5e-77], N[(0.5 * N[Sqrt[N[(N[(-4.0 / a), $MachinePrecision] * c), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[((-b) / a), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;b \leq -5.5 \cdot 10^{-73}:\\
\;\;\;\;\frac{-c}{b}\\
\mathbf{elif}\;b \leq 7.5 \cdot 10^{-77}:\\
\;\;\;\;0.5 \cdot \sqrt{\frac{-4}{a} \cdot c}\\
\mathbf{else}:\\
\;\;\;\;\frac{-b}{a}\\
\end{array}
if b < -5.5000000000000001e-73Initial program 52.5%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6435.1%
Applied rewrites35.1%
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
distribute-neg-fracN/A
lift-neg.f64N/A
lower-/.f6435.1%
Applied rewrites35.1%
if -5.5000000000000001e-73 < b < 7.5000000000000006e-77Initial program 52.5%
Taylor expanded in a around -inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6417.3%
Applied rewrites17.3%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f6417.3%
Applied rewrites17.3%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6417.3%
Applied rewrites17.3%
if 7.5000000000000006e-77 < b Initial program 52.5%
Taylor expanded in b around inf
lower-*.f64N/A
lower-/.f6434.9%
Applied rewrites34.9%
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
distribute-neg-fracN/A
lift-neg.f64N/A
lower-/.f6434.9%
Applied rewrites34.9%
(FPCore (a b c) :precision binary64 (if (<= b -5.5e-73) (/ (- c) b) (if (<= b 7.5e-77) (* 0.5 (sqrt (* -4.0 (/ c a)))) (/ (- b) a))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5.5e-73) {
tmp = -c / b;
} else if (b <= 7.5e-77) {
tmp = 0.5 * sqrt((-4.0 * (c / a)));
} else {
tmp = -b / a;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-5.5d-73)) then
tmp = -c / b
else if (b <= 7.5d-77) then
tmp = 0.5d0 * sqrt(((-4.0d0) * (c / a)))
else
tmp = -b / a
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -5.5e-73) {
tmp = -c / b;
} else if (b <= 7.5e-77) {
tmp = 0.5 * Math.sqrt((-4.0 * (c / a)));
} else {
tmp = -b / a;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5.5e-73: tmp = -c / b elif b <= 7.5e-77: tmp = 0.5 * math.sqrt((-4.0 * (c / a))) else: tmp = -b / a return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5.5e-73) tmp = Float64(Float64(-c) / b); elseif (b <= 7.5e-77) tmp = Float64(0.5 * sqrt(Float64(-4.0 * Float64(c / a)))); else tmp = Float64(Float64(-b) / a); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5.5e-73) tmp = -c / b; elseif (b <= 7.5e-77) tmp = 0.5 * sqrt((-4.0 * (c / a))); else tmp = -b / a; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5.5e-73], N[((-c) / b), $MachinePrecision], If[LessEqual[b, 7.5e-77], N[(0.5 * N[Sqrt[N[(-4.0 * N[(c / a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[((-b) / a), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;b \leq -5.5 \cdot 10^{-73}:\\
\;\;\;\;\frac{-c}{b}\\
\mathbf{elif}\;b \leq 7.5 \cdot 10^{-77}:\\
\;\;\;\;0.5 \cdot \sqrt{-4 \cdot \frac{c}{a}}\\
\mathbf{else}:\\
\;\;\;\;\frac{-b}{a}\\
\end{array}
if b < -5.5000000000000001e-73Initial program 52.5%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6435.1%
Applied rewrites35.1%
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
distribute-neg-fracN/A
lift-neg.f64N/A
lower-/.f6435.1%
Applied rewrites35.1%
if -5.5000000000000001e-73 < b < 7.5000000000000006e-77Initial program 52.5%
Taylor expanded in a around -inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6417.3%
Applied rewrites17.3%
if 7.5000000000000006e-77 < b Initial program 52.5%
Taylor expanded in b around inf
lower-*.f64N/A
lower-/.f6434.9%
Applied rewrites34.9%
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
distribute-neg-fracN/A
lift-neg.f64N/A
lower-/.f6434.9%
Applied rewrites34.9%
(FPCore (a b c) :precision binary64 (if (<= b -1.9e-149) (/ (- c) b) (if (<= b 5.4e-110) (* -0.5 (sqrt (/ (* -4.0 c) a))) (/ (- b) a))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.9e-149) {
tmp = -c / b;
} else if (b <= 5.4e-110) {
tmp = -0.5 * sqrt(((-4.0 * c) / a));
} else {
tmp = -b / a;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-1.9d-149)) then
tmp = -c / b
else if (b <= 5.4d-110) then
tmp = (-0.5d0) * sqrt((((-4.0d0) * c) / a))
else
tmp = -b / a
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1.9e-149) {
tmp = -c / b;
} else if (b <= 5.4e-110) {
tmp = -0.5 * Math.sqrt(((-4.0 * c) / a));
} else {
tmp = -b / a;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.9e-149: tmp = -c / b elif b <= 5.4e-110: tmp = -0.5 * math.sqrt(((-4.0 * c) / a)) else: tmp = -b / a return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.9e-149) tmp = Float64(Float64(-c) / b); elseif (b <= 5.4e-110) tmp = Float64(-0.5 * sqrt(Float64(Float64(-4.0 * c) / a))); else tmp = Float64(Float64(-b) / a); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.9e-149) tmp = -c / b; elseif (b <= 5.4e-110) tmp = -0.5 * sqrt(((-4.0 * c) / a)); else tmp = -b / a; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.9e-149], N[((-c) / b), $MachinePrecision], If[LessEqual[b, 5.4e-110], N[(-0.5 * N[Sqrt[N[(N[(-4.0 * c), $MachinePrecision] / a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[((-b) / a), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;b \leq -1.9 \cdot 10^{-149}:\\
\;\;\;\;\frac{-c}{b}\\
\mathbf{elif}\;b \leq 5.4 \cdot 10^{-110}:\\
\;\;\;\;-0.5 \cdot \sqrt{\frac{-4 \cdot c}{a}}\\
\mathbf{else}:\\
\;\;\;\;\frac{-b}{a}\\
\end{array}
if b < -1.9e-149Initial program 52.5%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6435.1%
Applied rewrites35.1%
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
distribute-neg-fracN/A
lift-neg.f64N/A
lower-/.f6435.1%
Applied rewrites35.1%
if -1.9e-149 < b < 5.3999999999999996e-110Initial program 52.5%
Taylor expanded in a around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6417.4%
Applied rewrites17.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f6417.4%
Applied rewrites17.4%
if 5.3999999999999996e-110 < b Initial program 52.5%
Taylor expanded in b around inf
lower-*.f64N/A
lower-/.f6434.9%
Applied rewrites34.9%
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
distribute-neg-fracN/A
lift-neg.f64N/A
lower-/.f6434.9%
Applied rewrites34.9%
(FPCore (a b c) :precision binary64 (if (<= b -1.9e-149) (/ (- c) b) (if (<= b 5.4e-110) (* -0.5 (sqrt (* -4.0 (/ c a)))) (/ (- b) a))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.9e-149) {
tmp = -c / b;
} else if (b <= 5.4e-110) {
tmp = -0.5 * sqrt((-4.0 * (c / a)));
} else {
tmp = -b / a;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-1.9d-149)) then
tmp = -c / b
else if (b <= 5.4d-110) then
tmp = (-0.5d0) * sqrt(((-4.0d0) * (c / a)))
else
tmp = -b / a
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1.9e-149) {
tmp = -c / b;
} else if (b <= 5.4e-110) {
tmp = -0.5 * Math.sqrt((-4.0 * (c / a)));
} else {
tmp = -b / a;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.9e-149: tmp = -c / b elif b <= 5.4e-110: tmp = -0.5 * math.sqrt((-4.0 * (c / a))) else: tmp = -b / a return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.9e-149) tmp = Float64(Float64(-c) / b); elseif (b <= 5.4e-110) tmp = Float64(-0.5 * sqrt(Float64(-4.0 * Float64(c / a)))); else tmp = Float64(Float64(-b) / a); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.9e-149) tmp = -c / b; elseif (b <= 5.4e-110) tmp = -0.5 * sqrt((-4.0 * (c / a))); else tmp = -b / a; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.9e-149], N[((-c) / b), $MachinePrecision], If[LessEqual[b, 5.4e-110], N[(-0.5 * N[Sqrt[N[(-4.0 * N[(c / a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[((-b) / a), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;b \leq -1.9 \cdot 10^{-149}:\\
\;\;\;\;\frac{-c}{b}\\
\mathbf{elif}\;b \leq 5.4 \cdot 10^{-110}:\\
\;\;\;\;-0.5 \cdot \sqrt{-4 \cdot \frac{c}{a}}\\
\mathbf{else}:\\
\;\;\;\;\frac{-b}{a}\\
\end{array}
if b < -1.9e-149Initial program 52.5%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6435.1%
Applied rewrites35.1%
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
distribute-neg-fracN/A
lift-neg.f64N/A
lower-/.f6435.1%
Applied rewrites35.1%
if -1.9e-149 < b < 5.3999999999999996e-110Initial program 52.5%
Taylor expanded in a around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6417.4%
Applied rewrites17.4%
if 5.3999999999999996e-110 < b Initial program 52.5%
Taylor expanded in b around inf
lower-*.f64N/A
lower-/.f6434.9%
Applied rewrites34.9%
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
distribute-neg-fracN/A
lift-neg.f64N/A
lower-/.f6434.9%
Applied rewrites34.9%
(FPCore (a b c) :precision binary64 (if (<= b -5e-291) (/ (- c) b) (/ (- b) a)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-291) {
tmp = -c / b;
} else {
tmp = -b / a;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-5d-291)) then
tmp = -c / b
else
tmp = -b / a
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -5e-291) {
tmp = -c / b;
} else {
tmp = -b / a;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-291: tmp = -c / b else: tmp = -b / a return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-291) tmp = Float64(Float64(-c) / b); else tmp = Float64(Float64(-b) / a); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e-291) tmp = -c / b; else tmp = -b / a; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-291], N[((-c) / b), $MachinePrecision], N[((-b) / a), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-291}:\\
\;\;\;\;\frac{-c}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{-b}{a}\\
\end{array}
if b < -5.0000000000000003e-291Initial program 52.5%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6435.1%
Applied rewrites35.1%
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
distribute-neg-fracN/A
lift-neg.f64N/A
lower-/.f6435.1%
Applied rewrites35.1%
if -5.0000000000000003e-291 < b Initial program 52.5%
Taylor expanded in b around inf
lower-*.f64N/A
lower-/.f6434.9%
Applied rewrites34.9%
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
distribute-neg-fracN/A
lift-neg.f64N/A
lower-/.f6434.9%
Applied rewrites34.9%
(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]
\frac{-b}{a}
Initial program 52.5%
Taylor expanded in b around inf
lower-*.f64N/A
lower-/.f6434.9%
Applied rewrites34.9%
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
distribute-neg-fracN/A
lift-neg.f64N/A
lower-/.f6434.9%
Applied rewrites34.9%
herbie shell --seed 2025258
(FPCore (a b c)
:name "quadm (p42, negative)"
:precision binary64
:herbie-expected 10
(/ (- (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))