
(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]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
Herbie found 18 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]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
(FPCore (a b c)
:precision binary64
(if (<= b -2.7e+97)
(/ (* -2.0 b) (* 3.0 a))
(if (<= b 5.6e-126)
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a))
(* -0.5 (/ c b)))))double code(double a, double b, double c) {
double tmp;
if (b <= -2.7e+97) {
tmp = (-2.0 * b) / (3.0 * a);
} else if (b <= 5.6e-126) {
tmp = (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-2.7d+97)) then
tmp = ((-2.0d0) * b) / (3.0d0 * a)
else if (b <= 5.6d-126) then
tmp = (-b + sqrt(((b * b) - ((3.0d0 * a) * c)))) / (3.0d0 * a)
else
tmp = (-0.5d0) * (c / b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -2.7e+97) {
tmp = (-2.0 * b) / (3.0 * a);
} else if (b <= 5.6e-126) {
tmp = (-b + Math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.7e+97: tmp = (-2.0 * b) / (3.0 * a) elif b <= 5.6e-126: tmp = (-b + math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.7e+97) tmp = Float64(Float64(-2.0 * b) / Float64(3.0 * a)); elseif (b <= 5.6e-126) tmp = Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c)))) / Float64(3.0 * a)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2.7e+97) tmp = (-2.0 * b) / (3.0 * a); elseif (b <= 5.6e-126) tmp = (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.7e+97], N[(N[(-2.0 * b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 5.6e-126], 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], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;b \leq -2.7 \cdot 10^{+97}:\\
\;\;\;\;\frac{-2 \cdot b}{3 \cdot a}\\
\mathbf{elif}\;b \leq 5.6 \cdot 10^{-126}:\\
\;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
if b < -2.69999999999999993e97Initial program 52.1%
Taylor expanded in b around -inf
lower-*.f6436.0%
Applied rewrites36.0%
if -2.69999999999999993e97 < b < 5.59999999999999983e-126Initial program 52.1%
if 5.59999999999999983e-126 < b Initial program 52.1%
Taylor expanded in b around inf
lower-*.f64N/A
lower-/.f6433.9%
Applied rewrites33.9%
(FPCore (a b c)
:precision binary64
(if (<= b -2.7e+97)
(/ (* -2.0 b) (* 3.0 a))
(if (<= b 5.6e-126)
(/ (+ (- b) (sqrt (fma (* c a) -3.0 (* b b)))) (* 3.0 a))
(* -0.5 (/ c b)))))double code(double a, double b, double c) {
double tmp;
if (b <= -2.7e+97) {
tmp = (-2.0 * b) / (3.0 * a);
} else if (b <= 5.6e-126) {
tmp = (-b + sqrt(fma((c * a), -3.0, (b * b)))) / (3.0 * a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -2.7e+97) tmp = Float64(Float64(-2.0 * b) / Float64(3.0 * a)); elseif (b <= 5.6e-126) tmp = Float64(Float64(Float64(-b) + sqrt(fma(Float64(c * a), -3.0, Float64(b * b)))) / Float64(3.0 * a)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -2.7e+97], N[(N[(-2.0 * b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 5.6e-126], N[(N[((-b) + N[Sqrt[N[(N[(c * a), $MachinePrecision] * -3.0 + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;b \leq -2.7 \cdot 10^{+97}:\\
\;\;\;\;\frac{-2 \cdot b}{3 \cdot a}\\
\mathbf{elif}\;b \leq 5.6 \cdot 10^{-126}:\\
\;\;\;\;\frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(c \cdot a, -3, b \cdot b\right)}}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
if b < -2.69999999999999993e97Initial program 52.1%
Taylor expanded in b around -inf
lower-*.f6436.0%
Applied rewrites36.0%
if -2.69999999999999993e97 < b < 5.59999999999999983e-126Initial program 52.1%
lift--.f64N/A
sub-negate-revN/A
sub-flipN/A
distribute-neg-inN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lift-*.f64N/A
sqr-abs-revN/A
distribute-rgt-neg-inN/A
distribute-lft-neg-outN/A
sqr-neg-revN/A
sqr-abs-revN/A
lift-*.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
metadata-eval52.1%
Applied rewrites52.1%
if 5.59999999999999983e-126 < b Initial program 52.1%
Taylor expanded in b around inf
lower-*.f64N/A
lower-/.f6433.9%
Applied rewrites33.9%
(FPCore (a b c)
:precision binary64
(if (<= b -2.7e+97)
(/ (* -2.0 b) (* 3.0 a))
(if (<= b 5.6e-126)
(/ (/ (- (sqrt (fma (* c -3.0) a (* b b))) b) a) 3.0)
(* -0.5 (/ c b)))))double code(double a, double b, double c) {
double tmp;
if (b <= -2.7e+97) {
tmp = (-2.0 * b) / (3.0 * a);
} else if (b <= 5.6e-126) {
tmp = ((sqrt(fma((c * -3.0), a, (b * b))) - b) / a) / 3.0;
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -2.7e+97) tmp = Float64(Float64(-2.0 * b) / Float64(3.0 * a)); elseif (b <= 5.6e-126) tmp = Float64(Float64(Float64(sqrt(fma(Float64(c * -3.0), a, Float64(b * b))) - b) / a) / 3.0); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -2.7e+97], N[(N[(-2.0 * b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 5.6e-126], N[(N[(N[(N[Sqrt[N[(N[(c * -3.0), $MachinePrecision] * a + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / a), $MachinePrecision] / 3.0), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;b \leq -2.7 \cdot 10^{+97}:\\
\;\;\;\;\frac{-2 \cdot b}{3 \cdot a}\\
\mathbf{elif}\;b \leq 5.6 \cdot 10^{-126}:\\
\;\;\;\;\frac{\frac{\sqrt{\mathsf{fma}\left(c \cdot -3, a, b \cdot b\right)} - b}{a}}{3}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
if b < -2.69999999999999993e97Initial program 52.1%
Taylor expanded in b around -inf
lower-*.f6436.0%
Applied rewrites36.0%
if -2.69999999999999993e97 < b < 5.59999999999999983e-126Initial program 52.1%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites52.1%
if 5.59999999999999983e-126 < b Initial program 52.1%
Taylor expanded in b around inf
lower-*.f64N/A
lower-/.f6433.9%
Applied rewrites33.9%
(FPCore (a b c)
:precision binary64
(if (<= b -2.7e+97)
(/ (* -2.0 b) (* 3.0 a))
(if (<= b 5.6e-126)
(/ (- (sqrt (fma (* c -3.0) a (* b b))) b) (* a 3.0))
(* -0.5 (/ c b)))))double code(double a, double b, double c) {
double tmp;
if (b <= -2.7e+97) {
tmp = (-2.0 * b) / (3.0 * a);
} else if (b <= 5.6e-126) {
tmp = (sqrt(fma((c * -3.0), a, (b * b))) - b) / (a * 3.0);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -2.7e+97) tmp = Float64(Float64(-2.0 * b) / Float64(3.0 * a)); elseif (b <= 5.6e-126) tmp = Float64(Float64(sqrt(fma(Float64(c * -3.0), a, Float64(b * b))) - b) / Float64(a * 3.0)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -2.7e+97], N[(N[(-2.0 * b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 5.6e-126], N[(N[(N[Sqrt[N[(N[(c * -3.0), $MachinePrecision] * a + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;b \leq -2.7 \cdot 10^{+97}:\\
\;\;\;\;\frac{-2 \cdot b}{3 \cdot a}\\
\mathbf{elif}\;b \leq 5.6 \cdot 10^{-126}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(c \cdot -3, a, b \cdot b\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
if b < -2.69999999999999993e97Initial program 52.1%
Taylor expanded in b around -inf
lower-*.f6436.0%
Applied rewrites36.0%
if -2.69999999999999993e97 < b < 5.59999999999999983e-126Initial program 52.1%
Applied rewrites52.1%
if 5.59999999999999983e-126 < b Initial program 52.1%
Taylor expanded in b around inf
lower-*.f64N/A
lower-/.f6433.9%
Applied rewrites33.9%
(FPCore (a b c)
:precision binary64
(if (<= b -6.5e+116)
(/ (* -2.0 b) (* 3.0 a))
(if (<= b 5.6e-126)
(/ (* (- b (sqrt (fma (* c -3.0) a (* b b)))) -0.3333333333333333) a)
(* -0.5 (/ c b)))))double code(double a, double b, double c) {
double tmp;
if (b <= -6.5e+116) {
tmp = (-2.0 * b) / (3.0 * a);
} else if (b <= 5.6e-126) {
tmp = ((b - sqrt(fma((c * -3.0), a, (b * b)))) * -0.3333333333333333) / a;
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -6.5e+116) tmp = Float64(Float64(-2.0 * b) / Float64(3.0 * a)); elseif (b <= 5.6e-126) tmp = Float64(Float64(Float64(b - sqrt(fma(Float64(c * -3.0), a, Float64(b * b)))) * -0.3333333333333333) / a); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -6.5e+116], N[(N[(-2.0 * b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 5.6e-126], N[(N[(N[(b - N[Sqrt[N[(N[(c * -3.0), $MachinePrecision] * a + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * -0.3333333333333333), $MachinePrecision] / a), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;b \leq -6.5 \cdot 10^{+116}:\\
\;\;\;\;\frac{-2 \cdot b}{3 \cdot a}\\
\mathbf{elif}\;b \leq 5.6 \cdot 10^{-126}:\\
\;\;\;\;\frac{\left(b - \sqrt{\mathsf{fma}\left(c \cdot -3, a, b \cdot b\right)}\right) \cdot -0.3333333333333333}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
if b < -6.4999999999999998e116Initial program 52.1%
Taylor expanded in b around -inf
lower-*.f6436.0%
Applied rewrites36.0%
if -6.4999999999999998e116 < b < 5.59999999999999983e-126Initial program 52.1%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites52.1%
if 5.59999999999999983e-126 < b Initial program 52.1%
Taylor expanded in b around inf
lower-*.f64N/A
lower-/.f6433.9%
Applied rewrites33.9%
(FPCore (a b c)
:precision binary64
(if (<= b -2.7e+97)
(/ (* -2.0 b) (* 3.0 a))
(if (<= b 5.6e-126)
(* (/ (- (sqrt (fma (* c -3.0) a (* b b))) b) a) 0.3333333333333333)
(* -0.5 (/ c b)))))double code(double a, double b, double c) {
double tmp;
if (b <= -2.7e+97) {
tmp = (-2.0 * b) / (3.0 * a);
} else if (b <= 5.6e-126) {
tmp = ((sqrt(fma((c * -3.0), a, (b * b))) - b) / a) * 0.3333333333333333;
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -2.7e+97) tmp = Float64(Float64(-2.0 * b) / Float64(3.0 * a)); elseif (b <= 5.6e-126) tmp = Float64(Float64(Float64(sqrt(fma(Float64(c * -3.0), a, Float64(b * b))) - b) / a) * 0.3333333333333333); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -2.7e+97], N[(N[(-2.0 * b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 5.6e-126], N[(N[(N[(N[Sqrt[N[(N[(c * -3.0), $MachinePrecision] * a + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / a), $MachinePrecision] * 0.3333333333333333), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;b \leq -2.7 \cdot 10^{+97}:\\
\;\;\;\;\frac{-2 \cdot b}{3 \cdot a}\\
\mathbf{elif}\;b \leq 5.6 \cdot 10^{-126}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(c \cdot -3, a, b \cdot b\right)} - b}{a} \cdot 0.3333333333333333\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
if b < -2.69999999999999993e97Initial program 52.1%
Taylor expanded in b around -inf
lower-*.f6436.0%
Applied rewrites36.0%
if -2.69999999999999993e97 < b < 5.59999999999999983e-126Initial program 52.1%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
mult-flipN/A
lower-*.f64N/A
Applied rewrites52.0%
if 5.59999999999999983e-126 < b Initial program 52.1%
Taylor expanded in b around inf
lower-*.f64N/A
lower-/.f6433.9%
Applied rewrites33.9%
(FPCore (a b c)
:precision binary64
(if (<= b -6.5e+116)
(/ (* -2.0 b) (* 3.0 a))
(if (<= b 5.6e-126)
(* (- (sqrt (fma (* c -3.0) a (* b b))) b) (/ 0.3333333333333333 a))
(* -0.5 (/ c b)))))double code(double a, double b, double c) {
double tmp;
if (b <= -6.5e+116) {
tmp = (-2.0 * b) / (3.0 * a);
} else if (b <= 5.6e-126) {
tmp = (sqrt(fma((c * -3.0), a, (b * b))) - b) * (0.3333333333333333 / a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -6.5e+116) tmp = Float64(Float64(-2.0 * b) / Float64(3.0 * a)); elseif (b <= 5.6e-126) tmp = Float64(Float64(sqrt(fma(Float64(c * -3.0), a, Float64(b * b))) - b) * Float64(0.3333333333333333 / a)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -6.5e+116], N[(N[(-2.0 * b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 5.6e-126], N[(N[(N[Sqrt[N[(N[(c * -3.0), $MachinePrecision] * a + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] * N[(0.3333333333333333 / a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;b \leq -6.5 \cdot 10^{+116}:\\
\;\;\;\;\frac{-2 \cdot b}{3 \cdot a}\\
\mathbf{elif}\;b \leq 5.6 \cdot 10^{-126}:\\
\;\;\;\;\left(\sqrt{\mathsf{fma}\left(c \cdot -3, a, b \cdot b\right)} - b\right) \cdot \frac{0.3333333333333333}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
if b < -6.4999999999999998e116Initial program 52.1%
Taylor expanded in b around -inf
lower-*.f6436.0%
Applied rewrites36.0%
if -6.4999999999999998e116 < b < 5.59999999999999983e-126Initial program 52.1%
lift-/.f64N/A
mult-flipN/A
lower-*.f64N/A
Applied rewrites52.0%
if 5.59999999999999983e-126 < b Initial program 52.1%
Taylor expanded in b around inf
lower-*.f64N/A
lower-/.f6433.9%
Applied rewrites33.9%
(FPCore (a b c)
:precision binary64
(if (<= b -15000000.0)
(/ (* -2.0 b) (* 3.0 a))
(if (<= b 5.6e-126)
(/ (/ (- (sqrt (* -3.0 (* a c))) b) a) 3.0)
(* -0.5 (/ c b)))))double code(double a, double b, double c) {
double tmp;
if (b <= -15000000.0) {
tmp = (-2.0 * b) / (3.0 * a);
} else if (b <= 5.6e-126) {
tmp = ((sqrt((-3.0 * (a * c))) - b) / a) / 3.0;
} else {
tmp = -0.5 * (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 <= (-15000000.0d0)) then
tmp = ((-2.0d0) * b) / (3.0d0 * a)
else if (b <= 5.6d-126) then
tmp = ((sqrt(((-3.0d0) * (a * c))) - b) / a) / 3.0d0
else
tmp = (-0.5d0) * (c / b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -15000000.0) {
tmp = (-2.0 * b) / (3.0 * a);
} else if (b <= 5.6e-126) {
tmp = ((Math.sqrt((-3.0 * (a * c))) - b) / a) / 3.0;
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -15000000.0: tmp = (-2.0 * b) / (3.0 * a) elif b <= 5.6e-126: tmp = ((math.sqrt((-3.0 * (a * c))) - b) / a) / 3.0 else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -15000000.0) tmp = Float64(Float64(-2.0 * b) / Float64(3.0 * a)); elseif (b <= 5.6e-126) tmp = Float64(Float64(Float64(sqrt(Float64(-3.0 * Float64(a * c))) - b) / a) / 3.0); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -15000000.0) tmp = (-2.0 * b) / (3.0 * a); elseif (b <= 5.6e-126) tmp = ((sqrt((-3.0 * (a * c))) - b) / a) / 3.0; else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -15000000.0], N[(N[(-2.0 * b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 5.6e-126], N[(N[(N[(N[Sqrt[N[(-3.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / a), $MachinePrecision] / 3.0), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;b \leq -15000000:\\
\;\;\;\;\frac{-2 \cdot b}{3 \cdot a}\\
\mathbf{elif}\;b \leq 5.6 \cdot 10^{-126}:\\
\;\;\;\;\frac{\frac{\sqrt{-3 \cdot \left(a \cdot c\right)} - b}{a}}{3}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
if b < -1.5e7Initial program 52.1%
Taylor expanded in b around -inf
lower-*.f6436.0%
Applied rewrites36.0%
if -1.5e7 < b < 5.59999999999999983e-126Initial program 52.1%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites52.1%
Taylor expanded in a around inf
lower-*.f64N/A
lower-*.f6433.2%
Applied rewrites33.2%
if 5.59999999999999983e-126 < b Initial program 52.1%
Taylor expanded in b around inf
lower-*.f64N/A
lower-/.f6433.9%
Applied rewrites33.9%
(FPCore (a b c)
:precision binary64
(if (<= b -15000000.0)
(/ (* -2.0 b) (* 3.0 a))
(if (<= b 5.6e-126)
(* (/ (- (sqrt (* -3.0 (* a c))) b) a) 0.3333333333333333)
(* -0.5 (/ c b)))))double code(double a, double b, double c) {
double tmp;
if (b <= -15000000.0) {
tmp = (-2.0 * b) / (3.0 * a);
} else if (b <= 5.6e-126) {
tmp = ((sqrt((-3.0 * (a * c))) - b) / a) * 0.3333333333333333;
} else {
tmp = -0.5 * (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 <= (-15000000.0d0)) then
tmp = ((-2.0d0) * b) / (3.0d0 * a)
else if (b <= 5.6d-126) then
tmp = ((sqrt(((-3.0d0) * (a * c))) - b) / a) * 0.3333333333333333d0
else
tmp = (-0.5d0) * (c / b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -15000000.0) {
tmp = (-2.0 * b) / (3.0 * a);
} else if (b <= 5.6e-126) {
tmp = ((Math.sqrt((-3.0 * (a * c))) - b) / a) * 0.3333333333333333;
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -15000000.0: tmp = (-2.0 * b) / (3.0 * a) elif b <= 5.6e-126: tmp = ((math.sqrt((-3.0 * (a * c))) - b) / a) * 0.3333333333333333 else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -15000000.0) tmp = Float64(Float64(-2.0 * b) / Float64(3.0 * a)); elseif (b <= 5.6e-126) tmp = Float64(Float64(Float64(sqrt(Float64(-3.0 * Float64(a * c))) - b) / a) * 0.3333333333333333); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -15000000.0) tmp = (-2.0 * b) / (3.0 * a); elseif (b <= 5.6e-126) tmp = ((sqrt((-3.0 * (a * c))) - b) / a) * 0.3333333333333333; else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -15000000.0], N[(N[(-2.0 * b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 5.6e-126], N[(N[(N[(N[Sqrt[N[(-3.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / a), $MachinePrecision] * 0.3333333333333333), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;b \leq -15000000:\\
\;\;\;\;\frac{-2 \cdot b}{3 \cdot a}\\
\mathbf{elif}\;b \leq 5.6 \cdot 10^{-126}:\\
\;\;\;\;\frac{\sqrt{-3 \cdot \left(a \cdot c\right)} - b}{a} \cdot 0.3333333333333333\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
if b < -1.5e7Initial program 52.1%
Taylor expanded in b around -inf
lower-*.f6436.0%
Applied rewrites36.0%
if -1.5e7 < b < 5.59999999999999983e-126Initial program 52.1%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
mult-flipN/A
lower-*.f64N/A
Applied rewrites52.0%
Taylor expanded in a around inf
lower-*.f64N/A
lower-*.f6433.1%
Applied rewrites33.1%
if 5.59999999999999983e-126 < b Initial program 52.1%
Taylor expanded in b around inf
lower-*.f64N/A
lower-/.f6433.9%
Applied rewrites33.9%
(FPCore (a b c)
:precision binary64
(if (<= b -8.2e-44)
(/ (* -2.0 b) (* 3.0 a))
(if (<= b 5.6e-126)
(/ (sqrt (* (* -3.0 a) c)) (* 3.0 a))
(* -0.5 (/ c b)))))double code(double a, double b, double c) {
double tmp;
if (b <= -8.2e-44) {
tmp = (-2.0 * b) / (3.0 * a);
} else if (b <= 5.6e-126) {
tmp = sqrt(((-3.0 * a) * c)) / (3.0 * a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-8.2d-44)) then
tmp = ((-2.0d0) * b) / (3.0d0 * a)
else if (b <= 5.6d-126) then
tmp = sqrt((((-3.0d0) * a) * c)) / (3.0d0 * a)
else
tmp = (-0.5d0) * (c / b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -8.2e-44) {
tmp = (-2.0 * b) / (3.0 * a);
} else if (b <= 5.6e-126) {
tmp = Math.sqrt(((-3.0 * a) * c)) / (3.0 * a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -8.2e-44: tmp = (-2.0 * b) / (3.0 * a) elif b <= 5.6e-126: tmp = math.sqrt(((-3.0 * a) * c)) / (3.0 * a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -8.2e-44) tmp = Float64(Float64(-2.0 * b) / Float64(3.0 * a)); elseif (b <= 5.6e-126) tmp = Float64(sqrt(Float64(Float64(-3.0 * a) * c)) / Float64(3.0 * a)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -8.2e-44) tmp = (-2.0 * b) / (3.0 * a); elseif (b <= 5.6e-126) tmp = sqrt(((-3.0 * a) * c)) / (3.0 * a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -8.2e-44], N[(N[(-2.0 * b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 5.6e-126], N[(N[Sqrt[N[(N[(-3.0 * a), $MachinePrecision] * c), $MachinePrecision]], $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;b \leq -8.2 \cdot 10^{-44}:\\
\;\;\;\;\frac{-2 \cdot b}{3 \cdot a}\\
\mathbf{elif}\;b \leq 5.6 \cdot 10^{-126}:\\
\;\;\;\;\frac{\sqrt{\left(-3 \cdot a\right) \cdot c}}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
if b < -8.19999999999999984e-44Initial program 52.1%
Taylor expanded in b around -inf
lower-*.f6436.0%
Applied rewrites36.0%
if -8.19999999999999984e-44 < b < 5.59999999999999983e-126Initial program 52.1%
Taylor expanded in b around 0
lower-sqrt.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-*.f6428.8%
Applied rewrites28.8%
lift-neg.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
distribute-lft-neg-outN/A
lower-*.f64N/A
lift-*.f64N/A
distribute-lft-neg-outN/A
metadata-evalN/A
lower-*.f6428.8%
Applied rewrites28.8%
if 5.59999999999999983e-126 < b Initial program 52.1%
Taylor expanded in b around inf
lower-*.f64N/A
lower-/.f6433.9%
Applied rewrites33.9%
(FPCore (a b c)
:precision binary64
(if (<= b -8.2e-44)
(/ (* -2.0 b) (* 3.0 a))
(if (<= b 5.6e-126)
(* 0.3333333333333333 (/ (sqrt (* -3.0 (* a c))) a))
(* -0.5 (/ c b)))))double code(double a, double b, double c) {
double tmp;
if (b <= -8.2e-44) {
tmp = (-2.0 * b) / (3.0 * a);
} else if (b <= 5.6e-126) {
tmp = 0.3333333333333333 * (sqrt((-3.0 * (a * c))) / a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-8.2d-44)) then
tmp = ((-2.0d0) * b) / (3.0d0 * a)
else if (b <= 5.6d-126) then
tmp = 0.3333333333333333d0 * (sqrt(((-3.0d0) * (a * c))) / a)
else
tmp = (-0.5d0) * (c / b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -8.2e-44) {
tmp = (-2.0 * b) / (3.0 * a);
} else if (b <= 5.6e-126) {
tmp = 0.3333333333333333 * (Math.sqrt((-3.0 * (a * c))) / a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -8.2e-44: tmp = (-2.0 * b) / (3.0 * a) elif b <= 5.6e-126: tmp = 0.3333333333333333 * (math.sqrt((-3.0 * (a * c))) / a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -8.2e-44) tmp = Float64(Float64(-2.0 * b) / Float64(3.0 * a)); elseif (b <= 5.6e-126) tmp = Float64(0.3333333333333333 * Float64(sqrt(Float64(-3.0 * Float64(a * c))) / a)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -8.2e-44) tmp = (-2.0 * b) / (3.0 * a); elseif (b <= 5.6e-126) tmp = 0.3333333333333333 * (sqrt((-3.0 * (a * c))) / a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -8.2e-44], N[(N[(-2.0 * b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 5.6e-126], N[(0.3333333333333333 * N[(N[Sqrt[N[(-3.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;b \leq -8.2 \cdot 10^{-44}:\\
\;\;\;\;\frac{-2 \cdot b}{3 \cdot a}\\
\mathbf{elif}\;b \leq 5.6 \cdot 10^{-126}:\\
\;\;\;\;0.3333333333333333 \cdot \frac{\sqrt{-3 \cdot \left(a \cdot c\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
if b < -8.19999999999999984e-44Initial program 52.1%
Taylor expanded in b around -inf
lower-*.f6436.0%
Applied rewrites36.0%
if -8.19999999999999984e-44 < b < 5.59999999999999983e-126Initial program 52.1%
lift--.f64N/A
sub-negate-revN/A
sub-flipN/A
distribute-neg-inN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lift-*.f64N/A
sqr-abs-revN/A
distribute-rgt-neg-inN/A
distribute-lft-neg-outN/A
sqr-neg-revN/A
sqr-abs-revN/A
lift-*.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
metadata-eval52.1%
Applied rewrites52.1%
Taylor expanded in b around 0
lower-*.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-*.f6428.7%
Applied rewrites28.7%
if 5.59999999999999983e-126 < b Initial program 52.1%
Taylor expanded in b around inf
lower-*.f64N/A
lower-/.f6433.9%
Applied rewrites33.9%
(FPCore (a b c) :precision binary64 (if (<= b -6e-50) (/ (* -2.0 b) (* 3.0 a)) (if (<= b 1.02e-94) (/ (sqrt (* -3.0 (/ c a))) 3.0) (* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -6e-50) {
tmp = (-2.0 * b) / (3.0 * a);
} else if (b <= 1.02e-94) {
tmp = sqrt((-3.0 * (c / a))) / 3.0;
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-6d-50)) then
tmp = ((-2.0d0) * b) / (3.0d0 * a)
else if (b <= 1.02d-94) then
tmp = sqrt(((-3.0d0) * (c / a))) / 3.0d0
else
tmp = (-0.5d0) * (c / b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -6e-50) {
tmp = (-2.0 * b) / (3.0 * a);
} else if (b <= 1.02e-94) {
tmp = Math.sqrt((-3.0 * (c / a))) / 3.0;
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -6e-50: tmp = (-2.0 * b) / (3.0 * a) elif b <= 1.02e-94: tmp = math.sqrt((-3.0 * (c / a))) / 3.0 else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -6e-50) tmp = Float64(Float64(-2.0 * b) / Float64(3.0 * a)); elseif (b <= 1.02e-94) tmp = Float64(sqrt(Float64(-3.0 * Float64(c / a))) / 3.0); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -6e-50) tmp = (-2.0 * b) / (3.0 * a); elseif (b <= 1.02e-94) tmp = sqrt((-3.0 * (c / a))) / 3.0; else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -6e-50], N[(N[(-2.0 * b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.02e-94], N[(N[Sqrt[N[(-3.0 * N[(c / a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / 3.0), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;b \leq -6 \cdot 10^{-50}:\\
\;\;\;\;\frac{-2 \cdot b}{3 \cdot a}\\
\mathbf{elif}\;b \leq 1.02 \cdot 10^{-94}:\\
\;\;\;\;\frac{\sqrt{-3 \cdot \frac{c}{a}}}{3}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
if b < -5.99999999999999981e-50Initial program 52.1%
Taylor expanded in b around -inf
lower-*.f6436.0%
Applied rewrites36.0%
if -5.99999999999999981e-50 < b < 1.02e-94Initial program 52.1%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites52.1%
Taylor expanded in a around inf
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6417.5%
Applied rewrites17.5%
if 1.02e-94 < b Initial program 52.1%
Taylor expanded in b around inf
lower-*.f64N/A
lower-/.f6433.9%
Applied rewrites33.9%
(FPCore (a b c)
:precision binary64
(if (<= b -6e-50)
(/ (* -2.0 b) (* 3.0 a))
(if (<= b 1.02e-94)
(* 0.3333333333333333 (sqrt (* -3.0 (/ c a))))
(* -0.5 (/ c b)))))double code(double a, double b, double c) {
double tmp;
if (b <= -6e-50) {
tmp = (-2.0 * b) / (3.0 * a);
} else if (b <= 1.02e-94) {
tmp = 0.3333333333333333 * sqrt((-3.0 * (c / a)));
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-6d-50)) then
tmp = ((-2.0d0) * b) / (3.0d0 * a)
else if (b <= 1.02d-94) then
tmp = 0.3333333333333333d0 * sqrt(((-3.0d0) * (c / a)))
else
tmp = (-0.5d0) * (c / b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -6e-50) {
tmp = (-2.0 * b) / (3.0 * a);
} else if (b <= 1.02e-94) {
tmp = 0.3333333333333333 * Math.sqrt((-3.0 * (c / a)));
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -6e-50: tmp = (-2.0 * b) / (3.0 * a) elif b <= 1.02e-94: tmp = 0.3333333333333333 * math.sqrt((-3.0 * (c / a))) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -6e-50) tmp = Float64(Float64(-2.0 * b) / Float64(3.0 * a)); elseif (b <= 1.02e-94) tmp = Float64(0.3333333333333333 * sqrt(Float64(-3.0 * Float64(c / a)))); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -6e-50) tmp = (-2.0 * b) / (3.0 * a); elseif (b <= 1.02e-94) tmp = 0.3333333333333333 * sqrt((-3.0 * (c / a))); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -6e-50], N[(N[(-2.0 * b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.02e-94], N[(0.3333333333333333 * N[Sqrt[N[(-3.0 * N[(c / a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;b \leq -6 \cdot 10^{-50}:\\
\;\;\;\;\frac{-2 \cdot b}{3 \cdot a}\\
\mathbf{elif}\;b \leq 1.02 \cdot 10^{-94}:\\
\;\;\;\;0.3333333333333333 \cdot \sqrt{-3 \cdot \frac{c}{a}}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
if b < -5.99999999999999981e-50Initial program 52.1%
Taylor expanded in b around -inf
lower-*.f6436.0%
Applied rewrites36.0%
if -5.99999999999999981e-50 < b < 1.02e-94Initial program 52.1%
Taylor expanded in a around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6417.4%
Applied rewrites17.4%
if 1.02e-94 < b Initial program 52.1%
Taylor expanded in b around inf
lower-*.f64N/A
lower-/.f6433.9%
Applied rewrites33.9%
(FPCore (a b c)
:precision binary64
(if (<= b -2.2e-140)
(/ (* -2.0 b) (* 3.0 a))
(if (<= b 1.85e-228)
(* -0.3333333333333333 (sqrt (* -3.0 (/ c a))))
(* -0.5 (/ c b)))))double code(double a, double b, double c) {
double tmp;
if (b <= -2.2e-140) {
tmp = (-2.0 * b) / (3.0 * a);
} else if (b <= 1.85e-228) {
tmp = -0.3333333333333333 * sqrt((-3.0 * (c / a)));
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-2.2d-140)) then
tmp = ((-2.0d0) * b) / (3.0d0 * a)
else if (b <= 1.85d-228) then
tmp = (-0.3333333333333333d0) * sqrt(((-3.0d0) * (c / a)))
else
tmp = (-0.5d0) * (c / b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -2.2e-140) {
tmp = (-2.0 * b) / (3.0 * a);
} else if (b <= 1.85e-228) {
tmp = -0.3333333333333333 * Math.sqrt((-3.0 * (c / a)));
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.2e-140: tmp = (-2.0 * b) / (3.0 * a) elif b <= 1.85e-228: tmp = -0.3333333333333333 * math.sqrt((-3.0 * (c / a))) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.2e-140) tmp = Float64(Float64(-2.0 * b) / Float64(3.0 * a)); elseif (b <= 1.85e-228) tmp = Float64(-0.3333333333333333 * sqrt(Float64(-3.0 * Float64(c / a)))); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2.2e-140) tmp = (-2.0 * b) / (3.0 * a); elseif (b <= 1.85e-228) tmp = -0.3333333333333333 * sqrt((-3.0 * (c / a))); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.2e-140], N[(N[(-2.0 * b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.85e-228], N[(-0.3333333333333333 * N[Sqrt[N[(-3.0 * N[(c / a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;b \leq -2.2 \cdot 10^{-140}:\\
\;\;\;\;\frac{-2 \cdot b}{3 \cdot a}\\
\mathbf{elif}\;b \leq 1.85 \cdot 10^{-228}:\\
\;\;\;\;-0.3333333333333333 \cdot \sqrt{-3 \cdot \frac{c}{a}}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
if b < -2.1999999999999999e-140Initial program 52.1%
Taylor expanded in b around -inf
lower-*.f6436.0%
Applied rewrites36.0%
if -2.1999999999999999e-140 < b < 1.85e-228Initial program 52.1%
Taylor expanded in a around -inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6417.4%
Applied rewrites17.4%
if 1.85e-228 < b Initial program 52.1%
Taylor expanded in b around inf
lower-*.f64N/A
lower-/.f6433.9%
Applied rewrites33.9%
(FPCore (a b c) :precision binary64 (if (<= b 1.42e-306) (/ (* -2.0 b) (* 3.0 a)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.42e-306) {
tmp = (-2.0 * b) / (3.0 * a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= 1.42d-306) then
tmp = ((-2.0d0) * b) / (3.0d0 * a)
else
tmp = (-0.5d0) * (c / b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 1.42e-306) {
tmp = (-2.0 * b) / (3.0 * a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.42e-306: tmp = (-2.0 * b) / (3.0 * a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.42e-306) tmp = Float64(Float64(-2.0 * b) / Float64(3.0 * a)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 1.42e-306) tmp = (-2.0 * b) / (3.0 * a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.42e-306], N[(N[(-2.0 * b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;b \leq 1.42 \cdot 10^{-306}:\\
\;\;\;\;\frac{-2 \cdot b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
if b < 1.42000000000000005e-306Initial program 52.1%
Taylor expanded in b around -inf
lower-*.f6436.0%
Applied rewrites36.0%
if 1.42000000000000005e-306 < b Initial program 52.1%
Taylor expanded in b around inf
lower-*.f64N/A
lower-/.f6433.9%
Applied rewrites33.9%
(FPCore (a b c) :precision binary64 (if (<= b 1.42e-306) (/ (* -0.6666666666666666 b) a) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.42e-306) {
tmp = (-0.6666666666666666 * b) / a;
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= 1.42d-306) then
tmp = ((-0.6666666666666666d0) * b) / a
else
tmp = (-0.5d0) * (c / b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 1.42e-306) {
tmp = (-0.6666666666666666 * b) / a;
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.42e-306: tmp = (-0.6666666666666666 * b) / a else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.42e-306) tmp = Float64(Float64(-0.6666666666666666 * b) / a); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 1.42e-306) tmp = (-0.6666666666666666 * b) / a; else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.42e-306], N[(N[(-0.6666666666666666 * b), $MachinePrecision] / a), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;b \leq 1.42 \cdot 10^{-306}:\\
\;\;\;\;\frac{-0.6666666666666666 \cdot b}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
if b < 1.42000000000000005e-306Initial program 52.1%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6436.0%
Applied rewrites36.0%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f6436.0%
Applied rewrites36.0%
if 1.42000000000000005e-306 < b Initial program 52.1%
Taylor expanded in b around inf
lower-*.f64N/A
lower-/.f6433.9%
Applied rewrites33.9%
(FPCore (a b c) :precision binary64 (if (<= b 1.42e-306) (* -0.6666666666666666 (/ b a)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.42e-306) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= 1.42d-306) then
tmp = (-0.6666666666666666d0) * (b / a)
else
tmp = (-0.5d0) * (c / b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 1.42e-306) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.42e-306: tmp = -0.6666666666666666 * (b / a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.42e-306) tmp = Float64(-0.6666666666666666 * Float64(b / a)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 1.42e-306) tmp = -0.6666666666666666 * (b / a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.42e-306], N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;b \leq 1.42 \cdot 10^{-306}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
if b < 1.42000000000000005e-306Initial program 52.1%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6436.0%
Applied rewrites36.0%
if 1.42000000000000005e-306 < b Initial program 52.1%
Taylor expanded in b around inf
lower-*.f64N/A
lower-/.f6433.9%
Applied rewrites33.9%
(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]
-0.6666666666666666 \cdot \frac{b}{a}
Initial program 52.1%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6436.0%
Applied rewrites36.0%
herbie shell --seed 2025183
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))