
(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
(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 (/ (- (fabs b) b) a))
(t_3 (fma t_2 0.5 (/ (- c) (fabs b)))))
(if (<= t_1 -1e+257)
(fma t_2 0.5 (* (- (/ (- (* c a)) (* (* b b) b)) (/ 1.0 (fabs b))) c))
(if (<= t_1 -1e-218)
t_0
(if (<= t_1 0.0) t_3 (if (<= t_1 5e+263) t_0 t_3))))))
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 = (fabs(b) - b) / a;
double t_3 = fma(t_2, 0.5, (-c / fabs(b)));
double tmp;
if (t_1 <= -1e+257) {
tmp = fma(t_2, 0.5, (((-(c * a) / ((b * b) * b)) - (1.0 / fabs(b))) * c));
} else if (t_1 <= -1e-218) {
tmp = t_0;
} else if (t_1 <= 0.0) {
tmp = t_3;
} else if (t_1 <= 5e+263) {
tmp = t_0;
} else {
tmp = t_3;
}
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 = Float64(Float64(abs(b) - b) / a) t_3 = fma(t_2, 0.5, Float64(Float64(-c) / abs(b))) tmp = 0.0 if (t_1 <= -1e+257) tmp = fma(t_2, 0.5, Float64(Float64(Float64(Float64(-Float64(c * a)) / Float64(Float64(b * b) * b)) - Float64(1.0 / abs(b))) * c)); elseif (t_1 <= -1e-218) tmp = t_0; elseif (t_1 <= 0.0) tmp = t_3; elseif (t_1 <= 5e+263) tmp = t_0; else tmp = t_3; 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[Abs[b], $MachinePrecision] - b), $MachinePrecision] / a), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$2 * 0.5 + N[((-c) / N[Abs[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -1e+257], N[(t$95$2 * 0.5 + N[(N[(N[((-N[(c * a), $MachinePrecision]) / N[(N[(b * b), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision] - N[(1.0 / N[Abs[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, -1e-218], t$95$0, If[LessEqual[t$95$1, 0.0], t$95$3, If[LessEqual[t$95$1, 5e+263], t$95$0, t$95$3]]]]]]]]
\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 := \frac{\left|b\right| - b}{a}\\
t_3 := \mathsf{fma}\left(t\_2, 0.5, \frac{-c}{\left|b\right|}\right)\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{+257}:\\
\;\;\;\;\mathsf{fma}\left(t\_2, 0.5, \left(\frac{-c \cdot a}{\left(b \cdot b\right) \cdot b} - \frac{1}{\left|b\right|}\right) \cdot c\right)\\
\mathbf{elif}\;t\_1 \leq -1 \cdot 10^{-218}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_1 \leq 0:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+263}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_3\\
\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)) < -1.00000000000000003e257Initial program 52.0%
Taylor expanded in c around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites61.0%
Applied rewrites61.5%
if -1.00000000000000003e257 < (/.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)) < -1e-218 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)) < 5.00000000000000022e263Initial program 52.0%
Applied rewrites52.0%
if -1e-218 < (/.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.0 or 5.00000000000000022e263 < (/.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.0%
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.f6468.4
Applied rewrites68.4%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (fma (/ (- (fabs b) b) a) 0.5 (/ (- c) (fabs b))))
(t_1 (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))
(t_2 (/ (+ (sqrt (fma (* -4.0 a) c (* b b))) (- b)) (+ a a))))
(if (<= t_1 -1e+257)
t_0
(if (<= t_1 -1e-218)
t_2
(if (<= t_1 0.0) t_0 (if (<= t_1 5e+263) t_2 t_0))))))
double code(double a, double b, double c) {
double t_0 = fma(((fabs(b) - b) / a), 0.5, (-c / fabs(b)));
double t_1 = (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
double t_2 = (sqrt(fma((-4.0 * a), c, (b * b))) + -b) / (a + a);
double tmp;
if (t_1 <= -1e+257) {
tmp = t_0;
} else if (t_1 <= -1e-218) {
tmp = t_2;
} else if (t_1 <= 0.0) {
tmp = t_0;
} else if (t_1 <= 5e+263) {
tmp = t_2;
} else {
tmp = t_0;
}
return tmp;
}
function code(a, b, c) t_0 = fma(Float64(Float64(abs(b) - b) / a), 0.5, Float64(Float64(-c) / abs(b))) t_1 = Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c)))) / Float64(2.0 * a)) t_2 = Float64(Float64(sqrt(fma(Float64(-4.0 * a), c, Float64(b * b))) + Float64(-b)) / Float64(a + a)) tmp = 0.0 if (t_1 <= -1e+257) tmp = t_0; elseif (t_1 <= -1e-218) tmp = t_2; elseif (t_1 <= 0.0) tmp = t_0; elseif (t_1 <= 5e+263) tmp = t_2; else tmp = t_0; end return tmp end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(N[(N[Abs[b], $MachinePrecision] - b), $MachinePrecision] / a), $MachinePrecision] * 0.5 + N[((-c) / N[Abs[b], $MachinePrecision]), $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[Sqrt[N[(N[(-4.0 * a), $MachinePrecision] * c + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + (-b)), $MachinePrecision] / N[(a + a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -1e+257], t$95$0, If[LessEqual[t$95$1, -1e-218], t$95$2, If[LessEqual[t$95$1, 0.0], t$95$0, If[LessEqual[t$95$1, 5e+263], t$95$2, t$95$0]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\frac{\left|b\right| - b}{a}, 0.5, \frac{-c}{\left|b\right|}\right)\\
t_1 := \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\
t_2 := \frac{\sqrt{\mathsf{fma}\left(-4 \cdot a, c, b \cdot b\right)} + \left(-b\right)}{a + a}\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{+257}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_1 \leq -1 \cdot 10^{-218}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 0:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+263}:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\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)) < -1.00000000000000003e257 or -1e-218 < (/.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.0 or 5.00000000000000022e263 < (/.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.0%
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.f6468.4
Applied rewrites68.4%
if -1.00000000000000003e257 < (/.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)) < -1e-218 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)) < 5.00000000000000022e263Initial program 52.0%
Applied rewrites52.0%
(FPCore (a b c) :precision binary64 (if (<= b -5.7e-21) (fma (/ (- (fabs b) b) a) 0.5 (/ (- c) (fabs b))) (if (<= b 4.5e-117) (/ (- (sqrt (* (* -4.0 a) c)) b) (+ a a)) (/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5.7e-21) {
tmp = fma(((fabs(b) - b) / a), 0.5, (-c / fabs(b)));
} else if (b <= 4.5e-117) {
tmp = (sqrt(((-4.0 * a) * c)) - b) / (a + a);
} else {
tmp = -c / b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -5.7e-21) tmp = fma(Float64(Float64(abs(b) - b) / a), 0.5, Float64(Float64(-c) / abs(b))); elseif (b <= 4.5e-117) tmp = Float64(Float64(sqrt(Float64(Float64(-4.0 * a) * c)) - b) / Float64(a + a)); else tmp = Float64(Float64(-c) / b); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -5.7e-21], N[(N[(N[(N[Abs[b], $MachinePrecision] - b), $MachinePrecision] / a), $MachinePrecision] * 0.5 + N[((-c) / N[Abs[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 4.5e-117], N[(N[(N[Sqrt[N[(N[(-4.0 * a), $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 -5.7 \cdot 10^{-21}:\\
\;\;\;\;\mathsf{fma}\left(\frac{\left|b\right| - b}{a}, 0.5, \frac{-c}{\left|b\right|}\right)\\
\mathbf{elif}\;b \leq 4.5 \cdot 10^{-117}:\\
\;\;\;\;\frac{\sqrt{\left(-4 \cdot a\right) \cdot c} - b}{a + a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -5.6999999999999996e-21Initial program 52.0%
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.f6468.4
Applied rewrites68.4%
if -5.6999999999999996e-21 < b < 4.49999999999999969e-117Initial program 52.0%
Applied rewrites52.0%
Taylor expanded in b around 0
mul-1-negN/A
lift-neg.f64N/A
lower-+.f64N/A
lower-sqrt.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lift-*.f6433.7
Applied rewrites33.7%
Taylor expanded in a around 0
metadata-evalN/A
distribute-lft-neg-inN/A
lower--.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
associate-*l*N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-*.f6433.7
Applied rewrites33.7%
if 4.49999999999999969e-117 < b Initial program 52.0%
Taylor expanded in b around inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6435.6
Applied rewrites35.6%
(FPCore (a b c) :precision binary64 (if (<= b -5.7e-21) (* (- b) (+ (/ (- c) (* b b)) (/ 1.0 a))) (if (<= b 4.5e-117) (/ (- (sqrt (* (* -4.0 a) c)) b) (+ a a)) (/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5.7e-21) {
tmp = -b * ((-c / (b * b)) + (1.0 / a));
} else if (b <= 4.5e-117) {
tmp = (sqrt(((-4.0 * a) * 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 <= (-5.7d-21)) then
tmp = -b * ((-c / (b * b)) + (1.0d0 / a))
else if (b <= 4.5d-117) then
tmp = (sqrt((((-4.0d0) * a) * 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 <= -5.7e-21) {
tmp = -b * ((-c / (b * b)) + (1.0 / a));
} else if (b <= 4.5e-117) {
tmp = (Math.sqrt(((-4.0 * a) * c)) - b) / (a + a);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5.7e-21: tmp = -b * ((-c / (b * b)) + (1.0 / a)) elif b <= 4.5e-117: tmp = (math.sqrt(((-4.0 * a) * c)) - b) / (a + a) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5.7e-21) tmp = Float64(Float64(-b) * Float64(Float64(Float64(-c) / Float64(b * b)) + Float64(1.0 / a))); elseif (b <= 4.5e-117) tmp = Float64(Float64(sqrt(Float64(Float64(-4.0 * a) * c)) - 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 <= -5.7e-21) tmp = -b * ((-c / (b * b)) + (1.0 / a)); elseif (b <= 4.5e-117) tmp = (sqrt(((-4.0 * a) * c)) - b) / (a + a); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5.7e-21], N[((-b) * N[(N[((-c) / N[(b * b), $MachinePrecision]), $MachinePrecision] + N[(1.0 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 4.5e-117], N[(N[(N[Sqrt[N[(N[(-4.0 * a), $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 -5.7 \cdot 10^{-21}:\\
\;\;\;\;\left(-b\right) \cdot \left(\frac{-c}{b \cdot b} + \frac{1}{a}\right)\\
\mathbf{elif}\;b \leq 4.5 \cdot 10^{-117}:\\
\;\;\;\;\frac{\sqrt{\left(-4 \cdot a\right) \cdot c} - b}{a + a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -5.6999999999999996e-21Initial program 52.0%
Taylor expanded in b around -inf
associate-*r*N/A
mul-1-negN/A
lift-neg.f64N/A
lower-*.f64N/A
lower-+.f64N/A
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f64N/A
pow2N/A
lift-*.f64N/A
lower-/.f6434.3
Applied rewrites34.3%
if -5.6999999999999996e-21 < b < 4.49999999999999969e-117Initial program 52.0%
Applied rewrites52.0%
Taylor expanded in b around 0
mul-1-negN/A
lift-neg.f64N/A
lower-+.f64N/A
lower-sqrt.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lift-*.f6433.7
Applied rewrites33.7%
Taylor expanded in a around 0
metadata-evalN/A
distribute-lft-neg-inN/A
lower--.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
associate-*l*N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-*.f6433.7
Applied rewrites33.7%
if 4.49999999999999969e-117 < b Initial program 52.0%
Taylor expanded in b around inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6435.6
Applied rewrites35.6%
(FPCore (a b c) :precision binary64 (if (<= b -5.7e-21) (/ (- b) a) (if (<= b 4.5e-117) (/ (- (sqrt (* (* -4.0 a) c)) b) (+ a a)) (/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5.7e-21) {
tmp = -b / a;
} else if (b <= 4.5e-117) {
tmp = (sqrt(((-4.0 * a) * 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 <= (-5.7d-21)) then
tmp = -b / a
else if (b <= 4.5d-117) then
tmp = (sqrt((((-4.0d0) * a) * 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 <= -5.7e-21) {
tmp = -b / a;
} else if (b <= 4.5e-117) {
tmp = (Math.sqrt(((-4.0 * a) * c)) - b) / (a + a);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5.7e-21: tmp = -b / a elif b <= 4.5e-117: tmp = (math.sqrt(((-4.0 * a) * c)) - b) / (a + a) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5.7e-21) tmp = Float64(Float64(-b) / a); elseif (b <= 4.5e-117) tmp = Float64(Float64(sqrt(Float64(Float64(-4.0 * a) * c)) - 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 <= -5.7e-21) tmp = -b / a; elseif (b <= 4.5e-117) tmp = (sqrt(((-4.0 * a) * c)) - b) / (a + a); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5.7e-21], N[((-b) / a), $MachinePrecision], If[LessEqual[b, 4.5e-117], N[(N[(N[Sqrt[N[(N[(-4.0 * a), $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 -5.7 \cdot 10^{-21}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{elif}\;b \leq 4.5 \cdot 10^{-117}:\\
\;\;\;\;\frac{\sqrt{\left(-4 \cdot a\right) \cdot c} - b}{a + a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -5.6999999999999996e-21Initial program 52.0%
Taylor expanded in b around -inf
associate-*r/N/A
mul-1-negN/A
lift-neg.f64N/A
lower-/.f6435.1
Applied rewrites35.1%
if -5.6999999999999996e-21 < b < 4.49999999999999969e-117Initial program 52.0%
Applied rewrites52.0%
Taylor expanded in b around 0
mul-1-negN/A
lift-neg.f64N/A
lower-+.f64N/A
lower-sqrt.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lift-*.f6433.7
Applied rewrites33.7%
Taylor expanded in a around 0
metadata-evalN/A
distribute-lft-neg-inN/A
lower--.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
associate-*l*N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-*.f6433.7
Applied rewrites33.7%
if 4.49999999999999969e-117 < b Initial program 52.0%
Taylor expanded in b around inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6435.6
Applied rewrites35.6%
(FPCore (a b c) :precision binary64 (if (<= b -5.7e-21) (/ (- b) a) (if (<= b 4.5e-117) (/ (sqrt (* (* c a) -4.0)) (+ a a)) (/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5.7e-21) {
tmp = -b / a;
} else if (b <= 4.5e-117) {
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 <= (-5.7d-21)) then
tmp = -b / a
else if (b <= 4.5d-117) 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 <= -5.7e-21) {
tmp = -b / a;
} else if (b <= 4.5e-117) {
tmp = Math.sqrt(((c * a) * -4.0)) / (a + a);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5.7e-21: tmp = -b / a elif b <= 4.5e-117: 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 <= -5.7e-21) tmp = Float64(Float64(-b) / a); elseif (b <= 4.5e-117) 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 <= -5.7e-21) tmp = -b / a; elseif (b <= 4.5e-117) tmp = sqrt(((c * a) * -4.0)) / (a + a); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5.7e-21], N[((-b) / a), $MachinePrecision], If[LessEqual[b, 4.5e-117], 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 -5.7 \cdot 10^{-21}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{elif}\;b \leq 4.5 \cdot 10^{-117}:\\
\;\;\;\;\frac{\sqrt{\left(c \cdot a\right) \cdot -4}}{a + a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -5.6999999999999996e-21Initial program 52.0%
Taylor expanded in b around -inf
associate-*r/N/A
mul-1-negN/A
lift-neg.f64N/A
lower-/.f6435.1
Applied rewrites35.1%
if -5.6999999999999996e-21 < b < 4.49999999999999969e-117Initial program 52.0%
Taylor expanded in b around 0
distribute-lft-neg-inN/A
metadata-evalN/A
lower-sqrt.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6428.8
Applied rewrites28.8%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lift-*.f6428.8
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
Applied rewrites28.8%
if 4.49999999999999969e-117 < b Initial program 52.0%
Taylor expanded in b around inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6435.6
Applied rewrites35.6%
(FPCore (a b c) :precision binary64 (if (<= b -5.7e-21) (/ (- b) a) (if (<= b 6e-102) (* (/ (sqrt (* c -4.0)) (sqrt a)) 0.5) (/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5.7e-21) {
tmp = -b / a;
} else if (b <= 6e-102) {
tmp = (sqrt((c * -4.0)) / sqrt(a)) * 0.5;
} 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.7d-21)) then
tmp = -b / a
else if (b <= 6d-102) then
tmp = (sqrt((c * (-4.0d0))) / sqrt(a)) * 0.5d0
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.7e-21) {
tmp = -b / a;
} else if (b <= 6e-102) {
tmp = (Math.sqrt((c * -4.0)) / Math.sqrt(a)) * 0.5;
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5.7e-21: tmp = -b / a elif b <= 6e-102: tmp = (math.sqrt((c * -4.0)) / math.sqrt(a)) * 0.5 else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5.7e-21) tmp = Float64(Float64(-b) / a); elseif (b <= 6e-102) tmp = Float64(Float64(sqrt(Float64(c * -4.0)) / sqrt(a)) * 0.5); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5.7e-21) tmp = -b / a; elseif (b <= 6e-102) tmp = (sqrt((c * -4.0)) / sqrt(a)) * 0.5; else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5.7e-21], N[((-b) / a), $MachinePrecision], If[LessEqual[b, 6e-102], N[(N[(N[Sqrt[N[(c * -4.0), $MachinePrecision]], $MachinePrecision] / N[Sqrt[a], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5.7 \cdot 10^{-21}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{elif}\;b \leq 6 \cdot 10^{-102}:\\
\;\;\;\;\frac{\sqrt{c \cdot -4}}{\sqrt{a}} \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -5.6999999999999996e-21Initial program 52.0%
Taylor expanded in b around -inf
associate-*r/N/A
mul-1-negN/A
lift-neg.f64N/A
lower-/.f6435.1
Applied rewrites35.1%
if -5.6999999999999996e-21 < b < 6e-102Initial program 52.0%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
rem-square-sqrtN/A
lower-sqrt.f64N/A
rem-square-sqrtN/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6417.4
Applied rewrites17.4%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-sqrt.f6416.7
Applied rewrites16.7%
if 6e-102 < b Initial program 52.0%
Taylor expanded in b around inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6435.6
Applied rewrites35.6%
(FPCore (a b c) :precision binary64 (if (<= b -5.7e-21) (/ (- b) a) (if (<= b 6e-102) (* (sqrt (/ (* c -4.0) a)) 0.5) (/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5.7e-21) {
tmp = -b / a;
} else if (b <= 6e-102) {
tmp = sqrt(((c * -4.0) / a)) * 0.5;
} 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.7d-21)) then
tmp = -b / a
else if (b <= 6d-102) then
tmp = sqrt(((c * (-4.0d0)) / a)) * 0.5d0
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.7e-21) {
tmp = -b / a;
} else if (b <= 6e-102) {
tmp = Math.sqrt(((c * -4.0) / a)) * 0.5;
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5.7e-21: tmp = -b / a elif b <= 6e-102: tmp = math.sqrt(((c * -4.0) / a)) * 0.5 else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5.7e-21) tmp = Float64(Float64(-b) / a); elseif (b <= 6e-102) tmp = Float64(sqrt(Float64(Float64(c * -4.0) / a)) * 0.5); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5.7e-21) tmp = -b / a; elseif (b <= 6e-102) tmp = sqrt(((c * -4.0) / a)) * 0.5; else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5.7e-21], N[((-b) / a), $MachinePrecision], If[LessEqual[b, 6e-102], N[(N[Sqrt[N[(N[(c * -4.0), $MachinePrecision] / a), $MachinePrecision]], $MachinePrecision] * 0.5), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5.7 \cdot 10^{-21}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{elif}\;b \leq 6 \cdot 10^{-102}:\\
\;\;\;\;\sqrt{\frac{c \cdot -4}{a}} \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -5.6999999999999996e-21Initial program 52.0%
Taylor expanded in b around -inf
associate-*r/N/A
mul-1-negN/A
lift-neg.f64N/A
lower-/.f6435.1
Applied rewrites35.1%
if -5.6999999999999996e-21 < b < 6e-102Initial program 52.0%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
rem-square-sqrtN/A
lower-sqrt.f64N/A
rem-square-sqrtN/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6417.4
Applied rewrites17.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
lower-*.f6417.4
Applied rewrites17.4%
if 6e-102 < b Initial program 52.0%
Taylor expanded in b around inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6435.6
Applied rewrites35.6%
(FPCore (a b c) :precision binary64 (if (<= b -5.7e-21) (/ (- b) a) (if (<= b 6e-102) (* (sqrt (* (/ c a) -4.0)) 0.5) (/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5.7e-21) {
tmp = -b / a;
} else if (b <= 6e-102) {
tmp = sqrt(((c / a) * -4.0)) * 0.5;
} 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.7d-21)) then
tmp = -b / a
else if (b <= 6d-102) then
tmp = sqrt(((c / a) * (-4.0d0))) * 0.5d0
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.7e-21) {
tmp = -b / a;
} else if (b <= 6e-102) {
tmp = Math.sqrt(((c / a) * -4.0)) * 0.5;
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5.7e-21: tmp = -b / a elif b <= 6e-102: tmp = math.sqrt(((c / a) * -4.0)) * 0.5 else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5.7e-21) tmp = Float64(Float64(-b) / a); elseif (b <= 6e-102) tmp = Float64(sqrt(Float64(Float64(c / a) * -4.0)) * 0.5); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5.7e-21) tmp = -b / a; elseif (b <= 6e-102) tmp = sqrt(((c / a) * -4.0)) * 0.5; else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5.7e-21], N[((-b) / a), $MachinePrecision], If[LessEqual[b, 6e-102], N[(N[Sqrt[N[(N[(c / a), $MachinePrecision] * -4.0), $MachinePrecision]], $MachinePrecision] * 0.5), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5.7 \cdot 10^{-21}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{elif}\;b \leq 6 \cdot 10^{-102}:\\
\;\;\;\;\sqrt{\frac{c}{a} \cdot -4} \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -5.6999999999999996e-21Initial program 52.0%
Taylor expanded in b around -inf
associate-*r/N/A
mul-1-negN/A
lift-neg.f64N/A
lower-/.f6435.1
Applied rewrites35.1%
if -5.6999999999999996e-21 < b < 6e-102Initial program 52.0%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
rem-square-sqrtN/A
lower-sqrt.f64N/A
rem-square-sqrtN/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6417.4
Applied rewrites17.4%
if 6e-102 < b Initial program 52.0%
Taylor expanded in b around inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6435.6
Applied rewrites35.6%
(FPCore (a b c) :precision binary64 (if (<= b -4.4e-163) (/ (- b) a) (if (<= b 2.4e-116) (* -0.5 (sqrt (* (/ c a) -4.0))) (/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4.4e-163) {
tmp = -b / a;
} else if (b <= 2.4e-116) {
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 <= (-4.4d-163)) then
tmp = -b / a
else if (b <= 2.4d-116) 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 <= -4.4e-163) {
tmp = -b / a;
} else if (b <= 2.4e-116) {
tmp = -0.5 * Math.sqrt(((c / a) * -4.0));
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -4.4e-163: tmp = -b / a elif b <= 2.4e-116: 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 <= -4.4e-163) tmp = Float64(Float64(-b) / a); elseif (b <= 2.4e-116) 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 <= -4.4e-163) tmp = -b / a; elseif (b <= 2.4e-116) tmp = -0.5 * sqrt(((c / a) * -4.0)); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -4.4e-163], N[((-b) / a), $MachinePrecision], If[LessEqual[b, 2.4e-116], 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 -4.4 \cdot 10^{-163}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{elif}\;b \leq 2.4 \cdot 10^{-116}:\\
\;\;\;\;-0.5 \cdot \sqrt{\frac{c}{a} \cdot -4}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -4.40000000000000022e-163Initial program 52.0%
Taylor expanded in b around -inf
associate-*r/N/A
mul-1-negN/A
lift-neg.f64N/A
lower-/.f6435.1
Applied rewrites35.1%
if -4.40000000000000022e-163 < b < 2.39999999999999993e-116Initial program 52.0%
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.6
Applied rewrites17.6%
if 2.39999999999999993e-116 < b Initial program 52.0%
Taylor expanded in b around inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6435.6
Applied rewrites35.6%
(FPCore (a b c) :precision binary64 (if (<= b -3.2e-279) (/ (- b) a) (/ (- c) (fabs b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -3.2e-279) {
tmp = -b / a;
} else {
tmp = -c / fabs(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 <= (-3.2d-279)) then
tmp = -b / a
else
tmp = -c / abs(b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -3.2e-279) {
tmp = -b / a;
} else {
tmp = -c / Math.abs(b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -3.2e-279: tmp = -b / a else: tmp = -c / math.fabs(b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -3.2e-279) tmp = Float64(Float64(-b) / a); else tmp = Float64(Float64(-c) / abs(b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -3.2e-279) tmp = -b / a; else tmp = -c / abs(b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -3.2e-279], N[((-b) / a), $MachinePrecision], N[((-c) / N[Abs[b], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.2 \cdot 10^{-279}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{\left|b\right|}\\
\end{array}
\end{array}
if b < -3.1999999999999999e-279Initial program 52.0%
Taylor expanded in b around -inf
associate-*r/N/A
mul-1-negN/A
lift-neg.f64N/A
lower-/.f6435.1
Applied rewrites35.1%
if -3.1999999999999999e-279 < b Initial program 52.0%
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.f6468.4
Applied rewrites68.4%
Taylor expanded in a around inf
mul-1-negN/A
distribute-frac-negN/A
lift-neg.f64N/A
lift-/.f64N/A
lift-fabs.f6436.3
Applied rewrites36.3%
(FPCore (a b c) :precision binary64 (if (<= b 8e-253) (/ (- b) a) (/ (- c) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 8e-253) {
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 <= 8d-253) 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 <= 8e-253) {
tmp = -b / a;
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 8e-253: tmp = -b / a else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 8e-253) 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 <= 8e-253) tmp = -b / a; else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 8e-253], N[((-b) / a), $MachinePrecision], N[((-c) / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 8 \cdot 10^{-253}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < 8.0000000000000005e-253Initial program 52.0%
Taylor expanded in b around -inf
associate-*r/N/A
mul-1-negN/A
lift-neg.f64N/A
lower-/.f6435.1
Applied rewrites35.1%
if 8.0000000000000005e-253 < b Initial program 52.0%
Taylor expanded in b around inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6435.6
Applied rewrites35.6%
(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.0%
Taylor expanded in b around -inf
associate-*r/N/A
mul-1-negN/A
lift-neg.f64N/A
lower-/.f6435.1
Applied rewrites35.1%
herbie shell --seed 2025143
(FPCore (a b c)
:name "Quadratic roots, full range"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))