
(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(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 (if (<= (cosh x) 1.35) (/ (sin y) y) (cosh x)))
double code(double x, double y) {
double tmp;
if (cosh(x) <= 1.35) {
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.35d0) 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.35) {
tmp = Math.sin(y) / y;
} else {
tmp = Math.cosh(x);
}
return tmp;
}
def code(x, y): tmp = 0 if math.cosh(x) <= 1.35: tmp = math.sin(y) / y else: tmp = math.cosh(x) return tmp
function code(x, y) tmp = 0.0 if (cosh(x) <= 1.35) 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.35) tmp = sin(y) / y; else tmp = cosh(x); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Cosh[x], $MachinePrecision], 1.35], N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision], N[Cosh[x], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cosh x \leq 1.35:\\
\;\;\;\;\frac{\sin y}{y}\\
\mathbf{else}:\\
\;\;\;\;\cosh x\\
\end{array}
\end{array}
(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}
(FPCore (x y) :precision binary64 (if (<= x 0.0015) (/ -1.0 (* y (+ (/ -1.0 y) (* y -0.16666666666666666)))) (/ (/ 1.0 y) (* y 0.16666666666666666))))
double code(double x, double y) {
double tmp;
if (x <= 0.0015) {
tmp = -1.0 / (y * ((-1.0 / y) + (y * -0.16666666666666666)));
} 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 (x <= 0.0015d0) then
tmp = (-1.0d0) / (y * (((-1.0d0) / y) + (y * (-0.16666666666666666d0))))
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 (x <= 0.0015) {
tmp = -1.0 / (y * ((-1.0 / y) + (y * -0.16666666666666666)));
} else {
tmp = (1.0 / y) / (y * 0.16666666666666666);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 0.0015: tmp = -1.0 / (y * ((-1.0 / y) + (y * -0.16666666666666666))) else: tmp = (1.0 / y) / (y * 0.16666666666666666) return tmp
function code(x, y) tmp = 0.0 if (x <= 0.0015) tmp = Float64(-1.0 / Float64(y * Float64(Float64(-1.0 / y) + Float64(y * -0.16666666666666666)))); else tmp = Float64(Float64(1.0 / y) / Float64(y * 0.16666666666666666)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 0.0015) tmp = -1.0 / (y * ((-1.0 / y) + (y * -0.16666666666666666))); else tmp = (1.0 / y) / (y * 0.16666666666666666); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 0.0015], N[(-1.0 / N[(y * N[(N[(-1.0 / y), $MachinePrecision] + N[(y * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / y), $MachinePrecision] / N[(y * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.0015:\\
\;\;\;\;\frac{-1}{y \cdot \left(\frac{-1}{y} + y \cdot -0.16666666666666666\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{y}}{y \cdot 0.16666666666666666}\\
\end{array}
\end{array}
(FPCore (x y) :precision binary64 (if (<= x 6.8e-5) (/ (/ 1.0 y) (+ (/ 1.0 y) (* y 0.16666666666666666))) (/ (/ 1.0 y) (* y 0.16666666666666666))))
double code(double x, double y) {
double tmp;
if (x <= 6.8e-5) {
tmp = (1.0 / y) / ((1.0 / y) + (y * 0.16666666666666666));
} 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 (x <= 6.8d-5) then
tmp = (1.0d0 / y) / ((1.0d0 / y) + (y * 0.16666666666666666d0))
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 (x <= 6.8e-5) {
tmp = (1.0 / y) / ((1.0 / y) + (y * 0.16666666666666666));
} else {
tmp = (1.0 / y) / (y * 0.16666666666666666);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 6.8e-5: tmp = (1.0 / y) / ((1.0 / y) + (y * 0.16666666666666666)) else: tmp = (1.0 / y) / (y * 0.16666666666666666) return tmp
function code(x, y) tmp = 0.0 if (x <= 6.8e-5) tmp = Float64(Float64(1.0 / y) / Float64(Float64(1.0 / y) + Float64(y * 0.16666666666666666))); else tmp = Float64(Float64(1.0 / y) / Float64(y * 0.16666666666666666)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 6.8e-5) tmp = (1.0 / y) / ((1.0 / y) + (y * 0.16666666666666666)); else tmp = (1.0 / y) / (y * 0.16666666666666666); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 6.8e-5], N[(N[(1.0 / y), $MachinePrecision] / N[(N[(1.0 / y), $MachinePrecision] + N[(y * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / y), $MachinePrecision] / N[(y * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 6.8 \cdot 10^{-5}:\\
\;\;\;\;\frac{\frac{1}{y}}{\frac{1}{y} + y \cdot 0.16666666666666666}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{y}}{y \cdot 0.16666666666666666}\\
\end{array}
\end{array}
(FPCore (x y) :precision binary64 (if (<= x 6.8e-5) 1.0 (/ (/ 1.0 y) (* y 0.16666666666666666))))
double code(double x, double y) {
double tmp;
if (x <= 6.8e-5) {
tmp = 1.0;
} 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 (x <= 6.8d-5) then
tmp = 1.0d0
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 (x <= 6.8e-5) {
tmp = 1.0;
} else {
tmp = (1.0 / y) / (y * 0.16666666666666666);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 6.8e-5: tmp = 1.0 else: tmp = (1.0 / y) / (y * 0.16666666666666666) return tmp
function code(x, y) tmp = 0.0 if (x <= 6.8e-5) tmp = 1.0; else tmp = Float64(Float64(1.0 / y) / Float64(y * 0.16666666666666666)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 6.8e-5) tmp = 1.0; else tmp = (1.0 / y) / (y * 0.16666666666666666); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 6.8e-5], 1.0, N[(N[(1.0 / y), $MachinePrecision] / N[(y * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 6.8 \cdot 10^{-5}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{y}}{y \cdot 0.16666666666666666}\\
\end{array}
\end{array}
(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}
(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 2024006
(FPCore (x y)
:name "Linear.Quaternion:$csinh from linear-1.19.1.3"
:precision binary64
:herbie-target
(/ (* (cosh x) (sin y)) y)
(* (cosh x) (/ (sin y) y)))