
(FPCore (x y z a) :precision binary64 (+ x (- (tan (+ y z)) (tan a))))
double code(double x, double y, double z, double a) {
return x + (tan((y + z)) - tan(a));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
code = x + (tan((y + z)) - tan(a))
end function
public static double code(double x, double y, double z, double a) {
return x + (Math.tan((y + z)) - Math.tan(a));
}
def code(x, y, z, a): return x + (math.tan((y + z)) - math.tan(a))
function code(x, y, z, a) return Float64(x + Float64(tan(Float64(y + z)) - tan(a))) end
function tmp = code(x, y, z, a) tmp = x + (tan((y + z)) - tan(a)); end
code[x_, y_, z_, a_] := N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
x + \left(\tan \left(y + z\right) - \tan a\right)
Herbie found 17 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z a) :precision binary64 (+ x (- (tan (+ y z)) (tan a))))
double code(double x, double y, double z, double a) {
return x + (tan((y + z)) - tan(a));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
code = x + (tan((y + z)) - tan(a))
end function
public static double code(double x, double y, double z, double a) {
return x + (Math.tan((y + z)) - Math.tan(a));
}
def code(x, y, z, a): return x + (math.tan((y + z)) - math.tan(a))
function code(x, y, z, a) return Float64(x + Float64(tan(Float64(y + z)) - tan(a))) end
function tmp = code(x, y, z, a) tmp = x + (tan((y + z)) - tan(a)); end
code[x_, y_, z_, a_] := N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
x + \left(\tan \left(y + z\right) - \tan a\right)
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (fma (sin z) (- (sin y)) (* (cos z) (cos y)))))
(+
x
(- (+ (/ (* (sin z) (cos y)) t_0) (/ (* (cos z) (sin y)) t_0)) (tan a)))))double code(double x, double y, double z, double a) {
double t_0 = fma(sin(z), -sin(y), (cos(z) * cos(y)));
return x + ((((sin(z) * cos(y)) / t_0) + ((cos(z) * sin(y)) / t_0)) - tan(a));
}
function code(x, y, z, a) t_0 = fma(sin(z), Float64(-sin(y)), Float64(cos(z) * cos(y))) return Float64(x + Float64(Float64(Float64(Float64(sin(z) * cos(y)) / t_0) + Float64(Float64(cos(z) * sin(y)) / t_0)) - tan(a))) end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[(N[Sin[z], $MachinePrecision] * (-N[Sin[y], $MachinePrecision]) + N[(N[Cos[z], $MachinePrecision] * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(x + N[(N[(N[(N[(N[Sin[z], $MachinePrecision] * N[Cos[y], $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision] + N[(N[(N[Cos[z], $MachinePrecision] * N[Sin[y], $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
t_0 := \mathsf{fma}\left(\sin z, -\sin y, \cos z \cdot \cos y\right)\\
x + \left(\left(\frac{\sin z \cdot \cos y}{t\_0} + \frac{\cos z \cdot \sin y}{t\_0}\right) - \tan a\right)
\end{array}
Initial program 79.5%
lift-tan.f64N/A
tan-quotN/A
lift-+.f64N/A
+-commutativeN/A
sin-sumN/A
div-addN/A
*-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
Applied rewrites80.0%
lift-cos.f64N/A
lift-+.f64N/A
cos-sumN/A
lower--.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f6480.8%
Applied rewrites80.8%
lift-cos.f64N/A
lift-+.f64N/A
cos-sumN/A
lower--.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f6499.7%
Applied rewrites99.7%
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-neg.f6499.7%
Applied rewrites99.7%
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-neg.f6499.7%
Applied rewrites99.7%
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (- (* (cos z) (cos y)) (* (sin y) (sin z)))))
(+
x
(- (+ (/ (* (sin z) (cos y)) t_0) (/ (* (cos z) (sin y)) t_0)) (tan a)))))double code(double x, double y, double z, double a) {
double t_0 = (cos(z) * cos(y)) - (sin(y) * sin(z));
return x + ((((sin(z) * cos(y)) / t_0) + ((cos(z) * sin(y)) / 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 = (cos(z) * cos(y)) - (sin(y) * sin(z))
code = x + ((((sin(z) * cos(y)) / t_0) + ((cos(z) * sin(y)) / t_0)) - tan(a))
end function
public static double code(double x, double y, double z, double a) {
double t_0 = (Math.cos(z) * Math.cos(y)) - (Math.sin(y) * Math.sin(z));
return x + ((((Math.sin(z) * Math.cos(y)) / t_0) + ((Math.cos(z) * Math.sin(y)) / t_0)) - Math.tan(a));
}
def code(x, y, z, a): t_0 = (math.cos(z) * math.cos(y)) - (math.sin(y) * math.sin(z)) return x + ((((math.sin(z) * math.cos(y)) / t_0) + ((math.cos(z) * math.sin(y)) / t_0)) - math.tan(a))
function code(x, y, z, a) t_0 = Float64(Float64(cos(z) * cos(y)) - Float64(sin(y) * sin(z))) return Float64(x + Float64(Float64(Float64(Float64(sin(z) * cos(y)) / t_0) + Float64(Float64(cos(z) * sin(y)) / t_0)) - tan(a))) end
function tmp = code(x, y, z, a) t_0 = (cos(z) * cos(y)) - (sin(y) * sin(z)); tmp = x + ((((sin(z) * cos(y)) / t_0) + ((cos(z) * sin(y)) / t_0)) - tan(a)); end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[(N[(N[Cos[z], $MachinePrecision] * N[Cos[y], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[y], $MachinePrecision] * N[Sin[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(x + N[(N[(N[(N[(N[Sin[z], $MachinePrecision] * N[Cos[y], $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision] + N[(N[(N[Cos[z], $MachinePrecision] * N[Sin[y], $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
t_0 := \cos z \cdot \cos y - \sin y \cdot \sin z\\
x + \left(\left(\frac{\sin z \cdot \cos y}{t\_0} + \frac{\cos z \cdot \sin y}{t\_0}\right) - \tan a\right)
\end{array}
Initial program 79.5%
lift-tan.f64N/A
tan-quotN/A
lift-+.f64N/A
+-commutativeN/A
sin-sumN/A
div-addN/A
*-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
Applied rewrites80.0%
lift-cos.f64N/A
lift-+.f64N/A
cos-sumN/A
lower--.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f6480.8%
Applied rewrites80.8%
lift-cos.f64N/A
lift-+.f64N/A
cos-sumN/A
lower--.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f6499.7%
Applied rewrites99.7%
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (sin (fmax y z)))
(t_1 (+ (fmin y z) (fmax y z)))
(t_2 (cos t_1))
(t_3 (cos (fmax y z)))
(t_4 (sin (fmin y z)))
(t_5 (* t_3 t_4))
(t_6 (* t_4 t_0))
(t_7 (cos (fmin y z)))
(t_8 (/ t_5 (- (* t_3 t_7) t_6)))
(t_9 (- (* t_7 t_3) t_6))
(t_10 (* t_7 t_0)))
(if (<= a -2.05)
(+ x (- (+ (/ t_10 t_2) t_8) (tan a)))
(if (<= a 1.02e-13)
(+
x
(fma
a
(- (* -0.3333333333333333 (pow a 2.0)) 1.0)
(+ (/ t_10 t_9) (/ t_5 t_9))))
(+
x
(-
(+ (/ (+ (sin t_1) (sin (- (fmax y z) (fmin y z)))) (* 2.0 t_2)) t_8)
(tan a)))))))double code(double x, double y, double z, double a) {
double t_0 = sin(fmax(y, z));
double t_1 = fmin(y, z) + fmax(y, z);
double t_2 = cos(t_1);
double t_3 = cos(fmax(y, z));
double t_4 = sin(fmin(y, z));
double t_5 = t_3 * t_4;
double t_6 = t_4 * t_0;
double t_7 = cos(fmin(y, z));
double t_8 = t_5 / ((t_3 * t_7) - t_6);
double t_9 = (t_7 * t_3) - t_6;
double t_10 = t_7 * t_0;
double tmp;
if (a <= -2.05) {
tmp = x + (((t_10 / t_2) + t_8) - tan(a));
} else if (a <= 1.02e-13) {
tmp = x + fma(a, ((-0.3333333333333333 * pow(a, 2.0)) - 1.0), ((t_10 / t_9) + (t_5 / t_9)));
} else {
tmp = x + ((((sin(t_1) + sin((fmax(y, z) - fmin(y, z)))) / (2.0 * t_2)) + t_8) - tan(a));
}
return tmp;
}
function code(x, y, z, a) t_0 = sin(fmax(y, z)) t_1 = Float64(fmin(y, z) + fmax(y, z)) t_2 = cos(t_1) t_3 = cos(fmax(y, z)) t_4 = sin(fmin(y, z)) t_5 = Float64(t_3 * t_4) t_6 = Float64(t_4 * t_0) t_7 = cos(fmin(y, z)) t_8 = Float64(t_5 / Float64(Float64(t_3 * t_7) - t_6)) t_9 = Float64(Float64(t_7 * t_3) - t_6) t_10 = Float64(t_7 * t_0) tmp = 0.0 if (a <= -2.05) tmp = Float64(x + Float64(Float64(Float64(t_10 / t_2) + t_8) - tan(a))); elseif (a <= 1.02e-13) tmp = Float64(x + fma(a, Float64(Float64(-0.3333333333333333 * (a ^ 2.0)) - 1.0), Float64(Float64(t_10 / t_9) + Float64(t_5 / t_9)))); else tmp = Float64(x + Float64(Float64(Float64(Float64(sin(t_1) + sin(Float64(fmax(y, z) - fmin(y, z)))) / Float64(2.0 * t_2)) + t_8) - tan(a))); end return tmp end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[Sin[N[Max[y, z], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Min[y, z], $MachinePrecision] + N[Max[y, z], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Cos[t$95$1], $MachinePrecision]}, Block[{t$95$3 = N[Cos[N[Max[y, z], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[Sin[N[Min[y, z], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$5 = N[(t$95$3 * t$95$4), $MachinePrecision]}, Block[{t$95$6 = N[(t$95$4 * t$95$0), $MachinePrecision]}, Block[{t$95$7 = N[Cos[N[Min[y, z], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$8 = N[(t$95$5 / N[(N[(t$95$3 * t$95$7), $MachinePrecision] - t$95$6), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$9 = N[(N[(t$95$7 * t$95$3), $MachinePrecision] - t$95$6), $MachinePrecision]}, Block[{t$95$10 = N[(t$95$7 * t$95$0), $MachinePrecision]}, If[LessEqual[a, -2.05], N[(x + N[(N[(N[(t$95$10 / t$95$2), $MachinePrecision] + t$95$8), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 1.02e-13], N[(x + N[(a * N[(N[(-0.3333333333333333 * N[Power[a, 2.0], $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision] + N[(N[(t$95$10 / t$95$9), $MachinePrecision] + N[(t$95$5 / t$95$9), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(N[(N[(N[Sin[t$95$1], $MachinePrecision] + N[Sin[N[(N[Max[y, z], $MachinePrecision] - N[Min[y, z], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * t$95$2), $MachinePrecision]), $MachinePrecision] + t$95$8), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]]]]]]
\begin{array}{l}
t_0 := \sin \left(\mathsf{max}\left(y, z\right)\right)\\
t_1 := \mathsf{min}\left(y, z\right) + \mathsf{max}\left(y, z\right)\\
t_2 := \cos t\_1\\
t_3 := \cos \left(\mathsf{max}\left(y, z\right)\right)\\
t_4 := \sin \left(\mathsf{min}\left(y, z\right)\right)\\
t_5 := t\_3 \cdot t\_4\\
t_6 := t\_4 \cdot t\_0\\
t_7 := \cos \left(\mathsf{min}\left(y, z\right)\right)\\
t_8 := \frac{t\_5}{t\_3 \cdot t\_7 - t\_6}\\
t_9 := t\_7 \cdot t\_3 - t\_6\\
t_10 := t\_7 \cdot t\_0\\
\mathbf{if}\;a \leq -2.05:\\
\;\;\;\;x + \left(\left(\frac{t\_10}{t\_2} + t\_8\right) - \tan a\right)\\
\mathbf{elif}\;a \leq 1.02 \cdot 10^{-13}:\\
\;\;\;\;x + \mathsf{fma}\left(a, -0.3333333333333333 \cdot {a}^{2} - 1, \frac{t\_10}{t\_9} + \frac{t\_5}{t\_9}\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(\left(\frac{\sin t\_1 + \sin \left(\mathsf{max}\left(y, z\right) - \mathsf{min}\left(y, z\right)\right)}{2 \cdot t\_2} + t\_8\right) - \tan a\right)\\
\end{array}
if a < -2.0499999999999998Initial program 79.5%
lift-tan.f64N/A
tan-quotN/A
lift-+.f64N/A
+-commutativeN/A
sin-sumN/A
div-addN/A
*-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
Applied rewrites80.0%
lift-cos.f64N/A
lift-+.f64N/A
cos-sumN/A
lower--.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f6480.8%
Applied rewrites80.8%
lift-cos.f64N/A
lift-+.f64N/A
cos-sumN/A
lower--.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f6499.7%
Applied rewrites99.7%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.7%
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-sin.f64N/A
lift-sin.f64N/A
cos-sumN/A
lift-+.f64N/A
lift-cos.f6480.7%
lift-+.f64N/A
+-commutativeN/A
lift-+.f6480.7%
Applied rewrites80.7%
if -2.0499999999999998 < a < 1.0199999999999999e-13Initial program 79.5%
lift-tan.f64N/A
tan-quotN/A
lift-+.f64N/A
+-commutativeN/A
sin-sumN/A
div-addN/A
*-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
Applied rewrites80.0%
lift-cos.f64N/A
lift-+.f64N/A
cos-sumN/A
lower--.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f6480.8%
Applied rewrites80.8%
lift-cos.f64N/A
lift-+.f64N/A
cos-sumN/A
lower--.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f6499.7%
Applied rewrites99.7%
Taylor expanded in a around 0
lower-fma.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
Applied rewrites49.9%
if 1.0199999999999999e-13 < a Initial program 79.5%
lift-tan.f64N/A
tan-quotN/A
lift-+.f64N/A
+-commutativeN/A
sin-sumN/A
div-addN/A
*-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
Applied rewrites80.0%
lift-cos.f64N/A
lift-+.f64N/A
cos-sumN/A
lower--.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f6480.8%
Applied rewrites80.8%
lift-cos.f64N/A
lift-+.f64N/A
cos-sumN/A
lower--.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f6499.7%
Applied rewrites99.7%
lift-/.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
sin-cos-multN/A
lift--.f64N/A
lift-sin.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-sin.f64N/A
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-sin.f64N/A
lift-sin.f64N/A
cos-sumN/A
lift-+.f64N/A
Applied rewrites80.5%
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (sin (fmax y z)))
(t_1 (+ (fmin y z) (fmax y z)))
(t_2 (cos t_1))
(t_3 (cos (fmax y z)))
(t_4 (sin (fmin y z)))
(t_5 (* t_3 t_4))
(t_6 (* t_4 t_0))
(t_7 (cos (fmin y z)))
(t_8 (* t_7 t_0))
(t_9 (/ t_5 (- (* t_3 t_7) t_6)))
(t_10 (- (* t_7 t_3) t_6)))
(if (<= a -2.05)
(+ x (- (+ (/ t_8 t_2) t_9) (tan a)))
(if (<= a 1.02e-13)
(+ x (fma -1.0 a (+ (/ t_8 t_10) (/ t_5 t_10))))
(+
x
(-
(+ (/ (+ (sin t_1) (sin (- (fmax y z) (fmin y z)))) (* 2.0 t_2)) t_9)
(tan a)))))))double code(double x, double y, double z, double a) {
double t_0 = sin(fmax(y, z));
double t_1 = fmin(y, z) + fmax(y, z);
double t_2 = cos(t_1);
double t_3 = cos(fmax(y, z));
double t_4 = sin(fmin(y, z));
double t_5 = t_3 * t_4;
double t_6 = t_4 * t_0;
double t_7 = cos(fmin(y, z));
double t_8 = t_7 * t_0;
double t_9 = t_5 / ((t_3 * t_7) - t_6);
double t_10 = (t_7 * t_3) - t_6;
double tmp;
if (a <= -2.05) {
tmp = x + (((t_8 / t_2) + t_9) - tan(a));
} else if (a <= 1.02e-13) {
tmp = x + fma(-1.0, a, ((t_8 / t_10) + (t_5 / t_10)));
} else {
tmp = x + ((((sin(t_1) + sin((fmax(y, z) - fmin(y, z)))) / (2.0 * t_2)) + t_9) - tan(a));
}
return tmp;
}
function code(x, y, z, a) t_0 = sin(fmax(y, z)) t_1 = Float64(fmin(y, z) + fmax(y, z)) t_2 = cos(t_1) t_3 = cos(fmax(y, z)) t_4 = sin(fmin(y, z)) t_5 = Float64(t_3 * t_4) t_6 = Float64(t_4 * t_0) t_7 = cos(fmin(y, z)) t_8 = Float64(t_7 * t_0) t_9 = Float64(t_5 / Float64(Float64(t_3 * t_7) - t_6)) t_10 = Float64(Float64(t_7 * t_3) - t_6) tmp = 0.0 if (a <= -2.05) tmp = Float64(x + Float64(Float64(Float64(t_8 / t_2) + t_9) - tan(a))); elseif (a <= 1.02e-13) tmp = Float64(x + fma(-1.0, a, Float64(Float64(t_8 / t_10) + Float64(t_5 / t_10)))); else tmp = Float64(x + Float64(Float64(Float64(Float64(sin(t_1) + sin(Float64(fmax(y, z) - fmin(y, z)))) / Float64(2.0 * t_2)) + t_9) - tan(a))); end return tmp end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[Sin[N[Max[y, z], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Min[y, z], $MachinePrecision] + N[Max[y, z], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Cos[t$95$1], $MachinePrecision]}, Block[{t$95$3 = N[Cos[N[Max[y, z], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[Sin[N[Min[y, z], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$5 = N[(t$95$3 * t$95$4), $MachinePrecision]}, Block[{t$95$6 = N[(t$95$4 * t$95$0), $MachinePrecision]}, Block[{t$95$7 = N[Cos[N[Min[y, z], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$8 = N[(t$95$7 * t$95$0), $MachinePrecision]}, Block[{t$95$9 = N[(t$95$5 / N[(N[(t$95$3 * t$95$7), $MachinePrecision] - t$95$6), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$10 = N[(N[(t$95$7 * t$95$3), $MachinePrecision] - t$95$6), $MachinePrecision]}, If[LessEqual[a, -2.05], N[(x + N[(N[(N[(t$95$8 / t$95$2), $MachinePrecision] + t$95$9), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 1.02e-13], N[(x + N[(-1.0 * a + N[(N[(t$95$8 / t$95$10), $MachinePrecision] + N[(t$95$5 / t$95$10), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(N[(N[(N[Sin[t$95$1], $MachinePrecision] + N[Sin[N[(N[Max[y, z], $MachinePrecision] - N[Min[y, z], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * t$95$2), $MachinePrecision]), $MachinePrecision] + t$95$9), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]]]]]]
\begin{array}{l}
t_0 := \sin \left(\mathsf{max}\left(y, z\right)\right)\\
t_1 := \mathsf{min}\left(y, z\right) + \mathsf{max}\left(y, z\right)\\
t_2 := \cos t\_1\\
t_3 := \cos \left(\mathsf{max}\left(y, z\right)\right)\\
t_4 := \sin \left(\mathsf{min}\left(y, z\right)\right)\\
t_5 := t\_3 \cdot t\_4\\
t_6 := t\_4 \cdot t\_0\\
t_7 := \cos \left(\mathsf{min}\left(y, z\right)\right)\\
t_8 := t\_7 \cdot t\_0\\
t_9 := \frac{t\_5}{t\_3 \cdot t\_7 - t\_6}\\
t_10 := t\_7 \cdot t\_3 - t\_6\\
\mathbf{if}\;a \leq -2.05:\\
\;\;\;\;x + \left(\left(\frac{t\_8}{t\_2} + t\_9\right) - \tan a\right)\\
\mathbf{elif}\;a \leq 1.02 \cdot 10^{-13}:\\
\;\;\;\;x + \mathsf{fma}\left(-1, a, \frac{t\_8}{t\_10} + \frac{t\_5}{t\_10}\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(\left(\frac{\sin t\_1 + \sin \left(\mathsf{max}\left(y, z\right) - \mathsf{min}\left(y, z\right)\right)}{2 \cdot t\_2} + t\_9\right) - \tan a\right)\\
\end{array}
if a < -2.0499999999999998Initial program 79.5%
lift-tan.f64N/A
tan-quotN/A
lift-+.f64N/A
+-commutativeN/A
sin-sumN/A
div-addN/A
*-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
Applied rewrites80.0%
lift-cos.f64N/A
lift-+.f64N/A
cos-sumN/A
lower--.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f6480.8%
Applied rewrites80.8%
lift-cos.f64N/A
lift-+.f64N/A
cos-sumN/A
lower--.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f6499.7%
Applied rewrites99.7%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.7%
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-sin.f64N/A
lift-sin.f64N/A
cos-sumN/A
lift-+.f64N/A
lift-cos.f6480.7%
lift-+.f64N/A
+-commutativeN/A
lift-+.f6480.7%
Applied rewrites80.7%
if -2.0499999999999998 < a < 1.0199999999999999e-13Initial program 79.5%
lift-tan.f64N/A
tan-quotN/A
lift-+.f64N/A
+-commutativeN/A
sin-sumN/A
div-addN/A
*-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
Applied rewrites80.0%
lift-cos.f64N/A
lift-+.f64N/A
cos-sumN/A
lower--.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f6480.8%
Applied rewrites80.8%
lift-cos.f64N/A
lift-+.f64N/A
cos-sumN/A
lower--.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f6499.7%
Applied rewrites99.7%
Taylor expanded in a around 0
lower-fma.f64N/A
lower-+.f64N/A
Applied rewrites50.2%
if 1.0199999999999999e-13 < a Initial program 79.5%
lift-tan.f64N/A
tan-quotN/A
lift-+.f64N/A
+-commutativeN/A
sin-sumN/A
div-addN/A
*-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
Applied rewrites80.0%
lift-cos.f64N/A
lift-+.f64N/A
cos-sumN/A
lower--.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f6480.8%
Applied rewrites80.8%
lift-cos.f64N/A
lift-+.f64N/A
cos-sumN/A
lower--.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f6499.7%
Applied rewrites99.7%
lift-/.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
sin-cos-multN/A
lift--.f64N/A
lift-sin.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-sin.f64N/A
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-sin.f64N/A
lift-sin.f64N/A
cos-sumN/A
lift-+.f64N/A
Applied rewrites80.5%
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (sin (fmax y z)))
(t_1 (+ (fmin y z) (fmax y z)))
(t_2 (cos (fmax y z)))
(t_3 (sin (fmin y z)))
(t_4 (* t_2 t_3))
(t_5 (* t_3 t_0))
(t_6 (cos (fmin y z)))
(t_7 (/ t_4 (- (* t_2 t_6) t_5)))
(t_8 (* t_6 t_0))
(t_9 (cos t_1))
(t_10 (- (* t_6 t_2) t_5)))
(if (<= a -3.7)
(+ x (- (+ (/ t_8 t_9) t_7) (tan a)))
(if (<= a 1.02e-13)
(+ x (+ (/ t_8 t_10) (/ t_4 t_10)))
(+
x
(-
(+ (/ (+ (sin t_1) (sin (- (fmax y z) (fmin y z)))) (* 2.0 t_9)) t_7)
(tan a)))))))double code(double x, double y, double z, double a) {
double t_0 = sin(fmax(y, z));
double t_1 = fmin(y, z) + fmax(y, z);
double t_2 = cos(fmax(y, z));
double t_3 = sin(fmin(y, z));
double t_4 = t_2 * t_3;
double t_5 = t_3 * t_0;
double t_6 = cos(fmin(y, z));
double t_7 = t_4 / ((t_2 * t_6) - t_5);
double t_8 = t_6 * t_0;
double t_9 = cos(t_1);
double t_10 = (t_6 * t_2) - t_5;
double tmp;
if (a <= -3.7) {
tmp = x + (((t_8 / t_9) + t_7) - tan(a));
} else if (a <= 1.02e-13) {
tmp = x + ((t_8 / t_10) + (t_4 / t_10));
} else {
tmp = x + ((((sin(t_1) + sin((fmax(y, z) - fmin(y, z)))) / (2.0 * t_9)) + t_7) - tan(a));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
real(8) :: t_0
real(8) :: t_1
real(8) :: t_10
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: t_5
real(8) :: t_6
real(8) :: t_7
real(8) :: t_8
real(8) :: t_9
real(8) :: tmp
t_0 = sin(fmax(y, z))
t_1 = fmin(y, z) + fmax(y, z)
t_2 = cos(fmax(y, z))
t_3 = sin(fmin(y, z))
t_4 = t_2 * t_3
t_5 = t_3 * t_0
t_6 = cos(fmin(y, z))
t_7 = t_4 / ((t_2 * t_6) - t_5)
t_8 = t_6 * t_0
t_9 = cos(t_1)
t_10 = (t_6 * t_2) - t_5
if (a <= (-3.7d0)) then
tmp = x + (((t_8 / t_9) + t_7) - tan(a))
else if (a <= 1.02d-13) then
tmp = x + ((t_8 / t_10) + (t_4 / t_10))
else
tmp = x + ((((sin(t_1) + sin((fmax(y, z) - fmin(y, z)))) / (2.0d0 * t_9)) + t_7) - tan(a))
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double t_0 = Math.sin(fmax(y, z));
double t_1 = fmin(y, z) + fmax(y, z);
double t_2 = Math.cos(fmax(y, z));
double t_3 = Math.sin(fmin(y, z));
double t_4 = t_2 * t_3;
double t_5 = t_3 * t_0;
double t_6 = Math.cos(fmin(y, z));
double t_7 = t_4 / ((t_2 * t_6) - t_5);
double t_8 = t_6 * t_0;
double t_9 = Math.cos(t_1);
double t_10 = (t_6 * t_2) - t_5;
double tmp;
if (a <= -3.7) {
tmp = x + (((t_8 / t_9) + t_7) - Math.tan(a));
} else if (a <= 1.02e-13) {
tmp = x + ((t_8 / t_10) + (t_4 / t_10));
} else {
tmp = x + ((((Math.sin(t_1) + Math.sin((fmax(y, z) - fmin(y, z)))) / (2.0 * t_9)) + t_7) - Math.tan(a));
}
return tmp;
}
def code(x, y, z, a): t_0 = math.sin(fmax(y, z)) t_1 = fmin(y, z) + fmax(y, z) t_2 = math.cos(fmax(y, z)) t_3 = math.sin(fmin(y, z)) t_4 = t_2 * t_3 t_5 = t_3 * t_0 t_6 = math.cos(fmin(y, z)) t_7 = t_4 / ((t_2 * t_6) - t_5) t_8 = t_6 * t_0 t_9 = math.cos(t_1) t_10 = (t_6 * t_2) - t_5 tmp = 0 if a <= -3.7: tmp = x + (((t_8 / t_9) + t_7) - math.tan(a)) elif a <= 1.02e-13: tmp = x + ((t_8 / t_10) + (t_4 / t_10)) else: tmp = x + ((((math.sin(t_1) + math.sin((fmax(y, z) - fmin(y, z)))) / (2.0 * t_9)) + t_7) - math.tan(a)) return tmp
function code(x, y, z, a) t_0 = sin(fmax(y, z)) t_1 = Float64(fmin(y, z) + fmax(y, z)) t_2 = cos(fmax(y, z)) t_3 = sin(fmin(y, z)) t_4 = Float64(t_2 * t_3) t_5 = Float64(t_3 * t_0) t_6 = cos(fmin(y, z)) t_7 = Float64(t_4 / Float64(Float64(t_2 * t_6) - t_5)) t_8 = Float64(t_6 * t_0) t_9 = cos(t_1) t_10 = Float64(Float64(t_6 * t_2) - t_5) tmp = 0.0 if (a <= -3.7) tmp = Float64(x + Float64(Float64(Float64(t_8 / t_9) + t_7) - tan(a))); elseif (a <= 1.02e-13) tmp = Float64(x + Float64(Float64(t_8 / t_10) + Float64(t_4 / t_10))); else tmp = Float64(x + Float64(Float64(Float64(Float64(sin(t_1) + sin(Float64(fmax(y, z) - fmin(y, z)))) / Float64(2.0 * t_9)) + t_7) - tan(a))); end return tmp end
function tmp_2 = code(x, y, z, a) t_0 = sin(max(y, z)); t_1 = min(y, z) + max(y, z); t_2 = cos(max(y, z)); t_3 = sin(min(y, z)); t_4 = t_2 * t_3; t_5 = t_3 * t_0; t_6 = cos(min(y, z)); t_7 = t_4 / ((t_2 * t_6) - t_5); t_8 = t_6 * t_0; t_9 = cos(t_1); t_10 = (t_6 * t_2) - t_5; tmp = 0.0; if (a <= -3.7) tmp = x + (((t_8 / t_9) + t_7) - tan(a)); elseif (a <= 1.02e-13) tmp = x + ((t_8 / t_10) + (t_4 / t_10)); else tmp = x + ((((sin(t_1) + sin((max(y, z) - min(y, z)))) / (2.0 * t_9)) + t_7) - tan(a)); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[Sin[N[Max[y, z], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Min[y, z], $MachinePrecision] + N[Max[y, z], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Cos[N[Max[y, z], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Sin[N[Min[y, z], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[(t$95$2 * t$95$3), $MachinePrecision]}, Block[{t$95$5 = N[(t$95$3 * t$95$0), $MachinePrecision]}, Block[{t$95$6 = N[Cos[N[Min[y, z], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$7 = N[(t$95$4 / N[(N[(t$95$2 * t$95$6), $MachinePrecision] - t$95$5), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$8 = N[(t$95$6 * t$95$0), $MachinePrecision]}, Block[{t$95$9 = N[Cos[t$95$1], $MachinePrecision]}, Block[{t$95$10 = N[(N[(t$95$6 * t$95$2), $MachinePrecision] - t$95$5), $MachinePrecision]}, If[LessEqual[a, -3.7], N[(x + N[(N[(N[(t$95$8 / t$95$9), $MachinePrecision] + t$95$7), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 1.02e-13], N[(x + N[(N[(t$95$8 / t$95$10), $MachinePrecision] + N[(t$95$4 / t$95$10), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(N[(N[(N[Sin[t$95$1], $MachinePrecision] + N[Sin[N[(N[Max[y, z], $MachinePrecision] - N[Min[y, z], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * t$95$9), $MachinePrecision]), $MachinePrecision] + t$95$7), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]]]]]]
\begin{array}{l}
t_0 := \sin \left(\mathsf{max}\left(y, z\right)\right)\\
t_1 := \mathsf{min}\left(y, z\right) + \mathsf{max}\left(y, z\right)\\
t_2 := \cos \left(\mathsf{max}\left(y, z\right)\right)\\
t_3 := \sin \left(\mathsf{min}\left(y, z\right)\right)\\
t_4 := t\_2 \cdot t\_3\\
t_5 := t\_3 \cdot t\_0\\
t_6 := \cos \left(\mathsf{min}\left(y, z\right)\right)\\
t_7 := \frac{t\_4}{t\_2 \cdot t\_6 - t\_5}\\
t_8 := t\_6 \cdot t\_0\\
t_9 := \cos t\_1\\
t_10 := t\_6 \cdot t\_2 - t\_5\\
\mathbf{if}\;a \leq -3.7:\\
\;\;\;\;x + \left(\left(\frac{t\_8}{t\_9} + t\_7\right) - \tan a\right)\\
\mathbf{elif}\;a \leq 1.02 \cdot 10^{-13}:\\
\;\;\;\;x + \left(\frac{t\_8}{t\_10} + \frac{t\_4}{t\_10}\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(\left(\frac{\sin t\_1 + \sin \left(\mathsf{max}\left(y, z\right) - \mathsf{min}\left(y, z\right)\right)}{2 \cdot t\_9} + t\_7\right) - \tan a\right)\\
\end{array}
if a < -3.7000000000000002Initial program 79.5%
lift-tan.f64N/A
tan-quotN/A
lift-+.f64N/A
+-commutativeN/A
sin-sumN/A
div-addN/A
*-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
Applied rewrites80.0%
lift-cos.f64N/A
lift-+.f64N/A
cos-sumN/A
lower--.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f6480.8%
Applied rewrites80.8%
lift-cos.f64N/A
lift-+.f64N/A
cos-sumN/A
lower--.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f6499.7%
Applied rewrites99.7%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.7%
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-sin.f64N/A
lift-sin.f64N/A
cos-sumN/A
lift-+.f64N/A
lift-cos.f6480.7%
lift-+.f64N/A
+-commutativeN/A
lift-+.f6480.7%
Applied rewrites80.7%
if -3.7000000000000002 < a < 1.0199999999999999e-13Initial program 79.5%
lift-tan.f64N/A
tan-quotN/A
lift-+.f64N/A
+-commutativeN/A
sin-sumN/A
div-addN/A
*-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
Applied rewrites80.0%
lift-cos.f64N/A
lift-+.f64N/A
cos-sumN/A
lower--.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f6480.8%
Applied rewrites80.8%
lift-cos.f64N/A
lift-+.f64N/A
cos-sumN/A
lower--.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f6499.7%
Applied rewrites99.7%
Taylor expanded in a around 0
lower-+.f64N/A
lower-+.f64N/A
Applied rewrites60.1%
if 1.0199999999999999e-13 < a Initial program 79.5%
lift-tan.f64N/A
tan-quotN/A
lift-+.f64N/A
+-commutativeN/A
sin-sumN/A
div-addN/A
*-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
Applied rewrites80.0%
lift-cos.f64N/A
lift-+.f64N/A
cos-sumN/A
lower--.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f6480.8%
Applied rewrites80.8%
lift-cos.f64N/A
lift-+.f64N/A
cos-sumN/A
lower--.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f6499.7%
Applied rewrites99.7%
lift-/.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
sin-cos-multN/A
lift--.f64N/A
lift-sin.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-sin.f64N/A
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-sin.f64N/A
lift-sin.f64N/A
cos-sumN/A
lift-+.f64N/A
Applied rewrites80.5%
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (cos (fmax y z)))
(t_1 (sin (fmin y z)))
(t_2 (cos (fmin y z)))
(t_3 (sin (fmax y z))))
(+
x
(-
(+
(/ (* t_2 t_3) (cos (+ (fmin y z) (fmax y z))))
(/ (* t_0 t_1) (- (* t_0 t_2) (* t_1 t_3))))
(tan a)))))double code(double x, double y, double z, double a) {
double t_0 = cos(fmax(y, z));
double t_1 = sin(fmin(y, z));
double t_2 = cos(fmin(y, z));
double t_3 = sin(fmax(y, z));
return x + ((((t_2 * t_3) / cos((fmin(y, z) + fmax(y, z)))) + ((t_0 * t_1) / ((t_0 * t_2) - (t_1 * t_3)))) - tan(a));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
t_0 = cos(fmax(y, z))
t_1 = sin(fmin(y, z))
t_2 = cos(fmin(y, z))
t_3 = sin(fmax(y, z))
code = x + ((((t_2 * t_3) / cos((fmin(y, z) + fmax(y, z)))) + ((t_0 * t_1) / ((t_0 * t_2) - (t_1 * t_3)))) - tan(a))
end function
public static double code(double x, double y, double z, double a) {
double t_0 = Math.cos(fmax(y, z));
double t_1 = Math.sin(fmin(y, z));
double t_2 = Math.cos(fmin(y, z));
double t_3 = Math.sin(fmax(y, z));
return x + ((((t_2 * t_3) / Math.cos((fmin(y, z) + fmax(y, z)))) + ((t_0 * t_1) / ((t_0 * t_2) - (t_1 * t_3)))) - Math.tan(a));
}
def code(x, y, z, a): t_0 = math.cos(fmax(y, z)) t_1 = math.sin(fmin(y, z)) t_2 = math.cos(fmin(y, z)) t_3 = math.sin(fmax(y, z)) return x + ((((t_2 * t_3) / math.cos((fmin(y, z) + fmax(y, z)))) + ((t_0 * t_1) / ((t_0 * t_2) - (t_1 * t_3)))) - math.tan(a))
function code(x, y, z, a) t_0 = cos(fmax(y, z)) t_1 = sin(fmin(y, z)) t_2 = cos(fmin(y, z)) t_3 = sin(fmax(y, z)) return Float64(x + Float64(Float64(Float64(Float64(t_2 * t_3) / cos(Float64(fmin(y, z) + fmax(y, z)))) + Float64(Float64(t_0 * t_1) / Float64(Float64(t_0 * t_2) - Float64(t_1 * t_3)))) - tan(a))) end
function tmp = code(x, y, z, a) t_0 = cos(max(y, z)); t_1 = sin(min(y, z)); t_2 = cos(min(y, z)); t_3 = sin(max(y, z)); tmp = x + ((((t_2 * t_3) / cos((min(y, z) + max(y, z)))) + ((t_0 * t_1) / ((t_0 * t_2) - (t_1 * t_3)))) - tan(a)); end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[Cos[N[Max[y, z], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[Min[y, z], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Cos[N[Min[y, z], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Sin[N[Max[y, z], $MachinePrecision]], $MachinePrecision]}, N[(x + N[(N[(N[(N[(t$95$2 * t$95$3), $MachinePrecision] / N[Cos[N[(N[Min[y, z], $MachinePrecision] + N[Max[y, z], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(N[(t$95$0 * t$95$1), $MachinePrecision] / N[(N[(t$95$0 * t$95$2), $MachinePrecision] - N[(t$95$1 * t$95$3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
t_0 := \cos \left(\mathsf{max}\left(y, z\right)\right)\\
t_1 := \sin \left(\mathsf{min}\left(y, z\right)\right)\\
t_2 := \cos \left(\mathsf{min}\left(y, z\right)\right)\\
t_3 := \sin \left(\mathsf{max}\left(y, z\right)\right)\\
x + \left(\left(\frac{t\_2 \cdot t\_3}{\cos \left(\mathsf{min}\left(y, z\right) + \mathsf{max}\left(y, z\right)\right)} + \frac{t\_0 \cdot t\_1}{t\_0 \cdot t\_2 - t\_1 \cdot t\_3}\right) - \tan a\right)
\end{array}
Initial program 79.5%
lift-tan.f64N/A
tan-quotN/A
lift-+.f64N/A
+-commutativeN/A
sin-sumN/A
div-addN/A
*-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
Applied rewrites80.0%
lift-cos.f64N/A
lift-+.f64N/A
cos-sumN/A
lower--.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f6480.8%
Applied rewrites80.8%
lift-cos.f64N/A
lift-+.f64N/A
cos-sumN/A
lower--.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f6499.7%
Applied rewrites99.7%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.7%
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-sin.f64N/A
lift-sin.f64N/A
cos-sumN/A
lift-+.f64N/A
lift-cos.f6480.7%
lift-+.f64N/A
+-commutativeN/A
lift-+.f6480.7%
Applied rewrites80.7%
(FPCore (x y z a) :precision binary64 (fma (/ 1.0 (- (* (cos z) (cos y)) (* (sin y) (sin z)))) (sin (+ z y)) (- x (tan a))))
double code(double x, double y, double z, double a) {
return fma((1.0 / ((cos(z) * cos(y)) - (sin(y) * sin(z)))), sin((z + y)), (x - tan(a)));
}
function code(x, y, z, a) return fma(Float64(1.0 / Float64(Float64(cos(z) * cos(y)) - Float64(sin(y) * sin(z)))), sin(Float64(z + y)), Float64(x - tan(a))) end
code[x_, y_, z_, a_] := N[(N[(1.0 / N[(N[(N[Cos[z], $MachinePrecision] * N[Cos[y], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[y], $MachinePrecision] * N[Sin[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sin[N[(z + y), $MachinePrecision]], $MachinePrecision] + N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\mathsf{fma}\left(\frac{1}{\cos z \cdot \cos y - \sin y \cdot \sin z}, \sin \left(z + y\right), x - \tan a\right)
Initial program 79.5%
lift-+.f64N/A
lift--.f64N/A
associate-+r-N/A
+-commutativeN/A
associate--l+N/A
lift-tan.f64N/A
tan-quotN/A
mult-flipN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-sin.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f6479.4%
Applied rewrites79.4%
lift-cos.f64N/A
lift-+.f64N/A
cos-sumN/A
lower--.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f6480.0%
Applied rewrites80.0%
(FPCore (x y z a) :precision binary64 (fma (/ 1.0 (cos (+ z y))) (fma (sin y) (cos z) (* (cos y) (sin z))) (- x (tan a))))
double code(double x, double y, double z, double a) {
return fma((1.0 / cos((z + y))), fma(sin(y), cos(z), (cos(y) * sin(z))), (x - tan(a)));
}
function code(x, y, z, a) return fma(Float64(1.0 / cos(Float64(z + y))), fma(sin(y), cos(z), Float64(cos(y) * sin(z))), Float64(x - tan(a))) end
code[x_, y_, z_, a_] := N[(N[(1.0 / N[Cos[N[(z + y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[Sin[y], $MachinePrecision] * N[Cos[z], $MachinePrecision] + N[(N[Cos[y], $MachinePrecision] * N[Sin[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\mathsf{fma}\left(\frac{1}{\cos \left(z + y\right)}, \mathsf{fma}\left(\sin y, \cos z, \cos y \cdot \sin z\right), x - \tan a\right)
Initial program 79.5%
lift-+.f64N/A
lift--.f64N/A
associate-+r-N/A
+-commutativeN/A
associate--l+N/A
lift-tan.f64N/A
tan-quotN/A
mult-flipN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-sin.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f6479.4%
Applied rewrites79.4%
lift-sin.f64N/A
lift-+.f64N/A
+-commutativeN/A
sin-sumN/A
lift-sin.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower-fma.f6479.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6479.9%
Applied rewrites79.9%
(FPCore (x y z a) :precision binary64 (fma (/ 1.0 (cos (+ z y))) (fma (* 2.0 (sin z)) 0.5 (* (sin y) (cos z))) (- x (tan a))))
double code(double x, double y, double z, double a) {
return fma((1.0 / cos((z + y))), fma((2.0 * sin(z)), 0.5, (sin(y) * cos(z))), (x - tan(a)));
}
function code(x, y, z, a) return fma(Float64(1.0 / cos(Float64(z + y))), fma(Float64(2.0 * sin(z)), 0.5, Float64(sin(y) * cos(z))), Float64(x - tan(a))) end
code[x_, y_, z_, a_] := N[(N[(1.0 / N[Cos[N[(z + y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[(2.0 * N[Sin[z], $MachinePrecision]), $MachinePrecision] * 0.5 + N[(N[Sin[y], $MachinePrecision] * N[Cos[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\mathsf{fma}\left(\frac{1}{\cos \left(z + y\right)}, \mathsf{fma}\left(2 \cdot \sin z, 0.5, \sin y \cdot \cos z\right), x - \tan a\right)
Initial program 79.5%
lift-+.f64N/A
lift--.f64N/A
associate-+r-N/A
+-commutativeN/A
associate--l+N/A
lift-tan.f64N/A
tan-quotN/A
mult-flipN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-sin.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f6479.4%
Applied rewrites79.4%
lift-sin.f64N/A
lift-+.f64N/A
sin-sumN/A
sin-cos-multN/A
mult-flipN/A
metadata-evalN/A
lift-cos.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
lower-fma.f64N/A
lift-+.f64N/A
lift-sin.f64N/A
lower-+.f64N/A
lower-sin.f64N/A
lower--.f6479.6%
lift-+.f64N/A
+-commutativeN/A
lift-+.f6479.6%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6479.6%
Applied rewrites79.6%
Taylor expanded in y around 0
lower-*.f64N/A
lower-sin.f6479.5%
Applied rewrites79.5%
(FPCore (x y z a) :precision binary64 (fma (- (* (cos a) (tan (+ z y))) (sin a)) (/ 1.0 (cos a)) x))
double code(double x, double y, double z, double a) {
return fma(((cos(a) * tan((z + y))) - sin(a)), (1.0 / cos(a)), x);
}
function code(x, y, z, a) return fma(Float64(Float64(cos(a) * tan(Float64(z + y))) - sin(a)), Float64(1.0 / cos(a)), x) end
code[x_, y_, z_, a_] := N[(N[(N[(N[Cos[a], $MachinePrecision] * N[Tan[N[(z + y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[Sin[a], $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[Cos[a], $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]
\mathsf{fma}\left(\cos a \cdot \tan \left(z + y\right) - \sin a, \frac{1}{\cos a}, x\right)
Initial program 79.5%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
lift-tan.f64N/A
tan-quotN/A
sub-to-fractionN/A
mult-flipN/A
lower-fma.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-sin.f64N/A
lower-/.f64N/A
lower-cos.f6479.5%
Applied rewrites79.5%
(FPCore (x y z a) :precision binary64 (+ x (fma (sin a) (/ 1.0 (- (cos a))) (tan (+ z y)))))
double code(double x, double y, double z, double a) {
return x + fma(sin(a), (1.0 / -cos(a)), tan((z + y)));
}
function code(x, y, z, a) return Float64(x + fma(sin(a), Float64(1.0 / Float64(-cos(a))), tan(Float64(z + y)))) end
code[x_, y_, z_, a_] := N[(x + N[(N[Sin[a], $MachinePrecision] * N[(1.0 / (-N[Cos[a], $MachinePrecision])), $MachinePrecision] + N[Tan[N[(z + y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
x + \mathsf{fma}\left(\sin a, \frac{1}{-\cos a}, \tan \left(z + y\right)\right)
Initial program 79.5%
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
lift-tan.f64N/A
tan-quotN/A
distribute-neg-frac2N/A
mult-flipN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-/.f64N/A
lower-neg.f64N/A
lower-cos.f6479.5%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6479.5%
Applied rewrites79.5%
(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]
x - \left(\tan a - \tan \left(z + y\right)\right)
Initial program 79.5%
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6479.5%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6479.5%
Applied rewrites79.5%
(FPCore (x y z a) :precision binary64 (if (<= (fmin y z) -44000000000.0) (+ (tan (+ (fmin y z) (fmax y z))) x) (- x (- (tan a) (tan (fmax y z))))))
double code(double x, double y, double z, double a) {
double tmp;
if (fmin(y, z) <= -44000000000.0) {
tmp = tan((fmin(y, z) + fmax(y, z))) + x;
} else {
tmp = x - (tan(a) - tan(fmax(y, 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 (fmin(y, z) <= (-44000000000.0d0)) then
tmp = tan((fmin(y, z) + fmax(y, z))) + x
else
tmp = x - (tan(a) - tan(fmax(y, z)))
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double tmp;
if (fmin(y, z) <= -44000000000.0) {
tmp = Math.tan((fmin(y, z) + fmax(y, z))) + x;
} else {
tmp = x - (Math.tan(a) - Math.tan(fmax(y, z)));
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if fmin(y, z) <= -44000000000.0: tmp = math.tan((fmin(y, z) + fmax(y, z))) + x else: tmp = x - (math.tan(a) - math.tan(fmax(y, z))) return tmp
function code(x, y, z, a) tmp = 0.0 if (fmin(y, z) <= -44000000000.0) tmp = Float64(tan(Float64(fmin(y, z) + fmax(y, z))) + x); else tmp = Float64(x - Float64(tan(a) - tan(fmax(y, z)))); end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if (min(y, z) <= -44000000000.0) tmp = tan((min(y, z) + max(y, z))) + x; else tmp = x - (tan(a) - tan(max(y, z))); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[N[Min[y, z], $MachinePrecision], -44000000000.0], N[(N[Tan[N[(N[Min[y, z], $MachinePrecision] + N[Max[y, z], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + x), $MachinePrecision], N[(x - N[(N[Tan[a], $MachinePrecision] - N[Tan[N[Max[y, z], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\mathsf{min}\left(y, z\right) \leq -44000000000:\\
\;\;\;\;\tan \left(\mathsf{min}\left(y, z\right) + \mathsf{max}\left(y, z\right)\right) + x\\
\mathbf{else}:\\
\;\;\;\;x - \left(\tan a - \tan \left(\mathsf{max}\left(y, z\right)\right)\right)\\
\end{array}
if y < -4.4e10Initial program 79.5%
lift-tan.f64N/A
tan-quotN/A
lift-+.f64N/A
+-commutativeN/A
sin-sumN/A
div-addN/A
*-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
Applied rewrites80.0%
Taylor expanded in a around 0
lower-+.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
Applied rewrites50.3%
Applied rewrites50.0%
if -4.4e10 < y Initial program 79.5%
lift-tan.f64N/A
tan-quotN/A
lift-+.f64N/A
+-commutativeN/A
sin-sumN/A
div-addN/A
*-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
Applied rewrites80.0%
Taylor expanded in y around 0
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f6460.2%
Applied rewrites60.2%
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6460.2%
Applied rewrites60.2%
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (+ (fmin y z) (fmax y z))))
(if (<= t_0 -40000000000.0)
(+ x (/ (sin (fmin y z)) (cos (fmin y z))))
(if (<= t_0 2.0)
(+
x
(-
(* (fmax y z) (+ 1.0 (* 0.3333333333333333 (pow (fmax y z) 2.0))))
(tan a)))
(+ (tan t_0) x)))))double code(double x, double y, double z, double a) {
double t_0 = fmin(y, z) + fmax(y, z);
double tmp;
if (t_0 <= -40000000000.0) {
tmp = x + (sin(fmin(y, z)) / cos(fmin(y, z)));
} else if (t_0 <= 2.0) {
tmp = x + ((fmax(y, z) * (1.0 + (0.3333333333333333 * pow(fmax(y, z), 2.0)))) - tan(a));
} else {
tmp = tan(t_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) :: t_0
real(8) :: tmp
t_0 = fmin(y, z) + fmax(y, z)
if (t_0 <= (-40000000000.0d0)) then
tmp = x + (sin(fmin(y, z)) / cos(fmin(y, z)))
else if (t_0 <= 2.0d0) then
tmp = x + ((fmax(y, z) * (1.0d0 + (0.3333333333333333d0 * (fmax(y, z) ** 2.0d0)))) - tan(a))
else
tmp = tan(t_0) + x
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double t_0 = fmin(y, z) + fmax(y, z);
double tmp;
if (t_0 <= -40000000000.0) {
tmp = x + (Math.sin(fmin(y, z)) / Math.cos(fmin(y, z)));
} else if (t_0 <= 2.0) {
tmp = x + ((fmax(y, z) * (1.0 + (0.3333333333333333 * Math.pow(fmax(y, z), 2.0)))) - Math.tan(a));
} else {
tmp = Math.tan(t_0) + x;
}
return tmp;
}
def code(x, y, z, a): t_0 = fmin(y, z) + fmax(y, z) tmp = 0 if t_0 <= -40000000000.0: tmp = x + (math.sin(fmin(y, z)) / math.cos(fmin(y, z))) elif t_0 <= 2.0: tmp = x + ((fmax(y, z) * (1.0 + (0.3333333333333333 * math.pow(fmax(y, z), 2.0)))) - math.tan(a)) else: tmp = math.tan(t_0) + x return tmp
function code(x, y, z, a) t_0 = Float64(fmin(y, z) + fmax(y, z)) tmp = 0.0 if (t_0 <= -40000000000.0) tmp = Float64(x + Float64(sin(fmin(y, z)) / cos(fmin(y, z)))); elseif (t_0 <= 2.0) tmp = Float64(x + Float64(Float64(fmax(y, z) * Float64(1.0 + Float64(0.3333333333333333 * (fmax(y, z) ^ 2.0)))) - tan(a))); else tmp = Float64(tan(t_0) + x); end return tmp end
function tmp_2 = code(x, y, z, a) t_0 = min(y, z) + max(y, z); tmp = 0.0; if (t_0 <= -40000000000.0) tmp = x + (sin(min(y, z)) / cos(min(y, z))); elseif (t_0 <= 2.0) tmp = x + ((max(y, z) * (1.0 + (0.3333333333333333 * (max(y, z) ^ 2.0)))) - tan(a)); else tmp = tan(t_0) + x; end tmp_2 = tmp; end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[(N[Min[y, z], $MachinePrecision] + N[Max[y, z], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -40000000000.0], N[(x + N[(N[Sin[N[Min[y, z], $MachinePrecision]], $MachinePrecision] / N[Cos[N[Min[y, z], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 2.0], N[(x + N[(N[(N[Max[y, z], $MachinePrecision] * N[(1.0 + N[(0.3333333333333333 * N[Power[N[Max[y, z], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Tan[t$95$0], $MachinePrecision] + x), $MachinePrecision]]]]
\begin{array}{l}
t_0 := \mathsf{min}\left(y, z\right) + \mathsf{max}\left(y, z\right)\\
\mathbf{if}\;t\_0 \leq -40000000000:\\
\;\;\;\;x + \frac{\sin \left(\mathsf{min}\left(y, z\right)\right)}{\cos \left(\mathsf{min}\left(y, z\right)\right)}\\
\mathbf{elif}\;t\_0 \leq 2:\\
\;\;\;\;x + \left(\mathsf{max}\left(y, z\right) \cdot \left(1 + 0.3333333333333333 \cdot {\left(\mathsf{max}\left(y, z\right)\right)}^{2}\right) - \tan a\right)\\
\mathbf{else}:\\
\;\;\;\;\tan t\_0 + x\\
\end{array}
if (+.f64 y z) < -4e10Initial program 79.5%
lift-tan.f64N/A
tan-quotN/A
lift-+.f64N/A
+-commutativeN/A
sin-sumN/A
div-addN/A
*-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
Applied rewrites80.0%
Taylor expanded in a around 0
lower-+.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
Applied rewrites50.3%
Taylor expanded in z around 0
lower-+.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f6440.6%
Applied rewrites40.6%
if -4e10 < (+.f64 y z) < 2Initial program 79.5%
lift-tan.f64N/A
tan-quotN/A
lift-+.f64N/A
+-commutativeN/A
sin-sumN/A
div-addN/A
*-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
Applied rewrites80.0%
Taylor expanded in y around 0
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f6460.2%
Applied rewrites60.2%
Taylor expanded in z around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6431.7%
Applied rewrites31.7%
if 2 < (+.f64 y z) Initial program 79.5%
lift-tan.f64N/A
tan-quotN/A
lift-+.f64N/A
+-commutativeN/A
sin-sumN/A
div-addN/A
*-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
Applied rewrites80.0%
Taylor expanded in a around 0
lower-+.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
Applied rewrites50.3%
Applied rewrites50.0%
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (+ (tan (+ y z)) x)))
(if (<= (+ y z) -40000000000.0)
t_0
(if (<= (+ y z) 2.0)
(+ x (- (* z (+ 1.0 (* 0.3333333333333333 (pow z 2.0)))) (tan a)))
t_0))))double code(double x, double y, double z, double a) {
double t_0 = tan((y + z)) + x;
double tmp;
if ((y + z) <= -40000000000.0) {
tmp = t_0;
} else if ((y + z) <= 2.0) {
tmp = x + ((z * (1.0 + (0.3333333333333333 * pow(z, 2.0)))) - tan(a));
} else {
tmp = t_0;
}
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((y + z)) + x
if ((y + z) <= (-40000000000.0d0)) then
tmp = t_0
else if ((y + z) <= 2.0d0) then
tmp = x + ((z * (1.0d0 + (0.3333333333333333d0 * (z ** 2.0d0)))) - tan(a))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double t_0 = Math.tan((y + z)) + x;
double tmp;
if ((y + z) <= -40000000000.0) {
tmp = t_0;
} else if ((y + z) <= 2.0) {
tmp = x + ((z * (1.0 + (0.3333333333333333 * Math.pow(z, 2.0)))) - Math.tan(a));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z, a): t_0 = math.tan((y + z)) + x tmp = 0 if (y + z) <= -40000000000.0: tmp = t_0 elif (y + z) <= 2.0: tmp = x + ((z * (1.0 + (0.3333333333333333 * math.pow(z, 2.0)))) - math.tan(a)) else: tmp = t_0 return tmp
function code(x, y, z, a) t_0 = Float64(tan(Float64(y + z)) + x) tmp = 0.0 if (Float64(y + z) <= -40000000000.0) tmp = t_0; elseif (Float64(y + z) <= 2.0) tmp = Float64(x + Float64(Float64(z * Float64(1.0 + Float64(0.3333333333333333 * (z ^ 2.0)))) - tan(a))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z, a) t_0 = tan((y + z)) + x; tmp = 0.0; if ((y + z) <= -40000000000.0) tmp = t_0; elseif ((y + z) <= 2.0) tmp = x + ((z * (1.0 + (0.3333333333333333 * (z ^ 2.0)))) - tan(a)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[N[(y + z), $MachinePrecision], -40000000000.0], t$95$0, If[LessEqual[N[(y + z), $MachinePrecision], 2.0], N[(x + N[(N[(z * N[(1.0 + N[(0.3333333333333333 * N[Power[z, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := \tan \left(y + z\right) + x\\
\mathbf{if}\;y + z \leq -40000000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y + z \leq 2:\\
\;\;\;\;x + \left(z \cdot \left(1 + 0.3333333333333333 \cdot {z}^{2}\right) - \tan a\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if (+.f64 y z) < -4e10 or 2 < (+.f64 y z) Initial program 79.5%
lift-tan.f64N/A
tan-quotN/A
lift-+.f64N/A
+-commutativeN/A
sin-sumN/A
div-addN/A
*-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
Applied rewrites80.0%
Taylor expanded in a around 0
lower-+.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
Applied rewrites50.3%
Applied rewrites50.0%
if -4e10 < (+.f64 y z) < 2Initial program 79.5%
lift-tan.f64N/A
tan-quotN/A
lift-+.f64N/A
+-commutativeN/A
sin-sumN/A
div-addN/A
*-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
Applied rewrites80.0%
Taylor expanded in y around 0
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f6460.2%
Applied rewrites60.2%
Taylor expanded in z around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6431.7%
Applied rewrites31.7%
(FPCore (x y z a) :precision binary64 (+ (tan (+ y z)) x))
double code(double x, double y, double z, double a) {
return tan((y + z)) + 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 + z)) + x
end function
public static double code(double x, double y, double z, double a) {
return Math.tan((y + z)) + x;
}
def code(x, y, z, a): return math.tan((y + z)) + x
function code(x, y, z, a) return Float64(tan(Float64(y + z)) + x) end
function tmp = code(x, y, z, a) tmp = tan((y + z)) + x; end
code[x_, y_, z_, a_] := N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] + x), $MachinePrecision]
\tan \left(y + z\right) + x
Initial program 79.5%
lift-tan.f64N/A
tan-quotN/A
lift-+.f64N/A
+-commutativeN/A
sin-sumN/A
div-addN/A
*-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
Applied rewrites80.0%
Taylor expanded in a around 0
lower-+.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
Applied rewrites50.3%
Applied rewrites50.0%
(FPCore (x y z a) :precision binary64 (- (tan z) (- a x)))
double code(double x, double y, double z, double a) {
return tan(z) - (a - 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(z) - (a - x)
end function
public static double code(double x, double y, double z, double a) {
return Math.tan(z) - (a - x);
}
def code(x, y, z, a): return math.tan(z) - (a - x)
function code(x, y, z, a) return Float64(tan(z) - Float64(a - x)) end
function tmp = code(x, y, z, a) tmp = tan(z) - (a - x); end
code[x_, y_, z_, a_] := N[(N[Tan[z], $MachinePrecision] - N[(a - x), $MachinePrecision]), $MachinePrecision]
\tan z - \left(a - x\right)
Initial program 79.5%
Taylor expanded in a around 0
Applied rewrites40.5%
Applied rewrites40.5%
Taylor expanded in y around 0
Applied rewrites31.0%
herbie shell --seed 2025183
(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))))