
(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}
Sampling outcomes in binary64 precision:
Herbie found 19 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z a) :precision binary64 (+ x (- (tan (+ y z)) (tan a))))
double code(double x, double y, double z, double a) {
return x + (tan((y + z)) - tan(a));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
code = x + (tan((y + z)) - tan(a))
end function
public static double code(double x, double y, double z, double a) {
return x + (Math.tan((y + z)) - Math.tan(a));
}
def code(x, y, z, a): return x + (math.tan((y + z)) - math.tan(a))
function code(x, y, z, a) return Float64(x + Float64(tan(Float64(y + z)) - tan(a))) end
function tmp = code(x, y, z, a) tmp = x + (tan((y + z)) - tan(a)); end
code[x_, y_, z_, a_] := N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\tan \left(y + z\right) - \tan a\right)
\end{array}
(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)))))
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));
}
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
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));
}
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))
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
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
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}
\\
\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 78.9%
lift-+.f64N/A
lift-tan.f64N/A
tan-sumN/A
quot-tanN/A
quot-tanN/A
div-addN/A
lower-+.f64N/A
Applied rewrites99.8%
(FPCore (x y z a) :precision binary64 (+ x (- (/ (+ (tan z) (tan y)) (- 1.0 (* (tan z) (tan y)))) (tan 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));
}
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
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));
}
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))
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
function tmp = code(x, y, z, a) tmp = x + (((tan(z) + tan(y)) / (1.0 - (tan(z) * tan(y)))) - tan(a)); end
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 + \left(\frac{\tan z + \tan y}{1 - \tan z \cdot \tan y} - \tan a\right)
\end{array}
Initial program 78.9%
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.8
Applied rewrites99.8%
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (+ (tan z) (tan y))))
(if (or (<= a -0.00032) (not (<= a 3.0)))
(+ x (- (/ t_0 1.0) (tan a)))
(+ x (- (/ t_0 (- 1.0 (* (tan z) (tan y)))) a)))))
double code(double x, double y, double z, double a) {
double t_0 = tan(z) + tan(y);
double tmp;
if ((a <= -0.00032) || !(a <= 3.0)) {
tmp = x + ((t_0 / 1.0) - tan(a));
} else {
tmp = x + ((t_0 / (1.0 - (tan(z) * tan(y)))) - 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 = tan(z) + tan(y)
if ((a <= (-0.00032d0)) .or. (.not. (a <= 3.0d0))) then
tmp = x + ((t_0 / 1.0d0) - tan(a))
else
tmp = x + ((t_0 / (1.0d0 - (tan(z) * tan(y)))) - a)
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double t_0 = Math.tan(z) + Math.tan(y);
double tmp;
if ((a <= -0.00032) || !(a <= 3.0)) {
tmp = x + ((t_0 / 1.0) - Math.tan(a));
} else {
tmp = x + ((t_0 / (1.0 - (Math.tan(z) * Math.tan(y)))) - a);
}
return tmp;
}
def code(x, y, z, a): t_0 = math.tan(z) + math.tan(y) tmp = 0 if (a <= -0.00032) or not (a <= 3.0): tmp = x + ((t_0 / 1.0) - math.tan(a)) else: tmp = x + ((t_0 / (1.0 - (math.tan(z) * math.tan(y)))) - a) return tmp
function code(x, y, z, a) t_0 = Float64(tan(z) + tan(y)) tmp = 0.0 if ((a <= -0.00032) || !(a <= 3.0)) tmp = Float64(x + Float64(Float64(t_0 / 1.0) - tan(a))); else tmp = Float64(x + Float64(Float64(t_0 / Float64(1.0 - Float64(tan(z) * tan(y)))) - a)); end return tmp end
function tmp_2 = code(x, y, z, a) t_0 = tan(z) + tan(y); tmp = 0.0; if ((a <= -0.00032) || ~((a <= 3.0))) tmp = x + ((t_0 / 1.0) - tan(a)); else tmp = x + ((t_0 / (1.0 - (tan(z) * tan(y)))) - a); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[(N[Tan[z], $MachinePrecision] + N[Tan[y], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[a, -0.00032], N[Not[LessEqual[a, 3.0]], $MachinePrecision]], N[(x + N[(N[(t$95$0 / 1.0), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(t$95$0 / N[(1.0 - N[(N[Tan[z], $MachinePrecision] * N[Tan[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan z + \tan y\\
\mathbf{if}\;a \leq -0.00032 \lor \neg \left(a \leq 3\right):\\
\;\;\;\;x + \left(\frac{t\_0}{1} - \tan a\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(\frac{t\_0}{1 - \tan z \cdot \tan y} - a\right)\\
\end{array}
\end{array}
if a < -3.20000000000000026e-4 or 3 < a Initial program 79.9%
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%
lift-tan.f64N/A
tan-quotN/A
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f6499.7
Applied rewrites99.7%
Taylor expanded in y around 0
Applied rewrites80.5%
if -3.20000000000000026e-4 < a < 3Initial program 77.6%
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.8
Applied rewrites99.8%
Taylor expanded in a around 0
Applied rewrites99.2%
Final simplification88.6%
(FPCore (x y z a) :precision binary64 (+ x (- (/ (+ (tan z) (tan y)) 1.0) (tan a))))
double code(double x, double y, double z, double a) {
return x + (((tan(z) + tan(y)) / 1.0) - 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(z) + tan(y)) / 1.0d0) - tan(a))
end function
public static double code(double x, double y, double z, double a) {
return x + (((Math.tan(z) + Math.tan(y)) / 1.0) - Math.tan(a));
}
def code(x, y, z, a): return x + (((math.tan(z) + math.tan(y)) / 1.0) - math.tan(a))
function code(x, y, z, a) return Float64(x + Float64(Float64(Float64(tan(z) + tan(y)) / 1.0) - tan(a))) end
function tmp = code(x, y, z, a) tmp = x + (((tan(z) + tan(y)) / 1.0) - tan(a)); end
code[x_, y_, z_, a_] := N[(x + N[(N[(N[(N[Tan[z], $MachinePrecision] + N[Tan[y], $MachinePrecision]), $MachinePrecision] / 1.0), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\frac{\tan z + \tan y}{1} - \tan a\right)
\end{array}
Initial program 78.9%
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.8
Applied rewrites99.8%
lift-tan.f64N/A
tan-quotN/A
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f6499.8
Applied rewrites99.8%
Taylor expanded in y around 0
Applied rewrites79.6%
(FPCore (x y z a) :precision binary64 (+ x (- (tan (+ y z)) (/ (sin a) (cos a)))))
double code(double x, double y, double z, double a) {
return x + (tan((y + z)) - (sin(a) / cos(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)) - (sin(a) / cos(a)))
end function
public static double code(double x, double y, double z, double a) {
return x + (Math.tan((y + z)) - (Math.sin(a) / Math.cos(a)));
}
def code(x, y, z, a): return x + (math.tan((y + z)) - (math.sin(a) / math.cos(a)))
function code(x, y, z, a) return Float64(x + Float64(tan(Float64(y + z)) - Float64(sin(a) / cos(a)))) end
function tmp = code(x, y, z, a) tmp = x + (tan((y + z)) - (sin(a) / cos(a))); end
code[x_, y_, z_, a_] := N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[(N[Sin[a], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\tan \left(y + z\right) - \frac{\sin a}{\cos a}\right)
\end{array}
Initial program 78.9%
lift-tan.f64N/A
tan-quotN/A
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f6478.9
Applied rewrites78.9%
(FPCore (x y z a) :precision binary64 (if (or (<= (tan a) -0.0002) (not (<= (tan a) 0.18))) (- x (tan a)) (+ x (tan (+ z y)))))
double code(double x, double y, double z, double a) {
double tmp;
if ((tan(a) <= -0.0002) || !(tan(a) <= 0.18)) {
tmp = x - tan(a);
} else {
tmp = x + tan((z + y));
}
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 ((tan(a) <= (-0.0002d0)) .or. (.not. (tan(a) <= 0.18d0))) then
tmp = x - tan(a)
else
tmp = x + tan((z + y))
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double tmp;
if ((Math.tan(a) <= -0.0002) || !(Math.tan(a) <= 0.18)) {
tmp = x - Math.tan(a);
} else {
tmp = x + Math.tan((z + y));
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if (math.tan(a) <= -0.0002) or not (math.tan(a) <= 0.18): tmp = x - math.tan(a) else: tmp = x + math.tan((z + y)) return tmp
function code(x, y, z, a) tmp = 0.0 if ((tan(a) <= -0.0002) || !(tan(a) <= 0.18)) tmp = Float64(x - tan(a)); else tmp = Float64(x + tan(Float64(z + y))); end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if ((tan(a) <= -0.0002) || ~((tan(a) <= 0.18))) tmp = x - tan(a); else tmp = x + tan((z + y)); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[Or[LessEqual[N[Tan[a], $MachinePrecision], -0.0002], N[Not[LessEqual[N[Tan[a], $MachinePrecision], 0.18]], $MachinePrecision]], N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision], N[(x + N[Tan[N[(z + y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\tan a \leq -0.0002 \lor \neg \left(\tan a \leq 0.18\right):\\
\;\;\;\;x - \tan a\\
\mathbf{else}:\\
\;\;\;\;x + \tan \left(z + y\right)\\
\end{array}
\end{array}
if (tan.f64 a) < -2.0000000000000001e-4 or 0.17999999999999999 < (tan.f64 a) Initial program 80.1%
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.f6457.2
Applied rewrites57.2%
Taylor expanded in x around inf
Applied rewrites38.3%
if -2.0000000000000001e-4 < (tan.f64 a) < 0.17999999999999999Initial program 77.6%
Taylor expanded in a around 0
tan-quotN/A
lift-tan.f64N/A
+-commutativeN/A
lower-+.f6472.5
Applied rewrites72.5%
Final simplification54.5%
(FPCore (x y z a) :precision binary64 (if (<= (+ y z) -5e-15) (+ x (- (tan y) (tan a))) (+ x (- (tan z) (tan a)))))
double code(double x, double y, double z, double a) {
double tmp;
if ((y + z) <= -5e-15) {
tmp = x + (tan(y) - tan(a));
} else {
tmp = x + (tan(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 ((y + z) <= (-5d-15)) then
tmp = x + (tan(y) - tan(a))
else
tmp = x + (tan(z) - tan(a))
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double tmp;
if ((y + z) <= -5e-15) {
tmp = x + (Math.tan(y) - Math.tan(a));
} else {
tmp = x + (Math.tan(z) - Math.tan(a));
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if (y + z) <= -5e-15: tmp = x + (math.tan(y) - math.tan(a)) else: tmp = x + (math.tan(z) - math.tan(a)) return tmp
function code(x, y, z, a) tmp = 0.0 if (Float64(y + z) <= -5e-15) tmp = Float64(x + Float64(tan(y) - tan(a))); else tmp = Float64(x + Float64(tan(z) - tan(a))); end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if ((y + z) <= -5e-15) tmp = x + (tan(y) - tan(a)); else tmp = x + (tan(z) - tan(a)); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[N[(y + z), $MachinePrecision], -5e-15], 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}
\\
\begin{array}{l}
\mathbf{if}\;y + z \leq -5 \cdot 10^{-15}:\\
\;\;\;\;x + \left(\tan y - \tan a\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(\tan z - \tan a\right)\\
\end{array}
\end{array}
if (+.f64 y z) < -4.99999999999999999e-15Initial program 75.5%
Taylor expanded in y around inf
Applied rewrites48.7%
if -4.99999999999999999e-15 < (+.f64 y z) Initial program 81.2%
Taylor expanded in y around 0
Applied rewrites69.7%
(FPCore (x y z a) :precision binary64 (if (<= (+ y z) -5e-15) (+ x (- (tan y) (tan a))) (- (+ (tan z) x) (tan a))))
double code(double x, double y, double z, double a) {
double tmp;
if ((y + z) <= -5e-15) {
tmp = x + (tan(y) - tan(a));
} else {
tmp = (tan(z) + x) - 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 ((y + z) <= (-5d-15)) then
tmp = x + (tan(y) - tan(a))
else
tmp = (tan(z) + x) - tan(a)
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double tmp;
if ((y + z) <= -5e-15) {
tmp = x + (Math.tan(y) - Math.tan(a));
} else {
tmp = (Math.tan(z) + x) - Math.tan(a);
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if (y + z) <= -5e-15: tmp = x + (math.tan(y) - math.tan(a)) else: tmp = (math.tan(z) + x) - math.tan(a) return tmp
function code(x, y, z, a) tmp = 0.0 if (Float64(y + z) <= -5e-15) tmp = Float64(x + Float64(tan(y) - tan(a))); else tmp = Float64(Float64(tan(z) + x) - tan(a)); end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if ((y + z) <= -5e-15) tmp = x + (tan(y) - tan(a)); else tmp = (tan(z) + x) - tan(a); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[N[(y + z), $MachinePrecision], -5e-15], 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}
\\
\begin{array}{l}
\mathbf{if}\;y + z \leq -5 \cdot 10^{-15}:\\
\;\;\;\;x + \left(\tan y - \tan a\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\tan z + x\right) - \tan a\\
\end{array}
\end{array}
if (+.f64 y z) < -4.99999999999999999e-15Initial program 75.5%
Taylor expanded in y around inf
Applied rewrites48.7%
if -4.99999999999999999e-15 < (+.f64 y z) Initial program 81.2%
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.f6469.7
Applied rewrites69.7%
(FPCore (x y z a) :precision binary64 (if (<= (+ y z) -5e-15) (- (+ (tan y) x) (tan a)) (- (+ (tan z) x) (tan a))))
double code(double x, double y, double z, double a) {
double tmp;
if ((y + z) <= -5e-15) {
tmp = (tan(y) + x) - tan(a);
} else {
tmp = (tan(z) + x) - 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 ((y + z) <= (-5d-15)) then
tmp = (tan(y) + x) - tan(a)
else
tmp = (tan(z) + x) - tan(a)
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double tmp;
if ((y + z) <= -5e-15) {
tmp = (Math.tan(y) + x) - Math.tan(a);
} else {
tmp = (Math.tan(z) + x) - Math.tan(a);
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if (y + z) <= -5e-15: tmp = (math.tan(y) + x) - math.tan(a) else: tmp = (math.tan(z) + x) - math.tan(a) return tmp
function code(x, y, z, a) tmp = 0.0 if (Float64(y + z) <= -5e-15) tmp = Float64(Float64(tan(y) + x) - tan(a)); else tmp = Float64(Float64(tan(z) + x) - tan(a)); end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if ((y + z) <= -5e-15) tmp = (tan(y) + x) - tan(a); else tmp = (tan(z) + x) - tan(a); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[N[(y + z), $MachinePrecision], -5e-15], 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}
\\
\begin{array}{l}
\mathbf{if}\;y + z \leq -5 \cdot 10^{-15}:\\
\;\;\;\;\left(\tan y + x\right) - \tan a\\
\mathbf{else}:\\
\;\;\;\;\left(\tan z + x\right) - \tan a\\
\end{array}
\end{array}
if (+.f64 y z) < -4.99999999999999999e-15Initial program 75.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.f6448.7
Applied rewrites48.7%
if -4.99999999999999999e-15 < (+.f64 y z) Initial program 81.2%
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.f6469.7
Applied rewrites69.7%
(FPCore (x y z a) :precision binary64 (if (<= (+ y z) 0.02) (- (+ (tan y) x) (tan a)) (+ x (tan z))))
double code(double x, double y, double z, double a) {
double tmp;
if ((y + z) <= 0.02) {
tmp = (tan(y) + x) - tan(a);
} else {
tmp = x + tan(z);
}
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 ((y + z) <= 0.02d0) then
tmp = (tan(y) + x) - tan(a)
else
tmp = x + tan(z)
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double tmp;
if ((y + z) <= 0.02) {
tmp = (Math.tan(y) + x) - Math.tan(a);
} else {
tmp = x + Math.tan(z);
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if (y + z) <= 0.02: tmp = (math.tan(y) + x) - math.tan(a) else: tmp = x + math.tan(z) return tmp
function code(x, y, z, a) tmp = 0.0 if (Float64(y + z) <= 0.02) tmp = Float64(Float64(tan(y) + x) - tan(a)); else tmp = Float64(x + tan(z)); end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if ((y + z) <= 0.02) tmp = (tan(y) + x) - tan(a); else tmp = x + tan(z); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[N[(y + z), $MachinePrecision], 0.02], N[(N[(N[Tan[y], $MachinePrecision] + x), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision], N[(x + N[Tan[z], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y + z \leq 0.02:\\
\;\;\;\;\left(\tan y + x\right) - \tan a\\
\mathbf{else}:\\
\;\;\;\;x + \tan z\\
\end{array}
\end{array}
if (+.f64 y z) < 0.0200000000000000004Initial program 84.0%
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.f6466.6
Applied rewrites66.6%
if 0.0200000000000000004 < (+.f64 y z) Initial program 70.8%
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%
Taylor expanded in y around 0
Applied rewrites53.6%
Taylor expanded in a around 0
lower-+.f64N/A
tan-quotN/A
lift-tan.f6435.6
Applied rewrites35.6%
(FPCore (x y z a) :precision binary64 (if (<= (+ y z) 0.02) (+ (tan y) (- x (tan a))) (+ x (tan z))))
double code(double x, double y, double z, double a) {
double tmp;
if ((y + z) <= 0.02) {
tmp = tan(y) + (x - tan(a));
} else {
tmp = x + tan(z);
}
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 ((y + z) <= 0.02d0) then
tmp = tan(y) + (x - tan(a))
else
tmp = x + tan(z)
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double tmp;
if ((y + z) <= 0.02) {
tmp = Math.tan(y) + (x - Math.tan(a));
} else {
tmp = x + Math.tan(z);
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if (y + z) <= 0.02: tmp = math.tan(y) + (x - math.tan(a)) else: tmp = x + math.tan(z) return tmp
function code(x, y, z, a) tmp = 0.0 if (Float64(y + z) <= 0.02) tmp = Float64(tan(y) + Float64(x - tan(a))); else tmp = Float64(x + tan(z)); end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if ((y + z) <= 0.02) tmp = tan(y) + (x - tan(a)); else tmp = x + tan(z); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[N[(y + z), $MachinePrecision], 0.02], N[(N[Tan[y], $MachinePrecision] + N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[Tan[z], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y + z \leq 0.02:\\
\;\;\;\;\tan y + \left(x - \tan a\right)\\
\mathbf{else}:\\
\;\;\;\;x + \tan z\\
\end{array}
\end{array}
if (+.f64 y z) < 0.0200000000000000004Initial program 84.0%
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.f6466.6
Applied rewrites66.6%
lift--.f64N/A
lift-+.f64N/A
lift-tan.f64N/A
lift-tan.f64N/A
tan-quotN/A
tan-quotN/A
associate--l+N/A
lower-+.f64N/A
tan-quotN/A
lift-tan.f64N/A
lower--.f64N/A
tan-quotN/A
lift-tan.f6466.6
Applied rewrites66.6%
if 0.0200000000000000004 < (+.f64 y z) Initial program 70.8%
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%
Taylor expanded in y around 0
Applied rewrites53.6%
Taylor expanded in a around 0
lower-+.f64N/A
tan-quotN/A
lift-tan.f6435.6
Applied rewrites35.6%
(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}
Initial program 78.9%
(FPCore (x y z a) :precision binary64 (if (or (<= a -0.088) (not (<= a 5.5e-7))) (- x (tan a)) (+ x (- (tan (+ y z)) (* (fma 0.3333333333333333 (* a a) 1.0) a)))))
double code(double x, double y, double z, double a) {
double tmp;
if ((a <= -0.088) || !(a <= 5.5e-7)) {
tmp = x - tan(a);
} else {
tmp = x + (tan((y + z)) - (fma(0.3333333333333333, (a * a), 1.0) * a));
}
return tmp;
}
function code(x, y, z, a) tmp = 0.0 if ((a <= -0.088) || !(a <= 5.5e-7)) tmp = Float64(x - tan(a)); else tmp = Float64(x + Float64(tan(Float64(y + z)) - Float64(fma(0.3333333333333333, Float64(a * a), 1.0) * a))); end return tmp end
code[x_, y_, z_, a_] := If[Or[LessEqual[a, -0.088], N[Not[LessEqual[a, 5.5e-7]], $MachinePrecision]], N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision], 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]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.088 \lor \neg \left(a \leq 5.5 \cdot 10^{-7}\right):\\
\;\;\;\;x - \tan a\\
\mathbf{else}:\\
\;\;\;\;x + \left(\tan \left(y + z\right) - \mathsf{fma}\left(0.3333333333333333, a \cdot a, 1\right) \cdot a\right)\\
\end{array}
\end{array}
if a < -0.087999999999999995 or 5.5000000000000003e-7 < a Initial program 79.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.f6455.5
Applied rewrites55.5%
Taylor expanded in x around inf
Applied rewrites36.9%
if -0.087999999999999995 < a < 5.5000000000000003e-7Initial program 78.1%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6478.1
Applied rewrites78.1%
Final simplification54.6%
(FPCore (x y z a) :precision binary64 (if (<= (+ y z) -2.0) (+ (tan y) x) (if (<= (+ y z) 0.02) (- (+ y x) (tan a)) (+ x (tan z)))))
double code(double x, double y, double z, double a) {
double tmp;
if ((y + z) <= -2.0) {
tmp = tan(y) + x;
} else if ((y + z) <= 0.02) {
tmp = (y + x) - tan(a);
} else {
tmp = x + tan(z);
}
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 ((y + z) <= (-2.0d0)) then
tmp = tan(y) + x
else if ((y + z) <= 0.02d0) then
tmp = (y + x) - tan(a)
else
tmp = x + tan(z)
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double tmp;
if ((y + z) <= -2.0) {
tmp = Math.tan(y) + x;
} else if ((y + z) <= 0.02) {
tmp = (y + x) - Math.tan(a);
} else {
tmp = x + Math.tan(z);
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if (y + z) <= -2.0: tmp = math.tan(y) + x elif (y + z) <= 0.02: tmp = (y + x) - math.tan(a) else: tmp = x + math.tan(z) return tmp
function code(x, y, z, a) tmp = 0.0 if (Float64(y + z) <= -2.0) tmp = Float64(tan(y) + x); elseif (Float64(y + z) <= 0.02) tmp = Float64(Float64(y + x) - tan(a)); else tmp = Float64(x + tan(z)); end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if ((y + z) <= -2.0) tmp = tan(y) + x; elseif ((y + z) <= 0.02) tmp = (y + x) - tan(a); else tmp = x + tan(z); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[N[(y + z), $MachinePrecision], -2.0], N[(N[Tan[y], $MachinePrecision] + x), $MachinePrecision], If[LessEqual[N[(y + z), $MachinePrecision], 0.02], N[(N[(y + x), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision], N[(x + N[Tan[z], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y + z \leq -2:\\
\;\;\;\;\tan y + x\\
\mathbf{elif}\;y + z \leq 0.02:\\
\;\;\;\;\left(y + x\right) - \tan a\\
\mathbf{else}:\\
\;\;\;\;x + \tan z\\
\end{array}
\end{array}
if (+.f64 y z) < -2Initial program 74.7%
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.f6447.8
Applied rewrites47.8%
Taylor expanded in a around 0
+-commutativeN/A
tan-quotN/A
lift-tan.f64N/A
lift-+.f6430.6
Applied rewrites30.6%
if -2 < (+.f64 y z) < 0.0200000000000000004Initial program 99.9%
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.f6498.8
Applied rewrites98.8%
Taylor expanded in y around 0
Applied rewrites98.1%
if 0.0200000000000000004 < (+.f64 y z) Initial program 70.8%
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%
Taylor expanded in y around 0
Applied rewrites53.6%
Taylor expanded in a around 0
lower-+.f64N/A
tan-quotN/A
lift-tan.f6435.6
Applied rewrites35.6%
(FPCore (x y z a) :precision binary64 (if (or (<= a -0.00032) (not (<= a 5.5e-7))) (- x (tan a)) (+ x (- (tan (+ y z)) a))))
double code(double x, double y, double z, double a) {
double tmp;
if ((a <= -0.00032) || !(a <= 5.5e-7)) {
tmp = x - tan(a);
} else {
tmp = x + (tan((y + z)) - 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 ((a <= (-0.00032d0)) .or. (.not. (a <= 5.5d-7))) then
tmp = x - tan(a)
else
tmp = x + (tan((y + z)) - a)
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double tmp;
if ((a <= -0.00032) || !(a <= 5.5e-7)) {
tmp = x - Math.tan(a);
} else {
tmp = x + (Math.tan((y + z)) - a);
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if (a <= -0.00032) or not (a <= 5.5e-7): tmp = x - math.tan(a) else: tmp = x + (math.tan((y + z)) - a) return tmp
function code(x, y, z, a) tmp = 0.0 if ((a <= -0.00032) || !(a <= 5.5e-7)) tmp = Float64(x - tan(a)); else tmp = Float64(x + Float64(tan(Float64(y + z)) - a)); end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if ((a <= -0.00032) || ~((a <= 5.5e-7))) tmp = x - tan(a); else tmp = x + (tan((y + z)) - a); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[Or[LessEqual[a, -0.00032], N[Not[LessEqual[a, 5.5e-7]], $MachinePrecision]], N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision], N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.00032 \lor \neg \left(a \leq 5.5 \cdot 10^{-7}\right):\\
\;\;\;\;x - \tan a\\
\mathbf{else}:\\
\;\;\;\;x + \left(\tan \left(y + z\right) - a\right)\\
\end{array}
\end{array}
if a < -3.20000000000000026e-4 or 5.5000000000000003e-7 < a Initial program 79.7%
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.f6455.8
Applied rewrites55.8%
Taylor expanded in x around inf
Applied rewrites37.3%
if -3.20000000000000026e-4 < a < 5.5000000000000003e-7Initial program 77.9%
Taylor expanded in a around 0
Applied rewrites77.9%
Final simplification54.6%
(FPCore (x y z a) :precision binary64 (if (<= (+ y z) -5e-15) (+ (tan y) x) (if (<= (+ y z) 0.02) (- x (tan a)) (+ x (tan z)))))
double code(double x, double y, double z, double a) {
double tmp;
if ((y + z) <= -5e-15) {
tmp = tan(y) + x;
} else if ((y + z) <= 0.02) {
tmp = x - tan(a);
} else {
tmp = x + tan(z);
}
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 ((y + z) <= (-5d-15)) then
tmp = tan(y) + x
else if ((y + z) <= 0.02d0) then
tmp = x - tan(a)
else
tmp = x + tan(z)
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double tmp;
if ((y + z) <= -5e-15) {
tmp = Math.tan(y) + x;
} else if ((y + z) <= 0.02) {
tmp = x - Math.tan(a);
} else {
tmp = x + Math.tan(z);
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if (y + z) <= -5e-15: tmp = math.tan(y) + x elif (y + z) <= 0.02: tmp = x - math.tan(a) else: tmp = x + math.tan(z) return tmp
function code(x, y, z, a) tmp = 0.0 if (Float64(y + z) <= -5e-15) tmp = Float64(tan(y) + x); elseif (Float64(y + z) <= 0.02) tmp = Float64(x - tan(a)); else tmp = Float64(x + tan(z)); end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if ((y + z) <= -5e-15) tmp = tan(y) + x; elseif ((y + z) <= 0.02) tmp = x - tan(a); else tmp = x + tan(z); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[N[(y + z), $MachinePrecision], -5e-15], N[(N[Tan[y], $MachinePrecision] + x), $MachinePrecision], If[LessEqual[N[(y + z), $MachinePrecision], 0.02], N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision], N[(x + N[Tan[z], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y + z \leq -5 \cdot 10^{-15}:\\
\;\;\;\;\tan y + x\\
\mathbf{elif}\;y + z \leq 0.02:\\
\;\;\;\;x - \tan a\\
\mathbf{else}:\\
\;\;\;\;x + \tan z\\
\end{array}
\end{array}
if (+.f64 y z) < -4.99999999999999999e-15Initial program 75.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.f6448.7
Applied rewrites48.7%
Taylor expanded in a around 0
+-commutativeN/A
tan-quotN/A
lift-tan.f64N/A
lift-+.f6431.8
Applied rewrites31.8%
if -4.99999999999999999e-15 < (+.f64 y z) < 0.0200000000000000004Initial program 99.9%
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.f6499.9
Applied rewrites99.9%
Taylor expanded in x around inf
Applied rewrites98.7%
if 0.0200000000000000004 < (+.f64 y z) Initial program 70.8%
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%
Taylor expanded in y around 0
Applied rewrites53.6%
Taylor expanded in a around 0
lower-+.f64N/A
tan-quotN/A
lift-tan.f6435.6
Applied rewrites35.6%
(FPCore (x y z a) :precision binary64 (if (<= (+ y z) -5e-15) (+ (tan y) x) (- x (tan a))))
double code(double x, double y, double z, double a) {
double tmp;
if ((y + z) <= -5e-15) {
tmp = tan(y) + x;
} else {
tmp = x - 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 ((y + z) <= (-5d-15)) then
tmp = tan(y) + x
else
tmp = x - tan(a)
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double tmp;
if ((y + z) <= -5e-15) {
tmp = Math.tan(y) + x;
} else {
tmp = x - Math.tan(a);
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if (y + z) <= -5e-15: tmp = math.tan(y) + x else: tmp = x - math.tan(a) return tmp
function code(x, y, z, a) tmp = 0.0 if (Float64(y + z) <= -5e-15) tmp = Float64(tan(y) + x); else tmp = Float64(x - tan(a)); end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if ((y + z) <= -5e-15) tmp = tan(y) + x; else tmp = x - tan(a); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[N[(y + z), $MachinePrecision], -5e-15], N[(N[Tan[y], $MachinePrecision] + x), $MachinePrecision], N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y + z \leq -5 \cdot 10^{-15}:\\
\;\;\;\;\tan y + x\\
\mathbf{else}:\\
\;\;\;\;x - \tan a\\
\end{array}
\end{array}
if (+.f64 y z) < -4.99999999999999999e-15Initial program 75.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.f6448.7
Applied rewrites48.7%
Taylor expanded in a around 0
+-commutativeN/A
tan-quotN/A
lift-tan.f64N/A
lift-+.f6431.8
Applied rewrites31.8%
if -4.99999999999999999e-15 < (+.f64 y z) Initial program 81.2%
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.f6462.5
Applied rewrites62.5%
Taylor expanded in x around inf
Applied rewrites51.2%
(FPCore (x y z a) :precision binary64 (+ (tan y) x))
double code(double x, double y, double z, double a) {
return tan(y) + x;
}
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 = tan(y) + x
end function
public static double code(double x, double y, double z, double a) {
return Math.tan(y) + x;
}
def code(x, y, z, a): return math.tan(y) + x
function code(x, y, z, a) return Float64(tan(y) + x) end
function tmp = code(x, y, z, a) tmp = tan(y) + x; end
code[x_, y_, z_, a_] := N[(N[Tan[y], $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\tan y + x
\end{array}
Initial program 78.9%
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.f6457.0
Applied rewrites57.0%
Taylor expanded in a around 0
+-commutativeN/A
tan-quotN/A
lift-tan.f64N/A
lift-+.f6438.1
Applied rewrites38.1%
(FPCore (x y z a) :precision binary64 x)
double code(double x, double y, double z, double a) {
return x;
}
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
public static double code(double x, double y, double z, double a) {
return x;
}
def code(x, y, z, a): return x
function code(x, y, z, a) return x end
function tmp = code(x, y, z, a) tmp = x; end
code[x_, y_, z_, a_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 78.9%
Taylor expanded in x around inf
Applied rewrites32.5%
herbie shell --seed 2025085
(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))))