
(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) (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}
Initial program 99.9%
associate-*r/99.9%
Applied egg-rr99.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(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 (or (<= x 0.036) (not (<= x 1.25e+154))) (* (sin y) (+ (* 0.5 (/ (* x x) y)) (/ 1.0 y))) (cosh x)))
double code(double x, double y) {
double tmp;
if ((x <= 0.036) || !(x <= 1.25e+154)) {
tmp = sin(y) * ((0.5 * ((x * x) / y)) + (1.0 / 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 ((x <= 0.036d0) .or. (.not. (x <= 1.25d+154))) then
tmp = sin(y) * ((0.5d0 * ((x * x) / y)) + (1.0d0 / y))
else
tmp = cosh(x)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= 0.036) || !(x <= 1.25e+154)) {
tmp = Math.sin(y) * ((0.5 * ((x * x) / y)) + (1.0 / y));
} else {
tmp = Math.cosh(x);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= 0.036) or not (x <= 1.25e+154): tmp = math.sin(y) * ((0.5 * ((x * x) / y)) + (1.0 / y)) else: tmp = math.cosh(x) return tmp
function code(x, y) tmp = 0.0 if ((x <= 0.036) || !(x <= 1.25e+154)) tmp = Float64(sin(y) * Float64(Float64(0.5 * Float64(Float64(x * x) / y)) + Float64(1.0 / y))); else tmp = cosh(x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= 0.036) || ~((x <= 1.25e+154))) tmp = sin(y) * ((0.5 * ((x * x) / y)) + (1.0 / y)); else tmp = cosh(x); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, 0.036], N[Not[LessEqual[x, 1.25e+154]], $MachinePrecision]], N[(N[Sin[y], $MachinePrecision] * N[(N[(0.5 * N[(N[(x * x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] + N[(1.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Cosh[x], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.036 \lor \neg \left(x \leq 1.25 \cdot 10^{+154}\right):\\
\;\;\;\;\sin y \cdot \left(0.5 \cdot \frac{x \cdot x}{y} + \frac{1}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;\cosh x\\
\end{array}
\end{array}
if x < 0.0359999999999999973 or 1.25000000000000001e154 < x Initial program 99.9%
*-commutative99.9%
associate-*l/99.9%
associate-/l*99.7%
Simplified99.7%
Taylor expanded in x around 0 91.0%
unpow291.0%
Applied egg-rr91.0%
if 0.0359999999999999973 < x < 1.25000000000000001e154Initial program 100.0%
associate-*r/100.0%
Applied egg-rr100.0%
Taylor expanded in y around 0 78.8%
*-commutative78.8%
associate-/l*78.7%
Applied egg-rr78.7%
associate-*r/78.8%
*-lft-identity78.8%
associate-*l/78.8%
associate-*r*78.8%
lft-mult-inverse78.8%
*-lft-identity78.8%
Simplified78.8%
Final simplification89.4%
(FPCore (x y) :precision binary64 (if (<= x 0.11) (/ (sin y) y) (cosh x)))
double code(double x, double y) {
double tmp;
if (x <= 0.11) {
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 (x <= 0.11d0) 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 (x <= 0.11) {
tmp = Math.sin(y) / y;
} else {
tmp = Math.cosh(x);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 0.11: tmp = math.sin(y) / y else: tmp = math.cosh(x) return tmp
function code(x, y) tmp = 0.0 if (x <= 0.11) tmp = Float64(sin(y) / y); else tmp = cosh(x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 0.11) tmp = sin(y) / y; else tmp = cosh(x); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 0.11], N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision], N[Cosh[x], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.11:\\
\;\;\;\;\frac{\sin y}{y}\\
\mathbf{else}:\\
\;\;\;\;\cosh x\\
\end{array}
\end{array}
if x < 0.110000000000000001Initial program 99.8%
Taylor expanded in x around 0 74.1%
if 0.110000000000000001 < x Initial program 100.0%
associate-*r/100.0%
Applied egg-rr100.0%
Taylor expanded in y around 0 66.7%
*-commutative66.7%
associate-/l*66.6%
Applied egg-rr66.6%
associate-*r/66.7%
*-lft-identity66.7%
associate-*l/66.7%
associate-*r*66.7%
lft-mult-inverse66.7%
*-lft-identity66.7%
Simplified66.7%
(FPCore (x y) :precision binary64 (cosh x))
double code(double x, double y) {
return cosh(x);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = cosh(x)
end function
public static double code(double x, double y) {
return Math.cosh(x);
}
def code(x, y): return math.cosh(x)
function code(x, y) return cosh(x) end
function tmp = code(x, y) tmp = cosh(x); end
code[x_, y_] := N[Cosh[x], $MachinePrecision]
\begin{array}{l}
\\
\cosh x
\end{array}
Initial program 99.9%
associate-*r/99.9%
Applied egg-rr99.9%
Taylor expanded in y around 0 54.4%
*-commutative54.4%
associate-/l*54.3%
Applied egg-rr54.3%
associate-*r/54.4%
*-lft-identity54.4%
associate-*l/54.3%
associate-*r*54.3%
lft-mult-inverse54.4%
*-lft-identity54.4%
Simplified54.4%
(FPCore (x y) :precision binary64 (* y (+ (* 0.5 (/ (* x x) y)) (/ 1.0 y))))
double code(double x, double y) {
return y * ((0.5 * ((x * x) / y)) + (1.0 / y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = y * ((0.5d0 * ((x * x) / y)) + (1.0d0 / y))
end function
public static double code(double x, double y) {
return y * ((0.5 * ((x * x) / y)) + (1.0 / y));
}
def code(x, y): return y * ((0.5 * ((x * x) / y)) + (1.0 / y))
function code(x, y) return Float64(y * Float64(Float64(0.5 * Float64(Float64(x * x) / y)) + Float64(1.0 / y))) end
function tmp = code(x, y) tmp = y * ((0.5 * ((x * x) / y)) + (1.0 / y)); end
code[x_, y_] := N[(y * N[(N[(0.5 * N[(N[(x * x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] + N[(1.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
y \cdot \left(0.5 \cdot \frac{x \cdot x}{y} + \frac{1}{y}\right)
\end{array}
Initial program 99.9%
*-commutative99.9%
associate-*l/99.9%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around 0 81.7%
unpow281.7%
Applied egg-rr81.7%
Taylor expanded in y around 0 42.1%
(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%
*-commutative99.9%
associate-*l/99.9%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around 0 56.5%
Taylor expanded in y around 0 26.0%
(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 2024143
(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)))