
(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}
Herbie found 13 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 (/ a (* b 3.0))) (t_2 (* -0.3333333333333333 (* t z))))
(if (<= (cos (- y (/ (* z t) 3.0))) 2.0)
(-
(* (* 2.0 (sqrt x)) (- (* (cos t_2) (cos y)) (* (sin t_2) (sin y))))
t_1)
(- (* (* (* x (cos y)) (/ 1.0 (sqrt x))) -2.0) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = a / (b * 3.0);
double t_2 = -0.3333333333333333 * (t * z);
double tmp;
if (cos((y - ((z * t) / 3.0))) <= 2.0) {
tmp = ((2.0 * sqrt(x)) * ((cos(t_2) * cos(y)) - (sin(t_2) * sin(y)))) - t_1;
} else {
tmp = (((x * cos(y)) * (1.0 / sqrt(x))) * -2.0) - t_1;
}
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(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
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = a / (b * 3.0d0)
t_2 = (-0.3333333333333333d0) * (t * z)
if (cos((y - ((z * t) / 3.0d0))) <= 2.0d0) then
tmp = ((2.0d0 * sqrt(x)) * ((cos(t_2) * cos(y)) - (sin(t_2) * sin(y)))) - t_1
else
tmp = (((x * cos(y)) * (1.0d0 / sqrt(x))) * (-2.0d0)) - t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
double t_1 = a / (b * 3.0);
double t_2 = -0.3333333333333333 * (t * z);
double tmp;
if (Math.cos((y - ((z * t) / 3.0))) <= 2.0) {
tmp = ((2.0 * Math.sqrt(x)) * ((Math.cos(t_2) * Math.cos(y)) - (Math.sin(t_2) * Math.sin(y)))) - t_1;
} else {
tmp = (((x * Math.cos(y)) * (1.0 / Math.sqrt(x))) * -2.0) - t_1;
}
return tmp;
}
def code(x, y, z, t, a, b): t_1 = a / (b * 3.0) t_2 = -0.3333333333333333 * (t * z) tmp = 0 if math.cos((y - ((z * t) / 3.0))) <= 2.0: tmp = ((2.0 * math.sqrt(x)) * ((math.cos(t_2) * math.cos(y)) - (math.sin(t_2) * math.sin(y)))) - t_1 else: tmp = (((x * math.cos(y)) * (1.0 / math.sqrt(x))) * -2.0) - t_1 return tmp
function code(x, y, z, t, a, b) t_1 = Float64(a / Float64(b * 3.0)) t_2 = Float64(-0.3333333333333333 * Float64(t * z)) tmp = 0.0 if (cos(Float64(y - Float64(Float64(z * t) / 3.0))) <= 2.0) tmp = Float64(Float64(Float64(2.0 * sqrt(x)) * Float64(Float64(cos(t_2) * cos(y)) - Float64(sin(t_2) * sin(y)))) - t_1); else tmp = Float64(Float64(Float64(Float64(x * cos(y)) * Float64(1.0 / sqrt(x))) * -2.0) - t_1); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) t_1 = a / (b * 3.0); t_2 = -0.3333333333333333 * (t * z); tmp = 0.0; if (cos((y - ((z * t) / 3.0))) <= 2.0) tmp = ((2.0 * sqrt(x)) * ((cos(t_2) * cos(y)) - (sin(t_2) * sin(y)))) - t_1; else tmp = (((x * cos(y)) * (1.0 / sqrt(x))) * -2.0) - t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(a / N[(b * 3.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(-0.3333333333333333 * N[(t * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Cos[N[(y - N[(N[(z * t), $MachinePrecision] / 3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], N[(N[(N[(2.0 * N[Sqrt[x], $MachinePrecision]), $MachinePrecision] * N[(N[(N[Cos[t$95$2], $MachinePrecision] * N[Cos[y], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[t$95$2], $MachinePrecision] * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision], N[(N[(N[(N[(x * N[Cos[y], $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -2.0), $MachinePrecision] - t$95$1), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{a}{b \cdot 3}\\
t_2 := -0.3333333333333333 \cdot \left(t \cdot z\right)\\
\mathbf{if}\;\cos \left(y - \frac{z \cdot t}{3}\right) \leq 2:\\
\;\;\;\;\left(2 \cdot \sqrt{x}\right) \cdot \left(\cos t\_2 \cdot \cos y - \sin t\_2 \cdot \sin y\right) - t\_1\\
\mathbf{else}:\\
\;\;\;\;\left(\left(x \cdot \cos y\right) \cdot \frac{1}{\sqrt{x}}\right) \cdot -2 - t\_1\\
\end{array}
\end{array}
if (cos.f64 (-.f64 y (/.f64 (*.f64 z t) #s(literal 3 binary64)))) < 2Initial program 70.2%
lift-cos.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
metadata-evalN/A
*-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
cos-sumN/A
metadata-evalN/A
distribute-lft-neg-inN/A
cos-negN/A
cos-neg-revN/A
mul-1-negN/A
lower--.f64N/A
Applied rewrites70.7%
if 2 < (cos.f64 (-.f64 y (/.f64 (*.f64 z t) #s(literal 3 binary64)))) Initial program 70.2%
Taylor expanded in z around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lift-sqrt.f6476.5
Applied rewrites76.5%
Taylor expanded in x around -inf
*-commutativeN/A
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
sqrt-divN/A
metadata-evalN/A
lower-/.f64N/A
lift-sqrt.f6451.1
Applied rewrites51.1%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (/ a (* b 3.0))))
(if (<= (cos (- y (/ (* z t) 3.0))) 2.0)
(-
(*
(* 2.0 (sqrt x))
(fma
(cos y)
(cos (* -0.3333333333333333 (* t z)))
(* (sin y) (sin (* (* t z) 0.3333333333333333)))))
t_1)
(- (* (* (* x (cos y)) (/ 1.0 (sqrt x))) -2.0) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = a / (b * 3.0);
double tmp;
if (cos((y - ((z * t) / 3.0))) <= 2.0) {
tmp = ((2.0 * sqrt(x)) * fma(cos(y), cos((-0.3333333333333333 * (t * z))), (sin(y) * sin(((t * z) * 0.3333333333333333))))) - t_1;
} else {
tmp = (((x * cos(y)) * (1.0 / sqrt(x))) * -2.0) - t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(a / Float64(b * 3.0)) tmp = 0.0 if (cos(Float64(y - Float64(Float64(z * t) / 3.0))) <= 2.0) tmp = Float64(Float64(Float64(2.0 * sqrt(x)) * fma(cos(y), cos(Float64(-0.3333333333333333 * Float64(t * z))), Float64(sin(y) * sin(Float64(Float64(t * z) * 0.3333333333333333))))) - t_1); else tmp = Float64(Float64(Float64(Float64(x * cos(y)) * Float64(1.0 / sqrt(x))) * -2.0) - t_1); 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[N[Cos[N[(y - N[(N[(z * t), $MachinePrecision] / 3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], N[(N[(N[(2.0 * N[Sqrt[x], $MachinePrecision]), $MachinePrecision] * N[(N[Cos[y], $MachinePrecision] * N[Cos[N[(-0.3333333333333333 * N[(t * z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[(N[Sin[y], $MachinePrecision] * N[Sin[N[(N[(t * z), $MachinePrecision] * 0.3333333333333333), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision], N[(N[(N[(N[(x * N[Cos[y], $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -2.0), $MachinePrecision] - t$95$1), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{a}{b \cdot 3}\\
\mathbf{if}\;\cos \left(y - \frac{z \cdot t}{3}\right) \leq 2:\\
\;\;\;\;\left(2 \cdot \sqrt{x}\right) \cdot \mathsf{fma}\left(\cos y, \cos \left(-0.3333333333333333 \cdot \left(t \cdot z\right)\right), \sin y \cdot \sin \left(\left(t \cdot z\right) \cdot 0.3333333333333333\right)\right) - t\_1\\
\mathbf{else}:\\
\;\;\;\;\left(\left(x \cdot \cos y\right) \cdot \frac{1}{\sqrt{x}}\right) \cdot -2 - t\_1\\
\end{array}
\end{array}
if (cos.f64 (-.f64 y (/.f64 (*.f64 z t) #s(literal 3 binary64)))) < 2Initial program 70.2%
lift-cos.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-/.f64N/A
cos-diffN/A
mult-flipN/A
*-commutativeN/A
metadata-evalN/A
*-commutativeN/A
cos-negN/A
mult-flipN/A
*-commutativeN/A
metadata-evalN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites70.7%
if 2 < (cos.f64 (-.f64 y (/.f64 (*.f64 z t) #s(literal 3 binary64)))) Initial program 70.2%
Taylor expanded in z around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lift-sqrt.f6476.5
Applied rewrites76.5%
Taylor expanded in x around -inf
*-commutativeN/A
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
sqrt-divN/A
metadata-evalN/A
lower-/.f64N/A
lift-sqrt.f6451.1
Applied rewrites51.1%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (/ a (* b 3.0)))
(t_2 (- (* (* 2.0 (sqrt x)) (cos (- y (/ (* z t) 3.0)))) t_1)))
(if (<= t_2 1e+152)
t_2
(- (* (* (* x (cos y)) (/ 1.0 (sqrt x))) -2.0) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = a / (b * 3.0);
double t_2 = ((2.0 * sqrt(x)) * cos((y - ((z * t) / 3.0)))) - t_1;
double tmp;
if (t_2 <= 1e+152) {
tmp = t_2;
} else {
tmp = (((x * cos(y)) * (1.0 / sqrt(x))) * -2.0) - t_1;
}
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(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
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = a / (b * 3.0d0)
t_2 = ((2.0d0 * sqrt(x)) * cos((y - ((z * t) / 3.0d0)))) - t_1
if (t_2 <= 1d+152) then
tmp = t_2
else
tmp = (((x * cos(y)) * (1.0d0 / sqrt(x))) * (-2.0d0)) - t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
double t_1 = a / (b * 3.0);
double t_2 = ((2.0 * Math.sqrt(x)) * Math.cos((y - ((z * t) / 3.0)))) - t_1;
double tmp;
if (t_2 <= 1e+152) {
tmp = t_2;
} else {
tmp = (((x * Math.cos(y)) * (1.0 / Math.sqrt(x))) * -2.0) - t_1;
}
return tmp;
}
def code(x, y, z, t, a, b): t_1 = a / (b * 3.0) t_2 = ((2.0 * math.sqrt(x)) * math.cos((y - ((z * t) / 3.0)))) - t_1 tmp = 0 if t_2 <= 1e+152: tmp = t_2 else: tmp = (((x * math.cos(y)) * (1.0 / math.sqrt(x))) * -2.0) - t_1 return tmp
function code(x, y, z, t, a, b) t_1 = Float64(a / Float64(b * 3.0)) t_2 = Float64(Float64(Float64(2.0 * sqrt(x)) * cos(Float64(y - Float64(Float64(z * t) / 3.0)))) - t_1) tmp = 0.0 if (t_2 <= 1e+152) tmp = t_2; else tmp = Float64(Float64(Float64(Float64(x * cos(y)) * Float64(1.0 / sqrt(x))) * -2.0) - t_1); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) t_1 = a / (b * 3.0); t_2 = ((2.0 * sqrt(x)) * cos((y - ((z * t) / 3.0)))) - t_1; tmp = 0.0; if (t_2 <= 1e+152) tmp = t_2; else tmp = (((x * cos(y)) * (1.0 / sqrt(x))) * -2.0) - t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(a / N[(b * 3.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = 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] - t$95$1), $MachinePrecision]}, If[LessEqual[t$95$2, 1e+152], t$95$2, N[(N[(N[(N[(x * N[Cos[y], $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -2.0), $MachinePrecision] - t$95$1), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{a}{b \cdot 3}\\
t_2 := \left(2 \cdot \sqrt{x}\right) \cdot \cos \left(y - \frac{z \cdot t}{3}\right) - t\_1\\
\mathbf{if}\;t\_2 \leq 10^{+152}:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;\left(\left(x \cdot \cos y\right) \cdot \frac{1}{\sqrt{x}}\right) \cdot -2 - t\_1\\
\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)))) < 1e152Initial program 70.2%
if 1e152 < (-.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 70.2%
Taylor expanded in z around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lift-sqrt.f6476.5
Applied rewrites76.5%
Taylor expanded in x around -inf
*-commutativeN/A
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
sqrt-divN/A
metadata-evalN/A
lower-/.f64N/A
lift-sqrt.f6451.1
Applied rewrites51.1%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (/ a (* b 3.0)))
(t_2 (* (* 2.0 (sqrt x)) (cos (- y (/ (* z t) 3.0))))))
(if (<= (- t_2 t_1) 1e+152)
(- t_2 (* a (/ 0.3333333333333333 b)))
(- (* (* (* x (cos y)) (/ 1.0 (sqrt x))) -2.0) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = a / (b * 3.0);
double t_2 = (2.0 * sqrt(x)) * cos((y - ((z * t) / 3.0)));
double tmp;
if ((t_2 - t_1) <= 1e+152) {
tmp = t_2 - (a * (0.3333333333333333 / b));
} else {
tmp = (((x * cos(y)) * (1.0 / sqrt(x))) * -2.0) - t_1;
}
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(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
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = a / (b * 3.0d0)
t_2 = (2.0d0 * sqrt(x)) * cos((y - ((z * t) / 3.0d0)))
if ((t_2 - t_1) <= 1d+152) then
tmp = t_2 - (a * (0.3333333333333333d0 / b))
else
tmp = (((x * cos(y)) * (1.0d0 / sqrt(x))) * (-2.0d0)) - t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
double t_1 = a / (b * 3.0);
double t_2 = (2.0 * Math.sqrt(x)) * Math.cos((y - ((z * t) / 3.0)));
double tmp;
if ((t_2 - t_1) <= 1e+152) {
tmp = t_2 - (a * (0.3333333333333333 / b));
} else {
tmp = (((x * Math.cos(y)) * (1.0 / Math.sqrt(x))) * -2.0) - t_1;
}
return tmp;
}
def code(x, y, z, t, a, b): t_1 = a / (b * 3.0) t_2 = (2.0 * math.sqrt(x)) * math.cos((y - ((z * t) / 3.0))) tmp = 0 if (t_2 - t_1) <= 1e+152: tmp = t_2 - (a * (0.3333333333333333 / b)) else: tmp = (((x * math.cos(y)) * (1.0 / math.sqrt(x))) * -2.0) - t_1 return tmp
function code(x, y, z, t, a, b) t_1 = Float64(a / Float64(b * 3.0)) t_2 = Float64(Float64(2.0 * sqrt(x)) * cos(Float64(y - Float64(Float64(z * t) / 3.0)))) tmp = 0.0 if (Float64(t_2 - t_1) <= 1e+152) tmp = Float64(t_2 - Float64(a * Float64(0.3333333333333333 / b))); else tmp = Float64(Float64(Float64(Float64(x * cos(y)) * Float64(1.0 / sqrt(x))) * -2.0) - t_1); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) t_1 = a / (b * 3.0); t_2 = (2.0 * sqrt(x)) * cos((y - ((z * t) / 3.0))); tmp = 0.0; if ((t_2 - t_1) <= 1e+152) tmp = t_2 - (a * (0.3333333333333333 / b)); else tmp = (((x * cos(y)) * (1.0 / sqrt(x))) * -2.0) - t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(a / N[(b * 3.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(2.0 * N[Sqrt[x], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(y - N[(N[(z * t), $MachinePrecision] / 3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$2 - t$95$1), $MachinePrecision], 1e+152], N[(t$95$2 - N[(a * N[(0.3333333333333333 / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(x * N[Cos[y], $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -2.0), $MachinePrecision] - t$95$1), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{a}{b \cdot 3}\\
t_2 := \left(2 \cdot \sqrt{x}\right) \cdot \cos \left(y - \frac{z \cdot t}{3}\right)\\
\mathbf{if}\;t\_2 - t\_1 \leq 10^{+152}:\\
\;\;\;\;t\_2 - a \cdot \frac{0.3333333333333333}{b}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(x \cdot \cos y\right) \cdot \frac{1}{\sqrt{x}}\right) \cdot -2 - t\_1\\
\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)))) < 1e152Initial program 70.2%
lift-*.f64N/A
lift-/.f64N/A
mult-flipN/A
metadata-evalN/A
*-commutativeN/A
frac-timesN/A
metadata-evalN/A
lower-*.f64N/A
mult-flip-revN/A
lower-/.f6470.2
Applied rewrites70.2%
if 1e152 < (-.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 70.2%
Taylor expanded in z around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lift-sqrt.f6476.5
Applied rewrites76.5%
Taylor expanded in x around -inf
*-commutativeN/A
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
sqrt-divN/A
metadata-evalN/A
lower-/.f64N/A
lift-sqrt.f6451.1
Applied rewrites51.1%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (/ a (* b 3.0))))
(if (<= (- (* (* 2.0 (sqrt x)) (cos (- y (/ (* z t) 3.0)))) t_1) 1e+152)
(fma
-0.3333333333333333
(/ a b)
(* (cos (fma (* -0.3333333333333333 t) z y)) (* (sqrt x) 2.0)))
(- (* (* (* x (cos y)) (/ 1.0 (sqrt x))) -2.0) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = a / (b * 3.0);
double tmp;
if ((((2.0 * sqrt(x)) * cos((y - ((z * t) / 3.0)))) - t_1) <= 1e+152) {
tmp = fma(-0.3333333333333333, (a / b), (cos(fma((-0.3333333333333333 * t), z, y)) * (sqrt(x) * 2.0)));
} else {
tmp = (((x * cos(y)) * (1.0 / sqrt(x))) * -2.0) - t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(a / Float64(b * 3.0)) tmp = 0.0 if (Float64(Float64(Float64(2.0 * sqrt(x)) * cos(Float64(y - Float64(Float64(z * t) / 3.0)))) - t_1) <= 1e+152) tmp = fma(-0.3333333333333333, Float64(a / b), Float64(cos(fma(Float64(-0.3333333333333333 * t), z, y)) * Float64(sqrt(x) * 2.0))); else tmp = Float64(Float64(Float64(Float64(x * cos(y)) * Float64(1.0 / sqrt(x))) * -2.0) - t_1); 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[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] - t$95$1), $MachinePrecision], 1e+152], N[(-0.3333333333333333 * N[(a / b), $MachinePrecision] + N[(N[Cos[N[(N[(-0.3333333333333333 * t), $MachinePrecision] * z + y), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[x], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(x * N[Cos[y], $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -2.0), $MachinePrecision] - t$95$1), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{a}{b \cdot 3}\\
\mathbf{if}\;\left(2 \cdot \sqrt{x}\right) \cdot \cos \left(y - \frac{z \cdot t}{3}\right) - t\_1 \leq 10^{+152}:\\
\;\;\;\;\mathsf{fma}\left(-0.3333333333333333, \frac{a}{b}, \cos \left(\mathsf{fma}\left(-0.3333333333333333 \cdot t, z, y\right)\right) \cdot \left(\sqrt{x} \cdot 2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(x \cdot \cos y\right) \cdot \frac{1}{\sqrt{x}}\right) \cdot -2 - t\_1\\
\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)))) < 1e152Initial program 70.2%
Taylor expanded in x around 0
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
*-commutativeN/A
metadata-evalN/A
mult-flipN/A
Applied rewrites70.2%
if 1e152 < (-.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 70.2%
Taylor expanded in z around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lift-sqrt.f6476.5
Applied rewrites76.5%
Taylor expanded in x around -inf
*-commutativeN/A
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
sqrt-divN/A
metadata-evalN/A
lower-/.f64N/A
lift-sqrt.f6451.1
Applied rewrites51.1%
(FPCore (x y z t a b) :precision binary64 (- (* (* 2.0 (cos y)) (sqrt x)) (/ a (* b 3.0))))
double code(double x, double y, double z, double t, double a, double b) {
return ((2.0 * cos(y)) * sqrt(x)) - (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 * cos(y)) * sqrt(x)) - (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.cos(y)) * Math.sqrt(x)) - (a / (b * 3.0));
}
def code(x, y, z, t, a, b): return ((2.0 * math.cos(y)) * math.sqrt(x)) - (a / (b * 3.0))
function code(x, y, z, t, a, b) return Float64(Float64(Float64(2.0 * cos(y)) * sqrt(x)) - Float64(a / Float64(b * 3.0))) end
function tmp = code(x, y, z, t, a, b) tmp = ((2.0 * cos(y)) * sqrt(x)) - (a / (b * 3.0)); end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(2.0 * N[Cos[y], $MachinePrecision]), $MachinePrecision] * N[Sqrt[x], $MachinePrecision]), $MachinePrecision] - N[(a / N[(b * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(2 \cdot \cos y\right) \cdot \sqrt{x} - \frac{a}{b \cdot 3}
\end{array}
Initial program 70.2%
Taylor expanded in z around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lift-sqrt.f6476.5
Applied rewrites76.5%
(FPCore (x y z t a b) :precision binary64 (fma (* 2.0 (cos y)) (sqrt x) (* -0.3333333333333333 (/ a b))))
double code(double x, double y, double z, double t, double a, double b) {
return fma((2.0 * cos(y)), sqrt(x), (-0.3333333333333333 * (a / b)));
}
function code(x, y, z, t, a, b) return fma(Float64(2.0 * cos(y)), sqrt(x), Float64(-0.3333333333333333 * Float64(a / b))) end
code[x_, y_, z_, t_, a_, b_] := N[(N[(2.0 * N[Cos[y], $MachinePrecision]), $MachinePrecision] * N[Sqrt[x], $MachinePrecision] + N[(-0.3333333333333333 * N[(a / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(2 \cdot \cos y, \sqrt{x}, -0.3333333333333333 \cdot \frac{a}{b}\right)
\end{array}
Initial program 70.2%
Taylor expanded in z around 0
fp-cancel-sub-sign-invN/A
associate-*r*N/A
metadata-evalN/A
lower-fma.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lift-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6476.4
Applied rewrites76.4%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (/ a (* b 3.0))) (t_2 (* 2.0 (sqrt x))))
(if (<= t_1 -1e-36)
(- t_2 (/ (/ a b) 3.0))
(if (<= t_1 2e-95)
(* (cos (fma (* -0.3333333333333333 t) z y)) (* (sqrt x) 2.0))
(- t_2 t_1)))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = a / (b * 3.0);
double t_2 = 2.0 * sqrt(x);
double tmp;
if (t_1 <= -1e-36) {
tmp = t_2 - ((a / b) / 3.0);
} else if (t_1 <= 2e-95) {
tmp = cos(fma((-0.3333333333333333 * t), z, y)) * (sqrt(x) * 2.0);
} else {
tmp = t_2 - t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(a / Float64(b * 3.0)) t_2 = Float64(2.0 * sqrt(x)) tmp = 0.0 if (t_1 <= -1e-36) tmp = Float64(t_2 - Float64(Float64(a / b) / 3.0)); elseif (t_1 <= 2e-95) tmp = Float64(cos(fma(Float64(-0.3333333333333333 * t), z, y)) * Float64(sqrt(x) * 2.0)); else tmp = Float64(t_2 - t_1); end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(a / N[(b * 3.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(2.0 * N[Sqrt[x], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -1e-36], N[(t$95$2 - N[(N[(a / b), $MachinePrecision] / 3.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2e-95], N[(N[Cos[N[(N[(-0.3333333333333333 * t), $MachinePrecision] * z + y), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[x], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision], N[(t$95$2 - t$95$1), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{a}{b \cdot 3}\\
t_2 := 2 \cdot \sqrt{x}\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{-36}:\\
\;\;\;\;t\_2 - \frac{\frac{a}{b}}{3}\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{-95}:\\
\;\;\;\;\cos \left(\mathsf{fma}\left(-0.3333333333333333 \cdot t, z, y\right)\right) \cdot \left(\sqrt{x} \cdot 2\right)\\
\mathbf{else}:\\
\;\;\;\;t\_2 - t\_1\\
\end{array}
\end{array}
if (/.f64 a (*.f64 b #s(literal 3 binary64))) < -9.9999999999999994e-37Initial program 70.2%
Taylor expanded in z around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lift-sqrt.f6476.5
Applied rewrites76.5%
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lift-/.f6476.5
Applied rewrites76.5%
Taylor expanded in y around 0
Applied rewrites65.3%
if -9.9999999999999994e-37 < (/.f64 a (*.f64 b #s(literal 3 binary64))) < 1.99999999999999998e-95Initial program 70.2%
Taylor expanded in a around inf
lower-*.f64N/A
lower-/.f6449.7
Applied rewrites49.7%
lift-/.f64N/A
mult-flipN/A
lower-*.f64N/A
lower-/.f6449.7
Applied rewrites49.7%
Taylor expanded in a around 0
Applied rewrites28.8%
if 1.99999999999999998e-95 < (/.f64 a (*.f64 b #s(literal 3 binary64))) Initial program 70.2%
Taylor expanded in z around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lift-sqrt.f6476.5
Applied rewrites76.5%
Taylor expanded in y around 0
Applied rewrites65.3%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (/ a (* b 3.0))) (t_2 (* 2.0 (sqrt x))))
(if (<= t_1 -1e-36)
(- t_2 (/ (/ a b) 3.0))
(if (<= t_1 2e-95) (* (* 2.0 (cos y)) (sqrt x)) (- t_2 t_1)))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = a / (b * 3.0);
double t_2 = 2.0 * sqrt(x);
double tmp;
if (t_1 <= -1e-36) {
tmp = t_2 - ((a / b) / 3.0);
} else if (t_1 <= 2e-95) {
tmp = (2.0 * cos(y)) * sqrt(x);
} else {
tmp = t_2 - t_1;
}
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(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
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = a / (b * 3.0d0)
t_2 = 2.0d0 * sqrt(x)
if (t_1 <= (-1d-36)) then
tmp = t_2 - ((a / b) / 3.0d0)
else if (t_1 <= 2d-95) then
tmp = (2.0d0 * cos(y)) * sqrt(x)
else
tmp = t_2 - t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
double t_1 = a / (b * 3.0);
double t_2 = 2.0 * Math.sqrt(x);
double tmp;
if (t_1 <= -1e-36) {
tmp = t_2 - ((a / b) / 3.0);
} else if (t_1 <= 2e-95) {
tmp = (2.0 * Math.cos(y)) * Math.sqrt(x);
} else {
tmp = t_2 - t_1;
}
return tmp;
}
def code(x, y, z, t, a, b): t_1 = a / (b * 3.0) t_2 = 2.0 * math.sqrt(x) tmp = 0 if t_1 <= -1e-36: tmp = t_2 - ((a / b) / 3.0) elif t_1 <= 2e-95: tmp = (2.0 * math.cos(y)) * math.sqrt(x) else: tmp = t_2 - t_1 return tmp
function code(x, y, z, t, a, b) t_1 = Float64(a / Float64(b * 3.0)) t_2 = Float64(2.0 * sqrt(x)) tmp = 0.0 if (t_1 <= -1e-36) tmp = Float64(t_2 - Float64(Float64(a / b) / 3.0)); elseif (t_1 <= 2e-95) tmp = Float64(Float64(2.0 * cos(y)) * sqrt(x)); else tmp = Float64(t_2 - t_1); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) t_1 = a / (b * 3.0); t_2 = 2.0 * sqrt(x); tmp = 0.0; if (t_1 <= -1e-36) tmp = t_2 - ((a / b) / 3.0); elseif (t_1 <= 2e-95) tmp = (2.0 * cos(y)) * sqrt(x); else tmp = t_2 - t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(a / N[(b * 3.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(2.0 * N[Sqrt[x], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -1e-36], N[(t$95$2 - N[(N[(a / b), $MachinePrecision] / 3.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2e-95], N[(N[(2.0 * N[Cos[y], $MachinePrecision]), $MachinePrecision] * N[Sqrt[x], $MachinePrecision]), $MachinePrecision], N[(t$95$2 - t$95$1), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{a}{b \cdot 3}\\
t_2 := 2 \cdot \sqrt{x}\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{-36}:\\
\;\;\;\;t\_2 - \frac{\frac{a}{b}}{3}\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{-95}:\\
\;\;\;\;\left(2 \cdot \cos y\right) \cdot \sqrt{x}\\
\mathbf{else}:\\
\;\;\;\;t\_2 - t\_1\\
\end{array}
\end{array}
if (/.f64 a (*.f64 b #s(literal 3 binary64))) < -9.9999999999999994e-37Initial program 70.2%
Taylor expanded in z around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lift-sqrt.f6476.5
Applied rewrites76.5%
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lift-/.f6476.5
Applied rewrites76.5%
Taylor expanded in y around 0
Applied rewrites65.3%
if -9.9999999999999994e-37 < (/.f64 a (*.f64 b #s(literal 3 binary64))) < 1.99999999999999998e-95Initial program 70.2%
Taylor expanded in z around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lift-sqrt.f6476.5
Applied rewrites76.5%
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lift-/.f6476.5
Applied rewrites76.5%
Taylor expanded in z around 0
associate-/l/N/A
cos-neg-revN/A
sin-+PI/2N/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift-sqrt.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f6476.4
Applied rewrites76.4%
Taylor expanded in a around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift-sqrt.f6429.2
Applied rewrites29.2%
if 1.99999999999999998e-95 < (/.f64 a (*.f64 b #s(literal 3 binary64))) Initial program 70.2%
Taylor expanded in z around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lift-sqrt.f6476.5
Applied rewrites76.5%
Taylor expanded in y around 0
Applied rewrites65.3%
(FPCore (x y z t a b) :precision binary64 (- (* 2.0 (sqrt x)) (/ a (* b 3.0))))
double code(double x, double y, double z, double t, double a, double b) {
return (2.0 * sqrt(x)) - (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)) - (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)) - (a / (b * 3.0));
}
def code(x, y, z, t, a, b): return (2.0 * math.sqrt(x)) - (a / (b * 3.0))
function code(x, y, z, t, a, b) return Float64(Float64(2.0 * sqrt(x)) - Float64(a / Float64(b * 3.0))) end
function tmp = code(x, y, z, t, a, b) tmp = (2.0 * sqrt(x)) - (a / (b * 3.0)); end
code[x_, y_, z_, t_, a_, b_] := N[(N[(2.0 * N[Sqrt[x], $MachinePrecision]), $MachinePrecision] - N[(a / N[(b * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
2 \cdot \sqrt{x} - \frac{a}{b \cdot 3}
\end{array}
Initial program 70.2%
Taylor expanded in z around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lift-sqrt.f6476.5
Applied rewrites76.5%
Taylor expanded in y around 0
Applied rewrites65.3%
(FPCore (x y z t a b) :precision binary64 (fma (/ a b) -0.3333333333333333 (* (sqrt x) 2.0)))
double code(double x, double y, double z, double t, double a, double b) {
return fma((a / b), -0.3333333333333333, (sqrt(x) * 2.0));
}
function code(x, y, z, t, a, b) return fma(Float64(a / b), -0.3333333333333333, Float64(sqrt(x) * 2.0)) end
code[x_, y_, z_, t_, a_, b_] := N[(N[(a / b), $MachinePrecision] * -0.3333333333333333 + N[(N[Sqrt[x], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{a}{b}, -0.3333333333333333, \sqrt{x} \cdot 2\right)
\end{array}
Initial program 70.2%
Taylor expanded in z around 0
associate--l+N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lift-sqrt.f64N/A
fp-cancel-sub-sign-invN/A
Applied rewrites66.0%
Taylor expanded in y around 0
*-commutativeN/A
lower-fma.f64N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sqrt.f6465.3
Applied rewrites65.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 70.2%
Taylor expanded in a around inf
lower-*.f64N/A
lower-/.f6449.7
Applied rewrites49.7%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f6449.7
Applied rewrites49.7%
(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 70.2%
Taylor expanded in a around inf
lower-*.f64N/A
lower-/.f6449.7
Applied rewrites49.7%
herbie shell --seed 2025136
(FPCore (x y z t a b)
:name "Diagrams.Solve.Polynomial:cubForm from diagrams-solve-0.1, K"
:precision binary64
(- (* (* 2.0 (sqrt x)) (cos (- y (/ (* z t) 3.0)))) (/ a (* b 3.0))))