
(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 20 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
(let* ((t_0 (* (tan y) (tan z))))
(+
x
(-
(+
(/
(tan y)
(/
(- 1.0 (* (pow (tan y) 3.0) (pow (tan z) 3.0)))
(+ 1.0 (+ (pow t_0 2.0) (* 1.0 t_0)))))
(/ (tan z) (- 1.0 t_0)))
(tan a)))))assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
double t_0 = tan(y) * tan(z);
return x + (((tan(y) / ((1.0 - (pow(tan(y), 3.0) * pow(tan(z), 3.0))) / (1.0 + (pow(t_0, 2.0) + (1.0 * t_0))))) + (tan(z) / (1.0 - t_0))) - 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
real(8) :: t_0
t_0 = tan(y) * tan(z)
code = x + (((tan(y) / ((1.0d0 - ((tan(y) ** 3.0d0) * (tan(z) ** 3.0d0))) / (1.0d0 + ((t_0 ** 2.0d0) + (1.0d0 * t_0))))) + (tan(z) / (1.0d0 - t_0))) - tan(a))
end function
assert x < y && y < z && z < a;
public static double code(double x, double y, double z, double a) {
double t_0 = Math.tan(y) * Math.tan(z);
return x + (((Math.tan(y) / ((1.0 - (Math.pow(Math.tan(y), 3.0) * Math.pow(Math.tan(z), 3.0))) / (1.0 + (Math.pow(t_0, 2.0) + (1.0 * t_0))))) + (Math.tan(z) / (1.0 - t_0))) - Math.tan(a));
}
[x, y, z, a] = sort([x, y, z, a]) def code(x, y, z, a): t_0 = math.tan(y) * math.tan(z) return x + (((math.tan(y) / ((1.0 - (math.pow(math.tan(y), 3.0) * math.pow(math.tan(z), 3.0))) / (1.0 + (math.pow(t_0, 2.0) + (1.0 * t_0))))) + (math.tan(z) / (1.0 - t_0))) - math.tan(a))
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) t_0 = Float64(tan(y) * tan(z)) return Float64(x + Float64(Float64(Float64(tan(y) / Float64(Float64(1.0 - Float64((tan(y) ^ 3.0) * (tan(z) ^ 3.0))) / Float64(1.0 + Float64((t_0 ^ 2.0) + Float64(1.0 * t_0))))) + Float64(tan(z) / Float64(1.0 - t_0))) - tan(a))) end
x, y, z, a = num2cell(sort([x, y, z, a])){:}
function tmp = code(x, y, z, a)
t_0 = tan(y) * tan(z);
tmp = x + (((tan(y) / ((1.0 - ((tan(y) ^ 3.0) * (tan(z) ^ 3.0))) / (1.0 + ((t_0 ^ 2.0) + (1.0 * t_0))))) + (tan(z) / (1.0 - t_0))) - tan(a));
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[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision]), $MachinePrecision]}, N[(x + N[(N[(N[(N[Tan[y], $MachinePrecision] / N[(N[(1.0 - N[(N[Power[N[Tan[y], $MachinePrecision], 3.0], $MachinePrecision] * N[Power[N[Tan[z], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[(N[Power[t$95$0, 2.0], $MachinePrecision] + N[(1.0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Tan[z], $MachinePrecision] / N[(1.0 - t$95$0), $MachinePrecision]), $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 := \tan y \cdot \tan z\\
x + \left(\left(\frac{\tan y}{\frac{1 - {\tan y}^{3} \cdot {\tan z}^{3}}{1 + \left({t\_0}^{2} + 1 \cdot t\_0\right)}} + \frac{\tan z}{1 - t\_0}\right) - \tan a\right)
\end{array}
\end{array}
Initial program 79.5%
lift-+.f64N/A
lift-tan.f64N/A
tan-sumN/A
quot-tanN/A
quot-tanN/A
div-addN/A
lower-+.f64N/A
Applied rewrites99.7%
lift--.f64N/A
lift-*.f64N/A
lift-tan.f64N/A
lift-tan.f64N/A
flip3--N/A
lower-/.f64N/A
metadata-evalN/A
lower--.f64N/A
lower-pow.f64N/A
lift-tan.f64N/A
lift-tan.f64N/A
lift-*.f64N/A
metadata-evalN/A
lower-+.f64N/A
Applied rewrites99.7%
lift-pow.f64N/A
lift-*.f64N/A
lift-tan.f64N/A
lift-tan.f64N/A
tan-quotN/A
tan-quotN/A
unpow-prod-downN/A
cube-div-revN/A
cube-div-revN/A
lower-*.f64N/A
cube-div-revN/A
lower-pow.f64N/A
tan-quotN/A
lift-tan.f64N/A
cube-div-revN/A
lower-pow.f64N/A
tan-quotN/A
lift-tan.f6499.7
Applied rewrites99.7%
lift-fma.f64N/A
lift-*.f64N/A
lift-tan.f64N/A
lift-tan.f64N/A
lift-*.f64N/A
lift-tan.f64N/A
lift-tan.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-tan.f64N/A
lift-tan.f64N/A
lower-+.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
(let* ((t_0 (* (tan y) (tan z))))
(+
x
(-
(+
(/
(tan y)
(/ (- 1.0 (pow t_0 3.0)) (+ 1.0 (+ (pow t_0 2.0) (* 1.0 t_0)))))
(/ (tan z) (- 1.0 t_0)))
(tan a)))))assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
double t_0 = tan(y) * tan(z);
return x + (((tan(y) / ((1.0 - pow(t_0, 3.0)) / (1.0 + (pow(t_0, 2.0) + (1.0 * t_0))))) + (tan(z) / (1.0 - t_0))) - 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
real(8) :: t_0
t_0 = tan(y) * tan(z)
code = x + (((tan(y) / ((1.0d0 - (t_0 ** 3.0d0)) / (1.0d0 + ((t_0 ** 2.0d0) + (1.0d0 * t_0))))) + (tan(z) / (1.0d0 - t_0))) - tan(a))
end function
assert x < y && y < z && z < a;
public static double code(double x, double y, double z, double a) {
double t_0 = Math.tan(y) * Math.tan(z);
return x + (((Math.tan(y) / ((1.0 - Math.pow(t_0, 3.0)) / (1.0 + (Math.pow(t_0, 2.0) + (1.0 * t_0))))) + (Math.tan(z) / (1.0 - t_0))) - Math.tan(a));
}
[x, y, z, a] = sort([x, y, z, a]) def code(x, y, z, a): t_0 = math.tan(y) * math.tan(z) return x + (((math.tan(y) / ((1.0 - math.pow(t_0, 3.0)) / (1.0 + (math.pow(t_0, 2.0) + (1.0 * t_0))))) + (math.tan(z) / (1.0 - t_0))) - math.tan(a))
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) t_0 = Float64(tan(y) * tan(z)) return Float64(x + Float64(Float64(Float64(tan(y) / Float64(Float64(1.0 - (t_0 ^ 3.0)) / Float64(1.0 + Float64((t_0 ^ 2.0) + Float64(1.0 * t_0))))) + Float64(tan(z) / Float64(1.0 - t_0))) - tan(a))) end
x, y, z, a = num2cell(sort([x, y, z, a])){:}
function tmp = code(x, y, z, a)
t_0 = tan(y) * tan(z);
tmp = x + (((tan(y) / ((1.0 - (t_0 ^ 3.0)) / (1.0 + ((t_0 ^ 2.0) + (1.0 * t_0))))) + (tan(z) / (1.0 - t_0))) - tan(a));
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[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision]), $MachinePrecision]}, N[(x + N[(N[(N[(N[Tan[y], $MachinePrecision] / N[(N[(1.0 - N[Power[t$95$0, 3.0], $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[(N[Power[t$95$0, 2.0], $MachinePrecision] + N[(1.0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Tan[z], $MachinePrecision] / N[(1.0 - t$95$0), $MachinePrecision]), $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 := \tan y \cdot \tan z\\
x + \left(\left(\frac{\tan y}{\frac{1 - {t\_0}^{3}}{1 + \left({t\_0}^{2} + 1 \cdot t\_0\right)}} + \frac{\tan z}{1 - t\_0}\right) - \tan a\right)
\end{array}
\end{array}
Initial program 79.5%
lift-+.f64N/A
lift-tan.f64N/A
tan-sumN/A
quot-tanN/A
quot-tanN/A
div-addN/A
lower-+.f64N/A
Applied rewrites99.7%
lift--.f64N/A
lift-*.f64N/A
lift-tan.f64N/A
lift-tan.f64N/A
flip3--N/A
lower-/.f64N/A
metadata-evalN/A
lower--.f64N/A
lower-pow.f64N/A
lift-tan.f64N/A
lift-tan.f64N/A
lift-*.f64N/A
metadata-evalN/A
lower-+.f64N/A
Applied rewrites99.7%
lift-fma.f64N/A
lift-*.f64N/A
lift-tan.f64N/A
lift-tan.f64N/A
lift-*.f64N/A
lift-tan.f64N/A
lift-tan.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-tan.f64N/A
lift-tan.f64N/A
lower-+.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
(-
(+
(/ (tan y) (- 1.0 (* (/ (sin y) (cos y)) (tan z))))
(/ (tan z) (- 1.0 (* (tan y) (tan z)))))
(tan a))))assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
return x + (((tan(y) / (1.0 - ((sin(y) / cos(y)) * tan(z)))) + (tan(z) / (1.0 - (tan(y) * tan(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) / (1.0d0 - ((sin(y) / cos(y)) * tan(z)))) + (tan(z) / (1.0d0 - (tan(y) * tan(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) / (1.0 - ((Math.sin(y) / Math.cos(y)) * Math.tan(z)))) + (Math.tan(z) / (1.0 - (Math.tan(y) * Math.tan(z))))) - Math.tan(a));
}
[x, y, z, a] = sort([x, y, z, a]) def code(x, y, z, a): return x + (((math.tan(y) / (1.0 - ((math.sin(y) / math.cos(y)) * math.tan(z)))) + (math.tan(z) / (1.0 - (math.tan(y) * math.tan(z))))) - math.tan(a))
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) return Float64(x + Float64(Float64(Float64(tan(y) / Float64(1.0 - Float64(Float64(sin(y) / cos(y)) * tan(z)))) + Float64(tan(z) / Float64(1.0 - Float64(tan(y) * tan(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) / (1.0 - ((sin(y) / cos(y)) * tan(z)))) + (tan(z) / (1.0 - (tan(y) * tan(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[(N[(N[Tan[y], $MachinePrecision] / N[(1.0 - N[(N[(N[Sin[y], $MachinePrecision] / N[Cos[y], $MachinePrecision]), $MachinePrecision] * N[Tan[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Tan[z], $MachinePrecision] / N[(1.0 - N[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision]), $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(\left(\frac{\tan y}{1 - \frac{\sin y}{\cos y} \cdot \tan z} + \frac{\tan z}{1 - \tan y \cdot \tan z}\right) - \tan a\right)
\end{array}
Initial program 79.5%
lift-+.f64N/A
lift-tan.f64N/A
tan-sumN/A
quot-tanN/A
quot-tanN/A
div-addN/A
lower-+.f64N/A
Applied rewrites99.7%
lift-tan.f64N/A
tan-quotN/A
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f6499.7
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
(-
(+
(/ (tan y) (- 1.0 (* (tan y) (tan z))))
(/ (tan z) (- 1.0 (* (/ (sin y) (cos y)) (tan z)))))
(tan a))))assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
return x + (((tan(y) / (1.0 - (tan(y) * tan(z)))) + (tan(z) / (1.0 - ((sin(y) / cos(y)) * tan(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) / (1.0d0 - (tan(y) * tan(z)))) + (tan(z) / (1.0d0 - ((sin(y) / cos(y)) * tan(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) / (1.0 - (Math.tan(y) * Math.tan(z)))) + (Math.tan(z) / (1.0 - ((Math.sin(y) / Math.cos(y)) * Math.tan(z))))) - Math.tan(a));
}
[x, y, z, a] = sort([x, y, z, a]) def code(x, y, z, a): return x + (((math.tan(y) / (1.0 - (math.tan(y) * math.tan(z)))) + (math.tan(z) / (1.0 - ((math.sin(y) / math.cos(y)) * math.tan(z))))) - math.tan(a))
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) return Float64(x + Float64(Float64(Float64(tan(y) / Float64(1.0 - Float64(tan(y) * tan(z)))) + Float64(tan(z) / Float64(1.0 - Float64(Float64(sin(y) / cos(y)) * tan(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) / (1.0 - (tan(y) * tan(z)))) + (tan(z) / (1.0 - ((sin(y) / cos(y)) * tan(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[(N[(N[Tan[y], $MachinePrecision] / N[(1.0 - N[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Tan[z], $MachinePrecision] / N[(1.0 - N[(N[(N[Sin[y], $MachinePrecision] / N[Cos[y], $MachinePrecision]), $MachinePrecision] * N[Tan[z], $MachinePrecision]), $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(\left(\frac{\tan y}{1 - \tan y \cdot \tan z} + \frac{\tan z}{1 - \frac{\sin y}{\cos y} \cdot \tan z}\right) - \tan a\right)
\end{array}
Initial program 79.5%
lift-+.f64N/A
lift-tan.f64N/A
tan-sumN/A
quot-tanN/A
quot-tanN/A
div-addN/A
lower-+.f64N/A
Applied rewrites99.7%
lift-tan.f64N/A
tan-quotN/A
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f6499.7
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 (let* ((t_0 (- 1.0 (* (tan y) (tan z))))) (+ x (- (+ (/ (tan y) t_0) (/ (tan z) t_0)) (tan a)))))
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
double t_0 = 1.0 - (tan(y) * tan(z));
return x + (((tan(y) / t_0) + (tan(z) / t_0)) - 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
real(8) :: t_0
t_0 = 1.0d0 - (tan(y) * tan(z))
code = x + (((tan(y) / t_0) + (tan(z) / t_0)) - tan(a))
end function
assert x < y && y < z && z < a;
public static double code(double x, double y, double z, double a) {
double t_0 = 1.0 - (Math.tan(y) * Math.tan(z));
return x + (((Math.tan(y) / t_0) + (Math.tan(z) / t_0)) - Math.tan(a));
}
[x, y, z, a] = sort([x, y, z, a]) def code(x, y, z, a): t_0 = 1.0 - (math.tan(y) * math.tan(z)) return x + (((math.tan(y) / t_0) + (math.tan(z) / t_0)) - math.tan(a))
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) t_0 = Float64(1.0 - Float64(tan(y) * tan(z))) return Float64(x + Float64(Float64(Float64(tan(y) / t_0) + Float64(tan(z) / t_0)) - tan(a))) end
x, y, z, a = num2cell(sort([x, y, z, a])){:}
function tmp = code(x, y, z, a)
t_0 = 1.0 - (tan(y) * tan(z));
tmp = x + (((tan(y) / t_0) + (tan(z) / t_0)) - tan(a));
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[(1.0 - N[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(x + N[(N[(N[(N[Tan[y], $MachinePrecision] / t$95$0), $MachinePrecision] + N[(N[Tan[z], $MachinePrecision] / t$95$0), $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 := 1 - \tan y \cdot \tan z\\
x + \left(\left(\frac{\tan y}{t\_0} + \frac{\tan z}{t\_0}\right) - \tan a\right)
\end{array}
\end{array}
Initial program 79.5%
lift-+.f64N/A
lift-tan.f64N/A
tan-sumN/A
quot-tanN/A
quot-tanN/A
div-addN/A
lower-+.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 (- (/ (+ (tan z) (tan y)) (- 1.0 (* (tan z) (tan y)))) (tan a))))
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
return x + (((tan(z) + tan(y)) / (1.0 - (tan(z) * tan(y)))) - 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(z) + tan(y)) / (1.0d0 - (tan(z) * tan(y)))) - 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(z) + Math.tan(y)) / (1.0 - (Math.tan(z) * Math.tan(y)))) - Math.tan(a));
}
[x, y, z, a] = sort([x, y, z, a]) def code(x, y, z, a): return x + (((math.tan(z) + math.tan(y)) / (1.0 - (math.tan(z) * math.tan(y)))) - math.tan(a))
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) return Float64(x + Float64(Float64(Float64(tan(z) + tan(y)) / Float64(1.0 - Float64(tan(z) * tan(y)))) - tan(a))) end
x, y, z, a = num2cell(sort([x, y, z, a])){:}
function tmp = code(x, y, z, a)
tmp = x + (((tan(z) + tan(y)) / (1.0 - (tan(z) * tan(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[Tan[z], $MachinePrecision] + N[Tan[y], $MachinePrecision]), $MachinePrecision] / N[(1.0 - N[(N[Tan[z], $MachinePrecision] * N[Tan[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{\tan z + \tan y}{1 - \tan z \cdot \tan y} - \tan a\right)
\end{array}
Initial program 79.5%
lift-+.f64N/A
lift-tan.f64N/A
+-commutativeN/A
tan-sumN/A
lower-/.f64N/A
quot-tanN/A
quot-tanN/A
lower-+.f64N/A
quot-tanN/A
lower-tan.f64N/A
quot-tanN/A
lower-tan.f64N/A
lower--.f64N/A
quot-tanN/A
quot-tanN/A
lower-*.f64N/A
quot-tanN/A
lower-tan.f64N/A
quot-tanN/A
lower-tan.f6499.7
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
(let* ((t_0 (- x (tan a))))
(if (<= (tan a) -0.04)
t_0
(if (<= (tan a) 0.0001)
(+ x (- (tan (+ y z)) (* (fma 0.3333333333333333 (* a a) 1.0) 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 tmp;
if (tan(a) <= -0.04) {
tmp = t_0;
} else if (tan(a) <= 0.0001) {
tmp = x + (tan((y + z)) - (fma(0.3333333333333333, (a * a), 1.0) * 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(a)) tmp = 0.0 if (tan(a) <= -0.04) tmp = t_0; elseif (tan(a) <= 0.0001) tmp = Float64(x + Float64(tan(Float64(y + z)) - Float64(fma(0.3333333333333333, Float64(a * a), 1.0) * a))); 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[a], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Tan[a], $MachinePrecision], -0.04], t$95$0, If[LessEqual[N[Tan[a], $MachinePrecision], 0.0001], N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[(N[(0.3333333333333333 * N[(a * a), $MachinePrecision] + 1.0), $MachinePrecision] * a), $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 a\\
\mathbf{if}\;\tan a \leq -0.04:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\tan a \leq 0.0001:\\
\;\;\;\;x + \left(\tan \left(y + z\right) - \mathsf{fma}\left(0.3333333333333333, a \cdot a, 1\right) \cdot a\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (tan.f64 a) < -0.0400000000000000008 or 1.00000000000000005e-4 < (tan.f64 a) Initial program 79.9%
Taylor expanded in y around 0
lower--.f64N/A
Applied rewrites51.5%
Taylor expanded in x around inf
Applied rewrites42.2%
if -0.0400000000000000008 < (tan.f64 a) < 1.00000000000000005e-4Initial program 79.1%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6478.0
Applied rewrites78.0%
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))))
(if (<= (tan a) -0.04)
t_0
(if (<= (tan a) 0.0001) (+ (+ x (- 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 tmp;
if (tan(a) <= -0.04) {
tmp = t_0;
} else if (tan(a) <= 0.0001) {
tmp = (x + -a) + tan((z + y));
} else {
tmp = t_0;
}
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) :: t_0
real(8) :: tmp
t_0 = x - tan(a)
if (tan(a) <= (-0.04d0)) then
tmp = t_0
else if (tan(a) <= 0.0001d0) then
tmp = (x + -a) + tan((z + y))
else
tmp = t_0
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 t_0 = x - Math.tan(a);
double tmp;
if (Math.tan(a) <= -0.04) {
tmp = t_0;
} else if (Math.tan(a) <= 0.0001) {
tmp = (x + -a) + Math.tan((z + y));
} 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) tmp = 0 if math.tan(a) <= -0.04: tmp = t_0 elif math.tan(a) <= 0.0001: tmp = (x + -a) + math.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(a)) tmp = 0.0 if (tan(a) <= -0.04) tmp = t_0; elseif (tan(a) <= 0.0001) tmp = Float64(Float64(x + Float64(-a)) + tan(Float64(z + y))); 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);
tmp = 0.0;
if (tan(a) <= -0.04)
tmp = t_0;
elseif (tan(a) <= 0.0001)
tmp = (x + -a) + tan((z + y));
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[a], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Tan[a], $MachinePrecision], -0.04], t$95$0, If[LessEqual[N[Tan[a], $MachinePrecision], 0.0001], N[(N[(x + (-a)), $MachinePrecision] + N[Tan[N[(z + y), $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 a\\
\mathbf{if}\;\tan a \leq -0.04:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\tan a \leq 0.0001:\\
\;\;\;\;\left(x + \left(-a\right)\right) + \tan \left(z + y\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (tan.f64 a) < -0.0400000000000000008 or 1.00000000000000005e-4 < (tan.f64 a) Initial program 79.9%
Taylor expanded in y around 0
lower--.f64N/A
Applied rewrites51.5%
Taylor expanded in x around inf
Applied rewrites42.2%
if -0.0400000000000000008 < (tan.f64 a) < 1.00000000000000005e-4Initial program 79.1%
Taylor expanded in a around 0
tan-quotN/A
associate-+r+N/A
lower-+.f64N/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-tan.f64N/A
+-commutativeN/A
lower-+.f6477.9
Applied rewrites77.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))))
(if (<= (tan a) -0.04)
t_0
(if (<= (tan a) 0.0001) (+ 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 tmp;
if (tan(a) <= -0.04) {
tmp = t_0;
} else if (tan(a) <= 0.0001) {
tmp = x + (tan((y + z)) - a);
} else {
tmp = t_0;
}
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) :: t_0
real(8) :: tmp
t_0 = x - tan(a)
if (tan(a) <= (-0.04d0)) then
tmp = t_0
else if (tan(a) <= 0.0001d0) then
tmp = x + (tan((y + z)) - a)
else
tmp = t_0
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 t_0 = x - Math.tan(a);
double tmp;
if (Math.tan(a) <= -0.04) {
tmp = t_0;
} else if (Math.tan(a) <= 0.0001) {
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) tmp = 0 if math.tan(a) <= -0.04: tmp = t_0 elif math.tan(a) <= 0.0001: 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(a)) tmp = 0.0 if (tan(a) <= -0.04) tmp = t_0; elseif (tan(a) <= 0.0001) 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);
tmp = 0.0;
if (tan(a) <= -0.04)
tmp = t_0;
elseif (tan(a) <= 0.0001)
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[a], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Tan[a], $MachinePrecision], -0.04], t$95$0, If[LessEqual[N[Tan[a], $MachinePrecision], 0.0001], 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 a\\
\mathbf{if}\;\tan a \leq -0.04:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\tan a \leq 0.0001:\\
\;\;\;\;x + \left(\tan \left(y + z\right) - a\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (tan.f64 a) < -0.0400000000000000008 or 1.00000000000000005e-4 < (tan.f64 a) Initial program 79.9%
Taylor expanded in y around 0
lower--.f64N/A
Applied rewrites51.5%
Taylor expanded in x around inf
Applied rewrites42.2%
if -0.0400000000000000008 < (tan.f64 a) < 1.00000000000000005e-4Initial program 79.1%
Taylor expanded in a around 0
Applied rewrites77.9%
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) 1e-13) (- (+ (tan y) x) (tan a)) (+ x (tan (+ z y)))))
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
double tmp;
if ((y + z) <= 1e-13) {
tmp = (tan(y) + x) - tan(a);
} else {
tmp = x + tan((z + y));
}
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) <= 1d-13) then
tmp = (tan(y) + x) - tan(a)
else
tmp = x + tan((z + y))
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) <= 1e-13) {
tmp = (Math.tan(y) + x) - Math.tan(a);
} else {
tmp = x + Math.tan((z + y));
}
return tmp;
}
[x, y, z, a] = sort([x, y, z, a]) def code(x, y, z, a): tmp = 0 if (y + z) <= 1e-13: tmp = (math.tan(y) + x) - math.tan(a) else: tmp = x + math.tan((z + y)) return tmp
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) tmp = 0.0 if (Float64(y + z) <= 1e-13) tmp = Float64(Float64(tan(y) + x) - tan(a)); else tmp = Float64(x + tan(Float64(z + y))); 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) <= 1e-13)
tmp = (tan(y) + x) - tan(a);
else
tmp = x + tan((z + y));
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], 1e-13], N[(N[(N[Tan[y], $MachinePrecision] + x), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision], N[(x + N[Tan[N[(z + y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
\begin{array}{l}
\mathbf{if}\;y + z \leq 10^{-13}:\\
\;\;\;\;\left(\tan y + x\right) - \tan a\\
\mathbf{else}:\\
\;\;\;\;x + \tan \left(z + y\right)\\
\end{array}
\end{array}
if (+.f64 y z) < 1e-13Initial program 83.4%
Taylor expanded in z around 0
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
quot-tanN/A
lower-tan.f64N/A
tan-quotN/A
lift-tan.f6483.2
Applied rewrites83.2%
if 1e-13 < (+.f64 y z) Initial program 73.3%
Taylor expanded in a around 0
tan-quotN/A
lift-tan.f64N/A
+-commutativeN/A
lower-+.f6446.2
Applied rewrites46.2%
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 1.15e-6) (+ 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 (z <= 1.15e-6) {
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 (z <= 1.15d-6) 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 (z <= 1.15e-6) {
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 z <= 1.15e-6: 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 (z <= 1.15e-6) 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 (z <= 1.15e-6)
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[z, 1.15e-6], 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}\;z \leq 1.15 \cdot 10^{-6}:\\
\;\;\;\;x + \left(\tan y - \tan a\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(\tan z - \tan a\right)\\
\end{array}
\end{array}
if z < 1.15e-6Initial program 90.5%
Taylor expanded in y around inf
Applied rewrites90.2%
if 1.15e-6 < z Initial program 65.7%
Taylor expanded in y around 0
Applied rewrites65.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 (<= z 1.15e-6) (+ 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 (z <= 1.15e-6) {
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 (z <= 1.15d-6) 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 (z <= 1.15e-6) {
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 z <= 1.15e-6: 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 (z <= 1.15e-6) 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 (z <= 1.15e-6)
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[z, 1.15e-6], 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}\;z \leq 1.15 \cdot 10^{-6}:\\
\;\;\;\;x + \left(\tan y - \tan a\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\tan z + x\right) - \tan a\\
\end{array}
\end{array}
if z < 1.15e-6Initial program 90.5%
Taylor expanded in y around inf
Applied rewrites90.2%
if 1.15e-6 < z Initial program 65.7%
Taylor expanded in y around 0
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
quot-tanN/A
lower-tan.f64N/A
tan-quotN/A
lift-tan.f6465.3
Applied rewrites65.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 1.15e-6) (- (+ (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 (z <= 1.15e-6) {
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 (z <= 1.15d-6) 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 (z <= 1.15e-6) {
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 z <= 1.15e-6: 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 (z <= 1.15e-6) 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 (z <= 1.15e-6)
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[z, 1.15e-6], 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}\;z \leq 1.15 \cdot 10^{-6}:\\
\;\;\;\;\left(\tan y + x\right) - \tan a\\
\mathbf{else}:\\
\;\;\;\;\left(\tan z + x\right) - \tan a\\
\end{array}
\end{array}
if z < 1.15e-6Initial program 90.5%
Taylor expanded in z around 0
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
quot-tanN/A
lower-tan.f64N/A
tan-quotN/A
lift-tan.f6490.2
Applied rewrites90.2%
if 1.15e-6 < z Initial program 65.7%
Taylor expanded in y around 0
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
quot-tanN/A
lower-tan.f64N/A
tan-quotN/A
lift-tan.f6465.3
Applied rewrites65.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.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))))
(if (<= a -0.55)
t_0
(if (<= a 0.45)
(+
x
(-
(tan (+ y z))
(*
(fma
(fma
(fma 0.05396825396825397 (* a a) 0.13333333333333333)
(* a a)
0.3333333333333333)
(* a a)
1.0)
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 tmp;
if (a <= -0.55) {
tmp = t_0;
} else if (a <= 0.45) {
tmp = x + (tan((y + z)) - (fma(fma(fma(0.05396825396825397, (a * a), 0.13333333333333333), (a * a), 0.3333333333333333), (a * a), 1.0) * 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(a)) tmp = 0.0 if (a <= -0.55) tmp = t_0; elseif (a <= 0.45) tmp = Float64(x + Float64(tan(Float64(y + z)) - Float64(fma(fma(fma(0.05396825396825397, Float64(a * a), 0.13333333333333333), Float64(a * a), 0.3333333333333333), Float64(a * a), 1.0) * a))); 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[a], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, -0.55], t$95$0, If[LessEqual[a, 0.45], N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[(N[(N[(N[(0.05396825396825397 * N[(a * a), $MachinePrecision] + 0.13333333333333333), $MachinePrecision] * N[(a * a), $MachinePrecision] + 0.3333333333333333), $MachinePrecision] * N[(a * a), $MachinePrecision] + 1.0), $MachinePrecision] * a), $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 a\\
\mathbf{if}\;a \leq -0.55:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;a \leq 0.45:\\
\;\;\;\;x + \left(\tan \left(y + z\right) - \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.05396825396825397, a \cdot a, 0.13333333333333333\right), a \cdot a, 0.3333333333333333\right), a \cdot a, 1\right) \cdot a\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if a < -0.55000000000000004 or 0.450000000000000011 < a Initial program 79.9%
Taylor expanded in y around 0
lower--.f64N/A
Applied rewrites51.3%
Taylor expanded in x around inf
Applied rewrites42.2%
if -0.55000000000000004 < a < 0.450000000000000011Initial program 79.2%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6479.0
Applied rewrites79.0%
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))))
(if (<= a -0.55)
t_0
(if (<= a 0.36)
(+
x
(-
(tan (+ y z))
(*
(fma
(fma 0.13333333333333333 (* a a) 0.3333333333333333)
(* a a)
1.0)
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 tmp;
if (a <= -0.55) {
tmp = t_0;
} else if (a <= 0.36) {
tmp = x + (tan((y + z)) - (fma(fma(0.13333333333333333, (a * a), 0.3333333333333333), (a * a), 1.0) * 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(a)) tmp = 0.0 if (a <= -0.55) tmp = t_0; elseif (a <= 0.36) tmp = Float64(x + Float64(tan(Float64(y + z)) - Float64(fma(fma(0.13333333333333333, Float64(a * a), 0.3333333333333333), Float64(a * a), 1.0) * a))); 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[a], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, -0.55], t$95$0, If[LessEqual[a, 0.36], N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[(N[(N[(0.13333333333333333 * N[(a * a), $MachinePrecision] + 0.3333333333333333), $MachinePrecision] * N[(a * a), $MachinePrecision] + 1.0), $MachinePrecision] * a), $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 a\\
\mathbf{if}\;a \leq -0.55:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;a \leq 0.36:\\
\;\;\;\;x + \left(\tan \left(y + z\right) - \mathsf{fma}\left(\mathsf{fma}\left(0.13333333333333333, a \cdot a, 0.3333333333333333\right), a \cdot a, 1\right) \cdot a\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if a < -0.55000000000000004 or 0.35999999999999999 < a Initial program 79.9%
Taylor expanded in y around 0
lower--.f64N/A
Applied rewrites51.3%
Taylor expanded in x around inf
Applied rewrites42.1%
if -0.55000000000000004 < a < 0.35999999999999999Initial program 79.1%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6479.0
Applied rewrites79.0%
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))))
(if (<= a -475000000000.0)
t_0
(if (<= a 2.3e-10) (+ x (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 tmp;
if (a <= -475000000000.0) {
tmp = t_0;
} else if (a <= 2.3e-10) {
tmp = x + tan((z + y));
} else {
tmp = t_0;
}
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) :: t_0
real(8) :: tmp
t_0 = x - tan(a)
if (a <= (-475000000000.0d0)) then
tmp = t_0
else if (a <= 2.3d-10) then
tmp = x + tan((z + y))
else
tmp = t_0
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 t_0 = x - Math.tan(a);
double tmp;
if (a <= -475000000000.0) {
tmp = t_0;
} else if (a <= 2.3e-10) {
tmp = x + Math.tan((z + y));
} 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) tmp = 0 if a <= -475000000000.0: tmp = t_0 elif a <= 2.3e-10: tmp = x + math.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(a)) tmp = 0.0 if (a <= -475000000000.0) tmp = t_0; elseif (a <= 2.3e-10) tmp = Float64(x + tan(Float64(z + y))); 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);
tmp = 0.0;
if (a <= -475000000000.0)
tmp = t_0;
elseif (a <= 2.3e-10)
tmp = x + tan((z + y));
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[a], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, -475000000000.0], t$95$0, If[LessEqual[a, 2.3e-10], N[(x + N[Tan[N[(z + y), $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 a\\
\mathbf{if}\;a \leq -475000000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;a \leq 2.3 \cdot 10^{-10}:\\
\;\;\;\;x + \tan \left(z + y\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if a < -4.75e11 or 2.30000000000000007e-10 < a Initial program 79.9%
Taylor expanded in y around 0
lower--.f64N/A
Applied rewrites51.2%
Taylor expanded in x around inf
Applied rewrites42.0%
if -4.75e11 < a < 2.30000000000000007e-10Initial program 79.1%
Taylor expanded in a around 0
tan-quotN/A
lift-tan.f64N/A
+-commutativeN/A
lower-+.f6477.3
Applied rewrites77.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) 1e-13) (- x (tan a)) (+ x (tan z))))
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
double tmp;
if ((y + z) <= 1e-13) {
tmp = x - tan(a);
} else {
tmp = x + tan(z);
}
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) <= 1d-13) then
tmp = x - tan(a)
else
tmp = x + tan(z)
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) <= 1e-13) {
tmp = x - Math.tan(a);
} else {
tmp = x + Math.tan(z);
}
return tmp;
}
[x, y, z, a] = sort([x, y, z, a]) def code(x, y, z, a): tmp = 0 if (y + z) <= 1e-13: tmp = x - math.tan(a) else: tmp = x + math.tan(z) return tmp
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) tmp = 0.0 if (Float64(y + z) <= 1e-13) tmp = Float64(x - tan(a)); else tmp = Float64(x + tan(z)); 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) <= 1e-13)
tmp = x - tan(a);
else
tmp = x + tan(z);
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], 1e-13], N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision], N[(x + N[Tan[z], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
\begin{array}{l}
\mathbf{if}\;y + z \leq 10^{-13}:\\
\;\;\;\;x - \tan a\\
\mathbf{else}:\\
\;\;\;\;x + \tan z\\
\end{array}
\end{array}
if (+.f64 y z) < 1e-13Initial program 83.4%
Taylor expanded in y around 0
lower--.f64N/A
Applied rewrites39.0%
Taylor expanded in x around inf
Applied rewrites52.3%
if 1e-13 < (+.f64 y z) Initial program 73.3%
lift-+.f64N/A
lift-tan.f64N/A
tan-sumN/A
quot-tanN/A
quot-tanN/A
div-addN/A
lower-+.f64N/A
Applied rewrites99.6%
Taylor expanded in y around 0
Applied rewrites73.1%
Taylor expanded in a around 0
lower-+.f64N/A
tan-quotN/A
lift-tan.f6446.2
Applied rewrites46.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 (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.5%
Taylor expanded in y around 0
lower--.f64N/A
Applied rewrites50.2%
Taylor expanded in x around inf
Applied rewrites41.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)
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 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])\\
\\
x
\end{array}
Initial program 79.5%
Taylor expanded in x around inf
Applied rewrites31.3%
herbie shell --seed 2025107
(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))))