
(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 13 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 (/ b a) b (* -3.0 c)))) (* (/ t_0 (- a)) (/ (pow (/ t_0 a) 2.0) 729.0))))
double code(double a, double b, double c) {
double t_0 = fma((b / a), b, (-3.0 * c));
return (t_0 / -a) * (pow((t_0 / a), 2.0) / 729.0);
}
function code(a, b, c) t_0 = fma(Float64(b / a), b, Float64(-3.0 * c)) return Float64(Float64(t_0 / Float64(-a)) * Float64((Float64(t_0 / a) ^ 2.0) / 729.0)) end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(b / a), $MachinePrecision] * b + N[(-3.0 * c), $MachinePrecision]), $MachinePrecision]}, N[(N[(t$95$0 / (-a)), $MachinePrecision] * N[(N[Power[N[(t$95$0 / a), $MachinePrecision], 2.0], $MachinePrecision] / 729.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
t_0 := \mathsf{fma}\left(\frac{b}{a}, b, -3 \cdot c\right)\\
\frac{t\_0}{-a} \cdot \frac{{\left(\frac{t\_0}{a}\right)}^{2}}{729}
\end{array}
Initial program 81.4%
lift-/.f64N/A
frac-2negN/A
distribute-frac-neg2N/A
distribute-frac-negN/A
remove-double-negN/A
lift-*.f64N/A
*-commutativeN/A
lift-pow.f64N/A
unpow2N/A
associate-*l*N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-pow.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f6483.8%
Applied rewrites83.8%
Applied rewrites99.3%
Applied rewrites99.4%
lift-fma.f64N/A
*-commutativeN/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
lower-*.f6499.4%
Applied rewrites99.4%
lift-fma.f64N/A
*-commutativeN/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
lower-*.f6499.4%
Applied rewrites99.4%
(FPCore (a b c) :precision binary64 (let* ((t_0 (fma c -3.0 (* (/ b a) b)))) (* (/ t_0 (- a)) (/ (pow (/ t_0 a) 2.0) 729.0))))
double code(double a, double b, double c) {
double t_0 = fma(c, -3.0, ((b / a) * b));
return (t_0 / -a) * (pow((t_0 / a), 2.0) / 729.0);
}
function code(a, b, c) t_0 = fma(c, -3.0, Float64(Float64(b / a) * b)) return Float64(Float64(t_0 / Float64(-a)) * Float64((Float64(t_0 / a) ^ 2.0) / 729.0)) end
code[a_, b_, c_] := Block[{t$95$0 = N[(c * -3.0 + N[(N[(b / a), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]}, N[(N[(t$95$0 / (-a)), $MachinePrecision] * N[(N[Power[N[(t$95$0 / a), $MachinePrecision], 2.0], $MachinePrecision] / 729.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
t_0 := \mathsf{fma}\left(c, -3, \frac{b}{a} \cdot b\right)\\
\frac{t\_0}{-a} \cdot \frac{{\left(\frac{t\_0}{a}\right)}^{2}}{729}
\end{array}
Initial program 81.4%
lift-/.f64N/A
frac-2negN/A
distribute-frac-neg2N/A
distribute-frac-negN/A
remove-double-negN/A
lift-*.f64N/A
*-commutativeN/A
lift-pow.f64N/A
unpow2N/A
associate-*l*N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-pow.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f6483.8%
Applied rewrites83.8%
Applied rewrites99.3%
Applied rewrites99.4%
(FPCore (a b c) :precision binary64 (let* ((t_0 (/ (fma c -3.0 (* (/ b a) b)) a))) (* (pow t_0 2.0) (/ t_0 -729.0))))
double code(double a, double b, double c) {
double t_0 = fma(c, -3.0, ((b / a) * b)) / a;
return pow(t_0, 2.0) * (t_0 / -729.0);
}
function code(a, b, c) t_0 = Float64(fma(c, -3.0, Float64(Float64(b / a) * b)) / a) return Float64((t_0 ^ 2.0) * Float64(t_0 / -729.0)) end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(c * -3.0 + N[(N[(b / a), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]}, N[(N[Power[t$95$0, 2.0], $MachinePrecision] * N[(t$95$0 / -729.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
t_0 := \frac{\mathsf{fma}\left(c, -3, \frac{b}{a} \cdot b\right)}{a}\\
{t\_0}^{2} \cdot \frac{t\_0}{-729}
\end{array}
Initial program 81.4%
lift-/.f64N/A
frac-2negN/A
distribute-frac-neg2N/A
distribute-frac-negN/A
remove-double-negN/A
lift-*.f64N/A
*-commutativeN/A
lift-pow.f64N/A
unpow2N/A
associate-*l*N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-pow.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f6483.8%
Applied rewrites83.8%
Applied rewrites99.3%
Applied rewrites99.4%
(FPCore (a b c) :precision binary64 (pow (/ (/ (fma -3.0 c (* b (/ b a))) a) -9.0) 3.0))
double code(double a, double b, double c) {
return pow(((fma(-3.0, c, (b * (b / a))) / a) / -9.0), 3.0);
}
function code(a, b, c) return Float64(Float64(fma(-3.0, c, Float64(b * Float64(b / a))) / a) / -9.0) ^ 3.0 end
code[a_, b_, c_] := N[Power[N[(N[(N[(-3.0 * c + N[(b * N[(b / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision] / -9.0), $MachinePrecision], 3.0], $MachinePrecision]
{\left(\frac{\frac{\mathsf{fma}\left(-3, c, b \cdot \frac{b}{a}\right)}{a}}{-9}\right)}^{3}
Initial program 81.4%
lift-/.f64N/A
frac-2negN/A
distribute-frac-neg2N/A
distribute-frac-negN/A
remove-double-negN/A
lift-*.f64N/A
*-commutativeN/A
lift-pow.f64N/A
unpow2N/A
associate-*l*N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-pow.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f6483.8%
Applied rewrites83.8%
Applied rewrites99.3%
(FPCore (a b c) :precision binary64 (pow (/ (fma -3.0 c (* b (/ b a))) (* -9.0 a)) 3.0))
double code(double a, double b, double c) {
return pow((fma(-3.0, c, (b * (b / a))) / (-9.0 * a)), 3.0);
}
function code(a, b, c) return Float64(fma(-3.0, c, Float64(b * Float64(b / a))) / Float64(-9.0 * a)) ^ 3.0 end
code[a_, b_, c_] := N[Power[N[(N[(-3.0 * c + N[(b * N[(b / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(-9.0 * a), $MachinePrecision]), $MachinePrecision], 3.0], $MachinePrecision]
{\left(\frac{\mathsf{fma}\left(-3, c, b \cdot \frac{b}{a}\right)}{-9 \cdot a}\right)}^{3}
Initial program 81.4%
lift-/.f64N/A
frac-2negN/A
distribute-frac-neg2N/A
distribute-frac-negN/A
remove-double-negN/A
lift-*.f64N/A
*-commutativeN/A
lift-pow.f64N/A
unpow2N/A
associate-*l*N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-pow.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f6483.8%
Applied rewrites83.8%
lift-/.f64N/A
frac-2negN/A
lower-/.f64N/A
Applied rewrites99.3%
(FPCore (a b c) :precision binary64 (pow (/ (fma (* b (/ b a)) -0.1111111111111111 (* 0.3333333333333333 c)) a) 3.0))
double code(double a, double b, double c) {
return pow((fma((b * (b / a)), -0.1111111111111111, (0.3333333333333333 * c)) / a), 3.0);
}
function code(a, b, c) return Float64(fma(Float64(b * Float64(b / a)), -0.1111111111111111, Float64(0.3333333333333333 * c)) / a) ^ 3.0 end
code[a_, b_, c_] := N[Power[N[(N[(N[(b * N[(b / a), $MachinePrecision]), $MachinePrecision] * -0.1111111111111111 + N[(0.3333333333333333 * c), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], 3.0], $MachinePrecision]
{\left(\frac{\mathsf{fma}\left(b \cdot \frac{b}{a}, -0.1111111111111111, 0.3333333333333333 \cdot c\right)}{a}\right)}^{3}
Initial program 81.4%
Taylor expanded in a around inf
lower-/.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-pow.f64N/A
lower-*.f6493.9%
Applied rewrites93.9%
lift-fma.f64N/A
*-commutativeN/A
lower-fma.f6493.9%
lift-/.f64N/A
lift-pow.f64N/A
pow2N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6499.2%
Applied rewrites99.2%
(FPCore (a b c) :precision binary64 (* (pow (/ (fma c -3.0 (* (/ b a) b)) a) 3.0) -0.0013717421124828531))
double code(double a, double b, double c) {
return pow((fma(c, -3.0, ((b / a) * b)) / a), 3.0) * -0.0013717421124828531;
}
function code(a, b, c) return Float64((Float64(fma(c, -3.0, Float64(Float64(b / a) * b)) / a) ^ 3.0) * -0.0013717421124828531) end
code[a_, b_, c_] := N[(N[Power[N[(N[(c * -3.0 + N[(N[(b / a), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], 3.0], $MachinePrecision] * -0.0013717421124828531), $MachinePrecision]
{\left(\frac{\mathsf{fma}\left(c, -3, \frac{b}{a} \cdot b\right)}{a}\right)}^{3} \cdot -0.0013717421124828531
Initial program 81.4%
lift-/.f64N/A
frac-2negN/A
distribute-frac-neg2N/A
distribute-frac-negN/A
remove-double-negN/A
lift-*.f64N/A
*-commutativeN/A
lift-pow.f64N/A
unpow2N/A
associate-*l*N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-pow.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f6483.8%
Applied rewrites83.8%
Applied rewrites99.3%
Applied rewrites99.2%
(FPCore (a b c)
:precision binary64
(if (<=
(pow (/ (- (* 3.0 (* a c)) (pow b 2.0)) (* 9.0 (pow a 2.0))) 3.0)
-4e+271)
(/ (* -0.3333333333333333 (* c (* (/ c a) c))) (* -9.0 (* a a)))
(/ (pow (* 3.0 (/ c a)) 3.0) 729.0)))double code(double a, double b, double c) {
double tmp;
if (pow((((3.0 * (a * c)) - pow(b, 2.0)) / (9.0 * pow(a, 2.0))), 3.0) <= -4e+271) {
tmp = (-0.3333333333333333 * (c * ((c / a) * c))) / (-9.0 * (a * a));
} else {
tmp = pow((3.0 * (c / a)), 3.0) / 729.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 (((((3.0d0 * (a * c)) - (b ** 2.0d0)) / (9.0d0 * (a ** 2.0d0))) ** 3.0d0) <= (-4d+271)) then
tmp = ((-0.3333333333333333d0) * (c * ((c / a) * c))) / ((-9.0d0) * (a * a))
else
tmp = ((3.0d0 * (c / a)) ** 3.0d0) / 729.0d0
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (Math.pow((((3.0 * (a * c)) - Math.pow(b, 2.0)) / (9.0 * Math.pow(a, 2.0))), 3.0) <= -4e+271) {
tmp = (-0.3333333333333333 * (c * ((c / a) * c))) / (-9.0 * (a * a));
} else {
tmp = Math.pow((3.0 * (c / a)), 3.0) / 729.0;
}
return tmp;
}
def code(a, b, c): tmp = 0 if math.pow((((3.0 * (a * c)) - math.pow(b, 2.0)) / (9.0 * math.pow(a, 2.0))), 3.0) <= -4e+271: tmp = (-0.3333333333333333 * (c * ((c / a) * c))) / (-9.0 * (a * a)) else: tmp = math.pow((3.0 * (c / a)), 3.0) / 729.0 return tmp
function code(a, b, c) tmp = 0.0 if ((Float64(Float64(Float64(3.0 * Float64(a * c)) - (b ^ 2.0)) / Float64(9.0 * (a ^ 2.0))) ^ 3.0) <= -4e+271) tmp = Float64(Float64(-0.3333333333333333 * Float64(c * Float64(Float64(c / a) * c))) / Float64(-9.0 * Float64(a * a))); else tmp = Float64((Float64(3.0 * Float64(c / a)) ^ 3.0) / 729.0); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (((((3.0 * (a * c)) - (b ^ 2.0)) / (9.0 * (a ^ 2.0))) ^ 3.0) <= -4e+271) tmp = (-0.3333333333333333 * (c * ((c / a) * c))) / (-9.0 * (a * a)); else tmp = ((3.0 * (c / a)) ^ 3.0) / 729.0; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[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], -4e+271], N[(N[(-0.3333333333333333 * N[(c * N[(N[(c / a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(-9.0 * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[N[(3.0 * N[(c / a), $MachinePrecision]), $MachinePrecision], 3.0], $MachinePrecision] / 729.0), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;{\left(\frac{3 \cdot \left(a \cdot c\right) - {b}^{2}}{9 \cdot {a}^{2}}\right)}^{3} \leq -4 \cdot 10^{+271}:\\
\;\;\;\;\frac{-0.3333333333333333 \cdot \left(c \cdot \left(\frac{c}{a} \cdot c\right)\right)}{-9 \cdot \left(a \cdot a\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{{\left(3 \cdot \frac{c}{a}\right)}^{3}}{729}\\
\end{array}
if (pow.f64 (/.f64 (-.f64 (*.f64 #s(literal 3 binary64) (*.f64 a c)) (pow.f64 b #s(literal 2 binary64))) (*.f64 #s(literal 9 binary64) (pow.f64 a #s(literal 2 binary64)))) #s(literal 3 binary64)) < -3.9999999999999998e271Initial program 81.4%
lift-pow.f64N/A
cube-multN/A
lift-/.f64N/A
frac-2negN/A
associate-*l/N/A
lower-/.f64N/A
Applied rewrites36.9%
Taylor expanded in a around inf
lower-*.f64N/A
lower-/.f64N/A
lower-pow.f6442.4%
Applied rewrites42.4%
lift-/.f64N/A
lift-pow.f64N/A
cube-multN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6448.5%
Applied rewrites48.5%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f6450.1%
Applied rewrites50.1%
if -3.9999999999999998e271 < (pow.f64 (/.f64 (-.f64 (*.f64 #s(literal 3 binary64) (*.f64 a c)) (pow.f64 b #s(literal 2 binary64))) (*.f64 #s(literal 9 binary64) (pow.f64 a #s(literal 2 binary64)))) #s(literal 3 binary64)) Initial program 81.4%
lift-pow.f64N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
cube-divN/A
lower-/.f64N/A
Applied rewrites81.3%
Taylor expanded in a around inf
lower-*.f64N/A
lower-/.f6458.7%
Applied rewrites58.7%
(FPCore (a b c) :precision binary64 (if (<= (fabs b) 6.6e-128) (pow (* c (/ 0.3333333333333333 a)) 3.0) (/ (* -0.3333333333333333 (* c (* (/ c a) c))) (* -9.0 (* a a)))))
double code(double a, double b, double c) {
double tmp;
if (fabs(b) <= 6.6e-128) {
tmp = pow((c * (0.3333333333333333 / a)), 3.0);
} else {
tmp = (-0.3333333333333333 * (c * ((c / a) * c))) / (-9.0 * (a * a));
}
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) <= 6.6d-128) then
tmp = (c * (0.3333333333333333d0 / a)) ** 3.0d0
else
tmp = ((-0.3333333333333333d0) * (c * ((c / a) * c))) / ((-9.0d0) * (a * a))
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (Math.abs(b) <= 6.6e-128) {
tmp = Math.pow((c * (0.3333333333333333 / a)), 3.0);
} else {
tmp = (-0.3333333333333333 * (c * ((c / a) * c))) / (-9.0 * (a * a));
}
return tmp;
}
def code(a, b, c): tmp = 0 if math.fabs(b) <= 6.6e-128: tmp = math.pow((c * (0.3333333333333333 / a)), 3.0) else: tmp = (-0.3333333333333333 * (c * ((c / a) * c))) / (-9.0 * (a * a)) return tmp
function code(a, b, c) tmp = 0.0 if (abs(b) <= 6.6e-128) tmp = Float64(c * Float64(0.3333333333333333 / a)) ^ 3.0; else tmp = Float64(Float64(-0.3333333333333333 * Float64(c * Float64(Float64(c / a) * c))) / Float64(-9.0 * Float64(a * a))); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (abs(b) <= 6.6e-128) tmp = (c * (0.3333333333333333 / a)) ^ 3.0; else tmp = (-0.3333333333333333 * (c * ((c / a) * c))) / (-9.0 * (a * a)); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[N[Abs[b], $MachinePrecision], 6.6e-128], N[Power[N[(c * N[(0.3333333333333333 / a), $MachinePrecision]), $MachinePrecision], 3.0], $MachinePrecision], N[(N[(-0.3333333333333333 * N[(c * N[(N[(c / a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(-9.0 * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\left|b\right| \leq 6.6 \cdot 10^{-128}:\\
\;\;\;\;{\left(c \cdot \frac{0.3333333333333333}{a}\right)}^{3}\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.3333333333333333 \cdot \left(c \cdot \left(\frac{c}{a} \cdot c\right)\right)}{-9 \cdot \left(a \cdot a\right)}\\
\end{array}
if b < 6.6e-128Initial program 81.4%
Taylor expanded in a around inf
lower-*.f64N/A
lower-/.f6458.7%
Applied rewrites58.7%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6458.7%
Applied rewrites58.7%
if 6.6e-128 < b Initial program 81.4%
lift-pow.f64N/A
cube-multN/A
lift-/.f64N/A
frac-2negN/A
associate-*l/N/A
lower-/.f64N/A
Applied rewrites36.9%
Taylor expanded in a around inf
lower-*.f64N/A
lower-/.f64N/A
lower-pow.f6442.4%
Applied rewrites42.4%
lift-/.f64N/A
lift-pow.f64N/A
cube-multN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6448.5%
Applied rewrites48.5%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f6450.1%
Applied rewrites50.1%
(FPCore (a b c) :precision binary64 (if (<= (fabs b) 6.6e-128) (pow (* 0.3333333333333333 (/ c a)) 3.0) (/ (* -0.3333333333333333 (* c (* (/ c a) c))) (* -9.0 (* a a)))))
double code(double a, double b, double c) {
double tmp;
if (fabs(b) <= 6.6e-128) {
tmp = pow((0.3333333333333333 * (c / a)), 3.0);
} else {
tmp = (-0.3333333333333333 * (c * ((c / a) * c))) / (-9.0 * (a * a));
}
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) <= 6.6d-128) then
tmp = (0.3333333333333333d0 * (c / a)) ** 3.0d0
else
tmp = ((-0.3333333333333333d0) * (c * ((c / a) * c))) / ((-9.0d0) * (a * a))
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (Math.abs(b) <= 6.6e-128) {
tmp = Math.pow((0.3333333333333333 * (c / a)), 3.0);
} else {
tmp = (-0.3333333333333333 * (c * ((c / a) * c))) / (-9.0 * (a * a));
}
return tmp;
}
def code(a, b, c): tmp = 0 if math.fabs(b) <= 6.6e-128: tmp = math.pow((0.3333333333333333 * (c / a)), 3.0) else: tmp = (-0.3333333333333333 * (c * ((c / a) * c))) / (-9.0 * (a * a)) return tmp
function code(a, b, c) tmp = 0.0 if (abs(b) <= 6.6e-128) tmp = Float64(0.3333333333333333 * Float64(c / a)) ^ 3.0; else tmp = Float64(Float64(-0.3333333333333333 * Float64(c * Float64(Float64(c / a) * c))) / Float64(-9.0 * Float64(a * a))); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (abs(b) <= 6.6e-128) tmp = (0.3333333333333333 * (c / a)) ^ 3.0; else tmp = (-0.3333333333333333 * (c * ((c / a) * c))) / (-9.0 * (a * a)); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[N[Abs[b], $MachinePrecision], 6.6e-128], N[Power[N[(0.3333333333333333 * N[(c / a), $MachinePrecision]), $MachinePrecision], 3.0], $MachinePrecision], N[(N[(-0.3333333333333333 * N[(c * N[(N[(c / a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(-9.0 * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\left|b\right| \leq 6.6 \cdot 10^{-128}:\\
\;\;\;\;{\left(0.3333333333333333 \cdot \frac{c}{a}\right)}^{3}\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.3333333333333333 \cdot \left(c \cdot \left(\frac{c}{a} \cdot c\right)\right)}{-9 \cdot \left(a \cdot a\right)}\\
\end{array}
if b < 6.6e-128Initial program 81.4%
Taylor expanded in a around inf
lower-*.f64N/A
lower-/.f6458.7%
Applied rewrites58.7%
if 6.6e-128 < b Initial program 81.4%
lift-pow.f64N/A
cube-multN/A
lift-/.f64N/A
frac-2negN/A
associate-*l/N/A
lower-/.f64N/A
Applied rewrites36.9%
Taylor expanded in a around inf
lower-*.f64N/A
lower-/.f64N/A
lower-pow.f6442.4%
Applied rewrites42.4%
lift-/.f64N/A
lift-pow.f64N/A
cube-multN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6448.5%
Applied rewrites48.5%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f6450.1%
Applied rewrites50.1%
(FPCore (a b c) :precision binary64 (if (<= (fabs b) 4.8e-125) (/ (/ (* (* (/ (* c c) a) c) -0.3333333333333333) (* -9.0 a)) a) (/ (* -0.3333333333333333 (* c (* (/ c a) c))) (* -9.0 (* a a)))))
double code(double a, double b, double c) {
double tmp;
if (fabs(b) <= 4.8e-125) {
tmp = (((((c * c) / a) * c) * -0.3333333333333333) / (-9.0 * a)) / a;
} else {
tmp = (-0.3333333333333333 * (c * ((c / a) * c))) / (-9.0 * (a * a));
}
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) <= 4.8d-125) then
tmp = (((((c * c) / a) * c) * (-0.3333333333333333d0)) / ((-9.0d0) * a)) / a
else
tmp = ((-0.3333333333333333d0) * (c * ((c / a) * c))) / ((-9.0d0) * (a * a))
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (Math.abs(b) <= 4.8e-125) {
tmp = (((((c * c) / a) * c) * -0.3333333333333333) / (-9.0 * a)) / a;
} else {
tmp = (-0.3333333333333333 * (c * ((c / a) * c))) / (-9.0 * (a * a));
}
return tmp;
}
def code(a, b, c): tmp = 0 if math.fabs(b) <= 4.8e-125: tmp = (((((c * c) / a) * c) * -0.3333333333333333) / (-9.0 * a)) / a else: tmp = (-0.3333333333333333 * (c * ((c / a) * c))) / (-9.0 * (a * a)) return tmp
function code(a, b, c) tmp = 0.0 if (abs(b) <= 4.8e-125) tmp = Float64(Float64(Float64(Float64(Float64(Float64(c * c) / a) * c) * -0.3333333333333333) / Float64(-9.0 * a)) / a); else tmp = Float64(Float64(-0.3333333333333333 * Float64(c * Float64(Float64(c / a) * c))) / Float64(-9.0 * Float64(a * a))); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (abs(b) <= 4.8e-125) tmp = (((((c * c) / a) * c) * -0.3333333333333333) / (-9.0 * a)) / a; else tmp = (-0.3333333333333333 * (c * ((c / a) * c))) / (-9.0 * (a * a)); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[N[Abs[b], $MachinePrecision], 4.8e-125], N[(N[(N[(N[(N[(N[(c * c), $MachinePrecision] / a), $MachinePrecision] * c), $MachinePrecision] * -0.3333333333333333), $MachinePrecision] / N[(-9.0 * a), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(N[(-0.3333333333333333 * N[(c * N[(N[(c / a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(-9.0 * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\left|b\right| \leq 4.8 \cdot 10^{-125}:\\
\;\;\;\;\frac{\frac{\left(\frac{c \cdot c}{a} \cdot c\right) \cdot -0.3333333333333333}{-9 \cdot a}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.3333333333333333 \cdot \left(c \cdot \left(\frac{c}{a} \cdot c\right)\right)}{-9 \cdot \left(a \cdot a\right)}\\
\end{array}
if b < 4.8000000000000003e-125Initial program 81.4%
lift-pow.f64N/A
cube-multN/A
lift-/.f64N/A
frac-2negN/A
associate-*l/N/A
lower-/.f64N/A
Applied rewrites36.9%
Taylor expanded in a around inf
lower-*.f64N/A
lower-/.f64N/A
lower-pow.f6442.4%
Applied rewrites42.4%
lift-/.f64N/A
lift-pow.f64N/A
cube-multN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6448.5%
Applied rewrites48.5%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites50.0%
if 4.8000000000000003e-125 < b Initial program 81.4%
lift-pow.f64N/A
cube-multN/A
lift-/.f64N/A
frac-2negN/A
associate-*l/N/A
lower-/.f64N/A
Applied rewrites36.9%
Taylor expanded in a around inf
lower-*.f64N/A
lower-/.f64N/A
lower-pow.f6442.4%
Applied rewrites42.4%
lift-/.f64N/A
lift-pow.f64N/A
cube-multN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6448.5%
Applied rewrites48.5%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f6450.1%
Applied rewrites50.1%
(FPCore (a b c) :precision binary64 (if (<= (pow b 2.0) 5.2e-253) (/ (/ (* (* (* c c) (/ c a)) -0.3333333333333333) (* -9.0 a)) a) (/ (* -0.3333333333333333 (* c (* (/ c a) c))) (* -9.0 (* a a)))))
double code(double a, double b, double c) {
double tmp;
if (pow(b, 2.0) <= 5.2e-253) {
tmp = ((((c * c) * (c / a)) * -0.3333333333333333) / (-9.0 * a)) / a;
} else {
tmp = (-0.3333333333333333 * (c * ((c / a) * c))) / (-9.0 * (a * a));
}
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.0d0) <= 5.2d-253) then
tmp = ((((c * c) * (c / a)) * (-0.3333333333333333d0)) / ((-9.0d0) * a)) / a
else
tmp = ((-0.3333333333333333d0) * (c * ((c / a) * c))) / ((-9.0d0) * (a * a))
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (Math.pow(b, 2.0) <= 5.2e-253) {
tmp = ((((c * c) * (c / a)) * -0.3333333333333333) / (-9.0 * a)) / a;
} else {
tmp = (-0.3333333333333333 * (c * ((c / a) * c))) / (-9.0 * (a * a));
}
return tmp;
}
def code(a, b, c): tmp = 0 if math.pow(b, 2.0) <= 5.2e-253: tmp = ((((c * c) * (c / a)) * -0.3333333333333333) / (-9.0 * a)) / a else: tmp = (-0.3333333333333333 * (c * ((c / a) * c))) / (-9.0 * (a * a)) return tmp
function code(a, b, c) tmp = 0.0 if ((b ^ 2.0) <= 5.2e-253) tmp = Float64(Float64(Float64(Float64(Float64(c * c) * Float64(c / a)) * -0.3333333333333333) / Float64(-9.0 * a)) / a); else tmp = Float64(Float64(-0.3333333333333333 * Float64(c * Float64(Float64(c / a) * c))) / Float64(-9.0 * Float64(a * a))); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if ((b ^ 2.0) <= 5.2e-253) tmp = ((((c * c) * (c / a)) * -0.3333333333333333) / (-9.0 * a)) / a; else tmp = (-0.3333333333333333 * (c * ((c / a) * c))) / (-9.0 * (a * a)); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[N[Power[b, 2.0], $MachinePrecision], 5.2e-253], N[(N[(N[(N[(N[(c * c), $MachinePrecision] * N[(c / a), $MachinePrecision]), $MachinePrecision] * -0.3333333333333333), $MachinePrecision] / N[(-9.0 * a), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(N[(-0.3333333333333333 * N[(c * N[(N[(c / a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(-9.0 * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;{b}^{2} \leq 5.2 \cdot 10^{-253}:\\
\;\;\;\;\frac{\frac{\left(\left(c \cdot c\right) \cdot \frac{c}{a}\right) \cdot -0.3333333333333333}{-9 \cdot a}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.3333333333333333 \cdot \left(c \cdot \left(\frac{c}{a} \cdot c\right)\right)}{-9 \cdot \left(a \cdot a\right)}\\
\end{array}
if (pow.f64 b #s(literal 2 binary64)) < 5.1999999999999998e-253Initial program 81.4%
lift-pow.f64N/A
cube-multN/A
lift-/.f64N/A
frac-2negN/A
associate-*l/N/A
lower-/.f64N/A
Applied rewrites36.9%
Taylor expanded in a around inf
lower-*.f64N/A
lower-/.f64N/A
lower-pow.f6442.4%
Applied rewrites42.4%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites50.0%
if 5.1999999999999998e-253 < (pow.f64 b #s(literal 2 binary64)) Initial program 81.4%
lift-pow.f64N/A
cube-multN/A
lift-/.f64N/A
frac-2negN/A
associate-*l/N/A
lower-/.f64N/A
Applied rewrites36.9%
Taylor expanded in a around inf
lower-*.f64N/A
lower-/.f64N/A
lower-pow.f6442.4%
Applied rewrites42.4%
lift-/.f64N/A
lift-pow.f64N/A
cube-multN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6448.5%
Applied rewrites48.5%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f6450.1%
Applied rewrites50.1%
(FPCore (a b c) :precision binary64 (/ (* -0.3333333333333333 (* c (* (/ c a) c))) (* -9.0 (* a a))))
double code(double a, double b, double c) {
return (-0.3333333333333333 * (c * ((c / a) * c))) / (-9.0 * (a * 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.3333333333333333d0) * (c * ((c / a) * c))) / ((-9.0d0) * (a * a))
end function
public static double code(double a, double b, double c) {
return (-0.3333333333333333 * (c * ((c / a) * c))) / (-9.0 * (a * a));
}
def code(a, b, c): return (-0.3333333333333333 * (c * ((c / a) * c))) / (-9.0 * (a * a))
function code(a, b, c) return Float64(Float64(-0.3333333333333333 * Float64(c * Float64(Float64(c / a) * c))) / Float64(-9.0 * Float64(a * a))) end
function tmp = code(a, b, c) tmp = (-0.3333333333333333 * (c * ((c / a) * c))) / (-9.0 * (a * a)); end
code[a_, b_, c_] := N[(N[(-0.3333333333333333 * N[(c * N[(N[(c / a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(-9.0 * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{-0.3333333333333333 \cdot \left(c \cdot \left(\frac{c}{a} \cdot c\right)\right)}{-9 \cdot \left(a \cdot a\right)}
Initial program 81.4%
lift-pow.f64N/A
cube-multN/A
lift-/.f64N/A
frac-2negN/A
associate-*l/N/A
lower-/.f64N/A
Applied rewrites36.9%
Taylor expanded in a around inf
lower-*.f64N/A
lower-/.f64N/A
lower-pow.f6442.4%
Applied rewrites42.4%
lift-/.f64N/A
lift-pow.f64N/A
cube-multN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6448.5%
Applied rewrites48.5%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f6450.1%
Applied rewrites50.1%
herbie shell --seed 2025204
(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))