
(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]
x + \left(\tan \left(y + z\right) - \tan a\right)
Herbie found 10 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]
x + \left(\tan \left(y + z\right) - \tan a\right)
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (tan (fmax y z)))
(t_1 (sin (fmin y z)))
(t_2 (cos (fmin y z))))
(+
x
(-
(+
(/
t_1
(*
t_2
(- 1.0 (/ (* t_1 (sin (fmax y z))) (* t_2 (cos (fmax y z)))))))
(/ t_0 (- 1.0 (* t_0 (tan (fmin y z))))))
(tan a)))))double code(double x, double y, double z, double a) {
double t_0 = tan(fmax(y, z));
double t_1 = sin(fmin(y, z));
double t_2 = cos(fmin(y, z));
return x + (((t_1 / (t_2 * (1.0 - ((t_1 * sin(fmax(y, z))) / (t_2 * cos(fmax(y, z))))))) + (t_0 / (1.0 - (t_0 * tan(fmin(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
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
t_0 = tan(fmax(y, z))
t_1 = sin(fmin(y, z))
t_2 = cos(fmin(y, z))
code = x + (((t_1 / (t_2 * (1.0d0 - ((t_1 * sin(fmax(y, z))) / (t_2 * cos(fmax(y, z))))))) + (t_0 / (1.0d0 - (t_0 * tan(fmin(y, z)))))) - tan(a))
end function
public static double code(double x, double y, double z, double a) {
double t_0 = Math.tan(fmax(y, z));
double t_1 = Math.sin(fmin(y, z));
double t_2 = Math.cos(fmin(y, z));
return x + (((t_1 / (t_2 * (1.0 - ((t_1 * Math.sin(fmax(y, z))) / (t_2 * Math.cos(fmax(y, z))))))) + (t_0 / (1.0 - (t_0 * Math.tan(fmin(y, z)))))) - Math.tan(a));
}
def code(x, y, z, a): t_0 = math.tan(fmax(y, z)) t_1 = math.sin(fmin(y, z)) t_2 = math.cos(fmin(y, z)) return x + (((t_1 / (t_2 * (1.0 - ((t_1 * math.sin(fmax(y, z))) / (t_2 * math.cos(fmax(y, z))))))) + (t_0 / (1.0 - (t_0 * math.tan(fmin(y, z)))))) - math.tan(a))
function code(x, y, z, a) t_0 = tan(fmax(y, z)) t_1 = sin(fmin(y, z)) t_2 = cos(fmin(y, z)) return Float64(x + Float64(Float64(Float64(t_1 / Float64(t_2 * Float64(1.0 - Float64(Float64(t_1 * sin(fmax(y, z))) / Float64(t_2 * cos(fmax(y, z))))))) + Float64(t_0 / Float64(1.0 - Float64(t_0 * tan(fmin(y, z)))))) - tan(a))) end
function tmp = code(x, y, z, a) t_0 = tan(max(y, z)); t_1 = sin(min(y, z)); t_2 = cos(min(y, z)); tmp = x + (((t_1 / (t_2 * (1.0 - ((t_1 * sin(max(y, z))) / (t_2 * cos(max(y, z))))))) + (t_0 / (1.0 - (t_0 * tan(min(y, z)))))) - tan(a)); end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[Tan[N[Max[y, z], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[Min[y, z], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Cos[N[Min[y, z], $MachinePrecision]], $MachinePrecision]}, N[(x + N[(N[(N[(t$95$1 / N[(t$95$2 * N[(1.0 - N[(N[(t$95$1 * N[Sin[N[Max[y, z], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(t$95$2 * N[Cos[N[Max[y, z], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(t$95$0 / N[(1.0 - N[(t$95$0 * N[Tan[N[Min[y, z], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
t_0 := \tan \left(\mathsf{max}\left(y, z\right)\right)\\
t_1 := \sin \left(\mathsf{min}\left(y, z\right)\right)\\
t_2 := \cos \left(\mathsf{min}\left(y, z\right)\right)\\
x + \left(\left(\frac{t\_1}{t\_2 \cdot \left(1 - \frac{t\_1 \cdot \sin \left(\mathsf{max}\left(y, z\right)\right)}{t\_2 \cdot \cos \left(\mathsf{max}\left(y, z\right)\right)}\right)} + \frac{t\_0}{1 - t\_0 \cdot \tan \left(\mathsf{min}\left(y, z\right)\right)}\right) - \tan a\right)
\end{array}
Initial program 79.7%
lift-tan.f64N/A
tan-quotN/A
lift-+.f64N/A
+-commutativeN/A
sin-sumN/A
div-addN/A
*-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
Applied rewrites80.2%
lift-cos.f64N/A
lift-+.f64N/A
+-commutativeN/A
cos-sumN/A
sub-to-multN/A
lower-unsound-*.f64N/A
lower-unsound--.f64N/A
lower-unsound-/.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lower-*.f6481.0%
Applied rewrites81.0%
lift-cos.f64N/A
lift-+.f64N/A
+-commutativeN/A
cos-sumN/A
sub-to-multN/A
lower-unsound-*.f64N/A
lower-unsound--.f64N/A
lower-unsound-/.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lower-*.f6499.7%
Applied rewrites99.7%
Taylor expanded in y around inf
lower-+.f64N/A
Applied rewrites99.7%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
quot-tanN/A
lower-tan.f6499.7%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
times-fracN/A
lift-/.f64N/A
lower-*.f64N/A
Applied rewrites99.7%
(FPCore (x y z a) :precision binary64 (- x (- (tan a) (/ (+ (tan z) (tan y)) (- 1.0 (* (tan z) (tan y)))))))
double code(double x, double y, double z, double a) {
return x - (tan(a) - ((tan(z) + tan(y)) / (1.0 - (tan(z) * tan(y)))));
}
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) - ((tan(z) + tan(y)) / (1.0d0 - (tan(z) * tan(y)))))
end function
public static double code(double x, double y, double z, double a) {
return x - (Math.tan(a) - ((Math.tan(z) + Math.tan(y)) / (1.0 - (Math.tan(z) * Math.tan(y)))));
}
def code(x, y, z, a): return x - (math.tan(a) - ((math.tan(z) + math.tan(y)) / (1.0 - (math.tan(z) * math.tan(y)))))
function code(x, y, z, a) return Float64(x - Float64(tan(a) - Float64(Float64(tan(z) + tan(y)) / Float64(1.0 - Float64(tan(z) * tan(y)))))) end
function tmp = code(x, y, z, a) tmp = x - (tan(a) - ((tan(z) + tan(y)) / (1.0 - (tan(z) * tan(y))))); end
code[x_, y_, z_, a_] := N[(x - N[(N[Tan[a], $MachinePrecision] - 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]), $MachinePrecision]), $MachinePrecision]
x - \left(\tan a - \frac{\tan z + \tan y}{1 - \tan z \cdot \tan y}\right)
Initial program 79.7%
lift-tan.f64N/A
tan-quotN/A
lift-+.f64N/A
+-commutativeN/A
sin-sumN/A
div-addN/A
*-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
Applied rewrites80.2%
lift-cos.f64N/A
lift-+.f64N/A
+-commutativeN/A
cos-sumN/A
sub-to-multN/A
lower-unsound-*.f64N/A
lower-unsound--.f64N/A
lower-unsound-/.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lower-*.f6481.0%
Applied rewrites81.0%
lift-cos.f64N/A
lift-+.f64N/A
+-commutativeN/A
cos-sumN/A
sub-to-multN/A
lower-unsound-*.f64N/A
lower-unsound--.f64N/A
lower-unsound-/.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lower-*.f6499.7%
Applied rewrites99.7%
Taylor expanded in y around inf
lower-+.f64N/A
Applied rewrites99.7%
Applied rewrites99.7%
(FPCore (x y z a) :precision binary64 (if (<= (+ (fmin y z) (fmax y z)) -5e-13) (- x (- (tan a) (tan (fmin y z)))) (+ x (- (tan (fmax y z)) (tan a)))))
double code(double x, double y, double z, double a) {
double tmp;
if ((fmin(y, z) + fmax(y, z)) <= -5e-13) {
tmp = x - (tan(a) - tan(fmin(y, z)));
} else {
tmp = x + (tan(fmax(y, z)) - tan(a));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(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 ((fmin(y, z) + fmax(y, z)) <= (-5d-13)) then
tmp = x - (tan(a) - tan(fmin(y, z)))
else
tmp = x + (tan(fmax(y, z)) - tan(a))
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double tmp;
if ((fmin(y, z) + fmax(y, z)) <= -5e-13) {
tmp = x - (Math.tan(a) - Math.tan(fmin(y, z)));
} else {
tmp = x + (Math.tan(fmax(y, z)) - Math.tan(a));
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if (fmin(y, z) + fmax(y, z)) <= -5e-13: tmp = x - (math.tan(a) - math.tan(fmin(y, z))) else: tmp = x + (math.tan(fmax(y, z)) - math.tan(a)) return tmp
function code(x, y, z, a) tmp = 0.0 if (Float64(fmin(y, z) + fmax(y, z)) <= -5e-13) tmp = Float64(x - Float64(tan(a) - tan(fmin(y, z)))); else tmp = Float64(x + Float64(tan(fmax(y, z)) - tan(a))); end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if ((min(y, z) + max(y, z)) <= -5e-13) tmp = x - (tan(a) - tan(min(y, z))); else tmp = x + (tan(max(y, z)) - tan(a)); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[N[(N[Min[y, z], $MachinePrecision] + N[Max[y, z], $MachinePrecision]), $MachinePrecision], -5e-13], N[(x - N[(N[Tan[a], $MachinePrecision] - N[Tan[N[Min[y, z], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[Tan[N[Max[y, z], $MachinePrecision]], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\mathsf{min}\left(y, z\right) + \mathsf{max}\left(y, z\right) \leq -5 \cdot 10^{-13}:\\
\;\;\;\;x - \left(\tan a - \tan \left(\mathsf{min}\left(y, z\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(\tan \left(\mathsf{max}\left(y, z\right)\right) - \tan a\right)\\
\end{array}
if (+.f64 y z) < -4.9999999999999999e-13Initial program 79.7%
Taylor expanded in z around 0
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f6459.9%
Applied rewrites59.9%
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6459.9%
lift-/.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
quot-tanN/A
lower-tan.f6459.9%
Applied rewrites59.9%
if -4.9999999999999999e-13 < (+.f64 y z) Initial program 79.7%
Taylor expanded in y around 0
Applied rewrites60.6%
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (+ (fmin y z) (fmax y z))))
(if (<= (fmin y z) -116.0)
(+ x (/ (sin t_0) (cos t_0)))
(+ x (- (tan (fmax y z)) (tan a))))))double code(double x, double y, double z, double a) {
double t_0 = fmin(y, z) + fmax(y, z);
double tmp;
if (fmin(y, z) <= -116.0) {
tmp = x + (sin(t_0) / cos(t_0));
} else {
tmp = x + (tan(fmax(y, z)) - tan(a));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(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 = fmin(y, z) + fmax(y, z)
if (fmin(y, z) <= (-116.0d0)) then
tmp = x + (sin(t_0) / cos(t_0))
else
tmp = x + (tan(fmax(y, z)) - tan(a))
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double t_0 = fmin(y, z) + fmax(y, z);
double tmp;
if (fmin(y, z) <= -116.0) {
tmp = x + (Math.sin(t_0) / Math.cos(t_0));
} else {
tmp = x + (Math.tan(fmax(y, z)) - Math.tan(a));
}
return tmp;
}
def code(x, y, z, a): t_0 = fmin(y, z) + fmax(y, z) tmp = 0 if fmin(y, z) <= -116.0: tmp = x + (math.sin(t_0) / math.cos(t_0)) else: tmp = x + (math.tan(fmax(y, z)) - math.tan(a)) return tmp
function code(x, y, z, a) t_0 = Float64(fmin(y, z) + fmax(y, z)) tmp = 0.0 if (fmin(y, z) <= -116.0) tmp = Float64(x + Float64(sin(t_0) / cos(t_0))); else tmp = Float64(x + Float64(tan(fmax(y, z)) - tan(a))); end return tmp end
function tmp_2 = code(x, y, z, a) t_0 = min(y, z) + max(y, z); tmp = 0.0; if (min(y, z) <= -116.0) tmp = x + (sin(t_0) / cos(t_0)); else tmp = x + (tan(max(y, z)) - tan(a)); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[(N[Min[y, z], $MachinePrecision] + N[Max[y, z], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Min[y, z], $MachinePrecision], -116.0], N[(x + N[(N[Sin[t$95$0], $MachinePrecision] / N[Cos[t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[Tan[N[Max[y, z], $MachinePrecision]], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
t_0 := \mathsf{min}\left(y, z\right) + \mathsf{max}\left(y, z\right)\\
\mathbf{if}\;\mathsf{min}\left(y, z\right) \leq -116:\\
\;\;\;\;x + \frac{\sin t\_0}{\cos t\_0}\\
\mathbf{else}:\\
\;\;\;\;x + \left(\tan \left(\mathsf{max}\left(y, z\right)\right) - \tan a\right)\\
\end{array}
if y < -116Initial program 79.7%
Taylor expanded in a around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6441.1%
Applied rewrites41.1%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f6441.1%
Applied rewrites41.1%
Taylor expanded in y around 0
Applied rewrites31.4%
Taylor expanded in a around 0
lower-+.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-+.f64N/A
lower-cos.f64N/A
lower-+.f6450.8%
Applied rewrites50.8%
if -116 < y Initial program 79.7%
Taylor expanded in y around 0
Applied rewrites60.6%
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (+ (fmin y z) (fmax y z)))
(t_1 (tan t_0))
(t_2 (+ x (/ (sin t_0) (cos t_0)))))
(if (<= t_1 -0.01)
t_2
(if (<= t_1 4e-13)
(+
x
(-
(+
(fmax y z)
(*
(fmin y z)
(+
1.0
(*
(fmin y z)
(+ (fmax y z) (* 0.3333333333333333 (fmin y z)))))))
(tan a)))
t_2))))double code(double x, double y, double z, double a) {
double t_0 = fmin(y, z) + fmax(y, z);
double t_1 = tan(t_0);
double t_2 = x + (sin(t_0) / cos(t_0));
double tmp;
if (t_1 <= -0.01) {
tmp = t_2;
} else if (t_1 <= 4e-13) {
tmp = x + ((fmax(y, z) + (fmin(y, z) * (1.0 + (fmin(y, z) * (fmax(y, z) + (0.3333333333333333 * fmin(y, z))))))) - tan(a));
} else {
tmp = t_2;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, 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) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = fmin(y, z) + fmax(y, z)
t_1 = tan(t_0)
t_2 = x + (sin(t_0) / cos(t_0))
if (t_1 <= (-0.01d0)) then
tmp = t_2
else if (t_1 <= 4d-13) then
tmp = x + ((fmax(y, z) + (fmin(y, z) * (1.0d0 + (fmin(y, z) * (fmax(y, z) + (0.3333333333333333d0 * fmin(y, z))))))) - tan(a))
else
tmp = t_2
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double t_0 = fmin(y, z) + fmax(y, z);
double t_1 = Math.tan(t_0);
double t_2 = x + (Math.sin(t_0) / Math.cos(t_0));
double tmp;
if (t_1 <= -0.01) {
tmp = t_2;
} else if (t_1 <= 4e-13) {
tmp = x + ((fmax(y, z) + (fmin(y, z) * (1.0 + (fmin(y, z) * (fmax(y, z) + (0.3333333333333333 * fmin(y, z))))))) - Math.tan(a));
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z, a): t_0 = fmin(y, z) + fmax(y, z) t_1 = math.tan(t_0) t_2 = x + (math.sin(t_0) / math.cos(t_0)) tmp = 0 if t_1 <= -0.01: tmp = t_2 elif t_1 <= 4e-13: tmp = x + ((fmax(y, z) + (fmin(y, z) * (1.0 + (fmin(y, z) * (fmax(y, z) + (0.3333333333333333 * fmin(y, z))))))) - math.tan(a)) else: tmp = t_2 return tmp
function code(x, y, z, a) t_0 = Float64(fmin(y, z) + fmax(y, z)) t_1 = tan(t_0) t_2 = Float64(x + Float64(sin(t_0) / cos(t_0))) tmp = 0.0 if (t_1 <= -0.01) tmp = t_2; elseif (t_1 <= 4e-13) tmp = Float64(x + Float64(Float64(fmax(y, z) + Float64(fmin(y, z) * Float64(1.0 + Float64(fmin(y, z) * Float64(fmax(y, z) + Float64(0.3333333333333333 * fmin(y, z))))))) - tan(a))); else tmp = t_2; end return tmp end
function tmp_2 = code(x, y, z, a) t_0 = min(y, z) + max(y, z); t_1 = tan(t_0); t_2 = x + (sin(t_0) / cos(t_0)); tmp = 0.0; if (t_1 <= -0.01) tmp = t_2; elseif (t_1 <= 4e-13) tmp = x + ((max(y, z) + (min(y, z) * (1.0 + (min(y, z) * (max(y, z) + (0.3333333333333333 * min(y, z))))))) - tan(a)); else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[(N[Min[y, z], $MachinePrecision] + N[Max[y, z], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Tan[t$95$0], $MachinePrecision]}, Block[{t$95$2 = N[(x + N[(N[Sin[t$95$0], $MachinePrecision] / N[Cos[t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -0.01], t$95$2, If[LessEqual[t$95$1, 4e-13], N[(x + N[(N[(N[Max[y, z], $MachinePrecision] + N[(N[Min[y, z], $MachinePrecision] * N[(1.0 + N[(N[Min[y, z], $MachinePrecision] * N[(N[Max[y, z], $MachinePrecision] + N[(0.3333333333333333 * N[Min[y, z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
t_0 := \mathsf{min}\left(y, z\right) + \mathsf{max}\left(y, z\right)\\
t_1 := \tan t\_0\\
t_2 := x + \frac{\sin t\_0}{\cos t\_0}\\
\mathbf{if}\;t\_1 \leq -0.01:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 4 \cdot 10^{-13}:\\
\;\;\;\;x + \left(\left(\mathsf{max}\left(y, z\right) + \mathsf{min}\left(y, z\right) \cdot \left(1 + \mathsf{min}\left(y, z\right) \cdot \left(\mathsf{max}\left(y, z\right) + 0.3333333333333333 \cdot \mathsf{min}\left(y, z\right)\right)\right)\right) - \tan a\right)\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
if (tan.f64 (+.f64 y z)) < -0.01 or 4.0000000000000001e-13 < (tan.f64 (+.f64 y z)) Initial program 79.7%
Taylor expanded in a around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6441.1%
Applied rewrites41.1%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f6441.1%
Applied rewrites41.1%
Taylor expanded in y around 0
Applied rewrites31.4%
Taylor expanded in a around 0
lower-+.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-+.f64N/A
lower-cos.f64N/A
lower-+.f6450.8%
Applied rewrites50.8%
if -0.01 < (tan.f64 (+.f64 y z)) < 4.0000000000000001e-13Initial program 79.7%
lift-tan.f64N/A
tan-quotN/A
lift-+.f64N/A
+-commutativeN/A
sin-sumN/A
div-addN/A
*-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
Applied rewrites80.2%
Taylor expanded in z around 0
lower-fma.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-pow.f64N/A
lower-sin.f64N/A
lower-pow.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f6450.6%
Applied rewrites50.6%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6426.2%
Applied rewrites26.2%
(FPCore (x y z a)
:precision binary64
(let* ((t_0
(+
x
(-
(*
(fmin y z)
(+ 1.0 (* 0.3333333333333333 (pow (fmin y z) 2.0))))
(tan a)))))
(if (<= a -0.015)
t_0
(if (<= a 3.05)
(+
x
(-
(tan (+ (fmin y z) (fmax y z)))
(* a (fma (* 0.3333333333333333 a) a 1.0))))
t_0))))double code(double x, double y, double z, double a) {
double t_0 = x + ((fmin(y, z) * (1.0 + (0.3333333333333333 * pow(fmin(y, z), 2.0)))) - tan(a));
double tmp;
if (a <= -0.015) {
tmp = t_0;
} else if (a <= 3.05) {
tmp = x + (tan((fmin(y, z) + fmax(y, z))) - (a * fma((0.3333333333333333 * a), a, 1.0)));
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z, a) t_0 = Float64(x + Float64(Float64(fmin(y, z) * Float64(1.0 + Float64(0.3333333333333333 * (fmin(y, z) ^ 2.0)))) - tan(a))) tmp = 0.0 if (a <= -0.015) tmp = t_0; elseif (a <= 3.05) tmp = Float64(x + Float64(tan(Float64(fmin(y, z) + fmax(y, z))) - Float64(a * fma(Float64(0.3333333333333333 * a), a, 1.0)))); else tmp = t_0; end return tmp end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[(x + N[(N[(N[Min[y, z], $MachinePrecision] * N[(1.0 + N[(0.3333333333333333 * N[Power[N[Min[y, z], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, -0.015], t$95$0, If[LessEqual[a, 3.05], N[(x + N[(N[Tan[N[(N[Min[y, z], $MachinePrecision] + N[Max[y, z], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - N[(a * N[(N[(0.3333333333333333 * a), $MachinePrecision] * a + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := x + \left(\mathsf{min}\left(y, z\right) \cdot \left(1 + 0.3333333333333333 \cdot {\left(\mathsf{min}\left(y, z\right)\right)}^{2}\right) - \tan a\right)\\
\mathbf{if}\;a \leq -0.015:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;a \leq 3.05:\\
\;\;\;\;x + \left(\tan \left(\mathsf{min}\left(y, z\right) + \mathsf{max}\left(y, z\right)\right) - a \cdot \mathsf{fma}\left(0.3333333333333333 \cdot a, a, 1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if a < -0.014999999999999999 or 3.0499999999999998 < a Initial program 79.7%
Taylor expanded in z around 0
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f6459.9%
Applied rewrites59.9%
Taylor expanded in y around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6431.3%
Applied rewrites31.3%
if -0.014999999999999999 < a < 3.0499999999999998Initial program 79.7%
Taylor expanded in a around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6441.1%
Applied rewrites41.1%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f6441.1%
Applied rewrites41.1%
(FPCore (x y z a)
:precision binary64
(let* ((t_0
(+
x
(-
(+
(fmax y z)
(* (fmin y z) (+ 1.0 (* (fmin y z) (fmax y z)))))
(tan a)))))
(if (<= (tan a) -0.01)
t_0
(if (<= (tan a) 2e-5)
(+
x
(-
(tan (+ (fmin y z) (fmax y z)))
(* a (fma (* 0.3333333333333333 a) a 1.0))))
t_0))))double code(double x, double y, double z, double a) {
double t_0 = x + ((fmax(y, z) + (fmin(y, z) * (1.0 + (fmin(y, z) * fmax(y, z))))) - tan(a));
double tmp;
if (tan(a) <= -0.01) {
tmp = t_0;
} else if (tan(a) <= 2e-5) {
tmp = x + (tan((fmin(y, z) + fmax(y, z))) - (a * fma((0.3333333333333333 * a), a, 1.0)));
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z, a) t_0 = Float64(x + Float64(Float64(fmax(y, z) + Float64(fmin(y, z) * Float64(1.0 + Float64(fmin(y, z) * fmax(y, z))))) - tan(a))) tmp = 0.0 if (tan(a) <= -0.01) tmp = t_0; elseif (tan(a) <= 2e-5) tmp = Float64(x + Float64(tan(Float64(fmin(y, z) + fmax(y, z))) - Float64(a * fma(Float64(0.3333333333333333 * a), a, 1.0)))); else tmp = t_0; end return tmp end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[(x + N[(N[(N[Max[y, z], $MachinePrecision] + N[(N[Min[y, z], $MachinePrecision] * N[(1.0 + N[(N[Min[y, z], $MachinePrecision] * N[Max[y, z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Tan[a], $MachinePrecision], -0.01], t$95$0, If[LessEqual[N[Tan[a], $MachinePrecision], 2e-5], N[(x + N[(N[Tan[N[(N[Min[y, z], $MachinePrecision] + N[Max[y, z], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - N[(a * N[(N[(0.3333333333333333 * a), $MachinePrecision] * a + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := x + \left(\left(\mathsf{max}\left(y, z\right) + \mathsf{min}\left(y, z\right) \cdot \left(1 + \mathsf{min}\left(y, z\right) \cdot \mathsf{max}\left(y, z\right)\right)\right) - \tan a\right)\\
\mathbf{if}\;\tan a \leq -0.01:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\tan a \leq 2 \cdot 10^{-5}:\\
\;\;\;\;x + \left(\tan \left(\mathsf{min}\left(y, z\right) + \mathsf{max}\left(y, z\right)\right) - a \cdot \mathsf{fma}\left(0.3333333333333333 \cdot a, a, 1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if (tan.f64 a) < -0.01 or 2.0000000000000002e-5 < (tan.f64 a) Initial program 79.7%
lift-tan.f64N/A
tan-quotN/A
lift-+.f64N/A
+-commutativeN/A
sin-sumN/A
div-addN/A
*-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
Applied rewrites80.2%
Taylor expanded in z around 0
lower-fma.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-pow.f64N/A
lower-sin.f64N/A
lower-pow.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f6450.6%
Applied rewrites50.6%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6426.4%
Applied rewrites26.4%
if -0.01 < (tan.f64 a) < 2.0000000000000002e-5Initial program 79.7%
Taylor expanded in a around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6441.1%
Applied rewrites41.1%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f6441.1%
Applied rewrites41.1%
(FPCore (x y z a)
:precision binary64
(let* ((t_0
(+
x
(-
(+
(fmax y z)
(* (fmin y z) (+ 1.0 (* (fmin y z) (fmax y z)))))
(tan a)))))
(if (<= (tan a) -0.01)
t_0
(if (<= (tan a) 1e-8)
(+
x
(-
(tan (fmax y z))
(* a (fma 0.3333333333333333 (* a a) 1.0))))
t_0))))double code(double x, double y, double z, double a) {
double t_0 = x + ((fmax(y, z) + (fmin(y, z) * (1.0 + (fmin(y, z) * fmax(y, z))))) - tan(a));
double tmp;
if (tan(a) <= -0.01) {
tmp = t_0;
} else if (tan(a) <= 1e-8) {
tmp = x + (tan(fmax(y, z)) - (a * fma(0.3333333333333333, (a * a), 1.0)));
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z, a) t_0 = Float64(x + Float64(Float64(fmax(y, z) + Float64(fmin(y, z) * Float64(1.0 + Float64(fmin(y, z) * fmax(y, z))))) - tan(a))) tmp = 0.0 if (tan(a) <= -0.01) tmp = t_0; elseif (tan(a) <= 1e-8) tmp = Float64(x + Float64(tan(fmax(y, z)) - Float64(a * fma(0.3333333333333333, Float64(a * a), 1.0)))); else tmp = t_0; end return tmp end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[(x + N[(N[(N[Max[y, z], $MachinePrecision] + N[(N[Min[y, z], $MachinePrecision] * N[(1.0 + N[(N[Min[y, z], $MachinePrecision] * N[Max[y, z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Tan[a], $MachinePrecision], -0.01], t$95$0, If[LessEqual[N[Tan[a], $MachinePrecision], 1e-8], N[(x + N[(N[Tan[N[Max[y, z], $MachinePrecision]], $MachinePrecision] - N[(a * N[(0.3333333333333333 * N[(a * a), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := x + \left(\left(\mathsf{max}\left(y, z\right) + \mathsf{min}\left(y, z\right) \cdot \left(1 + \mathsf{min}\left(y, z\right) \cdot \mathsf{max}\left(y, z\right)\right)\right) - \tan a\right)\\
\mathbf{if}\;\tan a \leq -0.01:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\tan a \leq 10^{-8}:\\
\;\;\;\;x + \left(\tan \left(\mathsf{max}\left(y, z\right)\right) - a \cdot \mathsf{fma}\left(0.3333333333333333, a \cdot a, 1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if (tan.f64 a) < -0.01 or 1e-8 < (tan.f64 a) Initial program 79.7%
lift-tan.f64N/A
tan-quotN/A
lift-+.f64N/A
+-commutativeN/A
sin-sumN/A
div-addN/A
*-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
Applied rewrites80.2%
Taylor expanded in z around 0
lower-fma.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-pow.f64N/A
lower-sin.f64N/A
lower-pow.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f6450.6%
Applied rewrites50.6%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6426.4%
Applied rewrites26.4%
if -0.01 < (tan.f64 a) < 1e-8Initial program 79.7%
Taylor expanded in a around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6441.1%
Applied rewrites41.1%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f6441.1%
Applied rewrites41.1%
Taylor expanded in y around 0
Applied rewrites31.4%
lift-fma.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f32N/A
lower-unsound-*.f32N/A
lower-fma.f64N/A
lower-unsound-*.f6431.4%
Applied rewrites31.4%
(FPCore (x y z a) :precision binary64 (+ x (- (tan (fmax y z)) (* a (fma 0.3333333333333333 (* a a) 1.0)))))
double code(double x, double y, double z, double a) {
return x + (tan(fmax(y, z)) - (a * fma(0.3333333333333333, (a * a), 1.0)));
}
function code(x, y, z, a) return Float64(x + Float64(tan(fmax(y, z)) - Float64(a * fma(0.3333333333333333, Float64(a * a), 1.0)))) end
code[x_, y_, z_, a_] := N[(x + N[(N[Tan[N[Max[y, z], $MachinePrecision]], $MachinePrecision] - N[(a * N[(0.3333333333333333 * N[(a * a), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
x + \left(\tan \left(\mathsf{max}\left(y, z\right)\right) - a \cdot \mathsf{fma}\left(0.3333333333333333, a \cdot a, 1\right)\right)
Initial program 79.7%
Taylor expanded in a around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6441.1%
Applied rewrites41.1%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f6441.1%
Applied rewrites41.1%
Taylor expanded in y around 0
Applied rewrites31.4%
lift-fma.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f32N/A
lower-unsound-*.f32N/A
lower-fma.f64N/A
lower-unsound-*.f6431.4%
Applied rewrites31.4%
herbie shell --seed 2025210
(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))))