
(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 9 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 -4e+85)
(/ (- b) a)
(if (<= b 1.55e-200)
(/ (+ (sqrt (fma (* -4.0 a) c (* b b))) (- b)) (+ a a))
(if (<= b 410.0)
(/
(/ (* (* c a) -4.0) (- (sqrt (fma b b (* (* a -4.0) c))) (- b)))
(+ a a))
(/ (- c) b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4e+85) {
tmp = -b / a;
} else if (b <= 1.55e-200) {
tmp = (sqrt(fma((-4.0 * a), c, (b * b))) + -b) / (a + a);
} else if (b <= 410.0) {
tmp = (((c * a) * -4.0) / (sqrt(fma(b, b, ((a * -4.0) * c))) - -b)) / (a + a);
} else {
tmp = -c / b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -4e+85) tmp = Float64(Float64(-b) / a); elseif (b <= 1.55e-200) tmp = Float64(Float64(sqrt(fma(Float64(-4.0 * a), c, Float64(b * b))) + Float64(-b)) / Float64(a + a)); elseif (b <= 410.0) tmp = Float64(Float64(Float64(Float64(c * a) * -4.0) / Float64(sqrt(fma(b, b, Float64(Float64(a * -4.0) * c))) - Float64(-b))) / Float64(a + a)); else tmp = Float64(Float64(-c) / b); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -4e+85], N[((-b) / a), $MachinePrecision], If[LessEqual[b, 1.55e-200], N[(N[(N[Sqrt[N[(N[(-4.0 * a), $MachinePrecision] * c + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + (-b)), $MachinePrecision] / N[(a + a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 410.0], N[(N[(N[(N[(c * a), $MachinePrecision] * -4.0), $MachinePrecision] / N[(N[Sqrt[N[(b * b + N[(N[(a * -4.0), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - (-b)), $MachinePrecision]), $MachinePrecision] / N[(a + a), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4 \cdot 10^{+85}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{elif}\;b \leq 1.55 \cdot 10^{-200}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(-4 \cdot a, c, b \cdot b\right)} + \left(-b\right)}{a + a}\\
\mathbf{elif}\;b \leq 410:\\
\;\;\;\;\frac{\frac{\left(c \cdot a\right) \cdot -4}{\sqrt{\mathsf{fma}\left(b, b, \left(a \cdot -4\right) \cdot c\right)} - \left(-b\right)}}{a + a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -4.0000000000000001e85Initial program 57.6%
Taylor expanded in b around -inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lift-neg.f6495.1
Applied rewrites95.1%
if -4.0000000000000001e85 < b < 1.5499999999999999e-200Initial program 84.0%
lift-neg.f64N/A
lift-+.f64N/A
lift-sqrt.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
Applied rewrites84.0%
lift-*.f64N/A
count-2-revN/A
lower-+.f6484.0
Applied rewrites84.0%
if 1.5499999999999999e-200 < b < 410Initial program 52.4%
lift-neg.f64N/A
lift-+.f64N/A
lift-sqrt.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
Applied rewrites52.4%
lift-*.f64N/A
count-2-revN/A
lower-+.f6452.4
Applied rewrites52.4%
lift-neg.f64N/A
lift-+.f64N/A
lift-sqrt.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
flip-+N/A
lower-/.f64N/A
Applied rewrites52.0%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6472.3
Applied rewrites72.3%
if 410 < b Initial program 13.1%
Taylor expanded in a around 0
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6491.9
Applied rewrites91.9%
(FPCore (a b c)
:precision binary64
(if (<= b -4e+85)
(/ (- b) a)
(if (<= b 3.4e-38)
(/ (+ (sqrt (fma (* -4.0 a) c (* b b))) (- b)) (+ a a))
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4e+85) {
tmp = -b / a;
} else if (b <= 3.4e-38) {
tmp = (sqrt(fma((-4.0 * a), c, (b * b))) + -b) / (a + a);
} else {
tmp = -c / b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -4e+85) tmp = Float64(Float64(-b) / a); elseif (b <= 3.4e-38) tmp = Float64(Float64(sqrt(fma(Float64(-4.0 * a), c, Float64(b * b))) + Float64(-b)) / Float64(a + a)); else tmp = Float64(Float64(-c) / b); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -4e+85], N[((-b) / a), $MachinePrecision], If[LessEqual[b, 3.4e-38], N[(N[(N[Sqrt[N[(N[(-4.0 * a), $MachinePrecision] * c + 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 -4 \cdot 10^{+85}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{elif}\;b \leq 3.4 \cdot 10^{-38}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(-4 \cdot a, c, b \cdot b\right)} + \left(-b\right)}{a + a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -4.0000000000000001e85Initial program 57.6%
Taylor expanded in b around -inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lift-neg.f6495.1
Applied rewrites95.1%
if -4.0000000000000001e85 < b < 3.4000000000000002e-38Initial program 77.4%
lift-neg.f64N/A
lift-+.f64N/A
lift-sqrt.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
Applied rewrites77.4%
lift-*.f64N/A
count-2-revN/A
lower-+.f6477.4
Applied rewrites77.4%
if 3.4000000000000002e-38 < b Initial program 15.4%
Taylor expanded in a around 0
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6488.9
Applied rewrites88.9%
(FPCore (a b c)
:precision binary64
(if (<= b -5.1e-157)
(/ (- b) a)
(if (<= b 1.8e-263)
(- (sqrt (/ (- c) a)))
(if (<= b 9.2e-148) (/ (sqrt (- c)) (sqrt a)) (/ (- c) b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5.1e-157) {
tmp = -b / a;
} else if (b <= 1.8e-263) {
tmp = -sqrt((-c / a));
} else if (b <= 9.2e-148) {
tmp = sqrt(-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 <= (-5.1d-157)) then
tmp = -b / a
else if (b <= 1.8d-263) then
tmp = -sqrt((-c / a))
else if (b <= 9.2d-148) then
tmp = sqrt(-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 <= -5.1e-157) {
tmp = -b / a;
} else if (b <= 1.8e-263) {
tmp = -Math.sqrt((-c / a));
} else if (b <= 9.2e-148) {
tmp = Math.sqrt(-c) / Math.sqrt(a);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5.1e-157: tmp = -b / a elif b <= 1.8e-263: tmp = -math.sqrt((-c / a)) elif b <= 9.2e-148: tmp = math.sqrt(-c) / math.sqrt(a) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5.1e-157) tmp = Float64(Float64(-b) / a); elseif (b <= 1.8e-263) tmp = Float64(-sqrt(Float64(Float64(-c) / a))); elseif (b <= 9.2e-148) tmp = Float64(sqrt(Float64(-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 <= -5.1e-157) tmp = -b / a; elseif (b <= 1.8e-263) tmp = -sqrt((-c / a)); elseif (b <= 9.2e-148) tmp = sqrt(-c) / sqrt(a); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5.1e-157], N[((-b) / a), $MachinePrecision], If[LessEqual[b, 1.8e-263], (-N[Sqrt[N[((-c) / a), $MachinePrecision]], $MachinePrecision]), If[LessEqual[b, 9.2e-148], N[(N[Sqrt[(-c)], $MachinePrecision] / N[Sqrt[a], $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5.1 \cdot 10^{-157}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{elif}\;b \leq 1.8 \cdot 10^{-263}:\\
\;\;\;\;-\sqrt{\frac{-c}{a}}\\
\mathbf{elif}\;b \leq 9.2 \cdot 10^{-148}:\\
\;\;\;\;\frac{\sqrt{-c}}{\sqrt{a}}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -5.09999999999999999e-157Initial program 72.5%
Taylor expanded in b around -inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lift-neg.f6479.6
Applied rewrites79.6%
if -5.09999999999999999e-157 < b < 1.8e-263Initial program 73.6%
lift-neg.f64N/A
lift-+.f64N/A
lift-sqrt.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
Applied rewrites73.6%
Taylor expanded in a around -inf
sqrt-prodN/A
mul-1-negN/A
lift-/.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
lift-neg.f6437.8
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6437.8
Applied rewrites37.8%
if 1.8e-263 < b < 9.1999999999999999e-148Initial program 73.2%
lift-neg.f64N/A
lift-+.f64N/A
lift-sqrt.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
Applied rewrites73.2%
Taylor expanded in a around -inf
sqrt-prodN/A
mul-1-negN/A
lift-/.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
lift-neg.f6432.4
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6432.4
Applied rewrites32.4%
Taylor expanded in c around -inf
sqrt-unprodN/A
*-commutativeN/A
mul-1-negN/A
distribute-frac-negN/A
lift-/.f64N/A
lift-neg.f64N/A
lift-sqrt.f6435.8
Applied rewrites35.8%
lift-sqrt.f64N/A
lift-neg.f64N/A
lift-/.f64N/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lift-neg.f64N/A
lower-sqrt.f6445.8
Applied rewrites45.8%
if 9.1999999999999999e-148 < b Initial program 21.9%
Taylor expanded in a around 0
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6480.8
Applied rewrites80.8%
(FPCore (a b c)
:precision binary64
(if (<= b -1.9e-96)
(/ (- b) a)
(if (<= b 3.4e-38)
(/ (+ (sqrt (* (* a -4.0) c)) (- b)) (+ a a))
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.9e-96) {
tmp = -b / a;
} else if (b <= 3.4e-38) {
tmp = (sqrt(((a * -4.0) * c)) + -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.9d-96)) then
tmp = -b / a
else if (b <= 3.4d-38) then
tmp = (sqrt(((a * (-4.0d0)) * c)) + -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.9e-96) {
tmp = -b / a;
} else if (b <= 3.4e-38) {
tmp = (Math.sqrt(((a * -4.0) * c)) + -b) / (a + a);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.9e-96: tmp = -b / a elif b <= 3.4e-38: tmp = (math.sqrt(((a * -4.0) * c)) + -b) / (a + a) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.9e-96) tmp = Float64(Float64(-b) / a); elseif (b <= 3.4e-38) tmp = Float64(Float64(sqrt(Float64(Float64(a * -4.0) * c)) + Float64(-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.9e-96) tmp = -b / a; elseif (b <= 3.4e-38) tmp = (sqrt(((a * -4.0) * c)) + -b) / (a + a); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.9e-96], N[((-b) / a), $MachinePrecision], If[LessEqual[b, 3.4e-38], N[(N[(N[Sqrt[N[(N[(a * -4.0), $MachinePrecision] * c), $MachinePrecision]], $MachinePrecision] + (-b)), $MachinePrecision] / N[(a + a), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.9 \cdot 10^{-96}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{elif}\;b \leq 3.4 \cdot 10^{-38}:\\
\;\;\;\;\frac{\sqrt{\left(a \cdot -4\right) \cdot c} + \left(-b\right)}{a + a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -1.9e-96Initial program 70.8%
Taylor expanded in b around -inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lift-neg.f6484.1
Applied rewrites84.1%
if -1.9e-96 < b < 3.4000000000000002e-38Initial program 69.9%
lift-neg.f64N/A
lift-+.f64N/A
lift-sqrt.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
Applied rewrites69.9%
lift-*.f64N/A
count-2-revN/A
lower-+.f6469.9
Applied rewrites69.9%
Taylor expanded in a around inf
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6465.5
Applied rewrites65.5%
if 3.4000000000000002e-38 < b Initial program 15.4%
Taylor expanded in a around 0
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6488.9
Applied rewrites88.9%
(FPCore (a b c) :precision binary64 (if (<= b -1.8e-114) (/ (- b) a) (if (<= b 3.4e-38) (/ (sqrt (* -4.0 (* c a))) (+ a a)) (/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.8e-114) {
tmp = -b / a;
} else if (b <= 3.4e-38) {
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 <= (-1.8d-114)) then
tmp = -b / a
else if (b <= 3.4d-38) 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 <= -1.8e-114) {
tmp = -b / a;
} else if (b <= 3.4e-38) {
tmp = Math.sqrt((-4.0 * (c * a))) / (a + a);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.8e-114: tmp = -b / a elif b <= 3.4e-38: 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 <= -1.8e-114) tmp = Float64(Float64(-b) / a); elseif (b <= 3.4e-38) 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 <= -1.8e-114) tmp = -b / a; elseif (b <= 3.4e-38) tmp = sqrt((-4.0 * (c * a))) / (a + a); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.8e-114], N[((-b) / a), $MachinePrecision], If[LessEqual[b, 3.4e-38], 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 -1.8 \cdot 10^{-114}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{elif}\;b \leq 3.4 \cdot 10^{-38}:\\
\;\;\;\;\frac{\sqrt{-4 \cdot \left(c \cdot a\right)}}{a + a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -1.80000000000000009e-114Initial program 71.4%
Taylor expanded in b around -inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lift-neg.f6483.0
Applied rewrites83.0%
if -1.80000000000000009e-114 < b < 3.4000000000000002e-38Initial program 69.1%
Taylor expanded in a around inf
sqrt-unprodN/A
*-commutativeN/A
lower-sqrt.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6464.9
Applied rewrites64.9%
lift-*.f64N/A
count-2-revN/A
lower-+.f6464.9
Applied rewrites64.9%
if 3.4000000000000002e-38 < b Initial program 15.4%
Taylor expanded in a around 0
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6488.9
Applied rewrites88.9%
(FPCore (a b c) :precision binary64 (if (<= b -5.1e-157) (/ (- b) a) (if (<= b 2.4e-183) (- (sqrt (/ (- c) a))) (/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5.1e-157) {
tmp = -b / a;
} else if (b <= 2.4e-183) {
tmp = -sqrt((-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 <= (-5.1d-157)) then
tmp = -b / a
else if (b <= 2.4d-183) then
tmp = -sqrt((-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 <= -5.1e-157) {
tmp = -b / a;
} else if (b <= 2.4e-183) {
tmp = -Math.sqrt((-c / a));
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5.1e-157: tmp = -b / a elif b <= 2.4e-183: tmp = -math.sqrt((-c / a)) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5.1e-157) tmp = Float64(Float64(-b) / a); elseif (b <= 2.4e-183) tmp = Float64(-sqrt(Float64(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 <= -5.1e-157) tmp = -b / a; elseif (b <= 2.4e-183) tmp = -sqrt((-c / a)); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5.1e-157], N[((-b) / a), $MachinePrecision], If[LessEqual[b, 2.4e-183], (-N[Sqrt[N[((-c) / a), $MachinePrecision]], $MachinePrecision]), N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5.1 \cdot 10^{-157}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{elif}\;b \leq 2.4 \cdot 10^{-183}:\\
\;\;\;\;-\sqrt{\frac{-c}{a}}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -5.09999999999999999e-157Initial program 72.5%
Taylor expanded in b around -inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lift-neg.f6479.6
Applied rewrites79.6%
if -5.09999999999999999e-157 < b < 2.39999999999999993e-183Initial program 74.2%
lift-neg.f64N/A
lift-+.f64N/A
lift-sqrt.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
Applied rewrites74.2%
Taylor expanded in a around -inf
sqrt-prodN/A
mul-1-negN/A
lift-/.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
lift-neg.f6436.9
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6436.9
Applied rewrites36.9%
if 2.39999999999999993e-183 < b Initial program 24.5%
Taylor expanded in a around 0
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6477.6
Applied rewrites77.6%
(FPCore (a b c) :precision binary64 (if (<= b -1.75e-131) (/ (- b) a) (if (<= b 2.5e-151) (sqrt (/ (- c) a)) (/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.75e-131) {
tmp = -b / a;
} else if (b <= 2.5e-151) {
tmp = sqrt((-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 <= (-1.75d-131)) then
tmp = -b / a
else if (b <= 2.5d-151) then
tmp = sqrt((-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 <= -1.75e-131) {
tmp = -b / a;
} else if (b <= 2.5e-151) {
tmp = Math.sqrt((-c / a));
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.75e-131: tmp = -b / a elif b <= 2.5e-151: tmp = math.sqrt((-c / a)) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.75e-131) tmp = Float64(Float64(-b) / a); elseif (b <= 2.5e-151) tmp = sqrt(Float64(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 <= -1.75e-131) tmp = -b / a; elseif (b <= 2.5e-151) tmp = sqrt((-c / a)); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.75e-131], N[((-b) / a), $MachinePrecision], If[LessEqual[b, 2.5e-151], N[Sqrt[N[((-c) / a), $MachinePrecision]], $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.75 \cdot 10^{-131}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{elif}\;b \leq 2.5 \cdot 10^{-151}:\\
\;\;\;\;\sqrt{\frac{-c}{a}}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -1.7500000000000001e-131Initial program 71.9%
Taylor expanded in b around -inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lift-neg.f6481.7
Applied rewrites81.7%
if -1.7500000000000001e-131 < b < 2.50000000000000002e-151Initial program 74.8%
Taylor expanded in a around -inf
mul-1-negN/A
lower-neg.f64N/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6435.0
Applied rewrites35.0%
Taylor expanded in c around -inf
sqrt-prodN/A
lower-sqrt.f64N/A
*-commutativeN/A
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6435.6
Applied rewrites35.6%
if 2.50000000000000002e-151 < b Initial program 22.2%
Taylor expanded in a around 0
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6480.5
Applied rewrites80.5%
(FPCore (a b c) :precision binary64 (if (<= b 2e-240) (/ (- b) a) (/ (- c) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 2e-240) {
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 <= 2d-240) 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 <= 2e-240) {
tmp = -b / a;
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2e-240: tmp = -b / a else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2e-240) 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 <= 2e-240) tmp = -b / a; else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2e-240], N[((-b) / a), $MachinePrecision], N[((-c) / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2 \cdot 10^{-240}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < 1.9999999999999999e-240Initial program 72.8%
Taylor expanded in b around -inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lift-neg.f6464.3
Applied rewrites64.3%
if 1.9999999999999999e-240 < b Initial program 28.4%
Taylor expanded in a around 0
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6472.5
Applied rewrites72.5%
(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.3%
Taylor expanded in b around -inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lift-neg.f6435.8
Applied rewrites35.8%
herbie shell --seed 2025088
(FPCore (a b c)
:name "Quadratic roots, full range"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))