
(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 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]
\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 -3.5e-48)
(- (/ (* (fma (* a (/ (/ c b_2) b_2)) 0.125 0.5) c) b_2))
(if (<= b_2 6.2e+65)
(/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a)
(* (/ b_2 a) -2.0))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -3.5e-48) {
tmp = -((fma((a * ((c / b_2) / b_2)), 0.125, 0.5) * c) / b_2);
} else if (b_2 <= 6.2e+65) {
tmp = (-b_2 - sqrt(((b_2 * b_2) - (a * c)))) / a;
} else {
tmp = (b_2 / a) * -2.0;
}
return tmp;
}
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -3.5e-48) tmp = Float64(-Float64(Float64(fma(Float64(a * Float64(Float64(c / b_2) / b_2)), 0.125, 0.5) * c) / b_2)); elseif (b_2 <= 6.2e+65) tmp = Float64(Float64(Float64(-b_2) - sqrt(Float64(Float64(b_2 * b_2) - Float64(a * c)))) / a); else tmp = Float64(Float64(b_2 / a) * -2.0); end return tmp end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -3.5e-48], (-N[(N[(N[(N[(a * N[(N[(c / b$95$2), $MachinePrecision] / b$95$2), $MachinePrecision]), $MachinePrecision] * 0.125 + 0.5), $MachinePrecision] * c), $MachinePrecision] / b$95$2), $MachinePrecision]), If[LessEqual[b$95$2, 6.2e+65], 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[(b$95$2 / a), $MachinePrecision] * -2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b\_2 \leq -3.5 \cdot 10^{-48}:\\
\;\;\;\;-\frac{\mathsf{fma}\left(a \cdot \frac{\frac{c}{b\_2}}{b\_2}, 0.125, 0.5\right) \cdot c}{b\_2}\\
\mathbf{elif}\;b\_2 \leq 6.2 \cdot 10^{+65}:\\
\;\;\;\;\frac{\left(-b\_2\right) - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{b\_2}{a} \cdot -2\\
\end{array}
\end{array}
if b_2 < -3.49999999999999991e-48Initial program 15.8%
Taylor expanded in b_2 around -inf
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
lower-*.f6470.0
Applied rewrites70.0%
Taylor expanded in c around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f6487.4
Applied rewrites87.4%
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6487.3
Applied rewrites87.3%
if -3.49999999999999991e-48 < b_2 < 6.19999999999999981e65Initial program 76.8%
if 6.19999999999999981e65 < b_2 Initial program 58.0%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6494.7
Applied rewrites94.7%
(FPCore (a b_2 c)
:precision binary64
(if (<= b_2 -3.5e-48)
(- (/ (* (fma (* a (/ c (* b_2 b_2))) 0.125 0.5) c) b_2))
(if (<= b_2 6.2e+65)
(/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a)
(* (/ b_2 a) -2.0))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -3.5e-48) {
tmp = -((fma((a * (c / (b_2 * b_2))), 0.125, 0.5) * c) / b_2);
} else if (b_2 <= 6.2e+65) {
tmp = (-b_2 - sqrt(((b_2 * b_2) - (a * c)))) / a;
} else {
tmp = (b_2 / a) * -2.0;
}
return tmp;
}
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -3.5e-48) tmp = Float64(-Float64(Float64(fma(Float64(a * Float64(c / Float64(b_2 * b_2))), 0.125, 0.5) * c) / b_2)); elseif (b_2 <= 6.2e+65) tmp = Float64(Float64(Float64(-b_2) - sqrt(Float64(Float64(b_2 * b_2) - Float64(a * c)))) / a); else tmp = Float64(Float64(b_2 / a) * -2.0); end return tmp end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -3.5e-48], (-N[(N[(N[(N[(a * N[(c / N[(b$95$2 * b$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.125 + 0.5), $MachinePrecision] * c), $MachinePrecision] / b$95$2), $MachinePrecision]), If[LessEqual[b$95$2, 6.2e+65], 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[(b$95$2 / a), $MachinePrecision] * -2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b\_2 \leq -3.5 \cdot 10^{-48}:\\
\;\;\;\;-\frac{\mathsf{fma}\left(a \cdot \frac{c}{b\_2 \cdot b\_2}, 0.125, 0.5\right) \cdot c}{b\_2}\\
\mathbf{elif}\;b\_2 \leq 6.2 \cdot 10^{+65}:\\
\;\;\;\;\frac{\left(-b\_2\right) - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{b\_2}{a} \cdot -2\\
\end{array}
\end{array}
if b_2 < -3.49999999999999991e-48Initial program 15.8%
Taylor expanded in b_2 around -inf
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
lower-*.f6470.0
Applied rewrites70.0%
Taylor expanded in c around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f6487.4
Applied rewrites87.4%
if -3.49999999999999991e-48 < b_2 < 6.19999999999999981e65Initial program 76.8%
if 6.19999999999999981e65 < b_2 Initial program 58.0%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6494.7
Applied rewrites94.7%
(FPCore (a b_2 c)
:precision binary64
(if (<= b_2 -4.6e-63)
(* -0.5 (/ c b_2))
(if (<= b_2 6.2e+65)
(/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a)
(* (/ b_2 a) -2.0))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -4.6e-63) {
tmp = -0.5 * (c / b_2);
} else if (b_2 <= 6.2e+65) {
tmp = (-b_2 - sqrt(((b_2 * b_2) - (a * c)))) / a;
} else {
tmp = (b_2 / a) * -2.0;
}
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.6d-63)) then
tmp = (-0.5d0) * (c / b_2)
else if (b_2 <= 6.2d+65) then
tmp = (-b_2 - sqrt(((b_2 * b_2) - (a * c)))) / a
else
tmp = (b_2 / a) * (-2.0d0)
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -4.6e-63) {
tmp = -0.5 * (c / b_2);
} else if (b_2 <= 6.2e+65) {
tmp = (-b_2 - Math.sqrt(((b_2 * b_2) - (a * c)))) / a;
} else {
tmp = (b_2 / a) * -2.0;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -4.6e-63: tmp = -0.5 * (c / b_2) elif b_2 <= 6.2e+65: tmp = (-b_2 - math.sqrt(((b_2 * b_2) - (a * c)))) / a else: tmp = (b_2 / a) * -2.0 return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -4.6e-63) tmp = Float64(-0.5 * Float64(c / b_2)); elseif (b_2 <= 6.2e+65) tmp = Float64(Float64(Float64(-b_2) - sqrt(Float64(Float64(b_2 * b_2) - Float64(a * c)))) / a); else tmp = Float64(Float64(b_2 / a) * -2.0); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -4.6e-63) tmp = -0.5 * (c / b_2); elseif (b_2 <= 6.2e+65) tmp = (-b_2 - sqrt(((b_2 * b_2) - (a * c)))) / a; else tmp = (b_2 / a) * -2.0; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -4.6e-63], N[(-0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, 6.2e+65], 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[(b$95$2 / a), $MachinePrecision] * -2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b\_2 \leq -4.6 \cdot 10^{-63}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b\_2}\\
\mathbf{elif}\;b\_2 \leq 6.2 \cdot 10^{+65}:\\
\;\;\;\;\frac{\left(-b\_2\right) - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{b\_2}{a} \cdot -2\\
\end{array}
\end{array}
if b_2 < -4.6e-63Initial program 16.9%
Taylor expanded in b_2 around -inf
lower-*.f64N/A
lower-/.f6486.3
Applied rewrites86.3%
if -4.6e-63 < b_2 < 6.19999999999999981e65Initial program 77.7%
if 6.19999999999999981e65 < b_2 Initial program 58.0%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6494.7
Applied rewrites94.7%
(FPCore (a b_2 c)
:precision binary64
(if (<= b_2 -4.6e-63)
(* -0.5 (/ c b_2))
(if (<= b_2 7e+22)
(/ (- (- b_2) (sqrt (* (- a) c))) a)
(* (/ b_2 a) -2.0))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -4.6e-63) {
tmp = -0.5 * (c / b_2);
} else if (b_2 <= 7e+22) {
tmp = (-b_2 - sqrt((-a * c))) / a;
} else {
tmp = (b_2 / a) * -2.0;
}
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.6d-63)) then
tmp = (-0.5d0) * (c / b_2)
else if (b_2 <= 7d+22) then
tmp = (-b_2 - sqrt((-a * c))) / a
else
tmp = (b_2 / a) * (-2.0d0)
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -4.6e-63) {
tmp = -0.5 * (c / b_2);
} else if (b_2 <= 7e+22) {
tmp = (-b_2 - Math.sqrt((-a * c))) / a;
} else {
tmp = (b_2 / a) * -2.0;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -4.6e-63: tmp = -0.5 * (c / b_2) elif b_2 <= 7e+22: tmp = (-b_2 - math.sqrt((-a * c))) / a else: tmp = (b_2 / a) * -2.0 return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -4.6e-63) tmp = Float64(-0.5 * Float64(c / b_2)); elseif (b_2 <= 7e+22) tmp = Float64(Float64(Float64(-b_2) - sqrt(Float64(Float64(-a) * c))) / a); else tmp = Float64(Float64(b_2 / a) * -2.0); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -4.6e-63) tmp = -0.5 * (c / b_2); elseif (b_2 <= 7e+22) tmp = (-b_2 - sqrt((-a * c))) / a; else tmp = (b_2 / a) * -2.0; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -4.6e-63], N[(-0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, 7e+22], N[(N[((-b$95$2) - N[Sqrt[N[((-a) * c), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(N[(b$95$2 / a), $MachinePrecision] * -2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b\_2 \leq -4.6 \cdot 10^{-63}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b\_2}\\
\mathbf{elif}\;b\_2 \leq 7 \cdot 10^{+22}:\\
\;\;\;\;\frac{\left(-b\_2\right) - \sqrt{\left(-a\right) \cdot c}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{b\_2}{a} \cdot -2\\
\end{array}
\end{array}
if b_2 < -4.6e-63Initial program 16.9%
Taylor expanded in b_2 around -inf
lower-*.f64N/A
lower-/.f6486.3
Applied rewrites86.3%
if -4.6e-63 < b_2 < 7e22Initial program 76.3%
Taylor expanded in a around inf
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f6462.1
Applied rewrites62.1%
if 7e22 < b_2 Initial program 62.7%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6492.3
Applied rewrites92.3%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -4.6e-63) (* -0.5 (/ c b_2)) (if (<= b_2 2.1e-57) (/ (- (sqrt (* (- a) c))) a) (* (/ b_2 a) -2.0))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -4.6e-63) {
tmp = -0.5 * (c / b_2);
} else if (b_2 <= 2.1e-57) {
tmp = -sqrt((-a * c)) / a;
} else {
tmp = (b_2 / a) * -2.0;
}
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.6d-63)) then
tmp = (-0.5d0) * (c / b_2)
else if (b_2 <= 2.1d-57) then
tmp = -sqrt((-a * c)) / a
else
tmp = (b_2 / a) * (-2.0d0)
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -4.6e-63) {
tmp = -0.5 * (c / b_2);
} else if (b_2 <= 2.1e-57) {
tmp = -Math.sqrt((-a * c)) / a;
} else {
tmp = (b_2 / a) * -2.0;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -4.6e-63: tmp = -0.5 * (c / b_2) elif b_2 <= 2.1e-57: tmp = -math.sqrt((-a * c)) / a else: tmp = (b_2 / a) * -2.0 return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -4.6e-63) tmp = Float64(-0.5 * Float64(c / b_2)); elseif (b_2 <= 2.1e-57) tmp = Float64(Float64(-sqrt(Float64(Float64(-a) * c))) / a); else tmp = Float64(Float64(b_2 / a) * -2.0); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -4.6e-63) tmp = -0.5 * (c / b_2); elseif (b_2 <= 2.1e-57) tmp = -sqrt((-a * c)) / a; else tmp = (b_2 / a) * -2.0; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -4.6e-63], N[(-0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, 2.1e-57], N[((-N[Sqrt[N[((-a) * c), $MachinePrecision]], $MachinePrecision]) / a), $MachinePrecision], N[(N[(b$95$2 / a), $MachinePrecision] * -2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b\_2 \leq -4.6 \cdot 10^{-63}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b\_2}\\
\mathbf{elif}\;b\_2 \leq 2.1 \cdot 10^{-57}:\\
\;\;\;\;\frac{-\sqrt{\left(-a\right) \cdot c}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{b\_2}{a} \cdot -2\\
\end{array}
\end{array}
if b_2 < -4.6e-63Initial program 16.9%
Taylor expanded in b_2 around -inf
lower-*.f64N/A
lower-/.f6486.3
Applied rewrites86.3%
if -4.6e-63 < b_2 < 2.0999999999999999e-57Initial program 73.3%
Taylor expanded in a around inf
mul-1-negN/A
lower-neg.f64N/A
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 2.0999999999999999e-57 < b_2 Initial program 67.9%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6487.0
Applied rewrites87.0%
(FPCore (a b_2 c)
:precision binary64
(let* ((t_0 (sqrt (/ (- c) a))))
(if (<= b_2 -1.5e-64)
(* -0.5 (/ c b_2))
(if (<= b_2 -4.5e-177)
t_0
(if (<= b_2 1.15e-285)
(- t_0)
(if (<= b_2 3.5e-55) t_0 (* (/ b_2 a) -2.0)))))))
double code(double a, double b_2, double c) {
double t_0 = sqrt((-c / a));
double tmp;
if (b_2 <= -1.5e-64) {
tmp = -0.5 * (c / b_2);
} else if (b_2 <= -4.5e-177) {
tmp = t_0;
} else if (b_2 <= 1.15e-285) {
tmp = -t_0;
} else if (b_2 <= 3.5e-55) {
tmp = t_0;
} else {
tmp = (b_2 / a) * -2.0;
}
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((-c / a))
if (b_2 <= (-1.5d-64)) then
tmp = (-0.5d0) * (c / b_2)
else if (b_2 <= (-4.5d-177)) then
tmp = t_0
else if (b_2 <= 1.15d-285) then
tmp = -t_0
else if (b_2 <= 3.5d-55) then
tmp = t_0
else
tmp = (b_2 / a) * (-2.0d0)
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 tmp;
if (b_2 <= -1.5e-64) {
tmp = -0.5 * (c / b_2);
} else if (b_2 <= -4.5e-177) {
tmp = t_0;
} else if (b_2 <= 1.15e-285) {
tmp = -t_0;
} else if (b_2 <= 3.5e-55) {
tmp = t_0;
} else {
tmp = (b_2 / a) * -2.0;
}
return tmp;
}
def code(a, b_2, c): t_0 = math.sqrt((-c / a)) tmp = 0 if b_2 <= -1.5e-64: tmp = -0.5 * (c / b_2) elif b_2 <= -4.5e-177: tmp = t_0 elif b_2 <= 1.15e-285: tmp = -t_0 elif b_2 <= 3.5e-55: tmp = t_0 else: tmp = (b_2 / a) * -2.0 return tmp
function code(a, b_2, c) t_0 = sqrt(Float64(Float64(-c) / a)) tmp = 0.0 if (b_2 <= -1.5e-64) tmp = Float64(-0.5 * Float64(c / b_2)); elseif (b_2 <= -4.5e-177) tmp = t_0; elseif (b_2 <= 1.15e-285) tmp = Float64(-t_0); elseif (b_2 <= 3.5e-55) tmp = t_0; else tmp = Float64(Float64(b_2 / a) * -2.0); end return tmp end
function tmp_2 = code(a, b_2, c) t_0 = sqrt((-c / a)); tmp = 0.0; if (b_2 <= -1.5e-64) tmp = -0.5 * (c / b_2); elseif (b_2 <= -4.5e-177) tmp = t_0; elseif (b_2 <= 1.15e-285) tmp = -t_0; elseif (b_2 <= 3.5e-55) tmp = t_0; else tmp = (b_2 / a) * -2.0; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := Block[{t$95$0 = N[Sqrt[N[((-c) / a), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b$95$2, -1.5e-64], N[(-0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, -4.5e-177], t$95$0, If[LessEqual[b$95$2, 1.15e-285], (-t$95$0), If[LessEqual[b$95$2, 3.5e-55], t$95$0, N[(N[(b$95$2 / a), $MachinePrecision] * -2.0), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\frac{-c}{a}}\\
\mathbf{if}\;b\_2 \leq -1.5 \cdot 10^{-64}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b\_2}\\
\mathbf{elif}\;b\_2 \leq -4.5 \cdot 10^{-177}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b\_2 \leq 1.15 \cdot 10^{-285}:\\
\;\;\;\;-t\_0\\
\mathbf{elif}\;b\_2 \leq 3.5 \cdot 10^{-55}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{b\_2}{a} \cdot -2\\
\end{array}
\end{array}
if b_2 < -1.5e-64Initial program 17.0%
Taylor expanded in b_2 around -inf
lower-*.f64N/A
lower-/.f6486.3
Applied rewrites86.3%
if -1.5e-64 < b_2 < -4.5000000000000003e-177 or 1.14999999999999998e-285 < b_2 < 3.50000000000000025e-55Initial program 73.8%
Taylor expanded in a around -inf
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6428.5
Applied rewrites28.5%
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6428.5
Applied rewrites28.5%
if -4.5000000000000003e-177 < b_2 < 1.14999999999999998e-285Initial program 72.5%
Taylor expanded in a around inf
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f6472.5
Applied rewrites72.5%
Taylor expanded in a around inf
mul-1-negN/A
lower-neg.f64N/A
sqrt-prodN/A
lower-sqrt.f64N/A
*-commutativeN/A
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6440.5
Applied rewrites40.5%
if 3.50000000000000025e-55 < b_2 Initial program 67.8%
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 -1.5e-64) (* -0.5 (/ c b_2)) (if (<= b_2 3.5e-55) (sqrt (/ (- c) a)) (* (/ b_2 a) -2.0))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -1.5e-64) {
tmp = -0.5 * (c / b_2);
} else if (b_2 <= 3.5e-55) {
tmp = sqrt((-c / a));
} else {
tmp = (b_2 / a) * -2.0;
}
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.5d-64)) then
tmp = (-0.5d0) * (c / b_2)
else if (b_2 <= 3.5d-55) then
tmp = sqrt((-c / a))
else
tmp = (b_2 / a) * (-2.0d0)
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -1.5e-64) {
tmp = -0.5 * (c / b_2);
} else if (b_2 <= 3.5e-55) {
tmp = Math.sqrt((-c / a));
} else {
tmp = (b_2 / a) * -2.0;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -1.5e-64: tmp = -0.5 * (c / b_2) elif b_2 <= 3.5e-55: tmp = math.sqrt((-c / a)) else: tmp = (b_2 / a) * -2.0 return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -1.5e-64) tmp = Float64(-0.5 * Float64(c / b_2)); elseif (b_2 <= 3.5e-55) tmp = sqrt(Float64(Float64(-c) / a)); else tmp = Float64(Float64(b_2 / a) * -2.0); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -1.5e-64) tmp = -0.5 * (c / b_2); elseif (b_2 <= 3.5e-55) tmp = sqrt((-c / a)); else tmp = (b_2 / a) * -2.0; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -1.5e-64], N[(-0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, 3.5e-55], N[Sqrt[N[((-c) / a), $MachinePrecision]], $MachinePrecision], N[(N[(b$95$2 / a), $MachinePrecision] * -2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b\_2 \leq -1.5 \cdot 10^{-64}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b\_2}\\
\mathbf{elif}\;b\_2 \leq 3.5 \cdot 10^{-55}:\\
\;\;\;\;\sqrt{\frac{-c}{a}}\\
\mathbf{else}:\\
\;\;\;\;\frac{b\_2}{a} \cdot -2\\
\end{array}
\end{array}
if b_2 < -1.5e-64Initial program 17.0%
Taylor expanded in b_2 around -inf
lower-*.f64N/A
lower-/.f6486.3
Applied rewrites86.3%
if -1.5e-64 < b_2 < 3.50000000000000025e-55Initial program 73.4%
Taylor expanded in a around -inf
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6430.1
Applied rewrites30.1%
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6430.1
Applied rewrites30.1%
if 3.50000000000000025e-55 < b_2 Initial program 67.8%
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 -2e-311) (* -0.5 (/ c b_2)) (* (/ b_2 a) -2.0)))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -2e-311) {
tmp = -0.5 * (c / b_2);
} else {
tmp = (b_2 / a) * -2.0;
}
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 <= (-2d-311)) then
tmp = (-0.5d0) * (c / b_2)
else
tmp = (b_2 / a) * (-2.0d0)
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -2e-311) {
tmp = -0.5 * (c / b_2);
} else {
tmp = (b_2 / a) * -2.0;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -2e-311: tmp = -0.5 * (c / b_2) else: tmp = (b_2 / a) * -2.0 return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -2e-311) tmp = Float64(-0.5 * Float64(c / b_2)); else tmp = Float64(Float64(b_2 / a) * -2.0); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -2e-311) tmp = -0.5 * (c / b_2); else tmp = (b_2 / a) * -2.0; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -2e-311], N[(-0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision], N[(N[(b$95$2 / a), $MachinePrecision] * -2.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b\_2 \leq -2 \cdot 10^{-311}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b\_2}\\
\mathbf{else}:\\
\;\;\;\;\frac{b\_2}{a} \cdot -2\\
\end{array}
\end{array}
if b_2 < -1.9999999999999e-311Initial program 31.8%
Taylor expanded in b_2 around -inf
lower-*.f64N/A
lower-/.f6466.9
Applied rewrites66.9%
if -1.9999999999999e-311 < b_2 Initial program 72.0%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6465.9
Applied rewrites65.9%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -2e-311) (* -0.5 (/ c b_2)) (/ (- b_2) a)))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -2e-311) {
tmp = -0.5 * (c / b_2);
} else {
tmp = -b_2 / a;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b_2, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
real(8) :: tmp
if (b_2 <= (-2d-311)) then
tmp = (-0.5d0) * (c / b_2)
else
tmp = -b_2 / a
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -2e-311) {
tmp = -0.5 * (c / b_2);
} else {
tmp = -b_2 / a;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -2e-311: tmp = -0.5 * (c / b_2) else: tmp = -b_2 / a return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -2e-311) tmp = Float64(-0.5 * Float64(c / b_2)); else tmp = Float64(Float64(-b_2) / a); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -2e-311) tmp = -0.5 * (c / b_2); else tmp = -b_2 / a; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -2e-311], N[(-0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision], N[((-b$95$2) / a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b\_2 \leq -2 \cdot 10^{-311}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b\_2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-b\_2}{a}\\
\end{array}
\end{array}
if b_2 < -1.9999999999999e-311Initial program 31.8%
Taylor expanded in b_2 around -inf
lower-*.f64N/A
lower-/.f6466.9
Applied rewrites66.9%
if -1.9999999999999e-311 < b_2 Initial program 72.0%
Taylor expanded in c around -inf
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6437.5
Applied rewrites37.5%
Taylor expanded in b_2 around inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lift-neg.f6426.8
Applied rewrites26.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 51.5%
Taylor expanded in c around -inf
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6431.5
Applied rewrites31.5%
Taylor expanded in b_2 around inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lift-neg.f6414.6
Applied rewrites14.6%
herbie shell --seed 2025101
(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))