
(FPCore (x y) :precision binary64 (/ (* (sin x) (sinh y)) x))
double code(double x, double y) {
return (sin(x) * sinh(y)) / 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, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (sin(x) * sinh(y)) / x
end function
public static double code(double x, double y) {
return (Math.sin(x) * Math.sinh(y)) / x;
}
def code(x, y): return (math.sin(x) * math.sinh(y)) / x
function code(x, y) return Float64(Float64(sin(x) * sinh(y)) / x) end
function tmp = code(x, y) tmp = (sin(x) * sinh(y)) / x; end
code[x_, y_] := N[(N[(N[Sin[x], $MachinePrecision] * N[Sinh[y], $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin x \cdot \sinh y}{x}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 19 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (/ (* (sin x) (sinh y)) x))
double code(double x, double y) {
return (sin(x) * sinh(y)) / 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, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (sin(x) * sinh(y)) / x
end function
public static double code(double x, double y) {
return (Math.sin(x) * Math.sinh(y)) / x;
}
def code(x, y): return (math.sin(x) * math.sinh(y)) / x
function code(x, y) return Float64(Float64(sin(x) * sinh(y)) / x) end
function tmp = code(x, y) tmp = (sin(x) * sinh(y)) / x; end
code[x_, y_] := N[(N[(N[Sin[x], $MachinePrecision] * N[Sinh[y], $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin x \cdot \sinh y}{x}
\end{array}
(FPCore (x y) :precision binary64 (* (/ (sinh y) x) (sin x)))
double code(double x, double y) {
return (sinh(y) / x) * sin(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, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (sinh(y) / x) * sin(x)
end function
public static double code(double x, double y) {
return (Math.sinh(y) / x) * Math.sin(x);
}
def code(x, y): return (math.sinh(y) / x) * math.sin(x)
function code(x, y) return Float64(Float64(sinh(y) / x) * sin(x)) end
function tmp = code(x, y) tmp = (sinh(y) / x) * sin(x); end
code[x_, y_] := N[(N[(N[Sinh[y], $MachinePrecision] / x), $MachinePrecision] * N[Sin[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sinh y}{x} \cdot \sin x
\end{array}
Initial program 87.6%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6499.9
Applied rewrites99.9%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (* (sin x) (sinh y)) x)))
(if (<= t_0 (- INFINITY))
(* (- (+ 1.0 y) (exp (- y))) 0.5)
(if (<= t_0 5e-52)
(* (/ (sin x) x) y)
(*
(fma
(fma (fabs (* 0.008333333333333333 y)) y 0.16666666666666666)
(* y y)
1.0)
y)))))
double code(double x, double y) {
double t_0 = (sin(x) * sinh(y)) / x;
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = ((1.0 + y) - exp(-y)) * 0.5;
} else if (t_0 <= 5e-52) {
tmp = (sin(x) / x) * y;
} else {
tmp = fma(fma(fabs((0.008333333333333333 * y)), y, 0.16666666666666666), (y * y), 1.0) * y;
}
return tmp;
}
function code(x, y) t_0 = Float64(Float64(sin(x) * sinh(y)) / x) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(Float64(Float64(1.0 + y) - exp(Float64(-y))) * 0.5); elseif (t_0 <= 5e-52) tmp = Float64(Float64(sin(x) / x) * y); else tmp = Float64(fma(fma(abs(Float64(0.008333333333333333 * y)), y, 0.16666666666666666), Float64(y * y), 1.0) * y); end return tmp end
code[x_, y_] := Block[{t$95$0 = N[(N[(N[Sin[x], $MachinePrecision] * N[Sinh[y], $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(N[(N[(1.0 + y), $MachinePrecision] - N[Exp[(-y)], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[t$95$0, 5e-52], N[(N[(N[Sin[x], $MachinePrecision] / x), $MachinePrecision] * y), $MachinePrecision], N[(N[(N[(N[Abs[N[(0.008333333333333333 * y), $MachinePrecision]], $MachinePrecision] * y + 0.16666666666666666), $MachinePrecision] * N[(y * y), $MachinePrecision] + 1.0), $MachinePrecision] * y), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sin x \cdot \sinh y}{x}\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;\left(\left(1 + y\right) - e^{-y}\right) \cdot 0.5\\
\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{-52}:\\
\;\;\;\;\frac{\sin x}{x} \cdot y\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\left|0.008333333333333333 \cdot y\right|, y, 0.16666666666666666\right), y \cdot y, 1\right) \cdot y\\
\end{array}
\end{array}
if (/.f64 (*.f64 (sin.f64 x) (sinh.f64 y)) x) < -inf.0Initial program 100.0%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
rec-expN/A
lower-exp.f64N/A
lower-neg.f6472.9
Applied rewrites72.9%
Taylor expanded in y around 0
Applied rewrites72.9%
if -inf.0 < (/.f64 (*.f64 (sin.f64 x) (sinh.f64 y)) x) < 5e-52Initial program 76.3%
Taylor expanded in y around 0
*-commutativeN/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
lower-sin.f6499.5
Applied rewrites99.5%
if 5e-52 < (/.f64 (*.f64 (sin.f64 x) (sinh.f64 y)) x) Initial program 99.9%
Taylor expanded in y around 0
Applied rewrites79.0%
Taylor expanded in x around 0
Applied rewrites67.1%
Applied rewrites80.9%
(FPCore (x y) :precision binary64 (if (or (<= y -5800.0) (not (or (<= y 0.08) (not (<= y 4.2e+116))))) (sinh y) (* (* (fma (* y y) 0.16666666666666666 1.0) (/ (sin x) x)) y)))
double code(double x, double y) {
double tmp;
if ((y <= -5800.0) || !((y <= 0.08) || !(y <= 4.2e+116))) {
tmp = sinh(y);
} else {
tmp = (fma((y * y), 0.16666666666666666, 1.0) * (sin(x) / x)) * y;
}
return tmp;
}
function code(x, y) tmp = 0.0 if ((y <= -5800.0) || !((y <= 0.08) || !(y <= 4.2e+116))) tmp = sinh(y); else tmp = Float64(Float64(fma(Float64(y * y), 0.16666666666666666, 1.0) * Float64(sin(x) / x)) * y); end return tmp end
code[x_, y_] := If[Or[LessEqual[y, -5800.0], N[Not[Or[LessEqual[y, 0.08], N[Not[LessEqual[y, 4.2e+116]], $MachinePrecision]]], $MachinePrecision]], N[Sinh[y], $MachinePrecision], N[(N[(N[(N[(y * y), $MachinePrecision] * 0.16666666666666666 + 1.0), $MachinePrecision] * N[(N[Sin[x], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5800 \lor \neg \left(y \leq 0.08 \lor \neg \left(y \leq 4.2 \cdot 10^{+116}\right)\right):\\
\;\;\;\;\sinh y\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(y \cdot y, 0.16666666666666666, 1\right) \cdot \frac{\sin x}{x}\right) \cdot y\\
\end{array}
\end{array}
if y < -5800 or 0.0800000000000000017 < y < 4.2000000000000002e116Initial program 100.0%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
rec-expN/A
lower-exp.f64N/A
lower-neg.f6480.7
Applied rewrites80.7%
Applied rewrites80.7%
Applied rewrites80.7%
if -5800 < y < 0.0800000000000000017 or 4.2000000000000002e116 < y Initial program 82.2%
Applied rewrites60.2%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites97.7%
Applied rewrites97.7%
Final simplification92.5%
(FPCore (x y)
:precision binary64
(let* ((t_0 (fma (* y y) 0.16666666666666666 1.0)))
(if (<= y -5800.0)
(sinh y)
(if (<= y 0.08)
(* (* t_0 (/ (sin x) x)) y)
(if (<= y 4.2e+116) (sinh y) (* (/ (* t_0 (sin x)) x) y))))))
double code(double x, double y) {
double t_0 = fma((y * y), 0.16666666666666666, 1.0);
double tmp;
if (y <= -5800.0) {
tmp = sinh(y);
} else if (y <= 0.08) {
tmp = (t_0 * (sin(x) / x)) * y;
} else if (y <= 4.2e+116) {
tmp = sinh(y);
} else {
tmp = ((t_0 * sin(x)) / x) * y;
}
return tmp;
}
function code(x, y) t_0 = fma(Float64(y * y), 0.16666666666666666, 1.0) tmp = 0.0 if (y <= -5800.0) tmp = sinh(y); elseif (y <= 0.08) tmp = Float64(Float64(t_0 * Float64(sin(x) / x)) * y); elseif (y <= 4.2e+116) tmp = sinh(y); else tmp = Float64(Float64(Float64(t_0 * sin(x)) / x) * y); end return tmp end
code[x_, y_] := Block[{t$95$0 = N[(N[(y * y), $MachinePrecision] * 0.16666666666666666 + 1.0), $MachinePrecision]}, If[LessEqual[y, -5800.0], N[Sinh[y], $MachinePrecision], If[LessEqual[y, 0.08], N[(N[(t$95$0 * N[(N[Sin[x], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[y, 4.2e+116], N[Sinh[y], $MachinePrecision], N[(N[(N[(t$95$0 * N[Sin[x], $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] * y), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(y \cdot y, 0.16666666666666666, 1\right)\\
\mathbf{if}\;y \leq -5800:\\
\;\;\;\;\sinh y\\
\mathbf{elif}\;y \leq 0.08:\\
\;\;\;\;\left(t\_0 \cdot \frac{\sin x}{x}\right) \cdot y\\
\mathbf{elif}\;y \leq 4.2 \cdot 10^{+116}:\\
\;\;\;\;\sinh y\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0 \cdot \sin x}{x} \cdot y\\
\end{array}
\end{array}
if y < -5800 or 0.0800000000000000017 < y < 4.2000000000000002e116Initial program 100.0%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
rec-expN/A
lower-exp.f64N/A
lower-neg.f6480.7
Applied rewrites80.7%
Applied rewrites80.7%
Applied rewrites80.7%
if -5800 < y < 0.0800000000000000017Initial program 77.3%
Applied rewrites76.5%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.0%
Applied rewrites99.0%
if 4.2000000000000002e116 < y Initial program 100.0%
Applied rewrites0.0%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites92.7%
(FPCore (x y)
:precision binary64
(if (<= x 1.55e-12)
(sinh y)
(/
(*
(*
(sin x)
(fma (fma (* y y) 0.008333333333333333 0.16666666666666666) (* y y) 1.0))
y)
x)))
double code(double x, double y) {
double tmp;
if (x <= 1.55e-12) {
tmp = sinh(y);
} else {
tmp = ((sin(x) * fma(fma((y * y), 0.008333333333333333, 0.16666666666666666), (y * y), 1.0)) * y) / x;
}
return tmp;
}
function code(x, y) tmp = 0.0 if (x <= 1.55e-12) tmp = sinh(y); else tmp = Float64(Float64(Float64(sin(x) * fma(fma(Float64(y * y), 0.008333333333333333, 0.16666666666666666), Float64(y * y), 1.0)) * y) / x); end return tmp end
code[x_, y_] := If[LessEqual[x, 1.55e-12], N[Sinh[y], $MachinePrecision], N[(N[(N[(N[Sin[x], $MachinePrecision] * N[(N[(N[(y * y), $MachinePrecision] * 0.008333333333333333 + 0.16666666666666666), $MachinePrecision] * N[(y * y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.55 \cdot 10^{-12}:\\
\;\;\;\;\sinh y\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(\sin x \cdot \mathsf{fma}\left(\mathsf{fma}\left(y \cdot y, 0.008333333333333333, 0.16666666666666666\right), y \cdot y, 1\right)\right) \cdot y}{x}\\
\end{array}
\end{array}
if x < 1.5500000000000001e-12Initial program 83.7%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
rec-expN/A
lower-exp.f64N/A
lower-neg.f6448.3
Applied rewrites48.3%
Applied rewrites75.9%
Applied rewrites75.9%
if 1.5500000000000001e-12 < x Initial program 99.9%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites85.9%
(FPCore (x y)
:precision binary64
(if (<= x 2e-16)
(sinh y)
(*
(/
(*
(sin x)
(fma (fma (* y y) 0.008333333333333333 0.16666666666666666) (* y y) 1.0))
x)
y)))
double code(double x, double y) {
double tmp;
if (x <= 2e-16) {
tmp = sinh(y);
} else {
tmp = ((sin(x) * fma(fma((y * y), 0.008333333333333333, 0.16666666666666666), (y * y), 1.0)) / x) * y;
}
return tmp;
}
function code(x, y) tmp = 0.0 if (x <= 2e-16) tmp = sinh(y); else tmp = Float64(Float64(Float64(sin(x) * fma(fma(Float64(y * y), 0.008333333333333333, 0.16666666666666666), Float64(y * y), 1.0)) / x) * y); end return tmp end
code[x_, y_] := If[LessEqual[x, 2e-16], N[Sinh[y], $MachinePrecision], N[(N[(N[(N[Sin[x], $MachinePrecision] * N[(N[(N[(y * y), $MachinePrecision] * 0.008333333333333333 + 0.16666666666666666), $MachinePrecision] * N[(y * y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2 \cdot 10^{-16}:\\
\;\;\;\;\sinh y\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin x \cdot \mathsf{fma}\left(\mathsf{fma}\left(y \cdot y, 0.008333333333333333, 0.16666666666666666\right), y \cdot y, 1\right)}{x} \cdot y\\
\end{array}
\end{array}
if x < 2e-16Initial program 83.7%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
rec-expN/A
lower-exp.f64N/A
lower-neg.f6448.3
Applied rewrites48.3%
Applied rewrites75.9%
Applied rewrites75.9%
if 2e-16 < x Initial program 99.9%
Taylor expanded in y around 0
Applied rewrites81.4%
(FPCore (x y)
:precision binary64
(if (<= x 1.55e-12)
(sinh y)
(*
(* (sin x) y)
(/
(fma (fma 0.008333333333333333 (* y y) 0.16666666666666666) (* y y) 1.0)
x))))
double code(double x, double y) {
double tmp;
if (x <= 1.55e-12) {
tmp = sinh(y);
} else {
tmp = (sin(x) * y) * (fma(fma(0.008333333333333333, (y * y), 0.16666666666666666), (y * y), 1.0) / x);
}
return tmp;
}
function code(x, y) tmp = 0.0 if (x <= 1.55e-12) tmp = sinh(y); else tmp = Float64(Float64(sin(x) * y) * Float64(fma(fma(0.008333333333333333, Float64(y * y), 0.16666666666666666), Float64(y * y), 1.0) / x)); end return tmp end
code[x_, y_] := If[LessEqual[x, 1.55e-12], N[Sinh[y], $MachinePrecision], N[(N[(N[Sin[x], $MachinePrecision] * y), $MachinePrecision] * N[(N[(N[(0.008333333333333333 * N[(y * y), $MachinePrecision] + 0.16666666666666666), $MachinePrecision] * N[(y * y), $MachinePrecision] + 1.0), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.55 \cdot 10^{-12}:\\
\;\;\;\;\sinh y\\
\mathbf{else}:\\
\;\;\;\;\left(\sin x \cdot y\right) \cdot \frac{\mathsf{fma}\left(\mathsf{fma}\left(0.008333333333333333, y \cdot y, 0.16666666666666666\right), y \cdot y, 1\right)}{x}\\
\end{array}
\end{array}
if x < 1.5500000000000001e-12Initial program 83.7%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
rec-expN/A
lower-exp.f64N/A
lower-neg.f6448.3
Applied rewrites48.3%
Applied rewrites75.9%
Applied rewrites75.9%
if 1.5500000000000001e-12 < x Initial program 99.9%
Taylor expanded in y around 0
Applied rewrites81.4%
Applied rewrites81.4%
(FPCore (x y) :precision binary64 (if (<= x 4.2e+129) (sinh y) (* (- (+ 1.0 y) (exp (- y))) 0.5)))
double code(double x, double y) {
double tmp;
if (x <= 4.2e+129) {
tmp = sinh(y);
} else {
tmp = ((1.0 + y) - exp(-y)) * 0.5;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= 4.2d+129) then
tmp = sinh(y)
else
tmp = ((1.0d0 + y) - exp(-y)) * 0.5d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= 4.2e+129) {
tmp = Math.sinh(y);
} else {
tmp = ((1.0 + y) - Math.exp(-y)) * 0.5;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 4.2e+129: tmp = math.sinh(y) else: tmp = ((1.0 + y) - math.exp(-y)) * 0.5 return tmp
function code(x, y) tmp = 0.0 if (x <= 4.2e+129) tmp = sinh(y); else tmp = Float64(Float64(Float64(1.0 + y) - exp(Float64(-y))) * 0.5); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 4.2e+129) tmp = sinh(y); else tmp = ((1.0 + y) - exp(-y)) * 0.5; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 4.2e+129], N[Sinh[y], $MachinePrecision], N[(N[(N[(1.0 + y), $MachinePrecision] - N[Exp[(-y)], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 4.2 \cdot 10^{+129}:\\
\;\;\;\;\sinh y\\
\mathbf{else}:\\
\;\;\;\;\left(\left(1 + y\right) - e^{-y}\right) \cdot 0.5\\
\end{array}
\end{array}
if x < 4.19999999999999993e129Initial program 85.4%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
rec-expN/A
lower-exp.f64N/A
lower-neg.f6446.6
Applied rewrites46.6%
Applied rewrites71.4%
Applied rewrites71.4%
if 4.19999999999999993e129 < x Initial program 99.9%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
rec-expN/A
lower-exp.f64N/A
lower-neg.f6459.2
Applied rewrites59.2%
Taylor expanded in y around 0
Applied rewrites56.8%
(FPCore (x y) :precision binary64 (if (<= x 1.6e+147) (sinh y) (* (- (+ 1.0 y) (fma (- (* 0.5 y) 1.0) y 1.0)) 0.5)))
double code(double x, double y) {
double tmp;
if (x <= 1.6e+147) {
tmp = sinh(y);
} else {
tmp = ((1.0 + y) - fma(((0.5 * y) - 1.0), y, 1.0)) * 0.5;
}
return tmp;
}
function code(x, y) tmp = 0.0 if (x <= 1.6e+147) tmp = sinh(y); else tmp = Float64(Float64(Float64(1.0 + y) - fma(Float64(Float64(0.5 * y) - 1.0), y, 1.0)) * 0.5); end return tmp end
code[x_, y_] := If[LessEqual[x, 1.6e+147], N[Sinh[y], $MachinePrecision], N[(N[(N[(1.0 + y), $MachinePrecision] - N[(N[(N[(0.5 * y), $MachinePrecision] - 1.0), $MachinePrecision] * y + 1.0), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.6 \cdot 10^{+147}:\\
\;\;\;\;\sinh y\\
\mathbf{else}:\\
\;\;\;\;\left(\left(1 + y\right) - \mathsf{fma}\left(0.5 \cdot y - 1, y, 1\right)\right) \cdot 0.5\\
\end{array}
\end{array}
if x < 1.59999999999999989e147Initial program 85.8%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
rec-expN/A
lower-exp.f64N/A
lower-neg.f6446.5
Applied rewrites46.5%
Applied rewrites70.7%
Applied rewrites70.7%
if 1.59999999999999989e147 < x Initial program 99.9%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
rec-expN/A
lower-exp.f64N/A
lower-neg.f6461.8
Applied rewrites61.8%
Taylor expanded in y around 0
Applied rewrites50.2%
Taylor expanded in y around 0
Applied rewrites47.4%
Taylor expanded in y around 0
Applied rewrites56.5%
(FPCore (x y)
:precision binary64
(if (<= x 1.18e+57)
(*
(fma (* (fma (* y y) 0.008333333333333333 0.16666666666666666) y) y 1.0)
y)
(if (<= x 8.7e+142)
(*
(fma
(-
(* (* (fma -0.0001984126984126984 (* x x) 0.008333333333333333) x) x)
0.16666666666666666)
(* x x)
1.0)
y)
(* (- (+ 1.0 y) (fma (- (* 0.5 y) 1.0) y 1.0)) 0.5))))
double code(double x, double y) {
double tmp;
if (x <= 1.18e+57) {
tmp = fma((fma((y * y), 0.008333333333333333, 0.16666666666666666) * y), y, 1.0) * y;
} else if (x <= 8.7e+142) {
tmp = fma((((fma(-0.0001984126984126984, (x * x), 0.008333333333333333) * x) * x) - 0.16666666666666666), (x * x), 1.0) * y;
} else {
tmp = ((1.0 + y) - fma(((0.5 * y) - 1.0), y, 1.0)) * 0.5;
}
return tmp;
}
function code(x, y) tmp = 0.0 if (x <= 1.18e+57) tmp = Float64(fma(Float64(fma(Float64(y * y), 0.008333333333333333, 0.16666666666666666) * y), y, 1.0) * y); elseif (x <= 8.7e+142) tmp = Float64(fma(Float64(Float64(Float64(fma(-0.0001984126984126984, Float64(x * x), 0.008333333333333333) * x) * x) - 0.16666666666666666), Float64(x * x), 1.0) * y); else tmp = Float64(Float64(Float64(1.0 + y) - fma(Float64(Float64(0.5 * y) - 1.0), y, 1.0)) * 0.5); end return tmp end
code[x_, y_] := If[LessEqual[x, 1.18e+57], N[(N[(N[(N[(N[(y * y), $MachinePrecision] * 0.008333333333333333 + 0.16666666666666666), $MachinePrecision] * y), $MachinePrecision] * y + 1.0), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[x, 8.7e+142], N[(N[(N[(N[(N[(N[(-0.0001984126984126984 * N[(x * x), $MachinePrecision] + 0.008333333333333333), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision] - 0.16666666666666666), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision] * y), $MachinePrecision], N[(N[(N[(1.0 + y), $MachinePrecision] - N[(N[(N[(0.5 * y), $MachinePrecision] - 1.0), $MachinePrecision] * y + 1.0), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.18 \cdot 10^{+57}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(y \cdot y, 0.008333333333333333, 0.16666666666666666\right) \cdot y, y, 1\right) \cdot y\\
\mathbf{elif}\;x \leq 8.7 \cdot 10^{+142}:\\
\;\;\;\;\mathsf{fma}\left(\left(\mathsf{fma}\left(-0.0001984126984126984, x \cdot x, 0.008333333333333333\right) \cdot x\right) \cdot x - 0.16666666666666666, x \cdot x, 1\right) \cdot y\\
\mathbf{else}:\\
\;\;\;\;\left(\left(1 + y\right) - \mathsf{fma}\left(0.5 \cdot y - 1, y, 1\right)\right) \cdot 0.5\\
\end{array}
\end{array}
if x < 1.18e57Initial program 84.6%
Taylor expanded in y around 0
Applied rewrites89.6%
Taylor expanded in x around 0
Applied rewrites65.0%
Applied rewrites65.0%
if 1.18e57 < x < 8.6999999999999999e142Initial program 100.0%
Taylor expanded in y around 0
*-commutativeN/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
lower-sin.f6422.8
Applied rewrites22.8%
Taylor expanded in x around 0
Applied rewrites53.7%
if 8.6999999999999999e142 < x Initial program 99.9%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
rec-expN/A
lower-exp.f64N/A
lower-neg.f6461.4
Applied rewrites61.4%
Taylor expanded in y around 0
Applied rewrites47.7%
Taylor expanded in y around 0
Applied rewrites45.0%
Taylor expanded in y around 0
Applied rewrites53.6%
(FPCore (x y)
:precision binary64
(if (<= x 1.12e+135)
(*
(*
(fma
(fma
(fma 0.0003968253968253968 (* y y) 0.016666666666666666)
(* y y)
0.3333333333333333)
(* y y)
2.0)
y)
0.5)
(* (- (+ 1.0 y) (fma (- (* 0.5 y) 1.0) y 1.0)) 0.5)))
double code(double x, double y) {
double tmp;
if (x <= 1.12e+135) {
tmp = (fma(fma(fma(0.0003968253968253968, (y * y), 0.016666666666666666), (y * y), 0.3333333333333333), (y * y), 2.0) * y) * 0.5;
} else {
tmp = ((1.0 + y) - fma(((0.5 * y) - 1.0), y, 1.0)) * 0.5;
}
return tmp;
}
function code(x, y) tmp = 0.0 if (x <= 1.12e+135) tmp = Float64(Float64(fma(fma(fma(0.0003968253968253968, Float64(y * y), 0.016666666666666666), Float64(y * y), 0.3333333333333333), Float64(y * y), 2.0) * y) * 0.5); else tmp = Float64(Float64(Float64(1.0 + y) - fma(Float64(Float64(0.5 * y) - 1.0), y, 1.0)) * 0.5); end return tmp end
code[x_, y_] := If[LessEqual[x, 1.12e+135], N[(N[(N[(N[(N[(0.0003968253968253968 * N[(y * y), $MachinePrecision] + 0.016666666666666666), $MachinePrecision] * N[(y * y), $MachinePrecision] + 0.3333333333333333), $MachinePrecision] * N[(y * y), $MachinePrecision] + 2.0), $MachinePrecision] * y), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[(1.0 + y), $MachinePrecision] - N[(N[(N[(0.5 * y), $MachinePrecision] - 1.0), $MachinePrecision] * y + 1.0), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.12 \cdot 10^{+135}:\\
\;\;\;\;\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.0003968253968253968, y \cdot y, 0.016666666666666666\right), y \cdot y, 0.3333333333333333\right), y \cdot y, 2\right) \cdot y\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\left(\left(1 + y\right) - \mathsf{fma}\left(0.5 \cdot y - 1, y, 1\right)\right) \cdot 0.5\\
\end{array}
\end{array}
if x < 1.1199999999999999e135Initial program 85.5%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
rec-expN/A
lower-exp.f64N/A
lower-neg.f6446.9
Applied rewrites46.9%
Taylor expanded in y around 0
Applied rewrites65.3%
if 1.1199999999999999e135 < x Initial program 99.9%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
rec-expN/A
lower-exp.f64N/A
lower-neg.f6458.1
Applied rewrites58.1%
Taylor expanded in y around 0
Applied rewrites45.1%
Taylor expanded in y around 0
Applied rewrites42.6%
Taylor expanded in y around 0
Applied rewrites50.8%
(FPCore (x y)
:precision binary64
(if (<= x 1.12e+135)
(*
(fma (* (fma (* y y) 0.008333333333333333 0.16666666666666666) y) y 1.0)
y)
(* (- (+ 1.0 y) (fma (- (* 0.5 y) 1.0) y 1.0)) 0.5)))
double code(double x, double y) {
double tmp;
if (x <= 1.12e+135) {
tmp = fma((fma((y * y), 0.008333333333333333, 0.16666666666666666) * y), y, 1.0) * y;
} else {
tmp = ((1.0 + y) - fma(((0.5 * y) - 1.0), y, 1.0)) * 0.5;
}
return tmp;
}
function code(x, y) tmp = 0.0 if (x <= 1.12e+135) tmp = Float64(fma(Float64(fma(Float64(y * y), 0.008333333333333333, 0.16666666666666666) * y), y, 1.0) * y); else tmp = Float64(Float64(Float64(1.0 + y) - fma(Float64(Float64(0.5 * y) - 1.0), y, 1.0)) * 0.5); end return tmp end
code[x_, y_] := If[LessEqual[x, 1.12e+135], N[(N[(N[(N[(N[(y * y), $MachinePrecision] * 0.008333333333333333 + 0.16666666666666666), $MachinePrecision] * y), $MachinePrecision] * y + 1.0), $MachinePrecision] * y), $MachinePrecision], N[(N[(N[(1.0 + y), $MachinePrecision] - N[(N[(N[(0.5 * y), $MachinePrecision] - 1.0), $MachinePrecision] * y + 1.0), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.12 \cdot 10^{+135}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(y \cdot y, 0.008333333333333333, 0.16666666666666666\right) \cdot y, y, 1\right) \cdot y\\
\mathbf{else}:\\
\;\;\;\;\left(\left(1 + y\right) - \mathsf{fma}\left(0.5 \cdot y - 1, y, 1\right)\right) \cdot 0.5\\
\end{array}
\end{array}
if x < 1.1199999999999999e135Initial program 85.5%
Taylor expanded in y around 0
Applied rewrites88.4%
Taylor expanded in x around 0
Applied rewrites63.1%
Applied rewrites63.1%
if 1.1199999999999999e135 < x Initial program 99.9%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
rec-expN/A
lower-exp.f64N/A
lower-neg.f6458.1
Applied rewrites58.1%
Taylor expanded in y around 0
Applied rewrites45.1%
Taylor expanded in y around 0
Applied rewrites42.6%
Taylor expanded in y around 0
Applied rewrites50.8%
(FPCore (x y) :precision binary64 (if (<= x 1.12e+135) (* (fma (* (* 0.008333333333333333 y) y) (* y y) 1.0) y) (* (- (+ 1.0 y) (fma (- (* 0.5 y) 1.0) y 1.0)) 0.5)))
double code(double x, double y) {
double tmp;
if (x <= 1.12e+135) {
tmp = fma(((0.008333333333333333 * y) * y), (y * y), 1.0) * y;
} else {
tmp = ((1.0 + y) - fma(((0.5 * y) - 1.0), y, 1.0)) * 0.5;
}
return tmp;
}
function code(x, y) tmp = 0.0 if (x <= 1.12e+135) tmp = Float64(fma(Float64(Float64(0.008333333333333333 * y) * y), Float64(y * y), 1.0) * y); else tmp = Float64(Float64(Float64(1.0 + y) - fma(Float64(Float64(0.5 * y) - 1.0), y, 1.0)) * 0.5); end return tmp end
code[x_, y_] := If[LessEqual[x, 1.12e+135], N[(N[(N[(N[(0.008333333333333333 * y), $MachinePrecision] * y), $MachinePrecision] * N[(y * y), $MachinePrecision] + 1.0), $MachinePrecision] * y), $MachinePrecision], N[(N[(N[(1.0 + y), $MachinePrecision] - N[(N[(N[(0.5 * y), $MachinePrecision] - 1.0), $MachinePrecision] * y + 1.0), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.12 \cdot 10^{+135}:\\
\;\;\;\;\mathsf{fma}\left(\left(0.008333333333333333 \cdot y\right) \cdot y, y \cdot y, 1\right) \cdot y\\
\mathbf{else}:\\
\;\;\;\;\left(\left(1 + y\right) - \mathsf{fma}\left(0.5 \cdot y - 1, y, 1\right)\right) \cdot 0.5\\
\end{array}
\end{array}
if x < 1.1199999999999999e135Initial program 85.5%
Taylor expanded in y around 0
Applied rewrites88.4%
Taylor expanded in x around 0
Applied rewrites63.1%
Taylor expanded in y around inf
Applied rewrites63.0%
Applied rewrites63.0%
if 1.1199999999999999e135 < x Initial program 99.9%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
rec-expN/A
lower-exp.f64N/A
lower-neg.f6458.1
Applied rewrites58.1%
Taylor expanded in y around 0
Applied rewrites45.1%
Taylor expanded in y around 0
Applied rewrites42.6%
Taylor expanded in y around 0
Applied rewrites50.8%
(FPCore (x y) :precision binary64 (if (<= x 1.22e+30) (* (fma (* y y) 0.16666666666666666 1.0) y) (* (- (+ 1.0 y) (fma (- (* 0.5 y) 1.0) y 1.0)) 0.5)))
double code(double x, double y) {
double tmp;
if (x <= 1.22e+30) {
tmp = fma((y * y), 0.16666666666666666, 1.0) * y;
} else {
tmp = ((1.0 + y) - fma(((0.5 * y) - 1.0), y, 1.0)) * 0.5;
}
return tmp;
}
function code(x, y) tmp = 0.0 if (x <= 1.22e+30) tmp = Float64(fma(Float64(y * y), 0.16666666666666666, 1.0) * y); else tmp = Float64(Float64(Float64(1.0 + y) - fma(Float64(Float64(0.5 * y) - 1.0), y, 1.0)) * 0.5); end return tmp end
code[x_, y_] := If[LessEqual[x, 1.22e+30], N[(N[(N[(y * y), $MachinePrecision] * 0.16666666666666666 + 1.0), $MachinePrecision] * y), $MachinePrecision], N[(N[(N[(1.0 + y), $MachinePrecision] - N[(N[(N[(0.5 * y), $MachinePrecision] - 1.0), $MachinePrecision] * y + 1.0), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.22 \cdot 10^{+30}:\\
\;\;\;\;\mathsf{fma}\left(y \cdot y, 0.16666666666666666, 1\right) \cdot y\\
\mathbf{else}:\\
\;\;\;\;\left(\left(1 + y\right) - \mathsf{fma}\left(0.5 \cdot y - 1, y, 1\right)\right) \cdot 0.5\\
\end{array}
\end{array}
if x < 1.22e30Initial program 84.1%
Applied rewrites40.8%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites82.1%
Taylor expanded in x around 0
Applied rewrites60.5%
if 1.22e30 < x Initial program 99.9%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
rec-expN/A
lower-exp.f64N/A
lower-neg.f6451.4
Applied rewrites51.4%
Taylor expanded in y around 0
Applied rewrites36.3%
Taylor expanded in y around 0
Applied rewrites29.8%
Taylor expanded in y around 0
Applied rewrites41.9%
(FPCore (x y) :precision binary64 (if (<= x 1.18e+57) (* (fma (* y y) 0.16666666666666666 1.0) y) (* (- (fma (fma 0.5 y 1.0) y 1.0) (- 1.0 y)) 0.5)))
double code(double x, double y) {
double tmp;
if (x <= 1.18e+57) {
tmp = fma((y * y), 0.16666666666666666, 1.0) * y;
} else {
tmp = (fma(fma(0.5, y, 1.0), y, 1.0) - (1.0 - y)) * 0.5;
}
return tmp;
}
function code(x, y) tmp = 0.0 if (x <= 1.18e+57) tmp = Float64(fma(Float64(y * y), 0.16666666666666666, 1.0) * y); else tmp = Float64(Float64(fma(fma(0.5, y, 1.0), y, 1.0) - Float64(1.0 - y)) * 0.5); end return tmp end
code[x_, y_] := If[LessEqual[x, 1.18e+57], N[(N[(N[(y * y), $MachinePrecision] * 0.16666666666666666 + 1.0), $MachinePrecision] * y), $MachinePrecision], N[(N[(N[(N[(0.5 * y + 1.0), $MachinePrecision] * y + 1.0), $MachinePrecision] - N[(1.0 - y), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.18 \cdot 10^{+57}:\\
\;\;\;\;\mathsf{fma}\left(y \cdot y, 0.16666666666666666, 1\right) \cdot y\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(\mathsf{fma}\left(0.5, y, 1\right), y, 1\right) - \left(1 - y\right)\right) \cdot 0.5\\
\end{array}
\end{array}
if x < 1.18e57Initial program 84.6%
Applied rewrites40.8%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites82.2%
Taylor expanded in x around 0
Applied rewrites59.5%
if 1.18e57 < x Initial program 99.9%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
rec-expN/A
lower-exp.f64N/A
lower-neg.f6451.5
Applied rewrites51.5%
Taylor expanded in y around 0
Applied rewrites38.0%
Taylor expanded in y around 0
Applied rewrites40.0%
(FPCore (x y) :precision binary64 (if (<= x 1.12e+135) (* (fma (* y y) 0.16666666666666666 1.0) y) (* (- (+ 1.0 y) (- 1.0 y)) 0.5)))
double code(double x, double y) {
double tmp;
if (x <= 1.12e+135) {
tmp = fma((y * y), 0.16666666666666666, 1.0) * y;
} else {
tmp = ((1.0 + y) - (1.0 - y)) * 0.5;
}
return tmp;
}
function code(x, y) tmp = 0.0 if (x <= 1.12e+135) tmp = Float64(fma(Float64(y * y), 0.16666666666666666, 1.0) * y); else tmp = Float64(Float64(Float64(1.0 + y) - Float64(1.0 - y)) * 0.5); end return tmp end
code[x_, y_] := If[LessEqual[x, 1.12e+135], N[(N[(N[(y * y), $MachinePrecision] * 0.16666666666666666 + 1.0), $MachinePrecision] * y), $MachinePrecision], N[(N[(N[(1.0 + y), $MachinePrecision] - N[(1.0 - y), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.12 \cdot 10^{+135}:\\
\;\;\;\;\mathsf{fma}\left(y \cdot y, 0.16666666666666666, 1\right) \cdot y\\
\mathbf{else}:\\
\;\;\;\;\left(\left(1 + y\right) - \left(1 - y\right)\right) \cdot 0.5\\
\end{array}
\end{array}
if x < 1.1199999999999999e135Initial program 85.5%
Applied rewrites39.8%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites80.7%
Taylor expanded in x around 0
Applied rewrites57.4%
if 1.1199999999999999e135 < x Initial program 99.9%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
rec-expN/A
lower-exp.f64N/A
lower-neg.f6458.1
Applied rewrites58.1%
Taylor expanded in y around 0
Applied rewrites45.1%
Taylor expanded in y around 0
Applied rewrites42.6%
(FPCore (x y) :precision binary64 (if (<= x 1.08e+143) (* (fma -0.16666666666666666 (* x x) 1.0) y) (* (- (+ 1.0 y) (- 1.0 y)) 0.5)))
double code(double x, double y) {
double tmp;
if (x <= 1.08e+143) {
tmp = fma(-0.16666666666666666, (x * x), 1.0) * y;
} else {
tmp = ((1.0 + y) - (1.0 - y)) * 0.5;
}
return tmp;
}
function code(x, y) tmp = 0.0 if (x <= 1.08e+143) tmp = Float64(fma(-0.16666666666666666, Float64(x * x), 1.0) * y); else tmp = Float64(Float64(Float64(1.0 + y) - Float64(1.0 - y)) * 0.5); end return tmp end
code[x_, y_] := If[LessEqual[x, 1.08e+143], N[(N[(-0.16666666666666666 * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision] * y), $MachinePrecision], N[(N[(N[(1.0 + y), $MachinePrecision] - N[(1.0 - y), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.08 \cdot 10^{+143}:\\
\;\;\;\;\mathsf{fma}\left(-0.16666666666666666, x \cdot x, 1\right) \cdot y\\
\mathbf{else}:\\
\;\;\;\;\left(\left(1 + y\right) - \left(1 - y\right)\right) \cdot 0.5\\
\end{array}
\end{array}
if x < 1.07999999999999993e143Initial program 85.6%
Taylor expanded in y around 0
*-commutativeN/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
lower-sin.f6455.2
Applied rewrites55.2%
Taylor expanded in x around 0
Applied rewrites41.7%
if 1.07999999999999993e143 < x Initial program 99.9%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
rec-expN/A
lower-exp.f64N/A
lower-neg.f6461.4
Applied rewrites61.4%
Taylor expanded in y around 0
Applied rewrites47.7%
Taylor expanded in y around 0
Applied rewrites45.0%
(FPCore (x y) :precision binary64 (if (<= x 8e+22) (* 1.0 y) (* (- (+ 1.0 y) (- 1.0 y)) 0.5)))
double code(double x, double y) {
double tmp;
if (x <= 8e+22) {
tmp = 1.0 * y;
} else {
tmp = ((1.0 + y) - (1.0 - y)) * 0.5;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= 8d+22) then
tmp = 1.0d0 * y
else
tmp = ((1.0d0 + y) - (1.0d0 - y)) * 0.5d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= 8e+22) {
tmp = 1.0 * y;
} else {
tmp = ((1.0 + y) - (1.0 - y)) * 0.5;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 8e+22: tmp = 1.0 * y else: tmp = ((1.0 + y) - (1.0 - y)) * 0.5 return tmp
function code(x, y) tmp = 0.0 if (x <= 8e+22) tmp = Float64(1.0 * y); else tmp = Float64(Float64(Float64(1.0 + y) - Float64(1.0 - y)) * 0.5); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 8e+22) tmp = 1.0 * y; else tmp = ((1.0 + y) - (1.0 - y)) * 0.5; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 8e+22], N[(1.0 * y), $MachinePrecision], N[(N[(N[(1.0 + y), $MachinePrecision] - N[(1.0 - y), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 8 \cdot 10^{+22}:\\
\;\;\;\;1 \cdot y\\
\mathbf{else}:\\
\;\;\;\;\left(\left(1 + y\right) - \left(1 - y\right)\right) \cdot 0.5\\
\end{array}
\end{array}
if x < 8e22Initial program 84.0%
Taylor expanded in y around 0
*-commutativeN/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
lower-sin.f6457.7
Applied rewrites57.7%
Taylor expanded in x around 0
Applied rewrites40.1%
if 8e22 < x Initial program 99.9%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
rec-expN/A
lower-exp.f64N/A
lower-neg.f6450.6
Applied rewrites50.6%
Taylor expanded in y around 0
Applied rewrites35.8%
Taylor expanded in y around 0
Applied rewrites29.4%
(FPCore (x y) :precision binary64 (* 1.0 y))
double code(double x, double y) {
return 1.0 * y;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0 * y
end function
public static double code(double x, double y) {
return 1.0 * y;
}
def code(x, y): return 1.0 * y
function code(x, y) return Float64(1.0 * y) end
function tmp = code(x, y) tmp = 1.0 * y; end
code[x_, y_] := N[(1.0 * y), $MachinePrecision]
\begin{array}{l}
\\
1 \cdot y
\end{array}
Initial program 87.6%
Taylor expanded in y around 0
*-commutativeN/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
lower-sin.f6456.1
Applied rewrites56.1%
Taylor expanded in x around 0
Applied rewrites31.8%
(FPCore (x y) :precision binary64 (* (sin x) (/ (sinh y) x)))
double code(double x, double y) {
return sin(x) * (sinh(y) / 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, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sin(x) * (sinh(y) / x)
end function
public static double code(double x, double y) {
return Math.sin(x) * (Math.sinh(y) / x);
}
def code(x, y): return math.sin(x) * (math.sinh(y) / x)
function code(x, y) return Float64(sin(x) * Float64(sinh(y) / x)) end
function tmp = code(x, y) tmp = sin(x) * (sinh(y) / x); end
code[x_, y_] := N[(N[Sin[x], $MachinePrecision] * N[(N[Sinh[y], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin x \cdot \frac{\sinh y}{x}
\end{array}
herbie shell --seed 2024363
(FPCore (x y)
:name "Linear.Quaternion:$ccosh from linear-1.19.1.3"
:precision binary64
:alt
(! :herbie-platform default (* (sin x) (/ (sinh y) x)))
(/ (* (sin x) (sinh y)) x))