
(FPCore (x y) :precision binary64 (let* ((t_0 (/ x (* y 2.0)))) (/ (tan t_0) (sin t_0))))
double code(double x, double y) {
double t_0 = x / (y * 2.0);
return tan(t_0) / sin(t_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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
t_0 = x / (y * 2.0d0)
code = tan(t_0) / sin(t_0)
end function
public static double code(double x, double y) {
double t_0 = x / (y * 2.0);
return Math.tan(t_0) / Math.sin(t_0);
}
def code(x, y): t_0 = x / (y * 2.0) return math.tan(t_0) / math.sin(t_0)
function code(x, y) t_0 = Float64(x / Float64(y * 2.0)) return Float64(tan(t_0) / sin(t_0)) end
function tmp = code(x, y) t_0 = x / (y * 2.0); tmp = tan(t_0) / sin(t_0); end
code[x_, y_] := Block[{t$95$0 = N[(x / N[(y * 2.0), $MachinePrecision]), $MachinePrecision]}, N[(N[Tan[t$95$0], $MachinePrecision] / N[Sin[t$95$0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{y \cdot 2}\\
\frac{\tan t\_0}{\sin t\_0}
\end{array}
\end{array}
Herbie found 6 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (let* ((t_0 (/ x (* y 2.0)))) (/ (tan t_0) (sin t_0))))
double code(double x, double y) {
double t_0 = x / (y * 2.0);
return tan(t_0) / sin(t_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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
t_0 = x / (y * 2.0d0)
code = tan(t_0) / sin(t_0)
end function
public static double code(double x, double y) {
double t_0 = x / (y * 2.0);
return Math.tan(t_0) / Math.sin(t_0);
}
def code(x, y): t_0 = x / (y * 2.0) return math.tan(t_0) / math.sin(t_0)
function code(x, y) t_0 = Float64(x / Float64(y * 2.0)) return Float64(tan(t_0) / sin(t_0)) end
function tmp = code(x, y) t_0 = x / (y * 2.0); tmp = tan(t_0) / sin(t_0); end
code[x_, y_] := Block[{t$95$0 = N[(x / N[(y * 2.0), $MachinePrecision]), $MachinePrecision]}, N[(N[Tan[t$95$0], $MachinePrecision] / N[Sin[t$95$0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{y \cdot 2}\\
\frac{\tan t\_0}{\sin t\_0}
\end{array}
\end{array}
x_m = (fabs.f64 x)
y_m = (fabs.f64 y)
(FPCore (x_m y_m)
:precision binary64
(let* ((t_0 (* 0.5 (cos (* 2.0 (+ PI PI))))))
(if (<= (/ x_m (* y_m 2.0)) 5e+148)
(/ 1.0 (sin (+ (- (* (/ x_m y_m) 0.5)) (/ PI 2.0))))
(/
(*
2.0
(fma
(* y_m x_m)
(- (/ 0.5 y_m) (* (/ (- 0.5 t_0) (* (+ 0.5 t_0) y_m)) -0.5))
(* y_m (tan (+ PI PI)))))
x_m))))x_m = fabs(x);
y_m = fabs(y);
double code(double x_m, double y_m) {
double t_0 = 0.5 * cos((2.0 * (((double) M_PI) + ((double) M_PI))));
double tmp;
if ((x_m / (y_m * 2.0)) <= 5e+148) {
tmp = 1.0 / sin((-((x_m / y_m) * 0.5) + (((double) M_PI) / 2.0)));
} else {
tmp = (2.0 * fma((y_m * x_m), ((0.5 / y_m) - (((0.5 - t_0) / ((0.5 + t_0) * y_m)) * -0.5)), (y_m * tan((((double) M_PI) + ((double) M_PI)))))) / x_m;
}
return tmp;
}
x_m = abs(x) y_m = abs(y) function code(x_m, y_m) t_0 = Float64(0.5 * cos(Float64(2.0 * Float64(pi + pi)))) tmp = 0.0 if (Float64(x_m / Float64(y_m * 2.0)) <= 5e+148) tmp = Float64(1.0 / sin(Float64(Float64(-Float64(Float64(x_m / y_m) * 0.5)) + Float64(pi / 2.0)))); else tmp = Float64(Float64(2.0 * fma(Float64(y_m * x_m), Float64(Float64(0.5 / y_m) - Float64(Float64(Float64(0.5 - t_0) / Float64(Float64(0.5 + t_0) * y_m)) * -0.5)), Float64(y_m * tan(Float64(pi + pi))))) / x_m); end return tmp end
x_m = N[Abs[x], $MachinePrecision]
y_m = N[Abs[y], $MachinePrecision]
code[x$95$m_, y$95$m_] := Block[{t$95$0 = N[(0.5 * N[Cos[N[(2.0 * N[(Pi + Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x$95$m / N[(y$95$m * 2.0), $MachinePrecision]), $MachinePrecision], 5e+148], N[(1.0 / N[Sin[N[((-N[(N[(x$95$m / y$95$m), $MachinePrecision] * 0.5), $MachinePrecision]) + N[(Pi / 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * N[(N[(y$95$m * x$95$m), $MachinePrecision] * N[(N[(0.5 / y$95$m), $MachinePrecision] - N[(N[(N[(0.5 - t$95$0), $MachinePrecision] / N[(N[(0.5 + t$95$0), $MachinePrecision] * y$95$m), $MachinePrecision]), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision] + N[(y$95$m * N[Tan[N[(Pi + Pi), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x$95$m), $MachinePrecision]]]
\begin{array}{l}
x_m = \left|x\right|
\\
y_m = \left|y\right|
\\
\begin{array}{l}
t_0 := 0.5 \cdot \cos \left(2 \cdot \left(\pi + \pi\right)\right)\\
\mathbf{if}\;\frac{x\_m}{y\_m \cdot 2} \leq 5 \cdot 10^{+148}:\\
\;\;\;\;\frac{1}{\sin \left(\left(-\frac{x\_m}{y\_m} \cdot 0.5\right) + \frac{\pi}{2}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot \mathsf{fma}\left(y\_m \cdot x\_m, \frac{0.5}{y\_m} - \frac{0.5 - t\_0}{\left(0.5 + t\_0\right) \cdot y\_m} \cdot -0.5, y\_m \cdot \tan \left(\pi + \pi\right)\right)}{x\_m}\\
\end{array}
\end{array}
if (/.f64 x (*.f64 y #s(literal 2 binary64))) < 5.00000000000000024e148Initial program 43.7%
Taylor expanded in x around inf
lower-/.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6454.7
Applied rewrites54.7%
lift-/.f64N/A
lower-*.f64N/A
associate-*l/N/A
associate-*r/N/A
mult-flip-revN/A
*-commutativeN/A
lower-*.f64N/A
mult-flip-revN/A
lift-/.f6454.7
Applied rewrites54.7%
lift-cos.f64N/A
lift-*.f64N/A
lift-/.f64N/A
cos-neg-revN/A
associate-*l/N/A
associate-*r/N/A
sin-+PI/2-revN/A
lower-sin.f64N/A
lower-+.f64N/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lift-PI.f6454.6
Applied rewrites54.6%
if 5.00000000000000024e148 < (/.f64 x (*.f64 y #s(literal 2 binary64))) Initial program 43.7%
lift-tan.f64N/A
tan-+PI-revN/A
tan-+PI-revN/A
lower-tan.f64N/A
lower-+.f64N/A
lift-*.f64N/A
lift-/.f64N/A
mult-flipN/A
metadata-evalN/A
times-fracN/A
metadata-evalN/A
*-commutativeN/A
lower-fma.f64N/A
mult-flip-revN/A
lower-/.f64N/A
lower-PI.f64N/A
lower-PI.f647.2
Applied rewrites7.2%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
quot-tanN/A
count-2-revN/A
tan-+PI-revN/A
tan-PI2.8
Applied rewrites2.8%
Taylor expanded in x around 0
Applied rewrites6.1%
x_m = (fabs.f64 x) y_m = (fabs.f64 y) (FPCore (x_m y_m) :precision binary64 (if (<= (/ x_m (* y_m 2.0)) 1e+148) (/ 1.0 (sin (+ (- (* (/ x_m y_m) 0.5)) (/ PI 2.0)))) (+ 0.0 (* y_m (* (/ (fma 0.5 x_m (* (* 0.0 x_m) 0.5)) (* y_m x_m)) 2.0)))))
x_m = fabs(x);
y_m = fabs(y);
double code(double x_m, double y_m) {
double tmp;
if ((x_m / (y_m * 2.0)) <= 1e+148) {
tmp = 1.0 / sin((-((x_m / y_m) * 0.5) + (((double) M_PI) / 2.0)));
} else {
tmp = 0.0 + (y_m * ((fma(0.5, x_m, ((0.0 * x_m) * 0.5)) / (y_m * x_m)) * 2.0));
}
return tmp;
}
x_m = abs(x) y_m = abs(y) function code(x_m, y_m) tmp = 0.0 if (Float64(x_m / Float64(y_m * 2.0)) <= 1e+148) tmp = Float64(1.0 / sin(Float64(Float64(-Float64(Float64(x_m / y_m) * 0.5)) + Float64(pi / 2.0)))); else tmp = Float64(0.0 + Float64(y_m * Float64(Float64(fma(0.5, x_m, Float64(Float64(0.0 * x_m) * 0.5)) / Float64(y_m * x_m)) * 2.0))); end return tmp end
x_m = N[Abs[x], $MachinePrecision] y_m = N[Abs[y], $MachinePrecision] code[x$95$m_, y$95$m_] := If[LessEqual[N[(x$95$m / N[(y$95$m * 2.0), $MachinePrecision]), $MachinePrecision], 1e+148], N[(1.0 / N[Sin[N[((-N[(N[(x$95$m / y$95$m), $MachinePrecision] * 0.5), $MachinePrecision]) + N[(Pi / 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(0.0 + N[(y$95$m * N[(N[(N[(0.5 * x$95$m + N[(N[(0.0 * x$95$m), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision] / N[(y$95$m * x$95$m), $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;\frac{x\_m}{y\_m \cdot 2} \leq 10^{+148}:\\
\;\;\;\;\frac{1}{\sin \left(\left(-\frac{x\_m}{y\_m} \cdot 0.5\right) + \frac{\pi}{2}\right)}\\
\mathbf{else}:\\
\;\;\;\;0 + y\_m \cdot \left(\frac{\mathsf{fma}\left(0.5, x\_m, \left(0 \cdot x\_m\right) \cdot 0.5\right)}{y\_m \cdot x\_m} \cdot 2\right)\\
\end{array}
\end{array}
if (/.f64 x (*.f64 y #s(literal 2 binary64))) < 1e148Initial program 43.7%
Taylor expanded in x around inf
lower-/.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6454.7
Applied rewrites54.7%
lift-/.f64N/A
lower-*.f64N/A
associate-*l/N/A
associate-*r/N/A
mult-flip-revN/A
*-commutativeN/A
lower-*.f64N/A
mult-flip-revN/A
lift-/.f6454.7
Applied rewrites54.7%
lift-cos.f64N/A
lift-*.f64N/A
lift-/.f64N/A
cos-neg-revN/A
associate-*l/N/A
associate-*r/N/A
sin-+PI/2-revN/A
lower-sin.f64N/A
lower-+.f64N/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lift-PI.f6454.6
Applied rewrites54.6%
if 1e148 < (/.f64 x (*.f64 y #s(literal 2 binary64))) Initial program 43.7%
lift-tan.f64N/A
tan-+PI-revN/A
tan-+PI-revN/A
lower-tan.f64N/A
lower-+.f64N/A
lift-*.f64N/A
lift-/.f64N/A
mult-flipN/A
metadata-evalN/A
times-fracN/A
metadata-evalN/A
*-commutativeN/A
lower-fma.f64N/A
mult-flip-revN/A
lower-/.f64N/A
lower-PI.f64N/A
lower-PI.f647.2
Applied rewrites7.2%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
quot-tanN/A
count-2-revN/A
tan-+PI-revN/A
tan-PI2.8
Applied rewrites2.8%
Taylor expanded in x around 0
Applied rewrites3.1%
Taylor expanded in y around inf
Applied rewrites42.0%
x_m = (fabs.f64 x) y_m = (fabs.f64 y) (FPCore (x_m y_m) :precision binary64 (if (<= (/ x_m (* y_m 2.0)) 2e+17) (/ 1.0 (sin (fma (/ 0.5 y_m) x_m (/ PI 2.0)))) 1.0))
x_m = fabs(x);
y_m = fabs(y);
double code(double x_m, double y_m) {
double tmp;
if ((x_m / (y_m * 2.0)) <= 2e+17) {
tmp = 1.0 / sin(fma((0.5 / y_m), x_m, (((double) M_PI) / 2.0)));
} else {
tmp = 1.0;
}
return tmp;
}
x_m = abs(x) y_m = abs(y) function code(x_m, y_m) tmp = 0.0 if (Float64(x_m / Float64(y_m * 2.0)) <= 2e+17) tmp = Float64(1.0 / sin(fma(Float64(0.5 / y_m), x_m, Float64(pi / 2.0)))); else tmp = 1.0; end return tmp end
x_m = N[Abs[x], $MachinePrecision] y_m = N[Abs[y], $MachinePrecision] code[x$95$m_, y$95$m_] := If[LessEqual[N[(x$95$m / N[(y$95$m * 2.0), $MachinePrecision]), $MachinePrecision], 2e+17], N[(1.0 / N[Sin[N[(N[(0.5 / y$95$m), $MachinePrecision] * x$95$m + N[(Pi / 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 1.0]
\begin{array}{l}
x_m = \left|x\right|
\\
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;\frac{x\_m}{y\_m \cdot 2} \leq 2 \cdot 10^{+17}:\\
\;\;\;\;\frac{1}{\sin \left(\mathsf{fma}\left(\frac{0.5}{y\_m}, x\_m, \frac{\pi}{2}\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if (/.f64 x (*.f64 y #s(literal 2 binary64))) < 2e17Initial program 43.7%
Taylor expanded in x around inf
lower-/.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6454.7
Applied rewrites54.7%
lift-cos.f64N/A
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
sin-+PI/2-revN/A
lower-sin.f64N/A
associate-*r/N/A
associate-*l/N/A
mult-flip-revN/A
lower-fma.f64N/A
mult-flip-revN/A
lift-/.f64N/A
lower-/.f64N/A
lift-PI.f6454.8
Applied rewrites54.8%
if 2e17 < (/.f64 x (*.f64 y #s(literal 2 binary64))) Initial program 43.7%
Taylor expanded in x around 0
Applied rewrites54.7%
x_m = (fabs.f64 x) y_m = (fabs.f64 y) (FPCore (x_m y_m) :precision binary64 (if (<= (/ x_m (* y_m 2.0)) 1e+29) (/ 1.0 (cos (* (/ 0.5 y_m) x_m))) 1.0))
x_m = fabs(x);
y_m = fabs(y);
double code(double x_m, double y_m) {
double tmp;
if ((x_m / (y_m * 2.0)) <= 1e+29) {
tmp = 1.0 / cos(((0.5 / y_m) * x_m));
} else {
tmp = 1.0;
}
return tmp;
}
x_m = private
y_m = private
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_m, y_m)
use fmin_fmax_functions
real(8), intent (in) :: x_m
real(8), intent (in) :: y_m
real(8) :: tmp
if ((x_m / (y_m * 2.0d0)) <= 1d+29) then
tmp = 1.0d0 / cos(((0.5d0 / y_m) * x_m))
else
tmp = 1.0d0
end if
code = tmp
end function
x_m = Math.abs(x);
y_m = Math.abs(y);
public static double code(double x_m, double y_m) {
double tmp;
if ((x_m / (y_m * 2.0)) <= 1e+29) {
tmp = 1.0 / Math.cos(((0.5 / y_m) * x_m));
} else {
tmp = 1.0;
}
return tmp;
}
x_m = math.fabs(x) y_m = math.fabs(y) def code(x_m, y_m): tmp = 0 if (x_m / (y_m * 2.0)) <= 1e+29: tmp = 1.0 / math.cos(((0.5 / y_m) * x_m)) else: tmp = 1.0 return tmp
x_m = abs(x) y_m = abs(y) function code(x_m, y_m) tmp = 0.0 if (Float64(x_m / Float64(y_m * 2.0)) <= 1e+29) tmp = Float64(1.0 / cos(Float64(Float64(0.5 / y_m) * x_m))); else tmp = 1.0; end return tmp end
x_m = abs(x); y_m = abs(y); function tmp_2 = code(x_m, y_m) tmp = 0.0; if ((x_m / (y_m * 2.0)) <= 1e+29) tmp = 1.0 / cos(((0.5 / y_m) * x_m)); else tmp = 1.0; end tmp_2 = tmp; end
x_m = N[Abs[x], $MachinePrecision] y_m = N[Abs[y], $MachinePrecision] code[x$95$m_, y$95$m_] := If[LessEqual[N[(x$95$m / N[(y$95$m * 2.0), $MachinePrecision]), $MachinePrecision], 1e+29], N[(1.0 / N[Cos[N[(N[(0.5 / y$95$m), $MachinePrecision] * x$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 1.0]
\begin{array}{l}
x_m = \left|x\right|
\\
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;\frac{x\_m}{y\_m \cdot 2} \leq 10^{+29}:\\
\;\;\;\;\frac{1}{\cos \left(\frac{0.5}{y\_m} \cdot x\_m\right)}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if (/.f64 x (*.f64 y #s(literal 2 binary64))) < 9.99999999999999914e28Initial program 43.7%
Taylor expanded in x around inf
lower-/.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6454.7
Applied rewrites54.7%
lift-/.f64N/A
lower-*.f64N/A
associate-*l/N/A
associate-*r/N/A
mult-flip-revN/A
*-commutativeN/A
lower-*.f64N/A
mult-flip-revN/A
lift-/.f6454.7
Applied rewrites54.7%
if 9.99999999999999914e28 < (/.f64 x (*.f64 y #s(literal 2 binary64))) Initial program 43.7%
Taylor expanded in x around 0
Applied rewrites54.7%
x_m = (fabs.f64 x) y_m = (fabs.f64 y) (FPCore (x_m y_m) :precision binary64 1.0)
x_m = fabs(x);
y_m = fabs(y);
double code(double x_m, double y_m) {
return 1.0;
}
x_m = private
y_m = private
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_m, y_m)
use fmin_fmax_functions
real(8), intent (in) :: x_m
real(8), intent (in) :: y_m
code = 1.0d0
end function
x_m = Math.abs(x);
y_m = Math.abs(y);
public static double code(double x_m, double y_m) {
return 1.0;
}
x_m = math.fabs(x) y_m = math.fabs(y) def code(x_m, y_m): return 1.0
x_m = abs(x) y_m = abs(y) function code(x_m, y_m) return 1.0 end
x_m = abs(x); y_m = abs(y); function tmp = code(x_m, y_m) tmp = 1.0; end
x_m = N[Abs[x], $MachinePrecision] y_m = N[Abs[y], $MachinePrecision] code[x$95$m_, y$95$m_] := 1.0
\begin{array}{l}
x_m = \left|x\right|
\\
y_m = \left|y\right|
\\
1
\end{array}
Initial program 43.7%
Taylor expanded in x around 0
Applied rewrites54.7%
x_m = (fabs.f64 x) y_m = (fabs.f64 y) (FPCore (x_m y_m) :precision binary64 0.0)
x_m = fabs(x);
y_m = fabs(y);
double code(double x_m, double y_m) {
return 0.0;
}
x_m = private
y_m = private
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_m, y_m)
use fmin_fmax_functions
real(8), intent (in) :: x_m
real(8), intent (in) :: y_m
code = 0.0d0
end function
x_m = Math.abs(x);
y_m = Math.abs(y);
public static double code(double x_m, double y_m) {
return 0.0;
}
x_m = math.fabs(x) y_m = math.fabs(y) def code(x_m, y_m): return 0.0
x_m = abs(x) y_m = abs(y) function code(x_m, y_m) return 0.0 end
x_m = abs(x); y_m = abs(y); function tmp = code(x_m, y_m) tmp = 0.0; end
x_m = N[Abs[x], $MachinePrecision] y_m = N[Abs[y], $MachinePrecision] code[x$95$m_, y$95$m_] := 0.0
\begin{array}{l}
x_m = \left|x\right|
\\
y_m = \left|y\right|
\\
0
\end{array}
Initial program 43.7%
lift-tan.f64N/A
tan-+PI-revN/A
tan-+PI-revN/A
lower-tan.f64N/A
lower-+.f64N/A
lift-*.f64N/A
lift-/.f64N/A
mult-flipN/A
metadata-evalN/A
times-fracN/A
metadata-evalN/A
*-commutativeN/A
lower-fma.f64N/A
mult-flip-revN/A
lower-/.f64N/A
lower-PI.f64N/A
lower-PI.f647.2
Applied rewrites7.2%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
quot-tanN/A
count-2-revN/A
tan-+PI-revN/A
tan-PI2.8
Applied rewrites2.8%
Taylor expanded in x around 0
Applied rewrites3.1%
herbie shell --seed 2025134
(FPCore (x y)
:name "Diagrams.TwoD.Layout.CirclePacking:approxRadius from diagrams-contrib-1.3.0.5"
:precision binary64
(/ (tan (/ x (* y 2.0))) (sin (/ x (* y 2.0)))))