
(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}
Sampling outcomes in binary64 precision:
Herbie found 16 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
(if (<= b -2.5e+158)
(/ (* b -2.0) (* 3.0 a))
(if (<= b 2.15e-60)
(/ (+ (- b) (sqrt (fma (* a -3.0) c (* b b)))) (* 3.0 a))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.5e+158) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 2.15e-60) {
tmp = (-b + sqrt(fma((a * -3.0), c, (b * b)))) / (3.0 * a);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -2.5e+158) tmp = Float64(Float64(b * -2.0) / Float64(3.0 * a)); elseif (b <= 2.15e-60) tmp = Float64(Float64(Float64(-b) + sqrt(fma(Float64(a * -3.0), c, Float64(b * b)))) / Float64(3.0 * a)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -2.5e+158], N[(N[(b * -2.0), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.15e-60], N[(N[((-b) + N[Sqrt[N[(N[(a * -3.0), $MachinePrecision] * c + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.5 \cdot 10^{+158}:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{elif}\;b \leq 2.15 \cdot 10^{-60}:\\
\;\;\;\;\frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(a \cdot -3, c, b \cdot b\right)}}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -2.4999999999999998e158Initial program 37.3%
Taylor expanded in b around -inf
Applied rewrites94.0%
if -2.4999999999999998e158 < b < 2.15e-60Initial program 80.9%
Applied rewrites80.9%
if 2.15e-60 < b Initial program 17.1%
Taylor expanded in a around 0
Applied rewrites89.8%
(FPCore (a b c)
:precision binary64
(if (<= b -2.5e+158)
(/ (* b -2.0) (* 3.0 a))
(if (<= b 2.15e-60)
(/ (+ (- b) (sqrt (fma a (* -3.0 c) (* b b)))) (* 3.0 a))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.5e+158) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 2.15e-60) {
tmp = (-b + sqrt(fma(a, (-3.0 * c), (b * b)))) / (3.0 * a);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -2.5e+158) tmp = Float64(Float64(b * -2.0) / Float64(3.0 * a)); elseif (b <= 2.15e-60) tmp = Float64(Float64(Float64(-b) + sqrt(fma(a, Float64(-3.0 * c), Float64(b * b)))) / Float64(3.0 * a)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -2.5e+158], N[(N[(b * -2.0), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.15e-60], N[(N[((-b) + N[Sqrt[N[(a * N[(-3.0 * c), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.5 \cdot 10^{+158}:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{elif}\;b \leq 2.15 \cdot 10^{-60}:\\
\;\;\;\;\frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)}}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -2.4999999999999998e158Initial program 37.3%
Taylor expanded in b around -inf
Applied rewrites94.0%
if -2.4999999999999998e158 < b < 2.15e-60Initial program 80.9%
Applied rewrites80.9%
Applied rewrites80.9%
if 2.15e-60 < b Initial program 17.1%
Taylor expanded in a around 0
Applied rewrites89.8%
(FPCore (a b c)
:precision binary64
(if (<= b -2.6e-56)
(fma (/ (* c -0.5) (* b b)) (- b) (* (/ 0.6666666666666666 a) (- b)))
(if (<= b 2.15e-60)
(/ (+ (- b) (sqrt (* (* a -3.0) c))) (* 3.0 a))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.6e-56) {
tmp = fma(((c * -0.5) / (b * b)), -b, ((0.6666666666666666 / a) * -b));
} else if (b <= 2.15e-60) {
tmp = (-b + sqrt(((a * -3.0) * c))) / (3.0 * a);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -2.6e-56) tmp = fma(Float64(Float64(c * -0.5) / Float64(b * b)), Float64(-b), Float64(Float64(0.6666666666666666 / a) * Float64(-b))); elseif (b <= 2.15e-60) tmp = Float64(Float64(Float64(-b) + sqrt(Float64(Float64(a * -3.0) * c))) / Float64(3.0 * a)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -2.6e-56], N[(N[(N[(c * -0.5), $MachinePrecision] / N[(b * b), $MachinePrecision]), $MachinePrecision] * (-b) + N[(N[(0.6666666666666666 / a), $MachinePrecision] * (-b)), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.15e-60], N[(N[((-b) + N[Sqrt[N[(N[(a * -3.0), $MachinePrecision] * c), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.6 \cdot 10^{-56}:\\
\;\;\;\;\mathsf{fma}\left(\frac{c \cdot -0.5}{b \cdot b}, -b, \frac{0.6666666666666666}{a} \cdot \left(-b\right)\right)\\
\mathbf{elif}\;b \leq 2.15 \cdot 10^{-60}:\\
\;\;\;\;\frac{\left(-b\right) + \sqrt{\left(a \cdot -3\right) \cdot c}}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -2.59999999999999997e-56Initial program 69.5%
Taylor expanded in b around -inf
Applied rewrites87.3%
Applied rewrites87.4%
if -2.59999999999999997e-56 < b < 2.15e-60Initial program 75.0%
Taylor expanded in a around inf
Applied rewrites66.9%
Applied rewrites67.0%
if 2.15e-60 < b Initial program 17.1%
Taylor expanded in a around 0
Applied rewrites89.8%
(FPCore (a b c)
:precision binary64
(if (<= b -2.6e-56)
(* (- b) (fma -0.5 (/ c (* b b)) (/ 0.6666666666666666 a)))
(if (<= b 2.15e-60)
(/ (+ (- b) (sqrt (* (* a -3.0) c))) (* 3.0 a))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.6e-56) {
tmp = -b * fma(-0.5, (c / (b * b)), (0.6666666666666666 / a));
} else if (b <= 2.15e-60) {
tmp = (-b + sqrt(((a * -3.0) * c))) / (3.0 * a);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -2.6e-56) tmp = Float64(Float64(-b) * fma(-0.5, Float64(c / Float64(b * b)), Float64(0.6666666666666666 / a))); elseif (b <= 2.15e-60) tmp = Float64(Float64(Float64(-b) + sqrt(Float64(Float64(a * -3.0) * c))) / Float64(3.0 * a)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -2.6e-56], N[((-b) * N[(-0.5 * N[(c / N[(b * b), $MachinePrecision]), $MachinePrecision] + N[(0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.15e-60], N[(N[((-b) + N[Sqrt[N[(N[(a * -3.0), $MachinePrecision] * c), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.6 \cdot 10^{-56}:\\
\;\;\;\;\left(-b\right) \cdot \mathsf{fma}\left(-0.5, \frac{c}{b \cdot b}, \frac{0.6666666666666666}{a}\right)\\
\mathbf{elif}\;b \leq 2.15 \cdot 10^{-60}:\\
\;\;\;\;\frac{\left(-b\right) + \sqrt{\left(a \cdot -3\right) \cdot c}}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -2.59999999999999997e-56Initial program 69.5%
Taylor expanded in b around -inf
Applied rewrites87.3%
if -2.59999999999999997e-56 < b < 2.15e-60Initial program 75.0%
Taylor expanded in a around inf
Applied rewrites66.9%
Applied rewrites67.0%
if 2.15e-60 < b Initial program 17.1%
Taylor expanded in a around 0
Applied rewrites89.8%
(FPCore (a b c)
:precision binary64
(if (<= b -3.6e-64)
(* (- b) (fma -0.5 (/ c (* b b)) (/ 0.6666666666666666 a)))
(if (<= b 2.15e-60)
(/ (sqrt (* (* a -3.0) c)) (* 3.0 a))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -3.6e-64) {
tmp = -b * fma(-0.5, (c / (b * b)), (0.6666666666666666 / a));
} else if (b <= 2.15e-60) {
tmp = sqrt(((a * -3.0) * c)) / (3.0 * a);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -3.6e-64) tmp = Float64(Float64(-b) * fma(-0.5, Float64(c / Float64(b * b)), Float64(0.6666666666666666 / a))); elseif (b <= 2.15e-60) tmp = Float64(sqrt(Float64(Float64(a * -3.0) * c)) / Float64(3.0 * a)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -3.6e-64], N[((-b) * N[(-0.5 * N[(c / N[(b * b), $MachinePrecision]), $MachinePrecision] + N[(0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.15e-60], N[(N[Sqrt[N[(N[(a * -3.0), $MachinePrecision] * c), $MachinePrecision]], $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.6 \cdot 10^{-64}:\\
\;\;\;\;\left(-b\right) \cdot \mathsf{fma}\left(-0.5, \frac{c}{b \cdot b}, \frac{0.6666666666666666}{a}\right)\\
\mathbf{elif}\;b \leq 2.15 \cdot 10^{-60}:\\
\;\;\;\;\frac{\sqrt{\left(a \cdot -3\right) \cdot c}}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -3.5999999999999998e-64Initial program 70.3%
Taylor expanded in b around -inf
Applied rewrites86.5%
if -3.5999999999999998e-64 < b < 2.15e-60Initial program 74.5%
Applied rewrites74.5%
Taylor expanded in a around inf
Applied rewrites65.6%
Applied rewrites65.8%
if 2.15e-60 < b Initial program 17.1%
Taylor expanded in a around 0
Applied rewrites89.8%
(FPCore (a b c)
:precision binary64
(if (<= b -3.6e-64)
(fma c (/ 0.5 b) (* (/ b a) -0.6666666666666666))
(if (<= b 2.15e-60)
(/ (sqrt (* (* a -3.0) c)) (* 3.0 a))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -3.6e-64) {
tmp = fma(c, (0.5 / b), ((b / a) * -0.6666666666666666));
} else if (b <= 2.15e-60) {
tmp = sqrt(((a * -3.0) * c)) / (3.0 * a);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -3.6e-64) tmp = fma(c, Float64(0.5 / b), Float64(Float64(b / a) * -0.6666666666666666)); elseif (b <= 2.15e-60) tmp = Float64(sqrt(Float64(Float64(a * -3.0) * c)) / Float64(3.0 * a)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -3.6e-64], N[(c * N[(0.5 / b), $MachinePrecision] + N[(N[(b / a), $MachinePrecision] * -0.6666666666666666), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.15e-60], N[(N[Sqrt[N[(N[(a * -3.0), $MachinePrecision] * c), $MachinePrecision]], $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.6 \cdot 10^{-64}:\\
\;\;\;\;\mathsf{fma}\left(c, \frac{0.5}{b}, \frac{b}{a} \cdot -0.6666666666666666\right)\\
\mathbf{elif}\;b \leq 2.15 \cdot 10^{-60}:\\
\;\;\;\;\frac{\sqrt{\left(a \cdot -3\right) \cdot c}}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -3.5999999999999998e-64Initial program 70.3%
Taylor expanded in b around -inf
Applied rewrites86.5%
Taylor expanded in a around inf
Applied rewrites3.0%
Taylor expanded in a around inf
Applied rewrites86.4%
if -3.5999999999999998e-64 < b < 2.15e-60Initial program 74.5%
Applied rewrites74.5%
Taylor expanded in a around inf
Applied rewrites65.6%
Applied rewrites65.8%
if 2.15e-60 < b Initial program 17.1%
Taylor expanded in a around 0
Applied rewrites89.8%
(FPCore (a b c)
:precision binary64
(if (<= b -3.6e-64)
(fma c (/ 0.5 b) (* (/ b a) -0.6666666666666666))
(if (<= b 2.15e-60)
(/ (sqrt (* (* a c) -3.0)) (* 3.0 a))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -3.6e-64) {
tmp = fma(c, (0.5 / b), ((b / a) * -0.6666666666666666));
} else if (b <= 2.15e-60) {
tmp = sqrt(((a * c) * -3.0)) / (3.0 * a);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -3.6e-64) tmp = fma(c, Float64(0.5 / b), Float64(Float64(b / a) * -0.6666666666666666)); elseif (b <= 2.15e-60) tmp = Float64(sqrt(Float64(Float64(a * c) * -3.0)) / Float64(3.0 * a)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -3.6e-64], N[(c * N[(0.5 / b), $MachinePrecision] + N[(N[(b / a), $MachinePrecision] * -0.6666666666666666), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.15e-60], N[(N[Sqrt[N[(N[(a * c), $MachinePrecision] * -3.0), $MachinePrecision]], $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.6 \cdot 10^{-64}:\\
\;\;\;\;\mathsf{fma}\left(c, \frac{0.5}{b}, \frac{b}{a} \cdot -0.6666666666666666\right)\\
\mathbf{elif}\;b \leq 2.15 \cdot 10^{-60}:\\
\;\;\;\;\frac{\sqrt{\left(a \cdot c\right) \cdot -3}}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -3.5999999999999998e-64Initial program 70.3%
Taylor expanded in b around -inf
Applied rewrites86.5%
Taylor expanded in a around inf
Applied rewrites3.0%
Taylor expanded in a around inf
Applied rewrites86.4%
if -3.5999999999999998e-64 < b < 2.15e-60Initial program 74.5%
Taylor expanded in a around inf
Applied rewrites65.6%
if 2.15e-60 < b Initial program 17.1%
Taylor expanded in a around 0
Applied rewrites89.8%
(FPCore (a b c)
:precision binary64
(if (<= b -1.18e-145)
(fma c (/ 0.5 b) (* (/ b a) -0.6666666666666666))
(if (<= b 1.9e-109)
(* 0.3333333333333333 (sqrt (/ (* -3.0 c) a)))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.18e-145) {
tmp = fma(c, (0.5 / b), ((b / a) * -0.6666666666666666));
} else if (b <= 1.9e-109) {
tmp = 0.3333333333333333 * sqrt(((-3.0 * c) / a));
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -1.18e-145) tmp = fma(c, Float64(0.5 / b), Float64(Float64(b / a) * -0.6666666666666666)); elseif (b <= 1.9e-109) tmp = Float64(0.3333333333333333 * sqrt(Float64(Float64(-3.0 * c) / a))); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -1.18e-145], N[(c * N[(0.5 / b), $MachinePrecision] + N[(N[(b / a), $MachinePrecision] * -0.6666666666666666), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.9e-109], N[(0.3333333333333333 * N[Sqrt[N[(N[(-3.0 * c), $MachinePrecision] / a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.18 \cdot 10^{-145}:\\
\;\;\;\;\mathsf{fma}\left(c, \frac{0.5}{b}, \frac{b}{a} \cdot -0.6666666666666666\right)\\
\mathbf{elif}\;b \leq 1.9 \cdot 10^{-109}:\\
\;\;\;\;0.3333333333333333 \cdot \sqrt{\frac{-3 \cdot c}{a}}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -1.18000000000000006e-145Initial program 74.0%
Taylor expanded in b around -inf
Applied rewrites77.4%
Taylor expanded in a around inf
Applied rewrites3.4%
Taylor expanded in a around inf
Applied rewrites77.4%
if -1.18000000000000006e-145 < b < 1.90000000000000001e-109Initial program 70.9%
Taylor expanded in a around inf
Applied rewrites39.8%
Applied rewrites40.0%
if 1.90000000000000001e-109 < b Initial program 23.0%
Taylor expanded in a around 0
Applied rewrites82.9%
(FPCore (a b c)
:precision binary64
(if (<= b -1.18e-145)
(fma -0.6666666666666666 (/ b a) (/ (* c 0.5) b))
(if (<= b 1.9e-109)
(* 0.3333333333333333 (sqrt (/ (* -3.0 c) a)))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.18e-145) {
tmp = fma(-0.6666666666666666, (b / a), ((c * 0.5) / b));
} else if (b <= 1.9e-109) {
tmp = 0.3333333333333333 * sqrt(((-3.0 * c) / a));
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -1.18e-145) tmp = fma(-0.6666666666666666, Float64(b / a), Float64(Float64(c * 0.5) / b)); elseif (b <= 1.9e-109) tmp = Float64(0.3333333333333333 * sqrt(Float64(Float64(-3.0 * c) / a))); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -1.18e-145], N[(-0.6666666666666666 * N[(b / a), $MachinePrecision] + N[(N[(c * 0.5), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.9e-109], N[(0.3333333333333333 * N[Sqrt[N[(N[(-3.0 * c), $MachinePrecision] / a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.18 \cdot 10^{-145}:\\
\;\;\;\;\mathsf{fma}\left(-0.6666666666666666, \frac{b}{a}, \frac{c \cdot 0.5}{b}\right)\\
\mathbf{elif}\;b \leq 1.9 \cdot 10^{-109}:\\
\;\;\;\;0.3333333333333333 \cdot \sqrt{\frac{-3 \cdot c}{a}}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -1.18000000000000006e-145Initial program 74.0%
Taylor expanded in b around -inf
Applied rewrites77.4%
Taylor expanded in a around inf
Applied rewrites77.4%
if -1.18000000000000006e-145 < b < 1.90000000000000001e-109Initial program 70.9%
Taylor expanded in a around inf
Applied rewrites39.8%
Applied rewrites40.0%
if 1.90000000000000001e-109 < b Initial program 23.0%
Taylor expanded in a around 0
Applied rewrites82.9%
(FPCore (a b c)
:precision binary64
(if (<= b -1.18e-145)
(/ (/ (* b -2.0) 3.0) a)
(if (<= b 1.9e-109)
(* 0.3333333333333333 (sqrt (/ (* -3.0 c) a)))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.18e-145) {
tmp = ((b * -2.0) / 3.0) / a;
} else if (b <= 1.9e-109) {
tmp = 0.3333333333333333 * sqrt(((-3.0 * c) / a));
} else {
tmp = (c * -0.5) / 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.18d-145)) then
tmp = ((b * (-2.0d0)) / 3.0d0) / a
else if (b <= 1.9d-109) then
tmp = 0.3333333333333333d0 * sqrt((((-3.0d0) * c) / a))
else
tmp = (c * (-0.5d0)) / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1.18e-145) {
tmp = ((b * -2.0) / 3.0) / a;
} else if (b <= 1.9e-109) {
tmp = 0.3333333333333333 * Math.sqrt(((-3.0 * c) / a));
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.18e-145: tmp = ((b * -2.0) / 3.0) / a elif b <= 1.9e-109: tmp = 0.3333333333333333 * math.sqrt(((-3.0 * c) / a)) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.18e-145) tmp = Float64(Float64(Float64(b * -2.0) / 3.0) / a); elseif (b <= 1.9e-109) tmp = Float64(0.3333333333333333 * sqrt(Float64(Float64(-3.0 * c) / a))); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.18e-145) tmp = ((b * -2.0) / 3.0) / a; elseif (b <= 1.9e-109) tmp = 0.3333333333333333 * sqrt(((-3.0 * c) / a)); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.18e-145], N[(N[(N[(b * -2.0), $MachinePrecision] / 3.0), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 1.9e-109], N[(0.3333333333333333 * N[Sqrt[N[(N[(-3.0 * c), $MachinePrecision] / a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.18 \cdot 10^{-145}:\\
\;\;\;\;\frac{\frac{b \cdot -2}{3}}{a}\\
\mathbf{elif}\;b \leq 1.9 \cdot 10^{-109}:\\
\;\;\;\;0.3333333333333333 \cdot \sqrt{\frac{-3 \cdot c}{a}}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -1.18000000000000006e-145Initial program 74.0%
Applied rewrites74.1%
Taylor expanded in b around -inf
Applied rewrites77.2%
Applied rewrites77.2%
if -1.18000000000000006e-145 < b < 1.90000000000000001e-109Initial program 70.9%
Taylor expanded in a around inf
Applied rewrites39.8%
Applied rewrites40.0%
if 1.90000000000000001e-109 < b Initial program 23.0%
Taylor expanded in a around 0
Applied rewrites82.9%
(FPCore (a b c)
:precision binary64
(if (<= b -1.18e-145)
(/ (/ (* b -2.0) 3.0) a)
(if (<= b 1.9e-109)
(* 0.3333333333333333 (sqrt (* (/ c a) -3.0)))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.18e-145) {
tmp = ((b * -2.0) / 3.0) / a;
} else if (b <= 1.9e-109) {
tmp = 0.3333333333333333 * sqrt(((c / a) * -3.0));
} else {
tmp = (c * -0.5) / 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.18d-145)) then
tmp = ((b * (-2.0d0)) / 3.0d0) / a
else if (b <= 1.9d-109) then
tmp = 0.3333333333333333d0 * sqrt(((c / a) * (-3.0d0)))
else
tmp = (c * (-0.5d0)) / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1.18e-145) {
tmp = ((b * -2.0) / 3.0) / a;
} else if (b <= 1.9e-109) {
tmp = 0.3333333333333333 * Math.sqrt(((c / a) * -3.0));
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.18e-145: tmp = ((b * -2.0) / 3.0) / a elif b <= 1.9e-109: tmp = 0.3333333333333333 * math.sqrt(((c / a) * -3.0)) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.18e-145) tmp = Float64(Float64(Float64(b * -2.0) / 3.0) / a); elseif (b <= 1.9e-109) tmp = Float64(0.3333333333333333 * sqrt(Float64(Float64(c / a) * -3.0))); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.18e-145) tmp = ((b * -2.0) / 3.0) / a; elseif (b <= 1.9e-109) tmp = 0.3333333333333333 * sqrt(((c / a) * -3.0)); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.18e-145], N[(N[(N[(b * -2.0), $MachinePrecision] / 3.0), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 1.9e-109], N[(0.3333333333333333 * N[Sqrt[N[(N[(c / a), $MachinePrecision] * -3.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.18 \cdot 10^{-145}:\\
\;\;\;\;\frac{\frac{b \cdot -2}{3}}{a}\\
\mathbf{elif}\;b \leq 1.9 \cdot 10^{-109}:\\
\;\;\;\;0.3333333333333333 \cdot \sqrt{\frac{c}{a} \cdot -3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -1.18000000000000006e-145Initial program 74.0%
Applied rewrites74.1%
Taylor expanded in b around -inf
Applied rewrites77.2%
Applied rewrites77.2%
if -1.18000000000000006e-145 < b < 1.90000000000000001e-109Initial program 70.9%
Taylor expanded in a around inf
Applied rewrites39.8%
if 1.90000000000000001e-109 < b Initial program 23.0%
Taylor expanded in a around 0
Applied rewrites82.9%
(FPCore (a b c) :precision binary64 (if (<= b 2.1e-308) (/ (/ (* b -2.0) 3.0) a) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 2.1e-308) {
tmp = ((b * -2.0) / 3.0) / a;
} else {
tmp = (c * -0.5) / 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.1d-308) then
tmp = ((b * (-2.0d0)) / 3.0d0) / a
else
tmp = (c * (-0.5d0)) / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 2.1e-308) {
tmp = ((b * -2.0) / 3.0) / a;
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2.1e-308: tmp = ((b * -2.0) / 3.0) / a else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2.1e-308) tmp = Float64(Float64(Float64(b * -2.0) / 3.0) / a); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 2.1e-308) tmp = ((b * -2.0) / 3.0) / a; else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2.1e-308], N[(N[(N[(b * -2.0), $MachinePrecision] / 3.0), $MachinePrecision] / a), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.1 \cdot 10^{-308}:\\
\;\;\;\;\frac{\frac{b \cdot -2}{3}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < 2.1e-308Initial program 76.9%
Applied rewrites76.9%
Taylor expanded in b around -inf
Applied rewrites59.4%
Applied rewrites59.5%
if 2.1e-308 < b Initial program 28.4%
Taylor expanded in a around 0
Applied rewrites69.5%
(FPCore (a b c) :precision binary64 (if (<= b 2.1e-308) (/ (* -0.6666666666666666 b) a) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 2.1e-308) {
tmp = (-0.6666666666666666 * b) / a;
} else {
tmp = (c * -0.5) / 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.1d-308) then
tmp = ((-0.6666666666666666d0) * b) / a
else
tmp = (c * (-0.5d0)) / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 2.1e-308) {
tmp = (-0.6666666666666666 * b) / a;
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2.1e-308: tmp = (-0.6666666666666666 * b) / a else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2.1e-308) tmp = Float64(Float64(-0.6666666666666666 * b) / a); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 2.1e-308) tmp = (-0.6666666666666666 * b) / a; else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2.1e-308], N[(N[(-0.6666666666666666 * b), $MachinePrecision] / a), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.1 \cdot 10^{-308}:\\
\;\;\;\;\frac{-0.6666666666666666 \cdot b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < 2.1e-308Initial program 76.9%
Taylor expanded in b around -inf
Applied rewrites59.4%
if 2.1e-308 < b Initial program 28.4%
Taylor expanded in a around 0
Applied rewrites69.5%
(FPCore (a b c) :precision binary64 (if (<= b 2.7e+31) (/ (* -0.6666666666666666 b) a) (* c (/ 0.5 b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 2.7e+31) {
tmp = (-0.6666666666666666 * b) / a;
} else {
tmp = c * (0.5 / 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+31) then
tmp = ((-0.6666666666666666d0) * b) / a
else
tmp = c * (0.5d0 / b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 2.7e+31) {
tmp = (-0.6666666666666666 * b) / a;
} else {
tmp = c * (0.5 / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2.7e+31: tmp = (-0.6666666666666666 * b) / a else: tmp = c * (0.5 / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2.7e+31) tmp = Float64(Float64(-0.6666666666666666 * b) / a); else tmp = Float64(c * Float64(0.5 / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 2.7e+31) tmp = (-0.6666666666666666 * b) / a; else tmp = c * (0.5 / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2.7e+31], N[(N[(-0.6666666666666666 * b), $MachinePrecision] / a), $MachinePrecision], N[(c * N[(0.5 / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.7 \cdot 10^{+31}:\\
\;\;\;\;\frac{-0.6666666666666666 \cdot b}{a}\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{0.5}{b}\\
\end{array}
\end{array}
if b < 2.69999999999999986e31Initial program 69.9%
Taylor expanded in b around -inf
Applied rewrites43.8%
if 2.69999999999999986e31 < b Initial program 13.1%
Taylor expanded in b around -inf
Applied rewrites2.7%
Taylor expanded in a around inf
Applied rewrites36.9%
Applied rewrites36.9%
(FPCore (a b c) :precision binary64 (if (<= b 2.7e+31) (* (/ b a) -0.6666666666666666) (* c (/ 0.5 b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 2.7e+31) {
tmp = (b / a) * -0.6666666666666666;
} else {
tmp = c * (0.5 / 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+31) then
tmp = (b / a) * (-0.6666666666666666d0)
else
tmp = c * (0.5d0 / b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 2.7e+31) {
tmp = (b / a) * -0.6666666666666666;
} else {
tmp = c * (0.5 / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2.7e+31: tmp = (b / a) * -0.6666666666666666 else: tmp = c * (0.5 / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2.7e+31) tmp = Float64(Float64(b / a) * -0.6666666666666666); else tmp = Float64(c * Float64(0.5 / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 2.7e+31) tmp = (b / a) * -0.6666666666666666; else tmp = c * (0.5 / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2.7e+31], N[(N[(b / a), $MachinePrecision] * -0.6666666666666666), $MachinePrecision], N[(c * N[(0.5 / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.7 \cdot 10^{+31}:\\
\;\;\;\;\frac{b}{a} \cdot -0.6666666666666666\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{0.5}{b}\\
\end{array}
\end{array}
if b < 2.69999999999999986e31Initial program 69.9%
Taylor expanded in b around -inf
Applied rewrites43.8%
Applied rewrites43.7%
if 2.69999999999999986e31 < b Initial program 13.1%
Taylor expanded in b around -inf
Applied rewrites2.7%
Taylor expanded in a around inf
Applied rewrites36.9%
Applied rewrites36.9%
(FPCore (a b c) :precision binary64 (* c (/ 0.5 b)))
double code(double a, double b, double c) {
return c * (0.5 / b);
}
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 = c * (0.5d0 / b)
end function
public static double code(double a, double b, double c) {
return c * (0.5 / b);
}
def code(a, b, c): return c * (0.5 / b)
function code(a, b, c) return Float64(c * Float64(0.5 / b)) end
function tmp = code(a, b, c) tmp = c * (0.5 / b); end
code[a_, b_, c_] := N[(c * N[(0.5 / b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
c \cdot \frac{0.5}{b}
\end{array}
Initial program 53.0%
Taylor expanded in b around -inf
Applied rewrites31.0%
Taylor expanded in a around inf
Applied rewrites13.1%
Applied rewrites13.1%
herbie shell --seed 2025036 -o generate:simplify -o generate:proofs
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))