
(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 9 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) x) (sinh y)))
double code(double x, double y) {
return (sin(x) / x) * sinh(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 = (sin(x) / x) * sinh(y)
end function
public static double code(double x, double y) {
return (Math.sin(x) / x) * Math.sinh(y);
}
def code(x, y): return (math.sin(x) / x) * math.sinh(y)
function code(x, y) return Float64(Float64(sin(x) / x) * sinh(y)) end
function tmp = code(x, y) tmp = (sin(x) / x) * sinh(y); end
code[x_, y_] := N[(N[(N[Sin[x], $MachinePrecision] / x), $MachinePrecision] * N[Sinh[y], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin x}{x} \cdot \sinh y
\end{array}
Initial program 88.6%
Applied rewrites99.9%
(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 2e-106) (* (/ (sin x) x) y) (* 1.0 (sinh y))))))
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 <= 2e-106) {
tmp = (sin(x) / x) * y;
} else {
tmp = 1.0 * sinh(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(fma(Float64(Float64(x * x) * x), -0.16666666666666666, x) * sinh(y)) / x); elseif (t_0 <= 2e-106) tmp = Float64(Float64(sin(x) / x) * y); else tmp = Float64(1.0 * sinh(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[(N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision] * -0.16666666666666666 + x), $MachinePrecision] * N[Sinh[y], $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[t$95$0, 2e-106], N[(N[(N[Sin[x], $MachinePrecision] / x), $MachinePrecision] * y), $MachinePrecision], N[(1.0 * N[Sinh[y], $MachinePrecision]), $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 2 \cdot 10^{-106}:\\
\;\;\;\;\frac{\sin x}{x} \cdot y\\
\mathbf{else}:\\
\;\;\;\;1 \cdot \sinh y\\
\end{array}
\end{array}
if (/.f64 (*.f64 (sin.f64 x) (sinh.f64 y)) x) < -inf.0Initial program 88.6%
Taylor expanded in x around 0
Applied rewrites51.8%
Applied rewrites51.8%
if -inf.0 < (/.f64 (*.f64 (sin.f64 x) (sinh.f64 y)) x) < 1.99999999999999988e-106Initial program 88.6%
Applied rewrites99.9%
Taylor expanded in x around 0
Applied rewrites63.7%
Taylor expanded in y around 0
Applied rewrites27.9%
Taylor expanded in x around inf
Applied rewrites51.2%
if 1.99999999999999988e-106 < (/.f64 (*.f64 (sin.f64 x) (sinh.f64 y)) x) Initial program 88.6%
Applied rewrites99.9%
Taylor expanded in x around 0
Applied rewrites63.7%
(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 1e-309)
(* 0.5 (- (+ 1.0 y) (fma (- (* 0.5 y) 1.0) y 1.0)))
(* 1.0 (sinh y))))))
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 <= 1e-309) {
tmp = 0.5 * ((1.0 + y) - fma(((0.5 * y) - 1.0), y, 1.0));
} else {
tmp = 1.0 * sinh(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(fma(Float64(Float64(x * x) * x), -0.16666666666666666, x) * sinh(y)) / x); elseif (t_0 <= 1e-309) tmp = Float64(0.5 * Float64(Float64(1.0 + y) - fma(Float64(Float64(0.5 * y) - 1.0), y, 1.0))); else tmp = Float64(1.0 * sinh(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[(N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision] * -0.16666666666666666 + x), $MachinePrecision] * N[Sinh[y], $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[t$95$0, 1e-309], N[(0.5 * N[(N[(1.0 + y), $MachinePrecision] - N[(N[(N[(0.5 * y), $MachinePrecision] - 1.0), $MachinePrecision] * y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 * N[Sinh[y], $MachinePrecision]), $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 10^{-309}:\\
\;\;\;\;0.5 \cdot \left(\left(1 + y\right) - \mathsf{fma}\left(0.5 \cdot y - 1, y, 1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;1 \cdot \sinh y\\
\end{array}
\end{array}
if (/.f64 (*.f64 (sin.f64 x) (sinh.f64 y)) x) < -inf.0Initial program 88.6%
Taylor expanded in x around 0
Applied rewrites51.8%
Applied rewrites51.8%
if -inf.0 < (/.f64 (*.f64 (sin.f64 x) (sinh.f64 y)) x) < 1.000000000000002e-309Initial program 88.6%
Taylor expanded in x around 0
Applied rewrites52.9%
Taylor expanded in y around 0
Applied rewrites34.7%
Taylor expanded in y around 0
Applied rewrites17.1%
Taylor expanded in y around 0
Applied rewrites28.0%
Applied rewrites28.0%
if 1.000000000000002e-309 < (/.f64 (*.f64 (sin.f64 x) (sinh.f64 y)) x) Initial program 88.6%
Applied rewrites99.9%
Taylor expanded in x around 0
Applied rewrites63.7%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (* (sin x) (sinh y)) x)))
(if (<= t_0 (- INFINITY))
(/ (* (fma (* (sqrt (* (* x x) (* x x))) x) -0.16666666666666666 x) y) x)
(if (<= t_0 1e-309)
(* 0.5 (- (+ 1.0 y) (fma (- (* 0.5 y) 1.0) y 1.0)))
(* 1.0 (sinh y))))))
double code(double x, double y) {
double t_0 = (sin(x) * sinh(y)) / x;
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = (fma((sqrt(((x * x) * (x * x))) * x), -0.16666666666666666, x) * y) / x;
} else if (t_0 <= 1e-309) {
tmp = 0.5 * ((1.0 + y) - fma(((0.5 * y) - 1.0), y, 1.0));
} else {
tmp = 1.0 * sinh(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(fma(Float64(sqrt(Float64(Float64(x * x) * Float64(x * x))) * x), -0.16666666666666666, x) * y) / x); elseif (t_0 <= 1e-309) tmp = Float64(0.5 * Float64(Float64(1.0 + y) - fma(Float64(Float64(0.5 * y) - 1.0), y, 1.0))); else tmp = Float64(1.0 * sinh(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[(N[(N[Sqrt[N[(N[(x * x), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * x), $MachinePrecision] * -0.16666666666666666 + x), $MachinePrecision] * y), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[t$95$0, 1e-309], N[(0.5 * N[(N[(1.0 + y), $MachinePrecision] - N[(N[(N[(0.5 * y), $MachinePrecision] - 1.0), $MachinePrecision] * y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 * N[Sinh[y], $MachinePrecision]), $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(\sqrt{\left(x \cdot x\right) \cdot \left(x \cdot x\right)} \cdot x, -0.16666666666666666, x\right) \cdot y}{x}\\
\mathbf{elif}\;t\_0 \leq 10^{-309}:\\
\;\;\;\;0.5 \cdot \left(\left(1 + y\right) - \mathsf{fma}\left(0.5 \cdot y - 1, y, 1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;1 \cdot \sinh y\\
\end{array}
\end{array}
if (/.f64 (*.f64 (sin.f64 x) (sinh.f64 y)) x) < -inf.0Initial program 88.6%
Taylor expanded in x around 0
Applied rewrites51.8%
Applied rewrites51.8%
Taylor expanded in y around 0
Applied rewrites25.6%
Applied rewrites25.7%
if -inf.0 < (/.f64 (*.f64 (sin.f64 x) (sinh.f64 y)) x) < 1.000000000000002e-309Initial program 88.6%
Taylor expanded in x around 0
Applied rewrites52.9%
Taylor expanded in y around 0
Applied rewrites34.7%
Taylor expanded in y around 0
Applied rewrites17.1%
Taylor expanded in y around 0
Applied rewrites28.0%
Applied rewrites28.0%
if 1.000000000000002e-309 < (/.f64 (*.f64 (sin.f64 x) (sinh.f64 y)) x) Initial program 88.6%
Applied rewrites99.9%
Taylor expanded in x around 0
Applied rewrites63.7%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (* (sin x) (sinh y)) x)))
(if (<= t_0 (- INFINITY))
(/ (* (fma (* x x) (* x -0.16666666666666666) x) y) x)
(if (<= t_0 1e-309)
(* 0.5 (- (+ 1.0 y) (fma (- (* 0.5 y) 1.0) y 1.0)))
(* 1.0 (sinh y))))))
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) * y) / x;
} else if (t_0 <= 1e-309) {
tmp = 0.5 * ((1.0 + y) - fma(((0.5 * y) - 1.0), y, 1.0));
} else {
tmp = 1.0 * sinh(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(fma(Float64(x * x), Float64(x * -0.16666666666666666), x) * y) / x); elseif (t_0 <= 1e-309) tmp = Float64(0.5 * Float64(Float64(1.0 + y) - fma(Float64(Float64(0.5 * y) - 1.0), y, 1.0))); else tmp = Float64(1.0 * sinh(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[(N[(x * x), $MachinePrecision] * N[(x * -0.16666666666666666), $MachinePrecision] + x), $MachinePrecision] * y), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[t$95$0, 1e-309], N[(0.5 * N[(N[(1.0 + y), $MachinePrecision] - N[(N[(N[(0.5 * y), $MachinePrecision] - 1.0), $MachinePrecision] * y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 * N[Sinh[y], $MachinePrecision]), $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(x \cdot x, x \cdot -0.16666666666666666, x\right) \cdot y}{x}\\
\mathbf{elif}\;t\_0 \leq 10^{-309}:\\
\;\;\;\;0.5 \cdot \left(\left(1 + y\right) - \mathsf{fma}\left(0.5 \cdot y - 1, y, 1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;1 \cdot \sinh y\\
\end{array}
\end{array}
if (/.f64 (*.f64 (sin.f64 x) (sinh.f64 y)) x) < -inf.0Initial program 88.6%
Taylor expanded in x around 0
Applied rewrites51.8%
Applied rewrites51.8%
Taylor expanded in y around 0
Applied rewrites25.6%
Applied rewrites25.6%
if -inf.0 < (/.f64 (*.f64 (sin.f64 x) (sinh.f64 y)) x) < 1.000000000000002e-309Initial program 88.6%
Taylor expanded in x around 0
Applied rewrites52.9%
Taylor expanded in y around 0
Applied rewrites34.7%
Taylor expanded in y around 0
Applied rewrites17.1%
Taylor expanded in y around 0
Applied rewrites28.0%
Applied rewrites28.0%
if 1.000000000000002e-309 < (/.f64 (*.f64 (sin.f64 x) (sinh.f64 y)) x) Initial program 88.6%
Applied rewrites99.9%
Taylor expanded in x around 0
Applied rewrites63.7%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (* (sin x) (sinh y)) x)))
(if (<= t_0 (- INFINITY))
(/ (* (fma (* x x) (* x -0.16666666666666666) x) y) x)
(if (<= t_0 1e-309)
(* 0.5 (- (+ 1.0 y) (/ 1.0 (+ 1.0 y))))
(* 1.0 (sinh y))))))
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) * y) / x;
} else if (t_0 <= 1e-309) {
tmp = 0.5 * ((1.0 + y) - (1.0 / (1.0 + y)));
} else {
tmp = 1.0 * sinh(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(fma(Float64(x * x), Float64(x * -0.16666666666666666), x) * y) / x); elseif (t_0 <= 1e-309) tmp = Float64(0.5 * Float64(Float64(1.0 + y) - Float64(1.0 / Float64(1.0 + y)))); else tmp = Float64(1.0 * sinh(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[(N[(x * x), $MachinePrecision] * N[(x * -0.16666666666666666), $MachinePrecision] + x), $MachinePrecision] * y), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[t$95$0, 1e-309], N[(0.5 * N[(N[(1.0 + y), $MachinePrecision] - N[(1.0 / N[(1.0 + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 * N[Sinh[y], $MachinePrecision]), $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(x \cdot x, x \cdot -0.16666666666666666, x\right) \cdot y}{x}\\
\mathbf{elif}\;t\_0 \leq 10^{-309}:\\
\;\;\;\;0.5 \cdot \left(\left(1 + y\right) - \frac{1}{1 + y}\right)\\
\mathbf{else}:\\
\;\;\;\;1 \cdot \sinh y\\
\end{array}
\end{array}
if (/.f64 (*.f64 (sin.f64 x) (sinh.f64 y)) x) < -inf.0Initial program 88.6%
Taylor expanded in x around 0
Applied rewrites51.8%
Applied rewrites51.8%
Taylor expanded in y around 0
Applied rewrites25.6%
Applied rewrites25.6%
if -inf.0 < (/.f64 (*.f64 (sin.f64 x) (sinh.f64 y)) x) < 1.000000000000002e-309Initial program 88.6%
Taylor expanded in x around 0
Applied rewrites52.9%
Taylor expanded in y around 0
Applied rewrites34.7%
Taylor expanded in y around 0
Applied rewrites17.1%
if 1.000000000000002e-309 < (/.f64 (*.f64 (sin.f64 x) (sinh.f64 y)) x) Initial program 88.6%
Applied rewrites99.9%
Taylor expanded in x around 0
Applied rewrites63.7%
(FPCore (x y) :precision binary64 (if (<= (/ (* (sin x) (sinh y)) x) 1e-309) (* 0.5 (- (+ 1.0 y) (/ 1.0 (+ 1.0 y)))) (* 1.0 (sinh y))))
double code(double x, double y) {
double tmp;
if (((sin(x) * sinh(y)) / x) <= 1e-309) {
tmp = 0.5 * ((1.0 + y) - (1.0 / (1.0 + y)));
} else {
tmp = 1.0 * sinh(y);
}
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 (((sin(x) * sinh(y)) / x) <= 1d-309) then
tmp = 0.5d0 * ((1.0d0 + y) - (1.0d0 / (1.0d0 + y)))
else
tmp = 1.0d0 * sinh(y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (((Math.sin(x) * Math.sinh(y)) / x) <= 1e-309) {
tmp = 0.5 * ((1.0 + y) - (1.0 / (1.0 + y)));
} else {
tmp = 1.0 * Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if ((math.sin(x) * math.sinh(y)) / x) <= 1e-309: tmp = 0.5 * ((1.0 + y) - (1.0 / (1.0 + y))) else: tmp = 1.0 * math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (Float64(Float64(sin(x) * sinh(y)) / x) <= 1e-309) tmp = Float64(0.5 * Float64(Float64(1.0 + y) - Float64(1.0 / Float64(1.0 + y)))); else tmp = Float64(1.0 * sinh(y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (((sin(x) * sinh(y)) / x) <= 1e-309) tmp = 0.5 * ((1.0 + y) - (1.0 / (1.0 + y))); else tmp = 1.0 * sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[(N[(N[Sin[x], $MachinePrecision] * N[Sinh[y], $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], 1e-309], N[(0.5 * N[(N[(1.0 + y), $MachinePrecision] - N[(1.0 / N[(1.0 + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 * N[Sinh[y], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{\sin x \cdot \sinh y}{x} \leq 10^{-309}:\\
\;\;\;\;0.5 \cdot \left(\left(1 + y\right) - \frac{1}{1 + y}\right)\\
\mathbf{else}:\\
\;\;\;\;1 \cdot \sinh y\\
\end{array}
\end{array}
if (/.f64 (*.f64 (sin.f64 x) (sinh.f64 y)) x) < 1.000000000000002e-309Initial program 88.6%
Taylor expanded in x around 0
Applied rewrites52.9%
Taylor expanded in y around 0
Applied rewrites34.7%
Taylor expanded in y around 0
Applied rewrites17.1%
if 1.000000000000002e-309 < (/.f64 (*.f64 (sin.f64 x) (sinh.f64 y)) x) Initial program 88.6%
Applied rewrites99.9%
Taylor expanded in x around 0
Applied rewrites63.7%
(FPCore (x y) :precision binary64 (if (<= x 1.7e+28) (* 1.0 y) (* 0.5 (- (+ 1.0 y) (- 1.0 y)))))
double code(double x, double y) {
double tmp;
if (x <= 1.7e+28) {
tmp = 1.0 * y;
} else {
tmp = 0.5 * ((1.0 + y) - (1.0 - y));
}
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 <= 1.7d+28) then
tmp = 1.0d0 * y
else
tmp = 0.5d0 * ((1.0d0 + y) - (1.0d0 - y))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= 1.7e+28) {
tmp = 1.0 * y;
} else {
tmp = 0.5 * ((1.0 + y) - (1.0 - y));
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 1.7e+28: tmp = 1.0 * y else: tmp = 0.5 * ((1.0 + y) - (1.0 - y)) return tmp
function code(x, y) tmp = 0.0 if (x <= 1.7e+28) tmp = Float64(1.0 * y); else tmp = Float64(0.5 * Float64(Float64(1.0 + y) - Float64(1.0 - y))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 1.7e+28) tmp = 1.0 * y; else tmp = 0.5 * ((1.0 + y) - (1.0 - y)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 1.7e+28], N[(1.0 * y), $MachinePrecision], N[(0.5 * N[(N[(1.0 + y), $MachinePrecision] - N[(1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.7 \cdot 10^{+28}:\\
\;\;\;\;1 \cdot y\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\left(1 + y\right) - \left(1 - y\right)\right)\\
\end{array}
\end{array}
if x < 1.7e28Initial program 88.6%
Applied rewrites99.9%
Taylor expanded in x around 0
Applied rewrites63.7%
Taylor expanded in y around 0
Applied rewrites27.9%
if 1.7e28 < x Initial program 88.6%
Taylor expanded in x around 0
Applied rewrites52.9%
Taylor expanded in y around 0
Applied rewrites34.7%
Taylor expanded in y around 0
Applied rewrites17.1%
Taylor expanded in y around 0
Applied rewrites17.3%
Applied rewrites17.3%
(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 88.6%
Applied rewrites99.9%
Taylor expanded in x around 0
Applied rewrites63.7%
Taylor expanded in y around 0
Applied rewrites27.9%
herbie shell --seed 2025153
(FPCore (x y)
:name "Linear.Quaternion:$ccosh from linear-1.19.1.3"
:precision binary64
(/ (* (sin x) (sinh y)) x))