
(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
(let* ((t_0 (/ (+ (sqrt (fma (* -4.0 a) c (* b b))) (- b)) (+ a a)))
(t_1 (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))
(t_2 (fma (/ (- (fabs b) b) a) 0.5 (/ (- c) (fabs b)))))
(if (<= t_1 (- INFINITY))
t_2
(if (<= t_1 -1e-305)
t_0
(if (<= t_1 0.0) (/ (- c) b) (if (<= t_1 2e+226) t_0 t_2))))))
double code(double a, double b, double c) {
double t_0 = (sqrt(fma((-4.0 * a), c, (b * b))) + -b) / (a + a);
double t_1 = (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
double t_2 = fma(((fabs(b) - b) / a), 0.5, (-c / fabs(b)));
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = t_2;
} else if (t_1 <= -1e-305) {
tmp = t_0;
} else if (t_1 <= 0.0) {
tmp = -c / b;
} else if (t_1 <= 2e+226) {
tmp = t_0;
} else {
tmp = t_2;
}
return tmp;
}
function code(a, b, c) t_0 = Float64(Float64(sqrt(fma(Float64(-4.0 * a), c, Float64(b * b))) + Float64(-b)) / Float64(a + a)) t_1 = Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c)))) / Float64(2.0 * a)) t_2 = fma(Float64(Float64(abs(b) - b) / a), 0.5, Float64(Float64(-c) / abs(b))) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = t_2; elseif (t_1 <= -1e-305) tmp = t_0; elseif (t_1 <= 0.0) tmp = Float64(Float64(-c) / b); elseif (t_1 <= 2e+226) tmp = t_0; else tmp = t_2; end return tmp end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(N[Sqrt[N[(N[(-4.0 * a), $MachinePrecision] * c + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + (-b)), $MachinePrecision] / N[(a + a), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = 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]}, Block[{t$95$2 = N[(N[(N[(N[Abs[b], $MachinePrecision] - b), $MachinePrecision] / a), $MachinePrecision] * 0.5 + N[((-c) / N[Abs[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], t$95$2, If[LessEqual[t$95$1, -1e-305], t$95$0, If[LessEqual[t$95$1, 0.0], N[((-c) / b), $MachinePrecision], If[LessEqual[t$95$1, 2e+226], t$95$0, t$95$2]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sqrt{\mathsf{fma}\left(-4 \cdot a, c, b \cdot b\right)} + \left(-b\right)}{a + a}\\
t_1 := \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\
t_2 := \mathsf{fma}\left(\frac{\left|b\right| - b}{a}, 0.5, \frac{-c}{\left|b\right|}\right)\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq -1 \cdot 10^{-305}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_1 \leq 0:\\
\;\;\;\;\frac{-c}{b}\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+226}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a)) < -inf.0 or 1.99999999999999992e226 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a)) Initial program 52.9%
Taylor expanded in c around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower--.f64N/A
pow2N/A
rem-sqrt-square-revN/A
lower-fabs.f64N/A
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f64N/A
pow2N/A
rem-sqrt-square-revN/A
lower-fabs.f6467.6
Applied rewrites67.6%
if -inf.0 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a)) < -9.99999999999999996e-306 or -0.0 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a)) < 1.99999999999999992e226Initial program 52.9%
Applied rewrites53.0%
if -9.99999999999999996e-306 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a)) < -0.0Initial program 52.9%
Taylor expanded in b around inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6434.6
Applied rewrites34.6%
(FPCore (a b c)
:precision binary64
(if (<= b -2.2e-62)
(fma (/ (- (fabs b) b) a) 0.5 (/ (- c) (fabs b)))
(if (<= b 2.8e-75)
(/ (- (sqrt (* (* c a) -4.0)) b) (* 2.0 a))
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.2e-62) {
tmp = fma(((fabs(b) - b) / a), 0.5, (-c / fabs(b)));
} else if (b <= 2.8e-75) {
tmp = (sqrt(((c * a) * -4.0)) - b) / (2.0 * a);
} else {
tmp = -c / b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -2.2e-62) tmp = fma(Float64(Float64(abs(b) - b) / a), 0.5, Float64(Float64(-c) / abs(b))); elseif (b <= 2.8e-75) tmp = Float64(Float64(sqrt(Float64(Float64(c * a) * -4.0)) - b) / Float64(2.0 * a)); else tmp = Float64(Float64(-c) / b); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -2.2e-62], N[(N[(N[(N[Abs[b], $MachinePrecision] - b), $MachinePrecision] / a), $MachinePrecision] * 0.5 + N[((-c) / N[Abs[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.8e-75], N[(N[(N[Sqrt[N[(N[(c * a), $MachinePrecision] * -4.0), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.2 \cdot 10^{-62}:\\
\;\;\;\;\mathsf{fma}\left(\frac{\left|b\right| - b}{a}, 0.5, \frac{-c}{\left|b\right|}\right)\\
\mathbf{elif}\;b \leq 2.8 \cdot 10^{-75}:\\
\;\;\;\;\frac{\sqrt{\left(c \cdot a\right) \cdot -4} - b}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -2.20000000000000017e-62Initial program 52.9%
Taylor expanded in c around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower--.f64N/A
pow2N/A
rem-sqrt-square-revN/A
lower-fabs.f64N/A
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f64N/A
pow2N/A
rem-sqrt-square-revN/A
lower-fabs.f6467.6
Applied rewrites67.6%
if -2.20000000000000017e-62 < b < 2.79999999999999998e-75Initial program 52.9%
Taylor expanded in c around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
associate-*r/N/A
mul-1-negN/A
lift-neg.f64N/A
lower-/.f64N/A
rem-square-sqrtN/A
lower-sqrt.f64N/A
rem-square-sqrtN/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6421.1
Applied rewrites21.1%
Taylor expanded in b around 0
mul-1-negN/A
lift-neg.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
lift-sqrt.f6421.3
Applied rewrites21.3%
Taylor expanded in c around 0
lower--.f64N/A
lower-sqrt.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6434.1
Applied rewrites34.1%
if 2.79999999999999998e-75 < b Initial program 52.9%
Taylor expanded in b around inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6434.6
Applied rewrites34.6%
(FPCore (a b c)
:precision binary64
(if (<= b -2.2e-62)
(/ (- b) a)
(if (<= b 2.8e-75)
(/ (- (sqrt (* (* c a) -4.0)) b) (* 2.0 a))
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.2e-62) {
tmp = -b / a;
} else if (b <= 2.8e-75) {
tmp = (sqrt(((c * a) * -4.0)) - b) / (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 <= (-2.2d-62)) then
tmp = -b / a
else if (b <= 2.8d-75) then
tmp = (sqrt(((c * a) * (-4.0d0))) - b) / (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 <= -2.2e-62) {
tmp = -b / a;
} else if (b <= 2.8e-75) {
tmp = (Math.sqrt(((c * a) * -4.0)) - b) / (2.0 * a);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.2e-62: tmp = -b / a elif b <= 2.8e-75: tmp = (math.sqrt(((c * a) * -4.0)) - b) / (2.0 * a) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.2e-62) tmp = Float64(Float64(-b) / a); elseif (b <= 2.8e-75) tmp = Float64(Float64(sqrt(Float64(Float64(c * a) * -4.0)) - b) / 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 <= -2.2e-62) tmp = -b / a; elseif (b <= 2.8e-75) tmp = (sqrt(((c * a) * -4.0)) - b) / (2.0 * a); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.2e-62], N[((-b) / a), $MachinePrecision], If[LessEqual[b, 2.8e-75], N[(N[(N[Sqrt[N[(N[(c * a), $MachinePrecision] * -4.0), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.2 \cdot 10^{-62}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{elif}\;b \leq 2.8 \cdot 10^{-75}:\\
\;\;\;\;\frac{\sqrt{\left(c \cdot a\right) \cdot -4} - b}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -2.20000000000000017e-62Initial program 52.9%
Taylor expanded in b around -inf
associate-*r/N/A
mul-1-negN/A
lift-neg.f64N/A
lower-/.f6435.3
Applied rewrites35.3%
if -2.20000000000000017e-62 < b < 2.79999999999999998e-75Initial program 52.9%
Taylor expanded in c around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
associate-*r/N/A
mul-1-negN/A
lift-neg.f64N/A
lower-/.f64N/A
rem-square-sqrtN/A
lower-sqrt.f64N/A
rem-square-sqrtN/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6421.1
Applied rewrites21.1%
Taylor expanded in b around 0
mul-1-negN/A
lift-neg.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
lift-sqrt.f6421.3
Applied rewrites21.3%
Taylor expanded in c around 0
lower--.f64N/A
lower-sqrt.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6434.1
Applied rewrites34.1%
if 2.79999999999999998e-75 < b Initial program 52.9%
Taylor expanded in b around inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6434.6
Applied rewrites34.6%
(FPCore (a b c) :precision binary64 (if (<= b -2.2e-62) (/ (- b) a) (if (<= b 2.8e-75) (/ (sqrt (* (* c a) -4.0)) (+ a a)) (/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.2e-62) {
tmp = -b / a;
} else if (b <= 2.8e-75) {
tmp = sqrt(((c * a) * -4.0)) / (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 <= (-2.2d-62)) then
tmp = -b / a
else if (b <= 2.8d-75) then
tmp = sqrt(((c * a) * (-4.0d0))) / (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 <= -2.2e-62) {
tmp = -b / a;
} else if (b <= 2.8e-75) {
tmp = Math.sqrt(((c * a) * -4.0)) / (a + a);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.2e-62: tmp = -b / a elif b <= 2.8e-75: tmp = math.sqrt(((c * a) * -4.0)) / (a + a) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.2e-62) tmp = Float64(Float64(-b) / a); elseif (b <= 2.8e-75) tmp = Float64(sqrt(Float64(Float64(c * a) * -4.0)) / 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 <= -2.2e-62) tmp = -b / a; elseif (b <= 2.8e-75) tmp = sqrt(((c * a) * -4.0)) / (a + a); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.2e-62], N[((-b) / a), $MachinePrecision], If[LessEqual[b, 2.8e-75], N[(N[Sqrt[N[(N[(c * a), $MachinePrecision] * -4.0), $MachinePrecision]], $MachinePrecision] / N[(a + a), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.2 \cdot 10^{-62}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{elif}\;b \leq 2.8 \cdot 10^{-75}:\\
\;\;\;\;\frac{\sqrt{\left(c \cdot a\right) \cdot -4}}{a + a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -2.20000000000000017e-62Initial program 52.9%
Taylor expanded in b around -inf
associate-*r/N/A
mul-1-negN/A
lift-neg.f64N/A
lower-/.f6435.3
Applied rewrites35.3%
if -2.20000000000000017e-62 < b < 2.79999999999999998e-75Initial program 52.9%
Applied rewrites53.0%
Taylor expanded in b around 0
lower-sqrt.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6429.7
Applied rewrites29.7%
if 2.79999999999999998e-75 < b Initial program 52.9%
Taylor expanded in b around inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6434.6
Applied rewrites34.6%
(FPCore (a b c) :precision binary64 (if (<= b -1.26e-160) (/ (- b) a) (if (<= b 2.6e-169) (* -0.5 (sqrt (* (/ c a) -4.0))) (/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.26e-160) {
tmp = -b / a;
} else if (b <= 2.6e-169) {
tmp = -0.5 * sqrt(((c / a) * -4.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) :: tmp
if (b <= (-1.26d-160)) then
tmp = -b / a
else if (b <= 2.6d-169) then
tmp = (-0.5d0) * sqrt(((c / a) * (-4.0d0)))
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.26e-160) {
tmp = -b / a;
} else if (b <= 2.6e-169) {
tmp = -0.5 * Math.sqrt(((c / a) * -4.0));
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.26e-160: tmp = -b / a elif b <= 2.6e-169: tmp = -0.5 * math.sqrt(((c / a) * -4.0)) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.26e-160) tmp = Float64(Float64(-b) / a); elseif (b <= 2.6e-169) tmp = Float64(-0.5 * sqrt(Float64(Float64(c / a) * -4.0))); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.26e-160) tmp = -b / a; elseif (b <= 2.6e-169) tmp = -0.5 * sqrt(((c / a) * -4.0)); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.26e-160], N[((-b) / a), $MachinePrecision], If[LessEqual[b, 2.6e-169], N[(-0.5 * N[Sqrt[N[(N[(c / a), $MachinePrecision] * -4.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.26 \cdot 10^{-160}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{elif}\;b \leq 2.6 \cdot 10^{-169}:\\
\;\;\;\;-0.5 \cdot \sqrt{\frac{c}{a} \cdot -4}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -1.26e-160Initial program 52.9%
Taylor expanded in b around -inf
associate-*r/N/A
mul-1-negN/A
lift-neg.f64N/A
lower-/.f6435.3
Applied rewrites35.3%
if -1.26e-160 < b < 2.60000000000000014e-169Initial program 52.9%
Taylor expanded in a around -inf
lower-*.f64N/A
rem-square-sqrtN/A
lower-sqrt.f64N/A
rem-square-sqrtN/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6417.7
Applied rewrites17.7%
if 2.60000000000000014e-169 < b Initial program 52.9%
Taylor expanded in b around inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6434.6
Applied rewrites34.6%
(FPCore (a b c) :precision binary64 (if (<= b 2.9e-308) (/ (- (fabs b) b) (+ a a)) (/ (- c) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 2.9e-308) {
tmp = (fabs(b) - 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 <= 2.9d-308) then
tmp = (abs(b) - 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 <= 2.9e-308) {
tmp = (Math.abs(b) - b) / (a + a);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2.9e-308: tmp = (math.fabs(b) - b) / (a + a) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2.9e-308) tmp = Float64(Float64(abs(b) - 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 <= 2.9e-308) tmp = (abs(b) - b) / (a + a); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2.9e-308], N[(N[(N[Abs[b], $MachinePrecision] - b), $MachinePrecision] / N[(a + a), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.9 \cdot 10^{-308}:\\
\;\;\;\;\frac{\left|b\right| - b}{a + a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < 2.9e-308Initial program 52.9%
Applied rewrites53.0%
Taylor expanded in a around 0
lower--.f64N/A
pow2N/A
rem-sqrt-square-revN/A
lower-fabs.f6444.1
Applied rewrites44.1%
if 2.9e-308 < b Initial program 52.9%
Taylor expanded in b around inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6434.6
Applied rewrites34.6%
(FPCore (a b c) :precision binary64 (if (<= b 2.9e-308) (/ (- b) a) (/ (- c) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 2.9e-308) {
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 <= 2.9d-308) 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 <= 2.9e-308) {
tmp = -b / a;
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2.9e-308: tmp = -b / a else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2.9e-308) 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 <= 2.9e-308) tmp = -b / a; else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2.9e-308], N[((-b) / a), $MachinePrecision], N[((-c) / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.9 \cdot 10^{-308}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < 2.9e-308Initial program 52.9%
Taylor expanded in b around -inf
associate-*r/N/A
mul-1-negN/A
lift-neg.f64N/A
lower-/.f6435.3
Applied rewrites35.3%
if 2.9e-308 < b Initial program 52.9%
Taylor expanded in b around inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6434.6
Applied rewrites34.6%
(FPCore (a b c) :precision binary64 (if (<= b -1e-311) (/ (- b) a) 0.0))
double code(double a, double b, double c) {
double tmp;
if (b <= -1e-311) {
tmp = -b / a;
} else {
tmp = 0.0;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b, 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 <= (-1d-311)) then
tmp = -b / a
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1e-311) {
tmp = -b / a;
} else {
tmp = 0.0;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1e-311: tmp = -b / a else: tmp = 0.0 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1e-311) tmp = Float64(Float64(-b) / a); else tmp = 0.0; end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1e-311) tmp = -b / a; else tmp = 0.0; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1e-311], N[((-b) / a), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1 \cdot 10^{-311}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if b < -9.99999999999948e-312Initial program 52.9%
Taylor expanded in b around -inf
associate-*r/N/A
mul-1-negN/A
lift-neg.f64N/A
lower-/.f6435.3
Applied rewrites35.3%
if -9.99999999999948e-312 < b Initial program 52.9%
Taylor expanded in a around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f6434.1
Applied rewrites34.1%
lift-sqrt.f64N/A
pow1/2N/A
metadata-evalN/A
pow-negN/A
lower-/.f64N/A
lower-pow.f6434.0
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lift-*.f6434.0
Applied rewrites34.0%
Taylor expanded in b around inf
pow-flip11.6
metadata-eval11.6
pow1/211.6
Applied rewrites11.6%
(FPCore (a b c) :precision binary64 0.0)
double code(double a, double b, double c) {
return 0.0;
}
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 = 0.0d0
end function
public static double code(double a, double b, double c) {
return 0.0;
}
def code(a, b, c): return 0.0
function code(a, b, c) return 0.0 end
function tmp = code(a, b, c) tmp = 0.0; end
code[a_, b_, c_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 52.9%
Taylor expanded in a around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f6434.1
Applied rewrites34.1%
lift-sqrt.f64N/A
pow1/2N/A
metadata-evalN/A
pow-negN/A
lower-/.f64N/A
lower-pow.f6434.0
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lift-*.f6434.0
Applied rewrites34.0%
Taylor expanded in b around inf
pow-flip11.6
metadata-eval11.6
pow1/211.6
Applied rewrites11.6%
herbie shell --seed 2025139
(FPCore (a b c)
:name "Quadratic roots, full range"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))