
(FPCore (x y z) :precision binary64 (/ (* (cosh x) (/ y x)) z))
double code(double x, double y, double z) {
return (cosh(x) * (y / x)) / 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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (cosh(x) * (y / x)) / z
end function
public static double code(double x, double y, double z) {
return (Math.cosh(x) * (y / x)) / z;
}
def code(x, y, z): return (math.cosh(x) * (y / x)) / z
function code(x, y, z) return Float64(Float64(cosh(x) * Float64(y / x)) / z) end
function tmp = code(x, y, z) tmp = (cosh(x) * (y / x)) / z; end
code[x_, y_, z_] := N[(N[(N[Cosh[x], $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{\cosh x \cdot \frac{y}{x}}{z}
\end{array}
Herbie found 5 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (/ (* (cosh x) (/ y x)) z))
double code(double x, double y, double z) {
return (cosh(x) * (y / x)) / 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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (cosh(x) * (y / x)) / z
end function
public static double code(double x, double y, double z) {
return (Math.cosh(x) * (y / x)) / z;
}
def code(x, y, z): return (math.cosh(x) * (y / x)) / z
function code(x, y, z) return Float64(Float64(cosh(x) * Float64(y / x)) / z) end
function tmp = code(x, y, z) tmp = (cosh(x) * (y / x)) / z; end
code[x_, y_, z_] := N[(N[(N[Cosh[x], $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{\cosh x \cdot \frac{y}{x}}{z}
\end{array}
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x_s x_m y_m z)
:precision binary64
(let* ((t_0 (* (cosh x_m) (/ y_m x_m))))
(*
y_s
(*
x_s
(if (<= t_0 5e+275)
(/ t_0 z)
(/ (* (/ (/ (* 2.0 (cosh x_m)) x_m) z) y_m) 2.0))))))x\_m = fabs(x);
x\_s = copysign(1.0, x);
y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x_s, double x_m, double y_m, double z) {
double t_0 = cosh(x_m) * (y_m / x_m);
double tmp;
if (t_0 <= 5e+275) {
tmp = t_0 / z;
} else {
tmp = ((((2.0 * cosh(x_m)) / x_m) / z) * y_m) / 2.0;
}
return y_s * (x_s * tmp);
}
x\_m = private
x\_s = private
y\_m = private
y\_s = 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(y_s, x_s, x_m, y_m, z)
use fmin_fmax_functions
real(8), intent (in) :: y_s
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = cosh(x_m) * (y_m / x_m)
if (t_0 <= 5d+275) then
tmp = t_0 / z
else
tmp = ((((2.0d0 * cosh(x_m)) / x_m) / z) * y_m) / 2.0d0
end if
code = y_s * (x_s * tmp)
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
public static double code(double y_s, double x_s, double x_m, double y_m, double z) {
double t_0 = Math.cosh(x_m) * (y_m / x_m);
double tmp;
if (t_0 <= 5e+275) {
tmp = t_0 / z;
} else {
tmp = ((((2.0 * Math.cosh(x_m)) / x_m) / z) * y_m) / 2.0;
}
return y_s * (x_s * tmp);
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) def code(y_s, x_s, x_m, y_m, z): t_0 = math.cosh(x_m) * (y_m / x_m) tmp = 0 if t_0 <= 5e+275: tmp = t_0 / z else: tmp = ((((2.0 * math.cosh(x_m)) / x_m) / z) * y_m) / 2.0 return y_s * (x_s * tmp)
x\_m = abs(x) x\_s = copysign(1.0, x) y\_m = abs(y) y\_s = copysign(1.0, y) function code(y_s, x_s, x_m, y_m, z) t_0 = Float64(cosh(x_m) * Float64(y_m / x_m)) tmp = 0.0 if (t_0 <= 5e+275) tmp = Float64(t_0 / z); else tmp = Float64(Float64(Float64(Float64(Float64(2.0 * cosh(x_m)) / x_m) / z) * y_m) / 2.0); end return Float64(y_s * Float64(x_s * tmp)) end
x\_m = abs(x); x\_s = sign(x) * abs(1.0); y\_m = abs(y); y\_s = sign(y) * abs(1.0); function tmp_2 = code(y_s, x_s, x_m, y_m, z) t_0 = cosh(x_m) * (y_m / x_m); tmp = 0.0; if (t_0 <= 5e+275) tmp = t_0 / z; else tmp = ((((2.0 * cosh(x_m)) / x_m) / z) * y_m) / 2.0; end tmp_2 = y_s * (x_s * tmp); end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x$95$s_, x$95$m_, y$95$m_, z_] := Block[{t$95$0 = N[(N[Cosh[x$95$m], $MachinePrecision] * N[(y$95$m / x$95$m), $MachinePrecision]), $MachinePrecision]}, N[(y$95$s * N[(x$95$s * If[LessEqual[t$95$0, 5e+275], N[(t$95$0 / z), $MachinePrecision], N[(N[(N[(N[(N[(2.0 * N[Cosh[x$95$m], $MachinePrecision]), $MachinePrecision] / x$95$m), $MachinePrecision] / z), $MachinePrecision] * y$95$m), $MachinePrecision] / 2.0), $MachinePrecision]]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
\begin{array}{l}
t_0 := \cosh x\_m \cdot \frac{y\_m}{x\_m}\\
y\_s \cdot \left(x\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_0 \leq 5 \cdot 10^{+275}:\\
\;\;\;\;\frac{t\_0}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{2 \cdot \cosh x\_m}{x\_m}}{z} \cdot y\_m}{2}\\
\end{array}\right)
\end{array}
\end{array}
if (*.f64 (cosh.f64 x) (/.f64 y x)) < 5.0000000000000003e275Initial program 99.7%
if 5.0000000000000003e275 < (*.f64 (cosh.f64 x) (/.f64 y x)) Initial program 76.3%
lift-/.f64N/A
lift-*.f64N/A
lift-cosh.f64N/A
lift-/.f64N/A
associate-/l*N/A
cosh-defN/A
rec-expN/A
associate-/r*N/A
associate-*l/N/A
associate-/l*N/A
*-commutativeN/A
lower-/.f64N/A
Applied rewrites99.9%
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x_s x_m y_m z)
:precision binary64
(*
y_s
(*
x_s
(if (<= x_m 1.1e+93)
(/ (* (* 2.0 (cosh x_m)) y_m) (* 2.0 (* z x_m)))
(fma
(fma
(*
(fma
0.001388888888888889
(/ (* (* x_m x_m) y_m) z)
(* 0.041666666666666664 (/ y_m z)))
x_m)
x_m
(* (/ y_m z) 0.5))
(/ (* x_m x_m) x_m)
(/ (/ y_m z) x_m))))))x\_m = fabs(x);
x\_s = copysign(1.0, x);
y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x_s, double x_m, double y_m, double z) {
double tmp;
if (x_m <= 1.1e+93) {
tmp = ((2.0 * cosh(x_m)) * y_m) / (2.0 * (z * x_m));
} else {
tmp = fma(fma((fma(0.001388888888888889, (((x_m * x_m) * y_m) / z), (0.041666666666666664 * (y_m / z))) * x_m), x_m, ((y_m / z) * 0.5)), ((x_m * x_m) / x_m), ((y_m / z) / x_m));
}
return y_s * (x_s * tmp);
}
x\_m = abs(x) x\_s = copysign(1.0, x) y\_m = abs(y) y\_s = copysign(1.0, y) function code(y_s, x_s, x_m, y_m, z) tmp = 0.0 if (x_m <= 1.1e+93) tmp = Float64(Float64(Float64(2.0 * cosh(x_m)) * y_m) / Float64(2.0 * Float64(z * x_m))); else tmp = fma(fma(Float64(fma(0.001388888888888889, Float64(Float64(Float64(x_m * x_m) * y_m) / z), Float64(0.041666666666666664 * Float64(y_m / z))) * x_m), x_m, Float64(Float64(y_m / z) * 0.5)), Float64(Float64(x_m * x_m) / x_m), Float64(Float64(y_m / z) / x_m)); end return Float64(y_s * Float64(x_s * tmp)) end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x$95$s_, x$95$m_, y$95$m_, z_] := N[(y$95$s * N[(x$95$s * If[LessEqual[x$95$m, 1.1e+93], N[(N[(N[(2.0 * N[Cosh[x$95$m], $MachinePrecision]), $MachinePrecision] * y$95$m), $MachinePrecision] / N[(2.0 * N[(z * x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(0.001388888888888889 * N[(N[(N[(x$95$m * x$95$m), $MachinePrecision] * y$95$m), $MachinePrecision] / z), $MachinePrecision] + N[(0.041666666666666664 * N[(y$95$m / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * x$95$m), $MachinePrecision] * x$95$m + N[(N[(y$95$m / z), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision] * N[(N[(x$95$m * x$95$m), $MachinePrecision] / x$95$m), $MachinePrecision] + N[(N[(y$95$m / z), $MachinePrecision] / x$95$m), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
y\_s \cdot \left(x\_s \cdot \begin{array}{l}
\mathbf{if}\;x\_m \leq 1.1 \cdot 10^{+93}:\\
\;\;\;\;\frac{\left(2 \cdot \cosh x\_m\right) \cdot y\_m}{2 \cdot \left(z \cdot x\_m\right)}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.001388888888888889, \frac{\left(x\_m \cdot x\_m\right) \cdot y\_m}{z}, 0.041666666666666664 \cdot \frac{y\_m}{z}\right) \cdot x\_m, x\_m, \frac{y\_m}{z} \cdot 0.5\right), \frac{x\_m \cdot x\_m}{x\_m}, \frac{\frac{y\_m}{z}}{x\_m}\right)\\
\end{array}\right)
\end{array}
if x < 1.10000000000000011e93Initial program 91.9%
lift-/.f64N/A
lift-*.f64N/A
lift-cosh.f64N/A
lift-/.f64N/A
associate-/l*N/A
cosh-defN/A
rec-expN/A
associate-/r*N/A
frac-timesN/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
rec-expN/A
cosh-undefN/A
lower-*.f64N/A
lift-cosh.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6492.9
Applied rewrites92.9%
if 1.10000000000000011e93 < x Initial program 70.7%
Taylor expanded in x around 0
div-addN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
Applied rewrites96.0%
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x_s x_m y_m z)
:precision binary64
(let* ((t_0 (/ (* (cosh x_m) (/ y_m x_m)) z)))
(*
y_s
(*
x_s
(if (<= t_0 INFINITY)
t_0
(fma
(fma
(*
(fma
0.001388888888888889
(/ (* (* x_m x_m) y_m) z)
(* 0.041666666666666664 (/ y_m z)))
x_m)
x_m
(* (/ y_m z) 0.5))
(/ (* x_m x_m) x_m)
(/ (/ y_m z) x_m)))))))x\_m = fabs(x);
x\_s = copysign(1.0, x);
y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x_s, double x_m, double y_m, double z) {
double t_0 = (cosh(x_m) * (y_m / x_m)) / z;
double tmp;
if (t_0 <= ((double) INFINITY)) {
tmp = t_0;
} else {
tmp = fma(fma((fma(0.001388888888888889, (((x_m * x_m) * y_m) / z), (0.041666666666666664 * (y_m / z))) * x_m), x_m, ((y_m / z) * 0.5)), ((x_m * x_m) / x_m), ((y_m / z) / x_m));
}
return y_s * (x_s * tmp);
}
x\_m = abs(x) x\_s = copysign(1.0, x) y\_m = abs(y) y\_s = copysign(1.0, y) function code(y_s, x_s, x_m, y_m, z) t_0 = Float64(Float64(cosh(x_m) * Float64(y_m / x_m)) / z) tmp = 0.0 if (t_0 <= Inf) tmp = t_0; else tmp = fma(fma(Float64(fma(0.001388888888888889, Float64(Float64(Float64(x_m * x_m) * y_m) / z), Float64(0.041666666666666664 * Float64(y_m / z))) * x_m), x_m, Float64(Float64(y_m / z) * 0.5)), Float64(Float64(x_m * x_m) / x_m), Float64(Float64(y_m / z) / x_m)); end return Float64(y_s * Float64(x_s * tmp)) end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x$95$s_, x$95$m_, y$95$m_, z_] := Block[{t$95$0 = N[(N[(N[Cosh[x$95$m], $MachinePrecision] * N[(y$95$m / x$95$m), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]}, N[(y$95$s * N[(x$95$s * If[LessEqual[t$95$0, Infinity], t$95$0, N[(N[(N[(N[(0.001388888888888889 * N[(N[(N[(x$95$m * x$95$m), $MachinePrecision] * y$95$m), $MachinePrecision] / z), $MachinePrecision] + N[(0.041666666666666664 * N[(y$95$m / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * x$95$m), $MachinePrecision] * x$95$m + N[(N[(y$95$m / z), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision] * N[(N[(x$95$m * x$95$m), $MachinePrecision] / x$95$m), $MachinePrecision] + N[(N[(y$95$m / z), $MachinePrecision] / x$95$m), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
\begin{array}{l}
t_0 := \frac{\cosh x\_m \cdot \frac{y\_m}{x\_m}}{z}\\
y\_s \cdot \left(x\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_0 \leq \infty:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.001388888888888889, \frac{\left(x\_m \cdot x\_m\right) \cdot y\_m}{z}, 0.041666666666666664 \cdot \frac{y\_m}{z}\right) \cdot x\_m, x\_m, \frac{y\_m}{z} \cdot 0.5\right), \frac{x\_m \cdot x\_m}{x\_m}, \frac{\frac{y\_m}{z}}{x\_m}\right)\\
\end{array}\right)
\end{array}
\end{array}
if (/.f64 (*.f64 (cosh.f64 x) (/.f64 y x)) z) < +inf.0Initial program 95.1%
if +inf.0 < (/.f64 (*.f64 (cosh.f64 x) (/.f64 y x)) z) Initial program 0.0%
Taylor expanded in x around 0
div-addN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
Applied rewrites87.0%
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x_s x_m y_m z)
:precision binary64
(*
y_s
(*
x_s
(fma
(fma
(*
(fma
0.001388888888888889
(/ (* (* x_m x_m) y_m) z)
(* 0.041666666666666664 (/ y_m z)))
x_m)
x_m
(* (/ y_m z) 0.5))
(/ (* x_m x_m) x_m)
(/ (/ y_m z) x_m)))))x\_m = fabs(x);
x\_s = copysign(1.0, x);
y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x_s, double x_m, double y_m, double z) {
return y_s * (x_s * fma(fma((fma(0.001388888888888889, (((x_m * x_m) * y_m) / z), (0.041666666666666664 * (y_m / z))) * x_m), x_m, ((y_m / z) * 0.5)), ((x_m * x_m) / x_m), ((y_m / z) / x_m)));
}
x\_m = abs(x) x\_s = copysign(1.0, x) y\_m = abs(y) y\_s = copysign(1.0, y) function code(y_s, x_s, x_m, y_m, z) return Float64(y_s * Float64(x_s * fma(fma(Float64(fma(0.001388888888888889, Float64(Float64(Float64(x_m * x_m) * y_m) / z), Float64(0.041666666666666664 * Float64(y_m / z))) * x_m), x_m, Float64(Float64(y_m / z) * 0.5)), Float64(Float64(x_m * x_m) / x_m), Float64(Float64(y_m / z) / x_m)))) end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x$95$s_, x$95$m_, y$95$m_, z_] := N[(y$95$s * N[(x$95$s * N[(N[(N[(N[(0.001388888888888889 * N[(N[(N[(x$95$m * x$95$m), $MachinePrecision] * y$95$m), $MachinePrecision] / z), $MachinePrecision] + N[(0.041666666666666664 * N[(y$95$m / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * x$95$m), $MachinePrecision] * x$95$m + N[(N[(y$95$m / z), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision] * N[(N[(x$95$m * x$95$m), $MachinePrecision] / x$95$m), $MachinePrecision] + N[(N[(y$95$m / z), $MachinePrecision] / x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
y\_s \cdot \left(x\_s \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.001388888888888889, \frac{\left(x\_m \cdot x\_m\right) \cdot y\_m}{z}, 0.041666666666666664 \cdot \frac{y\_m}{z}\right) \cdot x\_m, x\_m, \frac{y\_m}{z} \cdot 0.5\right), \frac{x\_m \cdot x\_m}{x\_m}, \frac{\frac{y\_m}{z}}{x\_m}\right)\right)
\end{array}
Initial program 84.5%
Taylor expanded in x around 0
div-addN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
Applied rewrites83.6%
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x_s x_m y_m z)
:precision binary64
(*
y_s
(*
x_s
(*
(fma
(/ y_m z)
0.001388888888888889
(fma
(/ y_m (* (* x_m x_m) z))
0.041666666666666664
(fma
(/ y_m (* (pow (* x_m x_m) 2.0) z))
0.5
(/ y_m (* (pow (* x_m x_m) 3.0) z)))))
(pow (* x_m x_m) 2.5)))))x\_m = fabs(x);
x\_s = copysign(1.0, x);
y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x_s, double x_m, double y_m, double z) {
return y_s * (x_s * (fma((y_m / z), 0.001388888888888889, fma((y_m / ((x_m * x_m) * z)), 0.041666666666666664, fma((y_m / (pow((x_m * x_m), 2.0) * z)), 0.5, (y_m / (pow((x_m * x_m), 3.0) * z))))) * pow((x_m * x_m), 2.5)));
}
x\_m = abs(x) x\_s = copysign(1.0, x) y\_m = abs(y) y\_s = copysign(1.0, y) function code(y_s, x_s, x_m, y_m, z) return Float64(y_s * Float64(x_s * Float64(fma(Float64(y_m / z), 0.001388888888888889, fma(Float64(y_m / Float64(Float64(x_m * x_m) * z)), 0.041666666666666664, fma(Float64(y_m / Float64((Float64(x_m * x_m) ^ 2.0) * z)), 0.5, Float64(y_m / Float64((Float64(x_m * x_m) ^ 3.0) * z))))) * (Float64(x_m * x_m) ^ 2.5)))) end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x$95$s_, x$95$m_, y$95$m_, z_] := N[(y$95$s * N[(x$95$s * N[(N[(N[(y$95$m / z), $MachinePrecision] * 0.001388888888888889 + N[(N[(y$95$m / N[(N[(x$95$m * x$95$m), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision] * 0.041666666666666664 + N[(N[(y$95$m / N[(N[Power[N[(x$95$m * x$95$m), $MachinePrecision], 2.0], $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision] * 0.5 + N[(y$95$m / N[(N[Power[N[(x$95$m * x$95$m), $MachinePrecision], 3.0], $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Power[N[(x$95$m * x$95$m), $MachinePrecision], 2.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
y\_s \cdot \left(x\_s \cdot \left(\mathsf{fma}\left(\frac{y\_m}{z}, 0.001388888888888889, \mathsf{fma}\left(\frac{y\_m}{\left(x\_m \cdot x\_m\right) \cdot z}, 0.041666666666666664, \mathsf{fma}\left(\frac{y\_m}{{\left(x\_m \cdot x\_m\right)}^{2} \cdot z}, 0.5, \frac{y\_m}{{\left(x\_m \cdot x\_m\right)}^{3} \cdot z}\right)\right)\right) \cdot {\left(x\_m \cdot x\_m\right)}^{2.5}\right)\right)
\end{array}
Initial program 84.5%
Taylor expanded in x around 0
div-addN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
Applied rewrites83.6%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites45.3%
herbie shell --seed 2025093
(FPCore (x y z)
:name "Linear.Quaternion:$ctan from linear-1.19.1.3"
:precision binary64
(/ (* (cosh x) (/ y x)) z))