
(FPCore (x) :precision binary64 (log (/ (sinh x) x)))
double code(double x) {
return log((sinh(x) / x));
}
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)
use fmin_fmax_functions
real(8), intent (in) :: x
code = log((sinh(x) / x))
end function
public static double code(double x) {
return Math.log((Math.sinh(x) / x));
}
def code(x): return math.log((math.sinh(x) / x))
function code(x) return log(Float64(sinh(x) / x)) end
function tmp = code(x) tmp = log((sinh(x) / x)); end
code[x_] := N[Log[N[(N[Sinh[x], $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\log \left(\frac{\sinh x}{x}\right)
\end{array}
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (log (/ (sinh x) x)))
double code(double x) {
return log((sinh(x) / x));
}
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)
use fmin_fmax_functions
real(8), intent (in) :: x
code = log((sinh(x) / x))
end function
public static double code(double x) {
return Math.log((Math.sinh(x) / x));
}
def code(x): return math.log((math.sinh(x) / x))
function code(x) return log(Float64(sinh(x) / x)) end
function tmp = code(x) tmp = log((sinh(x) / x)); end
code[x_] := N[Log[N[(N[Sinh[x], $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\log \left(\frac{\sinh x}{x}\right)
\end{array}
x_m = (fabs.f64 x)
(FPCore (x_m)
:precision binary64
(if (<= x_m 0.086)
(*
(*
(fma
(*
(fma
(fma -2.6455026455026456e-5 (* x_m x_m) 0.0003527336860670194)
(* x_m x_m)
-0.005555555555555556)
x_m)
x_m
0.16666666666666666)
x_m)
x_m)
(log (* (/ 1.0 x_m) (sinh x_m)))))x_m = fabs(x);
double code(double x_m) {
double tmp;
if (x_m <= 0.086) {
tmp = (fma((fma(fma(-2.6455026455026456e-5, (x_m * x_m), 0.0003527336860670194), (x_m * x_m), -0.005555555555555556) * x_m), x_m, 0.16666666666666666) * x_m) * x_m;
} else {
tmp = log(((1.0 / x_m) * sinh(x_m)));
}
return tmp;
}
x_m = abs(x) function code(x_m) tmp = 0.0 if (x_m <= 0.086) tmp = Float64(Float64(fma(Float64(fma(fma(-2.6455026455026456e-5, Float64(x_m * x_m), 0.0003527336860670194), Float64(x_m * x_m), -0.005555555555555556) * x_m), x_m, 0.16666666666666666) * x_m) * x_m); else tmp = log(Float64(Float64(1.0 / x_m) * sinh(x_m))); end return tmp end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_] := If[LessEqual[x$95$m, 0.086], N[(N[(N[(N[(N[(N[(-2.6455026455026456e-5 * N[(x$95$m * x$95$m), $MachinePrecision] + 0.0003527336860670194), $MachinePrecision] * N[(x$95$m * x$95$m), $MachinePrecision] + -0.005555555555555556), $MachinePrecision] * x$95$m), $MachinePrecision] * x$95$m + 0.16666666666666666), $MachinePrecision] * x$95$m), $MachinePrecision] * x$95$m), $MachinePrecision], N[Log[N[(N[(1.0 / x$95$m), $MachinePrecision] * N[Sinh[x$95$m], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;x\_m \leq 0.086:\\
\;\;\;\;\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-2.6455026455026456 \cdot 10^{-5}, x\_m \cdot x\_m, 0.0003527336860670194\right), x\_m \cdot x\_m, -0.005555555555555556\right) \cdot x\_m, x\_m, 0.16666666666666666\right) \cdot x\_m\right) \cdot x\_m\\
\mathbf{else}:\\
\;\;\;\;\log \left(\frac{1}{x\_m} \cdot \sinh x\_m\right)\\
\end{array}
\end{array}
if x < 0.085999999999999993Initial program 53.4%
Taylor expanded in x around 0
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6499.7
Applied rewrites99.7%
Taylor expanded in x around 0
log-divN/A
sinh-defN/A
sinh-undef-revN/A
*-commutativeN/A
associate-/l*N/A
metadata-evalN/A
metadata-evalN/A
associate-*l*N/A
*-commutativeN/A
*-rgt-identityN/A
log-divN/A
associate-*r/N/A
*-commutativeN/A
pow2N/A
associate-*r*N/A
Applied rewrites99.7%
if 0.085999999999999993 < x Initial program 42.4%
Taylor expanded in x around inf
sum-logN/A
lower-log.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
rec-expN/A
sinh-undefN/A
lower-*.f64N/A
lift-sinh.f64N/A
lower-/.f6442.4
Applied rewrites42.4%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-sinh.f64N/A
*-commutativeN/A
associate-*l*N/A
metadata-evalN/A
metadata-evalN/A
associate-/l*N/A
*-commutativeN/A
sinh-undef-revN/A
sinh-defN/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
lift-sinh.f6442.4
Applied rewrites42.4%
x_m = (fabs.f64 x)
(FPCore (x_m)
:precision binary64
(if (<= x_m 0.032)
(*
(fma
(fma (* x_m x_m) 0.0003527336860670194 -0.005555555555555556)
(* (* x_m x_m) x_m)
(* 0.16666666666666666 x_m))
x_m)
(log (* (/ 1.0 x_m) (sinh x_m)))))x_m = fabs(x);
double code(double x_m) {
double tmp;
if (x_m <= 0.032) {
tmp = fma(fma((x_m * x_m), 0.0003527336860670194, -0.005555555555555556), ((x_m * x_m) * x_m), (0.16666666666666666 * x_m)) * x_m;
} else {
tmp = log(((1.0 / x_m) * sinh(x_m)));
}
return tmp;
}
x_m = abs(x) function code(x_m) tmp = 0.0 if (x_m <= 0.032) tmp = Float64(fma(fma(Float64(x_m * x_m), 0.0003527336860670194, -0.005555555555555556), Float64(Float64(x_m * x_m) * x_m), Float64(0.16666666666666666 * x_m)) * x_m); else tmp = log(Float64(Float64(1.0 / x_m) * sinh(x_m))); end return tmp end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_] := If[LessEqual[x$95$m, 0.032], N[(N[(N[(N[(x$95$m * x$95$m), $MachinePrecision] * 0.0003527336860670194 + -0.005555555555555556), $MachinePrecision] * N[(N[(x$95$m * x$95$m), $MachinePrecision] * x$95$m), $MachinePrecision] + N[(0.16666666666666666 * x$95$m), $MachinePrecision]), $MachinePrecision] * x$95$m), $MachinePrecision], N[Log[N[(N[(1.0 / x$95$m), $MachinePrecision] * N[Sinh[x$95$m], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;x\_m \leq 0.032:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(x\_m \cdot x\_m, 0.0003527336860670194, -0.005555555555555556\right), \left(x\_m \cdot x\_m\right) \cdot x\_m, 0.16666666666666666 \cdot x\_m\right) \cdot x\_m\\
\mathbf{else}:\\
\;\;\;\;\log \left(\frac{1}{x\_m} \cdot \sinh x\_m\right)\\
\end{array}
\end{array}
if x < 0.032000000000000001Initial program 53.3%
Taylor expanded in x around 0
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6499.7
Applied rewrites99.7%
lift-*.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
+-commutativeN/A
pow2N/A
pow2N/A
*-commutativeN/A
distribute-rgt-inN/A
+-commutativeN/A
Applied rewrites99.7%
if 0.032000000000000001 < x Initial program 44.1%
Taylor expanded in x around inf
sum-logN/A
lower-log.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
rec-expN/A
sinh-undefN/A
lower-*.f64N/A
lift-sinh.f64N/A
lower-/.f6444.2
Applied rewrites44.2%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-sinh.f64N/A
*-commutativeN/A
associate-*l*N/A
metadata-evalN/A
metadata-evalN/A
associate-/l*N/A
*-commutativeN/A
sinh-undef-revN/A
sinh-defN/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
lift-sinh.f6444.2
Applied rewrites44.2%
x_m = (fabs.f64 x)
(FPCore (x_m)
:precision binary64
(if (<= x_m 0.032)
(*
(*
(fma
(fma (* x_m x_m) 0.0003527336860670194 -0.005555555555555556)
(* x_m x_m)
0.16666666666666666)
x_m)
x_m)
(log (* (/ 1.0 x_m) (sinh x_m)))))x_m = fabs(x);
double code(double x_m) {
double tmp;
if (x_m <= 0.032) {
tmp = (fma(fma((x_m * x_m), 0.0003527336860670194, -0.005555555555555556), (x_m * x_m), 0.16666666666666666) * x_m) * x_m;
} else {
tmp = log(((1.0 / x_m) * sinh(x_m)));
}
return tmp;
}
x_m = abs(x) function code(x_m) tmp = 0.0 if (x_m <= 0.032) tmp = Float64(Float64(fma(fma(Float64(x_m * x_m), 0.0003527336860670194, -0.005555555555555556), Float64(x_m * x_m), 0.16666666666666666) * x_m) * x_m); else tmp = log(Float64(Float64(1.0 / x_m) * sinh(x_m))); end return tmp end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_] := If[LessEqual[x$95$m, 0.032], N[(N[(N[(N[(N[(x$95$m * x$95$m), $MachinePrecision] * 0.0003527336860670194 + -0.005555555555555556), $MachinePrecision] * N[(x$95$m * x$95$m), $MachinePrecision] + 0.16666666666666666), $MachinePrecision] * x$95$m), $MachinePrecision] * x$95$m), $MachinePrecision], N[Log[N[(N[(1.0 / x$95$m), $MachinePrecision] * N[Sinh[x$95$m], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;x\_m \leq 0.032:\\
\;\;\;\;\left(\mathsf{fma}\left(\mathsf{fma}\left(x\_m \cdot x\_m, 0.0003527336860670194, -0.005555555555555556\right), x\_m \cdot x\_m, 0.16666666666666666\right) \cdot x\_m\right) \cdot x\_m\\
\mathbf{else}:\\
\;\;\;\;\log \left(\frac{1}{x\_m} \cdot \sinh x\_m\right)\\
\end{array}
\end{array}
if x < 0.032000000000000001Initial program 53.3%
Taylor expanded in x around 0
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6499.7
Applied rewrites99.7%
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
metadata-evalN/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
metadata-evalN/A
metadata-evalN/A
lower-fma.f64N/A
pow2N/A
lift-*.f6499.7
Applied rewrites99.7%
if 0.032000000000000001 < x Initial program 44.1%
Taylor expanded in x around inf
sum-logN/A
lower-log.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
rec-expN/A
sinh-undefN/A
lower-*.f64N/A
lift-sinh.f64N/A
lower-/.f6444.2
Applied rewrites44.2%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-sinh.f64N/A
*-commutativeN/A
associate-*l*N/A
metadata-evalN/A
metadata-evalN/A
associate-/l*N/A
*-commutativeN/A
sinh-undef-revN/A
sinh-defN/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
lift-sinh.f6444.2
Applied rewrites44.2%
x_m = (fabs.f64 x)
(FPCore (x_m)
:precision binary64
(if (<= x_m 0.032)
(*
(*
(fma
(fma (* x_m x_m) 0.0003527336860670194 -0.005555555555555556)
(* x_m x_m)
0.16666666666666666)
x_m)
x_m)
(log (/ (sinh x_m) x_m))))x_m = fabs(x);
double code(double x_m) {
double tmp;
if (x_m <= 0.032) {
tmp = (fma(fma((x_m * x_m), 0.0003527336860670194, -0.005555555555555556), (x_m * x_m), 0.16666666666666666) * x_m) * x_m;
} else {
tmp = log((sinh(x_m) / x_m));
}
return tmp;
}
x_m = abs(x) function code(x_m) tmp = 0.0 if (x_m <= 0.032) tmp = Float64(Float64(fma(fma(Float64(x_m * x_m), 0.0003527336860670194, -0.005555555555555556), Float64(x_m * x_m), 0.16666666666666666) * x_m) * x_m); else tmp = log(Float64(sinh(x_m) / x_m)); end return tmp end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_] := If[LessEqual[x$95$m, 0.032], N[(N[(N[(N[(N[(x$95$m * x$95$m), $MachinePrecision] * 0.0003527336860670194 + -0.005555555555555556), $MachinePrecision] * N[(x$95$m * x$95$m), $MachinePrecision] + 0.16666666666666666), $MachinePrecision] * x$95$m), $MachinePrecision] * x$95$m), $MachinePrecision], N[Log[N[(N[Sinh[x$95$m], $MachinePrecision] / x$95$m), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;x\_m \leq 0.032:\\
\;\;\;\;\left(\mathsf{fma}\left(\mathsf{fma}\left(x\_m \cdot x\_m, 0.0003527336860670194, -0.005555555555555556\right), x\_m \cdot x\_m, 0.16666666666666666\right) \cdot x\_m\right) \cdot x\_m\\
\mathbf{else}:\\
\;\;\;\;\log \left(\frac{\sinh x\_m}{x\_m}\right)\\
\end{array}
\end{array}
if x < 0.032000000000000001Initial program 53.3%
Taylor expanded in x around 0
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6499.7
Applied rewrites99.7%
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
metadata-evalN/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
metadata-evalN/A
metadata-evalN/A
lower-fma.f64N/A
pow2N/A
lift-*.f6499.7
Applied rewrites99.7%
if 0.032000000000000001 < x Initial program 44.1%
x_m = (fabs.f64 x) (FPCore (x_m) :precision binary64 (if (<= x_m 0.0065) (* (fma (* x_m x_m) -0.005555555555555556 0.16666666666666666) (* x_m x_m)) (log (/ (sinh x_m) x_m))))
x_m = fabs(x);
double code(double x_m) {
double tmp;
if (x_m <= 0.0065) {
tmp = fma((x_m * x_m), -0.005555555555555556, 0.16666666666666666) * (x_m * x_m);
} else {
tmp = log((sinh(x_m) / x_m));
}
return tmp;
}
x_m = abs(x) function code(x_m) tmp = 0.0 if (x_m <= 0.0065) tmp = Float64(fma(Float64(x_m * x_m), -0.005555555555555556, 0.16666666666666666) * Float64(x_m * x_m)); else tmp = log(Float64(sinh(x_m) / x_m)); end return tmp end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_] := If[LessEqual[x$95$m, 0.0065], N[(N[(N[(x$95$m * x$95$m), $MachinePrecision] * -0.005555555555555556 + 0.16666666666666666), $MachinePrecision] * N[(x$95$m * x$95$m), $MachinePrecision]), $MachinePrecision], N[Log[N[(N[Sinh[x$95$m], $MachinePrecision] / x$95$m), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;x\_m \leq 0.0065:\\
\;\;\;\;\mathsf{fma}\left(x\_m \cdot x\_m, -0.005555555555555556, 0.16666666666666666\right) \cdot \left(x\_m \cdot x\_m\right)\\
\mathbf{else}:\\
\;\;\;\;\log \left(\frac{\sinh x\_m}{x\_m}\right)\\
\end{array}
\end{array}
if x < 0.0064999999999999997Initial program 53.2%
Taylor expanded in x around 0
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6499.7
Applied rewrites99.7%
Applied rewrites99.7%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f6499.7
Applied rewrites99.7%
if 0.0064999999999999997 < x Initial program 47.1%
x_m = (fabs.f64 x) (FPCore (x_m) :precision binary64 (* (fma (* x_m x_m) -0.005555555555555556 0.16666666666666666) (* x_m x_m)))
x_m = fabs(x);
double code(double x_m) {
return fma((x_m * x_m), -0.005555555555555556, 0.16666666666666666) * (x_m * x_m);
}
x_m = abs(x) function code(x_m) return Float64(fma(Float64(x_m * x_m), -0.005555555555555556, 0.16666666666666666) * Float64(x_m * x_m)) end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_] := N[(N[(N[(x$95$m * x$95$m), $MachinePrecision] * -0.005555555555555556 + 0.16666666666666666), $MachinePrecision] * N[(x$95$m * x$95$m), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
\mathsf{fma}\left(x\_m \cdot x\_m, -0.005555555555555556, 0.16666666666666666\right) \cdot \left(x\_m \cdot x\_m\right)
\end{array}
Initial program 53.0%
Taylor expanded in x around 0
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6497.0
Applied rewrites97.0%
Applied rewrites97.1%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f6496.6
Applied rewrites96.6%
x_m = (fabs.f64 x) (FPCore (x_m) :precision binary64 (* (/ (* 0.004629629629629629 x_m) 0.027777777777777776) x_m))
x_m = fabs(x);
double code(double x_m) {
return ((0.004629629629629629 * x_m) / 0.027777777777777776) * x_m;
}
x_m = private
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x_m)
use fmin_fmax_functions
real(8), intent (in) :: x_m
code = ((0.004629629629629629d0 * x_m) / 0.027777777777777776d0) * x_m
end function
x_m = Math.abs(x);
public static double code(double x_m) {
return ((0.004629629629629629 * x_m) / 0.027777777777777776) * x_m;
}
x_m = math.fabs(x) def code(x_m): return ((0.004629629629629629 * x_m) / 0.027777777777777776) * x_m
x_m = abs(x) function code(x_m) return Float64(Float64(Float64(0.004629629629629629 * x_m) / 0.027777777777777776) * x_m) end
x_m = abs(x); function tmp = code(x_m) tmp = ((0.004629629629629629 * x_m) / 0.027777777777777776) * x_m; end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_] := N[(N[(N[(0.004629629629629629 * x$95$m), $MachinePrecision] / 0.027777777777777776), $MachinePrecision] * x$95$m), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
\frac{0.004629629629629629 \cdot x\_m}{0.027777777777777776} \cdot x\_m
\end{array}
Initial program 53.0%
Taylor expanded in x around 0
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6497.0
Applied rewrites97.0%
Applied rewrites97.1%
Taylor expanded in x around 0
Applied rewrites96.4%
Taylor expanded in x around 0
Applied rewrites96.5%
x_m = (fabs.f64 x) (FPCore (x_m) :precision binary64 (* (* x_m x_m) 0.16666666666666666))
x_m = fabs(x);
double code(double x_m) {
return (x_m * x_m) * 0.16666666666666666;
}
x_m = private
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x_m)
use fmin_fmax_functions
real(8), intent (in) :: x_m
code = (x_m * x_m) * 0.16666666666666666d0
end function
x_m = Math.abs(x);
public static double code(double x_m) {
return (x_m * x_m) * 0.16666666666666666;
}
x_m = math.fabs(x) def code(x_m): return (x_m * x_m) * 0.16666666666666666
x_m = abs(x) function code(x_m) return Float64(Float64(x_m * x_m) * 0.16666666666666666) end
x_m = abs(x); function tmp = code(x_m) tmp = (x_m * x_m) * 0.16666666666666666; end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_] := N[(N[(x$95$m * x$95$m), $MachinePrecision] * 0.16666666666666666), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
\left(x\_m \cdot x\_m\right) \cdot 0.16666666666666666
\end{array}
Initial program 53.0%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6496.5
Applied rewrites96.5%
x_m = (fabs.f64 x) (FPCore (x_m) :precision binary64 (log 1.0))
x_m = fabs(x);
double code(double x_m) {
return log(1.0);
}
x_m = private
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x_m)
use fmin_fmax_functions
real(8), intent (in) :: x_m
code = log(1.0d0)
end function
x_m = Math.abs(x);
public static double code(double x_m) {
return Math.log(1.0);
}
x_m = math.fabs(x) def code(x_m): return math.log(1.0)
x_m = abs(x) function code(x_m) return log(1.0) end
x_m = abs(x); function tmp = code(x_m) tmp = log(1.0); end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_] := N[Log[1.0], $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
\log 1
\end{array}
Initial program 53.0%
Taylor expanded in x around 0
Applied rewrites50.7%
herbie shell --seed 2025093
(FPCore (x)
:name "bug500, discussion (missed optimization)"
:precision binary64
(log (/ (sinh x) x)))