
(FPCore (x y) :precision binary64 :pre TRUE (* (cosh x) (/ (sin y) y)))
double code(double x, double y) {
return cosh(x) * (sin(y) / y);
}
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = cosh(x) * (sin(y) / y)
end function
public static double code(double x, double y) {
return Math.cosh(x) * (Math.sin(y) / y);
}
def code(x, y): return math.cosh(x) * (math.sin(y) / y)
function code(x, y) return Float64(cosh(x) * Float64(sin(y) / y)) end
function tmp = code(x, y) tmp = cosh(x) * (sin(y) / y); end
code[x_, y_] := N[(N[Cosh[x], $MachinePrecision] * N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = (((1) / (2)) * ((exp(x)) + ((1) / (exp(x))))) * ((sin(y)) / y) END code
\cosh x \cdot \frac{\sin y}{y}
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 :pre TRUE (* (cosh x) (/ (sin y) y)))
double code(double x, double y) {
return cosh(x) * (sin(y) / y);
}
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = cosh(x) * (sin(y) / y)
end function
public static double code(double x, double y) {
return Math.cosh(x) * (Math.sin(y) / y);
}
def code(x, y): return math.cosh(x) * (math.sin(y) / y)
function code(x, y) return Float64(cosh(x) * Float64(sin(y) / y)) end
function tmp = code(x, y) tmp = cosh(x) * (sin(y) / y); end
code[x_, y_] := N[(N[Cosh[x], $MachinePrecision] * N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = (((1) / (2)) * ((exp(x)) + ((1) / (exp(x))))) * ((sin(y)) / y) END code
\cosh x \cdot \frac{\sin y}{y}
(FPCore (x y)
:precision binary64
:pre TRUE
(let* ((t_0 (/ (sin y) y)) (t_1 (* (cosh x) t_0)))
(if (<= t_1 (- INFINITY))
(* (cosh x) (fma (* y y) -0.16666666666666666 1.0))
(if (<= t_1 0.9999999999999999) t_0 (/ 1.0 (/ 1.0 (cosh x)))))))double code(double x, double y) {
double t_0 = sin(y) / y;
double t_1 = cosh(x) * t_0;
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = cosh(x) * fma((y * y), -0.16666666666666666, 1.0);
} else if (t_1 <= 0.9999999999999999) {
tmp = t_0;
} else {
tmp = 1.0 / (1.0 / cosh(x));
}
return tmp;
}
function code(x, y) t_0 = Float64(sin(y) / y) t_1 = Float64(cosh(x) * t_0) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(cosh(x) * fma(Float64(y * y), -0.16666666666666666, 1.0)); elseif (t_1 <= 0.9999999999999999) tmp = t_0; else tmp = Float64(1.0 / Float64(1.0 / cosh(x))); end return tmp end
code[x_, y_] := Block[{t$95$0 = N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cosh[x], $MachinePrecision] * t$95$0), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(N[Cosh[x], $MachinePrecision] * N[(N[(y * y), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.9999999999999999], t$95$0, N[(1.0 / N[(1.0 / N[Cosh[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
t_0 := \frac{\sin y}{y}\\
t_1 := \cosh x \cdot t\_0\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;\cosh x \cdot \mathsf{fma}\left(y \cdot y, -0.16666666666666666, 1\right)\\
\mathbf{elif}\;t\_1 \leq 0.9999999999999999:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{1}{\cosh x}}\\
\end{array}
if (*.f64 (cosh.f64 x) (/.f64 (sin.f64 y) y)) < -inf.0Initial program 99.9%
Taylor expanded in y around 0
Applied rewrites62.7%
Applied rewrites62.7%
if -inf.0 < (*.f64 (cosh.f64 x) (/.f64 (sin.f64 y) y)) < 0.99999999999999989Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites51.0%
if 0.99999999999999989 < (*.f64 (cosh.f64 x) (/.f64 (sin.f64 y) y)) Initial program 99.9%
Applied rewrites99.8%
Taylor expanded in y around 0
Applied rewrites62.4%
Applied rewrites62.4%
(FPCore (x y) :precision binary64 :pre TRUE (if (<= (* (cosh x) (/ (sin y) y)) -1e-148) (* (cosh x) (fma (* y y) -0.16666666666666666 1.0)) (/ 1.0 (/ 1.0 (cosh x)))))
double code(double x, double y) {
double tmp;
if ((cosh(x) * (sin(y) / y)) <= -1e-148) {
tmp = cosh(x) * fma((y * y), -0.16666666666666666, 1.0);
} else {
tmp = 1.0 / (1.0 / cosh(x));
}
return tmp;
}
function code(x, y) tmp = 0.0 if (Float64(cosh(x) * Float64(sin(y) / y)) <= -1e-148) tmp = Float64(cosh(x) * fma(Float64(y * y), -0.16666666666666666, 1.0)); else tmp = Float64(1.0 / Float64(1.0 / cosh(x))); end return tmp end
code[x_, y_] := If[LessEqual[N[(N[Cosh[x], $MachinePrecision] * N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], -1e-148], N[(N[Cosh[x], $MachinePrecision] * N[(N[(y * y), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(1.0 / N[Cosh[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = LET tmp = IF (((((1) / (2)) * ((exp(x)) + ((1) / (exp(x))))) * ((sin(y)) / y)) <= (-999999999999999935748815890117282149663822731120577929628009867749049427642678029270005288335997592555778350731539802843803522676304070686845283750574203026982376971286717937832954133378800900225517256537491228018261850658864691187645294441546276508577338302627079226124410768716556281580123652602299929902354192051524133144221481909121761385664308924357650265601904493451002053916454315185546875e-544)) THEN ((((1) / (2)) * ((exp(x)) + ((1) / (exp(x))))) * (((y * y) * (-1666666666666666574148081281236954964697360992431640625e-55)) + (1))) ELSE ((1) / ((1) / (((1) / (2)) * ((exp(x)) + ((1) / (exp(x))))))) ENDIF IN tmp END code
\begin{array}{l}
\mathbf{if}\;\cosh x \cdot \frac{\sin y}{y} \leq -1 \cdot 10^{-148}:\\
\;\;\;\;\cosh x \cdot \mathsf{fma}\left(y \cdot y, -0.16666666666666666, 1\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{1}{\cosh x}}\\
\end{array}
if (*.f64 (cosh.f64 x) (/.f64 (sin.f64 y) y)) < -9.9999999999999994e-149Initial program 99.9%
Taylor expanded in y around 0
Applied rewrites62.7%
Applied rewrites62.7%
if -9.9999999999999994e-149 < (*.f64 (cosh.f64 x) (/.f64 (sin.f64 y) y)) Initial program 99.9%
Applied rewrites99.8%
Taylor expanded in y around 0
Applied rewrites62.4%
Applied rewrites62.4%
(FPCore (x y) :precision binary64 :pre TRUE (if (<= (* (cosh x) (/ (sin y) y)) -1e-148) (fma (sqrt (* (* y y) (* y y))) -0.16666666666666666 1.0) (/ 1.0 (/ 1.0 (cosh x)))))
double code(double x, double y) {
double tmp;
if ((cosh(x) * (sin(y) / y)) <= -1e-148) {
tmp = fma(sqrt(((y * y) * (y * y))), -0.16666666666666666, 1.0);
} else {
tmp = 1.0 / (1.0 / cosh(x));
}
return tmp;
}
function code(x, y) tmp = 0.0 if (Float64(cosh(x) * Float64(sin(y) / y)) <= -1e-148) tmp = fma(sqrt(Float64(Float64(y * y) * Float64(y * y))), -0.16666666666666666, 1.0); else tmp = Float64(1.0 / Float64(1.0 / cosh(x))); end return tmp end
code[x_, y_] := If[LessEqual[N[(N[Cosh[x], $MachinePrecision] * N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], -1e-148], N[(N[Sqrt[N[(N[(y * y), $MachinePrecision] * N[(y * y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision], N[(1.0 / N[(1.0 / N[Cosh[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = LET tmp = IF (((((1) / (2)) * ((exp(x)) + ((1) / (exp(x))))) * ((sin(y)) / y)) <= (-999999999999999935748815890117282149663822731120577929628009867749049427642678029270005288335997592555778350731539802843803522676304070686845283750574203026982376971286717937832954133378800900225517256537491228018261850658864691187645294441546276508577338302627079226124410768716556281580123652602299929902354192051524133144221481909121761385664308924357650265601904493451002053916454315185546875e-544)) THEN (((sqrt(((y * y) * (y * y)))) * (-1666666666666666574148081281236954964697360992431640625e-55)) + (1)) ELSE ((1) / ((1) / (((1) / (2)) * ((exp(x)) + ((1) / (exp(x))))))) ENDIF IN tmp END code
\begin{array}{l}
\mathbf{if}\;\cosh x \cdot \frac{\sin y}{y} \leq -1 \cdot 10^{-148}:\\
\;\;\;\;\mathsf{fma}\left(\sqrt{\left(y \cdot y\right) \cdot \left(y \cdot y\right)}, -0.16666666666666666, 1\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{1}{\cosh x}}\\
\end{array}
if (*.f64 (cosh.f64 x) (/.f64 (sin.f64 y) y)) < -9.9999999999999994e-149Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites51.0%
Taylor expanded in y around 0
Applied rewrites33.0%
Applied rewrites33.0%
rem-square-sqrtN/A
sqrt-unprodN/A
lift-*.f64N/A
lift-sqrt.f6436.0%
Applied rewrites36.0%
if -9.9999999999999994e-149 < (*.f64 (cosh.f64 x) (/.f64 (sin.f64 y) y)) Initial program 99.9%
Applied rewrites99.8%
Taylor expanded in y around 0
Applied rewrites62.4%
Applied rewrites62.4%
(FPCore (x y) :precision binary64 :pre TRUE (if (<= (* (cosh x) (/ (sin y) y)) 20.0) (fma (sqrt (* (* y y) (* y y))) -0.16666666666666666 1.0) (/ (/ -1.0 y) (* -0.16666666666666666 y))))
double code(double x, double y) {
double tmp;
if ((cosh(x) * (sin(y) / y)) <= 20.0) {
tmp = fma(sqrt(((y * y) * (y * y))), -0.16666666666666666, 1.0);
} else {
tmp = (-1.0 / y) / (-0.16666666666666666 * y);
}
return tmp;
}
function code(x, y) tmp = 0.0 if (Float64(cosh(x) * Float64(sin(y) / y)) <= 20.0) tmp = fma(sqrt(Float64(Float64(y * y) * Float64(y * y))), -0.16666666666666666, 1.0); else tmp = Float64(Float64(-1.0 / y) / Float64(-0.16666666666666666 * y)); end return tmp end
code[x_, y_] := If[LessEqual[N[(N[Cosh[x], $MachinePrecision] * N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], 20.0], N[(N[Sqrt[N[(N[(y * y), $MachinePrecision] * N[(y * y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision], N[(N[(-1.0 / y), $MachinePrecision] / N[(-0.16666666666666666 * y), $MachinePrecision]), $MachinePrecision]]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = LET tmp = IF (((((1) / (2)) * ((exp(x)) + ((1) / (exp(x))))) * ((sin(y)) / y)) <= (20)) THEN (((sqrt(((y * y) * (y * y)))) * (-1666666666666666574148081281236954964697360992431640625e-55)) + (1)) ELSE (((-1) / y) / ((-1666666666666666574148081281236954964697360992431640625e-55) * y)) ENDIF IN tmp END code
\begin{array}{l}
\mathbf{if}\;\cosh x \cdot \frac{\sin y}{y} \leq 20:\\
\;\;\;\;\mathsf{fma}\left(\sqrt{\left(y \cdot y\right) \cdot \left(y \cdot y\right)}, -0.16666666666666666, 1\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{-1}{y}}{-0.16666666666666666 \cdot y}\\
\end{array}
if (*.f64 (cosh.f64 x) (/.f64 (sin.f64 y) y)) < 20Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites51.0%
Taylor expanded in y around 0
Applied rewrites33.0%
Applied rewrites33.0%
rem-square-sqrtN/A
sqrt-unprodN/A
lift-*.f64N/A
lift-sqrt.f6436.0%
Applied rewrites36.0%
if 20 < (*.f64 (cosh.f64 x) (/.f64 (sin.f64 y) y)) Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites51.0%
Applied rewrites50.9%
Taylor expanded in y around 0
Applied rewrites27.3%
Taylor expanded in y around inf
Applied rewrites15.5%
(FPCore (x y) :precision binary64 :pre TRUE (if (<= (* (cosh x) (/ (sin y) y)) 20.0) (fma (* y y) -0.16666666666666666 1.0) (/ (/ -1.0 y) (* -0.16666666666666666 y))))
double code(double x, double y) {
double tmp;
if ((cosh(x) * (sin(y) / y)) <= 20.0) {
tmp = fma((y * y), -0.16666666666666666, 1.0);
} else {
tmp = (-1.0 / y) / (-0.16666666666666666 * y);
}
return tmp;
}
function code(x, y) tmp = 0.0 if (Float64(cosh(x) * Float64(sin(y) / y)) <= 20.0) tmp = fma(Float64(y * y), -0.16666666666666666, 1.0); else tmp = Float64(Float64(-1.0 / y) / Float64(-0.16666666666666666 * y)); end return tmp end
code[x_, y_] := If[LessEqual[N[(N[Cosh[x], $MachinePrecision] * N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], 20.0], N[(N[(y * y), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision], N[(N[(-1.0 / y), $MachinePrecision] / N[(-0.16666666666666666 * y), $MachinePrecision]), $MachinePrecision]]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = LET tmp = IF (((((1) / (2)) * ((exp(x)) + ((1) / (exp(x))))) * ((sin(y)) / y)) <= (20)) THEN (((y * y) * (-1666666666666666574148081281236954964697360992431640625e-55)) + (1)) ELSE (((-1) / y) / ((-1666666666666666574148081281236954964697360992431640625e-55) * y)) ENDIF IN tmp END code
\begin{array}{l}
\mathbf{if}\;\cosh x \cdot \frac{\sin y}{y} \leq 20:\\
\;\;\;\;\mathsf{fma}\left(y \cdot y, -0.16666666666666666, 1\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{-1}{y}}{-0.16666666666666666 \cdot y}\\
\end{array}
if (*.f64 (cosh.f64 x) (/.f64 (sin.f64 y) y)) < 20Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites51.0%
Taylor expanded in y around 0
Applied rewrites33.0%
Applied rewrites33.0%
if 20 < (*.f64 (cosh.f64 x) (/.f64 (sin.f64 y) y)) Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites51.0%
Applied rewrites50.9%
Taylor expanded in y around 0
Applied rewrites27.3%
Taylor expanded in y around inf
Applied rewrites15.5%
(FPCore (x y) :precision binary64 :pre TRUE (fma (* y y) -0.16666666666666666 1.0))
double code(double x, double y) {
return fma((y * y), -0.16666666666666666, 1.0);
}
function code(x, y) return fma(Float64(y * y), -0.16666666666666666, 1.0) end
code[x_, y_] := N[(N[(y * y), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = ((y * y) * (-1666666666666666574148081281236954964697360992431640625e-55)) + (1) END code
\mathsf{fma}\left(y \cdot y, -0.16666666666666666, 1\right)
Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites51.0%
Taylor expanded in y around 0
Applied rewrites33.0%
Applied rewrites33.0%
(FPCore (x y) :precision binary64 :pre TRUE (/ 1.0 (/ 2.0 2.0)))
double code(double x, double y) {
return 1.0 / (2.0 / 2.0);
}
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0 / (2.0d0 / 2.0d0)
end function
public static double code(double x, double y) {
return 1.0 / (2.0 / 2.0);
}
def code(x, y): return 1.0 / (2.0 / 2.0)
function code(x, y) return Float64(1.0 / Float64(2.0 / 2.0)) end
function tmp = code(x, y) tmp = 1.0 / (2.0 / 2.0); end
code[x_, y_] := N[(1.0 / N[(2.0 / 2.0), $MachinePrecision]), $MachinePrecision]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = (1) / ((2) / (2)) END code
\frac{1}{\frac{2}{2}}
Initial program 99.9%
Applied rewrites99.8%
Taylor expanded in y around 0
Applied rewrites62.4%
Taylor expanded in x around 0
Applied rewrites26.7%
herbie shell --seed 2026092
(FPCore (x y)
:name "Linear.Quaternion:$csinh from linear-1.19.1.3"
:precision binary64
(* (cosh x) (/ (sin y) y)))