
(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 9 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 (sin (fmin y z)))
(t_1 (sin (fmax y z)))
(t_2 (cos (fmax y z)))
(t_3 (cos (fmin y z)))
(t_4 (* t_3 t_2))
(t_5 (* (- 1 (/ (* t_0 t_1) t_4)) t_4)))
(- (+ (* (/ t_3 t_5) t_1) (+ x (* (/ t_0 t_5) t_2))) (tan a))))double code(double x, double y, double z, double a) {
double t_0 = sin(fmin(y, z));
double t_1 = sin(fmax(y, z));
double t_2 = cos(fmax(y, z));
double t_3 = cos(fmin(y, z));
double t_4 = t_3 * t_2;
double t_5 = (1.0 - ((t_0 * t_1) / t_4)) * t_4;
return (((t_3 / t_5) * t_1) + (x + ((t_0 / t_5) * t_2))) - 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
real(8) :: t_4
real(8) :: t_5
t_0 = sin(fmin(y, z))
t_1 = sin(fmax(y, z))
t_2 = cos(fmax(y, z))
t_3 = cos(fmin(y, z))
t_4 = t_3 * t_2
t_5 = (1.0d0 - ((t_0 * t_1) / t_4)) * t_4
code = (((t_3 / t_5) * t_1) + (x + ((t_0 / t_5) * t_2))) - tan(a)
end function
public static double code(double x, double y, double z, double a) {
double t_0 = Math.sin(fmin(y, z));
double t_1 = Math.sin(fmax(y, z));
double t_2 = Math.cos(fmax(y, z));
double t_3 = Math.cos(fmin(y, z));
double t_4 = t_3 * t_2;
double t_5 = (1.0 - ((t_0 * t_1) / t_4)) * t_4;
return (((t_3 / t_5) * t_1) + (x + ((t_0 / t_5) * t_2))) - Math.tan(a);
}
def code(x, y, z, a): t_0 = math.sin(fmin(y, z)) t_1 = math.sin(fmax(y, z)) t_2 = math.cos(fmax(y, z)) t_3 = math.cos(fmin(y, z)) t_4 = t_3 * t_2 t_5 = (1.0 - ((t_0 * t_1) / t_4)) * t_4 return (((t_3 / t_5) * t_1) + (x + ((t_0 / t_5) * t_2))) - math.tan(a)
function code(x, y, z, a) t_0 = sin(fmin(y, z)) t_1 = sin(fmax(y, z)) t_2 = cos(fmax(y, z)) t_3 = cos(fmin(y, z)) t_4 = Float64(t_3 * t_2) t_5 = Float64(Float64(1.0 - Float64(Float64(t_0 * t_1) / t_4)) * t_4) return Float64(Float64(Float64(Float64(t_3 / t_5) * t_1) + Float64(x + Float64(Float64(t_0 / t_5) * t_2))) - tan(a)) end
function tmp = code(x, y, z, a) t_0 = sin(min(y, z)); t_1 = sin(max(y, z)); t_2 = cos(max(y, z)); t_3 = cos(min(y, z)); t_4 = t_3 * t_2; t_5 = (1.0 - ((t_0 * t_1) / t_4)) * t_4; tmp = (((t_3 / t_5) * t_1) + (x + ((t_0 / t_5) * t_2))) - tan(a); end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[Sin[N[Min[y, z], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[Max[y, z], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Cos[N[Max[y, z], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Cos[N[Min[y, z], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[(t$95$3 * t$95$2), $MachinePrecision]}, Block[{t$95$5 = N[(N[(1 - N[(N[(t$95$0 * t$95$1), $MachinePrecision] / t$95$4), $MachinePrecision]), $MachinePrecision] * t$95$4), $MachinePrecision]}, N[(N[(N[(N[(t$95$3 / t$95$5), $MachinePrecision] * t$95$1), $MachinePrecision] + N[(x + N[(N[(t$95$0 / t$95$5), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
t_0 := \sin \left(\mathsf{min}\left(y, z\right)\right)\\
t_1 := \sin \left(\mathsf{max}\left(y, z\right)\right)\\
t_2 := \cos \left(\mathsf{max}\left(y, z\right)\right)\\
t_3 := \cos \left(\mathsf{min}\left(y, z\right)\right)\\
t_4 := t\_3 \cdot t\_2\\
t_5 := \left(1 - \frac{t\_0 \cdot t\_1}{t\_4}\right) \cdot t\_4\\
\left(\frac{t\_3}{t\_5} \cdot t\_1 + \left(x + \frac{t\_0}{t\_5} \cdot t\_2\right)\right) - \tan a
\end{array}
Initial program 79.8%
lift-+.f64N/A
lift--.f64N/A
associate-+r-N/A
lift-tan.f64N/A
tan-quotN/A
sub-to-fractionN/A
mult-flipN/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
lower-/.f64N/A
lower-cos.f6479.6%
Applied rewrites79.6%
Applied rewrites80.3%
lift-+.f64N/A
lift--.f64N/A
associate-+r-N/A
lower--.f64N/A
Applied rewrites80.3%
lift-cos.f64N/A
lift-+.f64N/A
cos-sumN/A
sub-to-multN/A
lower-unsound-*.f64N/A
lower-unsound--.f64N/A
lower-unsound-/.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lower-*.f6481.0%
Applied rewrites81.0%
lift-cos.f64N/A
lift-+.f64N/A
cos-sumN/A
sub-to-multN/A
lower-unsound-*.f64N/A
lower-unsound--.f64N/A
lower-unsound-/.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lower-*.f6499.5%
Applied rewrites99.5%
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (sin (fmin y z)))
(t_1 (sin (fmax y z)))
(t_2 (cos (fmin y z)))
(t_3 (cos (fmax y z)))
(t_4 (- (* t_2 t_3) (* t_0 t_1))))
(- (+ (* (/ t_2 t_4) t_1) (+ x (* (/ t_0 t_4) t_3))) (tan a))))double code(double x, double y, double z, double a) {
double t_0 = sin(fmin(y, z));
double t_1 = sin(fmax(y, z));
double t_2 = cos(fmin(y, z));
double t_3 = cos(fmax(y, z));
double t_4 = (t_2 * t_3) - (t_0 * t_1);
return (((t_2 / t_4) * t_1) + (x + ((t_0 / t_4) * 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
real(8) :: t_4
t_0 = sin(fmin(y, z))
t_1 = sin(fmax(y, z))
t_2 = cos(fmin(y, z))
t_3 = cos(fmax(y, z))
t_4 = (t_2 * t_3) - (t_0 * t_1)
code = (((t_2 / t_4) * t_1) + (x + ((t_0 / t_4) * t_3))) - tan(a)
end function
public static double code(double x, double y, double z, double a) {
double t_0 = Math.sin(fmin(y, z));
double t_1 = Math.sin(fmax(y, z));
double t_2 = Math.cos(fmin(y, z));
double t_3 = Math.cos(fmax(y, z));
double t_4 = (t_2 * t_3) - (t_0 * t_1);
return (((t_2 / t_4) * t_1) + (x + ((t_0 / t_4) * t_3))) - Math.tan(a);
}
def code(x, y, z, a): t_0 = math.sin(fmin(y, z)) t_1 = math.sin(fmax(y, z)) t_2 = math.cos(fmin(y, z)) t_3 = math.cos(fmax(y, z)) t_4 = (t_2 * t_3) - (t_0 * t_1) return (((t_2 / t_4) * t_1) + (x + ((t_0 / t_4) * t_3))) - math.tan(a)
function code(x, y, z, a) t_0 = sin(fmin(y, z)) t_1 = sin(fmax(y, z)) t_2 = cos(fmin(y, z)) t_3 = cos(fmax(y, z)) t_4 = Float64(Float64(t_2 * t_3) - Float64(t_0 * t_1)) return Float64(Float64(Float64(Float64(t_2 / t_4) * t_1) + Float64(x + Float64(Float64(t_0 / t_4) * t_3))) - tan(a)) end
function tmp = code(x, y, z, a) t_0 = sin(min(y, z)); t_1 = sin(max(y, z)); t_2 = cos(min(y, z)); t_3 = cos(max(y, z)); t_4 = (t_2 * t_3) - (t_0 * t_1); tmp = (((t_2 / t_4) * t_1) + (x + ((t_0 / t_4) * t_3))) - tan(a); end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[Sin[N[Min[y, z], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[Max[y, z], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Cos[N[Min[y, z], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Cos[N[Max[y, z], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[(N[(t$95$2 * t$95$3), $MachinePrecision] - N[(t$95$0 * t$95$1), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[(N[(t$95$2 / t$95$4), $MachinePrecision] * t$95$1), $MachinePrecision] + N[(x + N[(N[(t$95$0 / t$95$4), $MachinePrecision] * t$95$3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
t_0 := \sin \left(\mathsf{min}\left(y, z\right)\right)\\
t_1 := \sin \left(\mathsf{max}\left(y, z\right)\right)\\
t_2 := \cos \left(\mathsf{min}\left(y, z\right)\right)\\
t_3 := \cos \left(\mathsf{max}\left(y, z\right)\right)\\
t_4 := t\_2 \cdot t\_3 - t\_0 \cdot t\_1\\
\left(\frac{t\_2}{t\_4} \cdot t\_1 + \left(x + \frac{t\_0}{t\_4} \cdot t\_3\right)\right) - \tan a
\end{array}
Initial program 79.8%
lift-+.f64N/A
lift--.f64N/A
associate-+r-N/A
lift-tan.f64N/A
tan-quotN/A
sub-to-fractionN/A
mult-flipN/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
lower-/.f64N/A
lower-cos.f6479.6%
Applied rewrites79.6%
Applied rewrites80.3%
lift-+.f64N/A
lift--.f64N/A
associate-+r-N/A
lower--.f64N/A
Applied rewrites80.3%
lift-cos.f64N/A
lift-+.f64N/A
cos-sumN/A
lower--.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f6481.0%
Applied rewrites81.0%
lift-cos.f64N/A
lift-+.f64N/A
cos-sumN/A
lower--.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f6499.5%
Applied rewrites99.5%
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (- (* (cos y) (cos z)) (* (sin y) (sin z))))
(t_1 (cos (+ z y)))
(t_2 (/ (* (cos z) (sin y)) t_1)))
(if (<= (tan a) -1152921504606847/576460752303423488)
(+
x
(-
(+ (/ (* (sin z) (sin (+ (- y) (* PI 1/2)))) t_1) t_2)
(tan a)))
(if (<=
(tan a)
8920298079412249/178405961588244985132285746181186892047843328)
(+
(+ x (* (/ (cos y) t_0) (sin z)))
(* (/ (sin y) t_0) (cos z)))
(+ x (- (+ (/ (* (sin z) (cos y)) t_1) t_2) (tan a)))))))double code(double x, double y, double z, double a) {
double t_0 = (cos(y) * cos(z)) - (sin(y) * sin(z));
double t_1 = cos((z + y));
double t_2 = (cos(z) * sin(y)) / t_1;
double tmp;
if (tan(a) <= -0.002) {
tmp = x + ((((sin(z) * sin((-y + (((double) M_PI) * 0.5)))) / t_1) + t_2) - tan(a));
} else if (tan(a) <= 5e-29) {
tmp = (x + ((cos(y) / t_0) * sin(z))) + ((sin(y) / t_0) * cos(z));
} else {
tmp = x + ((((sin(z) * cos(y)) / t_1) + t_2) - tan(a));
}
return tmp;
}
public static double code(double x, double y, double z, double a) {
double t_0 = (Math.cos(y) * Math.cos(z)) - (Math.sin(y) * Math.sin(z));
double t_1 = Math.cos((z + y));
double t_2 = (Math.cos(z) * Math.sin(y)) / t_1;
double tmp;
if (Math.tan(a) <= -0.002) {
tmp = x + ((((Math.sin(z) * Math.sin((-y + (Math.PI * 0.5)))) / t_1) + t_2) - Math.tan(a));
} else if (Math.tan(a) <= 5e-29) {
tmp = (x + ((Math.cos(y) / t_0) * Math.sin(z))) + ((Math.sin(y) / t_0) * Math.cos(z));
} else {
tmp = x + ((((Math.sin(z) * Math.cos(y)) / t_1) + t_2) - Math.tan(a));
}
return tmp;
}
def code(x, y, z, a): t_0 = (math.cos(y) * math.cos(z)) - (math.sin(y) * math.sin(z)) t_1 = math.cos((z + y)) t_2 = (math.cos(z) * math.sin(y)) / t_1 tmp = 0 if math.tan(a) <= -0.002: tmp = x + ((((math.sin(z) * math.sin((-y + (math.pi * 0.5)))) / t_1) + t_2) - math.tan(a)) elif math.tan(a) <= 5e-29: tmp = (x + ((math.cos(y) / t_0) * math.sin(z))) + ((math.sin(y) / t_0) * math.cos(z)) else: tmp = x + ((((math.sin(z) * math.cos(y)) / t_1) + t_2) - math.tan(a)) return tmp
function code(x, y, z, a) t_0 = Float64(Float64(cos(y) * cos(z)) - Float64(sin(y) * sin(z))) t_1 = cos(Float64(z + y)) t_2 = Float64(Float64(cos(z) * sin(y)) / t_1) tmp = 0.0 if (tan(a) <= -0.002) tmp = Float64(x + Float64(Float64(Float64(Float64(sin(z) * sin(Float64(Float64(-y) + Float64(pi * 0.5)))) / t_1) + t_2) - tan(a))); elseif (tan(a) <= 5e-29) tmp = Float64(Float64(x + Float64(Float64(cos(y) / t_0) * sin(z))) + Float64(Float64(sin(y) / t_0) * cos(z))); else tmp = Float64(x + Float64(Float64(Float64(Float64(sin(z) * cos(y)) / t_1) + t_2) - tan(a))); end return tmp end
function tmp_2 = code(x, y, z, a) t_0 = (cos(y) * cos(z)) - (sin(y) * sin(z)); t_1 = cos((z + y)); t_2 = (cos(z) * sin(y)) / t_1; tmp = 0.0; if (tan(a) <= -0.002) tmp = x + ((((sin(z) * sin((-y + (pi * 0.5)))) / t_1) + t_2) - tan(a)); elseif (tan(a) <= 5e-29) tmp = (x + ((cos(y) / t_0) * sin(z))) + ((sin(y) / t_0) * cos(z)); else tmp = x + ((((sin(z) * cos(y)) / t_1) + t_2) - tan(a)); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[(N[(N[Cos[y], $MachinePrecision] * N[Cos[z], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[y], $MachinePrecision] * N[Sin[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(z + y), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[Cos[z], $MachinePrecision] * N[Sin[y], $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision]}, If[LessEqual[N[Tan[a], $MachinePrecision], -1152921504606847/576460752303423488], N[(x + N[(N[(N[(N[(N[Sin[z], $MachinePrecision] * N[Sin[N[((-y) + N[(Pi * 1/2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision] + t$95$2), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Tan[a], $MachinePrecision], 8920298079412249/178405961588244985132285746181186892047843328], N[(N[(x + N[(N[(N[Cos[y], $MachinePrecision] / t$95$0), $MachinePrecision] * N[Sin[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[Sin[y], $MachinePrecision] / t$95$0), $MachinePrecision] * N[Cos[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(N[(N[(N[Sin[z], $MachinePrecision] * N[Cos[y], $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision] + t$95$2), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
t_0 := \cos y \cdot \cos z - \sin y \cdot \sin z\\
t_1 := \cos \left(z + y\right)\\
t_2 := \frac{\cos z \cdot \sin y}{t\_1}\\
\mathbf{if}\;\tan a \leq \frac{-1152921504606847}{576460752303423488}:\\
\;\;\;\;x + \left(\left(\frac{\sin z \cdot \sin \left(\left(-y\right) + \pi \cdot \frac{1}{2}\right)}{t\_1} + t\_2\right) - \tan a\right)\\
\mathbf{elif}\;\tan a \leq \frac{8920298079412249}{178405961588244985132285746181186892047843328}:\\
\;\;\;\;\left(x + \frac{\cos y}{t\_0} \cdot \sin z\right) + \frac{\sin y}{t\_0} \cdot \cos z\\
\mathbf{else}:\\
\;\;\;\;x + \left(\left(\frac{\sin z \cdot \cos y}{t\_1} + t\_2\right) - \tan a\right)\\
\end{array}
if (tan.f64 a) < -2e-3Initial program 79.8%
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.3%
lift-cos.f64N/A
cos-neg-revN/A
sin-+PI/2-revN/A
lower-sin.f64N/A
lower-+.f64N/A
lower-neg.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-PI.f6479.9%
Applied rewrites79.9%
if -2e-3 < (tan.f64 a) < 4.9999999999999999e-29Initial program 79.8%
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.7%
Applied rewrites50.7%
lift-+.f64N/A
lift-/.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
quot-tanN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
tan-quotN/A
lift-+.f64N/A
sin-sum-revN/A
lift-sin.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
div-add-revN/A
lift-/.f64N/A
Applied rewrites51.1%
lift-cos.f64N/A
lift-+.f64N/A
cos-sumN/A
lower--.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f6451.6%
Applied rewrites51.6%
lift-cos.f64N/A
lift-+.f64N/A
cos-sumN/A
lower--.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f6461.2%
Applied rewrites61.2%
if 4.9999999999999999e-29 < (tan.f64 a) Initial program 79.8%
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.3%
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (cos (+ z 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 = cos((z + y));
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 + y))
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 + y));
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 + y)) 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 = cos(Float64(z + 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
function tmp = code(x, y, z, a) t_0 = cos((z + y)); 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[Cos[N[(z + y), $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 \left(z + 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.8%
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.3%
(FPCore (x y z a) :precision binary64 (let* ((t_0 (cos (+ z y)))) (+ x (- (+ (/ (* (sin z) 1) 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 + y));
return x + ((((sin(z) * 1.0) / 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 + y))
code = x + ((((sin(z) * 1.0d0) / 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 + y));
return x + ((((Math.sin(z) * 1.0) / t_0) + ((Math.cos(z) * Math.sin(y)) / t_0)) - Math.tan(a));
}
def code(x, y, z, a): t_0 = math.cos((z + y)) return x + ((((math.sin(z) * 1.0) / t_0) + ((math.cos(z) * math.sin(y)) / t_0)) - math.tan(a))
function code(x, y, z, a) t_0 = cos(Float64(z + y)) return Float64(x + Float64(Float64(Float64(Float64(sin(z) * 1.0) / t_0) + Float64(Float64(cos(z) * sin(y)) / t_0)) - tan(a))) end
function tmp = code(x, y, z, a) t_0 = cos((z + y)); tmp = x + ((((sin(z) * 1.0) / t_0) + ((cos(z) * sin(y)) / t_0)) - tan(a)); end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[Cos[N[(z + y), $MachinePrecision]], $MachinePrecision]}, N[(x + N[(N[(N[(N[(N[Sin[z], $MachinePrecision] * 1), $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 \left(z + y\right)\\
x + \left(\left(\frac{\sin z \cdot 1}{t\_0} + \frac{\cos z \cdot \sin y}{t\_0}\right) - \tan a\right)
\end{array}
Initial program 79.8%
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.3%
Taylor expanded in y around 0
Applied rewrites79.9%
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (cos (fmin y z))))
(-
(+
(* (/ t_0 (cos (+ (fmax y z) (fmin y z)))) (sin (fmax y z)))
(+ x (/ (sin (fmin y z)) t_0)))
(tan a))))double code(double x, double y, double z, double a) {
double t_0 = cos(fmin(y, z));
return (((t_0 / cos((fmax(y, z) + fmin(y, z)))) * sin(fmax(y, z))) + (x + (sin(fmin(y, z)) / t_0))) - tan(a);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
real(8) :: t_0
t_0 = cos(fmin(y, z))
code = (((t_0 / cos((fmax(y, z) + fmin(y, z)))) * sin(fmax(y, z))) + (x + (sin(fmin(y, z)) / t_0))) - tan(a)
end function
public static double code(double x, double y, double z, double a) {
double t_0 = Math.cos(fmin(y, z));
return (((t_0 / Math.cos((fmax(y, z) + fmin(y, z)))) * Math.sin(fmax(y, z))) + (x + (Math.sin(fmin(y, z)) / t_0))) - Math.tan(a);
}
def code(x, y, z, a): t_0 = math.cos(fmin(y, z)) return (((t_0 / math.cos((fmax(y, z) + fmin(y, z)))) * math.sin(fmax(y, z))) + (x + (math.sin(fmin(y, z)) / t_0))) - math.tan(a)
function code(x, y, z, a) t_0 = cos(fmin(y, z)) return Float64(Float64(Float64(Float64(t_0 / cos(Float64(fmax(y, z) + fmin(y, z)))) * sin(fmax(y, z))) + Float64(x + Float64(sin(fmin(y, z)) / t_0))) - tan(a)) end
function tmp = code(x, y, z, a) t_0 = cos(min(y, z)); tmp = (((t_0 / cos((max(y, z) + min(y, z)))) * sin(max(y, z))) + (x + (sin(min(y, z)) / t_0))) - tan(a); end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[Cos[N[Min[y, z], $MachinePrecision]], $MachinePrecision]}, N[(N[(N[(N[(t$95$0 / N[Cos[N[(N[Max[y, z], $MachinePrecision] + N[Min[y, z], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[N[Max[y, z], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(x + N[(N[Sin[N[Min[y, z], $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
t_0 := \cos \left(\mathsf{min}\left(y, z\right)\right)\\
\left(\frac{t\_0}{\cos \left(\mathsf{max}\left(y, z\right) + \mathsf{min}\left(y, z\right)\right)} \cdot \sin \left(\mathsf{max}\left(y, z\right)\right) + \left(x + \frac{\sin \left(\mathsf{min}\left(y, z\right)\right)}{t\_0}\right)\right) - \tan a
\end{array}
Initial program 79.8%
lift-+.f64N/A
lift--.f64N/A
associate-+r-N/A
lift-tan.f64N/A
tan-quotN/A
sub-to-fractionN/A
mult-flipN/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
lower-/.f64N/A
lower-cos.f6479.6%
Applied rewrites79.6%
Applied rewrites80.3%
lift-+.f64N/A
lift--.f64N/A
associate-+r-N/A
lower--.f64N/A
Applied rewrites80.3%
Taylor expanded in z around 0
lower-+.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f6479.8%
Applied rewrites79.8%
(FPCore (x y z a) :precision binary64 (if (<= (+ (fmin y z) (fmax y z)) -500) (+ (tan (+ (fmax y z) (fmin y z))) x) (+ x (- (tan (fmax y z)) (tan a)))))
double code(double x, double y, double z, double a) {
double tmp;
if ((fmin(y, z) + fmax(y, z)) <= -500.0) {
tmp = tan((fmax(y, z) + fmin(y, z))) + x;
} else {
tmp = x + (tan(fmax(y, z)) - tan(a));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
real(8) :: tmp
if ((fmin(y, z) + fmax(y, z)) <= (-500.0d0)) then
tmp = tan((fmax(y, z) + fmin(y, z))) + x
else
tmp = x + (tan(fmax(y, z)) - tan(a))
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double tmp;
if ((fmin(y, z) + fmax(y, z)) <= -500.0) {
tmp = Math.tan((fmax(y, z) + fmin(y, z))) + x;
} else {
tmp = x + (Math.tan(fmax(y, z)) - Math.tan(a));
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if (fmin(y, z) + fmax(y, z)) <= -500.0: tmp = math.tan((fmax(y, z) + fmin(y, z))) + x else: tmp = x + (math.tan(fmax(y, z)) - math.tan(a)) return tmp
function code(x, y, z, a) tmp = 0.0 if (Float64(fmin(y, z) + fmax(y, z)) <= -500.0) tmp = Float64(tan(Float64(fmax(y, z) + fmin(y, z))) + x); else tmp = Float64(x + Float64(tan(fmax(y, z)) - tan(a))); end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if ((min(y, z) + max(y, z)) <= -500.0) tmp = tan((max(y, z) + min(y, z))) + x; else tmp = x + (tan(max(y, z)) - tan(a)); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[N[(N[Min[y, z], $MachinePrecision] + N[Max[y, z], $MachinePrecision]), $MachinePrecision], -500], N[(N[Tan[N[(N[Max[y, z], $MachinePrecision] + N[Min[y, z], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + x), $MachinePrecision], N[(x + N[(N[Tan[N[Max[y, z], $MachinePrecision]], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\mathsf{min}\left(y, z\right) + \mathsf{max}\left(y, z\right) \leq -500:\\
\;\;\;\;\tan \left(\mathsf{max}\left(y, z\right) + \mathsf{min}\left(y, z\right)\right) + x\\
\mathbf{else}:\\
\;\;\;\;x + \left(\tan \left(\mathsf{max}\left(y, z\right)\right) - \tan a\right)\\
\end{array}
if (+.f64 y z) < -500Initial program 79.8%
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.7%
Applied rewrites50.7%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
quot-tanN/A
lower-tan.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-+.f6450.7%
Applied rewrites50.7%
if -500 < (+.f64 y z) Initial program 79.8%
Taylor expanded in y around 0
Applied rewrites60.6%
(FPCore (x y z a) :precision binary64 (+ (tan (+ z y)) x))
double code(double x, double y, double z, double a) {
return tan((z + y)) + x;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
code = tan((z + y)) + x
end function
public static double code(double x, double y, double z, double a) {
return Math.tan((z + y)) + x;
}
def code(x, y, z, a): return math.tan((z + y)) + x
function code(x, y, z, a) return Float64(tan(Float64(z + y)) + x) end
function tmp = code(x, y, z, a) tmp = tan((z + y)) + x; end
code[x_, y_, z_, a_] := N[(N[Tan[N[(z + y), $MachinePrecision]], $MachinePrecision] + x), $MachinePrecision]
\tan \left(z + y\right) + x
Initial program 79.8%
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.7%
Applied rewrites50.7%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
quot-tanN/A
lower-tan.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-+.f6450.7%
Applied rewrites50.7%
herbie shell --seed 2025285 -o generate:evaluate
(FPCore (x y z a)
:name "tan-example (used to crash)"
:precision binary64
:pre (and (and (and (or (== x 0) (and (<= 2942071/5000000 x) (<= x 5055909/10000))) (or (and (<= -179665800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 y) (<= y -1885117/2000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000)) (and (<= 642469/500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 y) (<= y 175122400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000)))) (or (and (<= -177670700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 z) (<= z -2149949/2500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000)) (and (<= 658629/20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 z) (<= z 172515400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000)))) (or (and (<= -179665800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 a) (<= a -1885117/2000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000)) (and (<= 642469/500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 a) (<= a 175122400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000))))
(+ x (- (tan (+ y z)) (tan a))))