
(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 7 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 -4208996133570293/2475880078570760549798248448)
(* -1/2 (/ c b_2))
(if (<=
b_2
520000000000000000996151044582027742832296666177899845799457827591677248586074153099842795456253768237056)
(/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a)
(/ (* -2 b_2) a))))double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -1.7e-12) {
tmp = -0.5 * (c / b_2);
} else if (b_2 <= 5.2e+104) {
tmp = (-b_2 - sqrt(((b_2 * b_2) - (a * c)))) / a;
} else {
tmp = (-2.0 * b_2) / 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.7d-12)) then
tmp = (-0.5d0) * (c / b_2)
else if (b_2 <= 5.2d+104) then
tmp = (-b_2 - sqrt(((b_2 * b_2) - (a * c)))) / a
else
tmp = ((-2.0d0) * b_2) / a
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -1.7e-12) {
tmp = -0.5 * (c / b_2);
} else if (b_2 <= 5.2e+104) {
tmp = (-b_2 - Math.sqrt(((b_2 * b_2) - (a * c)))) / a;
} else {
tmp = (-2.0 * b_2) / a;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -1.7e-12: tmp = -0.5 * (c / b_2) elif b_2 <= 5.2e+104: tmp = (-b_2 - math.sqrt(((b_2 * b_2) - (a * c)))) / a else: tmp = (-2.0 * b_2) / a return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -1.7e-12) tmp = Float64(-0.5 * Float64(c / b_2)); elseif (b_2 <= 5.2e+104) tmp = Float64(Float64(Float64(-b_2) - sqrt(Float64(Float64(b_2 * b_2) - Float64(a * c)))) / a); else tmp = Float64(Float64(-2.0 * b_2) / a); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -1.7e-12) tmp = -0.5 * (c / b_2); elseif (b_2 <= 5.2e+104) tmp = (-b_2 - sqrt(((b_2 * b_2) - (a * c)))) / a; else tmp = (-2.0 * b_2) / a; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -4208996133570293/2475880078570760549798248448], N[(-1/2 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, 520000000000000000996151044582027742832296666177899845799457827591677248586074153099842795456253768237056], N[(N[((-b$95$2) - N[Sqrt[N[(N[(b$95$2 * b$95$2), $MachinePrecision] - N[(a * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(N[(-2 * b$95$2), $MachinePrecision] / a), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;b\_2 \leq \frac{-4208996133570293}{2475880078570760549798248448}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b\_2}\\
\mathbf{elif}\;b\_2 \leq 520000000000000000996151044582027742832296666177899845799457827591677248586074153099842795456253768237056:\\
\;\;\;\;\frac{\left(-b\_2\right) - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-2 \cdot b\_2}{a}\\
\end{array}
if b_2 < -1.7e-12Initial program 53.1%
Taylor expanded in b_2 around -inf
lower-*.f64N/A
lower-/.f6434.9%
Applied rewrites34.9%
if -1.7e-12 < b_2 < 5.2e104Initial program 53.1%
if 5.2e104 < b_2 Initial program 53.1%
Taylor expanded in b_2 around -inf
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6427.3%
Applied rewrites27.3%
Taylor expanded in b_2 around inf
lower-*.f6435.5%
Applied rewrites35.5%
(FPCore (a b_2 c)
:precision binary64
(if (<=
b_2
-7404544304199621/21778071482940061661655974875633165533184)
(* -1/2 (/ c b_2))
(if (<=
b_2
5687876567655377/18347988927920572092886567162416695526372519913346248989900710715095383008707878464560148424881005492436992)
(/ (- (- b_2) (sqrt (- (* a c)))) a)
(/ (* -2 b_2) a))))double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -3.4e-25) {
tmp = -0.5 * (c / b_2);
} else if (b_2 <= 3.1e-91) {
tmp = (-b_2 - sqrt(-(a * c))) / a;
} else {
tmp = (-2.0 * b_2) / 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 <= (-3.4d-25)) then
tmp = (-0.5d0) * (c / b_2)
else if (b_2 <= 3.1d-91) then
tmp = (-b_2 - sqrt(-(a * c))) / a
else
tmp = ((-2.0d0) * b_2) / a
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -3.4e-25) {
tmp = -0.5 * (c / b_2);
} else if (b_2 <= 3.1e-91) {
tmp = (-b_2 - Math.sqrt(-(a * c))) / a;
} else {
tmp = (-2.0 * b_2) / a;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -3.4e-25: tmp = -0.5 * (c / b_2) elif b_2 <= 3.1e-91: tmp = (-b_2 - math.sqrt(-(a * c))) / a else: tmp = (-2.0 * b_2) / a return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -3.4e-25) tmp = Float64(-0.5 * Float64(c / b_2)); elseif (b_2 <= 3.1e-91) tmp = Float64(Float64(Float64(-b_2) - sqrt(Float64(-Float64(a * c)))) / a); else tmp = Float64(Float64(-2.0 * b_2) / a); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -3.4e-25) tmp = -0.5 * (c / b_2); elseif (b_2 <= 3.1e-91) tmp = (-b_2 - sqrt(-(a * c))) / a; else tmp = (-2.0 * b_2) / a; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -7404544304199621/21778071482940061661655974875633165533184], N[(-1/2 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, 5687876567655377/18347988927920572092886567162416695526372519913346248989900710715095383008707878464560148424881005492436992], N[(N[((-b$95$2) - N[Sqrt[(-N[(a * c), $MachinePrecision])], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(N[(-2 * b$95$2), $MachinePrecision] / a), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;b\_2 \leq \frac{-7404544304199621}{21778071482940061661655974875633165533184}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b\_2}\\
\mathbf{elif}\;b\_2 \leq \frac{5687876567655377}{18347988927920572092886567162416695526372519913346248989900710715095383008707878464560148424881005492436992}:\\
\;\;\;\;\frac{\left(-b\_2\right) - \sqrt{-a \cdot c}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-2 \cdot b\_2}{a}\\
\end{array}
if b_2 < -3.4e-25Initial program 53.1%
Taylor expanded in b_2 around -inf
lower-*.f64N/A
lower-/.f6434.9%
Applied rewrites34.9%
if -3.4e-25 < b_2 < 3.0999999999999998e-91Initial program 53.1%
Taylor expanded in b_2 around 0
lower-sqrt.f64N/A
lower-neg.f64N/A
lower-*.f6434.0%
Applied rewrites34.0%
if 3.0999999999999998e-91 < b_2 Initial program 53.1%
Taylor expanded in b_2 around -inf
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6427.3%
Applied rewrites27.3%
Taylor expanded in b_2 around inf
lower-*.f6435.5%
Applied rewrites35.5%
(FPCore (a b_2 c)
:precision binary64
(if (<=
b_2
-7404544304199621/21778071482940061661655974875633165533184)
(* -1/2 (/ c b_2))
(if (<=
b_2
5002207817901643/9619630419041620901435312524449124464130795720328478190417063819395928166869436184427311097384012607618805661696)
(* c (sqrt (/ -1 (* a c))))
(/ (* -2 b_2) a))))double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -3.4e-25) {
tmp = -0.5 * (c / b_2);
} else if (b_2 <= 5.2e-97) {
tmp = c * sqrt((-1.0 / (a * c)));
} else {
tmp = (-2.0 * b_2) / 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 <= (-3.4d-25)) then
tmp = (-0.5d0) * (c / b_2)
else if (b_2 <= 5.2d-97) then
tmp = c * sqrt(((-1.0d0) / (a * c)))
else
tmp = ((-2.0d0) * b_2) / a
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -3.4e-25) {
tmp = -0.5 * (c / b_2);
} else if (b_2 <= 5.2e-97) {
tmp = c * Math.sqrt((-1.0 / (a * c)));
} else {
tmp = (-2.0 * b_2) / a;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -3.4e-25: tmp = -0.5 * (c / b_2) elif b_2 <= 5.2e-97: tmp = c * math.sqrt((-1.0 / (a * c))) else: tmp = (-2.0 * b_2) / a return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -3.4e-25) tmp = Float64(-0.5 * Float64(c / b_2)); elseif (b_2 <= 5.2e-97) tmp = Float64(c * sqrt(Float64(-1.0 / Float64(a * c)))); else tmp = Float64(Float64(-2.0 * b_2) / a); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -3.4e-25) tmp = -0.5 * (c / b_2); elseif (b_2 <= 5.2e-97) tmp = c * sqrt((-1.0 / (a * c))); else tmp = (-2.0 * b_2) / a; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -7404544304199621/21778071482940061661655974875633165533184], N[(-1/2 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, 5002207817901643/9619630419041620901435312524449124464130795720328478190417063819395928166869436184427311097384012607618805661696], N[(c * N[Sqrt[N[(-1 / N[(a * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(-2 * b$95$2), $MachinePrecision] / a), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;b\_2 \leq \frac{-7404544304199621}{21778071482940061661655974875633165533184}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b\_2}\\
\mathbf{elif}\;b\_2 \leq \frac{5002207817901643}{9619630419041620901435312524449124464130795720328478190417063819395928166869436184427311097384012607618805661696}:\\
\;\;\;\;c \cdot \sqrt{\frac{-1}{a \cdot c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{-2 \cdot b\_2}{a}\\
\end{array}
if b_2 < -3.4e-25Initial program 53.1%
Taylor expanded in b_2 around -inf
lower-*.f64N/A
lower-/.f6434.9%
Applied rewrites34.9%
if -3.4e-25 < b_2 < 5.2000000000000001e-97Initial program 53.1%
Taylor expanded in c around -inf
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6413.8%
Applied rewrites13.8%
Taylor expanded in a around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-*.f6428.3%
Applied rewrites28.3%
if 5.2000000000000001e-97 < b_2 Initial program 53.1%
Taylor expanded in b_2 around -inf
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6427.3%
Applied rewrites27.3%
Taylor expanded in b_2 around inf
lower-*.f6435.5%
Applied rewrites35.5%
(FPCore (a b_2 c)
:precision binary64
(if (<=
b_2
-7691111892168569/3495959950985713037648777335653666807949431051290362857597833215614143555340930683513828645730545455985029236965209926766894148041634933679253543217964426223207137977048243664827490388364133151397099610379851714779776678907072458937421726941708288)
(* -1/2 (/ c b_2))
(if (<=
b_2
8322990519904913/112472844863579909570263462692149546471742427957547915827518889315295939516787196757976017152597271428748022765838022378080206651387357492225212879521629096378368)
(sqrt (* -1 (/ c a)))
(/ (* -2 b_2) a))))double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -2.2e-231) {
tmp = -0.5 * (c / b_2);
} else if (b_2 <= 7.4e-146) {
tmp = sqrt((-1.0 * (c / a)));
} else {
tmp = (-2.0 * b_2) / 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 <= (-2.2d-231)) then
tmp = (-0.5d0) * (c / b_2)
else if (b_2 <= 7.4d-146) then
tmp = sqrt(((-1.0d0) * (c / a)))
else
tmp = ((-2.0d0) * b_2) / a
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -2.2e-231) {
tmp = -0.5 * (c / b_2);
} else if (b_2 <= 7.4e-146) {
tmp = Math.sqrt((-1.0 * (c / a)));
} else {
tmp = (-2.0 * b_2) / a;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -2.2e-231: tmp = -0.5 * (c / b_2) elif b_2 <= 7.4e-146: tmp = math.sqrt((-1.0 * (c / a))) else: tmp = (-2.0 * b_2) / a return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -2.2e-231) tmp = Float64(-0.5 * Float64(c / b_2)); elseif (b_2 <= 7.4e-146) tmp = sqrt(Float64(-1.0 * Float64(c / a))); else tmp = Float64(Float64(-2.0 * b_2) / a); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -2.2e-231) tmp = -0.5 * (c / b_2); elseif (b_2 <= 7.4e-146) tmp = sqrt((-1.0 * (c / a))); else tmp = (-2.0 * b_2) / a; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -7691111892168569/3495959950985713037648777335653666807949431051290362857597833215614143555340930683513828645730545455985029236965209926766894148041634933679253543217964426223207137977048243664827490388364133151397099610379851714779776678907072458937421726941708288], N[(-1/2 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, 8322990519904913/112472844863579909570263462692149546471742427957547915827518889315295939516787196757976017152597271428748022765838022378080206651387357492225212879521629096378368], N[Sqrt[N[(-1 * N[(c / a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[(-2 * b$95$2), $MachinePrecision] / a), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;b\_2 \leq \frac{-7691111892168569}{3495959950985713037648777335653666807949431051290362857597833215614143555340930683513828645730545455985029236965209926766894148041634933679253543217964426223207137977048243664827490388364133151397099610379851714779776678907072458937421726941708288}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b\_2}\\
\mathbf{elif}\;b\_2 \leq \frac{8322990519904913}{112472844863579909570263462692149546471742427957547915827518889315295939516787196757976017152597271428748022765838022378080206651387357492225212879521629096378368}:\\
\;\;\;\;\sqrt{-1 \cdot \frac{c}{a}}\\
\mathbf{else}:\\
\;\;\;\;\frac{-2 \cdot b\_2}{a}\\
\end{array}
if b_2 < -2.2000000000000001e-231Initial program 53.1%
Taylor expanded in b_2 around -inf
lower-*.f64N/A
lower-/.f6434.9%
Applied rewrites34.9%
if -2.2000000000000001e-231 < b_2 < 7.3999999999999997e-146Initial program 53.1%
Taylor expanded in a around -inf
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6417.7%
Applied rewrites17.7%
if 7.3999999999999997e-146 < b_2 Initial program 53.1%
Taylor expanded in b_2 around -inf
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6427.3%
Applied rewrites27.3%
Taylor expanded in b_2 around inf
lower-*.f6435.5%
Applied rewrites35.5%
(FPCore (a b_2 c)
:precision binary64
(if (<=
b_2
-3643240559531591/202402253307310618352495346718917307049556649764142118356901358027430339567995346891960383701437124495187077864316811911389808737385793476867013399940738509921517424276566361364466907742093216341239767678472745068562007483424692698618103355649159556340810056512358769552333414615230502532186327508646006263307707741093494784)
(* -1/2 (/ c b_2))
(/ (* -2 b_2) a)))double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -1.8e-308) {
tmp = -0.5 * (c / b_2);
} else {
tmp = (-2.0 * b_2) / 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.8d-308)) then
tmp = (-0.5d0) * (c / b_2)
else
tmp = ((-2.0d0) * b_2) / a
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -1.8e-308) {
tmp = -0.5 * (c / b_2);
} else {
tmp = (-2.0 * b_2) / a;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -1.8e-308: tmp = -0.5 * (c / b_2) else: tmp = (-2.0 * b_2) / a return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -1.8e-308) tmp = Float64(-0.5 * Float64(c / b_2)); else tmp = Float64(Float64(-2.0 * b_2) / a); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -1.8e-308) tmp = -0.5 * (c / b_2); else tmp = (-2.0 * b_2) / a; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -3643240559531591/202402253307310618352495346718917307049556649764142118356901358027430339567995346891960383701437124495187077864316811911389808737385793476867013399940738509921517424276566361364466907742093216341239767678472745068562007483424692698618103355649159556340810056512358769552333414615230502532186327508646006263307707741093494784], N[(-1/2 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision], N[(N[(-2 * b$95$2), $MachinePrecision] / a), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;b\_2 \leq \frac{-3643240559531591}{202402253307310618352495346718917307049556649764142118356901358027430339567995346891960383701437124495187077864316811911389808737385793476867013399940738509921517424276566361364466907742093216341239767678472745068562007483424692698618103355649159556340810056512358769552333414615230502532186327508646006263307707741093494784}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b\_2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-2 \cdot b\_2}{a}\\
\end{array}
if b_2 < -1.7999999999999999e-308Initial program 53.1%
Taylor expanded in b_2 around -inf
lower-*.f64N/A
lower-/.f6434.9%
Applied rewrites34.9%
if -1.7999999999999999e-308 < b_2 Initial program 53.1%
Taylor expanded in b_2 around -inf
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6427.3%
Applied rewrites27.3%
Taylor expanded in b_2 around inf
lower-*.f6435.5%
Applied rewrites35.5%
(FPCore (a b_2 c)
:precision binary64
(if (<=
b_2
-3643240559531591/202402253307310618352495346718917307049556649764142118356901358027430339567995346891960383701437124495187077864316811911389808737385793476867013399940738509921517424276566361364466907742093216341239767678472745068562007483424692698618103355649159556340810056512358769552333414615230502532186327508646006263307707741093494784)
(* -1/2 (/ c b_2))
(/ (- b_2) a)))double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -1.8e-308) {
tmp = -0.5 * (c / b_2);
} else {
tmp = -b_2 / 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.8d-308)) then
tmp = (-0.5d0) * (c / b_2)
else
tmp = -b_2 / a
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -1.8e-308) {
tmp = -0.5 * (c / b_2);
} else {
tmp = -b_2 / a;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -1.8e-308: tmp = -0.5 * (c / b_2) else: tmp = -b_2 / a return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -1.8e-308) tmp = Float64(-0.5 * Float64(c / b_2)); else tmp = Float64(Float64(-b_2) / a); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -1.8e-308) tmp = -0.5 * (c / b_2); else tmp = -b_2 / a; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -3643240559531591/202402253307310618352495346718917307049556649764142118356901358027430339567995346891960383701437124495187077864316811911389808737385793476867013399940738509921517424276566361364466907742093216341239767678472745068562007483424692698618103355649159556340810056512358769552333414615230502532186327508646006263307707741093494784], N[(-1/2 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision], N[((-b$95$2) / a), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;b\_2 \leq \frac{-3643240559531591}{202402253307310618352495346718917307049556649764142118356901358027430339567995346891960383701437124495187077864316811911389808737385793476867013399940738509921517424276566361364466907742093216341239767678472745068562007483424692698618103355649159556340810056512358769552333414615230502532186327508646006263307707741093494784}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b\_2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-b\_2}{a}\\
\end{array}
if b_2 < -1.7999999999999999e-308Initial program 53.1%
Taylor expanded in b_2 around -inf
lower-*.f64N/A
lower-/.f6434.9%
Applied rewrites34.9%
if -1.7999999999999999e-308 < b_2 Initial program 53.1%
Taylor expanded in a around inf
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6419.6%
Applied rewrites19.6%
Taylor expanded in b_2 around inf
lower-*.f6415.6%
Applied rewrites15.6%
lift-*.f64N/A
mul-1-negN/A
lift-neg.f6415.6%
Applied rewrites15.6%
(FPCore (a b_2 c) :precision binary64 (/ (- b_2) a))
double code(double a, double b_2, double c) {
return -b_2 / a;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b_2, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
code = -b_2 / a
end function
public static double code(double a, double b_2, double c) {
return -b_2 / a;
}
def code(a, b_2, c): return -b_2 / a
function code(a, b_2, c) return Float64(Float64(-b_2) / a) end
function tmp = code(a, b_2, c) tmp = -b_2 / a; end
code[a_, b$95$2_, c_] := N[((-b$95$2) / a), $MachinePrecision]
\frac{-b\_2}{a}
Initial program 53.1%
Taylor expanded in a around inf
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6419.6%
Applied rewrites19.6%
Taylor expanded in b_2 around inf
lower-*.f6415.6%
Applied rewrites15.6%
lift-*.f64N/A
mul-1-negN/A
lift-neg.f6415.6%
Applied rewrites15.6%
herbie shell --seed 2025271 -o generate:evaluate
(FPCore (a b_2 c)
:name "quad2m (problem 3.2.1, negative)"
:precision binary64
:herbie-expected 10
(/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))