
(FPCore (x y z a) :precision binary64 (+ x (- (tan (+ y z)) (tan a))))
double code(double x, double y, double z, double a) {
return x + (tan((y + z)) - tan(a));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
code = x + (tan((y + z)) - tan(a))
end function
public static double code(double x, double y, double z, double a) {
return x + (Math.tan((y + z)) - Math.tan(a));
}
def code(x, y, z, a): return x + (math.tan((y + z)) - math.tan(a))
function code(x, y, z, a) return Float64(x + Float64(tan(Float64(y + z)) - tan(a))) end
function tmp = code(x, y, z, a) tmp = x + (tan((y + z)) - tan(a)); end
code[x_, y_, z_, a_] := N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\tan \left(y + z\right) - \tan a\right)
\end{array}
Herbie found 14 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 (+ x (- (* (+ (tan z) (tan y)) (/ 1.0 (- 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 / (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 / (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 / (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 / (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(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 / (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[(1.0 - N[(N[Tan[z], $MachinePrecision] * N[Tan[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\left(\tan z + \tan y\right) \cdot \frac{1}{1 - \tan z \cdot \tan y} - \tan a\right)
\end{array}
Initial program 79.1%
lift-tan.f64N/A
lift-+.f64N/A
tan-sumN/A
mult-flipN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-tan.f64N/A
lower-tan.f64N/A
lower-/.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-tan.f64N/A
lower-tan.f6499.7
Applied rewrites99.7%
(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 79.1%
lift-tan.f64N/A
lift-+.f64N/A
tan-sumN/A
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-tan.f64N/A
lower-tan.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-tan.f64N/A
lower-tan.f6499.7
Applied rewrites99.7%
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (+ x (- (/ (fma (sin z) (/ 1.0 (cos z)) (tan y)) 1.0) (tan a)))))
(if (<= a -0.017)
t_0
(if (<= a 3.5e-38)
(+
x
(-
(* (+ (tan z) (tan y)) (/ 1.0 (- 1.0 (* (tan z) (tan y)))))
(* a (+ 1.0 (* 0.3333333333333333 (pow a 2.0))))))
t_0))))
double code(double x, double y, double z, double a) {
double t_0 = x + ((fma(sin(z), (1.0 / cos(z)), tan(y)) / 1.0) - tan(a));
double tmp;
if (a <= -0.017) {
tmp = t_0;
} else if (a <= 3.5e-38) {
tmp = x + (((tan(z) + tan(y)) * (1.0 / (1.0 - (tan(z) * tan(y))))) - (a * (1.0 + (0.3333333333333333 * pow(a, 2.0)))));
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z, a) t_0 = Float64(x + Float64(Float64(fma(sin(z), Float64(1.0 / cos(z)), tan(y)) / 1.0) - tan(a))) tmp = 0.0 if (a <= -0.017) tmp = t_0; elseif (a <= 3.5e-38) tmp = Float64(x + Float64(Float64(Float64(tan(z) + tan(y)) * Float64(1.0 / Float64(1.0 - Float64(tan(z) * tan(y))))) - Float64(a * Float64(1.0 + Float64(0.3333333333333333 * (a ^ 2.0)))))); else tmp = t_0; end return tmp end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[(x + N[(N[(N[(N[Sin[z], $MachinePrecision] * N[(1.0 / N[Cos[z], $MachinePrecision]), $MachinePrecision] + N[Tan[y], $MachinePrecision]), $MachinePrecision] / 1.0), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, -0.017], t$95$0, If[LessEqual[a, 3.5e-38], N[(x + N[(N[(N[(N[Tan[z], $MachinePrecision] + N[Tan[y], $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(1.0 - N[(N[Tan[z], $MachinePrecision] * N[Tan[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(a * N[(1.0 + N[(0.3333333333333333 * N[Power[a, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x + \left(\frac{\mathsf{fma}\left(\sin z, \frac{1}{\cos z}, \tan y\right)}{1} - \tan a\right)\\
\mathbf{if}\;a \leq -0.017:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;a \leq 3.5 \cdot 10^{-38}:\\
\;\;\;\;x + \left(\left(\tan z + \tan y\right) \cdot \frac{1}{1 - \tan z \cdot \tan y} - a \cdot \left(1 + 0.3333333333333333 \cdot {a}^{2}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if a < -0.017000000000000001 or 3.5000000000000001e-38 < a Initial program 79.1%
lift-tan.f64N/A
lift-+.f64N/A
tan-sumN/A
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-tan.f64N/A
lower-tan.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-tan.f64N/A
lower-tan.f6499.7
Applied rewrites99.7%
lift-+.f64N/A
lift-tan.f64N/A
tan-quotN/A
mult-flipN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-/.f64N/A
lower-cos.f6499.7
Applied rewrites99.7%
Taylor expanded in y around 0
Applied rewrites79.4%
if -0.017000000000000001 < a < 3.5000000000000001e-38Initial program 79.1%
lift-tan.f64N/A
lift-+.f64N/A
tan-sumN/A
mult-flipN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-tan.f64N/A
lower-tan.f64N/A
lower-/.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-tan.f64N/A
lower-tan.f6499.7
Applied rewrites99.7%
Taylor expanded in a around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6451.5
Applied rewrites51.5%
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (+ x (- (/ (fma (sin z) (/ 1.0 (cos z)) (tan y)) 1.0) (tan a)))))
(if (<= a -0.017)
t_0
(if (<= a 3.5e-38)
(+
x
(-
(/ (+ (tan z) (tan y)) (- 1.0 (* (tan z) (tan y))))
(* a (+ 1.0 (* 0.3333333333333333 (pow a 2.0))))))
t_0))))
double code(double x, double y, double z, double a) {
double t_0 = x + ((fma(sin(z), (1.0 / cos(z)), tan(y)) / 1.0) - tan(a));
double tmp;
if (a <= -0.017) {
tmp = t_0;
} else if (a <= 3.5e-38) {
tmp = x + (((tan(z) + tan(y)) / (1.0 - (tan(z) * tan(y)))) - (a * (1.0 + (0.3333333333333333 * pow(a, 2.0)))));
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z, a) t_0 = Float64(x + Float64(Float64(fma(sin(z), Float64(1.0 / cos(z)), tan(y)) / 1.0) - tan(a))) tmp = 0.0 if (a <= -0.017) tmp = t_0; elseif (a <= 3.5e-38) tmp = Float64(x + Float64(Float64(Float64(tan(z) + tan(y)) / Float64(1.0 - Float64(tan(z) * tan(y)))) - Float64(a * Float64(1.0 + Float64(0.3333333333333333 * (a ^ 2.0)))))); else tmp = t_0; end return tmp end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[(x + N[(N[(N[(N[Sin[z], $MachinePrecision] * N[(1.0 / N[Cos[z], $MachinePrecision]), $MachinePrecision] + N[Tan[y], $MachinePrecision]), $MachinePrecision] / 1.0), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, -0.017], t$95$0, If[LessEqual[a, 3.5e-38], 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[(a * N[(1.0 + N[(0.3333333333333333 * N[Power[a, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x + \left(\frac{\mathsf{fma}\left(\sin z, \frac{1}{\cos z}, \tan y\right)}{1} - \tan a\right)\\
\mathbf{if}\;a \leq -0.017:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;a \leq 3.5 \cdot 10^{-38}:\\
\;\;\;\;x + \left(\frac{\tan z + \tan y}{1 - \tan z \cdot \tan y} - a \cdot \left(1 + 0.3333333333333333 \cdot {a}^{2}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if a < -0.017000000000000001 or 3.5000000000000001e-38 < a Initial program 79.1%
lift-tan.f64N/A
lift-+.f64N/A
tan-sumN/A
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-tan.f64N/A
lower-tan.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-tan.f64N/A
lower-tan.f6499.7
Applied rewrites99.7%
lift-+.f64N/A
lift-tan.f64N/A
tan-quotN/A
mult-flipN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-/.f64N/A
lower-cos.f6499.7
Applied rewrites99.7%
Taylor expanded in y around 0
Applied rewrites79.4%
if -0.017000000000000001 < a < 3.5000000000000001e-38Initial program 79.1%
lift-tan.f64N/A
lift-+.f64N/A
tan-sumN/A
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-tan.f64N/A
lower-tan.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-tan.f64N/A
lower-tan.f6499.7
Applied rewrites99.7%
Taylor expanded in a around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6451.5
Applied rewrites51.5%
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (+ x (- (/ (fma (sin z) (/ 1.0 (cos z)) (tan y)) 1.0) (tan a)))))
(if (<= a -0.017)
t_0
(if (<= a 3.5e-38)
(fma
(/ -1.0 (fma (tan y) (tan z) -1.0))
(+ (tan y) (tan z))
(+ (- a) x))
t_0))))
double code(double x, double y, double z, double a) {
double t_0 = x + ((fma(sin(z), (1.0 / cos(z)), tan(y)) / 1.0) - tan(a));
double tmp;
if (a <= -0.017) {
tmp = t_0;
} else if (a <= 3.5e-38) {
tmp = fma((-1.0 / fma(tan(y), tan(z), -1.0)), (tan(y) + tan(z)), (-a + x));
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z, a) t_0 = Float64(x + Float64(Float64(fma(sin(z), Float64(1.0 / cos(z)), tan(y)) / 1.0) - tan(a))) tmp = 0.0 if (a <= -0.017) tmp = t_0; elseif (a <= 3.5e-38) tmp = fma(Float64(-1.0 / fma(tan(y), tan(z), -1.0)), Float64(tan(y) + tan(z)), Float64(Float64(-a) + x)); else tmp = t_0; end return tmp end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[(x + N[(N[(N[(N[Sin[z], $MachinePrecision] * N[(1.0 / N[Cos[z], $MachinePrecision]), $MachinePrecision] + N[Tan[y], $MachinePrecision]), $MachinePrecision] / 1.0), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, -0.017], t$95$0, If[LessEqual[a, 3.5e-38], N[(N[(-1.0 / N[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision] * N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision] + N[((-a) + x), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x + \left(\frac{\mathsf{fma}\left(\sin z, \frac{1}{\cos z}, \tan y\right)}{1} - \tan a\right)\\
\mathbf{if}\;a \leq -0.017:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;a \leq 3.5 \cdot 10^{-38}:\\
\;\;\;\;\mathsf{fma}\left(\frac{-1}{\mathsf{fma}\left(\tan y, \tan z, -1\right)}, \tan y + \tan z, \left(-a\right) + x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if a < -0.017000000000000001 or 3.5000000000000001e-38 < a Initial program 79.1%
lift-tan.f64N/A
lift-+.f64N/A
tan-sumN/A
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-tan.f64N/A
lower-tan.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-tan.f64N/A
lower-tan.f6499.7
Applied rewrites99.7%
lift-+.f64N/A
lift-tan.f64N/A
tan-quotN/A
mult-flipN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-/.f64N/A
lower-cos.f6499.7
Applied rewrites99.7%
Taylor expanded in y around 0
Applied rewrites79.4%
if -0.017000000000000001 < a < 3.5000000000000001e-38Initial program 79.1%
Taylor expanded in a around 0
Applied rewrites41.5%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
sub-flipN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
associate-+l+N/A
Applied rewrites51.8%
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (+ x (- (/ (fma (sin z) (/ 1.0 (cos z)) (tan y)) 1.0) (tan a)))))
(if (<= a -0.017)
t_0
(if (<= a 3.5e-38)
(+ x (- (/ (+ (tan z) (tan y)) (- 1.0 (* (tan z) (tan y)))) a))
t_0))))
double code(double x, double y, double z, double a) {
double t_0 = x + ((fma(sin(z), (1.0 / cos(z)), tan(y)) / 1.0) - tan(a));
double tmp;
if (a <= -0.017) {
tmp = t_0;
} else if (a <= 3.5e-38) {
tmp = x + (((tan(z) + tan(y)) / (1.0 - (tan(z) * tan(y)))) - a);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z, a) t_0 = Float64(x + Float64(Float64(fma(sin(z), Float64(1.0 / cos(z)), tan(y)) / 1.0) - tan(a))) tmp = 0.0 if (a <= -0.017) tmp = t_0; elseif (a <= 3.5e-38) tmp = Float64(x + Float64(Float64(Float64(tan(z) + tan(y)) / Float64(1.0 - Float64(tan(z) * tan(y)))) - a)); else tmp = t_0; end return tmp end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[(x + N[(N[(N[(N[Sin[z], $MachinePrecision] * N[(1.0 / N[Cos[z], $MachinePrecision]), $MachinePrecision] + N[Tan[y], $MachinePrecision]), $MachinePrecision] / 1.0), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, -0.017], t$95$0, If[LessEqual[a, 3.5e-38], 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] - a), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x + \left(\frac{\mathsf{fma}\left(\sin z, \frac{1}{\cos z}, \tan y\right)}{1} - \tan a\right)\\
\mathbf{if}\;a \leq -0.017:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;a \leq 3.5 \cdot 10^{-38}:\\
\;\;\;\;x + \left(\frac{\tan z + \tan y}{1 - \tan z \cdot \tan y} - a\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if a < -0.017000000000000001 or 3.5000000000000001e-38 < a Initial program 79.1%
lift-tan.f64N/A
lift-+.f64N/A
tan-sumN/A
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-tan.f64N/A
lower-tan.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-tan.f64N/A
lower-tan.f6499.7
Applied rewrites99.7%
lift-+.f64N/A
lift-tan.f64N/A
tan-quotN/A
mult-flipN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-/.f64N/A
lower-cos.f6499.7
Applied rewrites99.7%
Taylor expanded in y around 0
Applied rewrites79.4%
if -0.017000000000000001 < a < 3.5000000000000001e-38Initial program 79.1%
lift-tan.f64N/A
lift-+.f64N/A
tan-sumN/A
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-tan.f64N/A
lower-tan.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-tan.f64N/A
lower-tan.f6499.7
Applied rewrites99.7%
Taylor expanded in a around 0
Applied rewrites51.8%
(FPCore (x y z a) :precision binary64 (+ x (- (/ (fma (sin z) (/ 1.0 (cos z)) (tan y)) 1.0) (tan a))))
double code(double x, double y, double z, double a) {
return x + ((fma(sin(z), (1.0 / cos(z)), tan(y)) / 1.0) - tan(a));
}
function code(x, y, z, a) return Float64(x + Float64(Float64(fma(sin(z), Float64(1.0 / cos(z)), tan(y)) / 1.0) - tan(a))) end
code[x_, y_, z_, a_] := N[(x + N[(N[(N[(N[Sin[z], $MachinePrecision] * N[(1.0 / N[Cos[z], $MachinePrecision]), $MachinePrecision] + N[Tan[y], $MachinePrecision]), $MachinePrecision] / 1.0), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\frac{\mathsf{fma}\left(\sin z, \frac{1}{\cos z}, \tan y\right)}{1} - \tan a\right)
\end{array}
Initial program 79.1%
lift-tan.f64N/A
lift-+.f64N/A
tan-sumN/A
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-tan.f64N/A
lower-tan.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-tan.f64N/A
lower-tan.f6499.7
Applied rewrites99.7%
lift-+.f64N/A
lift-tan.f64N/A
tan-quotN/A
mult-flipN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-/.f64N/A
lower-cos.f6499.7
Applied rewrites99.7%
Taylor expanded in y around 0
Applied rewrites79.4%
(FPCore (x y z a) :precision binary64 (- x (- (tan a) (tan (+ z y)))))
double code(double x, double y, double z, double a) {
return x - (tan(a) - tan((z + 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 + y)))
end function
public static double code(double x, double y, double z, double a) {
return x - (Math.tan(a) - Math.tan((z + y)));
}
def code(x, y, z, a): return x - (math.tan(a) - math.tan((z + y)))
function code(x, y, z, a) return Float64(x - Float64(tan(a) - tan(Float64(z + y)))) end
function tmp = code(x, y, z, a) tmp = x - (tan(a) - tan((z + y))); end
code[x_, y_, z_, a_] := N[(x - N[(N[Tan[a], $MachinePrecision] - N[Tan[N[(z + y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \left(\tan a - \tan \left(z + y\right)\right)
\end{array}
Initial program 79.1%
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6479.1
lift-+.f64N/A
+-commutativeN/A
lower-+.f6479.1
Applied rewrites79.1%
(FPCore (x y z a) :precision binary64 (if (<= (+ y z) -1e-12) (+ x (/ (sin (+ y z)) (cos (+ y z)))) (+ x (- (tan z) (tan a)))))
double code(double x, double y, double z, double a) {
double tmp;
if ((y + z) <= -1e-12) {
tmp = x + (sin((y + z)) / cos((y + z)));
} 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) <= (-1d-12)) then
tmp = x + (sin((y + z)) / cos((y + z)))
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) <= -1e-12) {
tmp = x + (Math.sin((y + z)) / Math.cos((y + z)));
} else {
tmp = x + (Math.tan(z) - Math.tan(a));
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if (y + z) <= -1e-12: tmp = x + (math.sin((y + z)) / math.cos((y + z))) else: tmp = x + (math.tan(z) - math.tan(a)) return tmp
function code(x, y, z, a) tmp = 0.0 if (Float64(y + z) <= -1e-12) tmp = Float64(x + Float64(sin(Float64(y + z)) / cos(Float64(y + z)))); 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) <= -1e-12) tmp = x + (sin((y + z)) / cos((y + z))); else tmp = x + (tan(z) - tan(a)); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[N[(y + z), $MachinePrecision], -1e-12], N[(x + N[(N[Sin[N[(y + z), $MachinePrecision]], $MachinePrecision] / N[Cos[N[(y + z), $MachinePrecision]], $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 -1 \cdot 10^{-12}:\\
\;\;\;\;x + \frac{\sin \left(y + z\right)}{\cos \left(y + z\right)}\\
\mathbf{else}:\\
\;\;\;\;x + \left(\tan z - \tan a\right)\\
\end{array}
\end{array}
if (+.f64 y z) < -9.9999999999999998e-13Initial program 79.1%
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.6
Applied rewrites50.6%
if -9.9999999999999998e-13 < (+.f64 y z) Initial program 79.1%
Taylor expanded in y around 0
Applied rewrites59.9%
(FPCore (x y z a)
:precision binary64
(if (<= (tan a) -0.004)
(* 1.0 x)
(if (<= (tan a) 0.02)
(+ x (- (tan (+ y z)) (* a (+ 1.0 (* 0.3333333333333333 (pow a 2.0))))))
(* 1.0 x))))
double code(double x, double y, double z, double a) {
double tmp;
if (tan(a) <= -0.004) {
tmp = 1.0 * x;
} else if (tan(a) <= 0.02) {
tmp = x + (tan((y + z)) - (a * (1.0 + (0.3333333333333333 * pow(a, 2.0)))));
} else {
tmp = 1.0 * x;
}
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.004d0)) then
tmp = 1.0d0 * x
else if (tan(a) <= 0.02d0) then
tmp = x + (tan((y + z)) - (a * (1.0d0 + (0.3333333333333333d0 * (a ** 2.0d0)))))
else
tmp = 1.0d0 * x
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.004) {
tmp = 1.0 * x;
} else if (Math.tan(a) <= 0.02) {
tmp = x + (Math.tan((y + z)) - (a * (1.0 + (0.3333333333333333 * Math.pow(a, 2.0)))));
} else {
tmp = 1.0 * x;
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if math.tan(a) <= -0.004: tmp = 1.0 * x elif math.tan(a) <= 0.02: tmp = x + (math.tan((y + z)) - (a * (1.0 + (0.3333333333333333 * math.pow(a, 2.0))))) else: tmp = 1.0 * x return tmp
function code(x, y, z, a) tmp = 0.0 if (tan(a) <= -0.004) tmp = Float64(1.0 * x); elseif (tan(a) <= 0.02) tmp = Float64(x + Float64(tan(Float64(y + z)) - Float64(a * Float64(1.0 + Float64(0.3333333333333333 * (a ^ 2.0)))))); else tmp = Float64(1.0 * x); end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if (tan(a) <= -0.004) tmp = 1.0 * x; elseif (tan(a) <= 0.02) tmp = x + (tan((y + z)) - (a * (1.0 + (0.3333333333333333 * (a ^ 2.0))))); else tmp = 1.0 * x; end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[N[Tan[a], $MachinePrecision], -0.004], N[(1.0 * x), $MachinePrecision], If[LessEqual[N[Tan[a], $MachinePrecision], 0.02], N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[(a * N[(1.0 + N[(0.3333333333333333 * N[Power[a, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\tan a \leq -0.004:\\
\;\;\;\;1 \cdot x\\
\mathbf{elif}\;\tan a \leq 0.02:\\
\;\;\;\;x + \left(\tan \left(y + z\right) - a \cdot \left(1 + 0.3333333333333333 \cdot {a}^{2}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;1 \cdot x\\
\end{array}
\end{array}
if (tan.f64 a) < -0.0040000000000000001 or 0.0200000000000000004 < (tan.f64 a) Initial program 79.1%
lift-+.f64N/A
add-flipN/A
sub-to-multN/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6478.8
lift-+.f64N/A
+-commutativeN/A
lower-+.f6478.8
Applied rewrites78.8%
Taylor expanded in x around inf
Applied rewrites31.6%
if -0.0040000000000000001 < (tan.f64 a) < 0.0200000000000000004Initial program 79.1%
Taylor expanded in a around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6441.2
Applied rewrites41.2%
(FPCore (x y z a) :precision binary64 (+ x (/ (sin (+ y z)) (cos (+ y z)))))
double code(double x, double y, double z, double a) {
return x + (sin((y + z)) / cos((y + z)));
}
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 + (sin((y + z)) / cos((y + z)))
end function
public static double code(double x, double y, double z, double a) {
return x + (Math.sin((y + z)) / Math.cos((y + z)));
}
def code(x, y, z, a): return x + (math.sin((y + z)) / math.cos((y + z)))
function code(x, y, z, a) return Float64(x + Float64(sin(Float64(y + z)) / cos(Float64(y + z)))) end
function tmp = code(x, y, z, a) tmp = x + (sin((y + z)) / cos((y + z))); end
code[x_, y_, z_, a_] := N[(x + N[(N[Sin[N[(y + z), $MachinePrecision]], $MachinePrecision] / N[Cos[N[(y + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{\sin \left(y + z\right)}{\cos \left(y + z\right)}
\end{array}
Initial program 79.1%
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.6
Applied rewrites50.6%
(FPCore (x y z a) :precision binary64 (if (<= a -4.6) (* 1.0 x) (if (<= a 1.56) (- (tan (+ y z)) (- a x)) (* 1.0 x))))
double code(double x, double y, double z, double a) {
double tmp;
if (a <= -4.6) {
tmp = 1.0 * x;
} else if (a <= 1.56) {
tmp = tan((y + z)) - (a - x);
} else {
tmp = 1.0 * x;
}
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 <= (-4.6d0)) then
tmp = 1.0d0 * x
else if (a <= 1.56d0) then
tmp = tan((y + z)) - (a - x)
else
tmp = 1.0d0 * x
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double tmp;
if (a <= -4.6) {
tmp = 1.0 * x;
} else if (a <= 1.56) {
tmp = Math.tan((y + z)) - (a - x);
} else {
tmp = 1.0 * x;
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if a <= -4.6: tmp = 1.0 * x elif a <= 1.56: tmp = math.tan((y + z)) - (a - x) else: tmp = 1.0 * x return tmp
function code(x, y, z, a) tmp = 0.0 if (a <= -4.6) tmp = Float64(1.0 * x); elseif (a <= 1.56) tmp = Float64(tan(Float64(y + z)) - Float64(a - x)); else tmp = Float64(1.0 * x); end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if (a <= -4.6) tmp = 1.0 * x; elseif (a <= 1.56) tmp = tan((y + z)) - (a - x); else tmp = 1.0 * x; end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[a, -4.6], N[(1.0 * x), $MachinePrecision], If[LessEqual[a, 1.56], N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[(a - x), $MachinePrecision]), $MachinePrecision], N[(1.0 * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -4.6:\\
\;\;\;\;1 \cdot x\\
\mathbf{elif}\;a \leq 1.56:\\
\;\;\;\;\tan \left(y + z\right) - \left(a - x\right)\\
\mathbf{else}:\\
\;\;\;\;1 \cdot x\\
\end{array}
\end{array}
if a < -4.5999999999999996 or 1.5600000000000001 < a Initial program 79.1%
lift-+.f64N/A
add-flipN/A
sub-to-multN/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6478.8
lift-+.f64N/A
+-commutativeN/A
lower-+.f6478.8
Applied rewrites78.8%
Taylor expanded in x around inf
Applied rewrites31.6%
if -4.5999999999999996 < a < 1.5600000000000001Initial program 79.1%
Taylor expanded in a around 0
Applied rewrites41.5%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
associate-+l-N/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lower--.f6441.5
Applied rewrites41.5%
(FPCore (x y z a) :precision binary64 (if (<= a -0.00185) (* 1.0 x) (if (<= a 1.56) (- x (- a (tan z))) (* 1.0 x))))
double code(double x, double y, double z, double a) {
double tmp;
if (a <= -0.00185) {
tmp = 1.0 * x;
} else if (a <= 1.56) {
tmp = x - (a - tan(z));
} else {
tmp = 1.0 * x;
}
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.00185d0)) then
tmp = 1.0d0 * x
else if (a <= 1.56d0) then
tmp = x - (a - tan(z))
else
tmp = 1.0d0 * x
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double tmp;
if (a <= -0.00185) {
tmp = 1.0 * x;
} else if (a <= 1.56) {
tmp = x - (a - Math.tan(z));
} else {
tmp = 1.0 * x;
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if a <= -0.00185: tmp = 1.0 * x elif a <= 1.56: tmp = x - (a - math.tan(z)) else: tmp = 1.0 * x return tmp
function code(x, y, z, a) tmp = 0.0 if (a <= -0.00185) tmp = Float64(1.0 * x); elseif (a <= 1.56) tmp = Float64(x - Float64(a - tan(z))); else tmp = Float64(1.0 * x); end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if (a <= -0.00185) tmp = 1.0 * x; elseif (a <= 1.56) tmp = x - (a - tan(z)); else tmp = 1.0 * x; end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[a, -0.00185], N[(1.0 * x), $MachinePrecision], If[LessEqual[a, 1.56], N[(x - N[(a - N[Tan[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.00185:\\
\;\;\;\;1 \cdot x\\
\mathbf{elif}\;a \leq 1.56:\\
\;\;\;\;x - \left(a - \tan z\right)\\
\mathbf{else}:\\
\;\;\;\;1 \cdot x\\
\end{array}
\end{array}
if a < -0.0018500000000000001 or 1.5600000000000001 < a Initial program 79.1%
lift-+.f64N/A
add-flipN/A
sub-to-multN/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6478.8
lift-+.f64N/A
+-commutativeN/A
lower-+.f6478.8
Applied rewrites78.8%
Taylor expanded in x around inf
Applied rewrites31.6%
if -0.0018500000000000001 < a < 1.5600000000000001Initial program 79.1%
Taylor expanded in a around 0
Applied rewrites41.5%
Taylor expanded in y around 0
Applied rewrites32.1%
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6432.1
Applied rewrites32.1%
(FPCore (x y z a) :precision binary64 (* 1.0 x))
double code(double x, double y, double z, double a) {
return 1.0 * 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 = 1.0d0 * x
end function
public static double code(double x, double y, double z, double a) {
return 1.0 * x;
}
def code(x, y, z, a): return 1.0 * x
function code(x, y, z, a) return Float64(1.0 * x) end
function tmp = code(x, y, z, a) tmp = 1.0 * x; end
code[x_, y_, z_, a_] := N[(1.0 * x), $MachinePrecision]
\begin{array}{l}
\\
1 \cdot x
\end{array}
Initial program 79.1%
lift-+.f64N/A
add-flipN/A
sub-to-multN/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6478.8
lift-+.f64N/A
+-commutativeN/A
lower-+.f6478.8
Applied rewrites78.8%
Taylor expanded in x around inf
Applied rewrites31.6%
herbie shell --seed 2025142
(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))))