
(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 10 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
(let* ((t_0 (sqrt (- (* b_2 b_2) (* c a)))))
(if (<=
b_2
-6099999999999999841728801650498289360189552030478590321787836116030972686527957979843325463625728)
(* -1/2 (/ c b_2))
(if (<=
b_2
-4678880108828875/346583711765101857447301773017885462929554634421977071896309947576827663475703202879996800763017447262173901370175446478621769728)
(/ (/ (+ 0 (* c a)) a) (- t_0 b_2))
(if (<=
b_2
240000000000000007829447601155211065538340938625732871707250923667456)
(- (/ (- t_0) a) (/ b_2 a))
(* -2 (/ b_2 a)))))))double code(double a, double b_2, double c) {
double t_0 = sqrt(((b_2 * b_2) - (c * a)));
double tmp;
if (b_2 <= -6.1e+96) {
tmp = -0.5 * (c / b_2);
} else if (b_2 <= -1.35e-113) {
tmp = ((0.0 + (c * a)) / a) / (t_0 - b_2);
} else if (b_2 <= 2.4e+68) {
tmp = (-t_0 / a) - (b_2 / 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) :: t_0
real(8) :: tmp
t_0 = sqrt(((b_2 * b_2) - (c * a)))
if (b_2 <= (-6.1d+96)) then
tmp = (-0.5d0) * (c / b_2)
else if (b_2 <= (-1.35d-113)) then
tmp = ((0.0d0 + (c * a)) / a) / (t_0 - b_2)
else if (b_2 <= 2.4d+68) then
tmp = (-t_0 / a) - (b_2 / 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 t_0 = Math.sqrt(((b_2 * b_2) - (c * a)));
double tmp;
if (b_2 <= -6.1e+96) {
tmp = -0.5 * (c / b_2);
} else if (b_2 <= -1.35e-113) {
tmp = ((0.0 + (c * a)) / a) / (t_0 - b_2);
} else if (b_2 <= 2.4e+68) {
tmp = (-t_0 / a) - (b_2 / a);
} else {
tmp = -2.0 * (b_2 / a);
}
return tmp;
}
def code(a, b_2, c): t_0 = math.sqrt(((b_2 * b_2) - (c * a))) tmp = 0 if b_2 <= -6.1e+96: tmp = -0.5 * (c / b_2) elif b_2 <= -1.35e-113: tmp = ((0.0 + (c * a)) / a) / (t_0 - b_2) elif b_2 <= 2.4e+68: tmp = (-t_0 / a) - (b_2 / a) else: tmp = -2.0 * (b_2 / a) return tmp
function code(a, b_2, c) t_0 = sqrt(Float64(Float64(b_2 * b_2) - Float64(c * a))) tmp = 0.0 if (b_2 <= -6.1e+96) tmp = Float64(-0.5 * Float64(c / b_2)); elseif (b_2 <= -1.35e-113) tmp = Float64(Float64(Float64(0.0 + Float64(c * a)) / a) / Float64(t_0 - b_2)); elseif (b_2 <= 2.4e+68) tmp = Float64(Float64(Float64(-t_0) / a) - Float64(b_2 / a)); else tmp = Float64(-2.0 * Float64(b_2 / a)); end return tmp end
function tmp_2 = code(a, b_2, c) t_0 = sqrt(((b_2 * b_2) - (c * a))); tmp = 0.0; if (b_2 <= -6.1e+96) tmp = -0.5 * (c / b_2); elseif (b_2 <= -1.35e-113) tmp = ((0.0 + (c * a)) / a) / (t_0 - b_2); elseif (b_2 <= 2.4e+68) tmp = (-t_0 / a) - (b_2 / a); else tmp = -2.0 * (b_2 / a); end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b$95$2 * b$95$2), $MachinePrecision] - N[(c * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b$95$2, -6099999999999999841728801650498289360189552030478590321787836116030972686527957979843325463625728], N[(-1/2 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, -4678880108828875/346583711765101857447301773017885462929554634421977071896309947576827663475703202879996800763017447262173901370175446478621769728], N[(N[(N[(0 + N[(c * a), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision] / N[(t$95$0 - b$95$2), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, 240000000000000007829447601155211065538340938625732871707250923667456], N[(N[((-t$95$0) / a), $MachinePrecision] - N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision], N[(-2 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
t_0 := \sqrt{b\_2 \cdot b\_2 - c \cdot a}\\
\mathbf{if}\;b\_2 \leq -6099999999999999841728801650498289360189552030478590321787836116030972686527957979843325463625728:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b\_2}\\
\mathbf{elif}\;b\_2 \leq \frac{-4678880108828875}{346583711765101857447301773017885462929554634421977071896309947576827663475703202879996800763017447262173901370175446478621769728}:\\
\;\;\;\;\frac{\frac{0 + c \cdot a}{a}}{t\_0 - b\_2}\\
\mathbf{elif}\;b\_2 \leq 240000000000000007829447601155211065538340938625732871707250923667456:\\
\;\;\;\;\frac{-t\_0}{a} - \frac{b\_2}{a}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b\_2}{a}\\
\end{array}
if b_2 < -6.0999999999999998e96Initial program 52.3%
Taylor expanded in b_2 around -inf
lower-*.f64N/A
lower-/.f6435.8%
Applied rewrites35.8%
if -6.0999999999999998e96 < b_2 < -1.35e-113Initial program 52.3%
lift-/.f64N/A
frac-2negN/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f64N/A
lower-neg.f64N/A
lift--.f64N/A
sub-negate-revN/A
sub-flipN/A
+-commutativeN/A
lower-+.f64N/A
lift-neg.f64N/A
remove-double-neg52.2%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6452.2%
Applied rewrites52.2%
Applied rewrites47.8%
if -1.35e-113 < b_2 < 2.4000000000000001e68Initial program 52.3%
lift-/.f64N/A
frac-2negN/A
lift--.f64N/A
sub-negate-revN/A
div-subN/A
distribute-neg-frac2N/A
lift-neg.f64N/A
frac-2negN/A
lower--.f64N/A
distribute-neg-fracN/A
lower-/.f64N/A
lower-neg.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites51.7%
if 2.4000000000000001e68 < b_2 Initial program 52.3%
Taylor expanded in b_2 around inf
lower-*.f64N/A
lower-/.f6434.6%
Applied rewrites34.6%
(FPCore (a b_2 c)
:precision binary64
(let* ((t_0 (sqrt (- (* b_2 b_2) (* c a)))))
(if (<=
b_2
-54999999999999998043547987204697905647054195046560117650923133451965273229273060805030445056)
(* -1/2 (/ c b_2))
(if (<=
b_2
-7225426368408531/1852673427797059126777135760139006525652319754650249024631321344126610074238976)
(* c (/ a (* (- t_0 b_2) a)))
(if (<=
b_2
240000000000000007829447601155211065538340938625732871707250923667456)
(- (/ (- t_0) a) (/ b_2 a))
(* -2 (/ b_2 a)))))))double code(double a, double b_2, double c) {
double t_0 = sqrt(((b_2 * b_2) - (c * a)));
double tmp;
if (b_2 <= -5.5e+91) {
tmp = -0.5 * (c / b_2);
} else if (b_2 <= -3.9e-63) {
tmp = c * (a / ((t_0 - b_2) * a));
} else if (b_2 <= 2.4e+68) {
tmp = (-t_0 / a) - (b_2 / 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) :: t_0
real(8) :: tmp
t_0 = sqrt(((b_2 * b_2) - (c * a)))
if (b_2 <= (-5.5d+91)) then
tmp = (-0.5d0) * (c / b_2)
else if (b_2 <= (-3.9d-63)) then
tmp = c * (a / ((t_0 - b_2) * a))
else if (b_2 <= 2.4d+68) then
tmp = (-t_0 / a) - (b_2 / 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 t_0 = Math.sqrt(((b_2 * b_2) - (c * a)));
double tmp;
if (b_2 <= -5.5e+91) {
tmp = -0.5 * (c / b_2);
} else if (b_2 <= -3.9e-63) {
tmp = c * (a / ((t_0 - b_2) * a));
} else if (b_2 <= 2.4e+68) {
tmp = (-t_0 / a) - (b_2 / a);
} else {
tmp = -2.0 * (b_2 / a);
}
return tmp;
}
def code(a, b_2, c): t_0 = math.sqrt(((b_2 * b_2) - (c * a))) tmp = 0 if b_2 <= -5.5e+91: tmp = -0.5 * (c / b_2) elif b_2 <= -3.9e-63: tmp = c * (a / ((t_0 - b_2) * a)) elif b_2 <= 2.4e+68: tmp = (-t_0 / a) - (b_2 / a) else: tmp = -2.0 * (b_2 / a) return tmp
function code(a, b_2, c) t_0 = sqrt(Float64(Float64(b_2 * b_2) - Float64(c * a))) tmp = 0.0 if (b_2 <= -5.5e+91) tmp = Float64(-0.5 * Float64(c / b_2)); elseif (b_2 <= -3.9e-63) tmp = Float64(c * Float64(a / Float64(Float64(t_0 - b_2) * a))); elseif (b_2 <= 2.4e+68) tmp = Float64(Float64(Float64(-t_0) / a) - Float64(b_2 / a)); else tmp = Float64(-2.0 * Float64(b_2 / a)); end return tmp end
function tmp_2 = code(a, b_2, c) t_0 = sqrt(((b_2 * b_2) - (c * a))); tmp = 0.0; if (b_2 <= -5.5e+91) tmp = -0.5 * (c / b_2); elseif (b_2 <= -3.9e-63) tmp = c * (a / ((t_0 - b_2) * a)); elseif (b_2 <= 2.4e+68) tmp = (-t_0 / a) - (b_2 / a); else tmp = -2.0 * (b_2 / a); end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b$95$2 * b$95$2), $MachinePrecision] - N[(c * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b$95$2, -54999999999999998043547987204697905647054195046560117650923133451965273229273060805030445056], N[(-1/2 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, -7225426368408531/1852673427797059126777135760139006525652319754650249024631321344126610074238976], N[(c * N[(a / N[(N[(t$95$0 - b$95$2), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, 240000000000000007829447601155211065538340938625732871707250923667456], N[(N[((-t$95$0) / a), $MachinePrecision] - N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision], N[(-2 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
t_0 := \sqrt{b\_2 \cdot b\_2 - c \cdot a}\\
\mathbf{if}\;b\_2 \leq -54999999999999998043547987204697905647054195046560117650923133451965273229273060805030445056:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b\_2}\\
\mathbf{elif}\;b\_2 \leq \frac{-7225426368408531}{1852673427797059126777135760139006525652319754650249024631321344126610074238976}:\\
\;\;\;\;c \cdot \frac{a}{\left(t\_0 - b\_2\right) \cdot a}\\
\mathbf{elif}\;b\_2 \leq 240000000000000007829447601155211065538340938625732871707250923667456:\\
\;\;\;\;\frac{-t\_0}{a} - \frac{b\_2}{a}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b\_2}{a}\\
\end{array}
if b_2 < -5.4999999999999998e91Initial program 52.3%
Taylor expanded in b_2 around -inf
lower-*.f64N/A
lower-/.f6435.8%
Applied rewrites35.8%
if -5.4999999999999998e91 < b_2 < -3.9000000000000002e-63Initial program 52.3%
lift-/.f64N/A
frac-2negN/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f64N/A
lower-neg.f64N/A
lift--.f64N/A
sub-negate-revN/A
sub-flipN/A
+-commutativeN/A
lower-+.f64N/A
lift-neg.f64N/A
remove-double-neg52.2%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6452.2%
Applied rewrites52.2%
Applied rewrites42.6%
lift-/.f64N/A
lift-+.f64N/A
+-lft-identityN/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6446.0%
Applied rewrites46.0%
if -3.9000000000000002e-63 < b_2 < 2.4000000000000001e68Initial program 52.3%
lift-/.f64N/A
frac-2negN/A
lift--.f64N/A
sub-negate-revN/A
div-subN/A
distribute-neg-frac2N/A
lift-neg.f64N/A
frac-2negN/A
lower--.f64N/A
distribute-neg-fracN/A
lower-/.f64N/A
lower-neg.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites51.7%
if 2.4000000000000001e68 < b_2 Initial program 52.3%
Taylor expanded in b_2 around inf
lower-*.f64N/A
lower-/.f6434.6%
Applied rewrites34.6%
(FPCore (a b_2 c)
:precision binary64
(if (<=
b_2
-54999999999999998043547987204697905647054195046560117650923133451965273229273060805030445056)
(* -1/2 (/ c b_2))
(if (<=
b_2
-7225426368408531/1852673427797059126777135760139006525652319754650249024631321344126610074238976)
(* c (/ a (* (- (sqrt (- (* b_2 b_2) (* c a))) b_2) a)))
(if (<=
b_2
240000000000000007829447601155211065538340938625732871707250923667456)
(/ (- (- 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 <= -5.5e+91) {
tmp = -0.5 * (c / b_2);
} else if (b_2 <= -3.9e-63) {
tmp = c * (a / ((sqrt(((b_2 * b_2) - (c * a))) - b_2) * a));
} else if (b_2 <= 2.4e+68) {
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 <= (-5.5d+91)) then
tmp = (-0.5d0) * (c / b_2)
else if (b_2 <= (-3.9d-63)) then
tmp = c * (a / ((sqrt(((b_2 * b_2) - (c * a))) - b_2) * a))
else if (b_2 <= 2.4d+68) 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 <= -5.5e+91) {
tmp = -0.5 * (c / b_2);
} else if (b_2 <= -3.9e-63) {
tmp = c * (a / ((Math.sqrt(((b_2 * b_2) - (c * a))) - b_2) * a));
} else if (b_2 <= 2.4e+68) {
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 <= -5.5e+91: tmp = -0.5 * (c / b_2) elif b_2 <= -3.9e-63: tmp = c * (a / ((math.sqrt(((b_2 * b_2) - (c * a))) - b_2) * a)) elif b_2 <= 2.4e+68: 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 <= -5.5e+91) tmp = Float64(-0.5 * Float64(c / b_2)); elseif (b_2 <= -3.9e-63) tmp = Float64(c * Float64(a / Float64(Float64(sqrt(Float64(Float64(b_2 * b_2) - Float64(c * a))) - b_2) * a))); elseif (b_2 <= 2.4e+68) tmp = Float64(Float64(Float64(-b_2) - sqrt(Float64(Float64(b_2 * b_2) - Float64(a * c)))) / a); else tmp = Float64(-2.0 * Float64(b_2 / a)); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -5.5e+91) tmp = -0.5 * (c / b_2); elseif (b_2 <= -3.9e-63) tmp = c * (a / ((sqrt(((b_2 * b_2) - (c * a))) - b_2) * a)); elseif (b_2 <= 2.4e+68) 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, -54999999999999998043547987204697905647054195046560117650923133451965273229273060805030445056], N[(-1/2 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, -7225426368408531/1852673427797059126777135760139006525652319754650249024631321344126610074238976], N[(c * N[(a / 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]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, 240000000000000007829447601155211065538340938625732871707250923667456], 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[(-2 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\mathbf{if}\;b\_2 \leq -54999999999999998043547987204697905647054195046560117650923133451965273229273060805030445056:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b\_2}\\
\mathbf{elif}\;b\_2 \leq \frac{-7225426368408531}{1852673427797059126777135760139006525652319754650249024631321344126610074238976}:\\
\;\;\;\;c \cdot \frac{a}{\left(\sqrt{b\_2 \cdot b\_2 - c \cdot a} - b\_2\right) \cdot a}\\
\mathbf{elif}\;b\_2 \leq 240000000000000007829447601155211065538340938625732871707250923667456:\\
\;\;\;\;\frac{\left(-b\_2\right) - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b\_2}{a}\\
\end{array}
if b_2 < -5.4999999999999998e91Initial program 52.3%
Taylor expanded in b_2 around -inf
lower-*.f64N/A
lower-/.f6435.8%
Applied rewrites35.8%
if -5.4999999999999998e91 < b_2 < -3.9000000000000002e-63Initial program 52.3%
lift-/.f64N/A
frac-2negN/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f64N/A
lower-neg.f64N/A
lift--.f64N/A
sub-negate-revN/A
sub-flipN/A
+-commutativeN/A
lower-+.f64N/A
lift-neg.f64N/A
remove-double-neg52.2%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6452.2%
Applied rewrites52.2%
Applied rewrites42.6%
lift-/.f64N/A
lift-+.f64N/A
+-lft-identityN/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6446.0%
Applied rewrites46.0%
if -3.9000000000000002e-63 < b_2 < 2.4000000000000001e68Initial program 52.3%
if 2.4000000000000001e68 < b_2 Initial program 52.3%
Taylor expanded in b_2 around inf
lower-*.f64N/A
lower-/.f6434.6%
Applied rewrites34.6%
(FPCore (a b_2 c)
:precision binary64
(if (<=
b_2
-7225426368408531/1852673427797059126777135760139006525652319754650249024631321344126610074238976)
(* -1/2 (/ c b_2))
(if (<=
b_2
240000000000000007829447601155211065538340938625732871707250923667456)
(/ (- (- 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 <= -3.9e-63) {
tmp = -0.5 * (c / b_2);
} else if (b_2 <= 2.4e+68) {
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 <= (-3.9d-63)) then
tmp = (-0.5d0) * (c / b_2)
else if (b_2 <= 2.4d+68) 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 <= -3.9e-63) {
tmp = -0.5 * (c / b_2);
} else if (b_2 <= 2.4e+68) {
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 <= -3.9e-63: tmp = -0.5 * (c / b_2) elif b_2 <= 2.4e+68: 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 <= -3.9e-63) tmp = Float64(-0.5 * Float64(c / b_2)); elseif (b_2 <= 2.4e+68) tmp = Float64(Float64(Float64(-b_2) - sqrt(Float64(Float64(b_2 * b_2) - Float64(a * c)))) / a); else tmp = Float64(-2.0 * Float64(b_2 / a)); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -3.9e-63) tmp = -0.5 * (c / b_2); elseif (b_2 <= 2.4e+68) 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, -7225426368408531/1852673427797059126777135760139006525652319754650249024631321344126610074238976], N[(-1/2 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, 240000000000000007829447601155211065538340938625732871707250923667456], 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[(-2 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;b\_2 \leq \frac{-7225426368408531}{1852673427797059126777135760139006525652319754650249024631321344126610074238976}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b\_2}\\
\mathbf{elif}\;b\_2 \leq 240000000000000007829447601155211065538340938625732871707250923667456:\\
\;\;\;\;\frac{\left(-b\_2\right) - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b\_2}{a}\\
\end{array}
if b_2 < -3.9000000000000002e-63Initial program 52.3%
Taylor expanded in b_2 around -inf
lower-*.f64N/A
lower-/.f6435.8%
Applied rewrites35.8%
if -3.9000000000000002e-63 < b_2 < 2.4000000000000001e68Initial program 52.3%
if 2.4000000000000001e68 < b_2 Initial program 52.3%
Taylor expanded in b_2 around inf
lower-*.f64N/A
lower-/.f6434.6%
Applied rewrites34.6%
(FPCore (a b_2 c)
:precision binary64
(if (<=
b_2
-7040159025628825/1852673427797059126777135760139006525652319754650249024631321344126610074238976)
(* -1/2 (/ c b_2))
(if (<=
b_2
4199521391583383/139984046386112763159840142535527767382602843577165595931249318810236991948760059086304843329475444736)
(/ (- (- 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.8e-63) {
tmp = -0.5 * (c / b_2);
} else if (b_2 <= 3e-86) {
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.8d-63)) then
tmp = (-0.5d0) * (c / b_2)
else if (b_2 <= 3d-86) 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.8e-63) {
tmp = -0.5 * (c / b_2);
} else if (b_2 <= 3e-86) {
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.8e-63: tmp = -0.5 * (c / b_2) elif b_2 <= 3e-86: 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.8e-63) tmp = Float64(-0.5 * Float64(c / b_2)); elseif (b_2 <= 3e-86) tmp = Float64(Float64(Float64(-b_2) - sqrt(Float64(-Float64(a * c)))) / a); else tmp = Float64(-2.0 * Float64(b_2 / a)); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -3.8e-63) tmp = -0.5 * (c / b_2); elseif (b_2 <= 3e-86) 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, -7040159025628825/1852673427797059126777135760139006525652319754650249024631321344126610074238976], N[(-1/2 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, 4199521391583383/139984046386112763159840142535527767382602843577165595931249318810236991948760059086304843329475444736], N[(N[((-b$95$2) - N[Sqrt[(-N[(a * c), $MachinePrecision])], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(-2 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;b\_2 \leq \frac{-7040159025628825}{1852673427797059126777135760139006525652319754650249024631321344126610074238976}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b\_2}\\
\mathbf{elif}\;b\_2 \leq \frac{4199521391583383}{139984046386112763159840142535527767382602843577165595931249318810236991948760059086304843329475444736}:\\
\;\;\;\;\frac{\left(-b\_2\right) - \sqrt{-a \cdot c}}{a}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b\_2}{a}\\
\end{array}
if b_2 < -3.8000000000000002e-63Initial program 52.3%
Taylor expanded in b_2 around -inf
lower-*.f64N/A
lower-/.f6435.8%
Applied rewrites35.8%
if -3.8000000000000002e-63 < b_2 < 3.0000000000000001e-86Initial program 52.3%
Taylor expanded in b_2 around 0
lower-sqrt.f64N/A
lower-neg.f64N/A
lower-*.f6433.7%
Applied rewrites33.7%
if 3.0000000000000001e-86 < b_2 Initial program 52.3%
Taylor expanded in b_2 around inf
lower-*.f64N/A
lower-/.f6434.6%
Applied rewrites34.6%
(FPCore (a b_2 c)
:precision binary64
(if (<=
b_2
-7040159025628825/1852673427797059126777135760139006525652319754650249024631321344126610074238976)
(* -1/2 (/ c b_2))
(if (<=
b_2
4199521391583383/139984046386112763159840142535527767382602843577165595931249318810236991948760059086304843329475444736)
(/ c (sqrt (- (* a c))))
(* -2 (/ b_2 a)))))double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -3.8e-63) {
tmp = -0.5 * (c / b_2);
} else if (b_2 <= 3e-86) {
tmp = c / sqrt(-(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.8d-63)) then
tmp = (-0.5d0) * (c / b_2)
else if (b_2 <= 3d-86) then
tmp = c / sqrt(-(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.8e-63) {
tmp = -0.5 * (c / b_2);
} else if (b_2 <= 3e-86) {
tmp = c / Math.sqrt(-(a * c));
} else {
tmp = -2.0 * (b_2 / a);
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -3.8e-63: tmp = -0.5 * (c / b_2) elif b_2 <= 3e-86: tmp = c / math.sqrt(-(a * c)) else: tmp = -2.0 * (b_2 / a) return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -3.8e-63) tmp = Float64(-0.5 * Float64(c / b_2)); elseif (b_2 <= 3e-86) tmp = Float64(c / sqrt(Float64(-Float64(a * c)))); else tmp = Float64(-2.0 * Float64(b_2 / a)); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -3.8e-63) tmp = -0.5 * (c / b_2); elseif (b_2 <= 3e-86) tmp = c / sqrt(-(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, -7040159025628825/1852673427797059126777135760139006525652319754650249024631321344126610074238976], N[(-1/2 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, 4199521391583383/139984046386112763159840142535527767382602843577165595931249318810236991948760059086304843329475444736], N[(c / N[Sqrt[(-N[(a * c), $MachinePrecision])], $MachinePrecision]), $MachinePrecision], N[(-2 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;b\_2 \leq \frac{-7040159025628825}{1852673427797059126777135760139006525652319754650249024631321344126610074238976}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b\_2}\\
\mathbf{elif}\;b\_2 \leq \frac{4199521391583383}{139984046386112763159840142535527767382602843577165595931249318810236991948760059086304843329475444736}:\\
\;\;\;\;\frac{c}{\sqrt{-a \cdot c}}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b\_2}{a}\\
\end{array}
if b_2 < -3.8000000000000002e-63Initial program 52.3%
Taylor expanded in b_2 around -inf
lower-*.f64N/A
lower-/.f6435.8%
Applied rewrites35.8%
if -3.8000000000000002e-63 < b_2 < 3.0000000000000001e-86Initial program 52.3%
Applied rewrites29.1%
Taylor expanded in b_2 around 0
lower-/.f64N/A
lower-sqrt.f64N/A
lower-neg.f64N/A
lower-*.f6429.5%
Applied rewrites29.5%
if 3.0000000000000001e-86 < b_2 Initial program 52.3%
Taylor expanded in b_2 around inf
lower-*.f64N/A
lower-/.f6434.6%
Applied rewrites34.6%
(FPCore (a b_2 c)
:precision binary64
(if (<=
b_2
-8997827589086393/112472844863579909570263462692149546471742427957547915827518889315295939516787196757976017152597271428748022765838022378080206651387357492225212879521629096378368)
(* -1/2 (/ c b_2))
(if (<=
b_2
183729060881773/8749002899132047697490008908470485461412677723572849745703082425639811996797503692894052708092215296)
(sqrt (* -1 (/ c a)))
(* -2 (/ b_2 a)))))double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -8e-146) {
tmp = -0.5 * (c / b_2);
} else if (b_2 <= 2.1e-86) {
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 <= (-8d-146)) then
tmp = (-0.5d0) * (c / b_2)
else if (b_2 <= 2.1d-86) 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 <= -8e-146) {
tmp = -0.5 * (c / b_2);
} else if (b_2 <= 2.1e-86) {
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 <= -8e-146: tmp = -0.5 * (c / b_2) elif b_2 <= 2.1e-86: 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 <= -8e-146) tmp = Float64(-0.5 * Float64(c / b_2)); elseif (b_2 <= 2.1e-86) tmp = sqrt(Float64(-1.0 * Float64(c / a))); else tmp = Float64(-2.0 * Float64(b_2 / a)); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -8e-146) tmp = -0.5 * (c / b_2); elseif (b_2 <= 2.1e-86) 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, -8997827589086393/112472844863579909570263462692149546471742427957547915827518889315295939516787196757976017152597271428748022765838022378080206651387357492225212879521629096378368], N[(-1/2 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, 183729060881773/8749002899132047697490008908470485461412677723572849745703082425639811996797503692894052708092215296], N[Sqrt[N[(-1 * N[(c / a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(-2 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;b\_2 \leq \frac{-8997827589086393}{112472844863579909570263462692149546471742427957547915827518889315295939516787196757976017152597271428748022765838022378080206651387357492225212879521629096378368}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b\_2}\\
\mathbf{elif}\;b\_2 \leq \frac{183729060881773}{8749002899132047697490008908470485461412677723572849745703082425639811996797503692894052708092215296}:\\
\;\;\;\;\sqrt{-1 \cdot \frac{c}{a}}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b\_2}{a}\\
\end{array}
if b_2 < -8.0000000000000002e-146Initial program 52.3%
Taylor expanded in b_2 around -inf
lower-*.f64N/A
lower-/.f6435.8%
Applied rewrites35.8%
if -8.0000000000000002e-146 < b_2 < 2.1e-86Initial program 52.3%
Taylor expanded in a around -inf
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6416.5%
Applied rewrites16.5%
if 2.1e-86 < b_2 Initial program 52.3%
Taylor expanded in b_2 around inf
lower-*.f64N/A
lower-/.f6434.6%
Applied rewrites34.6%
(FPCore (a b_2 c)
:precision binary64
(if (<=
b_2
-5464863684898495/12420144738405671481191835907700020442055088136933572889112416304208407621491015090647027270629171823603901845577048585649372640352918515131554298200329449113635639808166799244402122285052787558602103993549731750007142774830528462848)
(* -1/2 (/ c b_2))
(* -2 (/ b_2 a))))double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -4.4e-217) {
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 <= (-4.4d-217)) 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 <= -4.4e-217) {
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 <= -4.4e-217: 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 <= -4.4e-217) tmp = Float64(-0.5 * Float64(c / b_2)); else tmp = Float64(-2.0 * Float64(b_2 / a)); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -4.4e-217) 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, -5464863684898495/12420144738405671481191835907700020442055088136933572889112416304208407621491015090647027270629171823603901845577048585649372640352918515131554298200329449113635639808166799244402122285052787558602103993549731750007142774830528462848], N[(-1/2 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision], N[(-2 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;b\_2 \leq \frac{-5464863684898495}{12420144738405671481191835907700020442055088136933572889112416304208407621491015090647027270629171823603901845577048585649372640352918515131554298200329449113635639808166799244402122285052787558602103993549731750007142774830528462848}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b\_2}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b\_2}{a}\\
\end{array}
if b_2 < -4.3999999999999996e-217Initial program 52.3%
Taylor expanded in b_2 around -inf
lower-*.f64N/A
lower-/.f6435.8%
Applied rewrites35.8%
if -4.3999999999999996e-217 < b_2 Initial program 52.3%
Taylor expanded in b_2 around inf
lower-*.f64N/A
lower-/.f6434.6%
Applied rewrites34.6%
(FPCore (a b_2 c)
:precision binary64
(if (<=
b_2
1454766195646295/6325070415853456823515479584966165845298645305129441198653167438357198111499854590373761990669910140474596183259900372230931523043306046152094168748148078435047419508642698792639590866940413010663742739952273283392562733857021646831815729864036236135650314266011211548510419206725953204130822734645187695728365866909171712)
(* -2 (/ 0 a))
(* -2 (/ b_2 a))))double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= 2.3e-307) {
tmp = -2.0 * (0.0 / 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.3d-307) then
tmp = (-2.0d0) * (0.0d0 / 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.3e-307) {
tmp = -2.0 * (0.0 / a);
} else {
tmp = -2.0 * (b_2 / a);
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= 2.3e-307: tmp = -2.0 * (0.0 / a) else: tmp = -2.0 * (b_2 / a) return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= 2.3e-307) tmp = Float64(-2.0 * Float64(0.0 / a)); else tmp = Float64(-2.0 * Float64(b_2 / a)); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= 2.3e-307) tmp = -2.0 * (0.0 / a); else tmp = -2.0 * (b_2 / a); end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, 1454766195646295/6325070415853456823515479584966165845298645305129441198653167438357198111499854590373761990669910140474596183259900372230931523043306046152094168748148078435047419508642698792639590866940413010663742739952273283392562733857021646831815729864036236135650314266011211548510419206725953204130822734645187695728365866909171712], N[(-2 * N[(0 / a), $MachinePrecision]), $MachinePrecision], N[(-2 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;b\_2 \leq \frac{1454766195646295}{6325070415853456823515479584966165845298645305129441198653167438357198111499854590373761990669910140474596183259900372230931523043306046152094168748148078435047419508642698792639590866940413010663742739952273283392562733857021646831815729864036236135650314266011211548510419206725953204130822734645187695728365866909171712}:\\
\;\;\;\;-2 \cdot \frac{0}{a}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b\_2}{a}\\
\end{array}
if b_2 < 2.2999999999999999e-307Initial program 52.3%
Taylor expanded in b_2 around inf
lower-*.f64N/A
lower-/.f6434.6%
Applied rewrites34.6%
Taylor expanded in undef-var around zero
Applied rewrites11.8%
if 2.2999999999999999e-307 < b_2 Initial program 52.3%
Taylor expanded in b_2 around inf
lower-*.f64N/A
lower-/.f6434.6%
Applied rewrites34.6%
(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 52.3%
Taylor expanded in b_2 around inf
lower-*.f64N/A
lower-/.f6434.6%
Applied rewrites34.6%
herbie shell --seed 2025274 -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))