
(FPCore (x y z a) :precision binary64 (+ x (- (tan (+ y z)) (tan a))))
double code(double x, double y, double z, double a) {
return x + (tan((y + z)) - tan(a));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
code = x + (tan((y + z)) - tan(a))
end function
public static double code(double x, double y, double z, double a) {
return x + (Math.tan((y + z)) - Math.tan(a));
}
def code(x, y, z, a): return x + (math.tan((y + z)) - math.tan(a))
function code(x, y, z, a) return Float64(x + Float64(tan(Float64(y + z)) - tan(a))) end
function tmp = code(x, y, z, a) tmp = x + (tan((y + z)) - tan(a)); end
code[x_, y_, z_, a_] := N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\tan \left(y + z\right) - \tan a\right)
\end{array}
Herbie found 16 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z a) :precision binary64 (+ x (- (tan (+ y z)) (tan a))))
double code(double x, double y, double z, double a) {
return x + (tan((y + z)) - tan(a));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
code = x + (tan((y + z)) - tan(a))
end function
public static double code(double x, double y, double z, double a) {
return x + (Math.tan((y + z)) - Math.tan(a));
}
def code(x, y, z, a): return x + (math.tan((y + z)) - math.tan(a))
function code(x, y, z, a) return Float64(x + Float64(tan(Float64(y + z)) - tan(a))) end
function tmp = code(x, y, z, a) tmp = x + (tan((y + z)) - tan(a)); end
code[x_, y_, z_, a_] := N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\tan \left(y + z\right) - \tan a\right)
\end{array}
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (- (* (cos y) (cos z)) (* (sin y) (sin z)))))
(+
x
(- (+ (/ (* (cos z) (sin y)) t_0) (/ (* (cos y) (sin z)) t_0)) (tan a)))))
double code(double x, double y, double z, double a) {
double t_0 = (cos(y) * cos(z)) - (sin(y) * sin(z));
return x + ((((cos(z) * sin(y)) / t_0) + ((cos(y) * sin(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(y) * cos(z)) - (sin(y) * sin(z))
code = x + ((((cos(z) * sin(y)) / t_0) + ((cos(y) * sin(z)) / t_0)) - tan(a))
end function
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));
return x + ((((Math.cos(z) * Math.sin(y)) / t_0) + ((Math.cos(y) * Math.sin(z)) / t_0)) - Math.tan(a));
}
def code(x, y, z, a): t_0 = (math.cos(y) * math.cos(z)) - (math.sin(y) * math.sin(z)) return x + ((((math.cos(z) * math.sin(y)) / t_0) + ((math.cos(y) * math.sin(z)) / t_0)) - math.tan(a))
function code(x, y, z, a) t_0 = Float64(Float64(cos(y) * cos(z)) - Float64(sin(y) * sin(z))) return Float64(x + Float64(Float64(Float64(Float64(cos(z) * sin(y)) / t_0) + Float64(Float64(cos(y) * sin(z)) / t_0)) - tan(a))) end
function tmp = code(x, y, z, a) t_0 = (cos(y) * cos(z)) - (sin(y) * sin(z)); tmp = x + ((((cos(z) * sin(y)) / t_0) + ((cos(y) * sin(z)) / t_0)) - tan(a)); 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]}, N[(x + N[(N[(N[(N[(N[Cos[z], $MachinePrecision] * N[Sin[y], $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision] + N[(N[(N[Cos[y], $MachinePrecision] * N[Sin[z], $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos y \cdot \cos z - \sin y \cdot \sin z\\
x + \left(\left(\frac{\cos z \cdot \sin y}{t\_0} + \frac{\cos y \cdot \sin z}{t\_0}\right) - \tan a\right)
\end{array}
\end{array}
Initial program 79.4%
Applied rewrites79.8%
Applied rewrites80.7%
Applied rewrites99.7%
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (- (* (cos y) (cos z)) (* (sin y) (sin z))))
(t_1 (/ (* (cos z) (sin y)) t_0))
(t_2 (* (cos y) (sin z)))
(t_3 (+ x (- (+ t_1 (/ t_2 (cos (+ y z)))) (tan a)))))
(if (<= a -0.0225)
t_3
(if (<= a 0.0076)
(+
x
(fma
a
(- (* -0.3333333333333333 (pow a 2.0)) 1.0)
(+ (/ t_2 t_0) t_1)))
t_3))))
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) * sin(y)) / t_0;
double t_2 = cos(y) * sin(z);
double t_3 = x + ((t_1 + (t_2 / cos((y + z)))) - tan(a));
double tmp;
if (a <= -0.0225) {
tmp = t_3;
} else if (a <= 0.0076) {
tmp = x + fma(a, ((-0.3333333333333333 * pow(a, 2.0)) - 1.0), ((t_2 / t_0) + t_1));
} else {
tmp = t_3;
}
return tmp;
}
function code(x, y, z, a) t_0 = Float64(Float64(cos(y) * cos(z)) - Float64(sin(y) * sin(z))) t_1 = Float64(Float64(cos(z) * sin(y)) / t_0) t_2 = Float64(cos(y) * sin(z)) t_3 = Float64(x + Float64(Float64(t_1 + Float64(t_2 / cos(Float64(y + z)))) - tan(a))) tmp = 0.0 if (a <= -0.0225) tmp = t_3; elseif (a <= 0.0076) tmp = Float64(x + fma(a, Float64(Float64(-0.3333333333333333 * (a ^ 2.0)) - 1.0), Float64(Float64(t_2 / t_0) + t_1))); else tmp = t_3; end return 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[(N[(N[Cos[z], $MachinePrecision] * N[Sin[y], $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[y], $MachinePrecision] * N[Sin[z], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(x + N[(N[(t$95$1 + N[(t$95$2 / N[Cos[N[(y + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, -0.0225], t$95$3, If[LessEqual[a, 0.0076], N[(x + N[(a * N[(N[(-0.3333333333333333 * N[Power[a, 2.0], $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision] + N[(N[(t$95$2 / t$95$0), $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$3]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos y \cdot \cos z - \sin y \cdot \sin z\\
t_1 := \frac{\cos z \cdot \sin y}{t\_0}\\
t_2 := \cos y \cdot \sin z\\
t_3 := x + \left(\left(t\_1 + \frac{t\_2}{\cos \left(y + z\right)}\right) - \tan a\right)\\
\mathbf{if}\;a \leq -0.0225:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;a \leq 0.0076:\\
\;\;\;\;x + \mathsf{fma}\left(a, -0.3333333333333333 \cdot {a}^{2} - 1, \frac{t\_2}{t\_0} + t\_1\right)\\
\mathbf{else}:\\
\;\;\;\;t\_3\\
\end{array}
\end{array}
if a < -0.022499999999999999 or 0.00759999999999999998 < a Initial program 79.4%
Applied rewrites79.8%
Applied rewrites80.7%
Applied rewrites99.7%
Applied rewrites80.7%
if -0.022499999999999999 < a < 0.00759999999999999998Initial program 79.4%
Applied rewrites79.8%
Applied rewrites80.7%
Applied rewrites99.7%
Taylor expanded in a around 0
Applied rewrites49.7%
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (- (* (cos y) (cos z)) (* (sin y) (sin z))))
(t_1 (/ (* (cos z) (sin y)) t_0))
(t_2 (* (cos y) (sin z)))
(t_3 (+ x (- (+ t_1 (/ t_2 (cos (+ y z)))) (tan a)))))
(if (<= (tan a) -0.02)
t_3
(if (<= (tan a) 0.0002) (+ x (- (+ t_1 (/ t_2 t_0)) a)) t_3))))
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) * sin(y)) / t_0;
double t_2 = cos(y) * sin(z);
double t_3 = x + ((t_1 + (t_2 / cos((y + z)))) - tan(a));
double tmp;
if (tan(a) <= -0.02) {
tmp = t_3;
} else if (tan(a) <= 0.0002) {
tmp = x + ((t_1 + (t_2 / t_0)) - a);
} else {
tmp = t_3;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = (cos(y) * cos(z)) - (sin(y) * sin(z))
t_1 = (cos(z) * sin(y)) / t_0
t_2 = cos(y) * sin(z)
t_3 = x + ((t_1 + (t_2 / cos((y + z)))) - tan(a))
if (tan(a) <= (-0.02d0)) then
tmp = t_3
else if (tan(a) <= 0.0002d0) then
tmp = x + ((t_1 + (t_2 / t_0)) - a)
else
tmp = t_3
end if
code = tmp
end function
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) * Math.sin(y)) / t_0;
double t_2 = Math.cos(y) * Math.sin(z);
double t_3 = x + ((t_1 + (t_2 / Math.cos((y + z)))) - Math.tan(a));
double tmp;
if (Math.tan(a) <= -0.02) {
tmp = t_3;
} else if (Math.tan(a) <= 0.0002) {
tmp = x + ((t_1 + (t_2 / t_0)) - a);
} else {
tmp = t_3;
}
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) * math.sin(y)) / t_0 t_2 = math.cos(y) * math.sin(z) t_3 = x + ((t_1 + (t_2 / math.cos((y + z)))) - math.tan(a)) tmp = 0 if math.tan(a) <= -0.02: tmp = t_3 elif math.tan(a) <= 0.0002: tmp = x + ((t_1 + (t_2 / t_0)) - a) else: tmp = t_3 return tmp
function code(x, y, z, a) t_0 = Float64(Float64(cos(y) * cos(z)) - Float64(sin(y) * sin(z))) t_1 = Float64(Float64(cos(z) * sin(y)) / t_0) t_2 = Float64(cos(y) * sin(z)) t_3 = Float64(x + Float64(Float64(t_1 + Float64(t_2 / cos(Float64(y + z)))) - tan(a))) tmp = 0.0 if (tan(a) <= -0.02) tmp = t_3; elseif (tan(a) <= 0.0002) tmp = Float64(x + Float64(Float64(t_1 + Float64(t_2 / t_0)) - a)); else tmp = t_3; 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) * sin(y)) / t_0; t_2 = cos(y) * sin(z); t_3 = x + ((t_1 + (t_2 / cos((y + z)))) - tan(a)); tmp = 0.0; if (tan(a) <= -0.02) tmp = t_3; elseif (tan(a) <= 0.0002) tmp = x + ((t_1 + (t_2 / t_0)) - a); else tmp = t_3; 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[(N[(N[Cos[z], $MachinePrecision] * N[Sin[y], $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[y], $MachinePrecision] * N[Sin[z], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(x + N[(N[(t$95$1 + N[(t$95$2 / N[Cos[N[(y + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Tan[a], $MachinePrecision], -0.02], t$95$3, If[LessEqual[N[Tan[a], $MachinePrecision], 0.0002], N[(x + N[(N[(t$95$1 + N[(t$95$2 / t$95$0), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], t$95$3]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos y \cdot \cos z - \sin y \cdot \sin z\\
t_1 := \frac{\cos z \cdot \sin y}{t\_0}\\
t_2 := \cos y \cdot \sin z\\
t_3 := x + \left(\left(t\_1 + \frac{t\_2}{\cos \left(y + z\right)}\right) - \tan a\right)\\
\mathbf{if}\;\tan a \leq -0.02:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;\tan a \leq 0.0002:\\
\;\;\;\;x + \left(\left(t\_1 + \frac{t\_2}{t\_0}\right) - a\right)\\
\mathbf{else}:\\
\;\;\;\;t\_3\\
\end{array}
\end{array}
if (tan.f64 a) < -0.0200000000000000004 or 2.0000000000000001e-4 < (tan.f64 a) Initial program 79.4%
Applied rewrites79.8%
Applied rewrites80.7%
Applied rewrites99.7%
Applied rewrites80.7%
if -0.0200000000000000004 < (tan.f64 a) < 2.0000000000000001e-4Initial program 79.4%
Applied rewrites79.8%
Applied rewrites80.7%
Applied rewrites99.7%
Taylor expanded in a around 0
Applied rewrites50.1%
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (- (* (cos y) (cos z)) (* (sin y) (sin z))))
(t_1 (/ (* (cos z) (sin y)) t_0))
(t_2 (* (cos y) (sin z)))
(t_3 (+ x (- (+ t_1 (/ t_2 (cos (+ y z)))) (tan a)))))
(if (<= (tan a) -0.02)
t_3
(if (<= (tan a) 1e-20) (+ x (+ (/ t_2 t_0) t_1)) t_3))))
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) * sin(y)) / t_0;
double t_2 = cos(y) * sin(z);
double t_3 = x + ((t_1 + (t_2 / cos((y + z)))) - tan(a));
double tmp;
if (tan(a) <= -0.02) {
tmp = t_3;
} else if (tan(a) <= 1e-20) {
tmp = x + ((t_2 / t_0) + t_1);
} else {
tmp = t_3;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = (cos(y) * cos(z)) - (sin(y) * sin(z))
t_1 = (cos(z) * sin(y)) / t_0
t_2 = cos(y) * sin(z)
t_3 = x + ((t_1 + (t_2 / cos((y + z)))) - tan(a))
if (tan(a) <= (-0.02d0)) then
tmp = t_3
else if (tan(a) <= 1d-20) then
tmp = x + ((t_2 / t_0) + t_1)
else
tmp = t_3
end if
code = tmp
end function
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) * Math.sin(y)) / t_0;
double t_2 = Math.cos(y) * Math.sin(z);
double t_3 = x + ((t_1 + (t_2 / Math.cos((y + z)))) - Math.tan(a));
double tmp;
if (Math.tan(a) <= -0.02) {
tmp = t_3;
} else if (Math.tan(a) <= 1e-20) {
tmp = x + ((t_2 / t_0) + t_1);
} else {
tmp = t_3;
}
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) * math.sin(y)) / t_0 t_2 = math.cos(y) * math.sin(z) t_3 = x + ((t_1 + (t_2 / math.cos((y + z)))) - math.tan(a)) tmp = 0 if math.tan(a) <= -0.02: tmp = t_3 elif math.tan(a) <= 1e-20: tmp = x + ((t_2 / t_0) + t_1) else: tmp = t_3 return tmp
function code(x, y, z, a) t_0 = Float64(Float64(cos(y) * cos(z)) - Float64(sin(y) * sin(z))) t_1 = Float64(Float64(cos(z) * sin(y)) / t_0) t_2 = Float64(cos(y) * sin(z)) t_3 = Float64(x + Float64(Float64(t_1 + Float64(t_2 / cos(Float64(y + z)))) - tan(a))) tmp = 0.0 if (tan(a) <= -0.02) tmp = t_3; elseif (tan(a) <= 1e-20) tmp = Float64(x + Float64(Float64(t_2 / t_0) + t_1)); else tmp = t_3; 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) * sin(y)) / t_0; t_2 = cos(y) * sin(z); t_3 = x + ((t_1 + (t_2 / cos((y + z)))) - tan(a)); tmp = 0.0; if (tan(a) <= -0.02) tmp = t_3; elseif (tan(a) <= 1e-20) tmp = x + ((t_2 / t_0) + t_1); else tmp = t_3; 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[(N[(N[Cos[z], $MachinePrecision] * N[Sin[y], $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[y], $MachinePrecision] * N[Sin[z], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(x + N[(N[(t$95$1 + N[(t$95$2 / N[Cos[N[(y + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Tan[a], $MachinePrecision], -0.02], t$95$3, If[LessEqual[N[Tan[a], $MachinePrecision], 1e-20], N[(x + N[(N[(t$95$2 / t$95$0), $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision], t$95$3]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos y \cdot \cos z - \sin y \cdot \sin z\\
t_1 := \frac{\cos z \cdot \sin y}{t\_0}\\
t_2 := \cos y \cdot \sin z\\
t_3 := x + \left(\left(t\_1 + \frac{t\_2}{\cos \left(y + z\right)}\right) - \tan a\right)\\
\mathbf{if}\;\tan a \leq -0.02:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;\tan a \leq 10^{-20}:\\
\;\;\;\;x + \left(\frac{t\_2}{t\_0} + t\_1\right)\\
\mathbf{else}:\\
\;\;\;\;t\_3\\
\end{array}
\end{array}
if (tan.f64 a) < -0.0200000000000000004 or 9.99999999999999945e-21 < (tan.f64 a) Initial program 79.4%
Applied rewrites79.8%
Applied rewrites80.7%
Applied rewrites99.7%
Applied rewrites80.7%
if -0.0200000000000000004 < (tan.f64 a) < 9.99999999999999945e-21Initial program 79.4%
Applied rewrites79.8%
Applied rewrites80.7%
Applied rewrites99.7%
Taylor expanded in a around 0
Applied rewrites60.0%
(FPCore (x y z a)
:precision binary64
(+
x
(-
(+
(/ (* (cos z) (sin y)) (- (* (cos y) (cos z)) (* (sin y) (sin z))))
(/ (* (cos y) (sin z)) (cos (+ y z))))
(tan a))))
double code(double x, double y, double z, double a) {
return x + ((((cos(z) * sin(y)) / ((cos(y) * cos(z)) - (sin(y) * sin(z)))) + ((cos(y) * sin(z)) / cos((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 + ((((cos(z) * sin(y)) / ((cos(y) * cos(z)) - (sin(y) * sin(z)))) + ((cos(y) * sin(z)) / cos((y + z)))) - tan(a))
end function
public static double code(double x, double y, double z, double a) {
return x + ((((Math.cos(z) * Math.sin(y)) / ((Math.cos(y) * Math.cos(z)) - (Math.sin(y) * Math.sin(z)))) + ((Math.cos(y) * Math.sin(z)) / Math.cos((y + z)))) - Math.tan(a));
}
def code(x, y, z, a): return x + ((((math.cos(z) * math.sin(y)) / ((math.cos(y) * math.cos(z)) - (math.sin(y) * math.sin(z)))) + ((math.cos(y) * math.sin(z)) / math.cos((y + z)))) - math.tan(a))
function code(x, y, z, a) return Float64(x + Float64(Float64(Float64(Float64(cos(z) * sin(y)) / Float64(Float64(cos(y) * cos(z)) - Float64(sin(y) * sin(z)))) + Float64(Float64(cos(y) * sin(z)) / cos(Float64(y + z)))) - tan(a))) end
function tmp = code(x, y, z, a) tmp = x + ((((cos(z) * sin(y)) / ((cos(y) * cos(z)) - (sin(y) * sin(z)))) + ((cos(y) * sin(z)) / cos((y + z)))) - tan(a)); end
code[x_, y_, z_, a_] := N[(x + N[(N[(N[(N[(N[Cos[z], $MachinePrecision] * N[Sin[y], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[y], $MachinePrecision] * N[Cos[z], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[y], $MachinePrecision] * N[Sin[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[y], $MachinePrecision] * N[Sin[z], $MachinePrecision]), $MachinePrecision] / N[Cos[N[(y + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\left(\frac{\cos z \cdot \sin y}{\cos y \cdot \cos z - \sin y \cdot \sin z} + \frac{\cos y \cdot \sin z}{\cos \left(y + z\right)}\right) - \tan a\right)
\end{array}
Initial program 79.4%
Applied rewrites79.8%
Applied rewrites80.7%
Applied rewrites99.7%
Applied rewrites80.7%
(FPCore (x y z a)
:precision binary64
(+
x
(-
(+
(/ (* (cos z) (sin y)) (cos (+ y z)))
(/ (* (cos y) (sin z)) (- (* (cos y) (cos z)) (* (sin y) (sin z)))))
(tan a))))
double code(double x, double y, double z, double a) {
return x + ((((cos(z) * sin(y)) / cos((y + z))) + ((cos(y) * sin(z)) / ((cos(y) * cos(z)) - (sin(y) * sin(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 + ((((cos(z) * sin(y)) / cos((y + z))) + ((cos(y) * sin(z)) / ((cos(y) * cos(z)) - (sin(y) * sin(z))))) - tan(a))
end function
public static double code(double x, double y, double z, double a) {
return x + ((((Math.cos(z) * Math.sin(y)) / Math.cos((y + z))) + ((Math.cos(y) * Math.sin(z)) / ((Math.cos(y) * Math.cos(z)) - (Math.sin(y) * Math.sin(z))))) - Math.tan(a));
}
def code(x, y, z, a): return x + ((((math.cos(z) * math.sin(y)) / math.cos((y + z))) + ((math.cos(y) * math.sin(z)) / ((math.cos(y) * math.cos(z)) - (math.sin(y) * math.sin(z))))) - math.tan(a))
function code(x, y, z, a) return Float64(x + Float64(Float64(Float64(Float64(cos(z) * sin(y)) / cos(Float64(y + z))) + Float64(Float64(cos(y) * sin(z)) / Float64(Float64(cos(y) * cos(z)) - Float64(sin(y) * sin(z))))) - tan(a))) end
function tmp = code(x, y, z, a) tmp = x + ((((cos(z) * sin(y)) / cos((y + z))) + ((cos(y) * sin(z)) / ((cos(y) * cos(z)) - (sin(y) * sin(z))))) - tan(a)); end
code[x_, y_, z_, a_] := N[(x + N[(N[(N[(N[(N[Cos[z], $MachinePrecision] * N[Sin[y], $MachinePrecision]), $MachinePrecision] / N[Cos[N[(y + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[y], $MachinePrecision] * N[Sin[z], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[y], $MachinePrecision] * N[Cos[z], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[y], $MachinePrecision] * N[Sin[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\left(\frac{\cos z \cdot \sin y}{\cos \left(y + z\right)} + \frac{\cos y \cdot \sin z}{\cos y \cdot \cos z - \sin y \cdot \sin z}\right) - \tan a\right)
\end{array}
Initial program 79.4%
Applied rewrites79.8%
Applied rewrites80.7%
Applied rewrites99.7%
Applied rewrites80.6%
(FPCore (x y z a) :precision binary64 (fma (/ 1.0 (fma (cos z) (cos y) (* (sin y) (sin (- z))))) (sin (+ y z)) (- x (tan a))))
double code(double x, double y, double z, double a) {
return fma((1.0 / fma(cos(z), cos(y), (sin(y) * sin(-z)))), sin((y + z)), (x - tan(a)));
}
function code(x, y, z, a) return fma(Float64(1.0 / fma(cos(z), cos(y), Float64(sin(y) * sin(Float64(-z))))), sin(Float64(y + z)), Float64(x - tan(a))) end
code[x_, y_, z_, a_] := N[(N[(1.0 / N[(N[Cos[z], $MachinePrecision] * N[Cos[y], $MachinePrecision] + N[(N[Sin[y], $MachinePrecision] * N[Sin[(-z)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sin[N[(y + z), $MachinePrecision]], $MachinePrecision] + N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{1}{\mathsf{fma}\left(\cos z, \cos y, \sin y \cdot \sin \left(-z\right)\right)}, \sin \left(y + z\right), x - \tan a\right)
\end{array}
Initial program 79.4%
Applied rewrites79.3%
Applied rewrites79.9%
(FPCore (x y z a) :precision binary64 (fma (/ 1.0 (- (* (cos y) (cos z)) (* (sin y) (sin z)))) (sin (+ y z)) (- x (tan a))))
double code(double x, double y, double z, double a) {
return fma((1.0 / ((cos(y) * cos(z)) - (sin(y) * sin(z)))), sin((y + z)), (x - tan(a)));
}
function code(x, y, z, a) return fma(Float64(1.0 / Float64(Float64(cos(y) * cos(z)) - Float64(sin(y) * sin(z)))), sin(Float64(y + z)), Float64(x - tan(a))) end
code[x_, y_, z_, a_] := N[(N[(1.0 / N[(N[(N[Cos[y], $MachinePrecision] * N[Cos[z], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[y], $MachinePrecision] * N[Sin[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sin[N[(y + z), $MachinePrecision]], $MachinePrecision] + N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{1}{\cos y \cdot \cos z - \sin y \cdot \sin z}, \sin \left(y + z\right), x - \tan a\right)
\end{array}
Initial program 79.4%
Applied rewrites79.3%
Applied rewrites79.9%
(FPCore (x y z a) :precision binary64 (fma (/ 1.0 (cos (+ y z))) (fma (sin z) (cos y) (* (cos z) (sin y))) (- x (tan a))))
double code(double x, double y, double z, double a) {
return fma((1.0 / cos((y + z))), fma(sin(z), cos(y), (cos(z) * sin(y))), (x - tan(a)));
}
function code(x, y, z, a) return fma(Float64(1.0 / cos(Float64(y + z))), fma(sin(z), cos(y), Float64(cos(z) * sin(y))), Float64(x - tan(a))) end
code[x_, y_, z_, a_] := N[(N[(1.0 / N[Cos[N[(y + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[Sin[z], $MachinePrecision] * N[Cos[y], $MachinePrecision] + N[(N[Cos[z], $MachinePrecision] * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{1}{\cos \left(y + z\right)}, \mathsf{fma}\left(\sin z, \cos y, \cos z \cdot \sin y\right), x - \tan a\right)
\end{array}
Initial program 79.4%
Applied rewrites79.3%
Applied rewrites79.8%
(FPCore (x y z a) :precision binary64 (- x (- (tan a) (tan (+ y z)))))
double code(double x, double y, double z, double a) {
return x - (tan(a) - tan((y + z)));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
code = x - (tan(a) - tan((y + z)))
end function
public static double code(double x, double y, double z, double a) {
return x - (Math.tan(a) - Math.tan((y + z)));
}
def code(x, y, z, a): return x - (math.tan(a) - math.tan((y + z)))
function code(x, y, z, a) return Float64(x - Float64(tan(a) - tan(Float64(y + z)))) end
function tmp = code(x, y, z, a) tmp = x - (tan(a) - tan((y + z))); end
code[x_, y_, z_, a_] := N[(x - N[(N[Tan[a], $MachinePrecision] - N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \left(\tan a - \tan \left(y + z\right)\right)
\end{array}
Initial program 79.4%
Applied rewrites79.4%
(FPCore (x y z a) :precision binary64 (if (<= y -0.0225) (+ x (/ (sin (+ y z)) (cos (+ y z)))) (+ x (- (tan z) (tan a)))))
double code(double x, double y, double z, double a) {
double tmp;
if (y <= -0.0225) {
tmp = x + (sin((y + z)) / cos((y + z)));
} else {
tmp = x + (tan(z) - tan(a));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
real(8) :: tmp
if (y <= (-0.0225d0)) then
tmp = x + (sin((y + z)) / cos((y + z)))
else
tmp = x + (tan(z) - tan(a))
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double tmp;
if (y <= -0.0225) {
tmp = x + (Math.sin((y + z)) / Math.cos((y + z)));
} else {
tmp = x + (Math.tan(z) - Math.tan(a));
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if y <= -0.0225: tmp = x + (math.sin((y + z)) / math.cos((y + z))) else: tmp = x + (math.tan(z) - math.tan(a)) return tmp
function code(x, y, z, a) tmp = 0.0 if (y <= -0.0225) tmp = Float64(x + Float64(sin(Float64(y + z)) / cos(Float64(y + z)))); else tmp = Float64(x + Float64(tan(z) - tan(a))); end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if (y <= -0.0225) tmp = x + (sin((y + z)) / cos((y + z))); else tmp = x + (tan(z) - tan(a)); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[y, -0.0225], N[(x + N[(N[Sin[N[(y + z), $MachinePrecision]], $MachinePrecision] / N[Cos[N[(y + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[Tan[z], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -0.0225:\\
\;\;\;\;x + \frac{\sin \left(y + z\right)}{\cos \left(y + z\right)}\\
\mathbf{else}:\\
\;\;\;\;x + \left(\tan z - \tan a\right)\\
\end{array}
\end{array}
if y < -0.022499999999999999Initial program 79.4%
Taylor expanded in a around 0
Applied rewrites49.8%
if -0.022499999999999999 < y Initial program 79.4%
Taylor expanded in y around 0
Applied rewrites60.2%
(FPCore (x y z a) :precision binary64 (+ x (/ (sin (+ y z)) (cos (+ y z)))))
double code(double x, double y, double z, double a) {
return x + (sin((y + z)) / cos((y + z)));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
code = x + (sin((y + z)) / cos((y + z)))
end function
public static double code(double x, double y, double z, double a) {
return x + (Math.sin((y + z)) / Math.cos((y + z)));
}
def code(x, y, z, a): return x + (math.sin((y + z)) / math.cos((y + z)))
function code(x, y, z, a) return Float64(x + Float64(sin(Float64(y + z)) / cos(Float64(y + z)))) end
function tmp = code(x, y, z, a) tmp = x + (sin((y + z)) / cos((y + z))); end
code[x_, y_, z_, a_] := N[(x + N[(N[Sin[N[(y + z), $MachinePrecision]], $MachinePrecision] / N[Cos[N[(y + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{\sin \left(y + z\right)}{\cos \left(y + z\right)}
\end{array}
Initial program 79.4%
Taylor expanded in a around 0
Applied rewrites49.8%
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (* -1.0 (* x -1.0))))
(if (<= (tan a) -0.02)
t_0
(if (<= (tan a) 0.05)
(+ x (- (tan (+ y z)) (* a (+ 1.0 (* 0.3333333333333333 (pow a 2.0))))))
t_0))))
double code(double x, double y, double z, double a) {
double t_0 = -1.0 * (x * -1.0);
double tmp;
if (tan(a) <= -0.02) {
tmp = t_0;
} else if (tan(a) <= 0.05) {
tmp = x + (tan((y + z)) - (a * (1.0 + (0.3333333333333333 * pow(a, 2.0)))));
} 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 = (-1.0d0) * (x * (-1.0d0))
if (tan(a) <= (-0.02d0)) then
tmp = t_0
else if (tan(a) <= 0.05d0) then
tmp = x + (tan((y + z)) - (a * (1.0d0 + (0.3333333333333333d0 * (a ** 2.0d0)))))
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 = -1.0 * (x * -1.0);
double tmp;
if (Math.tan(a) <= -0.02) {
tmp = t_0;
} else if (Math.tan(a) <= 0.05) {
tmp = x + (Math.tan((y + z)) - (a * (1.0 + (0.3333333333333333 * Math.pow(a, 2.0)))));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z, a): t_0 = -1.0 * (x * -1.0) tmp = 0 if math.tan(a) <= -0.02: tmp = t_0 elif math.tan(a) <= 0.05: tmp = x + (math.tan((y + z)) - (a * (1.0 + (0.3333333333333333 * math.pow(a, 2.0))))) else: tmp = t_0 return tmp
function code(x, y, z, a) t_0 = Float64(-1.0 * Float64(x * -1.0)) tmp = 0.0 if (tan(a) <= -0.02) tmp = t_0; elseif (tan(a) <= 0.05) tmp = Float64(x + Float64(tan(Float64(y + z)) - Float64(a * Float64(1.0 + Float64(0.3333333333333333 * (a ^ 2.0)))))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z, a) t_0 = -1.0 * (x * -1.0); tmp = 0.0; if (tan(a) <= -0.02) tmp = t_0; elseif (tan(a) <= 0.05) tmp = x + (tan((y + z)) - (a * (1.0 + (0.3333333333333333 * (a ^ 2.0))))); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[(-1.0 * N[(x * -1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Tan[a], $MachinePrecision], -0.02], t$95$0, If[LessEqual[N[Tan[a], $MachinePrecision], 0.05], N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[(a * N[(1.0 + N[(0.3333333333333333 * N[Power[a, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -1 \cdot \left(x \cdot -1\right)\\
\mathbf{if}\;\tan a \leq -0.02:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\tan a \leq 0.05:\\
\;\;\;\;x + \left(\tan \left(y + z\right) - a \cdot \left(1 + 0.3333333333333333 \cdot {a}^{2}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (tan.f64 a) < -0.0200000000000000004 or 0.050000000000000003 < (tan.f64 a) Initial program 79.4%
Taylor expanded in x around -inf
Applied rewrites79.2%
Taylor expanded in x around inf
Applied rewrites31.7%
if -0.0200000000000000004 < (tan.f64 a) < 0.050000000000000003Initial program 79.4%
Taylor expanded in a around 0
Applied rewrites39.8%
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (* -1.0 (* x -1.0))))
(if (<= (tan a) -0.02)
t_0
(if (<= (tan a) 0.05) (+ x (- (tan (+ y z)) a)) t_0))))
double code(double x, double y, double z, double a) {
double t_0 = -1.0 * (x * -1.0);
double tmp;
if (tan(a) <= -0.02) {
tmp = t_0;
} else if (tan(a) <= 0.05) {
tmp = x + (tan((y + z)) - 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 = (-1.0d0) * (x * (-1.0d0))
if (tan(a) <= (-0.02d0)) then
tmp = t_0
else if (tan(a) <= 0.05d0) then
tmp = x + (tan((y + z)) - 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 = -1.0 * (x * -1.0);
double tmp;
if (Math.tan(a) <= -0.02) {
tmp = t_0;
} else if (Math.tan(a) <= 0.05) {
tmp = x + (Math.tan((y + z)) - a);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z, a): t_0 = -1.0 * (x * -1.0) tmp = 0 if math.tan(a) <= -0.02: tmp = t_0 elif math.tan(a) <= 0.05: tmp = x + (math.tan((y + z)) - a) else: tmp = t_0 return tmp
function code(x, y, z, a) t_0 = Float64(-1.0 * Float64(x * -1.0)) tmp = 0.0 if (tan(a) <= -0.02) tmp = t_0; elseif (tan(a) <= 0.05) tmp = Float64(x + Float64(tan(Float64(y + z)) - a)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z, a) t_0 = -1.0 * (x * -1.0); tmp = 0.0; if (tan(a) <= -0.02) tmp = t_0; elseif (tan(a) <= 0.05) tmp = x + (tan((y + z)) - a); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[(-1.0 * N[(x * -1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Tan[a], $MachinePrecision], -0.02], t$95$0, If[LessEqual[N[Tan[a], $MachinePrecision], 0.05], N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -1 \cdot \left(x \cdot -1\right)\\
\mathbf{if}\;\tan a \leq -0.02:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\tan a \leq 0.05:\\
\;\;\;\;x + \left(\tan \left(y + z\right) - a\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (tan.f64 a) < -0.0200000000000000004 or 0.050000000000000003 < (tan.f64 a) Initial program 79.4%
Taylor expanded in x around -inf
Applied rewrites79.2%
Taylor expanded in x around inf
Applied rewrites31.7%
if -0.0200000000000000004 < (tan.f64 a) < 0.050000000000000003Initial program 79.4%
Taylor expanded in a around 0
Applied rewrites40.2%
(FPCore (x y z a) :precision binary64 (let* ((t_0 (* -1.0 (* x -1.0)))) (if (<= (tan a) -0.02) t_0 (if (<= (tan a) 0.05) (+ x (- (tan z) a)) t_0))))
double code(double x, double y, double z, double a) {
double t_0 = -1.0 * (x * -1.0);
double tmp;
if (tan(a) <= -0.02) {
tmp = t_0;
} else if (tan(a) <= 0.05) {
tmp = x + (tan(z) - 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 = (-1.0d0) * (x * (-1.0d0))
if (tan(a) <= (-0.02d0)) then
tmp = t_0
else if (tan(a) <= 0.05d0) then
tmp = x + (tan(z) - 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 = -1.0 * (x * -1.0);
double tmp;
if (Math.tan(a) <= -0.02) {
tmp = t_0;
} else if (Math.tan(a) <= 0.05) {
tmp = x + (Math.tan(z) - a);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z, a): t_0 = -1.0 * (x * -1.0) tmp = 0 if math.tan(a) <= -0.02: tmp = t_0 elif math.tan(a) <= 0.05: tmp = x + (math.tan(z) - a) else: tmp = t_0 return tmp
function code(x, y, z, a) t_0 = Float64(-1.0 * Float64(x * -1.0)) tmp = 0.0 if (tan(a) <= -0.02) tmp = t_0; elseif (tan(a) <= 0.05) tmp = Float64(x + Float64(tan(z) - a)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z, a) t_0 = -1.0 * (x * -1.0); tmp = 0.0; if (tan(a) <= -0.02) tmp = t_0; elseif (tan(a) <= 0.05) tmp = x + (tan(z) - a); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[(-1.0 * N[(x * -1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Tan[a], $MachinePrecision], -0.02], t$95$0, If[LessEqual[N[Tan[a], $MachinePrecision], 0.05], N[(x + N[(N[Tan[z], $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -1 \cdot \left(x \cdot -1\right)\\
\mathbf{if}\;\tan a \leq -0.02:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\tan a \leq 0.05:\\
\;\;\;\;x + \left(\tan z - a\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (tan.f64 a) < -0.0200000000000000004 or 0.050000000000000003 < (tan.f64 a) Initial program 79.4%
Taylor expanded in x around -inf
Applied rewrites79.2%
Taylor expanded in x around inf
Applied rewrites31.7%
if -0.0200000000000000004 < (tan.f64 a) < 0.050000000000000003Initial program 79.4%
Taylor expanded in a around 0
Applied rewrites40.2%
Taylor expanded in y around 0
Applied rewrites31.0%
(FPCore (x y z a) :precision binary64 (* -1.0 (* x -1.0)))
double code(double x, double y, double z, double a) {
return -1.0 * (x * -1.0);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
code = (-1.0d0) * (x * (-1.0d0))
end function
public static double code(double x, double y, double z, double a) {
return -1.0 * (x * -1.0);
}
def code(x, y, z, a): return -1.0 * (x * -1.0)
function code(x, y, z, a) return Float64(-1.0 * Float64(x * -1.0)) end
function tmp = code(x, y, z, a) tmp = -1.0 * (x * -1.0); end
code[x_, y_, z_, a_] := N[(-1.0 * N[(x * -1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-1 \cdot \left(x \cdot -1\right)
\end{array}
Initial program 79.4%
Taylor expanded in x around -inf
Applied rewrites79.2%
Taylor expanded in x around inf
Applied rewrites31.7%
herbie shell --seed 2025153
(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))))