
(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}
Sampling outcomes in binary64 precision:
Herbie found 16 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}
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x y_m z)
:precision binary64
(*
y_s
(if (<= y_m 1.45e+80)
(/ (/ (* (cosh x) y_m) x) z)
(/ (* (/ (/ (* 2.0 (cosh x)) x) z) y_m) 2.0))))y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
double tmp;
if (y_m <= 1.45e+80) {
tmp = ((cosh(x) * y_m) / x) / z;
} else {
tmp = ((((2.0 * cosh(x)) / x) / z) * y_m) / 2.0;
}
return y_s * tmp;
}
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, y_m, z)
use fmin_fmax_functions
real(8), intent (in) :: y_s
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8) :: tmp
if (y_m <= 1.45d+80) then
tmp = ((cosh(x) * y_m) / x) / z
else
tmp = ((((2.0d0 * cosh(x)) / x) / z) * y_m) / 2.0d0
end if
code = y_s * tmp
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
public static double code(double y_s, double x, double y_m, double z) {
double tmp;
if (y_m <= 1.45e+80) {
tmp = ((Math.cosh(x) * y_m) / x) / z;
} else {
tmp = ((((2.0 * Math.cosh(x)) / x) / z) * y_m) / 2.0;
}
return y_s * tmp;
}
y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) def code(y_s, x, y_m, z): tmp = 0 if y_m <= 1.45e+80: tmp = ((math.cosh(x) * y_m) / x) / z else: tmp = ((((2.0 * math.cosh(x)) / x) / z) * y_m) / 2.0 return y_s * tmp
y\_m = abs(y) y\_s = copysign(1.0, y) function code(y_s, x, y_m, z) tmp = 0.0 if (y_m <= 1.45e+80) tmp = Float64(Float64(Float64(cosh(x) * y_m) / x) / z); else tmp = Float64(Float64(Float64(Float64(Float64(2.0 * cosh(x)) / x) / z) * y_m) / 2.0); end return Float64(y_s * tmp) end
y\_m = abs(y); y\_s = sign(y) * abs(1.0); function tmp_2 = code(y_s, x, y_m, z) tmp = 0.0; if (y_m <= 1.45e+80) tmp = ((cosh(x) * y_m) / x) / z; else tmp = ((((2.0 * cosh(x)) / x) / z) * y_m) / 2.0; end tmp_2 = y_s * tmp; end
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_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[y$95$m, 1.45e+80], N[(N[(N[(N[Cosh[x], $MachinePrecision] * y$95$m), $MachinePrecision] / x), $MachinePrecision] / z), $MachinePrecision], N[(N[(N[(N[(N[(2.0 * N[Cosh[x], $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / z), $MachinePrecision] * y$95$m), $MachinePrecision] / 2.0), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;y\_m \leq 1.45 \cdot 10^{+80}:\\
\;\;\;\;\frac{\frac{\cosh x \cdot y\_m}{x}}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{2 \cdot \cosh x}{x}}{z} \cdot y\_m}{2}\\
\end{array}
\end{array}
if y < 1.44999999999999993e80Initial program 82.9%
lift-*.f64N/A
lift-cosh.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lift-cosh.f6497.2
Applied rewrites97.2%
if 1.44999999999999993e80 < y Initial program 91.8%
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%
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x y_m z)
:precision binary64
(*
y_s
(if (<= (/ (* (cosh x) (/ y_m x)) z) 1e+303)
(*
(fma
(fma (fma 0.001388888888888889 (* x x) 0.041666666666666664) (* x x) 0.5)
(* x x)
1.0)
(/ (/ y_m x) z))
(/
(*
(/
(/
(fma
(fma
(fma 0.002777777777777778 (* x x) 0.08333333333333333)
(* x x)
1.0)
(* x x)
2.0)
x)
z)
y_m)
2.0))))y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
double tmp;
if (((cosh(x) * (y_m / x)) / z) <= 1e+303) {
tmp = fma(fma(fma(0.001388888888888889, (x * x), 0.041666666666666664), (x * x), 0.5), (x * x), 1.0) * ((y_m / x) / z);
} else {
tmp = (((fma(fma(fma(0.002777777777777778, (x * x), 0.08333333333333333), (x * x), 1.0), (x * x), 2.0) / x) / z) * y_m) / 2.0;
}
return y_s * tmp;
}
y\_m = abs(y) y\_s = copysign(1.0, y) function code(y_s, x, y_m, z) tmp = 0.0 if (Float64(Float64(cosh(x) * Float64(y_m / x)) / z) <= 1e+303) tmp = Float64(fma(fma(fma(0.001388888888888889, Float64(x * x), 0.041666666666666664), Float64(x * x), 0.5), Float64(x * x), 1.0) * Float64(Float64(y_m / x) / z)); else tmp = Float64(Float64(Float64(Float64(fma(fma(fma(0.002777777777777778, Float64(x * x), 0.08333333333333333), Float64(x * x), 1.0), Float64(x * x), 2.0) / x) / z) * y_m) / 2.0); end return Float64(y_s * tmp) end
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_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[N[(N[(N[Cosh[x], $MachinePrecision] * N[(y$95$m / x), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], 1e+303], N[(N[(N[(N[(0.001388888888888889 * N[(x * x), $MachinePrecision] + 0.041666666666666664), $MachinePrecision] * N[(x * x), $MachinePrecision] + 0.5), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision] * N[(N[(y$95$m / x), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(N[(N[(0.002777777777777778 * N[(x * x), $MachinePrecision] + 0.08333333333333333), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision] * N[(x * x), $MachinePrecision] + 2.0), $MachinePrecision] / x), $MachinePrecision] / z), $MachinePrecision] * y$95$m), $MachinePrecision] / 2.0), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;\frac{\cosh x \cdot \frac{y\_m}{x}}{z} \leq 10^{+303}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.001388888888888889, x \cdot x, 0.041666666666666664\right), x \cdot x, 0.5\right), x \cdot x, 1\right) \cdot \frac{\frac{y\_m}{x}}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.002777777777777778, x \cdot x, 0.08333333333333333\right), x \cdot x, 1\right), x \cdot x, 2\right)}{x}}{z} \cdot y\_m}{2}\\
\end{array}
\end{array}
if (/.f64 (*.f64 (cosh.f64 x) (/.f64 y x)) z) < 1e303Initial program 99.2%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6497.6
Applied rewrites97.6%
lift-/.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-/l*N/A
associate-/r*N/A
lower-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lift-/.f6491.2
Applied rewrites91.2%
if 1e303 < (/.f64 (*.f64 (cosh.f64 x) (/.f64 y x)) z) Initial program 62.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%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f6494.2
Applied rewrites94.2%
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x y_m z)
:precision binary64
(*
y_s
(if (<= (/ (* (cosh x) (/ y_m x)) z) 5e-14)
(/ (/ (fma (* x (* y_m x)) 0.5 y_m) x) z)
(/ (/ (fma (* (* x x) y_m) 0.5 y_m) z) x))))y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
double tmp;
if (((cosh(x) * (y_m / x)) / z) <= 5e-14) {
tmp = (fma((x * (y_m * x)), 0.5, y_m) / x) / z;
} else {
tmp = (fma(((x * x) * y_m), 0.5, y_m) / z) / x;
}
return y_s * tmp;
}
y\_m = abs(y) y\_s = copysign(1.0, y) function code(y_s, x, y_m, z) tmp = 0.0 if (Float64(Float64(cosh(x) * Float64(y_m / x)) / z) <= 5e-14) tmp = Float64(Float64(fma(Float64(x * Float64(y_m * x)), 0.5, y_m) / x) / z); else tmp = Float64(Float64(fma(Float64(Float64(x * x) * y_m), 0.5, y_m) / z) / x); end return Float64(y_s * tmp) end
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_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[N[(N[(N[Cosh[x], $MachinePrecision] * N[(y$95$m / x), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], 5e-14], N[(N[(N[(N[(x * N[(y$95$m * x), $MachinePrecision]), $MachinePrecision] * 0.5 + y$95$m), $MachinePrecision] / x), $MachinePrecision] / z), $MachinePrecision], N[(N[(N[(N[(N[(x * x), $MachinePrecision] * y$95$m), $MachinePrecision] * 0.5 + y$95$m), $MachinePrecision] / z), $MachinePrecision] / x), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;\frac{\cosh x \cdot \frac{y\_m}{x}}{z} \leq 5 \cdot 10^{-14}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(x \cdot \left(y\_m \cdot x\right), 0.5, y\_m\right)}{x}}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(\left(x \cdot x\right) \cdot y\_m, 0.5, y\_m\right)}{z}}{x}\\
\end{array}
\end{array}
if (/.f64 (*.f64 (cosh.f64 x) (/.f64 y x)) z) < 5.0000000000000002e-14Initial program 99.1%
Taylor expanded in x around 0
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6487.4
Applied rewrites87.4%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6486.6
Applied rewrites86.6%
if 5.0000000000000002e-14 < (/.f64 (*.f64 (cosh.f64 x) (/.f64 y x)) z) Initial program 69.8%
Taylor expanded in x around 0
lower-/.f64N/A
associate-*r/N/A
div-add-revN/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6482.9
Applied rewrites82.9%
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x y_m z)
:precision binary64
(*
y_s
(if (<= (/ (* (cosh x) (/ y_m x)) z) 5e-14)
(/ (/ y_m x) z)
(/ (/ (fma (* (* x x) y_m) 0.5 y_m) z) x))))y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
double tmp;
if (((cosh(x) * (y_m / x)) / z) <= 5e-14) {
tmp = (y_m / x) / z;
} else {
tmp = (fma(((x * x) * y_m), 0.5, y_m) / z) / x;
}
return y_s * tmp;
}
y\_m = abs(y) y\_s = copysign(1.0, y) function code(y_s, x, y_m, z) tmp = 0.0 if (Float64(Float64(cosh(x) * Float64(y_m / x)) / z) <= 5e-14) tmp = Float64(Float64(y_m / x) / z); else tmp = Float64(Float64(fma(Float64(Float64(x * x) * y_m), 0.5, y_m) / z) / x); end return Float64(y_s * tmp) end
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_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[N[(N[(N[Cosh[x], $MachinePrecision] * N[(y$95$m / x), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], 5e-14], N[(N[(y$95$m / x), $MachinePrecision] / z), $MachinePrecision], N[(N[(N[(N[(N[(x * x), $MachinePrecision] * y$95$m), $MachinePrecision] * 0.5 + y$95$m), $MachinePrecision] / z), $MachinePrecision] / x), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;\frac{\cosh x \cdot \frac{y\_m}{x}}{z} \leq 5 \cdot 10^{-14}:\\
\;\;\;\;\frac{\frac{y\_m}{x}}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(\left(x \cdot x\right) \cdot y\_m, 0.5, y\_m\right)}{z}}{x}\\
\end{array}
\end{array}
if (/.f64 (*.f64 (cosh.f64 x) (/.f64 y x)) z) < 5.0000000000000002e-14Initial program 99.1%
Taylor expanded in x around 0
lift-/.f6471.0
Applied rewrites71.0%
if 5.0000000000000002e-14 < (/.f64 (*.f64 (cosh.f64 x) (/.f64 y x)) z) Initial program 69.8%
Taylor expanded in x around 0
lower-/.f64N/A
associate-*r/N/A
div-add-revN/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6482.9
Applied rewrites82.9%
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x y_m z)
:precision binary64
(*
y_s
(if (<= (/ (* (cosh x) (/ y_m x)) z) 1e+303)
(/ (/ y_m x) z)
(/ (* (fma x x 2.0) y_m) (* (* z x) 2.0)))))y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
double tmp;
if (((cosh(x) * (y_m / x)) / z) <= 1e+303) {
tmp = (y_m / x) / z;
} else {
tmp = (fma(x, x, 2.0) * y_m) / ((z * x) * 2.0);
}
return y_s * tmp;
}
y\_m = abs(y) y\_s = copysign(1.0, y) function code(y_s, x, y_m, z) tmp = 0.0 if (Float64(Float64(cosh(x) * Float64(y_m / x)) / z) <= 1e+303) tmp = Float64(Float64(y_m / x) / z); else tmp = Float64(Float64(fma(x, x, 2.0) * y_m) / Float64(Float64(z * x) * 2.0)); end return Float64(y_s * tmp) end
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_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[N[(N[(N[Cosh[x], $MachinePrecision] * N[(y$95$m / x), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], 1e+303], N[(N[(y$95$m / x), $MachinePrecision] / z), $MachinePrecision], N[(N[(N[(x * x + 2.0), $MachinePrecision] * y$95$m), $MachinePrecision] / N[(N[(z * x), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;\frac{\cosh x \cdot \frac{y\_m}{x}}{z} \leq 10^{+303}:\\
\;\;\;\;\frac{\frac{y\_m}{x}}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x, x, 2\right) \cdot y\_m}{\left(z \cdot x\right) \cdot 2}\\
\end{array}
\end{array}
if (/.f64 (*.f64 (cosh.f64 x) (/.f64 y x)) z) < 1e303Initial program 99.2%
Taylor expanded in x around 0
lift-/.f6475.4
Applied rewrites75.4%
if 1e303 < (/.f64 (*.f64 (cosh.f64 x) (/.f64 y x)) z) Initial program 62.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%
Taylor expanded in x around 0
+-commutativeN/A
pow2N/A
lower-fma.f6478.1
Applied rewrites78.1%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
frac-timesN/A
lower-/.f64N/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6460.4
Applied rewrites60.4%
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x y_m z)
:precision binary64
(*
y_s
(if (<= y_m 850000.0)
(/ (/ (* (cosh x) y_m) x) z)
(* (/ (cosh x) x) (/ y_m z)))))y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
double tmp;
if (y_m <= 850000.0) {
tmp = ((cosh(x) * y_m) / x) / z;
} else {
tmp = (cosh(x) / x) * (y_m / z);
}
return y_s * tmp;
}
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, y_m, z)
use fmin_fmax_functions
real(8), intent (in) :: y_s
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8) :: tmp
if (y_m <= 850000.0d0) then
tmp = ((cosh(x) * y_m) / x) / z
else
tmp = (cosh(x) / x) * (y_m / z)
end if
code = y_s * tmp
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
public static double code(double y_s, double x, double y_m, double z) {
double tmp;
if (y_m <= 850000.0) {
tmp = ((Math.cosh(x) * y_m) / x) / z;
} else {
tmp = (Math.cosh(x) / x) * (y_m / z);
}
return y_s * tmp;
}
y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) def code(y_s, x, y_m, z): tmp = 0 if y_m <= 850000.0: tmp = ((math.cosh(x) * y_m) / x) / z else: tmp = (math.cosh(x) / x) * (y_m / z) return y_s * tmp
y\_m = abs(y) y\_s = copysign(1.0, y) function code(y_s, x, y_m, z) tmp = 0.0 if (y_m <= 850000.0) tmp = Float64(Float64(Float64(cosh(x) * y_m) / x) / z); else tmp = Float64(Float64(cosh(x) / x) * Float64(y_m / z)); end return Float64(y_s * tmp) end
y\_m = abs(y); y\_s = sign(y) * abs(1.0); function tmp_2 = code(y_s, x, y_m, z) tmp = 0.0; if (y_m <= 850000.0) tmp = ((cosh(x) * y_m) / x) / z; else tmp = (cosh(x) / x) * (y_m / z); end tmp_2 = y_s * tmp; end
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_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[y$95$m, 850000.0], N[(N[(N[(N[Cosh[x], $MachinePrecision] * y$95$m), $MachinePrecision] / x), $MachinePrecision] / z), $MachinePrecision], N[(N[(N[Cosh[x], $MachinePrecision] / x), $MachinePrecision] * N[(y$95$m / z), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;y\_m \leq 850000:\\
\;\;\;\;\frac{\frac{\cosh x \cdot y\_m}{x}}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{\cosh x}{x} \cdot \frac{y\_m}{z}\\
\end{array}
\end{array}
if y < 8.5e5Initial program 81.3%
lift-*.f64N/A
lift-cosh.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lift-cosh.f6496.9
Applied rewrites96.9%
if 8.5e5 < y Initial program 94.1%
lift-*.f64N/A
lift-cosh.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lift-cosh.f6494.1
Applied rewrites94.1%
lift-/.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-cosh.f64N/A
associate-/l/N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-cosh.f64N/A
lower-/.f64100.0
Applied rewrites100.0%
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x y_m z)
:precision binary64
(*
y_s
(if (<= y_m 410000.0)
(/
(*
y_m
(/
(fma
(fma
(fma (* x x) 0.001388888888888889 0.041666666666666664)
(* x x)
0.5)
(* x x)
1.0)
x))
z)
(* (/ (cosh x) x) (/ y_m z)))))y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
double tmp;
if (y_m <= 410000.0) {
tmp = (y_m * (fma(fma(fma((x * x), 0.001388888888888889, 0.041666666666666664), (x * x), 0.5), (x * x), 1.0) / x)) / z;
} else {
tmp = (cosh(x) / x) * (y_m / z);
}
return y_s * tmp;
}
y\_m = abs(y) y\_s = copysign(1.0, y) function code(y_s, x, y_m, z) tmp = 0.0 if (y_m <= 410000.0) tmp = Float64(Float64(y_m * Float64(fma(fma(fma(Float64(x * x), 0.001388888888888889, 0.041666666666666664), Float64(x * x), 0.5), Float64(x * x), 1.0) / x)) / z); else tmp = Float64(Float64(cosh(x) / x) * Float64(y_m / z)); end return Float64(y_s * tmp) end
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_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[y$95$m, 410000.0], N[(N[(y$95$m * N[(N[(N[(N[(N[(x * x), $MachinePrecision] * 0.001388888888888889 + 0.041666666666666664), $MachinePrecision] * N[(x * x), $MachinePrecision] + 0.5), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], N[(N[(N[Cosh[x], $MachinePrecision] / x), $MachinePrecision] * N[(y$95$m / z), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;y\_m \leq 410000:\\
\;\;\;\;\frac{y\_m \cdot \frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, 0.001388888888888889, 0.041666666666666664\right), x \cdot x, 0.5\right), x \cdot x, 1\right)}{x}}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{\cosh x}{x} \cdot \frac{y\_m}{z}\\
\end{array}
\end{array}
if y < 4.1e5Initial program 81.3%
Taylor expanded in x around 0
lower-/.f64N/A
Applied rewrites92.1%
Taylor expanded in y around 0
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
Applied rewrites94.0%
if 4.1e5 < y Initial program 94.1%
lift-*.f64N/A
lift-cosh.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lift-cosh.f6494.1
Applied rewrites94.1%
lift-/.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-cosh.f64N/A
associate-/l/N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-cosh.f64N/A
lower-/.f64100.0
Applied rewrites100.0%
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x y_m z)
:precision binary64
(*
y_s
(if (<= x 5.6e+45)
(/ (* (cosh x) y_m) (* z x))
(/
(*
y_m
(/
(fma
(fma
(fma (* x x) 0.001388888888888889 0.041666666666666664)
(* x x)
0.5)
(* x x)
1.0)
x))
z))))y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
double tmp;
if (x <= 5.6e+45) {
tmp = (cosh(x) * y_m) / (z * x);
} else {
tmp = (y_m * (fma(fma(fma((x * x), 0.001388888888888889, 0.041666666666666664), (x * x), 0.5), (x * x), 1.0) / x)) / z;
}
return y_s * tmp;
}
y\_m = abs(y) y\_s = copysign(1.0, y) function code(y_s, x, y_m, z) tmp = 0.0 if (x <= 5.6e+45) tmp = Float64(Float64(cosh(x) * y_m) / Float64(z * x)); else tmp = Float64(Float64(y_m * Float64(fma(fma(fma(Float64(x * x), 0.001388888888888889, 0.041666666666666664), Float64(x * x), 0.5), Float64(x * x), 1.0) / x)) / z); end return Float64(y_s * tmp) end
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_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[x, 5.6e+45], N[(N[(N[Cosh[x], $MachinePrecision] * y$95$m), $MachinePrecision] / N[(z * x), $MachinePrecision]), $MachinePrecision], N[(N[(y$95$m * N[(N[(N[(N[(N[(x * x), $MachinePrecision] * 0.001388888888888889 + 0.041666666666666664), $MachinePrecision] * N[(x * x), $MachinePrecision] + 0.5), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;x \leq 5.6 \cdot 10^{+45}:\\
\;\;\;\;\frac{\cosh x \cdot y\_m}{z \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{y\_m \cdot \frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, 0.001388888888888889, 0.041666666666666664\right), x \cdot x, 0.5\right), x \cdot x, 1\right)}{x}}{z}\\
\end{array}
\end{array}
if x < 5.5999999999999999e45Initial program 88.2%
lift-/.f64N/A
lift-*.f64N/A
lift-cosh.f64N/A
lift-/.f64N/A
associate-*r/N/A
associate-/l/N/A
lower-/.f64N/A
lower-*.f64N/A
lift-cosh.f64N/A
*-commutativeN/A
lower-*.f6488.7
Applied rewrites88.7%
if 5.5999999999999999e45 < x Initial program 70.9%
Taylor expanded in x around 0
lower-/.f64N/A
Applied rewrites94.8%
Taylor expanded in y around 0
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
Applied rewrites100.0%
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x y_m z)
:precision binary64
(*
y_s
(if (<= x 9e-151)
(/ y_m (* z x))
(if (<= x 2.6e+77)
(/
(*
(fma (* (fma (* x x) (* (* x x) 0.001388888888888889) 0.5) x) x 1.0)
(/ y_m x))
z)
(/
(/ (* (fma (* 0.041666666666666664 (* x x)) (* x x) 1.0) y_m) x)
z)))))y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
double tmp;
if (x <= 9e-151) {
tmp = y_m / (z * x);
} else if (x <= 2.6e+77) {
tmp = (fma((fma((x * x), ((x * x) * 0.001388888888888889), 0.5) * x), x, 1.0) * (y_m / x)) / z;
} else {
tmp = ((fma((0.041666666666666664 * (x * x)), (x * x), 1.0) * y_m) / x) / z;
}
return y_s * tmp;
}
y\_m = abs(y) y\_s = copysign(1.0, y) function code(y_s, x, y_m, z) tmp = 0.0 if (x <= 9e-151) tmp = Float64(y_m / Float64(z * x)); elseif (x <= 2.6e+77) tmp = Float64(Float64(fma(Float64(fma(Float64(x * x), Float64(Float64(x * x) * 0.001388888888888889), 0.5) * x), x, 1.0) * Float64(y_m / x)) / z); else tmp = Float64(Float64(Float64(fma(Float64(0.041666666666666664 * Float64(x * x)), Float64(x * x), 1.0) * y_m) / x) / z); end return Float64(y_s * tmp) end
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_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[x, 9e-151], N[(y$95$m / N[(z * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.6e+77], N[(N[(N[(N[(N[(N[(x * x), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * 0.001388888888888889), $MachinePrecision] + 0.5), $MachinePrecision] * x), $MachinePrecision] * x + 1.0), $MachinePrecision] * N[(y$95$m / x), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], N[(N[(N[(N[(N[(0.041666666666666664 * N[(x * x), $MachinePrecision]), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision] * y$95$m), $MachinePrecision] / x), $MachinePrecision] / z), $MachinePrecision]]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;x \leq 9 \cdot 10^{-151}:\\
\;\;\;\;\frac{y\_m}{z \cdot x}\\
\mathbf{elif}\;x \leq 2.6 \cdot 10^{+77}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, \left(x \cdot x\right) \cdot 0.001388888888888889, 0.5\right) \cdot x, x, 1\right) \cdot \frac{y\_m}{x}}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(0.041666666666666664 \cdot \left(x \cdot x\right), x \cdot x, 1\right) \cdot y\_m}{x}}{z}\\
\end{array}
\end{array}
if x < 9.0000000000000005e-151Initial program 84.6%
Taylor expanded in x around 0
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6462.9
Applied rewrites62.9%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6465.0
Applied rewrites65.0%
if 9.0000000000000005e-151 < x < 2.6000000000000002e77Initial program 99.8%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6490.0
Applied rewrites90.0%
Taylor expanded in x around inf
pow2N/A
lower-*.f64N/A
lift-*.f6490.0
Applied rewrites90.0%
lift-*.f64N/A
lift-fma.f64N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites90.0%
if 2.6000000000000002e77 < x Initial program 64.4%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6464.4
Applied rewrites64.4%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6464.4
Applied rewrites64.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64100.0
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64100.0
Applied rewrites100.0%
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x y_m z)
:precision binary64
(*
y_s
(if (<= x 9e-151)
(/ y_m (* z x))
(/
(*
y_m
(/
(fma
(fma
(fma (* x x) 0.001388888888888889 0.041666666666666664)
(* x x)
0.5)
(* x x)
1.0)
x))
z))))y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
double tmp;
if (x <= 9e-151) {
tmp = y_m / (z * x);
} else {
tmp = (y_m * (fma(fma(fma((x * x), 0.001388888888888889, 0.041666666666666664), (x * x), 0.5), (x * x), 1.0) / x)) / z;
}
return y_s * tmp;
}
y\_m = abs(y) y\_s = copysign(1.0, y) function code(y_s, x, y_m, z) tmp = 0.0 if (x <= 9e-151) tmp = Float64(y_m / Float64(z * x)); else tmp = Float64(Float64(y_m * Float64(fma(fma(fma(Float64(x * x), 0.001388888888888889, 0.041666666666666664), Float64(x * x), 0.5), Float64(x * x), 1.0) / x)) / z); end return Float64(y_s * tmp) end
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_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[x, 9e-151], N[(y$95$m / N[(z * x), $MachinePrecision]), $MachinePrecision], N[(N[(y$95$m * N[(N[(N[(N[(N[(x * x), $MachinePrecision] * 0.001388888888888889 + 0.041666666666666664), $MachinePrecision] * N[(x * x), $MachinePrecision] + 0.5), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;x \leq 9 \cdot 10^{-151}:\\
\;\;\;\;\frac{y\_m}{z \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{y\_m \cdot \frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, 0.001388888888888889, 0.041666666666666664\right), x \cdot x, 0.5\right), x \cdot x, 1\right)}{x}}{z}\\
\end{array}
\end{array}
if x < 9.0000000000000005e-151Initial program 84.6%
Taylor expanded in x around 0
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6462.9
Applied rewrites62.9%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6465.0
Applied rewrites65.0%
if 9.0000000000000005e-151 < x Initial program 84.3%
Taylor expanded in x around 0
lower-/.f64N/A
Applied rewrites91.6%
Taylor expanded in y around 0
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
Applied rewrites94.3%
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x y_m z)
:precision binary64
(*
y_s
(if (<= x 9e-151)
(/ y_m (* z x))
(if (<= x 5.8e+123)
(/ (* (fma (* (* 0.041666666666666664 x) x) (* x x) 1.0) (/ y_m x)) z)
(/ (* (/ (/ (fma x x 2.0) z) x) y_m) 2.0)))))y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
double tmp;
if (x <= 9e-151) {
tmp = y_m / (z * x);
} else if (x <= 5.8e+123) {
tmp = (fma(((0.041666666666666664 * x) * x), (x * x), 1.0) * (y_m / x)) / z;
} else {
tmp = (((fma(x, x, 2.0) / z) / x) * y_m) / 2.0;
}
return y_s * tmp;
}
y\_m = abs(y) y\_s = copysign(1.0, y) function code(y_s, x, y_m, z) tmp = 0.0 if (x <= 9e-151) tmp = Float64(y_m / Float64(z * x)); elseif (x <= 5.8e+123) tmp = Float64(Float64(fma(Float64(Float64(0.041666666666666664 * x) * x), Float64(x * x), 1.0) * Float64(y_m / x)) / z); else tmp = Float64(Float64(Float64(Float64(fma(x, x, 2.0) / z) / x) * y_m) / 2.0); end return Float64(y_s * tmp) end
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_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[x, 9e-151], N[(y$95$m / N[(z * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 5.8e+123], N[(N[(N[(N[(N[(0.041666666666666664 * x), $MachinePrecision] * x), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision] * N[(y$95$m / x), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], N[(N[(N[(N[(N[(x * x + 2.0), $MachinePrecision] / z), $MachinePrecision] / x), $MachinePrecision] * y$95$m), $MachinePrecision] / 2.0), $MachinePrecision]]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;x \leq 9 \cdot 10^{-151}:\\
\;\;\;\;\frac{y\_m}{z \cdot x}\\
\mathbf{elif}\;x \leq 5.8 \cdot 10^{+123}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\left(0.041666666666666664 \cdot x\right) \cdot x, x \cdot x, 1\right) \cdot \frac{y\_m}{x}}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{\mathsf{fma}\left(x, x, 2\right)}{z}}{x} \cdot y\_m}{2}\\
\end{array}
\end{array}
if x < 9.0000000000000005e-151Initial program 84.6%
Taylor expanded in x around 0
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6462.9
Applied rewrites62.9%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6465.0
Applied rewrites65.0%
if 9.0000000000000005e-151 < x < 5.80000000000000019e123Initial program 99.8%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6484.0
Applied rewrites84.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6484.0
Applied rewrites84.0%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6484.0
Applied rewrites84.0%
if 5.80000000000000019e123 < x Initial program 55.6%
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 rewrites100.0%
Taylor expanded in x around 0
lower-/.f64N/A
associate-*r/N/A
metadata-evalN/A
div-add-revN/A
lower-/.f64N/A
+-commutativeN/A
pow2N/A
lower-fma.f64100.0
Applied rewrites100.0%
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x y_m z)
:precision binary64
(*
y_s
(if (<= x 9e-151)
(/ y_m (* z x))
(/
(/ (* (fma (fma (* x x) 0.041666666666666664 0.5) (* x x) 1.0) y_m) x)
z))))y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
double tmp;
if (x <= 9e-151) {
tmp = y_m / (z * x);
} else {
tmp = ((fma(fma((x * x), 0.041666666666666664, 0.5), (x * x), 1.0) * y_m) / x) / z;
}
return y_s * tmp;
}
y\_m = abs(y) y\_s = copysign(1.0, y) function code(y_s, x, y_m, z) tmp = 0.0 if (x <= 9e-151) tmp = Float64(y_m / Float64(z * x)); else tmp = Float64(Float64(Float64(fma(fma(Float64(x * x), 0.041666666666666664, 0.5), Float64(x * x), 1.0) * y_m) / x) / z); end return Float64(y_s * tmp) end
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_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[x, 9e-151], N[(y$95$m / N[(z * x), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(N[(x * x), $MachinePrecision] * 0.041666666666666664 + 0.5), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision] * y$95$m), $MachinePrecision] / x), $MachinePrecision] / z), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;x \leq 9 \cdot 10^{-151}:\\
\;\;\;\;\frac{y\_m}{z \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, 0.041666666666666664, 0.5\right), x \cdot x, 1\right) \cdot y\_m}{x}}{z}\\
\end{array}
\end{array}
if x < 9.0000000000000005e-151Initial program 84.6%
Taylor expanded in x around 0
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6462.9
Applied rewrites62.9%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6465.0
Applied rewrites65.0%
if 9.0000000000000005e-151 < x Initial program 84.3%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6474.1
Applied rewrites74.1%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f6490.6
lift-fma.f64N/A
lift-*.f64N/A
pow2N/A
*-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f6490.6
Applied rewrites90.6%
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x y_m z)
:precision binary64
(*
y_s
(if (<= x 9e-151)
(/ y_m (* z x))
(/ (/ (* (fma (* 0.041666666666666664 (* x x)) (* x x) 1.0) y_m) x) z))))y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
double tmp;
if (x <= 9e-151) {
tmp = y_m / (z * x);
} else {
tmp = ((fma((0.041666666666666664 * (x * x)), (x * x), 1.0) * y_m) / x) / z;
}
return y_s * tmp;
}
y\_m = abs(y) y\_s = copysign(1.0, y) function code(y_s, x, y_m, z) tmp = 0.0 if (x <= 9e-151) tmp = Float64(y_m / Float64(z * x)); else tmp = Float64(Float64(Float64(fma(Float64(0.041666666666666664 * Float64(x * x)), Float64(x * x), 1.0) * y_m) / x) / z); end return Float64(y_s * tmp) end
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_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[x, 9e-151], N[(y$95$m / N[(z * x), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(0.041666666666666664 * N[(x * x), $MachinePrecision]), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision] * y$95$m), $MachinePrecision] / x), $MachinePrecision] / z), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;x \leq 9 \cdot 10^{-151}:\\
\;\;\;\;\frac{y\_m}{z \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(0.041666666666666664 \cdot \left(x \cdot x\right), x \cdot x, 1\right) \cdot y\_m}{x}}{z}\\
\end{array}
\end{array}
if x < 9.0000000000000005e-151Initial program 84.6%
Taylor expanded in x around 0
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6462.9
Applied rewrites62.9%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6465.0
Applied rewrites65.0%
if 9.0000000000000005e-151 < x Initial program 84.3%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6474.1
Applied rewrites74.1%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6474.1
Applied rewrites74.1%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f6490.6
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f6490.6
Applied rewrites90.6%
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x y_m z)
:precision binary64
(*
y_s
(if (<= x 1.1e+35)
(/ (* (fma x x 2.0) y_m) (* (* z x) 2.0))
(/ (/ (* (* (* x x) 0.5) y_m) x) z))))y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
double tmp;
if (x <= 1.1e+35) {
tmp = (fma(x, x, 2.0) * y_m) / ((z * x) * 2.0);
} else {
tmp = ((((x * x) * 0.5) * y_m) / x) / z;
}
return y_s * tmp;
}
y\_m = abs(y) y\_s = copysign(1.0, y) function code(y_s, x, y_m, z) tmp = 0.0 if (x <= 1.1e+35) tmp = Float64(Float64(fma(x, x, 2.0) * y_m) / Float64(Float64(z * x) * 2.0)); else tmp = Float64(Float64(Float64(Float64(Float64(x * x) * 0.5) * y_m) / x) / z); end return Float64(y_s * tmp) end
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_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[x, 1.1e+35], N[(N[(N[(x * x + 2.0), $MachinePrecision] * y$95$m), $MachinePrecision] / N[(N[(z * x), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(x * x), $MachinePrecision] * 0.5), $MachinePrecision] * y$95$m), $MachinePrecision] / x), $MachinePrecision] / z), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;x \leq 1.1 \cdot 10^{+35}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x, x, 2\right) \cdot y\_m}{\left(z \cdot x\right) \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\left(\left(x \cdot x\right) \cdot 0.5\right) \cdot y\_m}{x}}{z}\\
\end{array}
\end{array}
if x < 1.0999999999999999e35Initial program 87.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
associate-*l/N/A
associate-/l*N/A
*-commutativeN/A
lower-/.f64N/A
Applied rewrites95.9%
Taylor expanded in x around 0
+-commutativeN/A
pow2N/A
lower-fma.f6485.1
Applied rewrites85.1%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
frac-timesN/A
lower-/.f64N/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6478.1
Applied rewrites78.1%
if 1.0999999999999999e35 < x Initial program 72.9%
Taylor expanded in x around 0
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6472.1
Applied rewrites72.1%
Taylor expanded in x around inf
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6472.1
Applied rewrites72.1%
y\_m = (fabs.f64 y) y\_s = (copysign.f64 #s(literal 1 binary64) y) (FPCore (y_s x y_m z) :precision binary64 (* y_s (if (<= x 1.45) (/ y_m (* z x)) (/ (* (* y_m x) 0.5) z))))
y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
double tmp;
if (x <= 1.45) {
tmp = y_m / (z * x);
} else {
tmp = ((y_m * x) * 0.5) / z;
}
return y_s * tmp;
}
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, y_m, z)
use fmin_fmax_functions
real(8), intent (in) :: y_s
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8) :: tmp
if (x <= 1.45d0) then
tmp = y_m / (z * x)
else
tmp = ((y_m * x) * 0.5d0) / z
end if
code = y_s * tmp
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
public static double code(double y_s, double x, double y_m, double z) {
double tmp;
if (x <= 1.45) {
tmp = y_m / (z * x);
} else {
tmp = ((y_m * x) * 0.5) / z;
}
return y_s * tmp;
}
y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) def code(y_s, x, y_m, z): tmp = 0 if x <= 1.45: tmp = y_m / (z * x) else: tmp = ((y_m * x) * 0.5) / z return y_s * tmp
y\_m = abs(y) y\_s = copysign(1.0, y) function code(y_s, x, y_m, z) tmp = 0.0 if (x <= 1.45) tmp = Float64(y_m / Float64(z * x)); else tmp = Float64(Float64(Float64(y_m * x) * 0.5) / z); end return Float64(y_s * tmp) end
y\_m = abs(y); y\_s = sign(y) * abs(1.0); function tmp_2 = code(y_s, x, y_m, z) tmp = 0.0; if (x <= 1.45) tmp = y_m / (z * x); else tmp = ((y_m * x) * 0.5) / z; end tmp_2 = y_s * tmp; end
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_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[x, 1.45], N[(y$95$m / N[(z * x), $MachinePrecision]), $MachinePrecision], N[(N[(N[(y$95$m * x), $MachinePrecision] * 0.5), $MachinePrecision] / z), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;x \leq 1.45:\\
\;\;\;\;\frac{y\_m}{z \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(y\_m \cdot x\right) \cdot 0.5}{z}\\
\end{array}
\end{array}
if x < 1.44999999999999996Initial program 87.6%
Taylor expanded in x around 0
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6469.3
Applied rewrites69.3%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6470.5
Applied rewrites70.5%
if 1.44999999999999996 < x Initial program 75.4%
Taylor expanded in x around 0
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6467.4
Applied rewrites67.4%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6435.1
Applied rewrites35.1%
y\_m = (fabs.f64 y) y\_s = (copysign.f64 #s(literal 1 binary64) y) (FPCore (y_s x y_m z) :precision binary64 (* y_s (/ y_m (* z x))))
y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
return y_s * (y_m / (z * x));
}
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, y_m, z)
use fmin_fmax_functions
real(8), intent (in) :: y_s
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
code = y_s * (y_m / (z * x))
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
public static double code(double y_s, double x, double y_m, double z) {
return y_s * (y_m / (z * x));
}
y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) def code(y_s, x, y_m, z): return y_s * (y_m / (z * x))
y\_m = abs(y) y\_s = copysign(1.0, y) function code(y_s, x, y_m, z) return Float64(y_s * Float64(y_m / Float64(z * x))) end
y\_m = abs(y); y\_s = sign(y) * abs(1.0); function tmp = code(y_s, x, y_m, z) tmp = y_s * (y_m / (z * x)); end
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_, y$95$m_, z_] := N[(y$95$s * N[(y$95$m / N[(z * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
y\_s \cdot \frac{y\_m}{z \cdot x}
\end{array}
Initial program 84.5%
Taylor expanded in x around 0
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6455.4
Applied rewrites55.4%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6454.5
Applied rewrites54.5%
herbie shell --seed 2025085
(FPCore (x y z)
:name "Linear.Quaternion:$ctan from linear-1.19.1.3"
:precision binary64
:alt
(! :herbie-platform default (if (< y -2309451133843521/5000000000000000000000000000000000000000000000000000000000000000000) (* (/ (/ y z) x) (cosh x)) (if (< y 1038530535935153/1000000000000000000000000000000000000000000000000000000) (/ (/ (* (cosh x) y) x) z) (* (/ (/ y z) x) (cosh x)))))
(/ (* (cosh x) (/ y x)) z))