
(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 12 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 -6.5e+133)
(/ (* -2.0 b) (* 3.0 a))
(if (<= b 8.6e-83)
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -6.5e+133) {
tmp = (-2.0 * b) / (3.0 * a);
} else if (b <= 8.6e-83) {
tmp = (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-6.5d+133)) then
tmp = ((-2.0d0) * b) / (3.0d0 * a)
else if (b <= 8.6d-83) then
tmp = (-b + sqrt(((b * b) - ((3.0d0 * a) * c)))) / (3.0d0 * a)
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -6.5e+133) {
tmp = (-2.0 * b) / (3.0 * a);
} else if (b <= 8.6e-83) {
tmp = (-b + Math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -6.5e+133: tmp = (-2.0 * b) / (3.0 * a) elif b <= 8.6e-83: tmp = (-b + math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -6.5e+133) tmp = Float64(Float64(-2.0 * b) / Float64(3.0 * a)); elseif (b <= 8.6e-83) tmp = Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c)))) / Float64(3.0 * a)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -6.5e+133) tmp = (-2.0 * b) / (3.0 * a); elseif (b <= 8.6e-83) tmp = (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -6.5e+133], N[(N[(-2.0 * b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 8.6e-83], N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -6.5 \cdot 10^{+133}:\\
\;\;\;\;\frac{-2 \cdot b}{3 \cdot a}\\
\mathbf{elif}\;b \leq 8.6 \cdot 10^{-83}:\\
\;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -6.5000000000000004e133Initial program 46.8%
Taylor expanded in b around -inf
lower-*.f6497.0
Applied rewrites97.0%
if -6.5000000000000004e133 < b < 8.60000000000000066e-83Initial program 81.9%
if 8.60000000000000066e-83 < b Initial program 18.7%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6485.3
Applied rewrites85.3%
(FPCore (a b c)
:precision binary64
(if (<= b -6.5e+133)
(/ (* -2.0 b) (* 3.0 a))
(if (<= b 8.6e-83)
(/ (+ (sqrt (fma (* -3.0 a) c (* b b))) (- b)) (* 3.0 a))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -6.5e+133) {
tmp = (-2.0 * b) / (3.0 * a);
} else if (b <= 8.6e-83) {
tmp = (sqrt(fma((-3.0 * a), c, (b * b))) + -b) / (3.0 * a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -6.5e+133) tmp = Float64(Float64(-2.0 * b) / Float64(3.0 * a)); elseif (b <= 8.6e-83) tmp = Float64(Float64(sqrt(fma(Float64(-3.0 * a), c, Float64(b * b))) + Float64(-b)) / Float64(3.0 * a)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -6.5e+133], N[(N[(-2.0 * b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 8.6e-83], N[(N[(N[Sqrt[N[(N[(-3.0 * a), $MachinePrecision] * c + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + (-b)), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -6.5 \cdot 10^{+133}:\\
\;\;\;\;\frac{-2 \cdot b}{3 \cdot a}\\
\mathbf{elif}\;b \leq 8.6 \cdot 10^{-83}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(-3 \cdot a, c, b \cdot b\right)} + \left(-b\right)}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -6.5000000000000004e133Initial program 46.8%
Taylor expanded in b around -inf
lower-*.f6497.0
Applied rewrites97.0%
if -6.5000000000000004e133 < b < 8.60000000000000066e-83Initial program 81.9%
lift-neg.f64N/A
lift-+.f64N/A
lift-sqrt.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
Applied rewrites81.9%
if 8.60000000000000066e-83 < b Initial program 18.7%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6485.3
Applied rewrites85.3%
(FPCore (a b c)
:precision binary64
(if (<= b -5.6e-25)
(/ (* -2.0 b) (* 3.0 a))
(if (<= b 8.6e-83)
(/ (+ (- 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 <= -5.6e-25) {
tmp = (-2.0 * b) / (3.0 * a);
} else if (b <= 8.6e-83) {
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 <= (-5.6d-25)) then
tmp = ((-2.0d0) * b) / (3.0d0 * a)
else if (b <= 8.6d-83) 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 <= -5.6e-25) {
tmp = (-2.0 * b) / (3.0 * a);
} else if (b <= 8.6e-83) {
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 <= -5.6e-25: tmp = (-2.0 * b) / (3.0 * a) elif b <= 8.6e-83: 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 <= -5.6e-25) tmp = Float64(Float64(-2.0 * b) / Float64(3.0 * a)); elseif (b <= 8.6e-83) 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 <= -5.6e-25) tmp = (-2.0 * b) / (3.0 * a); elseif (b <= 8.6e-83) 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, -5.6e-25], N[(N[(-2.0 * b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 8.6e-83], 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 -5.6 \cdot 10^{-25}:\\
\;\;\;\;\frac{-2 \cdot b}{3 \cdot a}\\
\mathbf{elif}\;b \leq 8.6 \cdot 10^{-83}:\\
\;\;\;\;\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 < -5.59999999999999976e-25Initial program 67.5%
Taylor expanded in b around -inf
lower-*.f6490.0
Applied rewrites90.0%
if -5.59999999999999976e-25 < b < 8.60000000000000066e-83Initial program 76.9%
Taylor expanded in a around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f6465.7
Applied rewrites65.7%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6465.8
Applied rewrites65.8%
if 8.60000000000000066e-83 < b Initial program 18.7%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6485.3
Applied rewrites85.3%
(FPCore (a b c)
:precision binary64
(if (<= b -5.6e-25)
(/ (* -2.0 b) (* 3.0 a))
(if (<= b 8.6e-83)
(/ (+ (- 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 <= -5.6e-25) {
tmp = (-2.0 * b) / (3.0 * a);
} else if (b <= 8.6e-83) {
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 <= (-5.6d-25)) then
tmp = ((-2.0d0) * b) / (3.0d0 * a)
else if (b <= 8.6d-83) 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 <= -5.6e-25) {
tmp = (-2.0 * b) / (3.0 * a);
} else if (b <= 8.6e-83) {
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 <= -5.6e-25: tmp = (-2.0 * b) / (3.0 * a) elif b <= 8.6e-83: 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 <= -5.6e-25) tmp = Float64(Float64(-2.0 * b) / Float64(3.0 * a)); elseif (b <= 8.6e-83) 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 <= -5.6e-25) tmp = (-2.0 * b) / (3.0 * a); elseif (b <= 8.6e-83) 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, -5.6e-25], N[(N[(-2.0 * b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 8.6e-83], 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 -5.6 \cdot 10^{-25}:\\
\;\;\;\;\frac{-2 \cdot b}{3 \cdot a}\\
\mathbf{elif}\;b \leq 8.6 \cdot 10^{-83}:\\
\;\;\;\;\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 < -5.59999999999999976e-25Initial program 67.5%
Taylor expanded in b around -inf
lower-*.f6490.0
Applied rewrites90.0%
if -5.59999999999999976e-25 < b < 8.60000000000000066e-83Initial program 76.9%
Taylor expanded in a around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f6465.7
Applied rewrites65.7%
if 8.60000000000000066e-83 < b Initial program 18.7%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6485.3
Applied rewrites85.3%
(FPCore (a b c)
:precision binary64
(if (<= b -7.5e-65)
(/ (* -2.0 b) (* 3.0 a))
(if (<= b 8.6e-83)
(/ (* (sqrt (* (* c a) -3.0)) 0.3333333333333333) a)
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -7.5e-65) {
tmp = (-2.0 * b) / (3.0 * a);
} else if (b <= 8.6e-83) {
tmp = (sqrt(((c * a) * -3.0)) * 0.3333333333333333) / 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 <= (-7.5d-65)) then
tmp = ((-2.0d0) * b) / (3.0d0 * a)
else if (b <= 8.6d-83) then
tmp = (sqrt(((c * a) * (-3.0d0))) * 0.3333333333333333d0) / 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 <= -7.5e-65) {
tmp = (-2.0 * b) / (3.0 * a);
} else if (b <= 8.6e-83) {
tmp = (Math.sqrt(((c * a) * -3.0)) * 0.3333333333333333) / a;
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -7.5e-65: tmp = (-2.0 * b) / (3.0 * a) elif b <= 8.6e-83: tmp = (math.sqrt(((c * a) * -3.0)) * 0.3333333333333333) / a else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -7.5e-65) tmp = Float64(Float64(-2.0 * b) / Float64(3.0 * a)); elseif (b <= 8.6e-83) tmp = Float64(Float64(sqrt(Float64(Float64(c * a) * -3.0)) * 0.3333333333333333) / 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 <= -7.5e-65) tmp = (-2.0 * b) / (3.0 * a); elseif (b <= 8.6e-83) tmp = (sqrt(((c * a) * -3.0)) * 0.3333333333333333) / a; else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -7.5e-65], N[(N[(-2.0 * b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 8.6e-83], N[(N[(N[Sqrt[N[(N[(c * a), $MachinePrecision] * -3.0), $MachinePrecision]], $MachinePrecision] * 0.3333333333333333), $MachinePrecision] / a), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -7.5 \cdot 10^{-65}:\\
\;\;\;\;\frac{-2 \cdot b}{3 \cdot a}\\
\mathbf{elif}\;b \leq 8.6 \cdot 10^{-83}:\\
\;\;\;\;\frac{\sqrt{\left(c \cdot a\right) \cdot -3} \cdot 0.3333333333333333}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -7.5000000000000002e-65Initial program 69.5%
Taylor expanded in b around -inf
lower-*.f6487.1
Applied rewrites87.1%
if -7.5000000000000002e-65 < b < 8.60000000000000066e-83Initial program 75.5%
lift-*.f64N/A
lift-/.f64N/A
lift-neg.f64N/A
lift-+.f64N/A
lift-sqrt.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites75.4%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
sqrt-unprodN/A
*-commutativeN/A
lower-sqrt.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lift-*.f6466.4
Applied rewrites66.4%
if 8.60000000000000066e-83 < b Initial program 18.7%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6485.3
Applied rewrites85.3%
(FPCore (a b c) :precision binary64 (if (<= b -7.5e-65) (/ (* -2.0 b) (* 3.0 a)) (if (<= b 8.6e-83) (/ (sqrt (* (* -3.0 a) c)) (* 3.0 a)) (* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -7.5e-65) {
tmp = (-2.0 * b) / (3.0 * a);
} else if (b <= 8.6e-83) {
tmp = sqrt(((-3.0 * a) * c)) / (3.0 * a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-7.5d-65)) then
tmp = ((-2.0d0) * b) / (3.0d0 * a)
else if (b <= 8.6d-83) then
tmp = sqrt((((-3.0d0) * a) * c)) / (3.0d0 * a)
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -7.5e-65) {
tmp = (-2.0 * b) / (3.0 * a);
} else if (b <= 8.6e-83) {
tmp = Math.sqrt(((-3.0 * a) * c)) / (3.0 * a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -7.5e-65: tmp = (-2.0 * b) / (3.0 * a) elif b <= 8.6e-83: tmp = math.sqrt(((-3.0 * a) * c)) / (3.0 * a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -7.5e-65) tmp = Float64(Float64(-2.0 * b) / Float64(3.0 * a)); elseif (b <= 8.6e-83) tmp = Float64(sqrt(Float64(Float64(-3.0 * a) * c)) / Float64(3.0 * a)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -7.5e-65) tmp = (-2.0 * b) / (3.0 * a); elseif (b <= 8.6e-83) tmp = sqrt(((-3.0 * a) * c)) / (3.0 * a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -7.5e-65], N[(N[(-2.0 * b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 8.6e-83], N[(N[Sqrt[N[(N[(-3.0 * a), $MachinePrecision] * c), $MachinePrecision]], $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -7.5 \cdot 10^{-65}:\\
\;\;\;\;\frac{-2 \cdot b}{3 \cdot a}\\
\mathbf{elif}\;b \leq 8.6 \cdot 10^{-83}:\\
\;\;\;\;\frac{\sqrt{\left(-3 \cdot a\right) \cdot c}}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -7.5000000000000002e-65Initial program 69.5%
Taylor expanded in b around -inf
lower-*.f6487.1
Applied rewrites87.1%
if -7.5000000000000002e-65 < b < 8.60000000000000066e-83Initial program 75.5%
Taylor expanded in a around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f6467.9
Applied rewrites67.9%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6468.0
Applied rewrites68.0%
Taylor expanded in a around inf
sqrt-unprodN/A
*-commutativeN/A
associate-*r*N/A
lift-*.f64N/A
lift-*.f64N/A
lift-sqrt.f6466.5
Applied rewrites66.5%
if 8.60000000000000066e-83 < b Initial program 18.7%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6485.3
Applied rewrites85.3%
(FPCore (a b c) :precision binary64 (if (<= b -7.5e-65) (/ (* -2.0 b) (* 3.0 a)) (if (<= b 8.6e-83) (/ (sqrt (* -3.0 (* c a))) (* 3.0 a)) (* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -7.5e-65) {
tmp = (-2.0 * b) / (3.0 * a);
} else if (b <= 8.6e-83) {
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 <= (-7.5d-65)) then
tmp = ((-2.0d0) * b) / (3.0d0 * a)
else if (b <= 8.6d-83) 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 <= -7.5e-65) {
tmp = (-2.0 * b) / (3.0 * a);
} else if (b <= 8.6e-83) {
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 <= -7.5e-65: tmp = (-2.0 * b) / (3.0 * a) elif b <= 8.6e-83: 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 <= -7.5e-65) tmp = Float64(Float64(-2.0 * b) / Float64(3.0 * a)); elseif (b <= 8.6e-83) 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 <= -7.5e-65) tmp = (-2.0 * b) / (3.0 * a); elseif (b <= 8.6e-83) 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, -7.5e-65], N[(N[(-2.0 * b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 8.6e-83], 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 -7.5 \cdot 10^{-65}:\\
\;\;\;\;\frac{-2 \cdot b}{3 \cdot a}\\
\mathbf{elif}\;b \leq 8.6 \cdot 10^{-83}:\\
\;\;\;\;\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 < -7.5000000000000002e-65Initial program 69.5%
Taylor expanded in b around -inf
lower-*.f6487.1
Applied rewrites87.1%
if -7.5000000000000002e-65 < b < 8.60000000000000066e-83Initial program 75.5%
Taylor expanded in a around inf
sqrt-unprodN/A
*-commutativeN/A
lower-sqrt.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6466.4
Applied rewrites66.4%
if 8.60000000000000066e-83 < b Initial program 18.7%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6485.3
Applied rewrites85.3%
(FPCore (a b c)
:precision binary64
(if (<= b -2.8e-250)
(/ (* -2.0 b) (* 3.0 a))
(if (<= b 1.1e-108)
(* (sqrt (* (/ c a) -3.0)) 0.3333333333333333)
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.8e-250) {
tmp = (-2.0 * b) / (3.0 * a);
} else if (b <= 1.1e-108) {
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 <= (-2.8d-250)) then
tmp = ((-2.0d0) * b) / (3.0d0 * a)
else if (b <= 1.1d-108) 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 <= -2.8e-250) {
tmp = (-2.0 * b) / (3.0 * a);
} else if (b <= 1.1e-108) {
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 <= -2.8e-250: tmp = (-2.0 * b) / (3.0 * a) elif b <= 1.1e-108: 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 <= -2.8e-250) tmp = Float64(Float64(-2.0 * b) / Float64(3.0 * a)); elseif (b <= 1.1e-108) 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 <= -2.8e-250) tmp = (-2.0 * b) / (3.0 * a); elseif (b <= 1.1e-108) 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, -2.8e-250], N[(N[(-2.0 * b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.1e-108], 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 -2.8 \cdot 10^{-250}:\\
\;\;\;\;\frac{-2 \cdot b}{3 \cdot a}\\
\mathbf{elif}\;b \leq 1.1 \cdot 10^{-108}:\\
\;\;\;\;\sqrt{\frac{c}{a} \cdot -3} \cdot 0.3333333333333333\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -2.80000000000000028e-250Initial program 72.6%
Taylor expanded in b around -inf
lower-*.f6472.0
Applied rewrites72.0%
if -2.80000000000000028e-250 < b < 1.1000000000000001e-108Initial program 72.3%
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-/.f6436.1
Applied rewrites36.1%
if 1.1000000000000001e-108 < b Initial program 20.6%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6483.1
Applied rewrites83.1%
(FPCore (a b c)
:precision binary64
(if (<= b -2.4e-144)
(/ (* -2.0 b) (* 3.0 a))
(if (<= b 2e-84)
(* (sqrt (* c (/ -3.0 a))) -0.3333333333333333)
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.4e-144) {
tmp = (-2.0 * b) / (3.0 * a);
} else if (b <= 2e-84) {
tmp = sqrt((c * (-3.0 / 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 <= (-2.4d-144)) then
tmp = ((-2.0d0) * b) / (3.0d0 * a)
else if (b <= 2d-84) then
tmp = sqrt((c * ((-3.0d0) / 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 <= -2.4e-144) {
tmp = (-2.0 * b) / (3.0 * a);
} else if (b <= 2e-84) {
tmp = Math.sqrt((c * (-3.0 / a))) * -0.3333333333333333;
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.4e-144: tmp = (-2.0 * b) / (3.0 * a) elif b <= 2e-84: tmp = math.sqrt((c * (-3.0 / a))) * -0.3333333333333333 else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.4e-144) tmp = Float64(Float64(-2.0 * b) / Float64(3.0 * a)); elseif (b <= 2e-84) tmp = Float64(sqrt(Float64(c * Float64(-3.0 / 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 <= -2.4e-144) tmp = (-2.0 * b) / (3.0 * a); elseif (b <= 2e-84) tmp = sqrt((c * (-3.0 / a))) * -0.3333333333333333; else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.4e-144], N[(N[(-2.0 * b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2e-84], N[(N[Sqrt[N[(c * N[(-3.0 / a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * -0.3333333333333333), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.4 \cdot 10^{-144}:\\
\;\;\;\;\frac{-2 \cdot b}{3 \cdot a}\\
\mathbf{elif}\;b \leq 2 \cdot 10^{-84}:\\
\;\;\;\;\sqrt{c \cdot \frac{-3}{a}} \cdot -0.3333333333333333\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -2.39999999999999994e-144Initial program 72.5%
Taylor expanded in b around -inf
lower-*.f6480.4
Applied rewrites80.4%
if -2.39999999999999994e-144 < b < 2.0000000000000001e-84Initial program 72.0%
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-/.f6431.5
Applied rewrites31.5%
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6431.5
Applied rewrites31.5%
lift-*.f64N/A
lift-/.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6431.5
Applied rewrites31.5%
if 2.0000000000000001e-84 < b Initial program 18.9%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6485.1
Applied rewrites85.1%
(FPCore (a b c) :precision binary64 (if (<= b 1.25e-288) (/ (* -2.0 b) (* 3.0 a)) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.25e-288) {
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.25d-288) 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.25e-288) {
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.25e-288: 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.25e-288) 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.25e-288) 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.25e-288], 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.25 \cdot 10^{-288}:\\
\;\;\;\;\frac{-2 \cdot b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < 1.25000000000000003e-288Initial program 72.9%
Taylor expanded in b around -inf
lower-*.f6466.2
Applied rewrites66.2%
if 1.25000000000000003e-288 < b Initial program 31.2%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6469.4
Applied rewrites69.4%
(FPCore (a b c) :precision binary64 (if (<= b 1.25e-288) (* -0.6666666666666666 (/ b a)) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.25e-288) {
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.25d-288) 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.25e-288) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.25e-288: tmp = -0.6666666666666666 * (b / a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.25e-288) 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.25e-288) tmp = -0.6666666666666666 * (b / a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.25e-288], 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.25 \cdot 10^{-288}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < 1.25000000000000003e-288Initial program 72.9%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6466.2
Applied rewrites66.2%
if 1.25000000000000003e-288 < b Initial program 31.2%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6469.4
Applied rewrites69.4%
(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 51.9%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6434.3
Applied rewrites34.3%
herbie shell --seed 2025100
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))