
(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]
\begin{array}{l}
\\
\frac{\left(-b\_2\right) + \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a}
\end{array}
Herbie found 12 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]
\begin{array}{l}
\\
\frac{\left(-b\_2\right) + \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a}
\end{array}
(FPCore (a b_2 c)
:precision binary64
(if (<= b_2 -9.6e+64)
(fma (/ b_2 a) -2.0 (* 0.5 (/ c b_2)))
(if (<= b_2 8.6e-58)
(fma (/ b_2 a) -1.0 (/ (sqrt (fma (- a) c (* b_2 b_2))) a))
(* (/ c b_2) -0.5))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -9.6e+64) {
tmp = fma((b_2 / a), -2.0, (0.5 * (c / b_2)));
} else if (b_2 <= 8.6e-58) {
tmp = fma((b_2 / a), -1.0, (sqrt(fma(-a, c, (b_2 * b_2))) / a));
} else {
tmp = (c / b_2) * -0.5;
}
return tmp;
}
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -9.6e+64) tmp = fma(Float64(b_2 / a), -2.0, Float64(0.5 * Float64(c / b_2))); elseif (b_2 <= 8.6e-58) tmp = fma(Float64(b_2 / a), -1.0, Float64(sqrt(fma(Float64(-a), c, Float64(b_2 * b_2))) / a)); else tmp = Float64(Float64(c / b_2) * -0.5); end return tmp end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -9.6e+64], N[(N[(b$95$2 / a), $MachinePrecision] * -2.0 + N[(0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, 8.6e-58], N[(N[(b$95$2 / a), $MachinePrecision] * -1.0 + N[(N[Sqrt[N[((-a) * c + N[(b$95$2 * b$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b$95$2), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b\_2 \leq -9.6 \cdot 10^{+64}:\\
\;\;\;\;\mathsf{fma}\left(\frac{b\_2}{a}, -2, 0.5 \cdot \frac{c}{b\_2}\right)\\
\mathbf{elif}\;b\_2 \leq 8.6 \cdot 10^{-58}:\\
\;\;\;\;\mathsf{fma}\left(\frac{b\_2}{a}, -1, \frac{\sqrt{\mathsf{fma}\left(-a, c, b\_2 \cdot b\_2\right)}}{a}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b\_2} \cdot -0.5\\
\end{array}
\end{array}
if b_2 < -9.59999999999999997e64Initial program 58.2%
Taylor expanded in b_2 around -inf
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lift-neg.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f6494.2
Applied rewrites94.2%
Taylor expanded in a around inf
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f6494.5
Applied rewrites94.5%
if -9.59999999999999997e64 < b_2 < 8.5999999999999999e-58Initial program 77.9%
lift-/.f64N/A
lift-neg.f64N/A
lift-+.f64N/A
lift-sqrt.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
div-addN/A
mul-1-negN/A
associate-*r/N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f64N/A
Applied rewrites77.9%
if 8.5999999999999999e-58 < b_2 Initial program 17.5%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6487.0
Applied rewrites87.0%
(FPCore (a b_2 c)
:precision binary64
(if (<= b_2 -9.6e+64)
(fma (/ b_2 a) -2.0 (* 0.5 (/ c b_2)))
(if (<= b_2 8.6e-58)
(/ (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a)
(* (/ c b_2) -0.5))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -9.6e+64) {
tmp = fma((b_2 / a), -2.0, (0.5 * (c / b_2)));
} else if (b_2 <= 8.6e-58) {
tmp = (-b_2 + sqrt(((b_2 * b_2) - (a * c)))) / a;
} else {
tmp = (c / b_2) * -0.5;
}
return tmp;
}
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -9.6e+64) tmp = fma(Float64(b_2 / a), -2.0, Float64(0.5 * Float64(c / b_2))); elseif (b_2 <= 8.6e-58) tmp = Float64(Float64(Float64(-b_2) + sqrt(Float64(Float64(b_2 * b_2) - Float64(a * c)))) / a); else tmp = Float64(Float64(c / b_2) * -0.5); end return tmp end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -9.6e+64], N[(N[(b$95$2 / a), $MachinePrecision] * -2.0 + N[(0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, 8.6e-58], 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[(c / b$95$2), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b\_2 \leq -9.6 \cdot 10^{+64}:\\
\;\;\;\;\mathsf{fma}\left(\frac{b\_2}{a}, -2, 0.5 \cdot \frac{c}{b\_2}\right)\\
\mathbf{elif}\;b\_2 \leq 8.6 \cdot 10^{-58}:\\
\;\;\;\;\frac{\left(-b\_2\right) + \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b\_2} \cdot -0.5\\
\end{array}
\end{array}
if b_2 < -9.59999999999999997e64Initial program 58.2%
Taylor expanded in b_2 around -inf
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lift-neg.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f6494.2
Applied rewrites94.2%
Taylor expanded in a around inf
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f6494.5
Applied rewrites94.5%
if -9.59999999999999997e64 < b_2 < 8.5999999999999999e-58Initial program 77.9%
if 8.5999999999999999e-58 < b_2 Initial program 17.5%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6487.0
Applied rewrites87.0%
(FPCore (a b_2 c)
:precision binary64
(if (<= b_2 -3.1e-48)
(fma (/ b_2 a) -2.0 (* 0.5 (/ c b_2)))
(if (<= b_2 8.6e-58)
(/ (+ (- b_2) (sqrt (* (- a) c))) a)
(* (/ c b_2) -0.5))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -3.1e-48) {
tmp = fma((b_2 / a), -2.0, (0.5 * (c / b_2)));
} else if (b_2 <= 8.6e-58) {
tmp = (-b_2 + sqrt((-a * c))) / a;
} else {
tmp = (c / b_2) * -0.5;
}
return tmp;
}
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -3.1e-48) tmp = fma(Float64(b_2 / a), -2.0, Float64(0.5 * Float64(c / b_2))); elseif (b_2 <= 8.6e-58) tmp = Float64(Float64(Float64(-b_2) + sqrt(Float64(Float64(-a) * c))) / a); else tmp = Float64(Float64(c / b_2) * -0.5); end return tmp end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -3.1e-48], N[(N[(b$95$2 / a), $MachinePrecision] * -2.0 + N[(0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, 8.6e-58], N[(N[((-b$95$2) + N[Sqrt[N[((-a) * c), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(N[(c / b$95$2), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b\_2 \leq -3.1 \cdot 10^{-48}:\\
\;\;\;\;\mathsf{fma}\left(\frac{b\_2}{a}, -2, 0.5 \cdot \frac{c}{b\_2}\right)\\
\mathbf{elif}\;b\_2 \leq 8.6 \cdot 10^{-58}:\\
\;\;\;\;\frac{\left(-b\_2\right) + \sqrt{\left(-a\right) \cdot c}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b\_2} \cdot -0.5\\
\end{array}
\end{array}
if b_2 < -3.10000000000000016e-48Initial program 67.3%
Taylor expanded in b_2 around -inf
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lift-neg.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f6487.7
Applied rewrites87.7%
Taylor expanded in a around inf
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f6488.0
Applied rewrites88.0%
if -3.10000000000000016e-48 < b_2 < 8.5999999999999999e-58Initial program 73.9%
Taylor expanded in a around inf
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f6465.7
Applied rewrites65.7%
if 8.5999999999999999e-58 < b_2 Initial program 17.5%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6487.0
Applied rewrites87.0%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -2.8e-63) (fma (/ b_2 a) -2.0 (* 0.5 (/ c b_2))) (if (<= b_2 8.6e-58) (/ (sqrt (* (- a) c)) a) (* (/ c b_2) -0.5))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -2.8e-63) {
tmp = fma((b_2 / a), -2.0, (0.5 * (c / b_2)));
} else if (b_2 <= 8.6e-58) {
tmp = sqrt((-a * c)) / a;
} else {
tmp = (c / b_2) * -0.5;
}
return tmp;
}
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -2.8e-63) tmp = fma(Float64(b_2 / a), -2.0, Float64(0.5 * Float64(c / b_2))); elseif (b_2 <= 8.6e-58) tmp = Float64(sqrt(Float64(Float64(-a) * c)) / a); else tmp = Float64(Float64(c / b_2) * -0.5); end return tmp end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -2.8e-63], N[(N[(b$95$2 / a), $MachinePrecision] * -2.0 + N[(0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, 8.6e-58], N[(N[Sqrt[N[((-a) * c), $MachinePrecision]], $MachinePrecision] / a), $MachinePrecision], N[(N[(c / b$95$2), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b\_2 \leq -2.8 \cdot 10^{-63}:\\
\;\;\;\;\mathsf{fma}\left(\frac{b\_2}{a}, -2, 0.5 \cdot \frac{c}{b\_2}\right)\\
\mathbf{elif}\;b\_2 \leq 8.6 \cdot 10^{-58}:\\
\;\;\;\;\frac{\sqrt{\left(-a\right) \cdot c}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b\_2} \cdot -0.5\\
\end{array}
\end{array}
if b_2 < -2.8000000000000002e-63Initial program 68.1%
Taylor expanded in b_2 around -inf
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lift-neg.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f6486.4
Applied rewrites86.4%
Taylor expanded in a around inf
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f6486.7
Applied rewrites86.7%
if -2.8000000000000002e-63 < b_2 < 8.5999999999999999e-58Initial program 73.3%
Taylor expanded in a around inf
sqrt-unprodN/A
*-commutativeN/A
lower-sqrt.f64N/A
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f6465.3
Applied rewrites65.3%
if 8.5999999999999999e-58 < b_2 Initial program 17.5%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6487.0
Applied rewrites87.0%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -2.8e-63) (/ (* -2.0 b_2) a) (if (<= b_2 8.6e-58) (/ (sqrt (* (- a) c)) a) (* (/ c b_2) -0.5))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -2.8e-63) {
tmp = (-2.0 * b_2) / a;
} else if (b_2 <= 8.6e-58) {
tmp = sqrt((-a * c)) / a;
} else {
tmp = (c / b_2) * -0.5;
}
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.8d-63)) then
tmp = ((-2.0d0) * b_2) / a
else if (b_2 <= 8.6d-58) then
tmp = sqrt((-a * c)) / a
else
tmp = (c / b_2) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -2.8e-63) {
tmp = (-2.0 * b_2) / a;
} else if (b_2 <= 8.6e-58) {
tmp = Math.sqrt((-a * c)) / a;
} else {
tmp = (c / b_2) * -0.5;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -2.8e-63: tmp = (-2.0 * b_2) / a elif b_2 <= 8.6e-58: tmp = math.sqrt((-a * c)) / a else: tmp = (c / b_2) * -0.5 return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -2.8e-63) tmp = Float64(Float64(-2.0 * b_2) / a); elseif (b_2 <= 8.6e-58) tmp = Float64(sqrt(Float64(Float64(-a) * c)) / a); else tmp = Float64(Float64(c / b_2) * -0.5); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -2.8e-63) tmp = (-2.0 * b_2) / a; elseif (b_2 <= 8.6e-58) tmp = sqrt((-a * c)) / a; else tmp = (c / b_2) * -0.5; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -2.8e-63], N[(N[(-2.0 * b$95$2), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b$95$2, 8.6e-58], N[(N[Sqrt[N[((-a) * c), $MachinePrecision]], $MachinePrecision] / a), $MachinePrecision], N[(N[(c / b$95$2), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b\_2 \leq -2.8 \cdot 10^{-63}:\\
\;\;\;\;\frac{-2 \cdot b\_2}{a}\\
\mathbf{elif}\;b\_2 \leq 8.6 \cdot 10^{-58}:\\
\;\;\;\;\frac{\sqrt{\left(-a\right) \cdot c}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b\_2} \cdot -0.5\\
\end{array}
\end{array}
if b_2 < -2.8000000000000002e-63Initial program 68.1%
Taylor expanded in b_2 around -inf
lower-*.f6486.3
Applied rewrites86.3%
if -2.8000000000000002e-63 < b_2 < 8.5999999999999999e-58Initial program 73.3%
Taylor expanded in a around inf
sqrt-unprodN/A
*-commutativeN/A
lower-sqrt.f64N/A
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f6465.3
Applied rewrites65.3%
if 8.5999999999999999e-58 < b_2 Initial program 17.5%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6487.0
Applied rewrites87.0%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -5.5e-75) (/ (* -2.0 b_2) a) (if (<= b_2 6.2e-58) (/ (sqrt (- c)) (sqrt a)) (* (/ c b_2) -0.5))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -5.5e-75) {
tmp = (-2.0 * b_2) / a;
} else if (b_2 <= 6.2e-58) {
tmp = sqrt(-c) / sqrt(a);
} else {
tmp = (c / b_2) * -0.5;
}
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-75)) then
tmp = ((-2.0d0) * b_2) / a
else if (b_2 <= 6.2d-58) then
tmp = sqrt(-c) / sqrt(a)
else
tmp = (c / b_2) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -5.5e-75) {
tmp = (-2.0 * b_2) / a;
} else if (b_2 <= 6.2e-58) {
tmp = Math.sqrt(-c) / Math.sqrt(a);
} else {
tmp = (c / b_2) * -0.5;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -5.5e-75: tmp = (-2.0 * b_2) / a elif b_2 <= 6.2e-58: tmp = math.sqrt(-c) / math.sqrt(a) else: tmp = (c / b_2) * -0.5 return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -5.5e-75) tmp = Float64(Float64(-2.0 * b_2) / a); elseif (b_2 <= 6.2e-58) tmp = Float64(sqrt(Float64(-c)) / sqrt(a)); else tmp = Float64(Float64(c / b_2) * -0.5); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -5.5e-75) tmp = (-2.0 * b_2) / a; elseif (b_2 <= 6.2e-58) tmp = sqrt(-c) / sqrt(a); else tmp = (c / b_2) * -0.5; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -5.5e-75], N[(N[(-2.0 * b$95$2), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b$95$2, 6.2e-58], N[(N[Sqrt[(-c)], $MachinePrecision] / N[Sqrt[a], $MachinePrecision]), $MachinePrecision], N[(N[(c / b$95$2), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b\_2 \leq -5.5 \cdot 10^{-75}:\\
\;\;\;\;\frac{-2 \cdot b\_2}{a}\\
\mathbf{elif}\;b\_2 \leq 6.2 \cdot 10^{-58}:\\
\;\;\;\;\frac{\sqrt{-c}}{\sqrt{a}}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b\_2} \cdot -0.5\\
\end{array}
\end{array}
if b_2 < -5.50000000000000026e-75Initial program 68.4%
Taylor expanded in b_2 around -inf
lower-*.f6485.5
Applied rewrites85.5%
if -5.50000000000000026e-75 < b_2 < 6.1999999999999998e-58Initial program 73.0%
Taylor expanded in a around inf
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6432.6
Applied rewrites32.6%
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6432.6
Applied rewrites32.6%
lift-sqrt.f64N/A
lift-neg.f64N/A
lift-/.f64N/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lift-neg.f64N/A
lower-sqrt.f6441.9
Applied rewrites41.9%
if 6.1999999999999998e-58 < b_2 Initial program 17.5%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6486.9
Applied rewrites86.9%
(FPCore (a b_2 c)
:precision binary64
(let* ((t_0 (sqrt (/ (- c) a))) (t_1 (- t_0)))
(if (<= b_2 -2.8e-63)
(/ (* -2.0 b_2) a)
(if (<= b_2 -2.1e-183)
t_1
(if (<= b_2 8.5e-287)
t_0
(if (<= b_2 3.5e-55) t_1 (* (/ c b_2) -0.5)))))))
double code(double a, double b_2, double c) {
double t_0 = sqrt((-c / a));
double t_1 = -t_0;
double tmp;
if (b_2 <= -2.8e-63) {
tmp = (-2.0 * b_2) / a;
} else if (b_2 <= -2.1e-183) {
tmp = t_1;
} else if (b_2 <= 8.5e-287) {
tmp = t_0;
} else if (b_2 <= 3.5e-55) {
tmp = t_1;
} else {
tmp = (c / b_2) * -0.5;
}
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) :: t_1
real(8) :: tmp
t_0 = sqrt((-c / a))
t_1 = -t_0
if (b_2 <= (-2.8d-63)) then
tmp = ((-2.0d0) * b_2) / a
else if (b_2 <= (-2.1d-183)) then
tmp = t_1
else if (b_2 <= 8.5d-287) then
tmp = t_0
else if (b_2 <= 3.5d-55) then
tmp = t_1
else
tmp = (c / b_2) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double t_0 = Math.sqrt((-c / a));
double t_1 = -t_0;
double tmp;
if (b_2 <= -2.8e-63) {
tmp = (-2.0 * b_2) / a;
} else if (b_2 <= -2.1e-183) {
tmp = t_1;
} else if (b_2 <= 8.5e-287) {
tmp = t_0;
} else if (b_2 <= 3.5e-55) {
tmp = t_1;
} else {
tmp = (c / b_2) * -0.5;
}
return tmp;
}
def code(a, b_2, c): t_0 = math.sqrt((-c / a)) t_1 = -t_0 tmp = 0 if b_2 <= -2.8e-63: tmp = (-2.0 * b_2) / a elif b_2 <= -2.1e-183: tmp = t_1 elif b_2 <= 8.5e-287: tmp = t_0 elif b_2 <= 3.5e-55: tmp = t_1 else: tmp = (c / b_2) * -0.5 return tmp
function code(a, b_2, c) t_0 = sqrt(Float64(Float64(-c) / a)) t_1 = Float64(-t_0) tmp = 0.0 if (b_2 <= -2.8e-63) tmp = Float64(Float64(-2.0 * b_2) / a); elseif (b_2 <= -2.1e-183) tmp = t_1; elseif (b_2 <= 8.5e-287) tmp = t_0; elseif (b_2 <= 3.5e-55) tmp = t_1; else tmp = Float64(Float64(c / b_2) * -0.5); end return tmp end
function tmp_2 = code(a, b_2, c) t_0 = sqrt((-c / a)); t_1 = -t_0; tmp = 0.0; if (b_2 <= -2.8e-63) tmp = (-2.0 * b_2) / a; elseif (b_2 <= -2.1e-183) tmp = t_1; elseif (b_2 <= 8.5e-287) tmp = t_0; elseif (b_2 <= 3.5e-55) tmp = t_1; else tmp = (c / b_2) * -0.5; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := Block[{t$95$0 = N[Sqrt[N[((-c) / a), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = (-t$95$0)}, If[LessEqual[b$95$2, -2.8e-63], N[(N[(-2.0 * b$95$2), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b$95$2, -2.1e-183], t$95$1, If[LessEqual[b$95$2, 8.5e-287], t$95$0, If[LessEqual[b$95$2, 3.5e-55], t$95$1, N[(N[(c / b$95$2), $MachinePrecision] * -0.5), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\frac{-c}{a}}\\
t_1 := -t\_0\\
\mathbf{if}\;b\_2 \leq -2.8 \cdot 10^{-63}:\\
\;\;\;\;\frac{-2 \cdot b\_2}{a}\\
\mathbf{elif}\;b\_2 \leq -2.1 \cdot 10^{-183}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;b\_2 \leq 8.5 \cdot 10^{-287}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b\_2 \leq 3.5 \cdot 10^{-55}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b\_2} \cdot -0.5\\
\end{array}
\end{array}
if b_2 < -2.8000000000000002e-63Initial program 68.1%
Taylor expanded in b_2 around -inf
lower-*.f6486.3
Applied rewrites86.3%
if -2.8000000000000002e-63 < b_2 < -2.1000000000000002e-183 or 8.5000000000000003e-287 < b_2 < 3.50000000000000025e-55Initial program 73.1%
lift-/.f64N/A
lift-neg.f64N/A
lift-+.f64N/A
lift-sqrt.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
div-addN/A
mul-1-negN/A
associate-*r/N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f64N/A
Applied rewrites73.0%
Taylor expanded in a around -inf
*-commutativeN/A
mul-1-negN/A
distribute-frac-negN/A
lift-neg.f64N/A
lift-*.f64N/A
pow2N/A
+-commutativeN/A
lift-*.f64N/A
lift-neg.f64N/A
fp-cancel-sub-sign-invN/A
pow2N/A
div-addN/A
mul-1-negN/A
lower-neg.f64N/A
sqrt-prodN/A
lower-sqrt.f64N/A
Applied rewrites28.4%
if -2.1000000000000002e-183 < b_2 < 8.5000000000000003e-287Initial program 73.3%
Taylor expanded in a around inf
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6440.7
Applied rewrites40.7%
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6440.7
Applied rewrites40.7%
if 3.50000000000000025e-55 < b_2 Initial program 17.4%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6487.2
Applied rewrites87.2%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -4.1e-137) (/ (* -2.0 b_2) a) (if (<= b_2 6.2e-58) (sqrt (/ (- c) a)) (* (/ c b_2) -0.5))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -4.1e-137) {
tmp = (-2.0 * b_2) / a;
} else if (b_2 <= 6.2e-58) {
tmp = sqrt((-c / a));
} else {
tmp = (c / b_2) * -0.5;
}
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.1d-137)) then
tmp = ((-2.0d0) * b_2) / a
else if (b_2 <= 6.2d-58) then
tmp = sqrt((-c / a))
else
tmp = (c / b_2) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -4.1e-137) {
tmp = (-2.0 * b_2) / a;
} else if (b_2 <= 6.2e-58) {
tmp = Math.sqrt((-c / a));
} else {
tmp = (c / b_2) * -0.5;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -4.1e-137: tmp = (-2.0 * b_2) / a elif b_2 <= 6.2e-58: tmp = math.sqrt((-c / a)) else: tmp = (c / b_2) * -0.5 return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -4.1e-137) tmp = Float64(Float64(-2.0 * b_2) / a); elseif (b_2 <= 6.2e-58) tmp = sqrt(Float64(Float64(-c) / a)); else tmp = Float64(Float64(c / b_2) * -0.5); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -4.1e-137) tmp = (-2.0 * b_2) / a; elseif (b_2 <= 6.2e-58) tmp = sqrt((-c / a)); else tmp = (c / b_2) * -0.5; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -4.1e-137], N[(N[(-2.0 * b$95$2), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b$95$2, 6.2e-58], N[Sqrt[N[((-c) / a), $MachinePrecision]], $MachinePrecision], N[(N[(c / b$95$2), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b\_2 \leq -4.1 \cdot 10^{-137}:\\
\;\;\;\;\frac{-2 \cdot b\_2}{a}\\
\mathbf{elif}\;b\_2 \leq 6.2 \cdot 10^{-58}:\\
\;\;\;\;\sqrt{\frac{-c}{a}}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b\_2} \cdot -0.5\\
\end{array}
\end{array}
if b_2 < -4.0999999999999999e-137Initial program 70.5%
Taylor expanded in b_2 around -inf
lower-*.f6480.4
Applied rewrites80.4%
if -4.0999999999999999e-137 < b_2 < 6.1999999999999998e-58Initial program 70.6%
Taylor expanded in a around inf
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6434.2
Applied rewrites34.2%
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6434.2
Applied rewrites34.2%
if 6.1999999999999998e-58 < b_2 Initial program 17.5%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6486.9
Applied rewrites86.9%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -1.1e-70) (/ (- b_2) a) (if (<= b_2 6.2e-58) (sqrt (/ (- c) a)) (* (/ c b_2) -0.5))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -1.1e-70) {
tmp = -b_2 / a;
} else if (b_2 <= 6.2e-58) {
tmp = sqrt((-c / a));
} else {
tmp = (c / b_2) * -0.5;
}
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.1d-70)) then
tmp = -b_2 / a
else if (b_2 <= 6.2d-58) then
tmp = sqrt((-c / a))
else
tmp = (c / b_2) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -1.1e-70) {
tmp = -b_2 / a;
} else if (b_2 <= 6.2e-58) {
tmp = Math.sqrt((-c / a));
} else {
tmp = (c / b_2) * -0.5;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -1.1e-70: tmp = -b_2 / a elif b_2 <= 6.2e-58: tmp = math.sqrt((-c / a)) else: tmp = (c / b_2) * -0.5 return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -1.1e-70) tmp = Float64(Float64(-b_2) / a); elseif (b_2 <= 6.2e-58) tmp = sqrt(Float64(Float64(-c) / a)); else tmp = Float64(Float64(c / b_2) * -0.5); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -1.1e-70) tmp = -b_2 / a; elseif (b_2 <= 6.2e-58) tmp = sqrt((-c / a)); else tmp = (c / b_2) * -0.5; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -1.1e-70], N[((-b$95$2) / a), $MachinePrecision], If[LessEqual[b$95$2, 6.2e-58], N[Sqrt[N[((-c) / a), $MachinePrecision]], $MachinePrecision], N[(N[(c / b$95$2), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b\_2 \leq -1.1 \cdot 10^{-70}:\\
\;\;\;\;\frac{-b\_2}{a}\\
\mathbf{elif}\;b\_2 \leq 6.2 \cdot 10^{-58}:\\
\;\;\;\;\sqrt{\frac{-c}{a}}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b\_2} \cdot -0.5\\
\end{array}
\end{array}
if b_2 < -1.0999999999999999e-70Initial program 68.3%
Taylor expanded in a around -inf
*-commutativeN/A
lower-fma.f64N/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f64N/A
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lift-neg.f6422.2
Applied rewrites22.2%
Taylor expanded in b_2 around inf
mul-1-negN/A
distribute-frac-negN/A
lift-/.f64N/A
lift-neg.f6436.4
Applied rewrites36.4%
if -1.0999999999999999e-70 < b_2 < 6.1999999999999998e-58Initial program 73.1%
Taylor expanded in a around inf
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6432.6
Applied rewrites32.6%
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6432.6
Applied rewrites32.6%
if 6.1999999999999998e-58 < b_2 Initial program 17.5%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6486.9
Applied rewrites86.9%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -1.1e-70) (/ (- b_2) a) (if (<= b_2 2.7e+40) (sqrt (/ (- c) a)) (* 0.5 (/ c b_2)))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -1.1e-70) {
tmp = -b_2 / a;
} else if (b_2 <= 2.7e+40) {
tmp = sqrt((-c / a));
} else {
tmp = 0.5 * (c / b_2);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b_2, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
real(8) :: tmp
if (b_2 <= (-1.1d-70)) then
tmp = -b_2 / a
else if (b_2 <= 2.7d+40) then
tmp = sqrt((-c / a))
else
tmp = 0.5d0 * (c / b_2)
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -1.1e-70) {
tmp = -b_2 / a;
} else if (b_2 <= 2.7e+40) {
tmp = Math.sqrt((-c / a));
} else {
tmp = 0.5 * (c / b_2);
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -1.1e-70: tmp = -b_2 / a elif b_2 <= 2.7e+40: tmp = math.sqrt((-c / a)) else: tmp = 0.5 * (c / b_2) return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -1.1e-70) tmp = Float64(Float64(-b_2) / a); elseif (b_2 <= 2.7e+40) tmp = sqrt(Float64(Float64(-c) / a)); else tmp = Float64(0.5 * Float64(c / b_2)); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -1.1e-70) tmp = -b_2 / a; elseif (b_2 <= 2.7e+40) tmp = sqrt((-c / a)); else tmp = 0.5 * (c / b_2); end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -1.1e-70], N[((-b$95$2) / a), $MachinePrecision], If[LessEqual[b$95$2, 2.7e+40], N[Sqrt[N[((-c) / a), $MachinePrecision]], $MachinePrecision], N[(0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b\_2 \leq -1.1 \cdot 10^{-70}:\\
\;\;\;\;\frac{-b\_2}{a}\\
\mathbf{elif}\;b\_2 \leq 2.7 \cdot 10^{+40}:\\
\;\;\;\;\sqrt{\frac{-c}{a}}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{c}{b\_2}\\
\end{array}
\end{array}
if b_2 < -1.0999999999999999e-70Initial program 68.3%
Taylor expanded in a around -inf
*-commutativeN/A
lower-fma.f64N/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f64N/A
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lift-neg.f6422.2
Applied rewrites22.2%
Taylor expanded in b_2 around inf
mul-1-negN/A
distribute-frac-negN/A
lift-/.f64N/A
lift-neg.f6436.4
Applied rewrites36.4%
if -1.0999999999999999e-70 < b_2 < 2.70000000000000009e40Initial program 65.6%
Taylor expanded in a around inf
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6429.5
Applied rewrites29.5%
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6429.5
Applied rewrites29.5%
if 2.70000000000000009e40 < b_2 Initial program 12.7%
Taylor expanded in b_2 around -inf
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lift-neg.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f642.5
Applied rewrites2.5%
Taylor expanded in a around inf
lower-*.f64N/A
lower-/.f6431.8
Applied rewrites31.8%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 3.5e+40) (/ (- b_2) a) (* 0.5 (/ c b_2))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= 3.5e+40) {
tmp = -b_2 / a;
} else {
tmp = 0.5 * (c / b_2);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b_2, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
real(8) :: tmp
if (b_2 <= 3.5d+40) then
tmp = -b_2 / a
else
tmp = 0.5d0 * (c / b_2)
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= 3.5e+40) {
tmp = -b_2 / a;
} else {
tmp = 0.5 * (c / b_2);
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= 3.5e+40: tmp = -b_2 / a else: tmp = 0.5 * (c / b_2) return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= 3.5e+40) tmp = Float64(Float64(-b_2) / a); else tmp = Float64(0.5 * Float64(c / b_2)); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= 3.5e+40) tmp = -b_2 / a; else tmp = 0.5 * (c / b_2); end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, 3.5e+40], N[((-b$95$2) / a), $MachinePrecision], N[(0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b\_2 \leq 3.5 \cdot 10^{+40}:\\
\;\;\;\;\frac{-b\_2}{a}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{c}{b\_2}\\
\end{array}
\end{array}
if b_2 < 3.4999999999999999e40Initial program 66.9%
Taylor expanded in a around -inf
*-commutativeN/A
lower-fma.f64N/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f64N/A
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lift-neg.f6425.0
Applied rewrites25.0%
Taylor expanded in b_2 around inf
mul-1-negN/A
distribute-frac-negN/A
lift-/.f64N/A
lift-neg.f6420.0
Applied rewrites20.0%
if 3.4999999999999999e40 < b_2 Initial program 12.7%
Taylor expanded in b_2 around -inf
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lift-neg.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f642.5
Applied rewrites2.5%
Taylor expanded in a around inf
lower-*.f64N/A
lower-/.f6431.8
Applied rewrites31.8%
(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]
\begin{array}{l}
\\
\frac{-b\_2}{a}
\end{array}
Initial program 52.9%
Taylor expanded in a around -inf
*-commutativeN/A
lower-fma.f64N/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f64N/A
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lift-neg.f6419.6
Applied rewrites19.6%
Taylor expanded in b_2 around inf
mul-1-negN/A
distribute-frac-negN/A
lift-/.f64N/A
lift-neg.f6415.5
Applied rewrites15.5%
herbie shell --seed 2025101
(FPCore (a b_2 c)
:name "quad2p (problem 3.2.1, positive)"
:precision binary64
:herbie-expected 10
(/ (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))