
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.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) - ((3.0d0 * a) * c)))) / (3.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c)))) / Float64(3.0 * a)) end
function tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a); end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\end{array}
Herbie found 15 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.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) - ((3.0d0 * a) * c)))) / (3.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c)))) / Float64(3.0 * a)) end
function tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a); end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\end{array}
(FPCore (a b c)
:precision binary64
(let* ((t_0
(fma (/ c (fabs b)) -0.5 (* (/ (- (fabs b) b) a) 0.3333333333333333)))
(t_1 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
(t_2 (/ (+ (sqrt (fma (* -3.0 a) c (* b b))) (- b)) (* a 3.0))))
(if (<= t_1 (- INFINITY))
t_0
(if (<= t_1 -5e-306)
t_2
(if (<= t_1 0.0) (* (/ c b) -0.5) (if (<= t_1 1e+226) t_2 t_0))))))
double code(double a, double b, double c) {
double t_0 = fma((c / fabs(b)), -0.5, (((fabs(b) - b) / a) * 0.3333333333333333));
double t_1 = (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
double t_2 = (sqrt(fma((-3.0 * a), c, (b * b))) + -b) / (a * 3.0);
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = t_0;
} else if (t_1 <= -5e-306) {
tmp = t_2;
} else if (t_1 <= 0.0) {
tmp = (c / b) * -0.5;
} else if (t_1 <= 1e+226) {
tmp = t_2;
} else {
tmp = t_0;
}
return tmp;
}
function code(a, b, c) t_0 = fma(Float64(c / abs(b)), -0.5, Float64(Float64(Float64(abs(b) - b) / a) * 0.3333333333333333)) t_1 = Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c)))) / Float64(3.0 * a)) t_2 = Float64(Float64(sqrt(fma(Float64(-3.0 * a), c, Float64(b * b))) + Float64(-b)) / Float64(a * 3.0)) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = t_0; elseif (t_1 <= -5e-306) tmp = t_2; elseif (t_1 <= 0.0) tmp = Float64(Float64(c / b) * -0.5); elseif (t_1 <= 1e+226) tmp = t_2; else tmp = t_0; end return tmp end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(c / N[Abs[b], $MachinePrecision]), $MachinePrecision] * -0.5 + N[(N[(N[(N[Abs[b], $MachinePrecision] - b), $MachinePrecision] / a), $MachinePrecision] * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[Sqrt[N[(N[(-3.0 * a), $MachinePrecision] * c + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + (-b)), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], t$95$0, If[LessEqual[t$95$1, -5e-306], t$95$2, If[LessEqual[t$95$1, 0.0], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision], If[LessEqual[t$95$1, 1e+226], t$95$2, t$95$0]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\frac{c}{\left|b\right|}, -0.5, \frac{\left|b\right| - b}{a} \cdot 0.3333333333333333\right)\\
t_1 := \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\\
t_2 := \frac{\sqrt{\mathsf{fma}\left(-3 \cdot a, c, b \cdot b\right)} + \left(-b\right)}{a \cdot 3}\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_1 \leq -5 \cdot 10^{-306}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 0:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\mathbf{elif}\;t\_1 \leq 10^{+226}:\\
\;\;\;\;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 3 binary64) a) c)))) (*.f64 #s(literal 3 binary64) a)) < -inf.0 or 9.99999999999999961e225 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 3 binary64) a) c)))) (*.f64 #s(literal 3 binary64) a)) Initial program 52.9%
Taylor expanded in c around 0
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
pow2N/A
rem-sqrt-square-revN/A
lower-fabs.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f64N/A
pow2N/A
rem-sqrt-square-revN/A
lower-fabs.f6467.5
Applied rewrites67.5%
if -inf.0 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 3 binary64) a) c)))) (*.f64 #s(literal 3 binary64) a)) < -4.99999999999999998e-306 or -0.0 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 3 binary64) a) c)))) (*.f64 #s(literal 3 binary64) a)) < 9.99999999999999961e225Initial program 52.9%
Applied rewrites52.9%
if -4.99999999999999998e-306 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 3 binary64) a) c)))) (*.f64 #s(literal 3 binary64) a)) < -0.0Initial program 52.9%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f6434.6
Applied rewrites34.6%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (- (sqrt (fma (* -3.0 a) c (* b b))) b))
(t_1
(fma (/ c (fabs b)) -0.5 (* (/ (- (fabs b) b) a) 0.3333333333333333)))
(t_2 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a))))
(if (<= t_2 (- INFINITY))
t_1
(if (<= t_2 -5e-306)
(/ (/ t_0 3.0) a)
(if (<= t_2 0.0)
(* (/ c b) -0.5)
(if (<= t_2 2e+234) (/ (* t_0 0.3333333333333333) a) t_1))))))
double code(double a, double b, double c) {
double t_0 = sqrt(fma((-3.0 * a), c, (b * b))) - b;
double t_1 = fma((c / fabs(b)), -0.5, (((fabs(b) - b) / a) * 0.3333333333333333));
double t_2 = (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = t_1;
} else if (t_2 <= -5e-306) {
tmp = (t_0 / 3.0) / a;
} else if (t_2 <= 0.0) {
tmp = (c / b) * -0.5;
} else if (t_2 <= 2e+234) {
tmp = (t_0 * 0.3333333333333333) / a;
} else {
tmp = t_1;
}
return tmp;
}
function code(a, b, c) t_0 = Float64(sqrt(fma(Float64(-3.0 * a), c, Float64(b * b))) - b) t_1 = fma(Float64(c / abs(b)), -0.5, Float64(Float64(Float64(abs(b) - b) / a) * 0.3333333333333333)) t_2 = Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c)))) / Float64(3.0 * a)) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = t_1; elseif (t_2 <= -5e-306) tmp = Float64(Float64(t_0 / 3.0) / a); elseif (t_2 <= 0.0) tmp = Float64(Float64(c / b) * -0.5); elseif (t_2 <= 2e+234) tmp = Float64(Float64(t_0 * 0.3333333333333333) / a); else tmp = t_1; end return tmp end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[Sqrt[N[(N[(-3.0 * a), $MachinePrecision] * c + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision]}, Block[{t$95$1 = N[(N[(c / N[Abs[b], $MachinePrecision]), $MachinePrecision] * -0.5 + N[(N[(N[(N[Abs[b], $MachinePrecision] - b), $MachinePrecision] / a), $MachinePrecision] * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], t$95$1, If[LessEqual[t$95$2, -5e-306], N[(N[(t$95$0 / 3.0), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[t$95$2, 0.0], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision], If[LessEqual[t$95$2, 2e+234], N[(N[(t$95$0 * 0.3333333333333333), $MachinePrecision] / a), $MachinePrecision], t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\mathsf{fma}\left(-3 \cdot a, c, b \cdot b\right)} - b\\
t_1 := \mathsf{fma}\left(\frac{c}{\left|b\right|}, -0.5, \frac{\left|b\right| - b}{a} \cdot 0.3333333333333333\right)\\
t_2 := \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\\
\mathbf{if}\;t\_2 \leq -\infty:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq -5 \cdot 10^{-306}:\\
\;\;\;\;\frac{\frac{t\_0}{3}}{a}\\
\mathbf{elif}\;t\_2 \leq 0:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{+234}:\\
\;\;\;\;\frac{t\_0 \cdot 0.3333333333333333}{a}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 3 binary64) a) c)))) (*.f64 #s(literal 3 binary64) a)) < -inf.0 or 2.00000000000000004e234 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 3 binary64) a) c)))) (*.f64 #s(literal 3 binary64) a)) Initial program 52.9%
Taylor expanded in c around 0
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
pow2N/A
rem-sqrt-square-revN/A
lower-fabs.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f64N/A
pow2N/A
rem-sqrt-square-revN/A
lower-fabs.f6467.5
Applied rewrites67.5%
if -inf.0 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 3 binary64) a) c)))) (*.f64 #s(literal 3 binary64) a)) < -4.99999999999999998e-306Initial program 52.9%
lift-*.f64N/A
lift-/.f64N/A
lift-+.f64N/A
lift-neg.f64N/A
lift-sqrt.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites52.9%
lift-+.f64N/A
lift-sqrt.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
lift-neg.f64N/A
sub-flip-reverseN/A
lower--.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-sqrt.f6452.9
Applied rewrites52.9%
if -4.99999999999999998e-306 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 3 binary64) a) c)))) (*.f64 #s(literal 3 binary64) a)) < -0.0Initial program 52.9%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f6434.6
Applied rewrites34.6%
if -0.0 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 3 binary64) a) c)))) (*.f64 #s(literal 3 binary64) a)) < 2.00000000000000004e234Initial program 52.9%
lift-*.f64N/A
lift-/.f64N/A
lift-+.f64N/A
lift-neg.f64N/A
lift-sqrt.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites52.9%
Applied rewrites52.8%
(FPCore (a b c)
:precision binary64
(let* ((t_0
(fma (/ c (fabs b)) -0.5 (* (/ (- (fabs b) b) a) 0.3333333333333333)))
(t_1 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
(t_2
(/ (* (- (sqrt (fma (* -3.0 a) c (* b b))) b) 0.3333333333333333) a)))
(if (<= t_1 (- INFINITY))
t_0
(if (<= t_1 -5e-306)
t_2
(if (<= t_1 0.0) (* (/ c b) -0.5) (if (<= t_1 2e+234) t_2 t_0))))))
double code(double a, double b, double c) {
double t_0 = fma((c / fabs(b)), -0.5, (((fabs(b) - b) / a) * 0.3333333333333333));
double t_1 = (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
double t_2 = ((sqrt(fma((-3.0 * a), c, (b * b))) - b) * 0.3333333333333333) / a;
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = t_0;
} else if (t_1 <= -5e-306) {
tmp = t_2;
} else if (t_1 <= 0.0) {
tmp = (c / b) * -0.5;
} else if (t_1 <= 2e+234) {
tmp = t_2;
} else {
tmp = t_0;
}
return tmp;
}
function code(a, b, c) t_0 = fma(Float64(c / abs(b)), -0.5, Float64(Float64(Float64(abs(b) - b) / a) * 0.3333333333333333)) t_1 = Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c)))) / Float64(3.0 * a)) t_2 = Float64(Float64(Float64(sqrt(fma(Float64(-3.0 * a), c, Float64(b * b))) - b) * 0.3333333333333333) / a) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = t_0; elseif (t_1 <= -5e-306) tmp = t_2; elseif (t_1 <= 0.0) tmp = Float64(Float64(c / b) * -0.5); elseif (t_1 <= 2e+234) tmp = t_2; else tmp = t_0; end return tmp end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(c / N[Abs[b], $MachinePrecision]), $MachinePrecision] * -0.5 + N[(N[(N[(N[Abs[b], $MachinePrecision] - b), $MachinePrecision] / a), $MachinePrecision] * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(N[Sqrt[N[(N[(-3.0 * a), $MachinePrecision] * c + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] * 0.3333333333333333), $MachinePrecision] / a), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], t$95$0, If[LessEqual[t$95$1, -5e-306], t$95$2, If[LessEqual[t$95$1, 0.0], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision], If[LessEqual[t$95$1, 2e+234], t$95$2, t$95$0]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\frac{c}{\left|b\right|}, -0.5, \frac{\left|b\right| - b}{a} \cdot 0.3333333333333333\right)\\
t_1 := \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\\
t_2 := \frac{\left(\sqrt{\mathsf{fma}\left(-3 \cdot a, c, b \cdot b\right)} - b\right) \cdot 0.3333333333333333}{a}\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_1 \leq -5 \cdot 10^{-306}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 0:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+234}:\\
\;\;\;\;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 3 binary64) a) c)))) (*.f64 #s(literal 3 binary64) a)) < -inf.0 or 2.00000000000000004e234 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 3 binary64) a) c)))) (*.f64 #s(literal 3 binary64) a)) Initial program 52.9%
Taylor expanded in c around 0
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
pow2N/A
rem-sqrt-square-revN/A
lower-fabs.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f64N/A
pow2N/A
rem-sqrt-square-revN/A
lower-fabs.f6467.5
Applied rewrites67.5%
if -inf.0 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 3 binary64) a) c)))) (*.f64 #s(literal 3 binary64) a)) < -4.99999999999999998e-306 or -0.0 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 3 binary64) a) c)))) (*.f64 #s(literal 3 binary64) a)) < 2.00000000000000004e234Initial program 52.9%
lift-*.f64N/A
lift-/.f64N/A
lift-+.f64N/A
lift-neg.f64N/A
lift-sqrt.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites52.9%
Applied rewrites52.8%
if -4.99999999999999998e-306 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 3 binary64) a) c)))) (*.f64 #s(literal 3 binary64) a)) < -0.0Initial program 52.9%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f6434.6
Applied rewrites34.6%
(FPCore (a b c)
:precision binary64
(let* ((t_0
(fma
(/ c (fabs b))
-0.5
(* (/ (- (fabs b) b) a) 0.3333333333333333))))
(if (<= b -3.5e-62)
t_0
(if (<= b 6.6e-76) (/ (+ (- b) (sqrt (* -3.0 (* c a)))) (* 3.0 a)) t_0))))
double code(double a, double b, double c) {
double t_0 = fma((c / fabs(b)), -0.5, (((fabs(b) - b) / a) * 0.3333333333333333));
double tmp;
if (b <= -3.5e-62) {
tmp = t_0;
} else if (b <= 6.6e-76) {
tmp = (-b + sqrt((-3.0 * (c * a)))) / (3.0 * a);
} else {
tmp = t_0;
}
return tmp;
}
function code(a, b, c) t_0 = fma(Float64(c / abs(b)), -0.5, Float64(Float64(Float64(abs(b) - b) / a) * 0.3333333333333333)) tmp = 0.0 if (b <= -3.5e-62) tmp = t_0; elseif (b <= 6.6e-76) tmp = Float64(Float64(Float64(-b) + sqrt(Float64(-3.0 * Float64(c * a)))) / Float64(3.0 * a)); else tmp = t_0; end return tmp end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(c / N[Abs[b], $MachinePrecision]), $MachinePrecision] * -0.5 + N[(N[(N[(N[Abs[b], $MachinePrecision] - b), $MachinePrecision] / a), $MachinePrecision] * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -3.5e-62], t$95$0, If[LessEqual[b, 6.6e-76], N[(N[((-b) + N[Sqrt[N[(-3.0 * N[(c * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\frac{c}{\left|b\right|}, -0.5, \frac{\left|b\right| - b}{a} \cdot 0.3333333333333333\right)\\
\mathbf{if}\;b \leq -3.5 \cdot 10^{-62}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq 6.6 \cdot 10^{-76}:\\
\;\;\;\;\frac{\left(-b\right) + \sqrt{-3 \cdot \left(c \cdot a\right)}}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if b < -3.5000000000000001e-62 or 6.59999999999999967e-76 < b Initial program 52.9%
Taylor expanded in c around 0
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
pow2N/A
rem-sqrt-square-revN/A
lower-fabs.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f64N/A
pow2N/A
rem-sqrt-square-revN/A
lower-fabs.f6467.5
Applied rewrites67.5%
if -3.5000000000000001e-62 < b < 6.59999999999999967e-76Initial program 52.9%
Taylor expanded in a around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f6434.0
Applied rewrites34.0%
(FPCore (a b c)
:precision binary64
(if (<= b -3.5e-62)
(/ (* -2.0 b) (* 3.0 a))
(if (<= b 6.6e-76)
(/ (+ (- b) (sqrt (* -3.0 (* c a)))) (* 3.0 a))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -3.5e-62) {
tmp = (-2.0 * b) / (3.0 * a);
} else if (b <= 6.6e-76) {
tmp = (-b + sqrt((-3.0 * (c * a)))) / (3.0 * a);
} else {
tmp = (c / b) * -0.5;
}
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.5d-62)) then
tmp = ((-2.0d0) * b) / (3.0d0 * a)
else if (b <= 6.6d-76) then
tmp = (-b + sqrt(((-3.0d0) * (c * a)))) / (3.0d0 * a)
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -3.5e-62) {
tmp = (-2.0 * b) / (3.0 * a);
} else if (b <= 6.6e-76) {
tmp = (-b + Math.sqrt((-3.0 * (c * a)))) / (3.0 * a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -3.5e-62: tmp = (-2.0 * b) / (3.0 * a) elif b <= 6.6e-76: tmp = (-b + math.sqrt((-3.0 * (c * a)))) / (3.0 * a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -3.5e-62) tmp = Float64(Float64(-2.0 * b) / Float64(3.0 * a)); elseif (b <= 6.6e-76) tmp = Float64(Float64(Float64(-b) + sqrt(Float64(-3.0 * Float64(c * a)))) / Float64(3.0 * a)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -3.5e-62) tmp = (-2.0 * b) / (3.0 * a); elseif (b <= 6.6e-76) tmp = (-b + sqrt((-3.0 * (c * a)))) / (3.0 * a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -3.5e-62], N[(N[(-2.0 * b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 6.6e-76], N[(N[((-b) + N[Sqrt[N[(-3.0 * N[(c * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.5 \cdot 10^{-62}:\\
\;\;\;\;\frac{-2 \cdot b}{3 \cdot a}\\
\mathbf{elif}\;b \leq 6.6 \cdot 10^{-76}:\\
\;\;\;\;\frac{\left(-b\right) + \sqrt{-3 \cdot \left(c \cdot a\right)}}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -3.5000000000000001e-62Initial program 52.9%
Taylor expanded in b around -inf
lower-*.f6435.2
Applied rewrites35.2%
if -3.5000000000000001e-62 < b < 6.59999999999999967e-76Initial program 52.9%
Taylor expanded in a around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f6434.0
Applied rewrites34.0%
if 6.59999999999999967e-76 < b Initial program 52.9%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f6434.6
Applied rewrites34.6%
(FPCore (a b c) :precision binary64 (if (<= b -3.5e-62) (/ (* -2.0 b) (* 3.0 a)) (if (<= b 6.6e-76) (/ (sqrt (* (* -3.0 a) c)) (* 3.0 a)) (* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -3.5e-62) {
tmp = (-2.0 * b) / (3.0 * a);
} else if (b <= 6.6e-76) {
tmp = sqrt(((-3.0 * a) * c)) / (3.0 * a);
} else {
tmp = (c / b) * -0.5;
}
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.5d-62)) then
tmp = ((-2.0d0) * b) / (3.0d0 * a)
else if (b <= 6.6d-76) then
tmp = sqrt((((-3.0d0) * a) * c)) / (3.0d0 * a)
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -3.5e-62) {
tmp = (-2.0 * b) / (3.0 * a);
} else if (b <= 6.6e-76) {
tmp = Math.sqrt(((-3.0 * a) * c)) / (3.0 * a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -3.5e-62: tmp = (-2.0 * b) / (3.0 * a) elif b <= 6.6e-76: tmp = math.sqrt(((-3.0 * a) * c)) / (3.0 * a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -3.5e-62) tmp = Float64(Float64(-2.0 * b) / Float64(3.0 * a)); elseif (b <= 6.6e-76) tmp = Float64(sqrt(Float64(Float64(-3.0 * a) * c)) / Float64(3.0 * a)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -3.5e-62) tmp = (-2.0 * b) / (3.0 * a); elseif (b <= 6.6e-76) tmp = sqrt(((-3.0 * a) * c)) / (3.0 * a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -3.5e-62], N[(N[(-2.0 * b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 6.6e-76], N[(N[Sqrt[N[(N[(-3.0 * a), $MachinePrecision] * c), $MachinePrecision]], $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.5 \cdot 10^{-62}:\\
\;\;\;\;\frac{-2 \cdot b}{3 \cdot a}\\
\mathbf{elif}\;b \leq 6.6 \cdot 10^{-76}:\\
\;\;\;\;\frac{\sqrt{\left(-3 \cdot a\right) \cdot c}}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -3.5000000000000001e-62Initial program 52.9%
Taylor expanded in b around -inf
lower-*.f6435.2
Applied rewrites35.2%
if -3.5000000000000001e-62 < b < 6.59999999999999967e-76Initial program 52.9%
Taylor expanded in b around 0
distribute-lft-neg-inN/A
metadata-evalN/A
lower-sqrt.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6429.6
Applied rewrites29.6%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6429.7
Applied rewrites29.7%
if 6.59999999999999967e-76 < b Initial program 52.9%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f6434.6
Applied rewrites34.6%
(FPCore (a b c)
:precision binary64
(if (<= b -3.5e-62)
(/ (* -2.0 b) (* 3.0 a))
(if (<= b 6.6e-76)
(* (/ (sqrt (* -3.0 (* c a))) a) 0.3333333333333333)
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -3.5e-62) {
tmp = (-2.0 * b) / (3.0 * a);
} else if (b <= 6.6e-76) {
tmp = (sqrt((-3.0 * (c * a))) / a) * 0.3333333333333333;
} else {
tmp = (c / b) * -0.5;
}
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.5d-62)) then
tmp = ((-2.0d0) * b) / (3.0d0 * a)
else if (b <= 6.6d-76) then
tmp = (sqrt(((-3.0d0) * (c * a))) / a) * 0.3333333333333333d0
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -3.5e-62) {
tmp = (-2.0 * b) / (3.0 * a);
} else if (b <= 6.6e-76) {
tmp = (Math.sqrt((-3.0 * (c * a))) / a) * 0.3333333333333333;
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -3.5e-62: tmp = (-2.0 * b) / (3.0 * a) elif b <= 6.6e-76: tmp = (math.sqrt((-3.0 * (c * a))) / a) * 0.3333333333333333 else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -3.5e-62) tmp = Float64(Float64(-2.0 * b) / Float64(3.0 * a)); elseif (b <= 6.6e-76) tmp = Float64(Float64(sqrt(Float64(-3.0 * Float64(c * a))) / a) * 0.3333333333333333); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -3.5e-62) tmp = (-2.0 * b) / (3.0 * a); elseif (b <= 6.6e-76) tmp = (sqrt((-3.0 * (c * a))) / a) * 0.3333333333333333; else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -3.5e-62], N[(N[(-2.0 * b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 6.6e-76], N[(N[(N[Sqrt[N[(-3.0 * N[(c * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / a), $MachinePrecision] * 0.3333333333333333), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.5 \cdot 10^{-62}:\\
\;\;\;\;\frac{-2 \cdot b}{3 \cdot a}\\
\mathbf{elif}\;b \leq 6.6 \cdot 10^{-76}:\\
\;\;\;\;\frac{\sqrt{-3 \cdot \left(c \cdot a\right)}}{a} \cdot 0.3333333333333333\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -3.5000000000000001e-62Initial program 52.9%
Taylor expanded in b around -inf
lower-*.f6435.2
Applied rewrites35.2%
if -3.5000000000000001e-62 < b < 6.59999999999999967e-76Initial program 52.9%
Taylor expanded in b around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-sqrt.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6429.6
Applied rewrites29.6%
if 6.59999999999999967e-76 < b Initial program 52.9%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f6434.6
Applied rewrites34.6%
(FPCore (a b c)
:precision binary64
(if (<= b -3.5e-62)
(/ (* -2.0 b) (* 3.0 a))
(if (<= b 6.6e-76)
(* (* -0.3333333333333333 c) (sqrt (/ -3.0 (* c a))))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -3.5e-62) {
tmp = (-2.0 * b) / (3.0 * a);
} else if (b <= 6.6e-76) {
tmp = (-0.3333333333333333 * c) * sqrt((-3.0 / (c * a)));
} else {
tmp = (c / b) * -0.5;
}
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.5d-62)) then
tmp = ((-2.0d0) * b) / (3.0d0 * a)
else if (b <= 6.6d-76) then
tmp = ((-0.3333333333333333d0) * c) * sqrt(((-3.0d0) / (c * a)))
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -3.5e-62) {
tmp = (-2.0 * b) / (3.0 * a);
} else if (b <= 6.6e-76) {
tmp = (-0.3333333333333333 * c) * Math.sqrt((-3.0 / (c * a)));
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -3.5e-62: tmp = (-2.0 * b) / (3.0 * a) elif b <= 6.6e-76: tmp = (-0.3333333333333333 * c) * math.sqrt((-3.0 / (c * a))) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -3.5e-62) tmp = Float64(Float64(-2.0 * b) / Float64(3.0 * a)); elseif (b <= 6.6e-76) tmp = Float64(Float64(-0.3333333333333333 * c) * sqrt(Float64(-3.0 / Float64(c * a)))); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -3.5e-62) tmp = (-2.0 * b) / (3.0 * a); elseif (b <= 6.6e-76) tmp = (-0.3333333333333333 * c) * sqrt((-3.0 / (c * a))); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -3.5e-62], N[(N[(-2.0 * b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 6.6e-76], N[(N[(-0.3333333333333333 * c), $MachinePrecision] * N[Sqrt[N[(-3.0 / N[(c * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.5 \cdot 10^{-62}:\\
\;\;\;\;\frac{-2 \cdot b}{3 \cdot a}\\
\mathbf{elif}\;b \leq 6.6 \cdot 10^{-76}:\\
\;\;\;\;\left(-0.3333333333333333 \cdot c\right) \cdot \sqrt{\frac{-3}{c \cdot a}}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -3.5000000000000001e-62Initial program 52.9%
Taylor expanded in b around -inf
lower-*.f6435.2
Applied rewrites35.2%
if -3.5000000000000001e-62 < b < 6.59999999999999967e-76Initial program 52.9%
Taylor expanded in a around -inf
distribute-lft-outN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
rem-square-sqrtN/A
lower-sqrt.f64N/A
rem-square-sqrtN/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6420.1
Applied rewrites20.1%
Taylor expanded in c around inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lift-*.f6428.2
Applied rewrites28.2%
if 6.59999999999999967e-76 < b Initial program 52.9%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f6434.6
Applied rewrites34.6%
(FPCore (a b c)
:precision binary64
(if (<= b -1.1e-161)
(/ (/ (* -2.0 b) 3.0) a)
(if (<= b 2.05e-169)
(* -0.3333333333333333 (sqrt (* (/ c a) -3.0)))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.1e-161) {
tmp = ((-2.0 * b) / 3.0) / a;
} else if (b <= 2.05e-169) {
tmp = -0.3333333333333333 * sqrt(((c / a) * -3.0));
} else {
tmp = (c / b) * -0.5;
}
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.1d-161)) then
tmp = (((-2.0d0) * b) / 3.0d0) / a
else if (b <= 2.05d-169) then
tmp = (-0.3333333333333333d0) * sqrt(((c / a) * (-3.0d0)))
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1.1e-161) {
tmp = ((-2.0 * b) / 3.0) / a;
} else if (b <= 2.05e-169) {
tmp = -0.3333333333333333 * Math.sqrt(((c / a) * -3.0));
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.1e-161: tmp = ((-2.0 * b) / 3.0) / a elif b <= 2.05e-169: tmp = -0.3333333333333333 * math.sqrt(((c / a) * -3.0)) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.1e-161) tmp = Float64(Float64(Float64(-2.0 * b) / 3.0) / a); elseif (b <= 2.05e-169) tmp = Float64(-0.3333333333333333 * sqrt(Float64(Float64(c / a) * -3.0))); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.1e-161) tmp = ((-2.0 * b) / 3.0) / a; elseif (b <= 2.05e-169) tmp = -0.3333333333333333 * sqrt(((c / a) * -3.0)); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.1e-161], N[(N[(N[(-2.0 * b), $MachinePrecision] / 3.0), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 2.05e-169], N[(-0.3333333333333333 * N[Sqrt[N[(N[(c / a), $MachinePrecision] * -3.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.1 \cdot 10^{-161}:\\
\;\;\;\;\frac{\frac{-2 \cdot b}{3}}{a}\\
\mathbf{elif}\;b \leq 2.05 \cdot 10^{-169}:\\
\;\;\;\;-0.3333333333333333 \cdot \sqrt{\frac{c}{a} \cdot -3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -1.10000000000000001e-161Initial program 52.9%
lift-*.f64N/A
lift-/.f64N/A
lift-+.f64N/A
lift-neg.f64N/A
lift-sqrt.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites52.9%
Taylor expanded in b around -inf
lower-*.f6435.2
Applied rewrites35.2%
if -1.10000000000000001e-161 < b < 2.0499999999999999e-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.0499999999999999e-169 < b Initial program 52.9%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f6434.6
Applied rewrites34.6%
(FPCore (a b c) :precision binary64 (if (<= b 1.7e-307) (/ (- (fabs b) b) (* 3.0 a)) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.7e-307) {
tmp = (fabs(b) - b) / (3.0 * a);
} else {
tmp = (c / b) * -0.5;
}
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.7d-307) then
tmp = (abs(b) - b) / (3.0d0 * a)
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 1.7e-307) {
tmp = (Math.abs(b) - b) / (3.0 * a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.7e-307: tmp = (math.fabs(b) - b) / (3.0 * a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.7e-307) tmp = Float64(Float64(abs(b) - b) / Float64(3.0 * a)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 1.7e-307) tmp = (abs(b) - b) / (3.0 * a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.7e-307], N[(N[(N[Abs[b], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.7 \cdot 10^{-307}:\\
\;\;\;\;\frac{\left|b\right| - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < 1.69999999999999994e-307Initial program 52.9%
Taylor expanded in a around 0
lower--.f64N/A
pow2N/A
rem-sqrt-square-revN/A
lower-fabs.f6444.1
Applied rewrites44.1%
if 1.69999999999999994e-307 < b Initial program 52.9%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f6434.6
Applied rewrites34.6%
(FPCore (a b c) :precision binary64 (if (<= b 2.9e-308) (/ (* -2.0 b) (* 3.0 a)) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= 2.9e-308) {
tmp = (-2.0 * b) / (3.0 * a);
} else {
tmp = (c / b) * -0.5;
}
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 = ((-2.0d0) * b) / (3.0d0 * a)
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 2.9e-308) {
tmp = (-2.0 * b) / (3.0 * a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2.9e-308: tmp = (-2.0 * b) / (3.0 * a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2.9e-308) tmp = Float64(Float64(-2.0 * b) / Float64(3.0 * a)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 2.9e-308) tmp = (-2.0 * b) / (3.0 * a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2.9e-308], N[(N[(-2.0 * b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.9 \cdot 10^{-308}:\\
\;\;\;\;\frac{-2 \cdot b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < 2.9e-308Initial program 52.9%
Taylor expanded in b around -inf
lower-*.f6435.2
Applied rewrites35.2%
if 2.9e-308 < b Initial program 52.9%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f6434.6
Applied rewrites34.6%
(FPCore (a b c) :precision binary64 (if (<= b 2.9e-308) (/ (* -0.6666666666666666 b) a) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= 2.9e-308) {
tmp = (-0.6666666666666666 * b) / a;
} else {
tmp = (c / b) * -0.5;
}
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 = ((-0.6666666666666666d0) * b) / a
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 2.9e-308) {
tmp = (-0.6666666666666666 * b) / a;
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2.9e-308: tmp = (-0.6666666666666666 * b) / a else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2.9e-308) tmp = Float64(Float64(-0.6666666666666666 * b) / a); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 2.9e-308) tmp = (-0.6666666666666666 * b) / a; else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2.9e-308], N[(N[(-0.6666666666666666 * b), $MachinePrecision] / a), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.9 \cdot 10^{-308}:\\
\;\;\;\;\frac{-0.6666666666666666 \cdot b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < 2.9e-308Initial program 52.9%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6435.2
Applied rewrites35.2%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f6435.2
Applied rewrites35.2%
if 2.9e-308 < b Initial program 52.9%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f6434.6
Applied rewrites34.6%
(FPCore (a b c) :precision binary64 (if (<= b 2.9e-308) (* -0.6666666666666666 (/ b a)) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= 2.9e-308) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = (c / b) * -0.5;
}
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 = (-0.6666666666666666d0) * (b / a)
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 2.9e-308) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2.9e-308: tmp = -0.6666666666666666 * (b / a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2.9e-308) tmp = Float64(-0.6666666666666666 * Float64(b / a)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 2.9e-308) tmp = -0.6666666666666666 * (b / a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2.9e-308], N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.9 \cdot 10^{-308}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < 2.9e-308Initial program 52.9%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6435.2
Applied rewrites35.2%
if 2.9e-308 < b Initial program 52.9%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f6434.6
Applied rewrites34.6%
(FPCore (a b c) :precision binary64 (* -0.6666666666666666 (/ b a)))
double code(double a, double b, double c) {
return -0.6666666666666666 * (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 = (-0.6666666666666666d0) * (b / a)
end function
public static double code(double a, double b, double c) {
return -0.6666666666666666 * (b / a);
}
def code(a, b, c): return -0.6666666666666666 * (b / a)
function code(a, b, c) return Float64(-0.6666666666666666 * Float64(b / a)) end
function tmp = code(a, b, c) tmp = -0.6666666666666666 * (b / a); end
code[a_, b_, c_] := N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-0.6666666666666666 \cdot \frac{b}{a}
\end{array}
Initial program 52.9%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6435.2
Applied rewrites35.2%
(FPCore (a b c) :precision binary64 (* -0.3333333333333333 (/ b a)))
double code(double a, double b, double c) {
return -0.3333333333333333 * (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 = (-0.3333333333333333d0) * (b / a)
end function
public static double code(double a, double b, double c) {
return -0.3333333333333333 * (b / a);
}
def code(a, b, c): return -0.3333333333333333 * (b / a)
function code(a, b, c) return Float64(-0.3333333333333333 * Float64(b / a)) end
function tmp = code(a, b, c) tmp = -0.3333333333333333 * (b / a); end
code[a_, b_, c_] := N[(-0.3333333333333333 * N[(b / a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-0.3333333333333333 \cdot \frac{b}{a}
\end{array}
Initial program 52.9%
Taylor expanded in c around 0
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
pow2N/A
rem-sqrt-square-revN/A
lower-fabs.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f64N/A
pow2N/A
rem-sqrt-square-revN/A
lower-fabs.f6467.5
Applied rewrites67.5%
Taylor expanded in b around inf
lower-*.f64N/A
lift-/.f6415.5
Applied rewrites15.5%
herbie shell --seed 2025139
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))