
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.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) - ((4.0d0 * a) * c)))) / (2.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c)))) / Float64(2.0 * a)) end
function tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a); end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(4 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2 * a), $MachinePrecision]), $MachinePrecision]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.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) - ((4.0d0 * a) * c)))) / (2.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c)))) / Float64(2.0 * a)) end
function tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a); end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(4 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2 * a), $MachinePrecision]), $MachinePrecision]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
(FPCore (a b c) :precision binary64 (- (/ (- (* (* (* (* a a) c) c) (* c (* -2 (pow b -4)))) c) b) (/ (- (* (* (/ a (* b b)) c) c) (* (/ -5 (* (pow b 6) a)) (pow (* c a) 4))) b)))
double code(double a, double b, double c) {
return ((((((a * a) * c) * c) * (c * (-2.0 * pow(b, -4.0)))) - c) / b) - (((((a / (b * b)) * c) * c) - ((-5.0 / (pow(b, 6.0) * a)) * pow((c * a), 4.0))) / b);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = ((((((a * a) * c) * c) * (c * ((-2.0d0) * (b ** (-4.0d0))))) - c) / b) - (((((a / (b * b)) * c) * c) - (((-5.0d0) / ((b ** 6.0d0) * a)) * ((c * a) ** 4.0d0))) / b)
end function
public static double code(double a, double b, double c) {
return ((((((a * a) * c) * c) * (c * (-2.0 * Math.pow(b, -4.0)))) - c) / b) - (((((a / (b * b)) * c) * c) - ((-5.0 / (Math.pow(b, 6.0) * a)) * Math.pow((c * a), 4.0))) / b);
}
def code(a, b, c): return ((((((a * a) * c) * c) * (c * (-2.0 * math.pow(b, -4.0)))) - c) / b) - (((((a / (b * b)) * c) * c) - ((-5.0 / (math.pow(b, 6.0) * a)) * math.pow((c * a), 4.0))) / b)
function code(a, b, c) return Float64(Float64(Float64(Float64(Float64(Float64(Float64(a * a) * c) * c) * Float64(c * Float64(-2.0 * (b ^ -4.0)))) - c) / b) - Float64(Float64(Float64(Float64(Float64(a / Float64(b * b)) * c) * c) - Float64(Float64(-5.0 / Float64((b ^ 6.0) * a)) * (Float64(c * a) ^ 4.0))) / b)) end
function tmp = code(a, b, c) tmp = ((((((a * a) * c) * c) * (c * (-2.0 * (b ^ -4.0)))) - c) / b) - (((((a / (b * b)) * c) * c) - ((-5.0 / ((b ^ 6.0) * a)) * ((c * a) ^ 4.0))) / b); end
code[a_, b_, c_] := N[(N[(N[(N[(N[(N[(N[(a * a), $MachinePrecision] * c), $MachinePrecision] * c), $MachinePrecision] * N[(c * N[(-2 * N[Power[b, -4], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - c), $MachinePrecision] / b), $MachinePrecision] - N[(N[(N[(N[(N[(a / N[(b * b), $MachinePrecision]), $MachinePrecision] * c), $MachinePrecision] * c), $MachinePrecision] - N[(N[(-5 / N[(N[Power[b, 6], $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] * N[Power[N[(c * a), $MachinePrecision], 4], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision]
\frac{\left(\left(\left(a \cdot a\right) \cdot c\right) \cdot c\right) \cdot \left(c \cdot \left(-2 \cdot {b}^{-4}\right)\right) - c}{b} - \frac{\left(\frac{a}{b \cdot b} \cdot c\right) \cdot c - \frac{-5}{{b}^{6} \cdot a} \cdot {\left(c \cdot a\right)}^{4}}{b}
Initial program 30.9%
Taylor expanded in b around inf
Applied rewrites95.7%
Applied rewrites95.7%
Applied rewrites95.7%
(FPCore (a b c) :precision binary64 (- (/ (- (* (* (* (* (pow b -4) -2) c) c) (* (* a a) c)) c) b) (- (* c (* (/ c (* (* b b) b)) a)) (/ (* (pow (* c a) 4) -5) (* (* (pow b 6) a) b)))))
double code(double a, double b, double c) {
return ((((((pow(b, -4.0) * -2.0) * c) * c) * ((a * a) * c)) - c) / b) - ((c * ((c / ((b * b) * b)) * a)) - ((pow((c * a), 4.0) * -5.0) / ((pow(b, 6.0) * a) * b)));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (((((((b ** (-4.0d0)) * (-2.0d0)) * c) * c) * ((a * a) * c)) - c) / b) - ((c * ((c / ((b * b) * b)) * a)) - ((((c * a) ** 4.0d0) * (-5.0d0)) / (((b ** 6.0d0) * a) * b)))
end function
public static double code(double a, double b, double c) {
return ((((((Math.pow(b, -4.0) * -2.0) * c) * c) * ((a * a) * c)) - c) / b) - ((c * ((c / ((b * b) * b)) * a)) - ((Math.pow((c * a), 4.0) * -5.0) / ((Math.pow(b, 6.0) * a) * b)));
}
def code(a, b, c): return ((((((math.pow(b, -4.0) * -2.0) * c) * c) * ((a * a) * c)) - c) / b) - ((c * ((c / ((b * b) * b)) * a)) - ((math.pow((c * a), 4.0) * -5.0) / ((math.pow(b, 6.0) * a) * b)))
function code(a, b, c) return Float64(Float64(Float64(Float64(Float64(Float64(Float64((b ^ -4.0) * -2.0) * c) * c) * Float64(Float64(a * a) * c)) - c) / b) - Float64(Float64(c * Float64(Float64(c / Float64(Float64(b * b) * b)) * a)) - Float64(Float64((Float64(c * a) ^ 4.0) * -5.0) / Float64(Float64((b ^ 6.0) * a) * b)))) end
function tmp = code(a, b, c) tmp = (((((((b ^ -4.0) * -2.0) * c) * c) * ((a * a) * c)) - c) / b) - ((c * ((c / ((b * b) * b)) * a)) - ((((c * a) ^ 4.0) * -5.0) / (((b ^ 6.0) * a) * b))); end
code[a_, b_, c_] := N[(N[(N[(N[(N[(N[(N[(N[Power[b, -4], $MachinePrecision] * -2), $MachinePrecision] * c), $MachinePrecision] * c), $MachinePrecision] * N[(N[(a * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision] - c), $MachinePrecision] / b), $MachinePrecision] - N[(N[(c * N[(N[(c / N[(N[(b * b), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] - N[(N[(N[Power[N[(c * a), $MachinePrecision], 4], $MachinePrecision] * -5), $MachinePrecision] / N[(N[(N[Power[b, 6], $MachinePrecision] * a), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{\left(\left(\left({b}^{-4} \cdot -2\right) \cdot c\right) \cdot c\right) \cdot \left(\left(a \cdot a\right) \cdot c\right) - c}{b} - \left(c \cdot \left(\frac{c}{\left(b \cdot b\right) \cdot b} \cdot a\right) - \frac{{\left(c \cdot a\right)}^{4} \cdot -5}{\left({b}^{6} \cdot a\right) \cdot b}\right)
Initial program 30.9%
Taylor expanded in b around inf
Applied rewrites95.7%
Applied rewrites95.7%
Applied rewrites95.7%
Applied rewrites95.7%
(FPCore (a b c)
:precision binary64
(/
(-
(- c)
(-
(+
(* 1/4 (* (pow (* c a) 4) (/ 20 (* (pow b 6) a))))
(* (* c c) (/ a (* b b))))
(* (* (* (* a a) c) (* c c)) (* (pow b -4) -2))))
b))double code(double a, double b, double c) {
return (-c - (((0.25 * (pow((c * a), 4.0) * (20.0 / (pow(b, 6.0) * a)))) + ((c * c) * (a / (b * b)))) - ((((a * a) * c) * (c * c)) * (pow(b, -4.0) * -2.0)))) / b;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-c - (((0.25d0 * (((c * a) ** 4.0d0) * (20.0d0 / ((b ** 6.0d0) * a)))) + ((c * c) * (a / (b * b)))) - ((((a * a) * c) * (c * c)) * ((b ** (-4.0d0)) * (-2.0d0))))) / b
end function
public static double code(double a, double b, double c) {
return (-c - (((0.25 * (Math.pow((c * a), 4.0) * (20.0 / (Math.pow(b, 6.0) * a)))) + ((c * c) * (a / (b * b)))) - ((((a * a) * c) * (c * c)) * (Math.pow(b, -4.0) * -2.0)))) / b;
}
def code(a, b, c): return (-c - (((0.25 * (math.pow((c * a), 4.0) * (20.0 / (math.pow(b, 6.0) * a)))) + ((c * c) * (a / (b * b)))) - ((((a * a) * c) * (c * c)) * (math.pow(b, -4.0) * -2.0)))) / b
function code(a, b, c) return Float64(Float64(Float64(-c) - Float64(Float64(Float64(0.25 * Float64((Float64(c * a) ^ 4.0) * Float64(20.0 / Float64((b ^ 6.0) * a)))) + Float64(Float64(c * c) * Float64(a / Float64(b * b)))) - Float64(Float64(Float64(Float64(a * a) * c) * Float64(c * c)) * Float64((b ^ -4.0) * -2.0)))) / b) end
function tmp = code(a, b, c) tmp = (-c - (((0.25 * (((c * a) ^ 4.0) * (20.0 / ((b ^ 6.0) * a)))) + ((c * c) * (a / (b * b)))) - ((((a * a) * c) * (c * c)) * ((b ^ -4.0) * -2.0)))) / b; end
code[a_, b_, c_] := N[(N[((-c) - N[(N[(N[(1/4 * N[(N[Power[N[(c * a), $MachinePrecision], 4], $MachinePrecision] * N[(20 / N[(N[Power[b, 6], $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(c * c), $MachinePrecision] * N[(a / N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(N[(a * a), $MachinePrecision] * c), $MachinePrecision] * N[(c * c), $MachinePrecision]), $MachinePrecision] * N[(N[Power[b, -4], $MachinePrecision] * -2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision]
\frac{\left(-c\right) - \left(\left(\frac{1}{4} \cdot \left({\left(c \cdot a\right)}^{4} \cdot \frac{20}{{b}^{6} \cdot a}\right) + \left(c \cdot c\right) \cdot \frac{a}{b \cdot b}\right) - \left(\left(\left(a \cdot a\right) \cdot c\right) \cdot \left(c \cdot c\right)\right) \cdot \left({b}^{-4} \cdot -2\right)\right)}{b}
Initial program 30.9%
Taylor expanded in b around inf
Applied rewrites95.7%
Applied rewrites95.7%
(FPCore (a b c) :precision binary64 (/ (- (+ (- (* (* (* (* a a) c) c) (* c (* -2 (pow b -4)))) c) (* (/ -5 (* (pow b 6) a)) (pow (* c a) 4))) (* (* (/ a (* b b)) c) c)) b))
double code(double a, double b, double c) {
return (((((((a * a) * c) * c) * (c * (-2.0 * pow(b, -4.0)))) - c) + ((-5.0 / (pow(b, 6.0) * a)) * pow((c * a), 4.0))) - (((a / (b * b)) * c) * c)) / b;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (((((((a * a) * c) * c) * (c * ((-2.0d0) * (b ** (-4.0d0))))) - c) + (((-5.0d0) / ((b ** 6.0d0) * a)) * ((c * a) ** 4.0d0))) - (((a / (b * b)) * c) * c)) / b
end function
public static double code(double a, double b, double c) {
return (((((((a * a) * c) * c) * (c * (-2.0 * Math.pow(b, -4.0)))) - c) + ((-5.0 / (Math.pow(b, 6.0) * a)) * Math.pow((c * a), 4.0))) - (((a / (b * b)) * c) * c)) / b;
}
def code(a, b, c): return (((((((a * a) * c) * c) * (c * (-2.0 * math.pow(b, -4.0)))) - c) + ((-5.0 / (math.pow(b, 6.0) * a)) * math.pow((c * a), 4.0))) - (((a / (b * b)) * c) * c)) / b
function code(a, b, c) return Float64(Float64(Float64(Float64(Float64(Float64(Float64(Float64(a * a) * c) * c) * Float64(c * Float64(-2.0 * (b ^ -4.0)))) - c) + Float64(Float64(-5.0 / Float64((b ^ 6.0) * a)) * (Float64(c * a) ^ 4.0))) - Float64(Float64(Float64(a / Float64(b * b)) * c) * c)) / b) end
function tmp = code(a, b, c) tmp = (((((((a * a) * c) * c) * (c * (-2.0 * (b ^ -4.0)))) - c) + ((-5.0 / ((b ^ 6.0) * a)) * ((c * a) ^ 4.0))) - (((a / (b * b)) * c) * c)) / b; end
code[a_, b_, c_] := N[(N[(N[(N[(N[(N[(N[(N[(a * a), $MachinePrecision] * c), $MachinePrecision] * c), $MachinePrecision] * N[(c * N[(-2 * N[Power[b, -4], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - c), $MachinePrecision] + N[(N[(-5 / N[(N[Power[b, 6], $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] * N[Power[N[(c * a), $MachinePrecision], 4], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(a / N[(b * b), $MachinePrecision]), $MachinePrecision] * c), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision]
\frac{\left(\left(\left(\left(\left(a \cdot a\right) \cdot c\right) \cdot c\right) \cdot \left(c \cdot \left(-2 \cdot {b}^{-4}\right)\right) - c\right) + \frac{-5}{{b}^{6} \cdot a} \cdot {\left(c \cdot a\right)}^{4}\right) - \left(\frac{a}{b \cdot b} \cdot c\right) \cdot c}{b}
Initial program 30.9%
Taylor expanded in b around inf
Applied rewrites95.7%
Applied rewrites95.7%
Applied rewrites95.7%
(FPCore (a b c) :precision binary64 (+ (* c (* (- (* (* -2 (* a a)) (* c (pow b -5))) (/ a (* (* b b) b))) c)) (/ c (- b))))
double code(double a, double b, double c) {
return (c * ((((-2.0 * (a * a)) * (c * pow(b, -5.0))) - (a / ((b * b) * b))) * c)) + (c / -b);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (c * (((((-2.0d0) * (a * a)) * (c * (b ** (-5.0d0)))) - (a / ((b * b) * b))) * c)) + (c / -b)
end function
public static double code(double a, double b, double c) {
return (c * ((((-2.0 * (a * a)) * (c * Math.pow(b, -5.0))) - (a / ((b * b) * b))) * c)) + (c / -b);
}
def code(a, b, c): return (c * ((((-2.0 * (a * a)) * (c * math.pow(b, -5.0))) - (a / ((b * b) * b))) * c)) + (c / -b)
function code(a, b, c) return Float64(Float64(c * Float64(Float64(Float64(Float64(-2.0 * Float64(a * a)) * Float64(c * (b ^ -5.0))) - Float64(a / Float64(Float64(b * b) * b))) * c)) + Float64(c / Float64(-b))) end
function tmp = code(a, b, c) tmp = (c * ((((-2.0 * (a * a)) * (c * (b ^ -5.0))) - (a / ((b * b) * b))) * c)) + (c / -b); end
code[a_, b_, c_] := N[(N[(c * N[(N[(N[(N[(-2 * N[(a * a), $MachinePrecision]), $MachinePrecision] * N[(c * N[Power[b, -5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(a / N[(N[(b * b), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision] + N[(c / (-b)), $MachinePrecision]), $MachinePrecision]
c \cdot \left(\left(\left(-2 \cdot \left(a \cdot a\right)\right) \cdot \left(c \cdot {b}^{-5}\right) - \frac{a}{\left(b \cdot b\right) \cdot b}\right) \cdot c\right) + \frac{c}{-b}
Initial program 30.9%
Taylor expanded in b around inf
Applied rewrites95.7%
Taylor expanded in c around 0
lower-*.f64N/A
lower--.f64N/A
Applied rewrites94.0%
Applied rewrites94.3%
(FPCore (a b c) :precision binary64 (* (- (* (- (* (* -2 (* a a)) (* c (pow b -5))) (/ a (* (* b b) b))) c) (/ 1 b)) c))
double code(double a, double b, double c) {
return (((((-2.0 * (a * a)) * (c * pow(b, -5.0))) - (a / ((b * b) * b))) * c) - (1.0 / b)) * c;
}
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 = ((((((-2.0d0) * (a * a)) * (c * (b ** (-5.0d0)))) - (a / ((b * b) * b))) * c) - (1.0d0 / b)) * c
end function
public static double code(double a, double b, double c) {
return (((((-2.0 * (a * a)) * (c * Math.pow(b, -5.0))) - (a / ((b * b) * b))) * c) - (1.0 / b)) * c;
}
def code(a, b, c): return (((((-2.0 * (a * a)) * (c * math.pow(b, -5.0))) - (a / ((b * b) * b))) * c) - (1.0 / b)) * c
function code(a, b, c) return Float64(Float64(Float64(Float64(Float64(Float64(-2.0 * Float64(a * a)) * Float64(c * (b ^ -5.0))) - Float64(a / Float64(Float64(b * b) * b))) * c) - Float64(1.0 / b)) * c) end
function tmp = code(a, b, c) tmp = (((((-2.0 * (a * a)) * (c * (b ^ -5.0))) - (a / ((b * b) * b))) * c) - (1.0 / b)) * c; end
code[a_, b_, c_] := N[(N[(N[(N[(N[(N[(-2 * N[(a * a), $MachinePrecision]), $MachinePrecision] * N[(c * N[Power[b, -5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(a / N[(N[(b * b), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * c), $MachinePrecision] - N[(1 / b), $MachinePrecision]), $MachinePrecision] * c), $MachinePrecision]
\left(\left(\left(-2 \cdot \left(a \cdot a\right)\right) \cdot \left(c \cdot {b}^{-5}\right) - \frac{a}{\left(b \cdot b\right) \cdot b}\right) \cdot c - \frac{1}{b}\right) \cdot c
Initial program 30.9%
Taylor expanded in b around inf
Applied rewrites95.7%
Taylor expanded in c around 0
lower-*.f64N/A
lower--.f64N/A
Applied rewrites94.0%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6494.0%
Applied rewrites94.0%
(FPCore (a b c)
:precision binary64
(if (<=
(/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a))
-200000)
(/
(/
(- (- (* b b) (* c (* a 4))) (* b b))
(+ (4-sqrtz0z0z1z24 b c a) b))
(* 2 a))
(+ (* (* (- a) (/ c (* (* b b) b))) c) (/ c (- b)))))\begin{array}{l}
\mathbf{if}\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \leq -200000:\\
\;\;\;\;\frac{\frac{\left(b \cdot b - c \cdot \left(a \cdot 4\right)\right) - b \cdot b}{\mathsf{4\_sqrtz0z0z1z24}\left(b, c, a\right) + b}}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(-a\right) \cdot \frac{c}{\left(b \cdot b\right) \cdot b}\right) \cdot c + \frac{c}{-b}\\
\end{array}
if (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a)) < -2e5Initial program 30.9%
Applied rewrites31.9%
if -2e5 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a)) Initial program 30.9%
Taylor expanded in b around inf
Applied rewrites95.7%
Taylor expanded in c around 0
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower-/.f6490.9%
Applied rewrites90.9%
lift-*.f64N/A
lift--.f64N/A
*-lft-identityN/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
lift-/.f64N/A
mult-flipN/A
lift-/.f64N/A
distribute-rgt-inN/A
*-commutativeN/A
lift-*.f64N/A
lower-+.f64N/A
Applied rewrites91.2%
(FPCore (a b c)
:precision binary64
(if (<=
(/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a))
-200000)
(134-z0z1z2z3z4
1
(* (4-sqrtz0z0z1z24 b c a) (/ 1 a))
1/2
b
(/ 1/2 a))
(+ (* (* (- a) (/ c (* (* b b) b))) c) (/ c (- b)))))\begin{array}{l}
\mathbf{if}\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \leq -200000:\\
\;\;\;\;\mathsf{134\_z0z1z2z3z4}\left(1, \left(\mathsf{4\_sqrtz0z0z1z24}\left(b, c, a\right) \cdot \frac{1}{a}\right), \frac{1}{2}, b, \left(\frac{\frac{1}{2}}{a}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(-a\right) \cdot \frac{c}{\left(b \cdot b\right) \cdot b}\right) \cdot c + \frac{c}{-b}\\
\end{array}
if (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a)) < -2e5Initial program 30.9%
Applied rewrites32.3%
lift-/.f64N/A
mult-flipN/A
lower-*.f64N/A
lower-/.f6432.5%
Applied rewrites32.5%
if -2e5 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a)) Initial program 30.9%
Taylor expanded in b around inf
Applied rewrites95.7%
Taylor expanded in c around 0
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower-/.f6490.9%
Applied rewrites90.9%
lift-*.f64N/A
lift--.f64N/A
*-lft-identityN/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
lift-/.f64N/A
mult-flipN/A
lift-/.f64N/A
distribute-rgt-inN/A
*-commutativeN/A
lift-*.f64N/A
lower-+.f64N/A
Applied rewrites91.2%
(FPCore (a b c)
:precision binary64
(if (<=
(/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a))
-200000)
(/ 1 (/ (+ a a) (- (4-sqrtz0z0z1z24 b c a) b)))
(+ (* (* (- a) (/ c (* (* b b) b))) c) (/ c (- b)))))\begin{array}{l}
\mathbf{if}\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \leq -200000:\\
\;\;\;\;\frac{1}{\frac{a + a}{\mathsf{4\_sqrtz0z0z1z24}\left(b, c, a\right) - b}}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(-a\right) \cdot \frac{c}{\left(b \cdot b\right) \cdot b}\right) \cdot c + \frac{c}{-b}\\
\end{array}
if (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a)) < -2e5Initial program 30.9%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6430.9%
lift-*.f64N/A
count-2-revN/A
lower-+.f6430.9%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
lower--.f64N/A
Applied rewrites31.1%
if -2e5 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a)) Initial program 30.9%
Taylor expanded in b around inf
Applied rewrites95.7%
Taylor expanded in c around 0
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower-/.f6490.9%
Applied rewrites90.9%
lift-*.f64N/A
lift--.f64N/A
*-lft-identityN/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
lift-/.f64N/A
mult-flipN/A
lift-/.f64N/A
distribute-rgt-inN/A
*-commutativeN/A
lift-*.f64N/A
lower-+.f64N/A
Applied rewrites91.2%
(FPCore (a b c)
:precision binary64
(if (<=
(/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a))
-200000)
(/ 1 (/ (+ a a) (- (4-sqrtz0z0z1z24 b c a) b)))
(* (- (* (- a) (/ c (* (* b b) b))) (/ 1 b)) c)))\begin{array}{l}
\mathbf{if}\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \leq -200000:\\
\;\;\;\;\frac{1}{\frac{a + a}{\mathsf{4\_sqrtz0z0z1z24}\left(b, c, a\right) - b}}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(-a\right) \cdot \frac{c}{\left(b \cdot b\right) \cdot b} - \frac{1}{b}\right) \cdot c\\
\end{array}
if (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a)) < -2e5Initial program 30.9%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6430.9%
lift-*.f64N/A
count-2-revN/A
lower-+.f6430.9%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
lower--.f64N/A
Applied rewrites31.1%
if -2e5 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a)) Initial program 30.9%
Taylor expanded in b around inf
Applied rewrites95.7%
Taylor expanded in c around 0
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower-/.f6490.9%
Applied rewrites90.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6490.9%
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-/.f6490.9%
lift-pow.f64N/A
unpow3N/A
lift-*.f64N/A
lower-*.f6490.9%
Applied rewrites90.9%
(FPCore (a b c)
:precision binary64
(if (<=
(/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a))
-5534023222112865/4611686018427387904)
(* (/ 1/2 a) (- (4-sqrtz0z0z1z24 b c a) b))
(/ (- c) b)))\begin{array}{l}
\mathbf{if}\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \leq \frac{-5534023222112865}{4611686018427387904}:\\
\;\;\;\;\frac{\frac{1}{2}}{a} \cdot \left(\mathsf{4\_sqrtz0z0z1z24}\left(b, c, a\right) - b\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
if (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a)) < -0.0011999999999999999Initial program 30.9%
Applied rewrites32.3%
Applied rewrites31.1%
if -0.0011999999999999999 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a)) Initial program 30.9%
Taylor expanded in b around inf
lower-*.f64N/A
lower-/.f6481.7%
Applied rewrites81.7%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
lower-/.f6481.7%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6481.7%
Applied rewrites81.7%
(FPCore (a b c)
:precision binary64
(if (<=
(/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a))
-5534023222112865/4611686018427387904)
(/ (- (4-sqrtz0z0z1z24 b c a) b) (+ a a))
(/ (- c) b)))\begin{array}{l}
\mathbf{if}\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \leq \frac{-5534023222112865}{4611686018427387904}:\\
\;\;\;\;\frac{\mathsf{4\_sqrtz0z0z1z24}\left(b, c, a\right) - b}{a + a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
if (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a)) < -0.0011999999999999999Initial program 30.9%
Applied rewrites32.3%
lift-/.f64N/A
mult-flipN/A
lower-*.f64N/A
lower-/.f6432.5%
Applied rewrites32.5%
Applied rewrites31.1%
if -0.0011999999999999999 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a)) Initial program 30.9%
Taylor expanded in b around inf
lower-*.f64N/A
lower-/.f6481.7%
Applied rewrites81.7%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
lower-/.f6481.7%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6481.7%
Applied rewrites81.7%
(FPCore (a b c) :precision binary64 (/ (- c) b))
double code(double a, double b, double c) {
return -c / b;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = -c / b
end function
public static double code(double a, double b, double c) {
return -c / b;
}
def code(a, b, c): return -c / b
function code(a, b, c) return Float64(Float64(-c) / b) end
function tmp = code(a, b, c) tmp = -c / b; end
code[a_, b_, c_] := N[((-c) / b), $MachinePrecision]
\frac{-c}{b}
Initial program 30.9%
Taylor expanded in b around inf
lower-*.f64N/A
lower-/.f6481.7%
Applied rewrites81.7%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
lower-/.f6481.7%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6481.7%
Applied rewrites81.7%
herbie shell --seed 2025271 -o generate:evaluate
(FPCore (a b c)
:name "Quadratic roots, medium range"
:precision binary64
:pre (and (and (and (< 2220446049250313/20000000000000000000000000000000 a) (< a 9007199254740992)) (and (< 2220446049250313/20000000000000000000000000000000 b) (< b 9007199254740992))) (and (< 2220446049250313/20000000000000000000000000000000 c) (< c 9007199254740992)))
(/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)))