
(FPCore (x y) :precision binary64 (* (cosh x) (/ (sin y) y)))
double code(double x, double y) {
return cosh(x) * (sin(y) / y);
}
real(8) function code(x, y)
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]
\begin{array}{l}
\\
\cosh x \cdot \frac{\sin y}{y}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 27 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (* (cosh x) (/ (sin y) y)))
double code(double x, double y) {
return cosh(x) * (sin(y) / y);
}
real(8) function code(x, y)
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]
\begin{array}{l}
\\
\cosh x \cdot \frac{\sin y}{y}
\end{array}
(FPCore (x y) :precision binary64 (* (/ (sin y) y) (cosh x)))
double code(double x, double y) {
return (sin(y) / y) * cosh(x);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (sin(y) / y) * cosh(x)
end function
public static double code(double x, double y) {
return (Math.sin(y) / y) * Math.cosh(x);
}
def code(x, y): return (math.sin(y) / y) * math.cosh(x)
function code(x, y) return Float64(Float64(sin(y) / y) * cosh(x)) end
function tmp = code(x, y) tmp = (sin(y) / y) * cosh(x); end
code[x_, y_] := N[(N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision] * N[Cosh[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin y}{y} \cdot \cosh x
\end{array}
Initial program 99.9%
Final simplification99.9%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* (/ (sin y) y) (cosh x))))
(if (<= t_0 (- INFINITY))
(* (fma (* -0.16666666666666666 y) y 1.0) (cosh x))
(if (<= t_0 0.9999984954924755)
(/
(* (fma (* (fma (* 0.041666666666666664 x) x 0.5) x) x 1.0) (sin y))
y)
(* 1.0 (cosh x))))))
double code(double x, double y) {
double t_0 = (sin(y) / y) * cosh(x);
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = fma((-0.16666666666666666 * y), y, 1.0) * cosh(x);
} else if (t_0 <= 0.9999984954924755) {
tmp = (fma((fma((0.041666666666666664 * x), x, 0.5) * x), x, 1.0) * sin(y)) / y;
} else {
tmp = 1.0 * cosh(x);
}
return tmp;
}
function code(x, y) t_0 = Float64(Float64(sin(y) / y) * cosh(x)) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(fma(Float64(-0.16666666666666666 * y), y, 1.0) * cosh(x)); elseif (t_0 <= 0.9999984954924755) tmp = Float64(Float64(fma(Float64(fma(Float64(0.041666666666666664 * x), x, 0.5) * x), x, 1.0) * sin(y)) / y); else tmp = Float64(1.0 * cosh(x)); end return tmp end
code[x_, y_] := Block[{t$95$0 = N[(N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision] * N[Cosh[x], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(N[(N[(-0.16666666666666666 * y), $MachinePrecision] * y + 1.0), $MachinePrecision] * N[Cosh[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 0.9999984954924755], N[(N[(N[(N[(N[(N[(0.041666666666666664 * x), $MachinePrecision] * x + 0.5), $MachinePrecision] * x), $MachinePrecision] * x + 1.0), $MachinePrecision] * N[Sin[y], $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision], N[(1.0 * N[Cosh[x], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sin y}{y} \cdot \cosh x\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;\mathsf{fma}\left(-0.16666666666666666 \cdot y, y, 1\right) \cdot \cosh x\\
\mathbf{elif}\;t\_0 \leq 0.9999984954924755:\\
\;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(0.041666666666666664 \cdot x, x, 0.5\right) \cdot x, x, 1\right) \cdot \sin y}{y}\\
\mathbf{else}:\\
\;\;\;\;1 \cdot \cosh x\\
\end{array}
\end{array}
if (*.f64 (cosh.f64 x) (/.f64 (sin.f64 y) y)) < -inf.0Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64100.0
Applied rewrites100.0%
if -inf.0 < (*.f64 (cosh.f64 x) (/.f64 (sin.f64 y) y)) < 0.999998495492475548Initial program 99.7%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6499.7
Applied rewrites99.7%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
+-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f6498.6
Applied rewrites98.6%
if 0.999998495492475548 < (*.f64 (cosh.f64 x) (/.f64 (sin.f64 y) y)) Initial program 100.0%
Taylor expanded in y around 0
Applied rewrites99.8%
Final simplification99.5%
(FPCore (x y) :precision binary64 (/ (* (cosh x) (sin y)) y))
double code(double x, double y) {
return (cosh(x) * sin(y)) / y;
}
real(8) function code(x, y)
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(Float64(cosh(x) * sin(y)) / y) end
function tmp = code(x, y) tmp = (cosh(x) * sin(y)) / y; end
code[x_, y_] := N[(N[(N[Cosh[x], $MachinePrecision] * N[Sin[y], $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]
\begin{array}{l}
\\
\frac{\cosh x \cdot \sin y}{y}
\end{array}
herbie shell --seed 2024230
(FPCore (x y)
:name "Linear.Quaternion:$csinh from linear-1.19.1.3"
:precision binary64
:alt
(! :herbie-platform default (/ (* (cosh x) (sin y)) y))
(* (cosh x) (/ (sin y) y)))