
(FPCore (x y z t a b) :precision binary64 (- (* (* 2.0 (sqrt x)) (cos (- y (/ (* z t) 3.0)))) (/ a (* b 3.0))))
double code(double x, double y, double z, double t, double a, double b) {
return ((2.0 * sqrt(x)) * cos((y - ((z * t) / 3.0)))) - (a / (b * 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(x, y, z, t, a, b)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
code = ((2.0d0 * sqrt(x)) * cos((y - ((z * t) / 3.0d0)))) - (a / (b * 3.0d0))
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return ((2.0 * Math.sqrt(x)) * Math.cos((y - ((z * t) / 3.0)))) - (a / (b * 3.0));
}
def code(x, y, z, t, a, b): return ((2.0 * math.sqrt(x)) * math.cos((y - ((z * t) / 3.0)))) - (a / (b * 3.0))
function code(x, y, z, t, a, b) return Float64(Float64(Float64(2.0 * sqrt(x)) * cos(Float64(y - Float64(Float64(z * t) / 3.0)))) - Float64(a / Float64(b * 3.0))) end
function tmp = code(x, y, z, t, a, b) tmp = ((2.0 * sqrt(x)) * cos((y - ((z * t) / 3.0)))) - (a / (b * 3.0)); end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(2.0 * N[Sqrt[x], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(y - N[(N[(z * t), $MachinePrecision] / 3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(a / N[(b * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(2 \cdot \sqrt{x}\right) \cdot \cos \left(y - \frac{z \cdot t}{3}\right) - \frac{a}{b \cdot 3}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a b) :precision binary64 (- (* (* 2.0 (sqrt x)) (cos (- y (/ (* z t) 3.0)))) (/ a (* b 3.0))))
double code(double x, double y, double z, double t, double a, double b) {
return ((2.0 * sqrt(x)) * cos((y - ((z * t) / 3.0)))) - (a / (b * 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(x, y, z, t, a, b)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
code = ((2.0d0 * sqrt(x)) * cos((y - ((z * t) / 3.0d0)))) - (a / (b * 3.0d0))
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return ((2.0 * Math.sqrt(x)) * Math.cos((y - ((z * t) / 3.0)))) - (a / (b * 3.0));
}
def code(x, y, z, t, a, b): return ((2.0 * math.sqrt(x)) * math.cos((y - ((z * t) / 3.0)))) - (a / (b * 3.0))
function code(x, y, z, t, a, b) return Float64(Float64(Float64(2.0 * sqrt(x)) * cos(Float64(y - Float64(Float64(z * t) / 3.0)))) - Float64(a / Float64(b * 3.0))) end
function tmp = code(x, y, z, t, a, b) tmp = ((2.0 * sqrt(x)) * cos((y - ((z * t) / 3.0)))) - (a / (b * 3.0)); end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(2.0 * N[Sqrt[x], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(y - N[(N[(z * t), $MachinePrecision] / 3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(a / N[(b * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(2 \cdot \sqrt{x}\right) \cdot \cos \left(y - \frac{z \cdot t}{3}\right) - \frac{a}{b \cdot 3}
\end{array}
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (* (sqrt x) 2.0)))
(if (<=
(- (* (* 2.0 (sqrt x)) (cos (- y (/ (* z t) 3.0)))) (/ a (* b 3.0)))
1e+154)
(fma
-0.3333333333333333
(/ a b)
(*
t_1
(fma
(cos y)
(cos (* (* t z) -0.3333333333333333))
(* (sin y) (sin (* (* t z) 0.3333333333333333))))))
(- (* t_1 (cos y)) (/ (/ a b) 3.0)))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = sqrt(x) * 2.0;
double tmp;
if ((((2.0 * sqrt(x)) * cos((y - ((z * t) / 3.0)))) - (a / (b * 3.0))) <= 1e+154) {
tmp = fma(-0.3333333333333333, (a / b), (t_1 * fma(cos(y), cos(((t * z) * -0.3333333333333333)), (sin(y) * sin(((t * z) * 0.3333333333333333))))));
} else {
tmp = (t_1 * cos(y)) - ((a / b) / 3.0);
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(sqrt(x) * 2.0) tmp = 0.0 if (Float64(Float64(Float64(2.0 * sqrt(x)) * cos(Float64(y - Float64(Float64(z * t) / 3.0)))) - Float64(a / Float64(b * 3.0))) <= 1e+154) tmp = fma(-0.3333333333333333, Float64(a / b), Float64(t_1 * fma(cos(y), cos(Float64(Float64(t * z) * -0.3333333333333333)), Float64(sin(y) * sin(Float64(Float64(t * z) * 0.3333333333333333)))))); else tmp = Float64(Float64(t_1 * cos(y)) - Float64(Float64(a / b) / 3.0)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[Sqrt[x], $MachinePrecision] * 2.0), $MachinePrecision]}, If[LessEqual[N[(N[(N[(2.0 * N[Sqrt[x], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(y - N[(N[(z * t), $MachinePrecision] / 3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(a / N[(b * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1e+154], N[(-0.3333333333333333 * N[(a / b), $MachinePrecision] + N[(t$95$1 * N[(N[Cos[y], $MachinePrecision] * N[Cos[N[(N[(t * z), $MachinePrecision] * -0.3333333333333333), $MachinePrecision]], $MachinePrecision] + N[(N[Sin[y], $MachinePrecision] * N[Sin[N[(N[(t * z), $MachinePrecision] * 0.3333333333333333), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$1 * N[Cos[y], $MachinePrecision]), $MachinePrecision] - N[(N[(a / b), $MachinePrecision] / 3.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \sqrt{x} \cdot 2\\
\mathbf{if}\;\left(2 \cdot \sqrt{x}\right) \cdot \cos \left(y - \frac{z \cdot t}{3}\right) - \frac{a}{b \cdot 3} \leq 10^{+154}:\\
\;\;\;\;\mathsf{fma}\left(-0.3333333333333333, \frac{a}{b}, t\_1 \cdot \mathsf{fma}\left(\cos y, \cos \left(\left(t \cdot z\right) \cdot -0.3333333333333333\right), \sin y \cdot \sin \left(\left(t \cdot z\right) \cdot 0.3333333333333333\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1 \cdot \cos y - \frac{\frac{a}{b}}{3}\\
\end{array}
\end{array}
if (-.f64 (*.f64 (*.f64 #s(literal 2 binary64) (sqrt.f64 x)) (cos.f64 (-.f64 y (/.f64 (*.f64 z t) #s(literal 3 binary64))))) (/.f64 a (*.f64 b #s(literal 3 binary64)))) < 1.00000000000000004e154Initial program 75.0%
Taylor expanded in x around 0
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sqrt.f64N/A
lower-cos.f64N/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
lower-fma.f64N/A
lower-*.f6475.2
Applied rewrites75.2%
lift-*.f64N/A
lift-fma.f64N/A
lower-cos.f64N/A
+-commutativeN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
cos-diffN/A
cos-negN/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f64N/A
Applied rewrites76.1%
if 1.00000000000000004e154 < (-.f64 (*.f64 (*.f64 #s(literal 2 binary64) (sqrt.f64 x)) (cos.f64 (-.f64 y (/.f64 (*.f64 z t) #s(literal 3 binary64))))) (/.f64 a (*.f64 b #s(literal 3 binary64)))) Initial program 54.3%
Taylor expanded in y around inf
Applied rewrites87.0%
lift-*.f64N/A
lift-sqrt.f64N/A
*-commutativeN/A
lift-sqrt.f64N/A
lift-*.f6487.0
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lift-/.f64N/A
lower-/.f6487.0
Applied rewrites87.0%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (/ a (* b 3.0))))
(if (<= t_1 -5e-14)
(* -0.3333333333333333 (/ a b))
(if (<= t_1 1e+23)
(* (* (sqrt x) 2.0) (cos (fma -0.3333333333333333 (* t z) y)))
(/ (* -0.3333333333333333 a) b)))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = a / (b * 3.0);
double tmp;
if (t_1 <= -5e-14) {
tmp = -0.3333333333333333 * (a / b);
} else if (t_1 <= 1e+23) {
tmp = (sqrt(x) * 2.0) * cos(fma(-0.3333333333333333, (t * z), y));
} else {
tmp = (-0.3333333333333333 * a) / b;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(a / Float64(b * 3.0)) tmp = 0.0 if (t_1 <= -5e-14) tmp = Float64(-0.3333333333333333 * Float64(a / b)); elseif (t_1 <= 1e+23) tmp = Float64(Float64(sqrt(x) * 2.0) * cos(fma(-0.3333333333333333, Float64(t * z), y))); else tmp = Float64(Float64(-0.3333333333333333 * a) / b); end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(a / N[(b * 3.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -5e-14], N[(-0.3333333333333333 * N[(a / b), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1e+23], N[(N[(N[Sqrt[x], $MachinePrecision] * 2.0), $MachinePrecision] * N[Cos[N[(-0.3333333333333333 * N[(t * z), $MachinePrecision] + y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(-0.3333333333333333 * a), $MachinePrecision] / b), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{a}{b \cdot 3}\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{-14}:\\
\;\;\;\;-0.3333333333333333 \cdot \frac{a}{b}\\
\mathbf{elif}\;t\_1 \leq 10^{+23}:\\
\;\;\;\;\left(\sqrt{x} \cdot 2\right) \cdot \cos \left(\mathsf{fma}\left(-0.3333333333333333, t \cdot z, y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.3333333333333333 \cdot a}{b}\\
\end{array}
\end{array}
if (/.f64 a (*.f64 b #s(literal 3 binary64))) < -5.0000000000000002e-14Initial program 79.3%
Taylor expanded in a around inf
lower-*.f64N/A
lower-/.f6487.6
Applied rewrites87.6%
if -5.0000000000000002e-14 < (/.f64 a (*.f64 b #s(literal 3 binary64))) < 9.9999999999999992e22Initial program 55.8%
Taylor expanded in x around inf
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sqrt.f64N/A
lower-cos.f64N/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
lower-fma.f64N/A
lower-*.f6450.6
Applied rewrites50.6%
if 9.9999999999999992e22 < (/.f64 a (*.f64 b #s(literal 3 binary64))) Initial program 84.9%
Taylor expanded in a around inf
lower-*.f64N/A
lower-/.f6490.0
Applied rewrites90.0%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f6490.1
Applied rewrites90.1%
(FPCore (x y z t a b) :precision binary64 (- (* (* (sqrt x) 2.0) (cos y)) (/ (/ a b) 3.0)))
double code(double x, double y, double z, double t, double a, double b) {
return ((sqrt(x) * 2.0) * cos(y)) - ((a / b) / 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(x, y, z, t, a, b)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
code = ((sqrt(x) * 2.0d0) * cos(y)) - ((a / b) / 3.0d0)
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return ((Math.sqrt(x) * 2.0) * Math.cos(y)) - ((a / b) / 3.0);
}
def code(x, y, z, t, a, b): return ((math.sqrt(x) * 2.0) * math.cos(y)) - ((a / b) / 3.0)
function code(x, y, z, t, a, b) return Float64(Float64(Float64(sqrt(x) * 2.0) * cos(y)) - Float64(Float64(a / b) / 3.0)) end
function tmp = code(x, y, z, t, a, b) tmp = ((sqrt(x) * 2.0) * cos(y)) - ((a / b) / 3.0); end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(N[Sqrt[x], $MachinePrecision] * 2.0), $MachinePrecision] * N[Cos[y], $MachinePrecision]), $MachinePrecision] - N[(N[(a / b), $MachinePrecision] / 3.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\sqrt{x} \cdot 2\right) \cdot \cos y - \frac{\frac{a}{b}}{3}
\end{array}
Initial program 69.5%
Taylor expanded in y around inf
Applied rewrites77.3%
lift-*.f64N/A
lift-sqrt.f64N/A
*-commutativeN/A
lift-sqrt.f64N/A
lift-*.f6477.3
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lift-/.f64N/A
lower-/.f6477.3
Applied rewrites77.3%
(FPCore (x y z t a b) :precision binary64 (- (* (* 2.0 (sqrt x)) (cos y)) (/ a (* b 3.0))))
double code(double x, double y, double z, double t, double a, double b) {
return ((2.0 * sqrt(x)) * cos(y)) - (a / (b * 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(x, y, z, t, a, b)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
code = ((2.0d0 * sqrt(x)) * cos(y)) - (a / (b * 3.0d0))
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return ((2.0 * Math.sqrt(x)) * Math.cos(y)) - (a / (b * 3.0));
}
def code(x, y, z, t, a, b): return ((2.0 * math.sqrt(x)) * math.cos(y)) - (a / (b * 3.0))
function code(x, y, z, t, a, b) return Float64(Float64(Float64(2.0 * sqrt(x)) * cos(y)) - Float64(a / Float64(b * 3.0))) end
function tmp = code(x, y, z, t, a, b) tmp = ((2.0 * sqrt(x)) * cos(y)) - (a / (b * 3.0)); end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(2.0 * N[Sqrt[x], $MachinePrecision]), $MachinePrecision] * N[Cos[y], $MachinePrecision]), $MachinePrecision] - N[(a / N[(b * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(2 \cdot \sqrt{x}\right) \cdot \cos y - \frac{a}{b \cdot 3}
\end{array}
Initial program 69.5%
Taylor expanded in y around inf
Applied rewrites77.3%
(FPCore (x y z t a b) :precision binary64 (fma -0.3333333333333333 (/ a b) (* (* (sqrt x) 2.0) (cos y))))
double code(double x, double y, double z, double t, double a, double b) {
return fma(-0.3333333333333333, (a / b), ((sqrt(x) * 2.0) * cos(y)));
}
function code(x, y, z, t, a, b) return fma(-0.3333333333333333, Float64(a / b), Float64(Float64(sqrt(x) * 2.0) * cos(y))) end
code[x_, y_, z_, t_, a_, b_] := N[(-0.3333333333333333 * N[(a / b), $MachinePrecision] + N[(N[(N[Sqrt[x], $MachinePrecision] * 2.0), $MachinePrecision] * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(-0.3333333333333333, \frac{a}{b}, \left(\sqrt{x} \cdot 2\right) \cdot \cos y\right)
\end{array}
Initial program 69.5%
Taylor expanded in x around 0
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sqrt.f64N/A
lower-cos.f64N/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
lower-fma.f64N/A
lower-*.f6469.6
Applied rewrites69.6%
Taylor expanded in y around inf
Applied rewrites77.3%
(FPCore (x y z t a b) :precision binary64 (/ (* -0.3333333333333333 a) b))
double code(double x, double y, double z, double t, double a, double b) {
return (-0.3333333333333333 * 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(x, y, z, t, a, b)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
code = ((-0.3333333333333333d0) * a) / b
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return (-0.3333333333333333 * a) / b;
}
def code(x, y, z, t, a, b): return (-0.3333333333333333 * a) / b
function code(x, y, z, t, a, b) return Float64(Float64(-0.3333333333333333 * a) / b) end
function tmp = code(x, y, z, t, a, b) tmp = (-0.3333333333333333 * a) / b; end
code[x_, y_, z_, t_, a_, b_] := N[(N[(-0.3333333333333333 * a), $MachinePrecision] / b), $MachinePrecision]
\begin{array}{l}
\\
\frac{-0.3333333333333333 \cdot a}{b}
\end{array}
Initial program 69.5%
Taylor expanded in a around inf
lower-*.f64N/A
lower-/.f6451.6
Applied rewrites51.6%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f6451.6
Applied rewrites51.6%
(FPCore (x y z t a b) :precision binary64 (* -0.3333333333333333 (/ a b)))
double code(double x, double y, double z, double t, double a, double b) {
return -0.3333333333333333 * (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(x, y, z, t, a, b)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (-0.3333333333333333d0) * (a / b)
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return -0.3333333333333333 * (a / b);
}
def code(x, y, z, t, a, b): return -0.3333333333333333 * (a / b)
function code(x, y, z, t, a, b) return Float64(-0.3333333333333333 * Float64(a / b)) end
function tmp = code(x, y, z, t, a, b) tmp = -0.3333333333333333 * (a / b); end
code[x_, y_, z_, t_, a_, b_] := N[(-0.3333333333333333 * N[(a / b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-0.3333333333333333 \cdot \frac{a}{b}
\end{array}
Initial program 69.5%
Taylor expanded in a around inf
lower-*.f64N/A
lower-/.f6451.6
Applied rewrites51.6%
herbie shell --seed 2025084
(FPCore (x y z t a b)
:name "Diagrams.Solve.Polynomial:cubForm from diagrams-solve-0.1, K"
:precision binary64
:alt
(! :herbie-platform default (if (< z -1379333748723514100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (- (* (* 2 (sqrt x)) (cos (- (/ 1 y) (/ (/ 3333333333333333/10000000000000000 z) t)))) (/ (/ a 3) b)) (if (< z 35162906135559870000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (- (* (* (sqrt x) 2) (cos (- y (* (/ t 3) z)))) (/ (/ a 3) b)) (- (* (cos (- y (/ (/ 3333333333333333/10000000000000000 z) t))) (* 2 (sqrt x))) (/ (/ a b) 3)))))
(- (* (* 2.0 (sqrt x)) (cos (- y (/ (* z t) 3.0)))) (/ a (* b 3.0))))