
(FPCore (a b c) :precision binary64 (pow (/ (- (* 3.0 (* a c)) (pow b 2.0)) (* 9.0 (pow a 2.0))) 3.0))
double code(double a, double b, double c) {
return pow((((3.0 * (a * c)) - pow(b, 2.0)) / (9.0 * pow(a, 2.0))), 3.0);
}
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 = (((3.0d0 * (a * c)) - (b ** 2.0d0)) / (9.0d0 * (a ** 2.0d0))) ** 3.0d0
end function
public static double code(double a, double b, double c) {
return Math.pow((((3.0 * (a * c)) - Math.pow(b, 2.0)) / (9.0 * Math.pow(a, 2.0))), 3.0);
}
def code(a, b, c): return math.pow((((3.0 * (a * c)) - math.pow(b, 2.0)) / (9.0 * math.pow(a, 2.0))), 3.0)
function code(a, b, c) return Float64(Float64(Float64(3.0 * Float64(a * c)) - (b ^ 2.0)) / Float64(9.0 * (a ^ 2.0))) ^ 3.0 end
function tmp = code(a, b, c) tmp = (((3.0 * (a * c)) - (b ^ 2.0)) / (9.0 * (a ^ 2.0))) ^ 3.0; end
code[a_, b_, c_] := N[Power[N[(N[(N[(3.0 * N[(a * c), $MachinePrecision]), $MachinePrecision] - N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision] / N[(9.0 * N[Power[a, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 3.0], $MachinePrecision]
{\left(\frac{3 \cdot \left(a \cdot c\right) - {b}^{2}}{9 \cdot {a}^{2}}\right)}^{3}
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b c) :precision binary64 (pow (/ (- (* 3.0 (* a c)) (pow b 2.0)) (* 9.0 (pow a 2.0))) 3.0))
double code(double a, double b, double c) {
return pow((((3.0 * (a * c)) - pow(b, 2.0)) / (9.0 * pow(a, 2.0))), 3.0);
}
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 = (((3.0d0 * (a * c)) - (b ** 2.0d0)) / (9.0d0 * (a ** 2.0d0))) ** 3.0d0
end function
public static double code(double a, double b, double c) {
return Math.pow((((3.0 * (a * c)) - Math.pow(b, 2.0)) / (9.0 * Math.pow(a, 2.0))), 3.0);
}
def code(a, b, c): return math.pow((((3.0 * (a * c)) - math.pow(b, 2.0)) / (9.0 * math.pow(a, 2.0))), 3.0)
function code(a, b, c) return Float64(Float64(Float64(3.0 * Float64(a * c)) - (b ^ 2.0)) / Float64(9.0 * (a ^ 2.0))) ^ 3.0 end
function tmp = code(a, b, c) tmp = (((3.0 * (a * c)) - (b ^ 2.0)) / (9.0 * (a ^ 2.0))) ^ 3.0; end
code[a_, b_, c_] := N[Power[N[(N[(N[(3.0 * N[(a * c), $MachinePrecision]), $MachinePrecision] - N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision] / N[(9.0 * N[Power[a, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 3.0], $MachinePrecision]
{\left(\frac{3 \cdot \left(a \cdot c\right) - {b}^{2}}{9 \cdot {a}^{2}}\right)}^{3}
(FPCore (a b c)
:precision binary64
(let* ((t_0 (fma -3.0 c (* (/ b a) b))))
(*
(/ (* t_0 -0.1111111111111111) a)
(* (pow (/ t_0 a) 2.0) 0.012345679012345678))))double code(double a, double b, double c) {
double t_0 = fma(-3.0, c, ((b / a) * b));
return ((t_0 * -0.1111111111111111) / a) * (pow((t_0 / a), 2.0) * 0.012345679012345678);
}
function code(a, b, c) t_0 = fma(-3.0, c, Float64(Float64(b / a) * b)) return Float64(Float64(Float64(t_0 * -0.1111111111111111) / a) * Float64((Float64(t_0 / a) ^ 2.0) * 0.012345679012345678)) end
code[a_, b_, c_] := Block[{t$95$0 = N[(-3.0 * c + N[(N[(b / a), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[(t$95$0 * -0.1111111111111111), $MachinePrecision] / a), $MachinePrecision] * N[(N[Power[N[(t$95$0 / a), $MachinePrecision], 2.0], $MachinePrecision] * 0.012345679012345678), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
t_0 := \mathsf{fma}\left(-3, c, \frac{b}{a} \cdot b\right)\\
\frac{t\_0 \cdot -0.1111111111111111}{a} \cdot \left({\left(\frac{t\_0}{a}\right)}^{2} \cdot 0.012345679012345678\right)
\end{array}
Initial program 80.4%
lift-/.f64N/A
frac-2negN/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites80.4%
lift-pow.f64N/A
cube-multN/A
lower-*.f64N/A
Applied rewrites99.3%
(FPCore (a b c) :precision binary64 (let* ((t_0 (/ (fma -3.0 c (* (/ b a) b)) a))) (* (* (* (pow t_0 2.0) 0.012345679012345678) t_0) -0.1111111111111111)))
double code(double a, double b, double c) {
double t_0 = fma(-3.0, c, ((b / a) * b)) / a;
return ((pow(t_0, 2.0) * 0.012345679012345678) * t_0) * -0.1111111111111111;
}
function code(a, b, c) t_0 = Float64(fma(-3.0, c, Float64(Float64(b / a) * b)) / a) return Float64(Float64(Float64((t_0 ^ 2.0) * 0.012345679012345678) * t_0) * -0.1111111111111111) end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(-3.0 * c + N[(N[(b / a), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]}, N[(N[(N[(N[Power[t$95$0, 2.0], $MachinePrecision] * 0.012345679012345678), $MachinePrecision] * t$95$0), $MachinePrecision] * -0.1111111111111111), $MachinePrecision]]
\begin{array}{l}
t_0 := \frac{\mathsf{fma}\left(-3, c, \frac{b}{a} \cdot b\right)}{a}\\
\left(\left({t\_0}^{2} \cdot 0.012345679012345678\right) \cdot t\_0\right) \cdot -0.1111111111111111
\end{array}
Initial program 80.4%
lift-/.f64N/A
frac-2negN/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites80.4%
lift-pow.f64N/A
unpow3N/A
lift-/.f64N/A
mult-flipN/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites99.2%
(FPCore (a b c) :precision binary64 (pow (* (/ (fma (/ b a) b (* c -3.0)) a) -0.1111111111111111) 3.0))
double code(double a, double b, double c) {
return pow(((fma((b / a), b, (c * -3.0)) / a) * -0.1111111111111111), 3.0);
}
function code(a, b, c) return Float64(Float64(fma(Float64(b / a), b, Float64(c * -3.0)) / a) * -0.1111111111111111) ^ 3.0 end
code[a_, b_, c_] := N[Power[N[(N[(N[(N[(b / a), $MachinePrecision] * b + N[(c * -3.0), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision] * -0.1111111111111111), $MachinePrecision], 3.0], $MachinePrecision]
{\left(\frac{\mathsf{fma}\left(\frac{b}{a}, b, c \cdot -3\right)}{a} \cdot -0.1111111111111111\right)}^{3}
Initial program 80.4%
lift-/.f64N/A
frac-2negN/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites80.4%
lift-/.f64N/A
mult-flipN/A
lower-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
associate-*r*N/A
add-to-fraction-revN/A
lift-*.f64N/A
associate-*r/N/A
lift-/.f64N/A
lift-*.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
metadata-eval99.2%
Applied rewrites99.2%
lift-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6499.2%
Applied rewrites99.2%
(FPCore (a b c) :precision binary64 (pow (/ (fma (* -0.1111111111111111 (/ b a)) b (* 0.3333333333333333 c)) a) 3.0))
double code(double a, double b, double c) {
return pow((fma((-0.1111111111111111 * (b / a)), b, (0.3333333333333333 * c)) / a), 3.0);
}
function code(a, b, c) return Float64(fma(Float64(-0.1111111111111111 * Float64(b / a)), b, Float64(0.3333333333333333 * c)) / a) ^ 3.0 end
code[a_, b_, c_] := N[Power[N[(N[(N[(-0.1111111111111111 * N[(b / a), $MachinePrecision]), $MachinePrecision] * b + N[(0.3333333333333333 * c), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], 3.0], $MachinePrecision]
{\left(\frac{\mathsf{fma}\left(-0.1111111111111111 \cdot \frac{b}{a}, b, 0.3333333333333333 \cdot c\right)}{a}\right)}^{3}
Initial program 80.4%
Taylor expanded in a around inf
lower-/.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-pow.f64N/A
lower-*.f6493.4%
Applied rewrites93.4%
lift-fma.f64N/A
+-commutativeN/A
fp-cancel-sign-sub-invN/A
lower--.f64N/A
metadata-evalN/A
lower-*.f6493.4%
lift-/.f64N/A
lift-pow.f64N/A
pow2N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6499.2%
Applied rewrites99.2%
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-outN/A
metadata-evalN/A
metadata-evalN/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
metadata-eval99.2%
Applied rewrites99.2%
(FPCore (a b c) :precision binary64 (pow (/ (fma c 0.3333333333333333 (* -0.1111111111111111 (* (/ b a) b))) a) 3.0))
double code(double a, double b, double c) {
return pow((fma(c, 0.3333333333333333, (-0.1111111111111111 * ((b / a) * b))) / a), 3.0);
}
function code(a, b, c) return Float64(fma(c, 0.3333333333333333, Float64(-0.1111111111111111 * Float64(Float64(b / a) * b))) / a) ^ 3.0 end
code[a_, b_, c_] := N[Power[N[(N[(c * 0.3333333333333333 + N[(-0.1111111111111111 * N[(N[(b / a), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], 3.0], $MachinePrecision]
{\left(\frac{\mathsf{fma}\left(c, 0.3333333333333333, -0.1111111111111111 \cdot \left(\frac{b}{a} \cdot b\right)\right)}{a}\right)}^{3}
Initial program 80.4%
Taylor expanded in a around inf
lower-/.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-pow.f64N/A
lower-*.f6493.4%
Applied rewrites93.4%
lift-fma.f64N/A
+-commutativeN/A
fp-cancel-sign-sub-invN/A
lower--.f64N/A
metadata-evalN/A
lower-*.f6493.4%
lift-/.f64N/A
lift-pow.f64N/A
pow2N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6499.2%
Applied rewrites99.2%
lift--.f64N/A
sub-flipN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f64N/A
distribute-lft-neg-outN/A
metadata-evalN/A
metadata-evalN/A
lower-*.f64N/A
metadata-eval99.2%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.2%
Applied rewrites99.2%
(FPCore (a b c) :precision binary64 (* (pow (/ (fma -3.0 c (* (/ b a) b)) a) 3.0) -0.0013717421124828531))
double code(double a, double b, double c) {
return pow((fma(-3.0, c, ((b / a) * b)) / a), 3.0) * -0.0013717421124828531;
}
function code(a, b, c) return Float64((Float64(fma(-3.0, c, Float64(Float64(b / a) * b)) / a) ^ 3.0) * -0.0013717421124828531) end
code[a_, b_, c_] := N[(N[Power[N[(N[(-3.0 * c + N[(N[(b / a), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], 3.0], $MachinePrecision] * -0.0013717421124828531), $MachinePrecision]
{\left(\frac{\mathsf{fma}\left(-3, c, \frac{b}{a} \cdot b\right)}{a}\right)}^{3} \cdot -0.0013717421124828531
Initial program 80.4%
lift-/.f64N/A
frac-2negN/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites80.4%
lift-pow.f64N/A
lift-/.f64N/A
mult-flipN/A
cube-prodN/A
lower-*.f64N/A
Applied rewrites99.1%
(FPCore (a b c) :precision binary64 (if (<= (fabs b) 1.05e-199) (pow (* (/ 3.0 (* 9.0 a)) (* c 1.0)) 3.0) (pow (* (/ (* a 3.0) 9.0) (/ c (* a a))) 3.0)))
double code(double a, double b, double c) {
double tmp;
if (fabs(b) <= 1.05e-199) {
tmp = pow(((3.0 / (9.0 * a)) * (c * 1.0)), 3.0);
} else {
tmp = pow((((a * 3.0) / 9.0) * (c / (a * a))), 3.0);
}
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 (abs(b) <= 1.05d-199) then
tmp = ((3.0d0 / (9.0d0 * a)) * (c * 1.0d0)) ** 3.0d0
else
tmp = (((a * 3.0d0) / 9.0d0) * (c / (a * a))) ** 3.0d0
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (Math.abs(b) <= 1.05e-199) {
tmp = Math.pow(((3.0 / (9.0 * a)) * (c * 1.0)), 3.0);
} else {
tmp = Math.pow((((a * 3.0) / 9.0) * (c / (a * a))), 3.0);
}
return tmp;
}
def code(a, b, c): tmp = 0 if math.fabs(b) <= 1.05e-199: tmp = math.pow(((3.0 / (9.0 * a)) * (c * 1.0)), 3.0) else: tmp = math.pow((((a * 3.0) / 9.0) * (c / (a * a))), 3.0) return tmp
function code(a, b, c) tmp = 0.0 if (abs(b) <= 1.05e-199) tmp = Float64(Float64(3.0 / Float64(9.0 * a)) * Float64(c * 1.0)) ^ 3.0; else tmp = Float64(Float64(Float64(a * 3.0) / 9.0) * Float64(c / Float64(a * a))) ^ 3.0; end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (abs(b) <= 1.05e-199) tmp = ((3.0 / (9.0 * a)) * (c * 1.0)) ^ 3.0; else tmp = (((a * 3.0) / 9.0) * (c / (a * a))) ^ 3.0; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[N[Abs[b], $MachinePrecision], 1.05e-199], N[Power[N[(N[(3.0 / N[(9.0 * a), $MachinePrecision]), $MachinePrecision] * N[(c * 1.0), $MachinePrecision]), $MachinePrecision], 3.0], $MachinePrecision], N[Power[N[(N[(N[(a * 3.0), $MachinePrecision] / 9.0), $MachinePrecision] * N[(c / N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 3.0], $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\left|b\right| \leq 1.05 \cdot 10^{-199}:\\
\;\;\;\;{\left(\frac{3}{9 \cdot a} \cdot \left(c \cdot 1\right)\right)}^{3}\\
\mathbf{else}:\\
\;\;\;\;{\left(\frac{a \cdot 3}{9} \cdot \frac{c}{a \cdot a}\right)}^{3}\\
\end{array}
if b < 1.05e-199Initial program 80.4%
Taylor expanded in a around inf
lower-*.f64N/A
lower-/.f6458.0%
Applied rewrites58.0%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
lower-/.f6458.0%
Applied rewrites58.0%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
mult-flipN/A
*-inversesN/A
associate-/r*N/A
lift-*.f64N/A
mult-flipN/A
associate-*l*N/A
lift-*.f64N/A
metadata-evalN/A
mult-flipN/A
times-fracN/A
lift-*.f64N/A
associate-*r*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-inversesN/A
lower-*.f6458.0%
Applied rewrites58.0%
if 1.05e-199 < b Initial program 80.4%
Taylor expanded in a around inf
lower-*.f64N/A
lower-/.f6458.0%
Applied rewrites58.0%
lift-*.f64N/A
lift-/.f64N/A
mult-flipN/A
inv-powN/A
metadata-evalN/A
metadata-evalN/A
pow-plusN/A
pow-flipN/A
pow2N/A
lift-*.f64N/A
associate-*l*N/A
mult-flipN/A
lift-/.f64N/A
*-commutativeN/A
lift-/.f64N/A
associate-*l/N/A
lift-*.f64N/A
metadata-evalN/A
times-fracN/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
*-commutativeN/A
lift-*.f64N/A
pow2N/A
Applied rewrites58.4%
(FPCore (a b c) :precision binary64 (if (<= (fabs b) 8.2e-200) (pow (* (/ 3.0 (* 9.0 a)) (* c 1.0)) 3.0) (pow (* c (/ (* 0.3333333333333333 a) (* a a))) 3.0)))
double code(double a, double b, double c) {
double tmp;
if (fabs(b) <= 8.2e-200) {
tmp = pow(((3.0 / (9.0 * a)) * (c * 1.0)), 3.0);
} else {
tmp = pow((c * ((0.3333333333333333 * a) / (a * a))), 3.0);
}
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 (abs(b) <= 8.2d-200) then
tmp = ((3.0d0 / (9.0d0 * a)) * (c * 1.0d0)) ** 3.0d0
else
tmp = (c * ((0.3333333333333333d0 * a) / (a * a))) ** 3.0d0
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (Math.abs(b) <= 8.2e-200) {
tmp = Math.pow(((3.0 / (9.0 * a)) * (c * 1.0)), 3.0);
} else {
tmp = Math.pow((c * ((0.3333333333333333 * a) / (a * a))), 3.0);
}
return tmp;
}
def code(a, b, c): tmp = 0 if math.fabs(b) <= 8.2e-200: tmp = math.pow(((3.0 / (9.0 * a)) * (c * 1.0)), 3.0) else: tmp = math.pow((c * ((0.3333333333333333 * a) / (a * a))), 3.0) return tmp
function code(a, b, c) tmp = 0.0 if (abs(b) <= 8.2e-200) tmp = Float64(Float64(3.0 / Float64(9.0 * a)) * Float64(c * 1.0)) ^ 3.0; else tmp = Float64(c * Float64(Float64(0.3333333333333333 * a) / Float64(a * a))) ^ 3.0; end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (abs(b) <= 8.2e-200) tmp = ((3.0 / (9.0 * a)) * (c * 1.0)) ^ 3.0; else tmp = (c * ((0.3333333333333333 * a) / (a * a))) ^ 3.0; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[N[Abs[b], $MachinePrecision], 8.2e-200], N[Power[N[(N[(3.0 / N[(9.0 * a), $MachinePrecision]), $MachinePrecision] * N[(c * 1.0), $MachinePrecision]), $MachinePrecision], 3.0], $MachinePrecision], N[Power[N[(c * N[(N[(0.3333333333333333 * a), $MachinePrecision] / N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 3.0], $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\left|b\right| \leq 8.2 \cdot 10^{-200}:\\
\;\;\;\;{\left(\frac{3}{9 \cdot a} \cdot \left(c \cdot 1\right)\right)}^{3}\\
\mathbf{else}:\\
\;\;\;\;{\left(c \cdot \frac{0.3333333333333333 \cdot a}{a \cdot a}\right)}^{3}\\
\end{array}
if b < 8.1999999999999997e-200Initial program 80.4%
Taylor expanded in a around inf
lower-*.f64N/A
lower-/.f6458.0%
Applied rewrites58.0%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
lower-/.f6458.0%
Applied rewrites58.0%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
mult-flipN/A
*-inversesN/A
associate-/r*N/A
lift-*.f64N/A
mult-flipN/A
associate-*l*N/A
lift-*.f64N/A
metadata-evalN/A
mult-flipN/A
times-fracN/A
lift-*.f64N/A
associate-*r*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-inversesN/A
lower-*.f6458.0%
Applied rewrites58.0%
if 8.1999999999999997e-200 < b Initial program 80.4%
Taylor expanded in a around inf
lower-*.f64N/A
lower-/.f6458.0%
Applied rewrites58.0%
lift-*.f64N/A
lift-/.f64N/A
mult-flipN/A
inv-powN/A
metadata-evalN/A
metadata-evalN/A
pow-plusN/A
pow-flipN/A
pow2N/A
lift-*.f64N/A
associate-*l*N/A
mult-flipN/A
lift-/.f64N/A
*-commutativeN/A
associate-*r*N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6458.4%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6458.4%
Applied rewrites58.4%
(FPCore (a b c) :precision binary64 (if (<= (fabs b) 8.2e-200) (pow (* c (/ 0.3333333333333333 a)) 3.0) (pow (* c (/ (* 0.3333333333333333 a) (* a a))) 3.0)))
double code(double a, double b, double c) {
double tmp;
if (fabs(b) <= 8.2e-200) {
tmp = pow((c * (0.3333333333333333 / a)), 3.0);
} else {
tmp = pow((c * ((0.3333333333333333 * a) / (a * a))), 3.0);
}
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 (abs(b) <= 8.2d-200) then
tmp = (c * (0.3333333333333333d0 / a)) ** 3.0d0
else
tmp = (c * ((0.3333333333333333d0 * a) / (a * a))) ** 3.0d0
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (Math.abs(b) <= 8.2e-200) {
tmp = Math.pow((c * (0.3333333333333333 / a)), 3.0);
} else {
tmp = Math.pow((c * ((0.3333333333333333 * a) / (a * a))), 3.0);
}
return tmp;
}
def code(a, b, c): tmp = 0 if math.fabs(b) <= 8.2e-200: tmp = math.pow((c * (0.3333333333333333 / a)), 3.0) else: tmp = math.pow((c * ((0.3333333333333333 * a) / (a * a))), 3.0) return tmp
function code(a, b, c) tmp = 0.0 if (abs(b) <= 8.2e-200) tmp = Float64(c * Float64(0.3333333333333333 / a)) ^ 3.0; else tmp = Float64(c * Float64(Float64(0.3333333333333333 * a) / Float64(a * a))) ^ 3.0; end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (abs(b) <= 8.2e-200) tmp = (c * (0.3333333333333333 / a)) ^ 3.0; else tmp = (c * ((0.3333333333333333 * a) / (a * a))) ^ 3.0; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[N[Abs[b], $MachinePrecision], 8.2e-200], N[Power[N[(c * N[(0.3333333333333333 / a), $MachinePrecision]), $MachinePrecision], 3.0], $MachinePrecision], N[Power[N[(c * N[(N[(0.3333333333333333 * a), $MachinePrecision] / N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 3.0], $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\left|b\right| \leq 8.2 \cdot 10^{-200}:\\
\;\;\;\;{\left(c \cdot \frac{0.3333333333333333}{a}\right)}^{3}\\
\mathbf{else}:\\
\;\;\;\;{\left(c \cdot \frac{0.3333333333333333 \cdot a}{a \cdot a}\right)}^{3}\\
\end{array}
if b < 8.1999999999999997e-200Initial program 80.4%
Taylor expanded in a around inf
lower-*.f64N/A
lower-/.f6458.0%
Applied rewrites58.0%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6458.0%
Applied rewrites58.0%
if 8.1999999999999997e-200 < b Initial program 80.4%
Taylor expanded in a around inf
lower-*.f64N/A
lower-/.f6458.0%
Applied rewrites58.0%
lift-*.f64N/A
lift-/.f64N/A
mult-flipN/A
inv-powN/A
metadata-evalN/A
metadata-evalN/A
pow-plusN/A
pow-flipN/A
pow2N/A
lift-*.f64N/A
associate-*l*N/A
mult-flipN/A
lift-/.f64N/A
*-commutativeN/A
associate-*r*N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6458.4%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6458.4%
Applied rewrites58.4%
(FPCore (a b c) :precision binary64 (let* ((t_0 (* (/ 0.3333333333333333 a) c))) (* (* t_0 t_0) t_0)))
double code(double a, double b, double c) {
double t_0 = (0.3333333333333333 / a) * c;
return (t_0 * t_0) * t_0;
}
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) :: t_0
t_0 = (0.3333333333333333d0 / a) * c
code = (t_0 * t_0) * t_0
end function
public static double code(double a, double b, double c) {
double t_0 = (0.3333333333333333 / a) * c;
return (t_0 * t_0) * t_0;
}
def code(a, b, c): t_0 = (0.3333333333333333 / a) * c return (t_0 * t_0) * t_0
function code(a, b, c) t_0 = Float64(Float64(0.3333333333333333 / a) * c) return Float64(Float64(t_0 * t_0) * t_0) end
function tmp = code(a, b, c) t_0 = (0.3333333333333333 / a) * c; tmp = (t_0 * t_0) * t_0; end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(0.3333333333333333 / a), $MachinePrecision] * c), $MachinePrecision]}, N[(N[(t$95$0 * t$95$0), $MachinePrecision] * t$95$0), $MachinePrecision]]
\begin{array}{l}
t_0 := \frac{0.3333333333333333}{a} \cdot c\\
\left(t\_0 \cdot t\_0\right) \cdot t\_0
\end{array}
Initial program 80.4%
Taylor expanded in a around inf
lower-*.f64N/A
lower-/.f6458.0%
Applied rewrites58.0%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6458.0%
Applied rewrites58.0%
lift-pow.f64N/A
unpow3N/A
lower-*.f64N/A
Applied rewrites58.0%
(FPCore (a b c) :precision binary64 (pow (* c (/ 0.3333333333333333 a)) 3.0))
double code(double a, double b, double c) {
return pow((c * (0.3333333333333333 / a)), 3.0);
}
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.3333333333333333d0 / a)) ** 3.0d0
end function
public static double code(double a, double b, double c) {
return Math.pow((c * (0.3333333333333333 / a)), 3.0);
}
def code(a, b, c): return math.pow((c * (0.3333333333333333 / a)), 3.0)
function code(a, b, c) return Float64(c * Float64(0.3333333333333333 / a)) ^ 3.0 end
function tmp = code(a, b, c) tmp = (c * (0.3333333333333333 / a)) ^ 3.0; end
code[a_, b_, c_] := N[Power[N[(c * N[(0.3333333333333333 / a), $MachinePrecision]), $MachinePrecision], 3.0], $MachinePrecision]
{\left(c \cdot \frac{0.3333333333333333}{a}\right)}^{3}
Initial program 80.4%
Taylor expanded in a around inf
lower-*.f64N/A
lower-/.f6458.0%
Applied rewrites58.0%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6458.0%
Applied rewrites58.0%
(FPCore (a b c) :precision binary64 (pow (* 0.3333333333333333 (/ c a)) 3.0))
double code(double a, double b, double c) {
return pow((0.3333333333333333 * (c / a)), 3.0);
}
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.3333333333333333d0 * (c / a)) ** 3.0d0
end function
public static double code(double a, double b, double c) {
return Math.pow((0.3333333333333333 * (c / a)), 3.0);
}
def code(a, b, c): return math.pow((0.3333333333333333 * (c / a)), 3.0)
function code(a, b, c) return Float64(0.3333333333333333 * Float64(c / a)) ^ 3.0 end
function tmp = code(a, b, c) tmp = (0.3333333333333333 * (c / a)) ^ 3.0; end
code[a_, b_, c_] := N[Power[N[(0.3333333333333333 * N[(c / a), $MachinePrecision]), $MachinePrecision], 3.0], $MachinePrecision]
{\left(0.3333333333333333 \cdot \frac{c}{a}\right)}^{3}
Initial program 80.4%
Taylor expanded in a around inf
lower-*.f64N/A
lower-/.f6458.0%
Applied rewrites58.0%
herbie shell --seed 2025191
(FPCore (a b c)
:name "Q^3 (Cubic Equation Discriminant Part)"
:precision binary64
:pre (and (and (and (<= -1000000000.0 a) (<= a 1000000000.0)) (and (<= -1000000000.0 b) (<= b 1000000000.0))) (and (<= -1000000000.0 c) (<= c 1000000000.0)))
(pow (/ (- (* 3.0 (* a c)) (pow b 2.0)) (* 9.0 (pow a 2.0))) 3.0))