
(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]
\frac{\left(-b\_2\right) + \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a}
Herbie found 9 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]
\frac{\left(-b\_2\right) + \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a}
(FPCore (a b_2 c)
:precision binary64
(if (<=
b_2
-899999999999999946915980092523034999871946988517111352010114681811160456864717944276428980611627825091908289848159568488674963822739926718420037466981400576)
(* -2 (/ b_2 a))
(if (<=
b_2
4199521391583383/139984046386112763159840142535527767382602843577165595931249318810236991948760059086304843329475444736)
(- (/ (sqrt (- (* b_2 b_2) (* c a))) a) (/ b_2 a))
(/ 1 (* b_2 (- (* 1/2 (/ a (pow b_2 2))) (* 2 (/ 1 c))))))))double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -9e+155) {
tmp = -2.0 * (b_2 / a);
} else if (b_2 <= 3e-86) {
tmp = (sqrt(((b_2 * b_2) - (c * a))) / a) - (b_2 / a);
} else {
tmp = 1.0 / (b_2 * ((0.5 * (a / pow(b_2, 2.0))) - (2.0 * (1.0 / 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 <= (-9d+155)) then
tmp = (-2.0d0) * (b_2 / a)
else if (b_2 <= 3d-86) then
tmp = (sqrt(((b_2 * b_2) - (c * a))) / a) - (b_2 / a)
else
tmp = 1.0d0 / (b_2 * ((0.5d0 * (a / (b_2 ** 2.0d0))) - (2.0d0 * (1.0d0 / c))))
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -9e+155) {
tmp = -2.0 * (b_2 / a);
} else if (b_2 <= 3e-86) {
tmp = (Math.sqrt(((b_2 * b_2) - (c * a))) / a) - (b_2 / a);
} else {
tmp = 1.0 / (b_2 * ((0.5 * (a / Math.pow(b_2, 2.0))) - (2.0 * (1.0 / c))));
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -9e+155: tmp = -2.0 * (b_2 / a) elif b_2 <= 3e-86: tmp = (math.sqrt(((b_2 * b_2) - (c * a))) / a) - (b_2 / a) else: tmp = 1.0 / (b_2 * ((0.5 * (a / math.pow(b_2, 2.0))) - (2.0 * (1.0 / c)))) return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -9e+155) tmp = Float64(-2.0 * Float64(b_2 / a)); elseif (b_2 <= 3e-86) tmp = Float64(Float64(sqrt(Float64(Float64(b_2 * b_2) - Float64(c * a))) / a) - Float64(b_2 / a)); else tmp = Float64(1.0 / Float64(b_2 * Float64(Float64(0.5 * Float64(a / (b_2 ^ 2.0))) - Float64(2.0 * Float64(1.0 / c))))); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -9e+155) tmp = -2.0 * (b_2 / a); elseif (b_2 <= 3e-86) tmp = (sqrt(((b_2 * b_2) - (c * a))) / a) - (b_2 / a); else tmp = 1.0 / (b_2 * ((0.5 * (a / (b_2 ^ 2.0))) - (2.0 * (1.0 / c)))); end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -899999999999999946915980092523034999871946988517111352010114681811160456864717944276428980611627825091908289848159568488674963822739926718420037466981400576], N[(-2 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, 4199521391583383/139984046386112763159840142535527767382602843577165595931249318810236991948760059086304843329475444736], N[(N[(N[Sqrt[N[(N[(b$95$2 * b$95$2), $MachinePrecision] - N[(c * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / a), $MachinePrecision] - N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision], N[(1 / N[(b$95$2 * N[(N[(1/2 * N[(a / N[Power[b$95$2, 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(2 * N[(1 / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;b\_2 \leq -899999999999999946915980092523034999871946988517111352010114681811160456864717944276428980611627825091908289848159568488674963822739926718420037466981400576:\\
\;\;\;\;-2 \cdot \frac{b\_2}{a}\\
\mathbf{elif}\;b\_2 \leq \frac{4199521391583383}{139984046386112763159840142535527767382602843577165595931249318810236991948760059086304843329475444736}:\\
\;\;\;\;\frac{\sqrt{b\_2 \cdot b\_2 - c \cdot a}}{a} - \frac{b\_2}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{b\_2 \cdot \left(\frac{1}{2} \cdot \frac{a}{{b\_2}^{2}} - 2 \cdot \frac{1}{c}\right)}\\
\end{array}
if b_2 < -8.9999999999999995e155Initial program 53.2%
Taylor expanded in b_2 around -inf
lower-*.f64N/A
lower-/.f6436.0%
Applied rewrites36.0%
if -8.9999999999999995e155 < b_2 < 3.0000000000000001e-86Initial program 53.2%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
lower--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-neg.f64N/A
remove-double-neg53.2%
Applied rewrites53.2%
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6453.0%
Applied rewrites53.0%
lift-*.f64N/A
lift-/.f64N/A
associate-/r/N/A
div-flip-revN/A
lift--.f64N/A
div-subN/A
lift-sqrt.f64N/A
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
distribute-lft-neg-outN/A
*-commutativeN/A
sub-flipN/A
lift-*.f64N/A
lower--.f64N/A
Applied rewrites52.7%
if 3.0000000000000001e-86 < b_2 Initial program 53.2%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
lower--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-neg.f64N/A
remove-double-neg53.2%
Applied rewrites53.2%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6453.1%
Applied rewrites53.1%
Taylor expanded in b_2 around inf
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-pow.f64N/A
lower-*.f64N/A
lower-/.f6433.6%
Applied rewrites33.6%
(FPCore (a b_2 c)
:precision binary64
(if (<=
b_2
-899999999999999946915980092523034999871946988517111352010114681811160456864717944276428980611627825091908289848159568488674963822739926718420037466981400576)
(* -2 (/ b_2 a))
(if (<=
b_2
4199521391583383/139984046386112763159840142535527767382602843577165595931249318810236991948760059086304843329475444736)
(- (/ (sqrt (- (* b_2 b_2) (* c a))) a) (/ b_2 a))
(* -1/2 (/ c b_2)))))double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -9e+155) {
tmp = -2.0 * (b_2 / a);
} else if (b_2 <= 3e-86) {
tmp = (sqrt(((b_2 * b_2) - (c * a))) / a) - (b_2 / a);
} else {
tmp = -0.5 * (c / b_2);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b_2, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
real(8) :: tmp
if (b_2 <= (-9d+155)) then
tmp = (-2.0d0) * (b_2 / a)
else if (b_2 <= 3d-86) then
tmp = (sqrt(((b_2 * b_2) - (c * a))) / a) - (b_2 / a)
else
tmp = (-0.5d0) * (c / b_2)
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -9e+155) {
tmp = -2.0 * (b_2 / a);
} else if (b_2 <= 3e-86) {
tmp = (Math.sqrt(((b_2 * b_2) - (c * a))) / a) - (b_2 / a);
} else {
tmp = -0.5 * (c / b_2);
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -9e+155: tmp = -2.0 * (b_2 / a) elif b_2 <= 3e-86: tmp = (math.sqrt(((b_2 * b_2) - (c * a))) / a) - (b_2 / a) else: tmp = -0.5 * (c / b_2) return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -9e+155) tmp = Float64(-2.0 * Float64(b_2 / a)); elseif (b_2 <= 3e-86) tmp = Float64(Float64(sqrt(Float64(Float64(b_2 * b_2) - Float64(c * a))) / a) - Float64(b_2 / a)); else tmp = Float64(-0.5 * Float64(c / b_2)); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -9e+155) tmp = -2.0 * (b_2 / a); elseif (b_2 <= 3e-86) tmp = (sqrt(((b_2 * b_2) - (c * a))) / a) - (b_2 / a); else tmp = -0.5 * (c / b_2); end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -899999999999999946915980092523034999871946988517111352010114681811160456864717944276428980611627825091908289848159568488674963822739926718420037466981400576], N[(-2 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, 4199521391583383/139984046386112763159840142535527767382602843577165595931249318810236991948760059086304843329475444736], N[(N[(N[Sqrt[N[(N[(b$95$2 * b$95$2), $MachinePrecision] - N[(c * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / a), $MachinePrecision] - N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision], N[(-1/2 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;b\_2 \leq -899999999999999946915980092523034999871946988517111352010114681811160456864717944276428980611627825091908289848159568488674963822739926718420037466981400576:\\
\;\;\;\;-2 \cdot \frac{b\_2}{a}\\
\mathbf{elif}\;b\_2 \leq \frac{4199521391583383}{139984046386112763159840142535527767382602843577165595931249318810236991948760059086304843329475444736}:\\
\;\;\;\;\frac{\sqrt{b\_2 \cdot b\_2 - c \cdot a}}{a} - \frac{b\_2}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b\_2}\\
\end{array}
if b_2 < -8.9999999999999995e155Initial program 53.2%
Taylor expanded in b_2 around -inf
lower-*.f64N/A
lower-/.f6436.0%
Applied rewrites36.0%
if -8.9999999999999995e155 < b_2 < 3.0000000000000001e-86Initial program 53.2%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
lower--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-neg.f64N/A
remove-double-neg53.2%
Applied rewrites53.2%
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6453.0%
Applied rewrites53.0%
lift-*.f64N/A
lift-/.f64N/A
associate-/r/N/A
div-flip-revN/A
lift--.f64N/A
div-subN/A
lift-sqrt.f64N/A
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
distribute-lft-neg-outN/A
*-commutativeN/A
sub-flipN/A
lift-*.f64N/A
lower--.f64N/A
Applied rewrites52.7%
if 3.0000000000000001e-86 < b_2 Initial program 53.2%
Taylor expanded in b_2 around 0
lower-/.f64N/A
lower-sqrt.f64N/A
lower-neg.f64N/A
lower-*.f6429.3%
Applied rewrites29.3%
Taylor expanded in b_2 around inf
lower-*.f64N/A
lower-/.f6434.3%
Applied rewrites34.3%
(FPCore (a b_2 c)
:precision binary64
(if (<=
b_2
-899999999999999946915980092523034999871946988517111352010114681811160456864717944276428980611627825091908289848159568488674963822739926718420037466981400576)
(* -2 (/ b_2 a))
(if (<=
b_2
4199521391583383/139984046386112763159840142535527767382602843577165595931249318810236991948760059086304843329475444736)
(/ (- (sqrt (- (* b_2 b_2) (* c a))) b_2) a)
(* -1/2 (/ c b_2)))))double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -9e+155) {
tmp = -2.0 * (b_2 / a);
} else if (b_2 <= 3e-86) {
tmp = (sqrt(((b_2 * b_2) - (c * a))) - b_2) / a;
} else {
tmp = -0.5 * (c / b_2);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b_2, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
real(8) :: tmp
if (b_2 <= (-9d+155)) then
tmp = (-2.0d0) * (b_2 / a)
else if (b_2 <= 3d-86) then
tmp = (sqrt(((b_2 * b_2) - (c * a))) - b_2) / a
else
tmp = (-0.5d0) * (c / b_2)
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -9e+155) {
tmp = -2.0 * (b_2 / a);
} else if (b_2 <= 3e-86) {
tmp = (Math.sqrt(((b_2 * b_2) - (c * a))) - b_2) / a;
} else {
tmp = -0.5 * (c / b_2);
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -9e+155: tmp = -2.0 * (b_2 / a) elif b_2 <= 3e-86: tmp = (math.sqrt(((b_2 * b_2) - (c * a))) - b_2) / a else: tmp = -0.5 * (c / b_2) return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -9e+155) tmp = Float64(-2.0 * Float64(b_2 / a)); elseif (b_2 <= 3e-86) tmp = Float64(Float64(sqrt(Float64(Float64(b_2 * b_2) - Float64(c * a))) - b_2) / a); else tmp = Float64(-0.5 * Float64(c / b_2)); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -9e+155) tmp = -2.0 * (b_2 / a); elseif (b_2 <= 3e-86) tmp = (sqrt(((b_2 * b_2) - (c * a))) - b_2) / a; else tmp = -0.5 * (c / b_2); end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -899999999999999946915980092523034999871946988517111352010114681811160456864717944276428980611627825091908289848159568488674963822739926718420037466981400576], N[(-2 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, 4199521391583383/139984046386112763159840142535527767382602843577165595931249318810236991948760059086304843329475444736], N[(N[(N[Sqrt[N[(N[(b$95$2 * b$95$2), $MachinePrecision] - N[(c * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b$95$2), $MachinePrecision] / a), $MachinePrecision], N[(-1/2 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;b\_2 \leq -899999999999999946915980092523034999871946988517111352010114681811160456864717944276428980611627825091908289848159568488674963822739926718420037466981400576:\\
\;\;\;\;-2 \cdot \frac{b\_2}{a}\\
\mathbf{elif}\;b\_2 \leq \frac{4199521391583383}{139984046386112763159840142535527767382602843577165595931249318810236991948760059086304843329475444736}:\\
\;\;\;\;\frac{\sqrt{b\_2 \cdot b\_2 - c \cdot a} - b\_2}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b\_2}\\
\end{array}
if b_2 < -8.9999999999999995e155Initial program 53.2%
Taylor expanded in b_2 around -inf
lower-*.f64N/A
lower-/.f6436.0%
Applied rewrites36.0%
if -8.9999999999999995e155 < b_2 < 3.0000000000000001e-86Initial program 53.2%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
lower--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-neg.f64N/A
remove-double-neg53.2%
Applied rewrites53.2%
if 3.0000000000000001e-86 < b_2 Initial program 53.2%
Taylor expanded in b_2 around 0
lower-/.f64N/A
lower-sqrt.f64N/A
lower-neg.f64N/A
lower-*.f6429.3%
Applied rewrites29.3%
Taylor expanded in b_2 around inf
lower-*.f64N/A
lower-/.f6434.3%
Applied rewrites34.3%
(FPCore (a b_2 c)
:precision binary64
(if (<=
b_2
-8081519453784961/5986310706507378352962293074805895248510699696029696)
(* -2 (/ b_2 a))
(if (<=
b_2
4199521391583383/139984046386112763159840142535527767382602843577165595931249318810236991948760059086304843329475444736)
(/ (- (sqrt (- (* a c))) b_2) a)
(* -1/2 (/ c b_2)))))double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -1.35e-36) {
tmp = -2.0 * (b_2 / a);
} else if (b_2 <= 3e-86) {
tmp = (sqrt(-(a * c)) - b_2) / a;
} else {
tmp = -0.5 * (c / b_2);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b_2, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
real(8) :: tmp
if (b_2 <= (-1.35d-36)) then
tmp = (-2.0d0) * (b_2 / a)
else if (b_2 <= 3d-86) then
tmp = (sqrt(-(a * c)) - b_2) / a
else
tmp = (-0.5d0) * (c / b_2)
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -1.35e-36) {
tmp = -2.0 * (b_2 / a);
} else if (b_2 <= 3e-86) {
tmp = (Math.sqrt(-(a * c)) - b_2) / a;
} else {
tmp = -0.5 * (c / b_2);
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -1.35e-36: tmp = -2.0 * (b_2 / a) elif b_2 <= 3e-86: tmp = (math.sqrt(-(a * c)) - b_2) / a else: tmp = -0.5 * (c / b_2) return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -1.35e-36) tmp = Float64(-2.0 * Float64(b_2 / a)); elseif (b_2 <= 3e-86) tmp = Float64(Float64(sqrt(Float64(-Float64(a * c))) - b_2) / a); else tmp = Float64(-0.5 * Float64(c / b_2)); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -1.35e-36) tmp = -2.0 * (b_2 / a); elseif (b_2 <= 3e-86) tmp = (sqrt(-(a * c)) - b_2) / a; else tmp = -0.5 * (c / b_2); end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -8081519453784961/5986310706507378352962293074805895248510699696029696], N[(-2 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, 4199521391583383/139984046386112763159840142535527767382602843577165595931249318810236991948760059086304843329475444736], N[(N[(N[Sqrt[(-N[(a * c), $MachinePrecision])], $MachinePrecision] - b$95$2), $MachinePrecision] / a), $MachinePrecision], N[(-1/2 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;b\_2 \leq \frac{-8081519453784961}{5986310706507378352962293074805895248510699696029696}:\\
\;\;\;\;-2 \cdot \frac{b\_2}{a}\\
\mathbf{elif}\;b\_2 \leq \frac{4199521391583383}{139984046386112763159840142535527767382602843577165595931249318810236991948760059086304843329475444736}:\\
\;\;\;\;\frac{\sqrt{-a \cdot c} - b\_2}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b\_2}\\
\end{array}
if b_2 < -1.35e-36Initial program 53.2%
Taylor expanded in b_2 around -inf
lower-*.f64N/A
lower-/.f6436.0%
Applied rewrites36.0%
if -1.35e-36 < b_2 < 3.0000000000000001e-86Initial program 53.2%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
lower--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-neg.f64N/A
remove-double-neg53.2%
Applied rewrites53.2%
Taylor expanded in b_2 around 0
lower-sqrt.f64N/A
lower-neg.f64N/A
lower-*.f6434.4%
Applied rewrites34.4%
if 3.0000000000000001e-86 < b_2 Initial program 53.2%
Taylor expanded in b_2 around 0
lower-/.f64N/A
lower-sqrt.f64N/A
lower-neg.f64N/A
lower-*.f6429.3%
Applied rewrites29.3%
Taylor expanded in b_2 around inf
lower-*.f64N/A
lower-/.f6434.3%
Applied rewrites34.3%
(FPCore (a b_2 c)
:precision binary64
(if (<=
b_2
-7225426368408531/1852673427797059126777135760139006525652319754650249024631321344126610074238976)
(* -2 (/ b_2 a))
(if (<=
b_2
4199521391583383/139984046386112763159840142535527767382602843577165595931249318810236991948760059086304843329475444736)
(/ (sqrt (- (* a c))) a)
(* -1/2 (/ c b_2)))))double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -3.9e-63) {
tmp = -2.0 * (b_2 / a);
} else if (b_2 <= 3e-86) {
tmp = sqrt(-(a * c)) / a;
} else {
tmp = -0.5 * (c / b_2);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b_2, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
real(8) :: tmp
if (b_2 <= (-3.9d-63)) then
tmp = (-2.0d0) * (b_2 / a)
else if (b_2 <= 3d-86) then
tmp = sqrt(-(a * c)) / a
else
tmp = (-0.5d0) * (c / b_2)
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -3.9e-63) {
tmp = -2.0 * (b_2 / a);
} else if (b_2 <= 3e-86) {
tmp = Math.sqrt(-(a * c)) / a;
} else {
tmp = -0.5 * (c / b_2);
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -3.9e-63: tmp = -2.0 * (b_2 / a) elif b_2 <= 3e-86: tmp = math.sqrt(-(a * c)) / a else: tmp = -0.5 * (c / b_2) return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -3.9e-63) tmp = Float64(-2.0 * Float64(b_2 / a)); elseif (b_2 <= 3e-86) tmp = Float64(sqrt(Float64(-Float64(a * c))) / a); else tmp = Float64(-0.5 * Float64(c / b_2)); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -3.9e-63) tmp = -2.0 * (b_2 / a); elseif (b_2 <= 3e-86) tmp = sqrt(-(a * c)) / a; else tmp = -0.5 * (c / b_2); end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -7225426368408531/1852673427797059126777135760139006525652319754650249024631321344126610074238976], N[(-2 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, 4199521391583383/139984046386112763159840142535527767382602843577165595931249318810236991948760059086304843329475444736], N[(N[Sqrt[(-N[(a * c), $MachinePrecision])], $MachinePrecision] / a), $MachinePrecision], N[(-1/2 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;b\_2 \leq \frac{-7225426368408531}{1852673427797059126777135760139006525652319754650249024631321344126610074238976}:\\
\;\;\;\;-2 \cdot \frac{b\_2}{a}\\
\mathbf{elif}\;b\_2 \leq \frac{4199521391583383}{139984046386112763159840142535527767382602843577165595931249318810236991948760059086304843329475444736}:\\
\;\;\;\;\frac{\sqrt{-a \cdot c}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b\_2}\\
\end{array}
if b_2 < -3.9000000000000002e-63Initial program 53.2%
Taylor expanded in b_2 around -inf
lower-*.f64N/A
lower-/.f6436.0%
Applied rewrites36.0%
if -3.9000000000000002e-63 < b_2 < 3.0000000000000001e-86Initial program 53.2%
Taylor expanded in b_2 around 0
lower-/.f64N/A
lower-sqrt.f64N/A
lower-neg.f64N/A
lower-*.f6429.3%
Applied rewrites29.3%
if 3.0000000000000001e-86 < b_2 Initial program 53.2%
Taylor expanded in b_2 around 0
lower-/.f64N/A
lower-sqrt.f64N/A
lower-neg.f64N/A
lower-*.f6429.3%
Applied rewrites29.3%
Taylor expanded in b_2 around inf
lower-*.f64N/A
lower-/.f6434.3%
Applied rewrites34.3%
(FPCore (a b_2 c)
:precision binary64
(if (<=
b_2
-7225426368408531/1852673427797059126777135760139006525652319754650249024631321344126610074238976)
(* -2 (/ b_2 a))
(if (<=
b_2
1917062309491721/165263992197562149737978827008192759957101170741070304821162198818601447809077836456297302609928821211897803006255839576064)
(sqrt (* -1 (/ c a)))
(* -1/2 (/ c b_2)))))double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -3.9e-63) {
tmp = -2.0 * (b_2 / a);
} else if (b_2 <= 1.16e-107) {
tmp = sqrt((-1.0 * (c / a)));
} else {
tmp = -0.5 * (c / b_2);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b_2, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
real(8) :: tmp
if (b_2 <= (-3.9d-63)) then
tmp = (-2.0d0) * (b_2 / a)
else if (b_2 <= 1.16d-107) then
tmp = sqrt(((-1.0d0) * (c / a)))
else
tmp = (-0.5d0) * (c / b_2)
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -3.9e-63) {
tmp = -2.0 * (b_2 / a);
} else if (b_2 <= 1.16e-107) {
tmp = Math.sqrt((-1.0 * (c / a)));
} else {
tmp = -0.5 * (c / b_2);
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -3.9e-63: tmp = -2.0 * (b_2 / a) elif b_2 <= 1.16e-107: tmp = math.sqrt((-1.0 * (c / a))) else: tmp = -0.5 * (c / b_2) return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -3.9e-63) tmp = Float64(-2.0 * Float64(b_2 / a)); elseif (b_2 <= 1.16e-107) tmp = sqrt(Float64(-1.0 * Float64(c / a))); else tmp = Float64(-0.5 * Float64(c / b_2)); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -3.9e-63) tmp = -2.0 * (b_2 / a); elseif (b_2 <= 1.16e-107) tmp = sqrt((-1.0 * (c / a))); else tmp = -0.5 * (c / b_2); end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -7225426368408531/1852673427797059126777135760139006525652319754650249024631321344126610074238976], N[(-2 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, 1917062309491721/165263992197562149737978827008192759957101170741070304821162198818601447809077836456297302609928821211897803006255839576064], N[Sqrt[N[(-1 * N[(c / a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(-1/2 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;b\_2 \leq \frac{-7225426368408531}{1852673427797059126777135760139006525652319754650249024631321344126610074238976}:\\
\;\;\;\;-2 \cdot \frac{b\_2}{a}\\
\mathbf{elif}\;b\_2 \leq \frac{1917062309491721}{165263992197562149737978827008192759957101170741070304821162198818601447809077836456297302609928821211897803006255839576064}:\\
\;\;\;\;\sqrt{-1 \cdot \frac{c}{a}}\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b\_2}\\
\end{array}
if b_2 < -3.9000000000000002e-63Initial program 53.2%
Taylor expanded in b_2 around -inf
lower-*.f64N/A
lower-/.f6436.0%
Applied rewrites36.0%
if -3.9000000000000002e-63 < b_2 < 1.16e-107Initial program 53.2%
Taylor expanded in b_2 around 0
lower-/.f64N/A
lower-sqrt.f64N/A
lower-neg.f64N/A
lower-*.f6429.3%
Applied rewrites29.3%
Taylor expanded in b_2 around inf
lower-*.f64N/A
lower-/.f6434.3%
Applied rewrites34.3%
Taylor expanded in a around inf
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6417.4%
Applied rewrites17.4%
if 1.16e-107 < b_2 Initial program 53.2%
Taylor expanded in b_2 around 0
lower-/.f64N/A
lower-sqrt.f64N/A
lower-neg.f64N/A
lower-*.f6429.3%
Applied rewrites29.3%
Taylor expanded in b_2 around inf
lower-*.f64N/A
lower-/.f6434.3%
Applied rewrites34.3%
(FPCore (a b_2 c)
:precision binary64
(if (<=
b_2
790984979339419/359538626972463181545861038157804946723595395788461314546860162315465351611001926265416954644815072042240227759742786715317579537628833244985694861278948248755535786849730970552604439202492188238906165904170011537676301364684925762947826221081654474326701021369172596479894491876959432609670712659248448274432)
(* -2 (/ b_2 a))
(* -1/2 (/ c b_2))))double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= 2.2e-294) {
tmp = -2.0 * (b_2 / a);
} else {
tmp = -0.5 * (c / b_2);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b_2, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
real(8) :: tmp
if (b_2 <= 2.2d-294) then
tmp = (-2.0d0) * (b_2 / a)
else
tmp = (-0.5d0) * (c / b_2)
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= 2.2e-294) {
tmp = -2.0 * (b_2 / a);
} else {
tmp = -0.5 * (c / b_2);
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= 2.2e-294: tmp = -2.0 * (b_2 / a) else: tmp = -0.5 * (c / b_2) return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= 2.2e-294) tmp = Float64(-2.0 * Float64(b_2 / a)); else tmp = Float64(-0.5 * Float64(c / b_2)); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= 2.2e-294) tmp = -2.0 * (b_2 / a); else tmp = -0.5 * (c / b_2); end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, 790984979339419/359538626972463181545861038157804946723595395788461314546860162315465351611001926265416954644815072042240227759742786715317579537628833244985694861278948248755535786849730970552604439202492188238906165904170011537676301364684925762947826221081654474326701021369172596479894491876959432609670712659248448274432], N[(-2 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision], N[(-1/2 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;b\_2 \leq \frac{790984979339419}{359538626972463181545861038157804946723595395788461314546860162315465351611001926265416954644815072042240227759742786715317579537628833244985694861278948248755535786849730970552604439202492188238906165904170011537676301364684925762947826221081654474326701021369172596479894491876959432609670712659248448274432}:\\
\;\;\;\;-2 \cdot \frac{b\_2}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b\_2}\\
\end{array}
if b_2 < 2.2e-294Initial program 53.2%
Taylor expanded in b_2 around -inf
lower-*.f64N/A
lower-/.f6436.0%
Applied rewrites36.0%
if 2.2e-294 < b_2 Initial program 53.2%
Taylor expanded in b_2 around 0
lower-/.f64N/A
lower-sqrt.f64N/A
lower-neg.f64N/A
lower-*.f6429.3%
Applied rewrites29.3%
Taylor expanded in b_2 around inf
lower-*.f64N/A
lower-/.f6434.3%
Applied rewrites34.3%
(FPCore (a b_2 c)
:precision binary64
(if (<=
b_2
-1315614646497519/101201126653655309176247673359458653524778324882071059178450679013715169783997673445980191850718562247593538932158405955694904368692896738433506699970369254960758712138283180682233453871046608170619883839236372534281003741712346349309051677824579778170405028256179384776166707307615251266093163754323003131653853870546747392)
(* -2 (/ b_2 a))
(* -2 (/ 0 a))))double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -1.3e-308) {
tmp = -2.0 * (b_2 / a);
} else {
tmp = -2.0 * (0.0 / 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_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.3d-308)) then
tmp = (-2.0d0) * (b_2 / a)
else
tmp = (-2.0d0) * (0.0d0 / a)
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -1.3e-308) {
tmp = -2.0 * (b_2 / a);
} else {
tmp = -2.0 * (0.0 / a);
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -1.3e-308: tmp = -2.0 * (b_2 / a) else: tmp = -2.0 * (0.0 / a) return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -1.3e-308) tmp = Float64(-2.0 * Float64(b_2 / a)); else tmp = Float64(-2.0 * Float64(0.0 / a)); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -1.3e-308) tmp = -2.0 * (b_2 / a); else tmp = -2.0 * (0.0 / a); end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -1315614646497519/101201126653655309176247673359458653524778324882071059178450679013715169783997673445980191850718562247593538932158405955694904368692896738433506699970369254960758712138283180682233453871046608170619883839236372534281003741712346349309051677824579778170405028256179384776166707307615251266093163754323003131653853870546747392], N[(-2 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision], N[(-2 * N[(0 / a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;b\_2 \leq \frac{-1315614646497519}{101201126653655309176247673359458653524778324882071059178450679013715169783997673445980191850718562247593538932158405955694904368692896738433506699970369254960758712138283180682233453871046608170619883839236372534281003741712346349309051677824579778170405028256179384776166707307615251266093163754323003131653853870546747392}:\\
\;\;\;\;-2 \cdot \frac{b\_2}{a}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{0}{a}\\
\end{array}
if b_2 < -1.3e-308Initial program 53.2%
Taylor expanded in b_2 around -inf
lower-*.f64N/A
lower-/.f6436.0%
Applied rewrites36.0%
if -1.3e-308 < b_2 Initial program 53.2%
Taylor expanded in b_2 around -inf
lower-*.f64N/A
lower-/.f6436.0%
Applied rewrites36.0%
Taylor expanded in undef-var around zero
Applied rewrites10.5%
(FPCore (a b_2 c) :precision binary64 (* -2 (/ b_2 a)))
double code(double a, double b_2, double c) {
return -2.0 * (b_2 / a);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b_2, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
code = (-2.0d0) * (b_2 / a)
end function
public static double code(double a, double b_2, double c) {
return -2.0 * (b_2 / a);
}
def code(a, b_2, c): return -2.0 * (b_2 / a)
function code(a, b_2, c) return Float64(-2.0 * Float64(b_2 / a)) end
function tmp = code(a, b_2, c) tmp = -2.0 * (b_2 / a); end
code[a_, b$95$2_, c_] := N[(-2 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision]
-2 \cdot \frac{b\_2}{a}
Initial program 53.2%
Taylor expanded in b_2 around -inf
lower-*.f64N/A
lower-/.f6436.0%
Applied rewrites36.0%
herbie shell --seed 2025274 -o generate:evaluate
(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))