
(FPCore (x y z a) :precision binary64 (+ x (- (tan (+ y z)) (tan a))))
double code(double x, double y, double z, double a) {
return x + (tan((y + z)) - tan(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(x, y, z, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
code = x + (tan((y + z)) - tan(a))
end function
public static double code(double x, double y, double z, double a) {
return x + (Math.tan((y + z)) - Math.tan(a));
}
def code(x, y, z, a): return x + (math.tan((y + z)) - math.tan(a))
function code(x, y, z, a) return Float64(x + Float64(tan(Float64(y + z)) - tan(a))) end
function tmp = code(x, y, z, a) tmp = x + (tan((y + z)) - tan(a)); end
code[x_, y_, z_, a_] := N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\tan \left(y + z\right) - \tan a\right)
\end{array}
Herbie found 19 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z a) :precision binary64 (+ x (- (tan (+ y z)) (tan a))))
double code(double x, double y, double z, double a) {
return x + (tan((y + z)) - tan(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(x, y, z, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
code = x + (tan((y + z)) - tan(a))
end function
public static double code(double x, double y, double z, double a) {
return x + (Math.tan((y + z)) - Math.tan(a));
}
def code(x, y, z, a): return x + (math.tan((y + z)) - math.tan(a))
function code(x, y, z, a) return Float64(x + Float64(tan(Float64(y + z)) - tan(a))) end
function tmp = code(x, y, z, a) tmp = x + (tan((y + z)) - tan(a)); end
code[x_, y_, z_, a_] := N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\tan \left(y + z\right) - \tan a\right)
\end{array}
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
(FPCore (x y z a)
:precision binary64
(+
x
(-
(/
(fma (cos y) (sin z) (* (cos z) (sin y)))
(fma (cos y) (cos z) (* (sin z) (- (sin y)))))
(tan a))))assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
return x + ((fma(cos(y), sin(z), (cos(z) * sin(y))) / fma(cos(y), cos(z), (sin(z) * -sin(y)))) - tan(a));
}
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) return Float64(x + Float64(Float64(fma(cos(y), sin(z), Float64(cos(z) * sin(y))) / fma(cos(y), cos(z), Float64(sin(z) * Float64(-sin(y))))) - tan(a))) end
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, a_] := N[(x + N[(N[(N[(N[Cos[y], $MachinePrecision] * N[Sin[z], $MachinePrecision] + N[(N[Cos[z], $MachinePrecision] * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Cos[y], $MachinePrecision] * N[Cos[z], $MachinePrecision] + N[(N[Sin[z], $MachinePrecision] * (-N[Sin[y], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
x + \left(\frac{\mathsf{fma}\left(\cos y, \sin z, \cos z \cdot \sin y\right)}{\mathsf{fma}\left(\cos y, \cos z, \sin z \cdot \left(-\sin y\right)\right)} - \tan a\right)
\end{array}
Initial program 79.6%
lift-+.f64N/A
lift-tan.f64N/A
quot-tanN/A
sin-sumN/A
div-addN/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
+-commutativeN/A
lower-+.f6480.1
Applied rewrites80.1%
lift-+.f64N/A
lift-cos.f64N/A
add-flipN/A
mul-1-negN/A
cos-diffN/A
mul-1-negN/A
cos-neg-revN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
mul-1-negN/A
lower-sin.f64N/A
lower-neg.f6480.8
Applied rewrites80.8%
lift-+.f64N/A
lift-cos.f64N/A
add-flipN/A
mul-1-negN/A
cos-diffN/A
mul-1-negN/A
cos-neg-revN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
mul-1-negN/A
lower-sin.f64N/A
lower-neg.f6499.7
Applied rewrites99.7%
Taylor expanded in y around inf
div-add-revN/A
lower-/.f64N/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
Applied rewrites99.7%
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
(FPCore (x y z a)
:precision binary64
(-
(+
x
(/
(fma (cos y) (sin z) (* (cos z) (sin y)))
(fma (cos y) (cos z) (* (sin z) (- (sin y))))))
(tan a)))assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
return (x + (fma(cos(y), sin(z), (cos(z) * sin(y))) / fma(cos(y), cos(z), (sin(z) * -sin(y))))) - tan(a);
}
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) return Float64(Float64(x + Float64(fma(cos(y), sin(z), Float64(cos(z) * sin(y))) / fma(cos(y), cos(z), Float64(sin(z) * Float64(-sin(y)))))) - tan(a)) end
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, a_] := N[(N[(x + N[(N[(N[Cos[y], $MachinePrecision] * N[Sin[z], $MachinePrecision] + N[(N[Cos[z], $MachinePrecision] * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Cos[y], $MachinePrecision] * N[Cos[z], $MachinePrecision] + N[(N[Sin[z], $MachinePrecision] * (-N[Sin[y], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
\left(x + \frac{\mathsf{fma}\left(\cos y, \sin z, \cos z \cdot \sin y\right)}{\mathsf{fma}\left(\cos y, \cos z, \sin z \cdot \left(-\sin y\right)\right)}\right) - \tan a
\end{array}
Initial program 79.6%
lift-+.f64N/A
lift-tan.f64N/A
quot-tanN/A
sin-sumN/A
div-addN/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
+-commutativeN/A
lower-+.f6480.1
Applied rewrites80.1%
lift-+.f64N/A
lift-cos.f64N/A
add-flipN/A
mul-1-negN/A
cos-diffN/A
mul-1-negN/A
cos-neg-revN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
mul-1-negN/A
lower-sin.f64N/A
lower-neg.f6480.8
Applied rewrites80.8%
lift-+.f64N/A
lift-cos.f64N/A
add-flipN/A
mul-1-negN/A
cos-diffN/A
mul-1-negN/A
cos-neg-revN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
mul-1-negN/A
lower-sin.f64N/A
lower-neg.f6499.7
Applied rewrites99.7%
Taylor expanded in x around 0
lower--.f64N/A
Applied rewrites99.6%
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (cos (+ z y))) (t_1 (* (sin z) (- (sin y)))))
(if (<= a -1.35e-9)
(+
x
(fma (sin y) (/ (cos z) t_0) (- (* (cos y) (/ (sin z) t_0)) (tan a))))
(if (<= a 5.5e-16)
(+
x
(/
(fma (cos y) (sin z) (* (cos z) (sin y)))
(fma (cos y) (cos z) t_1)))
(+ x (- (/ (sin (+ y z)) (fma (cos z) (cos y) t_1)) (tan a)))))))assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
double t_0 = cos((z + y));
double t_1 = sin(z) * -sin(y);
double tmp;
if (a <= -1.35e-9) {
tmp = x + fma(sin(y), (cos(z) / t_0), ((cos(y) * (sin(z) / t_0)) - tan(a)));
} else if (a <= 5.5e-16) {
tmp = x + (fma(cos(y), sin(z), (cos(z) * sin(y))) / fma(cos(y), cos(z), t_1));
} else {
tmp = x + ((sin((y + z)) / fma(cos(z), cos(y), t_1)) - tan(a));
}
return tmp;
}
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) t_0 = cos(Float64(z + y)) t_1 = Float64(sin(z) * Float64(-sin(y))) tmp = 0.0 if (a <= -1.35e-9) tmp = Float64(x + fma(sin(y), Float64(cos(z) / t_0), Float64(Float64(cos(y) * Float64(sin(z) / t_0)) - tan(a)))); elseif (a <= 5.5e-16) tmp = Float64(x + Float64(fma(cos(y), sin(z), Float64(cos(z) * sin(y))) / fma(cos(y), cos(z), t_1))); else tmp = Float64(x + Float64(Float64(sin(Float64(y + z)) / fma(cos(z), cos(y), t_1)) - tan(a))); end return tmp end
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
code[x_, y_, z_, a_] := Block[{t$95$0 = N[Cos[N[(z + y), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[z], $MachinePrecision] * (-N[Sin[y], $MachinePrecision])), $MachinePrecision]}, If[LessEqual[a, -1.35e-9], N[(x + N[(N[Sin[y], $MachinePrecision] * N[(N[Cos[z], $MachinePrecision] / t$95$0), $MachinePrecision] + N[(N[(N[Cos[y], $MachinePrecision] * N[(N[Sin[z], $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 5.5e-16], N[(x + N[(N[(N[Cos[y], $MachinePrecision] * N[Sin[z], $MachinePrecision] + N[(N[Cos[z], $MachinePrecision] * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Cos[y], $MachinePrecision] * N[Cos[z], $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(N[Sin[N[(y + z), $MachinePrecision]], $MachinePrecision] / N[(N[Cos[z], $MachinePrecision] * N[Cos[y], $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
\begin{array}{l}
t_0 := \cos \left(z + y\right)\\
t_1 := \sin z \cdot \left(-\sin y\right)\\
\mathbf{if}\;a \leq -1.35 \cdot 10^{-9}:\\
\;\;\;\;x + \mathsf{fma}\left(\sin y, \frac{\cos z}{t\_0}, \cos y \cdot \frac{\sin z}{t\_0} - \tan a\right)\\
\mathbf{elif}\;a \leq 5.5 \cdot 10^{-16}:\\
\;\;\;\;x + \frac{\mathsf{fma}\left(\cos y, \sin z, \cos z \cdot \sin y\right)}{\mathsf{fma}\left(\cos y, \cos z, t\_1\right)}\\
\mathbf{else}:\\
\;\;\;\;x + \left(\frac{\sin \left(y + z\right)}{\mathsf{fma}\left(\cos z, \cos y, t\_1\right)} - \tan a\right)\\
\end{array}
\end{array}
if a < -1.3500000000000001e-9Initial program 79.6%
lift-+.f64N/A
lift-tan.f64N/A
quot-tanN/A
sin-sumN/A
div-addN/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
+-commutativeN/A
lower-+.f6480.1
Applied rewrites80.1%
lift--.f64N/A
lift-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lift-+.f64N/A
lift-cos.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
lift-+.f64N/A
lift-cos.f64N/A
lift-tan.f64N/A
Applied rewrites80.1%
if -1.3500000000000001e-9 < a < 5.49999999999999964e-16Initial program 79.6%
lift-+.f64N/A
lift-tan.f64N/A
quot-tanN/A
sin-sumN/A
div-addN/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
+-commutativeN/A
lower-+.f6480.1
Applied rewrites80.1%
lift-+.f64N/A
lift-cos.f64N/A
add-flipN/A
mul-1-negN/A
cos-diffN/A
mul-1-negN/A
cos-neg-revN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
mul-1-negN/A
lower-sin.f64N/A
lower-neg.f6480.8
Applied rewrites80.8%
lift-+.f64N/A
lift-cos.f64N/A
add-flipN/A
mul-1-negN/A
cos-diffN/A
mul-1-negN/A
cos-neg-revN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
mul-1-negN/A
lower-sin.f64N/A
lower-neg.f6499.7
Applied rewrites99.7%
Taylor expanded in a around 0
lower-+.f64N/A
div-add-revN/A
lower-/.f64N/A
Applied rewrites60.5%
if 5.49999999999999964e-16 < a Initial program 79.6%
lift-+.f64N/A
lift-tan.f64N/A
quot-tanN/A
sin-sumN/A
div-addN/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
+-commutativeN/A
lower-+.f6480.1
Applied rewrites80.1%
lift-+.f64N/A
lift-cos.f64N/A
add-flipN/A
mul-1-negN/A
cos-diffN/A
mul-1-negN/A
cos-neg-revN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
mul-1-negN/A
lower-sin.f64N/A
lower-neg.f6480.8
Applied rewrites80.8%
lift-+.f64N/A
lift-cos.f64N/A
add-flipN/A
mul-1-negN/A
cos-diffN/A
mul-1-negN/A
cos-neg-revN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
mul-1-negN/A
lower-sin.f64N/A
lower-neg.f6499.7
Applied rewrites99.7%
Applied rewrites80.2%
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. (FPCore (x y z a) :precision binary64 (+ x (- (/ (fma (cos y) (sin z) (* (cos z) (sin y))) (cos (+ z y))) (tan a))))
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
return x + ((fma(cos(y), sin(z), (cos(z) * sin(y))) / cos((z + y))) - tan(a));
}
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) return Float64(x + Float64(Float64(fma(cos(y), sin(z), Float64(cos(z) * sin(y))) / cos(Float64(z + y))) - tan(a))) end
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, a_] := N[(x + N[(N[(N[(N[Cos[y], $MachinePrecision] * N[Sin[z], $MachinePrecision] + N[(N[Cos[z], $MachinePrecision] * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Cos[N[(z + y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
x + \left(\frac{\mathsf{fma}\left(\cos y, \sin z, \cos z \cdot \sin y\right)}{\cos \left(z + y\right)} - \tan a\right)
\end{array}
Initial program 79.6%
lift-+.f64N/A
lift-tan.f64N/A
quot-tanN/A
sin-sumN/A
div-addN/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
+-commutativeN/A
lower-+.f6480.1
Applied rewrites80.1%
Taylor expanded in y around -inf
div-add-revN/A
mul-1-negN/A
add-flipN/A
lower-/.f64N/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lift-+.f6480.1
Applied rewrites80.1%
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. (FPCore (x y z a) :precision binary64 (+ (- (/ (fma (cos z) (sin y) (sin z)) (cos (+ z y))) (tan a)) x))
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
return ((fma(cos(z), sin(y), sin(z)) / cos((z + y))) - tan(a)) + x;
}
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) return Float64(Float64(Float64(fma(cos(z), sin(y), sin(z)) / cos(Float64(z + y))) - tan(a)) + x) end
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, a_] := N[(N[(N[(N[(N[Cos[z], $MachinePrecision] * N[Sin[y], $MachinePrecision] + N[Sin[z], $MachinePrecision]), $MachinePrecision] / N[Cos[N[(z + y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
\left(\frac{\mathsf{fma}\left(\cos z, \sin y, \sin z\right)}{\cos \left(z + y\right)} - \tan a\right) + x
\end{array}
Initial program 79.6%
lift-+.f64N/A
lift-tan.f64N/A
quot-tanN/A
sin-sumN/A
div-addN/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
+-commutativeN/A
lower-+.f6480.1
Applied rewrites80.1%
Taylor expanded in y around 0
lift-sin.f6479.6
Applied rewrites79.6%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6479.6
Applied rewrites79.6%
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. (FPCore (x y z a) :precision binary64 (if (<= y -1.5e-14) (+ x (- (tan y) (tan a))) (+ x (- (tan z) (tan a)))))
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
double tmp;
if (y <= -1.5e-14) {
tmp = x + (tan(y) - tan(a));
} else {
tmp = x + (tan(z) - tan(a));
}
return tmp;
}
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
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, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
real(8) :: tmp
if (y <= (-1.5d-14)) then
tmp = x + (tan(y) - tan(a))
else
tmp = x + (tan(z) - tan(a))
end if
code = tmp
end function
assert x < y && y < z && z < a;
public static double code(double x, double y, double z, double a) {
double tmp;
if (y <= -1.5e-14) {
tmp = x + (Math.tan(y) - Math.tan(a));
} else {
tmp = x + (Math.tan(z) - Math.tan(a));
}
return tmp;
}
[x, y, z, a] = sort([x, y, z, a]) def code(x, y, z, a): tmp = 0 if y <= -1.5e-14: tmp = x + (math.tan(y) - math.tan(a)) else: tmp = x + (math.tan(z) - math.tan(a)) return tmp
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) tmp = 0.0 if (y <= -1.5e-14) tmp = Float64(x + Float64(tan(y) - tan(a))); else tmp = Float64(x + Float64(tan(z) - tan(a))); end return tmp end
x, y, z, a = num2cell(sort([x, y, z, a])){:}
function tmp_2 = code(x, y, z, a)
tmp = 0.0;
if (y <= -1.5e-14)
tmp = x + (tan(y) - tan(a));
else
tmp = x + (tan(z) - tan(a));
end
tmp_2 = tmp;
end
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, a_] := If[LessEqual[y, -1.5e-14], N[(x + N[(N[Tan[y], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[Tan[z], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.5 \cdot 10^{-14}:\\
\;\;\;\;x + \left(\tan y - \tan a\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(\tan z - \tan a\right)\\
\end{array}
\end{array}
if y < -1.4999999999999999e-14Initial program 79.6%
Taylor expanded in z around 0
quot-tanN/A
lower-tan.f6460.1
Applied rewrites60.1%
if -1.4999999999999999e-14 < y Initial program 79.6%
Taylor expanded in y around 0
Applied rewrites60.4%
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. (FPCore (x y z a) :precision binary64 (if (<= y -1.5e-14) (+ x (- (tan y) (tan a))) (- (+ (tan z) x) (tan a))))
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
double tmp;
if (y <= -1.5e-14) {
tmp = x + (tan(y) - tan(a));
} else {
tmp = (tan(z) + x) - tan(a);
}
return tmp;
}
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
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, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
real(8) :: tmp
if (y <= (-1.5d-14)) then
tmp = x + (tan(y) - tan(a))
else
tmp = (tan(z) + x) - tan(a)
end if
code = tmp
end function
assert x < y && y < z && z < a;
public static double code(double x, double y, double z, double a) {
double tmp;
if (y <= -1.5e-14) {
tmp = x + (Math.tan(y) - Math.tan(a));
} else {
tmp = (Math.tan(z) + x) - Math.tan(a);
}
return tmp;
}
[x, y, z, a] = sort([x, y, z, a]) def code(x, y, z, a): tmp = 0 if y <= -1.5e-14: tmp = x + (math.tan(y) - math.tan(a)) else: tmp = (math.tan(z) + x) - math.tan(a) return tmp
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) tmp = 0.0 if (y <= -1.5e-14) tmp = Float64(x + Float64(tan(y) - tan(a))); else tmp = Float64(Float64(tan(z) + x) - tan(a)); end return tmp end
x, y, z, a = num2cell(sort([x, y, z, a])){:}
function tmp_2 = code(x, y, z, a)
tmp = 0.0;
if (y <= -1.5e-14)
tmp = x + (tan(y) - tan(a));
else
tmp = (tan(z) + x) - tan(a);
end
tmp_2 = tmp;
end
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, a_] := If[LessEqual[y, -1.5e-14], N[(x + N[(N[Tan[y], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Tan[z], $MachinePrecision] + x), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.5 \cdot 10^{-14}:\\
\;\;\;\;x + \left(\tan y - \tan a\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\tan z + x\right) - \tan a\\
\end{array}
\end{array}
if y < -1.4999999999999999e-14Initial program 79.6%
Taylor expanded in z around 0
quot-tanN/A
lower-tan.f6460.1
Applied rewrites60.1%
if -1.4999999999999999e-14 < y Initial program 79.6%
Taylor expanded in y around 0
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
quot-tanN/A
lower-tan.f64N/A
quot-tanN/A
lift-tan.f6460.3
Applied rewrites60.3%
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. (FPCore (x y z a) :precision binary64 (if (<= y -1.5e-14) (- (+ (tan y) x) (tan a)) (- (+ (tan z) x) (tan a))))
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
double tmp;
if (y <= -1.5e-14) {
tmp = (tan(y) + x) - tan(a);
} else {
tmp = (tan(z) + x) - tan(a);
}
return tmp;
}
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
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, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
real(8) :: tmp
if (y <= (-1.5d-14)) then
tmp = (tan(y) + x) - tan(a)
else
tmp = (tan(z) + x) - tan(a)
end if
code = tmp
end function
assert x < y && y < z && z < a;
public static double code(double x, double y, double z, double a) {
double tmp;
if (y <= -1.5e-14) {
tmp = (Math.tan(y) + x) - Math.tan(a);
} else {
tmp = (Math.tan(z) + x) - Math.tan(a);
}
return tmp;
}
[x, y, z, a] = sort([x, y, z, a]) def code(x, y, z, a): tmp = 0 if y <= -1.5e-14: tmp = (math.tan(y) + x) - math.tan(a) else: tmp = (math.tan(z) + x) - math.tan(a) return tmp
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) tmp = 0.0 if (y <= -1.5e-14) tmp = Float64(Float64(tan(y) + x) - tan(a)); else tmp = Float64(Float64(tan(z) + x) - tan(a)); end return tmp end
x, y, z, a = num2cell(sort([x, y, z, a])){:}
function tmp_2 = code(x, y, z, a)
tmp = 0.0;
if (y <= -1.5e-14)
tmp = (tan(y) + x) - tan(a);
else
tmp = (tan(z) + x) - tan(a);
end
tmp_2 = tmp;
end
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, a_] := If[LessEqual[y, -1.5e-14], N[(N[(N[Tan[y], $MachinePrecision] + x), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision], N[(N[(N[Tan[z], $MachinePrecision] + x), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.5 \cdot 10^{-14}:\\
\;\;\;\;\left(\tan y + x\right) - \tan a\\
\mathbf{else}:\\
\;\;\;\;\left(\tan z + x\right) - \tan a\\
\end{array}
\end{array}
if y < -1.4999999999999999e-14Initial program 79.6%
Taylor expanded in z around 0
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
quot-tanN/A
lower-tan.f64N/A
quot-tanN/A
lift-tan.f6460.1
Applied rewrites60.1%
if -1.4999999999999999e-14 < y Initial program 79.6%
Taylor expanded in y around 0
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
quot-tanN/A
lower-tan.f64N/A
quot-tanN/A
lift-tan.f6460.3
Applied rewrites60.3%
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. (FPCore (x y z a) :precision binary64 (+ x (- (tan (+ y z)) (tan a))))
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
return x + (tan((y + z)) - tan(a));
}
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
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, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
code = x + (tan((y + z)) - tan(a))
end function
assert x < y && y < z && z < a;
public static double code(double x, double y, double z, double a) {
return x + (Math.tan((y + z)) - Math.tan(a));
}
[x, y, z, a] = sort([x, y, z, a]) def code(x, y, z, a): return x + (math.tan((y + z)) - math.tan(a))
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) return Float64(x + Float64(tan(Float64(y + z)) - tan(a))) end
x, y, z, a = num2cell(sort([x, y, z, a])){:}
function tmp = code(x, y, z, a)
tmp = x + (tan((y + z)) - tan(a));
end
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, a_] := N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
x + \left(\tan \left(y + z\right) - \tan a\right)
\end{array}
Initial program 79.6%
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. (FPCore (x y z a) :precision binary64 (if (<= z 6.6e-7) (- (+ (tan y) x) (tan a)) (+ (tan (+ z y)) x)))
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
double tmp;
if (z <= 6.6e-7) {
tmp = (tan(y) + x) - tan(a);
} else {
tmp = tan((z + y)) + x;
}
return tmp;
}
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
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, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
real(8) :: tmp
if (z <= 6.6d-7) then
tmp = (tan(y) + x) - tan(a)
else
tmp = tan((z + y)) + x
end if
code = tmp
end function
assert x < y && y < z && z < a;
public static double code(double x, double y, double z, double a) {
double tmp;
if (z <= 6.6e-7) {
tmp = (Math.tan(y) + x) - Math.tan(a);
} else {
tmp = Math.tan((z + y)) + x;
}
return tmp;
}
[x, y, z, a] = sort([x, y, z, a]) def code(x, y, z, a): tmp = 0 if z <= 6.6e-7: tmp = (math.tan(y) + x) - math.tan(a) else: tmp = math.tan((z + y)) + x return tmp
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) tmp = 0.0 if (z <= 6.6e-7) tmp = Float64(Float64(tan(y) + x) - tan(a)); else tmp = Float64(tan(Float64(z + y)) + x); end return tmp end
x, y, z, a = num2cell(sort([x, y, z, a])){:}
function tmp_2 = code(x, y, z, a)
tmp = 0.0;
if (z <= 6.6e-7)
tmp = (tan(y) + x) - tan(a);
else
tmp = tan((z + y)) + x;
end
tmp_2 = tmp;
end
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, a_] := If[LessEqual[z, 6.6e-7], N[(N[(N[Tan[y], $MachinePrecision] + x), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision], N[(N[Tan[N[(z + y), $MachinePrecision]], $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq 6.6 \cdot 10^{-7}:\\
\;\;\;\;\left(\tan y + x\right) - \tan a\\
\mathbf{else}:\\
\;\;\;\;\tan \left(z + y\right) + x\\
\end{array}
\end{array}
if z < 6.6000000000000003e-7Initial program 79.6%
Taylor expanded in z around 0
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
quot-tanN/A
lower-tan.f64N/A
quot-tanN/A
lift-tan.f6460.1
Applied rewrites60.1%
if 6.6000000000000003e-7 < z Initial program 79.6%
Taylor expanded in a around 0
quot-tanN/A
+-commutativeN/A
lower-+.f64N/A
lift-tan.f64N/A
+-commutativeN/A
lower-+.f6450.3
Applied rewrites50.3%
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. (FPCore (x y z a) :precision binary64 (if (<= z 6.6e-7) (+ (tan y) (- x (tan a))) (+ (tan (+ z y)) x)))
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
double tmp;
if (z <= 6.6e-7) {
tmp = tan(y) + (x - tan(a));
} else {
tmp = tan((z + y)) + x;
}
return tmp;
}
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
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, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
real(8) :: tmp
if (z <= 6.6d-7) then
tmp = tan(y) + (x - tan(a))
else
tmp = tan((z + y)) + x
end if
code = tmp
end function
assert x < y && y < z && z < a;
public static double code(double x, double y, double z, double a) {
double tmp;
if (z <= 6.6e-7) {
tmp = Math.tan(y) + (x - Math.tan(a));
} else {
tmp = Math.tan((z + y)) + x;
}
return tmp;
}
[x, y, z, a] = sort([x, y, z, a]) def code(x, y, z, a): tmp = 0 if z <= 6.6e-7: tmp = math.tan(y) + (x - math.tan(a)) else: tmp = math.tan((z + y)) + x return tmp
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) tmp = 0.0 if (z <= 6.6e-7) tmp = Float64(tan(y) + Float64(x - tan(a))); else tmp = Float64(tan(Float64(z + y)) + x); end return tmp end
x, y, z, a = num2cell(sort([x, y, z, a])){:}
function tmp_2 = code(x, y, z, a)
tmp = 0.0;
if (z <= 6.6e-7)
tmp = tan(y) + (x - tan(a));
else
tmp = tan((z + y)) + x;
end
tmp_2 = tmp;
end
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, a_] := If[LessEqual[z, 6.6e-7], N[(N[Tan[y], $MachinePrecision] + N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Tan[N[(z + y), $MachinePrecision]], $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq 6.6 \cdot 10^{-7}:\\
\;\;\;\;\tan y + \left(x - \tan a\right)\\
\mathbf{else}:\\
\;\;\;\;\tan \left(z + y\right) + x\\
\end{array}
\end{array}
if z < 6.6000000000000003e-7Initial program 79.6%
Taylor expanded in z around 0
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
quot-tanN/A
lower-tan.f64N/A
quot-tanN/A
lift-tan.f6460.1
Applied rewrites60.1%
lift--.f64N/A
lift-+.f64N/A
lift-tan.f64N/A
quot-tanN/A
lift-tan.f64N/A
quot-tanN/A
associate--l+N/A
lower-+.f64N/A
quot-tanN/A
lift-tan.f64N/A
lower--.f64N/A
quot-tanN/A
lift-tan.f6460.1
Applied rewrites60.1%
if 6.6000000000000003e-7 < z Initial program 79.6%
Taylor expanded in a around 0
quot-tanN/A
+-commutativeN/A
lower-+.f64N/A
lift-tan.f64N/A
+-commutativeN/A
lower-+.f6450.3
Applied rewrites50.3%
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (- x (tan (+ a PI)))))
(if (<= a -1.3e-18)
t_0
(if (<= a 0.108)
(+ x (fma (fma (* a a) -0.3333333333333333 -1.0) a (tan (+ z y))))
t_0))))assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
double t_0 = x - tan((a + ((double) M_PI)));
double tmp;
if (a <= -1.3e-18) {
tmp = t_0;
} else if (a <= 0.108) {
tmp = x + fma(fma((a * a), -0.3333333333333333, -1.0), a, tan((z + y)));
} else {
tmp = t_0;
}
return tmp;
}
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) t_0 = Float64(x - tan(Float64(a + pi))) tmp = 0.0 if (a <= -1.3e-18) tmp = t_0; elseif (a <= 0.108) tmp = Float64(x + fma(fma(Float64(a * a), -0.3333333333333333, -1.0), a, tan(Float64(z + y)))); else tmp = t_0; end return tmp end
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
code[x_, y_, z_, a_] := Block[{t$95$0 = N[(x - N[Tan[N[(a + Pi), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, -1.3e-18], t$95$0, If[LessEqual[a, 0.108], N[(x + N[(N[(N[(a * a), $MachinePrecision] * -0.3333333333333333 + -1.0), $MachinePrecision] * a + N[Tan[N[(z + y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
\begin{array}{l}
t_0 := x - \tan \left(a + \pi\right)\\
\mathbf{if}\;a \leq -1.3 \cdot 10^{-18}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;a \leq 0.108:\\
\;\;\;\;x + \mathsf{fma}\left(\mathsf{fma}\left(a \cdot a, -0.3333333333333333, -1\right), a, \tan \left(z + y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if a < -1.3e-18 or 0.107999999999999999 < a Initial program 79.6%
Taylor expanded in z around 0
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
quot-tanN/A
lower-tan.f64N/A
quot-tanN/A
lift-tan.f6460.1
Applied rewrites60.1%
Taylor expanded in y around 0
lower--.f64N/A
quot-tanN/A
lift-tan.f6441.6
Applied rewrites41.6%
lift-tan.f64N/A
tan-+PI-revN/A
lower-tan.f64N/A
lower-+.f64N/A
lift-PI.f6441.3
Applied rewrites41.3%
if -1.3e-18 < a < 0.107999999999999999Initial program 79.6%
Taylor expanded in a around 0
*-commutativeN/A
quot-tanN/A
lower-fma.f64N/A
sub-flipN/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
lift-tan.f64N/A
+-commutativeN/A
lower-+.f6440.5
Applied rewrites40.5%
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. (FPCore (x y z a) :precision binary64 (let* ((t_0 (- x (tan (+ a PI))))) (if (<= a -1.3e-18) t_0 (if (<= a 0.037) (+ x (- (tan (+ y z)) a)) t_0))))
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
double t_0 = x - tan((a + ((double) M_PI)));
double tmp;
if (a <= -1.3e-18) {
tmp = t_0;
} else if (a <= 0.037) {
tmp = x + (tan((y + z)) - a);
} else {
tmp = t_0;
}
return tmp;
}
assert x < y && y < z && z < a;
public static double code(double x, double y, double z, double a) {
double t_0 = x - Math.tan((a + Math.PI));
double tmp;
if (a <= -1.3e-18) {
tmp = t_0;
} else if (a <= 0.037) {
tmp = x + (Math.tan((y + z)) - a);
} else {
tmp = t_0;
}
return tmp;
}
[x, y, z, a] = sort([x, y, z, a]) def code(x, y, z, a): t_0 = x - math.tan((a + math.pi)) tmp = 0 if a <= -1.3e-18: tmp = t_0 elif a <= 0.037: tmp = x + (math.tan((y + z)) - a) else: tmp = t_0 return tmp
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) t_0 = Float64(x - tan(Float64(a + pi))) tmp = 0.0 if (a <= -1.3e-18) tmp = t_0; elseif (a <= 0.037) tmp = Float64(x + Float64(tan(Float64(y + z)) - a)); else tmp = t_0; end return tmp end
x, y, z, a = num2cell(sort([x, y, z, a])){:}
function tmp_2 = code(x, y, z, a)
t_0 = x - tan((a + pi));
tmp = 0.0;
if (a <= -1.3e-18)
tmp = t_0;
elseif (a <= 0.037)
tmp = x + (tan((y + z)) - a);
else
tmp = t_0;
end
tmp_2 = tmp;
end
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
code[x_, y_, z_, a_] := Block[{t$95$0 = N[(x - N[Tan[N[(a + Pi), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, -1.3e-18], t$95$0, If[LessEqual[a, 0.037], N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
\begin{array}{l}
t_0 := x - \tan \left(a + \pi\right)\\
\mathbf{if}\;a \leq -1.3 \cdot 10^{-18}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;a \leq 0.037:\\
\;\;\;\;x + \left(\tan \left(y + z\right) - a\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if a < -1.3e-18 or 0.0369999999999999982 < a Initial program 79.6%
Taylor expanded in z around 0
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
quot-tanN/A
lower-tan.f64N/A
quot-tanN/A
lift-tan.f6460.1
Applied rewrites60.1%
Taylor expanded in y around 0
lower--.f64N/A
quot-tanN/A
lift-tan.f6441.6
Applied rewrites41.6%
lift-tan.f64N/A
tan-+PI-revN/A
lower-tan.f64N/A
lower-+.f64N/A
lift-PI.f6441.3
Applied rewrites41.3%
if -1.3e-18 < a < 0.0369999999999999982Initial program 79.6%
Taylor expanded in a around 0
Applied rewrites40.9%
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (- x (tan (+ a PI)))))
(if (<= (tan a) -0.01)
t_0
(if (<= (tan a) 0.0005) (+ (tan (+ z y)) x) t_0))))assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
double t_0 = x - tan((a + ((double) M_PI)));
double tmp;
if (tan(a) <= -0.01) {
tmp = t_0;
} else if (tan(a) <= 0.0005) {
tmp = tan((z + y)) + x;
} else {
tmp = t_0;
}
return tmp;
}
assert x < y && y < z && z < a;
public static double code(double x, double y, double z, double a) {
double t_0 = x - Math.tan((a + Math.PI));
double tmp;
if (Math.tan(a) <= -0.01) {
tmp = t_0;
} else if (Math.tan(a) <= 0.0005) {
tmp = Math.tan((z + y)) + x;
} else {
tmp = t_0;
}
return tmp;
}
[x, y, z, a] = sort([x, y, z, a]) def code(x, y, z, a): t_0 = x - math.tan((a + math.pi)) tmp = 0 if math.tan(a) <= -0.01: tmp = t_0 elif math.tan(a) <= 0.0005: tmp = math.tan((z + y)) + x else: tmp = t_0 return tmp
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) t_0 = Float64(x - tan(Float64(a + pi))) tmp = 0.0 if (tan(a) <= -0.01) tmp = t_0; elseif (tan(a) <= 0.0005) tmp = Float64(tan(Float64(z + y)) + x); else tmp = t_0; end return tmp end
x, y, z, a = num2cell(sort([x, y, z, a])){:}
function tmp_2 = code(x, y, z, a)
t_0 = x - tan((a + pi));
tmp = 0.0;
if (tan(a) <= -0.01)
tmp = t_0;
elseif (tan(a) <= 0.0005)
tmp = tan((z + y)) + x;
else
tmp = t_0;
end
tmp_2 = tmp;
end
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
code[x_, y_, z_, a_] := Block[{t$95$0 = N[(x - N[Tan[N[(a + Pi), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Tan[a], $MachinePrecision], -0.01], t$95$0, If[LessEqual[N[Tan[a], $MachinePrecision], 0.0005], N[(N[Tan[N[(z + y), $MachinePrecision]], $MachinePrecision] + x), $MachinePrecision], t$95$0]]]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
\begin{array}{l}
t_0 := x - \tan \left(a + \pi\right)\\
\mathbf{if}\;\tan a \leq -0.01:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\tan a \leq 0.0005:\\
\;\;\;\;\tan \left(z + y\right) + x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (tan.f64 a) < -0.0100000000000000002 or 5.0000000000000001e-4 < (tan.f64 a) Initial program 79.6%
Taylor expanded in z around 0
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
quot-tanN/A
lower-tan.f64N/A
quot-tanN/A
lift-tan.f6460.1
Applied rewrites60.1%
Taylor expanded in y around 0
lower--.f64N/A
quot-tanN/A
lift-tan.f6441.6
Applied rewrites41.6%
lift-tan.f64N/A
tan-+PI-revN/A
lower-tan.f64N/A
lower-+.f64N/A
lift-PI.f6441.3
Applied rewrites41.3%
if -0.0100000000000000002 < (tan.f64 a) < 5.0000000000000001e-4Initial program 79.6%
Taylor expanded in a around 0
quot-tanN/A
+-commutativeN/A
lower-+.f64N/A
lift-tan.f64N/A
+-commutativeN/A
lower-+.f6450.3
Applied rewrites50.3%
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. (FPCore (x y z a) :precision binary64 (if (<= (+ y z) -5e-5) (+ x (tan y)) (if (<= (+ y z) 4e-7) (- (+ y x) (tan a)) (+ (tan z) x))))
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
double tmp;
if ((y + z) <= -5e-5) {
tmp = x + tan(y);
} else if ((y + z) <= 4e-7) {
tmp = (y + x) - tan(a);
} else {
tmp = tan(z) + x;
}
return tmp;
}
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
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, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
real(8) :: tmp
if ((y + z) <= (-5d-5)) then
tmp = x + tan(y)
else if ((y + z) <= 4d-7) then
tmp = (y + x) - tan(a)
else
tmp = tan(z) + x
end if
code = tmp
end function
assert x < y && y < z && z < a;
public static double code(double x, double y, double z, double a) {
double tmp;
if ((y + z) <= -5e-5) {
tmp = x + Math.tan(y);
} else if ((y + z) <= 4e-7) {
tmp = (y + x) - Math.tan(a);
} else {
tmp = Math.tan(z) + x;
}
return tmp;
}
[x, y, z, a] = sort([x, y, z, a]) def code(x, y, z, a): tmp = 0 if (y + z) <= -5e-5: tmp = x + math.tan(y) elif (y + z) <= 4e-7: tmp = (y + x) - math.tan(a) else: tmp = math.tan(z) + x return tmp
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) tmp = 0.0 if (Float64(y + z) <= -5e-5) tmp = Float64(x + tan(y)); elseif (Float64(y + z) <= 4e-7) tmp = Float64(Float64(y + x) - tan(a)); else tmp = Float64(tan(z) + x); end return tmp end
x, y, z, a = num2cell(sort([x, y, z, a])){:}
function tmp_2 = code(x, y, z, a)
tmp = 0.0;
if ((y + z) <= -5e-5)
tmp = x + tan(y);
elseif ((y + z) <= 4e-7)
tmp = (y + x) - tan(a);
else
tmp = tan(z) + x;
end
tmp_2 = tmp;
end
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, a_] := If[LessEqual[N[(y + z), $MachinePrecision], -5e-5], N[(x + N[Tan[y], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(y + z), $MachinePrecision], 4e-7], N[(N[(y + x), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision], N[(N[Tan[z], $MachinePrecision] + x), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
\begin{array}{l}
\mathbf{if}\;y + z \leq -5 \cdot 10^{-5}:\\
\;\;\;\;x + \tan y\\
\mathbf{elif}\;y + z \leq 4 \cdot 10^{-7}:\\
\;\;\;\;\left(y + x\right) - \tan a\\
\mathbf{else}:\\
\;\;\;\;\tan z + x\\
\end{array}
\end{array}
if (+.f64 y z) < -5.00000000000000024e-5Initial program 79.6%
Taylor expanded in a around 0
quot-tanN/A
+-commutativeN/A
lower-+.f64N/A
lift-tan.f64N/A
+-commutativeN/A
lower-+.f6450.3
Applied rewrites50.3%
Taylor expanded in z around 0
lower-+.f64N/A
quot-tanN/A
lift-tan.f6440.7
Applied rewrites40.7%
if -5.00000000000000024e-5 < (+.f64 y z) < 3.9999999999999998e-7Initial program 79.6%
Taylor expanded in z around 0
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
quot-tanN/A
lower-tan.f64N/A
quot-tanN/A
lift-tan.f6460.1
Applied rewrites60.1%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6431.0
Applied rewrites31.0%
if 3.9999999999999998e-7 < (+.f64 y z) Initial program 79.6%
Taylor expanded in a around 0
quot-tanN/A
+-commutativeN/A
lower-+.f64N/A
lift-tan.f64N/A
+-commutativeN/A
lower-+.f6450.3
Applied rewrites50.3%
Taylor expanded in y around 0
Applied rewrites40.5%
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. (FPCore (x y z a) :precision binary64 (if (<= (+ y z) -5e-5) (+ x (tan y)) (if (<= (+ y z) 4e-7) (- x (tan a)) (+ (tan z) x))))
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
double tmp;
if ((y + z) <= -5e-5) {
tmp = x + tan(y);
} else if ((y + z) <= 4e-7) {
tmp = x - tan(a);
} else {
tmp = tan(z) + x;
}
return tmp;
}
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
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, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
real(8) :: tmp
if ((y + z) <= (-5d-5)) then
tmp = x + tan(y)
else if ((y + z) <= 4d-7) then
tmp = x - tan(a)
else
tmp = tan(z) + x
end if
code = tmp
end function
assert x < y && y < z && z < a;
public static double code(double x, double y, double z, double a) {
double tmp;
if ((y + z) <= -5e-5) {
tmp = x + Math.tan(y);
} else if ((y + z) <= 4e-7) {
tmp = x - Math.tan(a);
} else {
tmp = Math.tan(z) + x;
}
return tmp;
}
[x, y, z, a] = sort([x, y, z, a]) def code(x, y, z, a): tmp = 0 if (y + z) <= -5e-5: tmp = x + math.tan(y) elif (y + z) <= 4e-7: tmp = x - math.tan(a) else: tmp = math.tan(z) + x return tmp
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) tmp = 0.0 if (Float64(y + z) <= -5e-5) tmp = Float64(x + tan(y)); elseif (Float64(y + z) <= 4e-7) tmp = Float64(x - tan(a)); else tmp = Float64(tan(z) + x); end return tmp end
x, y, z, a = num2cell(sort([x, y, z, a])){:}
function tmp_2 = code(x, y, z, a)
tmp = 0.0;
if ((y + z) <= -5e-5)
tmp = x + tan(y);
elseif ((y + z) <= 4e-7)
tmp = x - tan(a);
else
tmp = tan(z) + x;
end
tmp_2 = tmp;
end
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, a_] := If[LessEqual[N[(y + z), $MachinePrecision], -5e-5], N[(x + N[Tan[y], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(y + z), $MachinePrecision], 4e-7], N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision], N[(N[Tan[z], $MachinePrecision] + x), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
\begin{array}{l}
\mathbf{if}\;y + z \leq -5 \cdot 10^{-5}:\\
\;\;\;\;x + \tan y\\
\mathbf{elif}\;y + z \leq 4 \cdot 10^{-7}:\\
\;\;\;\;x - \tan a\\
\mathbf{else}:\\
\;\;\;\;\tan z + x\\
\end{array}
\end{array}
if (+.f64 y z) < -5.00000000000000024e-5Initial program 79.6%
Taylor expanded in a around 0
quot-tanN/A
+-commutativeN/A
lower-+.f64N/A
lift-tan.f64N/A
+-commutativeN/A
lower-+.f6450.3
Applied rewrites50.3%
Taylor expanded in z around 0
lower-+.f64N/A
quot-tanN/A
lift-tan.f6440.7
Applied rewrites40.7%
if -5.00000000000000024e-5 < (+.f64 y z) < 3.9999999999999998e-7Initial program 79.6%
Taylor expanded in z around 0
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
quot-tanN/A
lower-tan.f64N/A
quot-tanN/A
lift-tan.f6460.1
Applied rewrites60.1%
Taylor expanded in y around 0
lower--.f64N/A
quot-tanN/A
lift-tan.f6441.6
Applied rewrites41.6%
if 3.9999999999999998e-7 < (+.f64 y z) Initial program 79.6%
Taylor expanded in a around 0
quot-tanN/A
+-commutativeN/A
lower-+.f64N/A
lift-tan.f64N/A
+-commutativeN/A
lower-+.f6450.3
Applied rewrites50.3%
Taylor expanded in y around 0
Applied rewrites40.5%
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. (FPCore (x y z a) :precision binary64 (if (<= (+ y z) 4e-7) (- x (tan a)) (+ (tan z) x)))
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
double tmp;
if ((y + z) <= 4e-7) {
tmp = x - tan(a);
} else {
tmp = tan(z) + x;
}
return tmp;
}
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
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, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
real(8) :: tmp
if ((y + z) <= 4d-7) then
tmp = x - tan(a)
else
tmp = tan(z) + x
end if
code = tmp
end function
assert x < y && y < z && z < a;
public static double code(double x, double y, double z, double a) {
double tmp;
if ((y + z) <= 4e-7) {
tmp = x - Math.tan(a);
} else {
tmp = Math.tan(z) + x;
}
return tmp;
}
[x, y, z, a] = sort([x, y, z, a]) def code(x, y, z, a): tmp = 0 if (y + z) <= 4e-7: tmp = x - math.tan(a) else: tmp = math.tan(z) + x return tmp
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) tmp = 0.0 if (Float64(y + z) <= 4e-7) tmp = Float64(x - tan(a)); else tmp = Float64(tan(z) + x); end return tmp end
x, y, z, a = num2cell(sort([x, y, z, a])){:}
function tmp_2 = code(x, y, z, a)
tmp = 0.0;
if ((y + z) <= 4e-7)
tmp = x - tan(a);
else
tmp = tan(z) + x;
end
tmp_2 = tmp;
end
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, a_] := If[LessEqual[N[(y + z), $MachinePrecision], 4e-7], N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision], N[(N[Tan[z], $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
\begin{array}{l}
\mathbf{if}\;y + z \leq 4 \cdot 10^{-7}:\\
\;\;\;\;x - \tan a\\
\mathbf{else}:\\
\;\;\;\;\tan z + x\\
\end{array}
\end{array}
if (+.f64 y z) < 3.9999999999999998e-7Initial program 79.6%
Taylor expanded in z around 0
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
quot-tanN/A
lower-tan.f64N/A
quot-tanN/A
lift-tan.f6460.1
Applied rewrites60.1%
Taylor expanded in y around 0
lower--.f64N/A
quot-tanN/A
lift-tan.f6441.6
Applied rewrites41.6%
if 3.9999999999999998e-7 < (+.f64 y z) Initial program 79.6%
Taylor expanded in a around 0
quot-tanN/A
+-commutativeN/A
lower-+.f64N/A
lift-tan.f64N/A
+-commutativeN/A
lower-+.f6450.3
Applied rewrites50.3%
Taylor expanded in y around 0
Applied rewrites40.5%
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. (FPCore (x y z a) :precision binary64 (- x (tan a)))
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
return x - tan(a);
}
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
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, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
code = x - tan(a)
end function
assert x < y && y < z && z < a;
public static double code(double x, double y, double z, double a) {
return x - Math.tan(a);
}
[x, y, z, a] = sort([x, y, z, a]) def code(x, y, z, a): return x - math.tan(a)
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) return Float64(x - tan(a)) end
x, y, z, a = num2cell(sort([x, y, z, a])){:}
function tmp = code(x, y, z, a)
tmp = x - tan(a);
end
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, a_] := N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
x - \tan a
\end{array}
Initial program 79.6%
Taylor expanded in z around 0
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
quot-tanN/A
lower-tan.f64N/A
quot-tanN/A
lift-tan.f6460.1
Applied rewrites60.1%
Taylor expanded in y around 0
lower--.f64N/A
quot-tanN/A
lift-tan.f6441.6
Applied rewrites41.6%
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. (FPCore (x y z a) :precision binary64 (- (- x)))
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
return -(-x);
}
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
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, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
code = -(-x)
end function
assert x < y && y < z && z < a;
public static double code(double x, double y, double z, double a) {
return -(-x);
}
[x, y, z, a] = sort([x, y, z, a]) def code(x, y, z, a): return -(-x)
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) return Float64(-Float64(-x)) end
x, y, z, a = num2cell(sort([x, y, z, a])){:}
function tmp = code(x, y, z, a)
tmp = -(-x);
end
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, a_] := (-(-x))
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
-\left(-x\right)
\end{array}
Initial program 79.6%
Taylor expanded in x around -inf
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
Applied rewrites79.4%
Taylor expanded in x around inf
mul-1-negN/A
lower-neg.f6431.4
Applied rewrites31.4%
herbie shell --seed 2025134
(FPCore (x y z a)
:name "tan-example (used to crash)"
:precision binary64
:pre (and (and (and (or (== x 0.0) (and (<= 0.5884142 x) (<= x 505.5909))) (or (and (<= -1.796658e+308 y) (<= y -9.425585e-310)) (and (<= 1.284938e-309 y) (<= y 1.751224e+308)))) (or (and (<= -1.776707e+308 z) (<= z -8.599796e-310)) (and (<= 3.293145e-311 z) (<= z 1.725154e+308)))) (or (and (<= -1.796658e+308 a) (<= a -9.425585e-310)) (and (<= 1.284938e-309 a) (<= a 1.751224e+308))))
(+ x (- (tan (+ y z)) (tan a))))