
(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 5 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 (* (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}
Initial program 99.8%
(FPCore (x y) :precision binary64 (if (<= (cosh x) 1.00000000002) (/ (sin y) y) (cosh x)))
double code(double x, double y) {
double tmp;
if (cosh(x) <= 1.00000000002) {
tmp = sin(y) / y;
} else {
tmp = cosh(x);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (cosh(x) <= 1.00000000002d0) then
tmp = sin(y) / y
else
tmp = cosh(x)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (Math.cosh(x) <= 1.00000000002) {
tmp = Math.sin(y) / y;
} else {
tmp = Math.cosh(x);
}
return tmp;
}
def code(x, y): tmp = 0 if math.cosh(x) <= 1.00000000002: tmp = math.sin(y) / y else: tmp = math.cosh(x) return tmp
function code(x, y) tmp = 0.0 if (cosh(x) <= 1.00000000002) tmp = Float64(sin(y) / y); else tmp = cosh(x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (cosh(x) <= 1.00000000002) tmp = sin(y) / y; else tmp = cosh(x); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Cosh[x], $MachinePrecision], 1.00000000002], N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision], N[Cosh[x], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cosh x \leq 1.00000000002:\\
\;\;\;\;\frac{\sin y}{y}\\
\mathbf{else}:\\
\;\;\;\;\cosh x\\
\end{array}
\end{array}
if (cosh.f64 x) < 1.00000000002Initial program 99.7%
Taylor expanded in x around 0 99.6%
if 1.00000000002 < (cosh.f64 x) Initial program 100.0%
Taylor expanded in y around 0 74.7%
*-inverses74.7%
*-rgt-identity74.7%
cosh-def74.7%
clear-num74.7%
cosh-undef74.7%
Applied egg-rr74.7%
associate-/r*74.7%
metadata-eval74.7%
remove-double-div74.7%
Simplified74.7%
(FPCore (x y) :precision binary64 (if (<= y 6.4e+234) (cosh x) (* -0.16666666666666666 (* y y))))
double code(double x, double y) {
double tmp;
if (y <= 6.4e+234) {
tmp = cosh(x);
} else {
tmp = -0.16666666666666666 * (y * y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 6.4d+234) then
tmp = cosh(x)
else
tmp = (-0.16666666666666666d0) * (y * y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 6.4e+234) {
tmp = Math.cosh(x);
} else {
tmp = -0.16666666666666666 * (y * y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 6.4e+234: tmp = math.cosh(x) else: tmp = -0.16666666666666666 * (y * y) return tmp
function code(x, y) tmp = 0.0 if (y <= 6.4e+234) tmp = cosh(x); else tmp = Float64(-0.16666666666666666 * Float64(y * y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 6.4e+234) tmp = cosh(x); else tmp = -0.16666666666666666 * (y * y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 6.4e+234], N[Cosh[x], $MachinePrecision], N[(-0.16666666666666666 * N[(y * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 6.4 \cdot 10^{+234}:\\
\;\;\;\;\cosh x\\
\mathbf{else}:\\
\;\;\;\;-0.16666666666666666 \cdot \left(y \cdot y\right)\\
\end{array}
\end{array}
if y < 6.39999999999999983e234Initial program 99.9%
Taylor expanded in y around 0 66.6%
*-inverses66.6%
*-rgt-identity66.6%
cosh-def66.6%
clear-num66.6%
cosh-undef66.6%
Applied egg-rr66.6%
associate-/r*66.6%
metadata-eval66.6%
remove-double-div66.6%
Simplified66.6%
if 6.39999999999999983e234 < y Initial program 99.8%
Taylor expanded in x around 0 52.1%
Taylor expanded in y around 0 31.3%
distribute-rgt-in31.3%
*-lft-identity31.3%
associate-*l*31.3%
unpow231.3%
unpow331.3%
Simplified31.3%
Taylor expanded in y around inf 31.3%
unpow231.3%
Applied egg-rr31.3%
(FPCore (x y) :precision binary64 (if (<= y 4.3e+142) 1.0 (* -0.16666666666666666 (* y y))))
double code(double x, double y) {
double tmp;
if (y <= 4.3e+142) {
tmp = 1.0;
} else {
tmp = -0.16666666666666666 * (y * y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 4.3d+142) then
tmp = 1.0d0
else
tmp = (-0.16666666666666666d0) * (y * y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 4.3e+142) {
tmp = 1.0;
} else {
tmp = -0.16666666666666666 * (y * y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 4.3e+142: tmp = 1.0 else: tmp = -0.16666666666666666 * (y * y) return tmp
function code(x, y) tmp = 0.0 if (y <= 4.3e+142) tmp = 1.0; else tmp = Float64(-0.16666666666666666 * Float64(y * y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 4.3e+142) tmp = 1.0; else tmp = -0.16666666666666666 * (y * y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 4.3e+142], 1.0, N[(-0.16666666666666666 * N[(y * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.3 \cdot 10^{+142}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-0.16666666666666666 \cdot \left(y \cdot y\right)\\
\end{array}
\end{array}
if y < 4.30000000000000012e142Initial program 99.9%
Taylor expanded in y around 0 68.6%
Taylor expanded in x around 0 29.8%
if 4.30000000000000012e142 < y Initial program 99.8%
Taylor expanded in x around 0 47.6%
Taylor expanded in y around 0 31.3%
distribute-rgt-in31.3%
*-lft-identity31.3%
associate-*l*31.3%
unpow231.3%
unpow331.3%
Simplified31.3%
Taylor expanded in y around inf 26.4%
unpow226.4%
Applied egg-rr26.4%
(FPCore (x y) :precision binary64 1.0)
double code(double x, double y) {
return 1.0;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0
end function
public static double code(double x, double y) {
return 1.0;
}
def code(x, y): return 1.0
function code(x, y) return 1.0 end
function tmp = code(x, y) tmp = 1.0; end
code[x_, y_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 99.8%
Taylor expanded in y around 0 62.3%
Taylor expanded in x around 0 25.9%
(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 2024172
(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)))