
(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 4 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.9%
Final simplification99.9%
(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%
Taylor expanded in y around 0 63.8%
Final simplification63.8%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ 1.0 (* (* y y) 0.16666666666666666))))
(if (<= y 2.6e+142)
(+ (/ 1.0 t_0) (* 0.5 (/ (* x x) t_0)))
(+ 1.0 (* (* y y) -0.16666666666666666)))))
double code(double x, double y) {
double t_0 = 1.0 + ((y * y) * 0.16666666666666666);
double tmp;
if (y <= 2.6e+142) {
tmp = (1.0 / t_0) + (0.5 * ((x * x) / t_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) :: t_0
real(8) :: tmp
t_0 = 1.0d0 + ((y * y) * 0.16666666666666666d0)
if (y <= 2.6d+142) then
tmp = (1.0d0 / t_0) + (0.5d0 * ((x * x) / t_0))
else
tmp = 1.0d0 + ((y * y) * (-0.16666666666666666d0))
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = 1.0 + ((y * y) * 0.16666666666666666);
double tmp;
if (y <= 2.6e+142) {
tmp = (1.0 / t_0) + (0.5 * ((x * x) / t_0));
} else {
tmp = 1.0 + ((y * y) * -0.16666666666666666);
}
return tmp;
}
def code(x, y): t_0 = 1.0 + ((y * y) * 0.16666666666666666) tmp = 0 if y <= 2.6e+142: tmp = (1.0 / t_0) + (0.5 * ((x * x) / t_0)) else: tmp = 1.0 + ((y * y) * -0.16666666666666666) return tmp
function code(x, y) t_0 = Float64(1.0 + Float64(Float64(y * y) * 0.16666666666666666)) tmp = 0.0 if (y <= 2.6e+142) tmp = Float64(Float64(1.0 / t_0) + Float64(0.5 * Float64(Float64(x * x) / t_0))); else tmp = Float64(1.0 + Float64(Float64(y * y) * -0.16666666666666666)); end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 + ((y * y) * 0.16666666666666666); tmp = 0.0; if (y <= 2.6e+142) tmp = (1.0 / t_0) + (0.5 * ((x * x) / t_0)); else tmp = 1.0 + ((y * y) * -0.16666666666666666); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(1.0 + N[(N[(y * y), $MachinePrecision] * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, 2.6e+142], N[(N[(1.0 / t$95$0), $MachinePrecision] + N[(0.5 * N[(N[(x * x), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[(y * y), $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \left(y \cdot y\right) \cdot 0.16666666666666666\\
\mathbf{if}\;y \leq 2.6 \cdot 10^{+142}:\\
\;\;\;\;\frac{1}{t_0} + 0.5 \cdot \frac{x \cdot x}{t_0}\\
\mathbf{else}:\\
\;\;\;\;1 + \left(y \cdot y\right) \cdot -0.16666666666666666\\
\end{array}
\end{array}
if y < 2.60000000000000021e142Initial program 99.9%
clear-num99.9%
inv-pow99.9%
Applied egg-rr99.9%
unpow-199.9%
Applied egg-rr99.9%
Taylor expanded in y around 0 67.4%
unpow267.4%
Simplified67.4%
Taylor expanded in x around 0 49.4%
*-commutative49.4%
unpow249.4%
unpow249.4%
*-commutative49.4%
unpow249.4%
Simplified49.4%
if 2.60000000000000021e142 < y Initial program 99.8%
clear-num99.7%
inv-pow99.7%
Applied egg-rr99.7%
Taylor expanded in y around 0 27.1%
*-commutative27.1%
unpow227.1%
Simplified27.1%
Taylor expanded in y around 0 27.1%
*-commutative27.1%
unpow227.1%
associate-*l*27.1%
*-commutative27.1%
Simplified27.1%
Taylor expanded in x around 0 27.1%
unpow227.1%
Simplified27.1%
Final simplification46.1%
(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%
clear-num99.9%
inv-pow99.9%
Applied egg-rr99.9%
Taylor expanded in y around 0 62.3%
*-commutative62.3%
unpow262.3%
Simplified62.3%
Taylor expanded in y around 0 62.3%
*-commutative62.3%
unpow262.3%
associate-*l*62.3%
*-commutative62.3%
Simplified62.3%
Taylor expanded in x around 0 32.6%
unpow232.6%
Simplified32.6%
Final simplification32.6%
(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 2023240
(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)))