
(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 7 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) (/ y (sin y))))
double code(double x, double y) {
return cosh(x) / (y / sin(y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = cosh(x) / (y / sin(y))
end function
public static double code(double x, double y) {
return Math.cosh(x) / (y / Math.sin(y));
}
def code(x, y): return math.cosh(x) / (y / math.sin(y))
function code(x, y) return Float64(cosh(x) / Float64(y / sin(y))) end
function tmp = code(x, y) tmp = cosh(x) / (y / sin(y)); end
code[x_, y_] := N[(N[Cosh[x], $MachinePrecision] / N[(y / N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\cosh x}{\frac{y}{\sin y}}
\end{array}
Initial program 99.9%
clear-num99.9%
un-div-inv99.9%
Applied egg-rr99.9%
(FPCore (x y) :precision binary64 (if (<= (cosh x) 3.1e+215) (/ 1.0 (/ y (sin y))) (cosh x)))
double code(double x, double y) {
double tmp;
if (cosh(x) <= 3.1e+215) {
tmp = 1.0 / (y / sin(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) <= 3.1d+215) then
tmp = 1.0d0 / (y / sin(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) <= 3.1e+215) {
tmp = 1.0 / (y / Math.sin(y));
} else {
tmp = Math.cosh(x);
}
return tmp;
}
def code(x, y): tmp = 0 if math.cosh(x) <= 3.1e+215: tmp = 1.0 / (y / math.sin(y)) else: tmp = math.cosh(x) return tmp
function code(x, y) tmp = 0.0 if (cosh(x) <= 3.1e+215) tmp = Float64(1.0 / Float64(y / sin(y))); else tmp = cosh(x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (cosh(x) <= 3.1e+215) tmp = 1.0 / (y / sin(y)); else tmp = cosh(x); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Cosh[x], $MachinePrecision], 3.1e+215], N[(1.0 / N[(y / N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Cosh[x], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cosh x \leq 3.1 \cdot 10^{+215}:\\
\;\;\;\;\frac{1}{\frac{y}{\sin y}}\\
\mathbf{else}:\\
\;\;\;\;\cosh x\\
\end{array}
\end{array}
if (cosh.f64 x) < 3.0999999999999999e215Initial program 99.7%
clear-num99.8%
un-div-inv99.8%
Applied egg-rr99.8%
Taylor expanded in x around 0 97.8%
if 3.0999999999999999e215 < (cosh.f64 x) Initial program 100.0%
clear-num100.0%
un-div-inv100.0%
Applied egg-rr100.0%
Taylor expanded in y around 0 78.3%
Taylor expanded in x around inf 78.3%
*-commutative78.3%
metadata-eval78.3%
associate-/l*78.3%
*-rgt-identity78.3%
rec-exp78.3%
cosh-def78.3%
Simplified78.3%
(FPCore (x y) :precision binary64 (if (<= (cosh x) 3.1e+215) (/ (sin y) y) (cosh x)))
double code(double x, double y) {
double tmp;
if (cosh(x) <= 3.1e+215) {
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) <= 3.1d+215) 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) <= 3.1e+215) {
tmp = Math.sin(y) / y;
} else {
tmp = Math.cosh(x);
}
return tmp;
}
def code(x, y): tmp = 0 if math.cosh(x) <= 3.1e+215: tmp = math.sin(y) / y else: tmp = math.cosh(x) return tmp
function code(x, y) tmp = 0.0 if (cosh(x) <= 3.1e+215) 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) <= 3.1e+215) tmp = sin(y) / y; else tmp = cosh(x); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Cosh[x], $MachinePrecision], 3.1e+215], N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision], N[Cosh[x], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cosh x \leq 3.1 \cdot 10^{+215}:\\
\;\;\;\;\frac{\sin y}{y}\\
\mathbf{else}:\\
\;\;\;\;\cosh x\\
\end{array}
\end{array}
if (cosh.f64 x) < 3.0999999999999999e215Initial program 99.7%
Taylor expanded in x around 0 97.8%
if 3.0999999999999999e215 < (cosh.f64 x) Initial program 100.0%
clear-num100.0%
un-div-inv100.0%
Applied egg-rr100.0%
Taylor expanded in y around 0 78.3%
Taylor expanded in x around inf 78.3%
*-commutative78.3%
metadata-eval78.3%
associate-/l*78.3%
*-rgt-identity78.3%
rec-exp78.3%
cosh-def78.3%
Simplified78.3%
(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.9%
(FPCore (x y) :precision binary64 (if (<= y 5.8e+252) (cosh x) (+ 1.0 (* (* y y) -0.16666666666666666))))
double code(double x, double y) {
double tmp;
if (y <= 5.8e+252) {
tmp = cosh(x);
} else {
tmp = 1.0 + ((y * y) * -0.16666666666666666);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 5.8d+252) then
tmp = cosh(x)
else
tmp = 1.0d0 + ((y * y) * (-0.16666666666666666d0))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 5.8e+252) {
tmp = Math.cosh(x);
} else {
tmp = 1.0 + ((y * y) * -0.16666666666666666);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 5.8e+252: tmp = math.cosh(x) else: tmp = 1.0 + ((y * y) * -0.16666666666666666) return tmp
function code(x, y) tmp = 0.0 if (y <= 5.8e+252) tmp = cosh(x); else tmp = Float64(1.0 + Float64(Float64(y * y) * -0.16666666666666666)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 5.8e+252) tmp = cosh(x); else tmp = 1.0 + ((y * y) * -0.16666666666666666); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 5.8e+252], N[Cosh[x], $MachinePrecision], N[(1.0 + N[(N[(y * y), $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5.8 \cdot 10^{+252}:\\
\;\;\;\;\cosh x\\
\mathbf{else}:\\
\;\;\;\;1 + \left(y \cdot y\right) \cdot -0.16666666666666666\\
\end{array}
\end{array}
if y < 5.79999999999999992e252Initial program 99.9%
clear-num99.9%
un-div-inv99.9%
Applied egg-rr99.9%
Taylor expanded in y around 0 65.6%
Taylor expanded in x around inf 65.6%
*-commutative65.6%
metadata-eval65.6%
associate-/l*65.6%
*-rgt-identity65.6%
rec-exp65.6%
cosh-def65.6%
Simplified65.6%
if 5.79999999999999992e252 < y Initial program 99.8%
Taylor expanded in x around 0 61.9%
Taylor expanded in y around 0 39.4%
*-commutative39.4%
Simplified39.4%
unpow239.4%
Applied egg-rr39.4%
(FPCore (x y) :precision binary64 (+ 1.0 (* (* y y) -0.16666666666666666)))
double code(double x, double y) {
return 1.0 + ((y * y) * -0.16666666666666666);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0 + ((y * y) * (-0.16666666666666666d0))
end function
public static double code(double x, double y) {
return 1.0 + ((y * y) * -0.16666666666666666);
}
def code(x, y): return 1.0 + ((y * y) * -0.16666666666666666)
function code(x, y) return Float64(1.0 + Float64(Float64(y * y) * -0.16666666666666666)) end
function tmp = code(x, y) tmp = 1.0 + ((y * y) * -0.16666666666666666); end
code[x_, y_] := N[(1.0 + N[(N[(y * y), $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \left(y \cdot y\right) \cdot -0.16666666666666666
\end{array}
Initial program 99.9%
Taylor expanded in x around 0 53.2%
Taylor expanded in y around 0 31.8%
*-commutative31.8%
Simplified31.8%
unpow231.8%
Applied egg-rr31.8%
(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.9%
Taylor expanded in x around 0 53.2%
Taylor expanded in y around 0 26.8%
Taylor expanded in y around 0 26.8%
(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 2024157
(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)))