
(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 12 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)
(FPCore (x_s x_m y z)
:precision binary64
(*
x_s
(if (<= x_m 4.2e+142)
(/ (* (cosh x_m) y) (* z x_m))
(/ (* y (/ (fma (* x_m x_m) 0.5 1.0) z)) x_m))))x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z) {
double tmp;
if (x_m <= 4.2e+142) {
tmp = (cosh(x_m) * y) / (z * x_m);
} else {
tmp = (y * (fma((x_m * x_m), 0.5, 1.0) / z)) / x_m;
}
return x_s * tmp;
}
x\_m = abs(x) x\_s = copysign(1.0, x) function code(x_s, x_m, y, z) tmp = 0.0 if (x_m <= 4.2e+142) tmp = Float64(Float64(cosh(x_m) * y) / Float64(z * x_m)); else tmp = Float64(Float64(y * Float64(fma(Float64(x_m * x_m), 0.5, 1.0) / z)) / x_m); end return 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]
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * If[LessEqual[x$95$m, 4.2e+142], N[(N[(N[Cosh[x$95$m], $MachinePrecision] * y), $MachinePrecision] / N[(z * x$95$m), $MachinePrecision]), $MachinePrecision], N[(N[(y * N[(N[(N[(x$95$m * x$95$m), $MachinePrecision] * 0.5 + 1.0), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision] / x$95$m), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;x\_m \leq 4.2 \cdot 10^{+142}:\\
\;\;\;\;\frac{\cosh x\_m \cdot y}{z \cdot x\_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{y \cdot \frac{\mathsf{fma}\left(x\_m \cdot x\_m, 0.5, 1\right)}{z}}{x\_m}\\
\end{array}
\end{array}
if x < 4.2e142Initial program 84.9%
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-*.f6483.7
Applied rewrites83.7%
if 4.2e142 < x Initial program 84.9%
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-*.f6481.3
Applied rewrites81.3%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6477.3
Applied rewrites77.3%
lift-/.f64N/A
lift-fma.f64N/A
div-addN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
pow2N/A
div-add-revN/A
+-commutativeN/A
div-addN/A
*-lft-identityN/A
div-addN/A
associate-*r*N/A
distribute-rgt-inN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
Applied rewrites81.4%
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
(FPCore (x_s x_m y z)
:precision binary64
(*
x_s
(if (<= x_m 4.2e+142)
(* y (/ (cosh x_m) (* x_m z)))
(/ (* y (/ (fma (* x_m x_m) 0.5 1.0) z)) x_m))))x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z) {
double tmp;
if (x_m <= 4.2e+142) {
tmp = y * (cosh(x_m) / (x_m * z));
} else {
tmp = (y * (fma((x_m * x_m), 0.5, 1.0) / z)) / x_m;
}
return x_s * tmp;
}
x\_m = abs(x) x\_s = copysign(1.0, x) function code(x_s, x_m, y, z) tmp = 0.0 if (x_m <= 4.2e+142) tmp = Float64(y * Float64(cosh(x_m) / Float64(x_m * z))); else tmp = Float64(Float64(y * Float64(fma(Float64(x_m * x_m), 0.5, 1.0) / z)) / x_m); end return 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]
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * If[LessEqual[x$95$m, 4.2e+142], N[(y * N[(N[Cosh[x$95$m], $MachinePrecision] / N[(x$95$m * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y * N[(N[(N[(x$95$m * x$95$m), $MachinePrecision] * 0.5 + 1.0), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision] / x$95$m), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;x\_m \leq 4.2 \cdot 10^{+142}:\\
\;\;\;\;y \cdot \frac{\cosh x\_m}{x\_m \cdot z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y \cdot \frac{\mathsf{fma}\left(x\_m \cdot x\_m, 0.5, 1\right)}{z}}{x\_m}\\
\end{array}
\end{array}
if x < 4.2e142Initial program 84.9%
lift-/.f64N/A
lift-*.f64N/A
lift-cosh.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lift-cosh.f6484.9
Applied rewrites84.9%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
lift-cosh.f64N/A
frac-timesN/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lift-cosh.f6490.4
Applied rewrites90.4%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
lift-cosh.f64N/A
frac-timesN/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-/.f64N/A
lift-cosh.f64N/A
lower-*.f6483.3
Applied rewrites83.3%
if 4.2e142 < x Initial program 84.9%
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-*.f6481.3
Applied rewrites81.3%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6477.3
Applied rewrites77.3%
lift-/.f64N/A
lift-fma.f64N/A
div-addN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
pow2N/A
div-add-revN/A
+-commutativeN/A
div-addN/A
*-lft-identityN/A
div-addN/A
associate-*r*N/A
distribute-rgt-inN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
Applied rewrites81.4%
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
(FPCore (x_s x_m y z)
:precision binary64
(*
x_s
(if (<= (/ (* (cosh x_m) (/ y x_m)) z) 5e+149)
(/ (fma x_m (* (* x_m y) 0.5) y) (* z x_m))
(/ (* y (/ (fma (* x_m x_m) 0.5 1.0) z)) x_m))))x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z) {
double tmp;
if (((cosh(x_m) * (y / x_m)) / z) <= 5e+149) {
tmp = fma(x_m, ((x_m * y) * 0.5), y) / (z * x_m);
} else {
tmp = (y * (fma((x_m * x_m), 0.5, 1.0) / z)) / x_m;
}
return x_s * tmp;
}
x\_m = abs(x) x\_s = copysign(1.0, x) function code(x_s, x_m, y, z) tmp = 0.0 if (Float64(Float64(cosh(x_m) * Float64(y / x_m)) / z) <= 5e+149) tmp = Float64(fma(x_m, Float64(Float64(x_m * y) * 0.5), y) / Float64(z * x_m)); else tmp = Float64(Float64(y * Float64(fma(Float64(x_m * x_m), 0.5, 1.0) / z)) / x_m); end return 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]
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * If[LessEqual[N[(N[(N[Cosh[x$95$m], $MachinePrecision] * N[(y / x$95$m), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], 5e+149], N[(N[(x$95$m * N[(N[(x$95$m * y), $MachinePrecision] * 0.5), $MachinePrecision] + y), $MachinePrecision] / N[(z * x$95$m), $MachinePrecision]), $MachinePrecision], N[(N[(y * N[(N[(N[(x$95$m * x$95$m), $MachinePrecision] * 0.5 + 1.0), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision] / x$95$m), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;\frac{\cosh x\_m \cdot \frac{y}{x\_m}}{z} \leq 5 \cdot 10^{+149}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x\_m, \left(x\_m \cdot y\right) \cdot 0.5, y\right)}{z \cdot x\_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{y \cdot \frac{\mathsf{fma}\left(x\_m \cdot x\_m, 0.5, 1\right)}{z}}{x\_m}\\
\end{array}
\end{array}
if (/.f64 (*.f64 (cosh.f64 x) (/.f64 y x)) z) < 4.9999999999999999e149Initial program 84.9%
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-*.f6481.3
Applied rewrites81.3%
lift-/.f64N/A
lift-/.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-/l/N/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
pow2N/A
associate-*r*N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f6469.4
Applied rewrites69.4%
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
*-commutativeN/A
lower-fma.f64N/A
associate-*r*N/A
*-commutativeN/A
pow2N/A
associate-*l*N/A
associate-*l*N/A
lower-fma.f64N/A
lower-*.f64N/A
lift-*.f6465.9
Applied rewrites65.9%
if 4.9999999999999999e149 < (/.f64 (*.f64 (cosh.f64 x) (/.f64 y x)) z) Initial program 84.9%
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-*.f6481.3
Applied rewrites81.3%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6477.3
Applied rewrites77.3%
lift-/.f64N/A
lift-fma.f64N/A
div-addN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
pow2N/A
div-add-revN/A
+-commutativeN/A
div-addN/A
*-lft-identityN/A
div-addN/A
associate-*r*N/A
distribute-rgt-inN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
Applied rewrites81.4%
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
(FPCore (x_s x_m y z)
:precision binary64
(*
x_s
(if (<= (* (cosh x_m) (/ y x_m)) 1e+265)
(/ (/ y x_m) z)
(* (* (/ (/ (fma x_m x_m 2.0) z) x_m) y) 0.5))))x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z) {
double tmp;
if ((cosh(x_m) * (y / x_m)) <= 1e+265) {
tmp = (y / x_m) / z;
} else {
tmp = (((fma(x_m, x_m, 2.0) / z) / x_m) * y) * 0.5;
}
return x_s * tmp;
}
x\_m = abs(x) x\_s = copysign(1.0, x) function code(x_s, x_m, y, z) tmp = 0.0 if (Float64(cosh(x_m) * Float64(y / x_m)) <= 1e+265) tmp = Float64(Float64(y / x_m) / z); else tmp = Float64(Float64(Float64(Float64(fma(x_m, x_m, 2.0) / z) / x_m) * y) * 0.5); end return 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]
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * If[LessEqual[N[(N[Cosh[x$95$m], $MachinePrecision] * N[(y / x$95$m), $MachinePrecision]), $MachinePrecision], 1e+265], N[(N[(y / x$95$m), $MachinePrecision] / z), $MachinePrecision], N[(N[(N[(N[(N[(x$95$m * x$95$m + 2.0), $MachinePrecision] / z), $MachinePrecision] / x$95$m), $MachinePrecision] * y), $MachinePrecision] * 0.5), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;\cosh x\_m \cdot \frac{y}{x\_m} \leq 10^{+265}:\\
\;\;\;\;\frac{\frac{y}{x\_m}}{z}\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{\frac{\mathsf{fma}\left(x\_m, x\_m, 2\right)}{z}}{x\_m} \cdot y\right) \cdot 0.5\\
\end{array}
\end{array}
if (*.f64 (cosh.f64 x) (/.f64 y x)) < 1.00000000000000007e265Initial program 84.9%
Taylor expanded in x around 0
lift-/.f6449.9
Applied rewrites49.9%
if 1.00000000000000007e265 < (*.f64 (cosh.f64 x) (/.f64 y x)) Initial program 84.9%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
rec-expN/A
cosh-undefN/A
lower-*.f64N/A
lift-cosh.f64N/A
*-commutativeN/A
lower-*.f6483.3
Applied rewrites83.3%
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.f6479.8
Applied rewrites79.8%
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
(FPCore (x_s x_m y z)
:precision binary64
(*
x_s
(if (<= x_m 1.55e+76)
(/ (fma x_m (* (* x_m y) 0.5) y) (* z x_m))
(* (* (/ (/ (* x_m x_m) z) x_m) y) 0.5))))x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z) {
double tmp;
if (x_m <= 1.55e+76) {
tmp = fma(x_m, ((x_m * y) * 0.5), y) / (z * x_m);
} else {
tmp = ((((x_m * x_m) / z) / x_m) * y) * 0.5;
}
return x_s * tmp;
}
x\_m = abs(x) x\_s = copysign(1.0, x) function code(x_s, x_m, y, z) tmp = 0.0 if (x_m <= 1.55e+76) tmp = Float64(fma(x_m, Float64(Float64(x_m * y) * 0.5), y) / Float64(z * x_m)); else tmp = Float64(Float64(Float64(Float64(Float64(x_m * x_m) / z) / x_m) * y) * 0.5); end return 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]
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * If[LessEqual[x$95$m, 1.55e+76], N[(N[(x$95$m * N[(N[(x$95$m * y), $MachinePrecision] * 0.5), $MachinePrecision] + y), $MachinePrecision] / N[(z * x$95$m), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(x$95$m * x$95$m), $MachinePrecision] / z), $MachinePrecision] / x$95$m), $MachinePrecision] * y), $MachinePrecision] * 0.5), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;x\_m \leq 1.55 \cdot 10^{+76}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x\_m, \left(x\_m \cdot y\right) \cdot 0.5, y\right)}{z \cdot x\_m}\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{\frac{x\_m \cdot x\_m}{z}}{x\_m} \cdot y\right) \cdot 0.5\\
\end{array}
\end{array}
if x < 1.55000000000000006e76Initial program 84.9%
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-*.f6481.3
Applied rewrites81.3%
lift-/.f64N/A
lift-/.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-/l/N/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
pow2N/A
associate-*r*N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f6469.4
Applied rewrites69.4%
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
*-commutativeN/A
lower-fma.f64N/A
associate-*r*N/A
*-commutativeN/A
pow2N/A
associate-*l*N/A
associate-*l*N/A
lower-fma.f64N/A
lower-*.f64N/A
lift-*.f6465.9
Applied rewrites65.9%
if 1.55000000000000006e76 < x Initial program 84.9%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
rec-expN/A
cosh-undefN/A
lower-*.f64N/A
lift-cosh.f64N/A
*-commutativeN/A
lower-*.f6483.3
Applied rewrites83.3%
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.f6479.8
Applied rewrites79.8%
Taylor expanded in x around inf
pow2N/A
lower-*.f6439.1
Applied rewrites39.1%
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
(FPCore (x_s x_m y z)
:precision binary64
(*
x_s
(if (<= x_m 1.55e+76)
(* (/ (* (fma x_m x_m 2.0) y) (* z x_m)) 0.5)
(* (* (/ (/ (* x_m x_m) z) x_m) y) 0.5))))x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z) {
double tmp;
if (x_m <= 1.55e+76) {
tmp = ((fma(x_m, x_m, 2.0) * y) / (z * x_m)) * 0.5;
} else {
tmp = ((((x_m * x_m) / z) / x_m) * y) * 0.5;
}
return x_s * tmp;
}
x\_m = abs(x) x\_s = copysign(1.0, x) function code(x_s, x_m, y, z) tmp = 0.0 if (x_m <= 1.55e+76) tmp = Float64(Float64(Float64(fma(x_m, x_m, 2.0) * y) / Float64(z * x_m)) * 0.5); else tmp = Float64(Float64(Float64(Float64(Float64(x_m * x_m) / z) / x_m) * y) * 0.5); end return 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]
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * If[LessEqual[x$95$m, 1.55e+76], N[(N[(N[(N[(x$95$m * x$95$m + 2.0), $MachinePrecision] * y), $MachinePrecision] / N[(z * x$95$m), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[(N[(N[(x$95$m * x$95$m), $MachinePrecision] / z), $MachinePrecision] / x$95$m), $MachinePrecision] * y), $MachinePrecision] * 0.5), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;x\_m \leq 1.55 \cdot 10^{+76}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x\_m, x\_m, 2\right) \cdot y}{z \cdot x\_m} \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{\frac{x\_m \cdot x\_m}{z}}{x\_m} \cdot y\right) \cdot 0.5\\
\end{array}
\end{array}
if x < 1.55000000000000006e76Initial program 84.9%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
rec-expN/A
cosh-undefN/A
lower-*.f64N/A
lift-cosh.f64N/A
*-commutativeN/A
lower-*.f6483.3
Applied rewrites83.3%
Taylor expanded in x around 0
+-commutativeN/A
pow2N/A
lower-fma.f6468.3
Applied rewrites68.3%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-*.f64N/A
*-commutativeN/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lift-*.f6469.4
Applied rewrites69.4%
if 1.55000000000000006e76 < x Initial program 84.9%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
rec-expN/A
cosh-undefN/A
lower-*.f64N/A
lift-cosh.f64N/A
*-commutativeN/A
lower-*.f6483.3
Applied rewrites83.3%
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.f6479.8
Applied rewrites79.8%
Taylor expanded in x around inf
pow2N/A
lower-*.f6439.1
Applied rewrites39.1%
x\_m = (fabs.f64 x) x\_s = (copysign.f64 #s(literal 1 binary64) x) (FPCore (x_s x_m y z) :precision binary64 (* x_s (if (<= x_m 1.4) (/ y (* z x_m)) (* (* (/ (/ (* x_m x_m) z) x_m) y) 0.5))))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z) {
double tmp;
if (x_m <= 1.4) {
tmp = y / (z * x_m);
} else {
tmp = ((((x_m * x_m) / z) / x_m) * y) * 0.5;
}
return x_s * tmp;
}
x\_m = private
x\_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(x_s, x_m, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (x_m <= 1.4d0) then
tmp = y / (z * x_m)
else
tmp = ((((x_m * x_m) / z) / x_m) * y) * 0.5d0
end if
code = x_s * tmp
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z) {
double tmp;
if (x_m <= 1.4) {
tmp = y / (z * x_m);
} else {
tmp = ((((x_m * x_m) / z) / x_m) * y) * 0.5;
}
return x_s * tmp;
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) def code(x_s, x_m, y, z): tmp = 0 if x_m <= 1.4: tmp = y / (z * x_m) else: tmp = ((((x_m * x_m) / z) / x_m) * y) * 0.5 return x_s * tmp
x\_m = abs(x) x\_s = copysign(1.0, x) function code(x_s, x_m, y, z) tmp = 0.0 if (x_m <= 1.4) tmp = Float64(y / Float64(z * x_m)); else tmp = Float64(Float64(Float64(Float64(Float64(x_m * x_m) / z) / x_m) * y) * 0.5); end return Float64(x_s * tmp) end
x\_m = abs(x); x\_s = sign(x) * abs(1.0); function tmp_2 = code(x_s, x_m, y, z) tmp = 0.0; if (x_m <= 1.4) tmp = y / (z * x_m); else tmp = ((((x_m * x_m) / z) / x_m) * y) * 0.5; end tmp_2 = 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]
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * If[LessEqual[x$95$m, 1.4], N[(y / N[(z * x$95$m), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(x$95$m * x$95$m), $MachinePrecision] / z), $MachinePrecision] / x$95$m), $MachinePrecision] * y), $MachinePrecision] * 0.5), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;x\_m \leq 1.4:\\
\;\;\;\;\frac{y}{z \cdot x\_m}\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{\frac{x\_m \cdot x\_m}{z}}{x\_m} \cdot y\right) \cdot 0.5\\
\end{array}
\end{array}
if x < 1.3999999999999999Initial program 84.9%
Taylor expanded in x around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f6450.0
Applied rewrites50.0%
if 1.3999999999999999 < x Initial program 84.9%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
rec-expN/A
cosh-undefN/A
lower-*.f64N/A
lift-cosh.f64N/A
*-commutativeN/A
lower-*.f6483.3
Applied rewrites83.3%
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.f6479.8
Applied rewrites79.8%
Taylor expanded in x around inf
pow2N/A
lower-*.f6439.1
Applied rewrites39.1%
x\_m = (fabs.f64 x) x\_s = (copysign.f64 #s(literal 1 binary64) x) (FPCore (x_s x_m y z) :precision binary64 (* x_s (if (<= x_m 1.4) (/ y (* z x_m)) (* (* (/ (* x_m x_m) (* z x_m)) y) 0.5))))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z) {
double tmp;
if (x_m <= 1.4) {
tmp = y / (z * x_m);
} else {
tmp = (((x_m * x_m) / (z * x_m)) * y) * 0.5;
}
return x_s * tmp;
}
x\_m = private
x\_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(x_s, x_m, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (x_m <= 1.4d0) then
tmp = y / (z * x_m)
else
tmp = (((x_m * x_m) / (z * x_m)) * y) * 0.5d0
end if
code = x_s * tmp
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z) {
double tmp;
if (x_m <= 1.4) {
tmp = y / (z * x_m);
} else {
tmp = (((x_m * x_m) / (z * x_m)) * y) * 0.5;
}
return x_s * tmp;
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) def code(x_s, x_m, y, z): tmp = 0 if x_m <= 1.4: tmp = y / (z * x_m) else: tmp = (((x_m * x_m) / (z * x_m)) * y) * 0.5 return x_s * tmp
x\_m = abs(x) x\_s = copysign(1.0, x) function code(x_s, x_m, y, z) tmp = 0.0 if (x_m <= 1.4) tmp = Float64(y / Float64(z * x_m)); else tmp = Float64(Float64(Float64(Float64(x_m * x_m) / Float64(z * x_m)) * y) * 0.5); end return Float64(x_s * tmp) end
x\_m = abs(x); x\_s = sign(x) * abs(1.0); function tmp_2 = code(x_s, x_m, y, z) tmp = 0.0; if (x_m <= 1.4) tmp = y / (z * x_m); else tmp = (((x_m * x_m) / (z * x_m)) * y) * 0.5; end tmp_2 = 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]
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * If[LessEqual[x$95$m, 1.4], N[(y / N[(z * x$95$m), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(x$95$m * x$95$m), $MachinePrecision] / N[(z * x$95$m), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision] * 0.5), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;x\_m \leq 1.4:\\
\;\;\;\;\frac{y}{z \cdot x\_m}\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{x\_m \cdot x\_m}{z \cdot x\_m} \cdot y\right) \cdot 0.5\\
\end{array}
\end{array}
if x < 1.3999999999999999Initial program 84.9%
Taylor expanded in x around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f6450.0
Applied rewrites50.0%
if 1.3999999999999999 < x Initial program 84.9%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
rec-expN/A
cosh-undefN/A
lower-*.f64N/A
lift-cosh.f64N/A
*-commutativeN/A
lower-*.f6483.3
Applied rewrites83.3%
Taylor expanded in x around 0
+-commutativeN/A
pow2N/A
lower-fma.f6468.3
Applied rewrites68.3%
Taylor expanded in x around inf
pow2N/A
lower-*.f6428.6
Applied rewrites28.6%
x\_m = (fabs.f64 x) x\_s = (copysign.f64 #s(literal 1 binary64) x) (FPCore (x_s x_m y z) :precision binary64 (* x_s (if (<= x_m 1.4) (/ y (* z x_m)) (* (* (/ x_m z) y) 0.5))))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z) {
double tmp;
if (x_m <= 1.4) {
tmp = y / (z * x_m);
} else {
tmp = ((x_m / z) * y) * 0.5;
}
return x_s * tmp;
}
x\_m = private
x\_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(x_s, x_m, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (x_m <= 1.4d0) then
tmp = y / (z * x_m)
else
tmp = ((x_m / z) * y) * 0.5d0
end if
code = x_s * tmp
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z) {
double tmp;
if (x_m <= 1.4) {
tmp = y / (z * x_m);
} else {
tmp = ((x_m / z) * y) * 0.5;
}
return x_s * tmp;
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) def code(x_s, x_m, y, z): tmp = 0 if x_m <= 1.4: tmp = y / (z * x_m) else: tmp = ((x_m / z) * y) * 0.5 return x_s * tmp
x\_m = abs(x) x\_s = copysign(1.0, x) function code(x_s, x_m, y, z) tmp = 0.0 if (x_m <= 1.4) tmp = Float64(y / Float64(z * x_m)); else tmp = Float64(Float64(Float64(x_m / z) * y) * 0.5); end return Float64(x_s * tmp) end
x\_m = abs(x); x\_s = sign(x) * abs(1.0); function tmp_2 = code(x_s, x_m, y, z) tmp = 0.0; if (x_m <= 1.4) tmp = y / (z * x_m); else tmp = ((x_m / z) * y) * 0.5; end tmp_2 = 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]
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * If[LessEqual[x$95$m, 1.4], N[(y / N[(z * x$95$m), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x$95$m / z), $MachinePrecision] * y), $MachinePrecision] * 0.5), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;x\_m \leq 1.4:\\
\;\;\;\;\frac{y}{z \cdot x\_m}\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{x\_m}{z} \cdot y\right) \cdot 0.5\\
\end{array}
\end{array}
if x < 1.3999999999999999Initial program 84.9%
Taylor expanded in x around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f6450.0
Applied rewrites50.0%
if 1.3999999999999999 < x Initial program 84.9%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
rec-expN/A
cosh-undefN/A
lower-*.f64N/A
lift-cosh.f64N/A
*-commutativeN/A
lower-*.f6483.3
Applied rewrites83.3%
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.f6479.8
Applied rewrites79.8%
Taylor expanded in x around inf
lower-/.f6425.7
Applied rewrites25.7%
x\_m = (fabs.f64 x) x\_s = (copysign.f64 #s(literal 1 binary64) x) (FPCore (x_s x_m y z) :precision binary64 (* x_s (if (<= x_m 1.4) (/ y (* z x_m)) (* (* x_m (/ y z)) 0.5))))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z) {
double tmp;
if (x_m <= 1.4) {
tmp = y / (z * x_m);
} else {
tmp = (x_m * (y / z)) * 0.5;
}
return x_s * tmp;
}
x\_m = private
x\_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(x_s, x_m, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (x_m <= 1.4d0) then
tmp = y / (z * x_m)
else
tmp = (x_m * (y / z)) * 0.5d0
end if
code = x_s * tmp
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z) {
double tmp;
if (x_m <= 1.4) {
tmp = y / (z * x_m);
} else {
tmp = (x_m * (y / z)) * 0.5;
}
return x_s * tmp;
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) def code(x_s, x_m, y, z): tmp = 0 if x_m <= 1.4: tmp = y / (z * x_m) else: tmp = (x_m * (y / z)) * 0.5 return x_s * tmp
x\_m = abs(x) x\_s = copysign(1.0, x) function code(x_s, x_m, y, z) tmp = 0.0 if (x_m <= 1.4) tmp = Float64(y / Float64(z * x_m)); else tmp = Float64(Float64(x_m * Float64(y / z)) * 0.5); end return Float64(x_s * tmp) end
x\_m = abs(x); x\_s = sign(x) * abs(1.0); function tmp_2 = code(x_s, x_m, y, z) tmp = 0.0; if (x_m <= 1.4) tmp = y / (z * x_m); else tmp = (x_m * (y / z)) * 0.5; end tmp_2 = 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]
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * If[LessEqual[x$95$m, 1.4], N[(y / N[(z * x$95$m), $MachinePrecision]), $MachinePrecision], N[(N[(x$95$m * N[(y / z), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;x\_m \leq 1.4:\\
\;\;\;\;\frac{y}{z \cdot x\_m}\\
\mathbf{else}:\\
\;\;\;\;\left(x\_m \cdot \frac{y}{z}\right) \cdot 0.5\\
\end{array}
\end{array}
if x < 1.3999999999999999Initial program 84.9%
Taylor expanded in x around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f6450.0
Applied rewrites50.0%
if 1.3999999999999999 < x Initial program 84.9%
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-*.f6481.3
Applied rewrites81.3%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6425.9
Applied rewrites25.9%
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
(FPCore (x_s x_m y z)
:precision binary64
(*
x_s
(if (<= (/ (* (cosh x_m) (/ y x_m)) z) 1e+30)
(/ y (* z x_m))
(/ (/ y z) x_m))))x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z) {
double tmp;
if (((cosh(x_m) * (y / x_m)) / z) <= 1e+30) {
tmp = y / (z * x_m);
} else {
tmp = (y / z) / x_m;
}
return x_s * tmp;
}
x\_m = private
x\_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(x_s, x_m, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (((cosh(x_m) * (y / x_m)) / z) <= 1d+30) then
tmp = y / (z * x_m)
else
tmp = (y / z) / x_m
end if
code = x_s * tmp
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z) {
double tmp;
if (((Math.cosh(x_m) * (y / x_m)) / z) <= 1e+30) {
tmp = y / (z * x_m);
} else {
tmp = (y / z) / x_m;
}
return x_s * tmp;
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) def code(x_s, x_m, y, z): tmp = 0 if ((math.cosh(x_m) * (y / x_m)) / z) <= 1e+30: tmp = y / (z * x_m) else: tmp = (y / z) / x_m return x_s * tmp
x\_m = abs(x) x\_s = copysign(1.0, x) function code(x_s, x_m, y, z) tmp = 0.0 if (Float64(Float64(cosh(x_m) * Float64(y / x_m)) / z) <= 1e+30) tmp = Float64(y / Float64(z * x_m)); else tmp = Float64(Float64(y / z) / x_m); end return Float64(x_s * tmp) end
x\_m = abs(x); x\_s = sign(x) * abs(1.0); function tmp_2 = code(x_s, x_m, y, z) tmp = 0.0; if (((cosh(x_m) * (y / x_m)) / z) <= 1e+30) tmp = y / (z * x_m); else tmp = (y / z) / x_m; end tmp_2 = 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]
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * If[LessEqual[N[(N[(N[Cosh[x$95$m], $MachinePrecision] * N[(y / x$95$m), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], 1e+30], N[(y / N[(z * x$95$m), $MachinePrecision]), $MachinePrecision], N[(N[(y / z), $MachinePrecision] / x$95$m), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;\frac{\cosh x\_m \cdot \frac{y}{x\_m}}{z} \leq 10^{+30}:\\
\;\;\;\;\frac{y}{z \cdot x\_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{y}{z}}{x\_m}\\
\end{array}
\end{array}
if (/.f64 (*.f64 (cosh.f64 x) (/.f64 y x)) z) < 1e30Initial program 84.9%
Taylor expanded in x around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f6450.0
Applied rewrites50.0%
if 1e30 < (/.f64 (*.f64 (cosh.f64 x) (/.f64 y x)) z) Initial program 84.9%
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-*.f6481.3
Applied rewrites81.3%
Taylor expanded in x around 0
Applied rewrites54.3%
x\_m = (fabs.f64 x) x\_s = (copysign.f64 #s(literal 1 binary64) x) (FPCore (x_s x_m y z) :precision binary64 (* x_s (/ y (* z x_m))))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z) {
return x_s * (y / (z * x_m));
}
x\_m = private
x\_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(x_s, x_m, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x_s * (y / (z * x_m))
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z) {
return x_s * (y / (z * x_m));
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) def code(x_s, x_m, y, z): return x_s * (y / (z * x_m))
x\_m = abs(x) x\_s = copysign(1.0, x) function code(x_s, x_m, y, z) return Float64(x_s * Float64(y / Float64(z * x_m))) end
x\_m = abs(x); x\_s = sign(x) * abs(1.0); function tmp = code(x_s, x_m, y, z) tmp = x_s * (y / (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]
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * N[(y / N[(z * x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot \frac{y}{z \cdot x\_m}
\end{array}
Initial program 84.9%
Taylor expanded in x around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f6450.0
Applied rewrites50.0%
herbie shell --seed 2025139
(FPCore (x y z)
:name "Linear.Quaternion:$ctan from linear-1.19.1.3"
:precision binary64
(/ (* (cosh x) (/ y x)) z))