
(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}
Herbie found 11 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 (* (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}
Initial program 89.2%
Applied rewrites99.8%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (* (sin x) (sinh y)) x)))
(if (<= t_0 (- INFINITY))
(/ (* (fma (* (* x x) x) -0.16666666666666666 x) (sinh y)) x)
(if (<= t_0 0.01)
(* (sin x) (* (/ (fma (* y 0.16666666666666666) y 1.0) x) y))
(/ (* x (sinh y)) x)))))
double code(double x, double y) {
double t_0 = (sin(x) * sinh(y)) / x;
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = (fma(((x * x) * x), -0.16666666666666666, x) * sinh(y)) / x;
} else if (t_0 <= 0.01) {
tmp = sin(x) * ((fma((y * 0.16666666666666666), y, 1.0) / x) * y);
} else {
tmp = (x * sinh(y)) / x;
}
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(fma(Float64(Float64(x * x) * x), -0.16666666666666666, x) * sinh(y)) / x); elseif (t_0 <= 0.01) tmp = Float64(sin(x) * Float64(Float64(fma(Float64(y * 0.16666666666666666), y, 1.0) / x) * y)); else tmp = Float64(Float64(x * sinh(y)) / x); 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[(N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision] * -0.16666666666666666 + x), $MachinePrecision] * N[Sinh[y], $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[t$95$0, 0.01], N[(N[Sin[x], $MachinePrecision] * N[(N[(N[(N[(y * 0.16666666666666666), $MachinePrecision] * y + 1.0), $MachinePrecision] / x), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision], N[(N[(x * N[Sinh[y], $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sin x \cdot \sinh y}{x}\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;\frac{\mathsf{fma}\left(\left(x \cdot x\right) \cdot x, -0.16666666666666666, x\right) \cdot \sinh y}{x}\\
\mathbf{elif}\;t\_0 \leq 0.01:\\
\;\;\;\;\sin x \cdot \left(\frac{\mathsf{fma}\left(y \cdot 0.16666666666666666, y, 1\right)}{x} \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \sinh y}{x}\\
\end{array}
\end{array}
if (/.f64 (*.f64 (sin.f64 x) (sinh.f64 y)) x) < -inf.0Initial program 89.2%
Taylor expanded in x around 0
Applied rewrites52.6%
Applied rewrites52.6%
if -inf.0 < (/.f64 (*.f64 (sin.f64 x) (sinh.f64 y)) x) < 0.0100000000000000002Initial program 89.2%
Applied rewrites99.8%
Taylor expanded in y around 0
Applied rewrites84.6%
Applied rewrites84.6%
if 0.0100000000000000002 < (/.f64 (*.f64 (sin.f64 x) (sinh.f64 y)) x) Initial program 89.2%
Taylor expanded in x around 0
Applied rewrites52.5%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (* (sin x) (sinh y)) x)))
(if (<= t_0 (- INFINITY))
(/ (* (fma (* (* x x) x) -0.16666666666666666 x) (sinh y)) x)
(if (<= t_0 4e-18) (* y (/ (sin x) x)) (/ (* x (sinh y)) x)))))
double code(double x, double y) {
double t_0 = (sin(x) * sinh(y)) / x;
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = (fma(((x * x) * x), -0.16666666666666666, x) * sinh(y)) / x;
} else if (t_0 <= 4e-18) {
tmp = y * (sin(x) / x);
} else {
tmp = (x * sinh(y)) / x;
}
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(fma(Float64(Float64(x * x) * x), -0.16666666666666666, x) * sinh(y)) / x); elseif (t_0 <= 4e-18) tmp = Float64(y * Float64(sin(x) / x)); else tmp = Float64(Float64(x * sinh(y)) / x); 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[(N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision] * -0.16666666666666666 + x), $MachinePrecision] * N[Sinh[y], $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[t$95$0, 4e-18], N[(y * N[(N[Sin[x], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], N[(N[(x * N[Sinh[y], $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sin x \cdot \sinh y}{x}\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;\frac{\mathsf{fma}\left(\left(x \cdot x\right) \cdot x, -0.16666666666666666, x\right) \cdot \sinh y}{x}\\
\mathbf{elif}\;t\_0 \leq 4 \cdot 10^{-18}:\\
\;\;\;\;y \cdot \frac{\sin x}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \sinh y}{x}\\
\end{array}
\end{array}
if (/.f64 (*.f64 (sin.f64 x) (sinh.f64 y)) x) < -inf.0Initial program 89.2%
Taylor expanded in x around 0
Applied rewrites52.6%
Applied rewrites52.6%
if -inf.0 < (/.f64 (*.f64 (sin.f64 x) (sinh.f64 y)) x) < 4.0000000000000003e-18Initial program 89.2%
Taylor expanded in y around 0
Applied rewrites80.8%
Taylor expanded in x around 0
Applied rewrites51.4%
Taylor expanded in y around 0
Applied rewrites52.2%
if 4.0000000000000003e-18 < (/.f64 (*.f64 (sin.f64 x) (sinh.f64 y)) x) Initial program 89.2%
Taylor expanded in x around 0
Applied rewrites52.5%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (* (sin x) (sinh y)) x)))
(if (<= t_0 -2e-213)
(/ (* (fma (* (* x x) x) -0.16666666666666666 x) (sinh y)) x)
(if (<= t_0 1e-102)
(* x (* (/ (fma (* y 0.16666666666666666) y 1.0) x) y))
(/ (* x (sinh y)) x)))))
double code(double x, double y) {
double t_0 = (sin(x) * sinh(y)) / x;
double tmp;
if (t_0 <= -2e-213) {
tmp = (fma(((x * x) * x), -0.16666666666666666, x) * sinh(y)) / x;
} else if (t_0 <= 1e-102) {
tmp = x * ((fma((y * 0.16666666666666666), y, 1.0) / x) * y);
} else {
tmp = (x * sinh(y)) / x;
}
return tmp;
}
function code(x, y) t_0 = Float64(Float64(sin(x) * sinh(y)) / x) tmp = 0.0 if (t_0 <= -2e-213) tmp = Float64(Float64(fma(Float64(Float64(x * x) * x), -0.16666666666666666, x) * sinh(y)) / x); elseif (t_0 <= 1e-102) tmp = Float64(x * Float64(Float64(fma(Float64(y * 0.16666666666666666), y, 1.0) / x) * y)); else tmp = Float64(Float64(x * sinh(y)) / x); 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, -2e-213], N[(N[(N[(N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision] * -0.16666666666666666 + x), $MachinePrecision] * N[Sinh[y], $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[t$95$0, 1e-102], N[(x * N[(N[(N[(N[(y * 0.16666666666666666), $MachinePrecision] * y + 1.0), $MachinePrecision] / x), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision], N[(N[(x * N[Sinh[y], $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sin x \cdot \sinh y}{x}\\
\mathbf{if}\;t\_0 \leq -2 \cdot 10^{-213}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\left(x \cdot x\right) \cdot x, -0.16666666666666666, x\right) \cdot \sinh y}{x}\\
\mathbf{elif}\;t\_0 \leq 10^{-102}:\\
\;\;\;\;x \cdot \left(\frac{\mathsf{fma}\left(y \cdot 0.16666666666666666, y, 1\right)}{x} \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \sinh y}{x}\\
\end{array}
\end{array}
if (/.f64 (*.f64 (sin.f64 x) (sinh.f64 y)) x) < -1.9999999999999999e-213Initial program 89.2%
Taylor expanded in x around 0
Applied rewrites52.6%
Applied rewrites52.6%
if -1.9999999999999999e-213 < (/.f64 (*.f64 (sin.f64 x) (sinh.f64 y)) x) < 9.99999999999999933e-103Initial program 89.2%
Applied rewrites99.8%
Taylor expanded in y around 0
Applied rewrites84.6%
Applied rewrites84.6%
Taylor expanded in x around 0
Applied rewrites66.2%
if 9.99999999999999933e-103 < (/.f64 (*.f64 (sin.f64 x) (sinh.f64 y)) x) Initial program 89.2%
Taylor expanded in x around 0
Applied rewrites52.5%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (* (sin x) (sinh y)) x)))
(if (<= t_0 -2e-213)
(/ (* (* (fma (* x -0.16666666666666666) x 1.0) x) y) x)
(if (<= t_0 1e-102)
(* x (* (/ (fma (* y 0.16666666666666666) y 1.0) x) y))
(/ (* x (sinh y)) x)))))
double code(double x, double y) {
double t_0 = (sin(x) * sinh(y)) / x;
double tmp;
if (t_0 <= -2e-213) {
tmp = ((fma((x * -0.16666666666666666), x, 1.0) * x) * y) / x;
} else if (t_0 <= 1e-102) {
tmp = x * ((fma((y * 0.16666666666666666), y, 1.0) / x) * y);
} else {
tmp = (x * sinh(y)) / x;
}
return tmp;
}
function code(x, y) t_0 = Float64(Float64(sin(x) * sinh(y)) / x) tmp = 0.0 if (t_0 <= -2e-213) tmp = Float64(Float64(Float64(fma(Float64(x * -0.16666666666666666), x, 1.0) * x) * y) / x); elseif (t_0 <= 1e-102) tmp = Float64(x * Float64(Float64(fma(Float64(y * 0.16666666666666666), y, 1.0) / x) * y)); else tmp = Float64(Float64(x * sinh(y)) / x); 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, -2e-213], N[(N[(N[(N[(N[(x * -0.16666666666666666), $MachinePrecision] * x + 1.0), $MachinePrecision] * x), $MachinePrecision] * y), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[t$95$0, 1e-102], N[(x * N[(N[(N[(N[(y * 0.16666666666666666), $MachinePrecision] * y + 1.0), $MachinePrecision] / x), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision], N[(N[(x * N[Sinh[y], $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sin x \cdot \sinh y}{x}\\
\mathbf{if}\;t\_0 \leq -2 \cdot 10^{-213}:\\
\;\;\;\;\frac{\left(\mathsf{fma}\left(x \cdot -0.16666666666666666, x, 1\right) \cdot x\right) \cdot y}{x}\\
\mathbf{elif}\;t\_0 \leq 10^{-102}:\\
\;\;\;\;x \cdot \left(\frac{\mathsf{fma}\left(y \cdot 0.16666666666666666, y, 1\right)}{x} \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \sinh y}{x}\\
\end{array}
\end{array}
if (/.f64 (*.f64 (sin.f64 x) (sinh.f64 y)) x) < -1.9999999999999999e-213Initial program 89.2%
Taylor expanded in y around 0
Applied rewrites41.5%
Taylor expanded in x around 0
Applied rewrites26.4%
Applied rewrites26.4%
if -1.9999999999999999e-213 < (/.f64 (*.f64 (sin.f64 x) (sinh.f64 y)) x) < 9.99999999999999933e-103Initial program 89.2%
Applied rewrites99.8%
Taylor expanded in y around 0
Applied rewrites84.6%
Applied rewrites84.6%
Taylor expanded in x around 0
Applied rewrites66.2%
if 9.99999999999999933e-103 < (/.f64 (*.f64 (sin.f64 x) (sinh.f64 y)) x) Initial program 89.2%
Taylor expanded in x around 0
Applied rewrites52.5%
(FPCore (x y) :precision binary64 (if (<= (/ (* (sin x) (sinh y)) x) -2e-213) (/ (* (* (fma (* x -0.16666666666666666) x 1.0) x) y) x) (* x (* (/ (fma (* y 0.16666666666666666) y 1.0) x) y))))
double code(double x, double y) {
double tmp;
if (((sin(x) * sinh(y)) / x) <= -2e-213) {
tmp = ((fma((x * -0.16666666666666666), x, 1.0) * x) * y) / x;
} else {
tmp = x * ((fma((y * 0.16666666666666666), y, 1.0) / x) * y);
}
return tmp;
}
function code(x, y) tmp = 0.0 if (Float64(Float64(sin(x) * sinh(y)) / x) <= -2e-213) tmp = Float64(Float64(Float64(fma(Float64(x * -0.16666666666666666), x, 1.0) * x) * y) / x); else tmp = Float64(x * Float64(Float64(fma(Float64(y * 0.16666666666666666), y, 1.0) / x) * y)); end return tmp end
code[x_, y_] := If[LessEqual[N[(N[(N[Sin[x], $MachinePrecision] * N[Sinh[y], $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], -2e-213], N[(N[(N[(N[(N[(x * -0.16666666666666666), $MachinePrecision] * x + 1.0), $MachinePrecision] * x), $MachinePrecision] * y), $MachinePrecision] / x), $MachinePrecision], N[(x * N[(N[(N[(N[(y * 0.16666666666666666), $MachinePrecision] * y + 1.0), $MachinePrecision] / x), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{\sin x \cdot \sinh y}{x} \leq -2 \cdot 10^{-213}:\\
\;\;\;\;\frac{\left(\mathsf{fma}\left(x \cdot -0.16666666666666666, x, 1\right) \cdot x\right) \cdot y}{x}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\frac{\mathsf{fma}\left(y \cdot 0.16666666666666666, y, 1\right)}{x} \cdot y\right)\\
\end{array}
\end{array}
if (/.f64 (*.f64 (sin.f64 x) (sinh.f64 y)) x) < -1.9999999999999999e-213Initial program 89.2%
Taylor expanded in y around 0
Applied rewrites41.5%
Taylor expanded in x around 0
Applied rewrites26.4%
Applied rewrites26.4%
if -1.9999999999999999e-213 < (/.f64 (*.f64 (sin.f64 x) (sinh.f64 y)) x) Initial program 89.2%
Applied rewrites99.8%
Taylor expanded in y around 0
Applied rewrites84.6%
Applied rewrites84.6%
Taylor expanded in x around 0
Applied rewrites66.2%
(FPCore (x y) :precision binary64 (if (<= (/ (* (sin x) (sinh y)) x) -2e-213) (/ (* (* (fma (* x -0.16666666666666666) x 1.0) x) y) x) (* y (fma (* (/ y x) y) (* x 0.16666666666666666) 1.0))))
double code(double x, double y) {
double tmp;
if (((sin(x) * sinh(y)) / x) <= -2e-213) {
tmp = ((fma((x * -0.16666666666666666), x, 1.0) * x) * y) / x;
} else {
tmp = y * fma(((y / x) * y), (x * 0.16666666666666666), 1.0);
}
return tmp;
}
function code(x, y) tmp = 0.0 if (Float64(Float64(sin(x) * sinh(y)) / x) <= -2e-213) tmp = Float64(Float64(Float64(fma(Float64(x * -0.16666666666666666), x, 1.0) * x) * y) / x); else tmp = Float64(y * fma(Float64(Float64(y / x) * y), Float64(x * 0.16666666666666666), 1.0)); end return tmp end
code[x_, y_] := If[LessEqual[N[(N[(N[Sin[x], $MachinePrecision] * N[Sinh[y], $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], -2e-213], N[(N[(N[(N[(N[(x * -0.16666666666666666), $MachinePrecision] * x + 1.0), $MachinePrecision] * x), $MachinePrecision] * y), $MachinePrecision] / x), $MachinePrecision], N[(y * N[(N[(N[(y / x), $MachinePrecision] * y), $MachinePrecision] * N[(x * 0.16666666666666666), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{\sin x \cdot \sinh y}{x} \leq -2 \cdot 10^{-213}:\\
\;\;\;\;\frac{\left(\mathsf{fma}\left(x \cdot -0.16666666666666666, x, 1\right) \cdot x\right) \cdot y}{x}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \mathsf{fma}\left(\frac{y}{x} \cdot y, x \cdot 0.16666666666666666, 1\right)\\
\end{array}
\end{array}
if (/.f64 (*.f64 (sin.f64 x) (sinh.f64 y)) x) < -1.9999999999999999e-213Initial program 89.2%
Taylor expanded in y around 0
Applied rewrites41.5%
Taylor expanded in x around 0
Applied rewrites26.4%
Applied rewrites26.4%
if -1.9999999999999999e-213 < (/.f64 (*.f64 (sin.f64 x) (sinh.f64 y)) x) Initial program 89.2%
Taylor expanded in y around 0
Applied rewrites80.8%
Taylor expanded in x around 0
Applied rewrites51.4%
Applied rewrites54.2%
Applied rewrites54.2%
(FPCore (x y) :precision binary64 (if (<= (/ (* (sin x) (sinh y)) x) -2e-213) (/ (* (* (fma (* x -0.16666666666666666) x 1.0) x) y) x) (* y (fma (* x (* y y)) (/ 0.16666666666666666 x) 1.0))))
double code(double x, double y) {
double tmp;
if (((sin(x) * sinh(y)) / x) <= -2e-213) {
tmp = ((fma((x * -0.16666666666666666), x, 1.0) * x) * y) / x;
} else {
tmp = y * fma((x * (y * y)), (0.16666666666666666 / x), 1.0);
}
return tmp;
}
function code(x, y) tmp = 0.0 if (Float64(Float64(sin(x) * sinh(y)) / x) <= -2e-213) tmp = Float64(Float64(Float64(fma(Float64(x * -0.16666666666666666), x, 1.0) * x) * y) / x); else tmp = Float64(y * fma(Float64(x * Float64(y * y)), Float64(0.16666666666666666 / x), 1.0)); end return tmp end
code[x_, y_] := If[LessEqual[N[(N[(N[Sin[x], $MachinePrecision] * N[Sinh[y], $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], -2e-213], N[(N[(N[(N[(N[(x * -0.16666666666666666), $MachinePrecision] * x + 1.0), $MachinePrecision] * x), $MachinePrecision] * y), $MachinePrecision] / x), $MachinePrecision], N[(y * N[(N[(x * N[(y * y), $MachinePrecision]), $MachinePrecision] * N[(0.16666666666666666 / x), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{\sin x \cdot \sinh y}{x} \leq -2 \cdot 10^{-213}:\\
\;\;\;\;\frac{\left(\mathsf{fma}\left(x \cdot -0.16666666666666666, x, 1\right) \cdot x\right) \cdot y}{x}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \mathsf{fma}\left(x \cdot \left(y \cdot y\right), \frac{0.16666666666666666}{x}, 1\right)\\
\end{array}
\end{array}
if (/.f64 (*.f64 (sin.f64 x) (sinh.f64 y)) x) < -1.9999999999999999e-213Initial program 89.2%
Taylor expanded in y around 0
Applied rewrites41.5%
Taylor expanded in x around 0
Applied rewrites26.4%
Applied rewrites26.4%
if -1.9999999999999999e-213 < (/.f64 (*.f64 (sin.f64 x) (sinh.f64 y)) x) Initial program 89.2%
Taylor expanded in y around 0
Applied rewrites80.8%
Taylor expanded in x around 0
Applied rewrites51.4%
Applied rewrites52.7%
(FPCore (x y) :precision binary64 (if (<= (/ (* (sin x) (sinh y)) x) -2e-213) (/ (* (* (fma (* x -0.16666666666666666) x 1.0) x) y) x) (* y (fma (* y y) 0.16666666666666666 1.0))))
double code(double x, double y) {
double tmp;
if (((sin(x) * sinh(y)) / x) <= -2e-213) {
tmp = ((fma((x * -0.16666666666666666), x, 1.0) * x) * y) / x;
} else {
tmp = y * fma((y * y), 0.16666666666666666, 1.0);
}
return tmp;
}
function code(x, y) tmp = 0.0 if (Float64(Float64(sin(x) * sinh(y)) / x) <= -2e-213) tmp = Float64(Float64(Float64(fma(Float64(x * -0.16666666666666666), x, 1.0) * x) * y) / x); else tmp = Float64(y * fma(Float64(y * y), 0.16666666666666666, 1.0)); end return tmp end
code[x_, y_] := If[LessEqual[N[(N[(N[Sin[x], $MachinePrecision] * N[Sinh[y], $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], -2e-213], N[(N[(N[(N[(N[(x * -0.16666666666666666), $MachinePrecision] * x + 1.0), $MachinePrecision] * x), $MachinePrecision] * y), $MachinePrecision] / x), $MachinePrecision], N[(y * N[(N[(y * y), $MachinePrecision] * 0.16666666666666666 + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{\sin x \cdot \sinh y}{x} \leq -2 \cdot 10^{-213}:\\
\;\;\;\;\frac{\left(\mathsf{fma}\left(x \cdot -0.16666666666666666, x, 1\right) \cdot x\right) \cdot y}{x}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \mathsf{fma}\left(y \cdot y, 0.16666666666666666, 1\right)\\
\end{array}
\end{array}
if (/.f64 (*.f64 (sin.f64 x) (sinh.f64 y)) x) < -1.9999999999999999e-213Initial program 89.2%
Taylor expanded in y around 0
Applied rewrites41.5%
Taylor expanded in x around 0
Applied rewrites26.4%
Applied rewrites26.4%
if -1.9999999999999999e-213 < (/.f64 (*.f64 (sin.f64 x) (sinh.f64 y)) x) Initial program 89.2%
Taylor expanded in y around 0
Applied rewrites80.8%
Taylor expanded in x around 0
Applied rewrites51.4%
Applied rewrites51.4%
(FPCore (x y) :precision binary64 (* y (fma (* y y) 0.16666666666666666 1.0)))
double code(double x, double y) {
return y * fma((y * y), 0.16666666666666666, 1.0);
}
function code(x, y) return Float64(y * fma(Float64(y * y), 0.16666666666666666, 1.0)) end
code[x_, y_] := N[(y * N[(N[(y * y), $MachinePrecision] * 0.16666666666666666 + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
y \cdot \mathsf{fma}\left(y \cdot y, 0.16666666666666666, 1\right)
\end{array}
Initial program 89.2%
Taylor expanded in y around 0
Applied rewrites80.8%
Taylor expanded in x around 0
Applied rewrites51.4%
Applied rewrites51.4%
(FPCore (x y) :precision binary64 (/ (* (* x 1.0) y) x))
double code(double x, double y) {
return ((x * 1.0) * 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 = ((x * 1.0d0) * y) / x
end function
public static double code(double x, double y) {
return ((x * 1.0) * y) / x;
}
def code(x, y): return ((x * 1.0) * y) / x
function code(x, y) return Float64(Float64(Float64(x * 1.0) * y) / x) end
function tmp = code(x, y) tmp = ((x * 1.0) * y) / x; end
code[x_, y_] := N[(N[(N[(x * 1.0), $MachinePrecision] * y), $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(x \cdot 1\right) \cdot y}{x}
\end{array}
Initial program 89.2%
Taylor expanded in y around 0
Applied rewrites41.5%
Taylor expanded in x around 0
Applied rewrites26.4%
Taylor expanded in x around 0
Applied rewrites22.5%
herbie shell --seed 2025161
(FPCore (x y)
:name "Linear.Quaternion:$ccosh from linear-1.19.1.3"
:precision binary64
(/ (* (sin x) (sinh y)) x))