
(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 6 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 (/ (sin y) (/ y (cosh x))))
double code(double x, double y) {
return sin(y) / (y / cosh(x));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sin(y) / (y / cosh(x))
end function
public static double code(double x, double y) {
return Math.sin(y) / (y / Math.cosh(x));
}
def code(x, y): return math.sin(y) / (y / math.cosh(x))
function code(x, y) return Float64(sin(y) / Float64(y / cosh(x))) end
function tmp = code(x, y) tmp = sin(y) / (y / cosh(x)); end
code[x_, y_] := N[(N[Sin[y], $MachinePrecision] / N[(y / N[Cosh[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin y}{\frac{y}{\cosh x}}
\end{array}
Initial program 99.9%
*-commutative99.9%
associate-/r/99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y) :precision binary64 (if (<= (cosh x) 1.0000000002) (/ (sin y) y) (/ (* y (cosh x)) y)))
double code(double x, double y) {
double tmp;
if (cosh(x) <= 1.0000000002) {
tmp = sin(y) / y;
} else {
tmp = (y * cosh(x)) / y;
}
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.0000000002d0) then
tmp = sin(y) / y
else
tmp = (y * cosh(x)) / y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (Math.cosh(x) <= 1.0000000002) {
tmp = Math.sin(y) / y;
} else {
tmp = (y * Math.cosh(x)) / y;
}
return tmp;
}
def code(x, y): tmp = 0 if math.cosh(x) <= 1.0000000002: tmp = math.sin(y) / y else: tmp = (y * math.cosh(x)) / y return tmp
function code(x, y) tmp = 0.0 if (cosh(x) <= 1.0000000002) tmp = Float64(sin(y) / y); else tmp = Float64(Float64(y * cosh(x)) / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (cosh(x) <= 1.0000000002) tmp = sin(y) / y; else tmp = (y * cosh(x)) / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Cosh[x], $MachinePrecision], 1.0000000002], N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision], N[(N[(y * N[Cosh[x], $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cosh x \leq 1.0000000002:\\
\;\;\;\;\frac{\sin y}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{y \cdot \cosh x}{y}\\
\end{array}
\end{array}
if (cosh.f64 x) < 1.0000000002Initial program 99.9%
*-commutative99.9%
associate-/r/99.9%
Simplified99.9%
Taylor expanded in x around 0 99.8%
if 1.0000000002 < (cosh.f64 x) Initial program 100.0%
*-commutative100.0%
associate-/r/100.0%
Simplified100.0%
clear-num100.0%
inv-pow100.0%
associate-/l/100.0%
Applied egg-rr100.0%
unpow-1100.0%
clear-num100.0%
Applied egg-rr100.0%
Taylor expanded in y around 0 70.5%
Final simplification85.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(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 (if (<= x 7500000.0) (/ (sin y) y) (* (pow y 2.0) -0.16666666666666666)))
double code(double x, double y) {
double tmp;
if (x <= 7500000.0) {
tmp = sin(y) / y;
} else {
tmp = pow(y, 2.0) * -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 <= 7500000.0d0) then
tmp = sin(y) / y
else
tmp = (y ** 2.0d0) * (-0.16666666666666666d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= 7500000.0) {
tmp = Math.sin(y) / y;
} else {
tmp = Math.pow(y, 2.0) * -0.16666666666666666;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 7500000.0: tmp = math.sin(y) / y else: tmp = math.pow(y, 2.0) * -0.16666666666666666 return tmp
function code(x, y) tmp = 0.0 if (x <= 7500000.0) tmp = Float64(sin(y) / y); else tmp = Float64((y ^ 2.0) * -0.16666666666666666); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 7500000.0) tmp = sin(y) / y; else tmp = (y ^ 2.0) * -0.16666666666666666; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 7500000.0], N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision], N[(N[Power[y, 2.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 7500000:\\
\;\;\;\;\frac{\sin y}{y}\\
\mathbf{else}:\\
\;\;\;\;{y}^{2} \cdot -0.16666666666666666\\
\end{array}
\end{array}
if x < 7.5e6Initial program 99.9%
*-commutative99.9%
associate-/r/99.9%
Simplified99.9%
Taylor expanded in x around 0 70.8%
if 7.5e6 < x Initial program 100.0%
*-commutative100.0%
associate-/r/100.0%
Simplified100.0%
Taylor expanded in x around 0 2.8%
clear-num2.8%
associate-/r/2.8%
Applied egg-rr2.8%
Taylor expanded in y around 0 22.5%
Taylor expanded in y around inf 13.0%
*-commutative13.0%
Simplified13.0%
Final simplification56.4%
(FPCore (x y) :precision binary64 (/ (sin y) y))
double code(double x, double y) {
return sin(y) / y;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sin(y) / y
end function
public static double code(double x, double y) {
return Math.sin(y) / y;
}
def code(x, y): return math.sin(y) / y
function code(x, y) return Float64(sin(y) / y) end
function tmp = code(x, y) tmp = sin(y) / y; end
code[x_, y_] := N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin y}{y}
\end{array}
Initial program 99.9%
*-commutative99.9%
associate-/r/99.9%
Simplified99.9%
Taylor expanded in x around 0 53.8%
Final simplification53.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%
*-commutative99.9%
associate-/r/99.9%
Simplified99.9%
Taylor expanded in x around 0 53.8%
Taylor expanded in y around 0 31.4%
Final simplification31.4%
(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 2023308
(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)))