
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * 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, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-b + sqrt(((b * b) - ((4.0d0 * a) * c)))) / (2.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c)))) / Float64(2.0 * a)) end
function tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a); end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\end{array}
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * 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, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-b + sqrt(((b * b) - ((4.0d0 * a) * c)))) / (2.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c)))) / Float64(2.0 * a)) end
function tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a); end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\end{array}
(FPCore (a b c)
:precision binary64
(if (<= b -5e+21)
(/ (fma (sqrt (- 1.0 (* (* a 4.0) (/ (/ c b) b)))) (fabs b) (- b)) (+ a a))
(if (<= b 1.45e-186)
(- (/ (sqrt (fma (* c a) -4.0 (* b b))) (+ a a)) (/ b (+ a a)))
(- (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e+21) {
tmp = fma(sqrt((1.0 - ((a * 4.0) * ((c / b) / b)))), fabs(b), -b) / (a + a);
} else if (b <= 1.45e-186) {
tmp = (sqrt(fma((c * a), -4.0, (b * b))) / (a + a)) - (b / (a + a));
} else {
tmp = -(c / b);
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -5e+21) tmp = Float64(fma(sqrt(Float64(1.0 - Float64(Float64(a * 4.0) * Float64(Float64(c / b) / b)))), abs(b), Float64(-b)) / Float64(a + a)); elseif (b <= 1.45e-186) tmp = Float64(Float64(sqrt(fma(Float64(c * a), -4.0, Float64(b * b))) / Float64(a + a)) - Float64(b / Float64(a + a))); else tmp = Float64(-Float64(c / b)); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -5e+21], N[(N[(N[Sqrt[N[(1.0 - N[(N[(a * 4.0), $MachinePrecision] * N[(N[(c / b), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Abs[b], $MachinePrecision] + (-b)), $MachinePrecision] / N[(a + a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.45e-186], N[(N[(N[Sqrt[N[(N[(c * a), $MachinePrecision] * -4.0 + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(a + a), $MachinePrecision]), $MachinePrecision] - N[(b / N[(a + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-N[(c / b), $MachinePrecision])]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{+21}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\sqrt{1 - \left(a \cdot 4\right) \cdot \frac{\frac{c}{b}}{b}}, \left|b\right|, -b\right)}{a + a}\\
\mathbf{elif}\;b \leq 1.45 \cdot 10^{-186}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(c \cdot a, -4, b \cdot b\right)}}{a + a} - \frac{b}{a + a}\\
\mathbf{else}:\\
\;\;\;\;-\frac{c}{b}\\
\end{array}
\end{array}
if b < -5e21Initial program 52.2%
lift-+.f64N/A
+-commutativeN/A
lift-sqrt.f64N/A
lift--.f64N/A
sub-to-multN/A
sqrt-prodN/A
lift-*.f64N/A
rem-sqrt-square-revN/A
lower-fma.f64N/A
Applied rewrites53.6%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6457.0
Applied rewrites57.0%
lift-*.f64N/A
count-2-revN/A
lift-+.f6457.0
Applied rewrites57.0%
if -5e21 < b < 1.4500000000000001e-186Initial program 52.2%
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
sub-flip-reverseN/A
lower--.f6452.2
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
metadata-evalN/A
*-commutativeN/A
lower-*.f6452.2
lift-*.f64N/A
count-2-revN/A
lower-+.f6452.2
Applied rewrites52.2%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
lower--.f64N/A
lower-/.f64N/A
lift-fma.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower-/.f6451.7
Applied rewrites51.7%
if 1.4500000000000001e-186 < b Initial program 52.2%
Taylor expanded in b around inf
lower-*.f64N/A
lower-/.f6435.1
Applied rewrites35.1%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6435.1
Applied rewrites35.1%
(FPCore (a b c)
:precision binary64
(if (<= b -4e+34)
(/ (- (* (fabs b) (sqrt (- 1.0 (* (/ c (* b b)) (* 4.0 a))))) b) (+ a a))
(if (<= b 1.45e-186)
(- (/ (sqrt (fma (* c a) -4.0 (* b b))) (+ a a)) (/ b (+ a a)))
(- (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4e+34) {
tmp = ((fabs(b) * sqrt((1.0 - ((c / (b * b)) * (4.0 * a))))) - b) / (a + a);
} else if (b <= 1.45e-186) {
tmp = (sqrt(fma((c * a), -4.0, (b * b))) / (a + a)) - (b / (a + a));
} else {
tmp = -(c / b);
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -4e+34) tmp = Float64(Float64(Float64(abs(b) * sqrt(Float64(1.0 - Float64(Float64(c / Float64(b * b)) * Float64(4.0 * a))))) - b) / Float64(a + a)); elseif (b <= 1.45e-186) tmp = Float64(Float64(sqrt(fma(Float64(c * a), -4.0, Float64(b * b))) / Float64(a + a)) - Float64(b / Float64(a + a))); else tmp = Float64(-Float64(c / b)); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -4e+34], N[(N[(N[(N[Abs[b], $MachinePrecision] * N[Sqrt[N[(1.0 - N[(N[(c / N[(b * b), $MachinePrecision]), $MachinePrecision] * N[(4.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision] / N[(a + a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.45e-186], N[(N[(N[Sqrt[N[(N[(c * a), $MachinePrecision] * -4.0 + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(a + a), $MachinePrecision]), $MachinePrecision] - N[(b / N[(a + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-N[(c / b), $MachinePrecision])]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4 \cdot 10^{+34}:\\
\;\;\;\;\frac{\left|b\right| \cdot \sqrt{1 - \frac{c}{b \cdot b} \cdot \left(4 \cdot a\right)} - b}{a + a}\\
\mathbf{elif}\;b \leq 1.45 \cdot 10^{-186}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(c \cdot a, -4, b \cdot b\right)}}{a + a} - \frac{b}{a + a}\\
\mathbf{else}:\\
\;\;\;\;-\frac{c}{b}\\
\end{array}
\end{array}
if b < -3.99999999999999978e34Initial program 52.2%
lift-+.f64N/A
+-commutativeN/A
lift-sqrt.f64N/A
lift--.f64N/A
sub-to-multN/A
sqrt-prodN/A
lift-*.f64N/A
rem-sqrt-square-revN/A
lower-fma.f64N/A
Applied rewrites53.6%
lift-fma.f64N/A
lift-neg.f64N/A
sub-flip-reverseN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f6453.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f6453.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f6453.6
lift-*.f64N/A
count-2-revN/A
lift-+.f6453.6
Applied rewrites53.6%
if -3.99999999999999978e34 < b < 1.4500000000000001e-186Initial program 52.2%
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
sub-flip-reverseN/A
lower--.f6452.2
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
metadata-evalN/A
*-commutativeN/A
lower-*.f6452.2
lift-*.f64N/A
count-2-revN/A
lower-+.f6452.2
Applied rewrites52.2%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
lower--.f64N/A
lower-/.f64N/A
lift-fma.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower-/.f6451.7
Applied rewrites51.7%
if 1.4500000000000001e-186 < b Initial program 52.2%
Taylor expanded in b around inf
lower-*.f64N/A
lower-/.f6435.1
Applied rewrites35.1%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6435.1
Applied rewrites35.1%
(FPCore (a b c)
:precision binary64
(if (<= b -6e+25)
(- (/ b a))
(if (<= b 1.45e-186)
(- (/ (sqrt (fma (* c a) -4.0 (* b b))) (+ a a)) (/ b (+ a a)))
(- (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -6e+25) {
tmp = -(b / a);
} else if (b <= 1.45e-186) {
tmp = (sqrt(fma((c * a), -4.0, (b * b))) / (a + a)) - (b / (a + a));
} else {
tmp = -(c / b);
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -6e+25) tmp = Float64(-Float64(b / a)); elseif (b <= 1.45e-186) tmp = Float64(Float64(sqrt(fma(Float64(c * a), -4.0, Float64(b * b))) / Float64(a + a)) - Float64(b / Float64(a + a))); else tmp = Float64(-Float64(c / b)); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -6e+25], (-N[(b / a), $MachinePrecision]), If[LessEqual[b, 1.45e-186], N[(N[(N[Sqrt[N[(N[(c * a), $MachinePrecision] * -4.0 + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(a + a), $MachinePrecision]), $MachinePrecision] - N[(b / N[(a + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-N[(c / b), $MachinePrecision])]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -6 \cdot 10^{+25}:\\
\;\;\;\;-\frac{b}{a}\\
\mathbf{elif}\;b \leq 1.45 \cdot 10^{-186}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(c \cdot a, -4, b \cdot b\right)}}{a + a} - \frac{b}{a + a}\\
\mathbf{else}:\\
\;\;\;\;-\frac{c}{b}\\
\end{array}
\end{array}
if b < -6.00000000000000011e25Initial program 52.2%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6436.0
Applied rewrites36.0%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6436.0
Applied rewrites36.0%
if -6.00000000000000011e25 < b < 1.4500000000000001e-186Initial program 52.2%
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
sub-flip-reverseN/A
lower--.f6452.2
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
metadata-evalN/A
*-commutativeN/A
lower-*.f6452.2
lift-*.f64N/A
count-2-revN/A
lower-+.f6452.2
Applied rewrites52.2%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
lower--.f64N/A
lower-/.f64N/A
lift-fma.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower-/.f6451.7
Applied rewrites51.7%
if 1.4500000000000001e-186 < b Initial program 52.2%
Taylor expanded in b around inf
lower-*.f64N/A
lower-/.f6435.1
Applied rewrites35.1%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6435.1
Applied rewrites35.1%
(FPCore (a b c)
:precision binary64
(if (<= b -6e+25)
(- (/ b a))
(if (<= b 1.45e-186)
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a))
(- (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -6e+25) {
tmp = -(b / a);
} else if (b <= 1.45e-186) {
tmp = (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
} else {
tmp = -(c / b);
}
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, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-6d+25)) then
tmp = -(b / a)
else if (b <= 1.45d-186) then
tmp = (-b + sqrt(((b * b) - ((4.0d0 * a) * c)))) / (2.0d0 * a)
else
tmp = -(c / b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -6e+25) {
tmp = -(b / a);
} else if (b <= 1.45e-186) {
tmp = (-b + Math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
} else {
tmp = -(c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -6e+25: tmp = -(b / a) elif b <= 1.45e-186: tmp = (-b + math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a) else: tmp = -(c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -6e+25) tmp = Float64(-Float64(b / a)); elseif (b <= 1.45e-186) tmp = Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c)))) / Float64(2.0 * a)); else tmp = Float64(-Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -6e+25) tmp = -(b / a); elseif (b <= 1.45e-186) tmp = (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a); else tmp = -(c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -6e+25], (-N[(b / a), $MachinePrecision]), If[LessEqual[b, 1.45e-186], N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], (-N[(c / b), $MachinePrecision])]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -6 \cdot 10^{+25}:\\
\;\;\;\;-\frac{b}{a}\\
\mathbf{elif}\;b \leq 1.45 \cdot 10^{-186}:\\
\;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;-\frac{c}{b}\\
\end{array}
\end{array}
if b < -6.00000000000000011e25Initial program 52.2%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6436.0
Applied rewrites36.0%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6436.0
Applied rewrites36.0%
if -6.00000000000000011e25 < b < 1.4500000000000001e-186Initial program 52.2%
if 1.4500000000000001e-186 < b Initial program 52.2%
Taylor expanded in b around inf
lower-*.f64N/A
lower-/.f6435.1
Applied rewrites35.1%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6435.1
Applied rewrites35.1%
(FPCore (a b c)
:precision binary64
(if (<= b -6e+25)
(- (/ b a))
(if (<= b 1.45e-186)
(/ (- (sqrt (fma -4.0 (* c a) (* b b))) b) (+ a a))
(- (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -6e+25) {
tmp = -(b / a);
} else if (b <= 1.45e-186) {
tmp = (sqrt(fma(-4.0, (c * a), (b * b))) - b) / (a + a);
} else {
tmp = -(c / b);
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -6e+25) tmp = Float64(-Float64(b / a)); elseif (b <= 1.45e-186) tmp = Float64(Float64(sqrt(fma(-4.0, Float64(c * a), Float64(b * b))) - b) / Float64(a + a)); else tmp = Float64(-Float64(c / b)); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -6e+25], (-N[(b / a), $MachinePrecision]), If[LessEqual[b, 1.45e-186], N[(N[(N[Sqrt[N[(-4.0 * N[(c * a), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a + a), $MachinePrecision]), $MachinePrecision], (-N[(c / b), $MachinePrecision])]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -6 \cdot 10^{+25}:\\
\;\;\;\;-\frac{b}{a}\\
\mathbf{elif}\;b \leq 1.45 \cdot 10^{-186}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(-4, c \cdot a, b \cdot b\right)} - b}{a + a}\\
\mathbf{else}:\\
\;\;\;\;-\frac{c}{b}\\
\end{array}
\end{array}
if b < -6.00000000000000011e25Initial program 52.2%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6436.0
Applied rewrites36.0%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6436.0
Applied rewrites36.0%
if -6.00000000000000011e25 < b < 1.4500000000000001e-186Initial program 52.2%
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
sub-flip-reverseN/A
lower--.f6452.2
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
metadata-evalN/A
*-commutativeN/A
lower-*.f6452.2
lift-*.f64N/A
count-2-revN/A
lower-+.f6452.2
Applied rewrites52.2%
if 1.4500000000000001e-186 < b Initial program 52.2%
Taylor expanded in b around inf
lower-*.f64N/A
lower-/.f6435.1
Applied rewrites35.1%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6435.1
Applied rewrites35.1%
(FPCore (a b c)
:precision binary64
(if (<= b -1.32e-45)
(- (/ b a))
(if (<= b 1.45e-186)
(/ (- (sqrt (* (* c a) -4.0)) b) (+ a a))
(- (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.32e-45) {
tmp = -(b / a);
} else if (b <= 1.45e-186) {
tmp = (sqrt(((c * a) * -4.0)) - b) / (a + a);
} else {
tmp = -(c / b);
}
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, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-1.32d-45)) then
tmp = -(b / a)
else if (b <= 1.45d-186) then
tmp = (sqrt(((c * a) * (-4.0d0))) - b) / (a + a)
else
tmp = -(c / b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1.32e-45) {
tmp = -(b / a);
} else if (b <= 1.45e-186) {
tmp = (Math.sqrt(((c * a) * -4.0)) - b) / (a + a);
} else {
tmp = -(c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.32e-45: tmp = -(b / a) elif b <= 1.45e-186: tmp = (math.sqrt(((c * a) * -4.0)) - b) / (a + a) else: tmp = -(c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.32e-45) tmp = Float64(-Float64(b / a)); elseif (b <= 1.45e-186) tmp = Float64(Float64(sqrt(Float64(Float64(c * a) * -4.0)) - b) / Float64(a + a)); else tmp = Float64(-Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.32e-45) tmp = -(b / a); elseif (b <= 1.45e-186) tmp = (sqrt(((c * a) * -4.0)) - b) / (a + a); else tmp = -(c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.32e-45], (-N[(b / a), $MachinePrecision]), If[LessEqual[b, 1.45e-186], N[(N[(N[Sqrt[N[(N[(c * a), $MachinePrecision] * -4.0), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a + a), $MachinePrecision]), $MachinePrecision], (-N[(c / b), $MachinePrecision])]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.32 \cdot 10^{-45}:\\
\;\;\;\;-\frac{b}{a}\\
\mathbf{elif}\;b \leq 1.45 \cdot 10^{-186}:\\
\;\;\;\;\frac{\sqrt{\left(c \cdot a\right) \cdot -4} - b}{a + a}\\
\mathbf{else}:\\
\;\;\;\;-\frac{c}{b}\\
\end{array}
\end{array}
if b < -1.32000000000000005e-45Initial program 52.2%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6436.0
Applied rewrites36.0%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6436.0
Applied rewrites36.0%
if -1.32000000000000005e-45 < b < 1.4500000000000001e-186Initial program 52.2%
Taylor expanded in a around inf
lower-*.f64N/A
lower-*.f6433.4
Applied rewrites33.4%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6433.4
lift-*.f64N/A
*-commutativeN/A
lift-*.f6433.4
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
Applied rewrites33.4%
lift-+.f64N/A
lift-neg.f64N/A
sub-flip-reverseN/A
lower--.f6433.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6433.4
Applied rewrites33.4%
if 1.4500000000000001e-186 < b Initial program 52.2%
Taylor expanded in b around inf
lower-*.f64N/A
lower-/.f6435.1
Applied rewrites35.1%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6435.1
Applied rewrites35.1%
(FPCore (a b c) :precision binary64 (if (<= b -8.2e-72) (- (/ b a)) (if (<= b 8.6e-166) (/ (sqrt (* -4.0 (* c a))) (+ a a)) (- (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -8.2e-72) {
tmp = -(b / a);
} else if (b <= 8.6e-166) {
tmp = sqrt((-4.0 * (c * a))) / (a + a);
} else {
tmp = -(c / b);
}
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, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-8.2d-72)) then
tmp = -(b / a)
else if (b <= 8.6d-166) then
tmp = sqrt(((-4.0d0) * (c * a))) / (a + a)
else
tmp = -(c / b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -8.2e-72) {
tmp = -(b / a);
} else if (b <= 8.6e-166) {
tmp = Math.sqrt((-4.0 * (c * a))) / (a + a);
} else {
tmp = -(c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -8.2e-72: tmp = -(b / a) elif b <= 8.6e-166: tmp = math.sqrt((-4.0 * (c * a))) / (a + a) else: tmp = -(c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -8.2e-72) tmp = Float64(-Float64(b / a)); elseif (b <= 8.6e-166) tmp = Float64(sqrt(Float64(-4.0 * Float64(c * a))) / Float64(a + a)); else tmp = Float64(-Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -8.2e-72) tmp = -(b / a); elseif (b <= 8.6e-166) tmp = sqrt((-4.0 * (c * a))) / (a + a); else tmp = -(c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -8.2e-72], (-N[(b / a), $MachinePrecision]), If[LessEqual[b, 8.6e-166], N[(N[Sqrt[N[(-4.0 * N[(c * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(a + a), $MachinePrecision]), $MachinePrecision], (-N[(c / b), $MachinePrecision])]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -8.2 \cdot 10^{-72}:\\
\;\;\;\;-\frac{b}{a}\\
\mathbf{elif}\;b \leq 8.6 \cdot 10^{-166}:\\
\;\;\;\;\frac{\sqrt{-4 \cdot \left(c \cdot a\right)}}{a + a}\\
\mathbf{else}:\\
\;\;\;\;-\frac{c}{b}\\
\end{array}
\end{array}
if b < -8.20000000000000007e-72Initial program 52.2%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6436.0
Applied rewrites36.0%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6436.0
Applied rewrites36.0%
if -8.20000000000000007e-72 < b < 8.6000000000000001e-166Initial program 52.2%
Taylor expanded in b around 0
lower-sqrt.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-*.f6428.4
Applied rewrites28.4%
lift-neg.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lift-*.f6428.4
lift-*.f64N/A
*-commutativeN/A
lift-*.f6428.4
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
Applied rewrites28.4%
if 8.6000000000000001e-166 < b Initial program 52.2%
Taylor expanded in b around inf
lower-*.f64N/A
lower-/.f6435.1
Applied rewrites35.1%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6435.1
Applied rewrites35.1%
(FPCore (a b c)
:precision binary64
(if (<= b -4.1e-51)
(- (/ b a))
(if (<= b 6.4e-276)
(* -0.5 (sqrt (* -4.0 (/ c a))))
(if (<= b 1.1e-167) (* 0.5 (/ (sqrt (* -4.0 c)) (sqrt a))) (- (/ c b))))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4.1e-51) {
tmp = -(b / a);
} else if (b <= 6.4e-276) {
tmp = -0.5 * sqrt((-4.0 * (c / a)));
} else if (b <= 1.1e-167) {
tmp = 0.5 * (sqrt((-4.0 * c)) / sqrt(a));
} else {
tmp = -(c / b);
}
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, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-4.1d-51)) then
tmp = -(b / a)
else if (b <= 6.4d-276) then
tmp = (-0.5d0) * sqrt(((-4.0d0) * (c / a)))
else if (b <= 1.1d-167) then
tmp = 0.5d0 * (sqrt(((-4.0d0) * c)) / sqrt(a))
else
tmp = -(c / b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -4.1e-51) {
tmp = -(b / a);
} else if (b <= 6.4e-276) {
tmp = -0.5 * Math.sqrt((-4.0 * (c / a)));
} else if (b <= 1.1e-167) {
tmp = 0.5 * (Math.sqrt((-4.0 * c)) / Math.sqrt(a));
} else {
tmp = -(c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -4.1e-51: tmp = -(b / a) elif b <= 6.4e-276: tmp = -0.5 * math.sqrt((-4.0 * (c / a))) elif b <= 1.1e-167: tmp = 0.5 * (math.sqrt((-4.0 * c)) / math.sqrt(a)) else: tmp = -(c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -4.1e-51) tmp = Float64(-Float64(b / a)); elseif (b <= 6.4e-276) tmp = Float64(-0.5 * sqrt(Float64(-4.0 * Float64(c / a)))); elseif (b <= 1.1e-167) tmp = Float64(0.5 * Float64(sqrt(Float64(-4.0 * c)) / sqrt(a))); else tmp = Float64(-Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -4.1e-51) tmp = -(b / a); elseif (b <= 6.4e-276) tmp = -0.5 * sqrt((-4.0 * (c / a))); elseif (b <= 1.1e-167) tmp = 0.5 * (sqrt((-4.0 * c)) / sqrt(a)); else tmp = -(c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -4.1e-51], (-N[(b / a), $MachinePrecision]), If[LessEqual[b, 6.4e-276], N[(-0.5 * N[Sqrt[N[(-4.0 * N[(c / a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.1e-167], N[(0.5 * N[(N[Sqrt[N[(-4.0 * c), $MachinePrecision]], $MachinePrecision] / N[Sqrt[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-N[(c / b), $MachinePrecision])]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.1 \cdot 10^{-51}:\\
\;\;\;\;-\frac{b}{a}\\
\mathbf{elif}\;b \leq 6.4 \cdot 10^{-276}:\\
\;\;\;\;-0.5 \cdot \sqrt{-4 \cdot \frac{c}{a}}\\
\mathbf{elif}\;b \leq 1.1 \cdot 10^{-167}:\\
\;\;\;\;0.5 \cdot \frac{\sqrt{-4 \cdot c}}{\sqrt{a}}\\
\mathbf{else}:\\
\;\;\;\;-\frac{c}{b}\\
\end{array}
\end{array}
if b < -4.09999999999999973e-51Initial program 52.2%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6436.0
Applied rewrites36.0%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6436.0
Applied rewrites36.0%
if -4.09999999999999973e-51 < b < 6.3999999999999998e-276Initial program 52.2%
Taylor expanded in a around -inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6417.0
Applied rewrites17.0%
if 6.3999999999999998e-276 < b < 1.1e-167Initial program 52.2%
Taylor expanded in a around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6417.5
Applied rewrites17.5%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f6417.5
Applied rewrites17.5%
lift-sqrt.f64N/A
lift-/.f64N/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6416.9
Applied rewrites16.9%
if 1.1e-167 < b Initial program 52.2%
Taylor expanded in b around inf
lower-*.f64N/A
lower-/.f6435.1
Applied rewrites35.1%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6435.1
Applied rewrites35.1%
(FPCore (a b c)
:precision binary64
(if (<= b -4.1e-51)
(- (/ b a))
(if (<= b 6.4e-276)
(* -0.5 (sqrt (* -4.0 (/ c a))))
(if (<= b 1.1e-167) (* 0.5 (sqrt (/ (* -4.0 c) a))) (- (/ c b))))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4.1e-51) {
tmp = -(b / a);
} else if (b <= 6.4e-276) {
tmp = -0.5 * sqrt((-4.0 * (c / a)));
} else if (b <= 1.1e-167) {
tmp = 0.5 * sqrt(((-4.0 * c) / a));
} else {
tmp = -(c / b);
}
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, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-4.1d-51)) then
tmp = -(b / a)
else if (b <= 6.4d-276) then
tmp = (-0.5d0) * sqrt(((-4.0d0) * (c / a)))
else if (b <= 1.1d-167) then
tmp = 0.5d0 * sqrt((((-4.0d0) * c) / a))
else
tmp = -(c / b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -4.1e-51) {
tmp = -(b / a);
} else if (b <= 6.4e-276) {
tmp = -0.5 * Math.sqrt((-4.0 * (c / a)));
} else if (b <= 1.1e-167) {
tmp = 0.5 * Math.sqrt(((-4.0 * c) / a));
} else {
tmp = -(c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -4.1e-51: tmp = -(b / a) elif b <= 6.4e-276: tmp = -0.5 * math.sqrt((-4.0 * (c / a))) elif b <= 1.1e-167: tmp = 0.5 * math.sqrt(((-4.0 * c) / a)) else: tmp = -(c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -4.1e-51) tmp = Float64(-Float64(b / a)); elseif (b <= 6.4e-276) tmp = Float64(-0.5 * sqrt(Float64(-4.0 * Float64(c / a)))); elseif (b <= 1.1e-167) tmp = Float64(0.5 * sqrt(Float64(Float64(-4.0 * c) / a))); else tmp = Float64(-Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -4.1e-51) tmp = -(b / a); elseif (b <= 6.4e-276) tmp = -0.5 * sqrt((-4.0 * (c / a))); elseif (b <= 1.1e-167) tmp = 0.5 * sqrt(((-4.0 * c) / a)); else tmp = -(c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -4.1e-51], (-N[(b / a), $MachinePrecision]), If[LessEqual[b, 6.4e-276], N[(-0.5 * N[Sqrt[N[(-4.0 * N[(c / a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.1e-167], N[(0.5 * N[Sqrt[N[(N[(-4.0 * c), $MachinePrecision] / a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], (-N[(c / b), $MachinePrecision])]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.1 \cdot 10^{-51}:\\
\;\;\;\;-\frac{b}{a}\\
\mathbf{elif}\;b \leq 6.4 \cdot 10^{-276}:\\
\;\;\;\;-0.5 \cdot \sqrt{-4 \cdot \frac{c}{a}}\\
\mathbf{elif}\;b \leq 1.1 \cdot 10^{-167}:\\
\;\;\;\;0.5 \cdot \sqrt{\frac{-4 \cdot c}{a}}\\
\mathbf{else}:\\
\;\;\;\;-\frac{c}{b}\\
\end{array}
\end{array}
if b < -4.09999999999999973e-51Initial program 52.2%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6436.0
Applied rewrites36.0%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6436.0
Applied rewrites36.0%
if -4.09999999999999973e-51 < b < 6.3999999999999998e-276Initial program 52.2%
Taylor expanded in a around -inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6417.0
Applied rewrites17.0%
if 6.3999999999999998e-276 < b < 1.1e-167Initial program 52.2%
Taylor expanded in a around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6417.5
Applied rewrites17.5%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f6417.5
Applied rewrites17.5%
if 1.1e-167 < b Initial program 52.2%
Taylor expanded in b around inf
lower-*.f64N/A
lower-/.f6435.1
Applied rewrites35.1%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6435.1
Applied rewrites35.1%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (* -4.0 (/ c a)))))
(if (<= b -4.1e-51)
(- (/ b a))
(if (<= b 6.4e-276)
(* -0.5 t_0)
(if (<= b 1.1e-167) (* 0.5 t_0) (- (/ c b)))))))
double code(double a, double b, double c) {
double t_0 = sqrt((-4.0 * (c / a)));
double tmp;
if (b <= -4.1e-51) {
tmp = -(b / a);
} else if (b <= 6.4e-276) {
tmp = -0.5 * t_0;
} else if (b <= 1.1e-167) {
tmp = 0.5 * t_0;
} else {
tmp = -(c / b);
}
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, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt(((-4.0d0) * (c / a)))
if (b <= (-4.1d-51)) then
tmp = -(b / a)
else if (b <= 6.4d-276) then
tmp = (-0.5d0) * t_0
else if (b <= 1.1d-167) then
tmp = 0.5d0 * t_0
else
tmp = -(c / b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double t_0 = Math.sqrt((-4.0 * (c / a)));
double tmp;
if (b <= -4.1e-51) {
tmp = -(b / a);
} else if (b <= 6.4e-276) {
tmp = -0.5 * t_0;
} else if (b <= 1.1e-167) {
tmp = 0.5 * t_0;
} else {
tmp = -(c / b);
}
return tmp;
}
def code(a, b, c): t_0 = math.sqrt((-4.0 * (c / a))) tmp = 0 if b <= -4.1e-51: tmp = -(b / a) elif b <= 6.4e-276: tmp = -0.5 * t_0 elif b <= 1.1e-167: tmp = 0.5 * t_0 else: tmp = -(c / b) return tmp
function code(a, b, c) t_0 = sqrt(Float64(-4.0 * Float64(c / a))) tmp = 0.0 if (b <= -4.1e-51) tmp = Float64(-Float64(b / a)); elseif (b <= 6.4e-276) tmp = Float64(-0.5 * t_0); elseif (b <= 1.1e-167) tmp = Float64(0.5 * t_0); else tmp = Float64(-Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) t_0 = sqrt((-4.0 * (c / a))); tmp = 0.0; if (b <= -4.1e-51) tmp = -(b / a); elseif (b <= 6.4e-276) tmp = -0.5 * t_0; elseif (b <= 1.1e-167) tmp = 0.5 * t_0; else tmp = -(c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(-4.0 * N[(c / a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b, -4.1e-51], (-N[(b / a), $MachinePrecision]), If[LessEqual[b, 6.4e-276], N[(-0.5 * t$95$0), $MachinePrecision], If[LessEqual[b, 1.1e-167], N[(0.5 * t$95$0), $MachinePrecision], (-N[(c / b), $MachinePrecision])]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{-4 \cdot \frac{c}{a}}\\
\mathbf{if}\;b \leq -4.1 \cdot 10^{-51}:\\
\;\;\;\;-\frac{b}{a}\\
\mathbf{elif}\;b \leq 6.4 \cdot 10^{-276}:\\
\;\;\;\;-0.5 \cdot t\_0\\
\mathbf{elif}\;b \leq 1.1 \cdot 10^{-167}:\\
\;\;\;\;0.5 \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;-\frac{c}{b}\\
\end{array}
\end{array}
if b < -4.09999999999999973e-51Initial program 52.2%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6436.0
Applied rewrites36.0%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6436.0
Applied rewrites36.0%
if -4.09999999999999973e-51 < b < 6.3999999999999998e-276Initial program 52.2%
Taylor expanded in a around -inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6417.0
Applied rewrites17.0%
if 6.3999999999999998e-276 < b < 1.1e-167Initial program 52.2%
Taylor expanded in a around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6417.5
Applied rewrites17.5%
if 1.1e-167 < b Initial program 52.2%
Taylor expanded in b around inf
lower-*.f64N/A
lower-/.f6435.1
Applied rewrites35.1%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6435.1
Applied rewrites35.1%
(FPCore (a b c) :precision binary64 (if (<= b -4.1e-51) (- (/ b a)) (if (<= b 7e-236) (* -0.5 (sqrt (* -4.0 (/ c a)))) (- (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4.1e-51) {
tmp = -(b / a);
} else if (b <= 7e-236) {
tmp = -0.5 * sqrt((-4.0 * (c / a)));
} else {
tmp = -(c / b);
}
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, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-4.1d-51)) then
tmp = -(b / a)
else if (b <= 7d-236) then
tmp = (-0.5d0) * sqrt(((-4.0d0) * (c / a)))
else
tmp = -(c / b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -4.1e-51) {
tmp = -(b / a);
} else if (b <= 7e-236) {
tmp = -0.5 * Math.sqrt((-4.0 * (c / a)));
} else {
tmp = -(c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -4.1e-51: tmp = -(b / a) elif b <= 7e-236: tmp = -0.5 * math.sqrt((-4.0 * (c / a))) else: tmp = -(c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -4.1e-51) tmp = Float64(-Float64(b / a)); elseif (b <= 7e-236) tmp = Float64(-0.5 * sqrt(Float64(-4.0 * Float64(c / a)))); else tmp = Float64(-Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -4.1e-51) tmp = -(b / a); elseif (b <= 7e-236) tmp = -0.5 * sqrt((-4.0 * (c / a))); else tmp = -(c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -4.1e-51], (-N[(b / a), $MachinePrecision]), If[LessEqual[b, 7e-236], N[(-0.5 * N[Sqrt[N[(-4.0 * N[(c / a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], (-N[(c / b), $MachinePrecision])]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.1 \cdot 10^{-51}:\\
\;\;\;\;-\frac{b}{a}\\
\mathbf{elif}\;b \leq 7 \cdot 10^{-236}:\\
\;\;\;\;-0.5 \cdot \sqrt{-4 \cdot \frac{c}{a}}\\
\mathbf{else}:\\
\;\;\;\;-\frac{c}{b}\\
\end{array}
\end{array}
if b < -4.09999999999999973e-51Initial program 52.2%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6436.0
Applied rewrites36.0%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6436.0
Applied rewrites36.0%
if -4.09999999999999973e-51 < b < 6.99999999999999988e-236Initial program 52.2%
Taylor expanded in a around -inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6417.0
Applied rewrites17.0%
if 6.99999999999999988e-236 < b Initial program 52.2%
Taylor expanded in b around inf
lower-*.f64N/A
lower-/.f6435.1
Applied rewrites35.1%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6435.1
Applied rewrites35.1%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (- (/ b a)) (- (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = -(b / a);
} else {
tmp = -(c / b);
}
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, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-5d-310)) then
tmp = -(b / a)
else
tmp = -(c / b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = -(b / a);
} else {
tmp = -(c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = -(b / a) else: tmp = -(c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(-Float64(b / a)); else tmp = Float64(-Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e-310) tmp = -(b / a); else tmp = -(c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], (-N[(b / a), $MachinePrecision]), (-N[(c / b), $MachinePrecision])]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;-\frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;-\frac{c}{b}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 52.2%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6436.0
Applied rewrites36.0%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6436.0
Applied rewrites36.0%
if -4.999999999999985e-310 < b Initial program 52.2%
Taylor expanded in b around inf
lower-*.f64N/A
lower-/.f6435.1
Applied rewrites35.1%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6435.1
Applied rewrites35.1%
(FPCore (a b c) :precision binary64 (- (/ b a)))
double code(double a, double b, double c) {
return -(b / 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, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = -(b / a)
end function
public static double code(double a, double b, double c) {
return -(b / a);
}
def code(a, b, c): return -(b / a)
function code(a, b, c) return Float64(-Float64(b / a)) end
function tmp = code(a, b, c) tmp = -(b / a); end
code[a_, b_, c_] := (-N[(b / a), $MachinePrecision])
\begin{array}{l}
\\
-\frac{b}{a}
\end{array}
Initial program 52.2%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6436.0
Applied rewrites36.0%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6436.0
Applied rewrites36.0%
herbie shell --seed 2025150
(FPCore (a b c)
:name "Quadratic roots, full range"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))