
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-b + sqrt(((b * b) - ((3.0d0 * a) * c)))) / (3.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c)))) / Float64(3.0 * a)) end
function tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a); end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\end{array}
Herbie found 14 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 -3.1e+148)
(/ (/ (* -2.0 b) 3.0) a)
(if (<= b 1.1e-40)
(/ (/ (+ (sqrt (fma (* c -3.0) a (* b b))) (- b)) 3.0) a)
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -3.1e+148) {
tmp = ((-2.0 * b) / 3.0) / a;
} else if (b <= 1.1e-40) {
tmp = ((sqrt(fma((c * -3.0), a, (b * b))) + -b) / 3.0) / a;
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -3.1e+148) tmp = Float64(Float64(Float64(-2.0 * b) / 3.0) / a); elseif (b <= 1.1e-40) tmp = Float64(Float64(Float64(sqrt(fma(Float64(c * -3.0), a, Float64(b * b))) + Float64(-b)) / 3.0) / a); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -3.1e+148], N[(N[(N[(-2.0 * b), $MachinePrecision] / 3.0), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 1.1e-40], N[(N[(N[(N[Sqrt[N[(N[(c * -3.0), $MachinePrecision] * a + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + (-b)), $MachinePrecision] / 3.0), $MachinePrecision] / a), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.1 \cdot 10^{+148}:\\
\;\;\;\;\frac{\frac{-2 \cdot b}{3}}{a}\\
\mathbf{elif}\;b \leq 1.1 \cdot 10^{-40}:\\
\;\;\;\;\frac{\frac{\sqrt{\mathsf{fma}\left(c \cdot -3, a, b \cdot b\right)} + \left(-b\right)}{3}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -3.09999999999999975e148Initial program 43.3%
Applied rewrites43.5%
Applied rewrites43.5%
Taylor expanded in b around -inf
lift-neg.f64N/A
+-commutativeN/A
lift-neg.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
pow2N/A
+-commutativeN/A
metadata-evalN/A
fp-cancel-sub-sign-invN/A
associate-*r*N/A
pow2N/A
lower-*.f6497.4
Applied rewrites97.4%
if -3.09999999999999975e148 < b < 1.10000000000000004e-40Initial program 80.1%
Applied rewrites80.1%
Applied rewrites80.1%
if 1.10000000000000004e-40 < b Initial program 16.8%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6487.4
Applied rewrites87.4%
(FPCore (a b c)
:precision binary64
(if (<= b -3.1e+148)
(/ (/ (* -2.0 b) 3.0) a)
(if (<= b 1.1e-40)
(/ (+ (sqrt (fma (* -3.0 a) c (* b b))) (- b)) (* a 3.0))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -3.1e+148) {
tmp = ((-2.0 * b) / 3.0) / a;
} else if (b <= 1.1e-40) {
tmp = (sqrt(fma((-3.0 * a), c, (b * b))) + -b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -3.1e+148) tmp = Float64(Float64(Float64(-2.0 * b) / 3.0) / a); elseif (b <= 1.1e-40) tmp = Float64(Float64(sqrt(fma(Float64(-3.0 * a), c, Float64(b * b))) + Float64(-b)) / Float64(a * 3.0)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -3.1e+148], N[(N[(N[(-2.0 * b), $MachinePrecision] / 3.0), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 1.1e-40], N[(N[(N[Sqrt[N[(N[(-3.0 * a), $MachinePrecision] * c + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + (-b)), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.1 \cdot 10^{+148}:\\
\;\;\;\;\frac{\frac{-2 \cdot b}{3}}{a}\\
\mathbf{elif}\;b \leq 1.1 \cdot 10^{-40}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(-3 \cdot a, c, b \cdot b\right)} + \left(-b\right)}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -3.09999999999999975e148Initial program 43.3%
Applied rewrites43.5%
Applied rewrites43.5%
Taylor expanded in b around -inf
lift-neg.f64N/A
+-commutativeN/A
lift-neg.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
pow2N/A
+-commutativeN/A
metadata-evalN/A
fp-cancel-sub-sign-invN/A
associate-*r*N/A
pow2N/A
lower-*.f6497.4
Applied rewrites97.4%
if -3.09999999999999975e148 < b < 1.10000000000000004e-40Initial program 80.1%
Applied rewrites80.1%
if 1.10000000000000004e-40 < b Initial program 16.8%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6487.4
Applied rewrites87.4%
(FPCore (a b c)
:precision binary64
(if (<= b -2.55e-17)
(* (- b) (fma (/ c (* b b)) -0.5 (/ 0.6666666666666666 a)))
(if (<= b 5.5e-110)
(/ (+ (- b) (sqrt (* (* a -3.0) c))) (* 3.0 a))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.55e-17) {
tmp = -b * fma((c / (b * b)), -0.5, (0.6666666666666666 / a));
} else if (b <= 5.5e-110) {
tmp = (-b + sqrt(((a * -3.0) * c))) / (3.0 * a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -2.55e-17) tmp = Float64(Float64(-b) * fma(Float64(c / Float64(b * b)), -0.5, Float64(0.6666666666666666 / a))); elseif (b <= 5.5e-110) tmp = Float64(Float64(Float64(-b) + sqrt(Float64(Float64(a * -3.0) * c))) / Float64(3.0 * a)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -2.55e-17], N[((-b) * N[(N[(c / N[(b * b), $MachinePrecision]), $MachinePrecision] * -0.5 + N[(0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 5.5e-110], N[(N[((-b) + N[Sqrt[N[(N[(a * -3.0), $MachinePrecision] * c), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.55 \cdot 10^{-17}:\\
\;\;\;\;\left(-b\right) \cdot \mathsf{fma}\left(\frac{c}{b \cdot b}, -0.5, \frac{0.6666666666666666}{a}\right)\\
\mathbf{elif}\;b \leq 5.5 \cdot 10^{-110}:\\
\;\;\;\;\frac{\left(-b\right) + \sqrt{\left(a \cdot -3\right) \cdot c}}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -2.5500000000000001e-17Initial program 67.2%
Taylor expanded in b around -inf
associate-*r*N/A
mul-1-negN/A
lift-neg.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f6489.5
Applied rewrites89.5%
if -2.5500000000000001e-17 < b < 5.4999999999999998e-110Initial program 78.7%
Taylor expanded in a around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f6466.9
Applied rewrites66.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6467.0
Applied rewrites67.0%
if 5.4999999999999998e-110 < b Initial program 20.8%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6482.1
Applied rewrites82.1%
(FPCore (a b c)
:precision binary64
(if (<= b -2.55e-17)
(/ (/ (* -2.0 b) 3.0) a)
(if (<= b 5.5e-110)
(/ (+ (- b) (sqrt (* (* a -3.0) c))) (* 3.0 a))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.55e-17) {
tmp = ((-2.0 * b) / 3.0) / a;
} else if (b <= 5.5e-110) {
tmp = (-b + sqrt(((a * -3.0) * c))) / (3.0 * a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-2.55d-17)) then
tmp = (((-2.0d0) * b) / 3.0d0) / a
else if (b <= 5.5d-110) then
tmp = (-b + sqrt(((a * (-3.0d0)) * c))) / (3.0d0 * a)
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -2.55e-17) {
tmp = ((-2.0 * b) / 3.0) / a;
} else if (b <= 5.5e-110) {
tmp = (-b + Math.sqrt(((a * -3.0) * c))) / (3.0 * a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.55e-17: tmp = ((-2.0 * b) / 3.0) / a elif b <= 5.5e-110: tmp = (-b + math.sqrt(((a * -3.0) * c))) / (3.0 * a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.55e-17) tmp = Float64(Float64(Float64(-2.0 * b) / 3.0) / a); elseif (b <= 5.5e-110) tmp = Float64(Float64(Float64(-b) + sqrt(Float64(Float64(a * -3.0) * c))) / Float64(3.0 * a)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2.55e-17) tmp = ((-2.0 * b) / 3.0) / a; elseif (b <= 5.5e-110) tmp = (-b + sqrt(((a * -3.0) * c))) / (3.0 * a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.55e-17], N[(N[(N[(-2.0 * b), $MachinePrecision] / 3.0), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 5.5e-110], N[(N[((-b) + N[Sqrt[N[(N[(a * -3.0), $MachinePrecision] * c), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.55 \cdot 10^{-17}:\\
\;\;\;\;\frac{\frac{-2 \cdot b}{3}}{a}\\
\mathbf{elif}\;b \leq 5.5 \cdot 10^{-110}:\\
\;\;\;\;\frac{\left(-b\right) + \sqrt{\left(a \cdot -3\right) \cdot c}}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -2.5500000000000001e-17Initial program 67.2%
Applied rewrites67.2%
Applied rewrites67.2%
Taylor expanded in b around -inf
lift-neg.f64N/A
+-commutativeN/A
lift-neg.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
pow2N/A
+-commutativeN/A
metadata-evalN/A
fp-cancel-sub-sign-invN/A
associate-*r*N/A
pow2N/A
lower-*.f6489.4
Applied rewrites89.4%
if -2.5500000000000001e-17 < b < 5.4999999999999998e-110Initial program 78.7%
Taylor expanded in a around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f6466.9
Applied rewrites66.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6467.0
Applied rewrites67.0%
if 5.4999999999999998e-110 < b Initial program 20.8%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6482.1
Applied rewrites82.1%
(FPCore (a b c)
:precision binary64
(if (<= b -2.55e-17)
(/ (/ (* -2.0 b) 3.0) a)
(if (<= b 5.5e-110)
(/ (+ (- b) (sqrt (* -3.0 (* c a)))) (* 3.0 a))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.55e-17) {
tmp = ((-2.0 * b) / 3.0) / a;
} else if (b <= 5.5e-110) {
tmp = (-b + sqrt((-3.0 * (c * a)))) / (3.0 * a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-2.55d-17)) then
tmp = (((-2.0d0) * b) / 3.0d0) / a
else if (b <= 5.5d-110) then
tmp = (-b + sqrt(((-3.0d0) * (c * a)))) / (3.0d0 * a)
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -2.55e-17) {
tmp = ((-2.0 * b) / 3.0) / a;
} else if (b <= 5.5e-110) {
tmp = (-b + Math.sqrt((-3.0 * (c * a)))) / (3.0 * a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.55e-17: tmp = ((-2.0 * b) / 3.0) / a elif b <= 5.5e-110: tmp = (-b + math.sqrt((-3.0 * (c * a)))) / (3.0 * a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.55e-17) tmp = Float64(Float64(Float64(-2.0 * b) / 3.0) / a); elseif (b <= 5.5e-110) tmp = Float64(Float64(Float64(-b) + sqrt(Float64(-3.0 * Float64(c * a)))) / Float64(3.0 * a)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2.55e-17) tmp = ((-2.0 * b) / 3.0) / a; elseif (b <= 5.5e-110) tmp = (-b + sqrt((-3.0 * (c * a)))) / (3.0 * a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.55e-17], N[(N[(N[(-2.0 * b), $MachinePrecision] / 3.0), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 5.5e-110], N[(N[((-b) + N[Sqrt[N[(-3.0 * N[(c * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.55 \cdot 10^{-17}:\\
\;\;\;\;\frac{\frac{-2 \cdot b}{3}}{a}\\
\mathbf{elif}\;b \leq 5.5 \cdot 10^{-110}:\\
\;\;\;\;\frac{\left(-b\right) + \sqrt{-3 \cdot \left(c \cdot a\right)}}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -2.5500000000000001e-17Initial program 67.2%
Applied rewrites67.2%
Applied rewrites67.2%
Taylor expanded in b around -inf
lift-neg.f64N/A
+-commutativeN/A
lift-neg.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
pow2N/A
+-commutativeN/A
metadata-evalN/A
fp-cancel-sub-sign-invN/A
associate-*r*N/A
pow2N/A
lower-*.f6489.4
Applied rewrites89.4%
if -2.5500000000000001e-17 < b < 5.4999999999999998e-110Initial program 78.7%
Taylor expanded in a around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f6466.9
Applied rewrites66.9%
if 5.4999999999999998e-110 < b Initial program 20.8%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6482.1
Applied rewrites82.1%
(FPCore (a b c)
:precision binary64
(if (<= b -2.55e-17)
(/ (/ (* -2.0 b) 3.0) a)
(if (<= b 5.5e-110)
(/ (sqrt (* (* -3.0 c) a)) (* a 3.0))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.55e-17) {
tmp = ((-2.0 * b) / 3.0) / a;
} else if (b <= 5.5e-110) {
tmp = sqrt(((-3.0 * c) * a)) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-2.55d-17)) then
tmp = (((-2.0d0) * b) / 3.0d0) / a
else if (b <= 5.5d-110) then
tmp = sqrt((((-3.0d0) * c) * a)) / (a * 3.0d0)
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -2.55e-17) {
tmp = ((-2.0 * b) / 3.0) / a;
} else if (b <= 5.5e-110) {
tmp = Math.sqrt(((-3.0 * c) * a)) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.55e-17: tmp = ((-2.0 * b) / 3.0) / a elif b <= 5.5e-110: tmp = math.sqrt(((-3.0 * c) * a)) / (a * 3.0) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.55e-17) tmp = Float64(Float64(Float64(-2.0 * b) / 3.0) / a); elseif (b <= 5.5e-110) tmp = Float64(sqrt(Float64(Float64(-3.0 * c) * a)) / Float64(a * 3.0)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2.55e-17) tmp = ((-2.0 * b) / 3.0) / a; elseif (b <= 5.5e-110) tmp = sqrt(((-3.0 * c) * a)) / (a * 3.0); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.55e-17], N[(N[(N[(-2.0 * b), $MachinePrecision] / 3.0), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 5.5e-110], N[(N[Sqrt[N[(N[(-3.0 * c), $MachinePrecision] * a), $MachinePrecision]], $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.55 \cdot 10^{-17}:\\
\;\;\;\;\frac{\frac{-2 \cdot b}{3}}{a}\\
\mathbf{elif}\;b \leq 5.5 \cdot 10^{-110}:\\
\;\;\;\;\frac{\sqrt{\left(-3 \cdot c\right) \cdot a}}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -2.5500000000000001e-17Initial program 67.2%
Applied rewrites67.2%
Applied rewrites67.2%
Taylor expanded in b around -inf
lift-neg.f64N/A
+-commutativeN/A
lift-neg.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
pow2N/A
+-commutativeN/A
metadata-evalN/A
fp-cancel-sub-sign-invN/A
associate-*r*N/A
pow2N/A
lower-*.f6489.4
Applied rewrites89.4%
if -2.5500000000000001e-17 < b < 5.4999999999999998e-110Initial program 78.7%
Applied rewrites78.7%
Taylor expanded in a around inf
lift-neg.f64N/A
pow2N/A
associate-*r*N/A
+-commutativeN/A
metadata-evalN/A
fp-cancel-sub-sign-invN/A
pow2N/A
associate-*r*N/A
+-commutativeN/A
lift-neg.f64N/A
sqrt-unprodN/A
*-commutativeN/A
lower-sqrt.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites64.9%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6464.9
Applied rewrites64.9%
if 5.4999999999999998e-110 < b Initial program 20.8%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6482.1
Applied rewrites82.1%
(FPCore (a b c)
:precision binary64
(if (<= b -2.55e-17)
(/ (/ (* -2.0 b) 3.0) a)
(if (<= b 5.5e-110)
(/ (sqrt (* -3.0 (* c a))) (* 3.0 a))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.55e-17) {
tmp = ((-2.0 * b) / 3.0) / a;
} else if (b <= 5.5e-110) {
tmp = sqrt((-3.0 * (c * a))) / (3.0 * a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-2.55d-17)) then
tmp = (((-2.0d0) * b) / 3.0d0) / a
else if (b <= 5.5d-110) then
tmp = sqrt(((-3.0d0) * (c * a))) / (3.0d0 * a)
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -2.55e-17) {
tmp = ((-2.0 * b) / 3.0) / a;
} else if (b <= 5.5e-110) {
tmp = Math.sqrt((-3.0 * (c * a))) / (3.0 * a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.55e-17: tmp = ((-2.0 * b) / 3.0) / a elif b <= 5.5e-110: tmp = math.sqrt((-3.0 * (c * a))) / (3.0 * a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.55e-17) tmp = Float64(Float64(Float64(-2.0 * b) / 3.0) / a); elseif (b <= 5.5e-110) tmp = Float64(sqrt(Float64(-3.0 * Float64(c * a))) / Float64(3.0 * a)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2.55e-17) tmp = ((-2.0 * b) / 3.0) / a; elseif (b <= 5.5e-110) tmp = sqrt((-3.0 * (c * a))) / (3.0 * a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.55e-17], N[(N[(N[(-2.0 * b), $MachinePrecision] / 3.0), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 5.5e-110], N[(N[Sqrt[N[(-3.0 * N[(c * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.55 \cdot 10^{-17}:\\
\;\;\;\;\frac{\frac{-2 \cdot b}{3}}{a}\\
\mathbf{elif}\;b \leq 5.5 \cdot 10^{-110}:\\
\;\;\;\;\frac{\sqrt{-3 \cdot \left(c \cdot a\right)}}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -2.5500000000000001e-17Initial program 67.2%
Applied rewrites67.2%
Applied rewrites67.2%
Taylor expanded in b around -inf
lift-neg.f64N/A
+-commutativeN/A
lift-neg.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
pow2N/A
+-commutativeN/A
metadata-evalN/A
fp-cancel-sub-sign-invN/A
associate-*r*N/A
pow2N/A
lower-*.f6489.4
Applied rewrites89.4%
if -2.5500000000000001e-17 < b < 5.4999999999999998e-110Initial program 78.7%
Taylor expanded in a around inf
sqrt-unprodN/A
*-commutativeN/A
lower-sqrt.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6464.9
Applied rewrites64.9%
if 5.4999999999999998e-110 < b Initial program 20.8%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6482.1
Applied rewrites82.1%
(FPCore (a b c)
:precision binary64
(if (<= b -1.45e-157)
(/ (/ (* -2.0 b) 3.0) a)
(if (<= b 1.85e-196)
(* (sqrt (/ (* -3.0 c) a)) 0.3333333333333333)
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.45e-157) {
tmp = ((-2.0 * b) / 3.0) / a;
} else if (b <= 1.85e-196) {
tmp = sqrt(((-3.0 * c) / a)) * 0.3333333333333333;
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-1.45d-157)) then
tmp = (((-2.0d0) * b) / 3.0d0) / a
else if (b <= 1.85d-196) then
tmp = sqrt((((-3.0d0) * c) / a)) * 0.3333333333333333d0
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1.45e-157) {
tmp = ((-2.0 * b) / 3.0) / a;
} else if (b <= 1.85e-196) {
tmp = Math.sqrt(((-3.0 * c) / a)) * 0.3333333333333333;
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.45e-157: tmp = ((-2.0 * b) / 3.0) / a elif b <= 1.85e-196: tmp = math.sqrt(((-3.0 * c) / a)) * 0.3333333333333333 else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.45e-157) tmp = Float64(Float64(Float64(-2.0 * b) / 3.0) / a); elseif (b <= 1.85e-196) tmp = Float64(sqrt(Float64(Float64(-3.0 * c) / a)) * 0.3333333333333333); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.45e-157) tmp = ((-2.0 * b) / 3.0) / a; elseif (b <= 1.85e-196) tmp = sqrt(((-3.0 * c) / a)) * 0.3333333333333333; else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.45e-157], N[(N[(N[(-2.0 * b), $MachinePrecision] / 3.0), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 1.85e-196], N[(N[Sqrt[N[(N[(-3.0 * c), $MachinePrecision] / a), $MachinePrecision]], $MachinePrecision] * 0.3333333333333333), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.45 \cdot 10^{-157}:\\
\;\;\;\;\frac{\frac{-2 \cdot b}{3}}{a}\\
\mathbf{elif}\;b \leq 1.85 \cdot 10^{-196}:\\
\;\;\;\;\sqrt{\frac{-3 \cdot c}{a}} \cdot 0.3333333333333333\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -1.44999999999999994e-157Initial program 72.6%
Applied rewrites72.7%
Applied rewrites72.7%
Taylor expanded in b around -inf
lift-neg.f64N/A
+-commutativeN/A
lift-neg.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
pow2N/A
+-commutativeN/A
metadata-evalN/A
fp-cancel-sub-sign-invN/A
associate-*r*N/A
pow2N/A
lower-*.f6478.9
Applied rewrites78.9%
if -1.44999999999999994e-157 < b < 1.85000000000000005e-196Initial program 74.7%
Taylor expanded in a around inf
*-commutativeN/A
metadata-evalN/A
sqrt-unprodN/A
lower-*.f64N/A
sqrt-unprodN/A
metadata-evalN/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6435.4
Applied rewrites35.4%
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f6435.3
Applied rewrites35.3%
if 1.85000000000000005e-196 < b Initial program 26.9%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6474.8
Applied rewrites74.8%
(FPCore (a b c)
:precision binary64
(if (<= b -1.45e-157)
(/ (/ (* -2.0 b) 3.0) a)
(if (<= b 1.85e-196)
(* (sqrt (* (/ c a) -3.0)) 0.3333333333333333)
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.45e-157) {
tmp = ((-2.0 * b) / 3.0) / a;
} else if (b <= 1.85e-196) {
tmp = sqrt(((c / a) * -3.0)) * 0.3333333333333333;
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-1.45d-157)) then
tmp = (((-2.0d0) * b) / 3.0d0) / a
else if (b <= 1.85d-196) then
tmp = sqrt(((c / a) * (-3.0d0))) * 0.3333333333333333d0
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1.45e-157) {
tmp = ((-2.0 * b) / 3.0) / a;
} else if (b <= 1.85e-196) {
tmp = Math.sqrt(((c / a) * -3.0)) * 0.3333333333333333;
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.45e-157: tmp = ((-2.0 * b) / 3.0) / a elif b <= 1.85e-196: tmp = math.sqrt(((c / a) * -3.0)) * 0.3333333333333333 else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.45e-157) tmp = Float64(Float64(Float64(-2.0 * b) / 3.0) / a); elseif (b <= 1.85e-196) tmp = Float64(sqrt(Float64(Float64(c / a) * -3.0)) * 0.3333333333333333); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.45e-157) tmp = ((-2.0 * b) / 3.0) / a; elseif (b <= 1.85e-196) tmp = sqrt(((c / a) * -3.0)) * 0.3333333333333333; else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.45e-157], N[(N[(N[(-2.0 * b), $MachinePrecision] / 3.0), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 1.85e-196], N[(N[Sqrt[N[(N[(c / a), $MachinePrecision] * -3.0), $MachinePrecision]], $MachinePrecision] * 0.3333333333333333), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.45 \cdot 10^{-157}:\\
\;\;\;\;\frac{\frac{-2 \cdot b}{3}}{a}\\
\mathbf{elif}\;b \leq 1.85 \cdot 10^{-196}:\\
\;\;\;\;\sqrt{\frac{c}{a} \cdot -3} \cdot 0.3333333333333333\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -1.44999999999999994e-157Initial program 72.6%
Applied rewrites72.7%
Applied rewrites72.7%
Taylor expanded in b around -inf
lift-neg.f64N/A
+-commutativeN/A
lift-neg.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
pow2N/A
+-commutativeN/A
metadata-evalN/A
fp-cancel-sub-sign-invN/A
associate-*r*N/A
pow2N/A
lower-*.f6478.9
Applied rewrites78.9%
if -1.44999999999999994e-157 < b < 1.85000000000000005e-196Initial program 74.7%
Taylor expanded in a around inf
*-commutativeN/A
metadata-evalN/A
sqrt-unprodN/A
lower-*.f64N/A
sqrt-unprodN/A
metadata-evalN/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6435.4
Applied rewrites35.4%
if 1.85000000000000005e-196 < b Initial program 26.9%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6474.8
Applied rewrites74.8%
(FPCore (a b c)
:precision binary64
(if (<= b -1.75e-91)
(/ (/ (* -2.0 b) 3.0) a)
(if (<= b 1.2e-223)
(* (sqrt (* (/ c a) -3.0)) -0.3333333333333333)
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.75e-91) {
tmp = ((-2.0 * b) / 3.0) / a;
} else if (b <= 1.2e-223) {
tmp = sqrt(((c / a) * -3.0)) * -0.3333333333333333;
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-1.75d-91)) then
tmp = (((-2.0d0) * b) / 3.0d0) / a
else if (b <= 1.2d-223) then
tmp = sqrt(((c / a) * (-3.0d0))) * (-0.3333333333333333d0)
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1.75e-91) {
tmp = ((-2.0 * b) / 3.0) / a;
} else if (b <= 1.2e-223) {
tmp = Math.sqrt(((c / a) * -3.0)) * -0.3333333333333333;
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.75e-91: tmp = ((-2.0 * b) / 3.0) / a elif b <= 1.2e-223: tmp = math.sqrt(((c / a) * -3.0)) * -0.3333333333333333 else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.75e-91) tmp = Float64(Float64(Float64(-2.0 * b) / 3.0) / a); elseif (b <= 1.2e-223) tmp = Float64(sqrt(Float64(Float64(c / a) * -3.0)) * -0.3333333333333333); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.75e-91) tmp = ((-2.0 * b) / 3.0) / a; elseif (b <= 1.2e-223) tmp = sqrt(((c / a) * -3.0)) * -0.3333333333333333; else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.75e-91], N[(N[(N[(-2.0 * b), $MachinePrecision] / 3.0), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 1.2e-223], N[(N[Sqrt[N[(N[(c / a), $MachinePrecision] * -3.0), $MachinePrecision]], $MachinePrecision] * -0.3333333333333333), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.75 \cdot 10^{-91}:\\
\;\;\;\;\frac{\frac{-2 \cdot b}{3}}{a}\\
\mathbf{elif}\;b \leq 1.2 \cdot 10^{-223}:\\
\;\;\;\;\sqrt{\frac{c}{a} \cdot -3} \cdot -0.3333333333333333\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -1.7499999999999999e-91Initial program 70.4%
Applied rewrites70.4%
Applied rewrites70.4%
Taylor expanded in b around -inf
lift-neg.f64N/A
+-commutativeN/A
lift-neg.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
pow2N/A
+-commutativeN/A
metadata-evalN/A
fp-cancel-sub-sign-invN/A
associate-*r*N/A
pow2N/A
lower-*.f6484.2
Applied rewrites84.2%
if -1.7499999999999999e-91 < b < 1.19999999999999993e-223Initial program 78.7%
Taylor expanded in a around -inf
*-commutativeN/A
lower-*.f64N/A
sqrt-unprodN/A
metadata-evalN/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6434.2
Applied rewrites34.2%
if 1.19999999999999993e-223 < b Initial program 28.8%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6472.4
Applied rewrites72.4%
(FPCore (a b c) :precision binary64 (if (<= b 1.7e-308) (/ (/ (* -2.0 b) 3.0) a) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.7e-308) {
tmp = ((-2.0 * b) / 3.0) / a;
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= 1.7d-308) then
tmp = (((-2.0d0) * b) / 3.0d0) / a
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 1.7e-308) {
tmp = ((-2.0 * b) / 3.0) / a;
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.7e-308: tmp = ((-2.0 * b) / 3.0) / a else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.7e-308) tmp = Float64(Float64(Float64(-2.0 * b) / 3.0) / a); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 1.7e-308) tmp = ((-2.0 * b) / 3.0) / a; else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.7e-308], N[(N[(N[(-2.0 * b), $MachinePrecision] / 3.0), $MachinePrecision] / a), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.7 \cdot 10^{-308}:\\
\;\;\;\;\frac{\frac{-2 \cdot b}{3}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < 1.7000000000000002e-308Initial program 72.9%
Applied rewrites72.9%
Applied rewrites72.9%
Taylor expanded in b around -inf
lift-neg.f64N/A
+-commutativeN/A
lift-neg.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
pow2N/A
+-commutativeN/A
metadata-evalN/A
fp-cancel-sub-sign-invN/A
associate-*r*N/A
pow2N/A
lower-*.f6467.7
Applied rewrites67.7%
if 1.7000000000000002e-308 < b Initial program 33.0%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6466.5
Applied rewrites66.5%
(FPCore (a b c) :precision binary64 (if (<= b 1.7e-308) (/ (* -2.0 b) (* 3.0 a)) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.7e-308) {
tmp = (-2.0 * b) / (3.0 * a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= 1.7d-308) then
tmp = ((-2.0d0) * b) / (3.0d0 * a)
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 1.7e-308) {
tmp = (-2.0 * b) / (3.0 * a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.7e-308: tmp = (-2.0 * b) / (3.0 * a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.7e-308) tmp = Float64(Float64(-2.0 * b) / Float64(3.0 * a)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 1.7e-308) tmp = (-2.0 * b) / (3.0 * a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.7e-308], N[(N[(-2.0 * b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.7 \cdot 10^{-308}:\\
\;\;\;\;\frac{-2 \cdot b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < 1.7000000000000002e-308Initial program 72.9%
Taylor expanded in b around -inf
lower-*.f6467.7
Applied rewrites67.7%
if 1.7000000000000002e-308 < b Initial program 33.0%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6466.5
Applied rewrites66.5%
(FPCore (a b c) :precision binary64 (if (<= b 1.7e-308) (* -0.6666666666666666 (/ b a)) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.7e-308) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= 1.7d-308) then
tmp = (-0.6666666666666666d0) * (b / a)
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 1.7e-308) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.7e-308: tmp = -0.6666666666666666 * (b / a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.7e-308) tmp = Float64(-0.6666666666666666 * Float64(b / a)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 1.7e-308) tmp = -0.6666666666666666 * (b / a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.7e-308], N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.7 \cdot 10^{-308}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < 1.7000000000000002e-308Initial program 72.9%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6467.6
Applied rewrites67.6%
if 1.7000000000000002e-308 < b Initial program 33.0%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6466.5
Applied rewrites66.5%
(FPCore (a b c) :precision binary64 (* -0.6666666666666666 (/ b a)))
double code(double a, double b, double c) {
return -0.6666666666666666 * (b / a);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-0.6666666666666666d0) * (b / a)
end function
public static double code(double a, double b, double c) {
return -0.6666666666666666 * (b / a);
}
def code(a, b, c): return -0.6666666666666666 * (b / a)
function code(a, b, c) return Float64(-0.6666666666666666 * Float64(b / a)) end
function tmp = code(a, b, c) tmp = -0.6666666666666666 * (b / a); end
code[a_, b_, c_] := N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-0.6666666666666666 \cdot \frac{b}{a}
\end{array}
Initial program 52.7%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6434.7
Applied rewrites34.7%
herbie shell --seed 2025117
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))