
(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}
x_m = (fabs.f64 x) (FPCore (x_m y) :precision binary64 (* 0.5 (/ (* (sin y) (+ (exp x_m) (/ 1.0 (exp x_m)))) y)))
x_m = fabs(x);
double code(double x_m, double y) {
return 0.5 * ((sin(y) * (exp(x_m) + (1.0 / exp(x_m)))) / y);
}
x_m = abs(x)
real(8) function code(x_m, y)
real(8), intent (in) :: x_m
real(8), intent (in) :: y
code = 0.5d0 * ((sin(y) * (exp(x_m) + (1.0d0 / exp(x_m)))) / y)
end function
x_m = Math.abs(x);
public static double code(double x_m, double y) {
return 0.5 * ((Math.sin(y) * (Math.exp(x_m) + (1.0 / Math.exp(x_m)))) / y);
}
x_m = math.fabs(x) def code(x_m, y): return 0.5 * ((math.sin(y) * (math.exp(x_m) + (1.0 / math.exp(x_m)))) / y)
x_m = abs(x) function code(x_m, y) return Float64(0.5 * Float64(Float64(sin(y) * Float64(exp(x_m) + Float64(1.0 / exp(x_m)))) / y)) end
x_m = abs(x); function tmp = code(x_m, y) tmp = 0.5 * ((sin(y) * (exp(x_m) + (1.0 / exp(x_m)))) / y); end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_, y_] := N[(0.5 * N[(N[(N[Sin[y], $MachinePrecision] * N[(N[Exp[x$95$m], $MachinePrecision] + N[(1.0 / N[Exp[x$95$m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
0.5 \cdot \frac{\sin y \cdot \left(e^{x\_m} + \frac{1}{e^{x\_m}}\right)}{y}
\end{array}
Initial program 99.9%
Taylor expanded in x around inf 99.9%
Final simplification99.9%
x_m = (fabs.f64 x) (FPCore (x_m y) :precision binary64 (if (<= (cosh x_m) 1.000000001) (/ (sin y) y) (cosh x_m)))
x_m = fabs(x);
double code(double x_m, double y) {
double tmp;
if (cosh(x_m) <= 1.000000001) {
tmp = sin(y) / y;
} else {
tmp = cosh(x_m);
}
return tmp;
}
x_m = abs(x)
real(8) function code(x_m, y)
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8) :: tmp
if (cosh(x_m) <= 1.000000001d0) then
tmp = sin(y) / y
else
tmp = cosh(x_m)
end if
code = tmp
end function
x_m = Math.abs(x);
public static double code(double x_m, double y) {
double tmp;
if (Math.cosh(x_m) <= 1.000000001) {
tmp = Math.sin(y) / y;
} else {
tmp = Math.cosh(x_m);
}
return tmp;
}
x_m = math.fabs(x) def code(x_m, y): tmp = 0 if math.cosh(x_m) <= 1.000000001: tmp = math.sin(y) / y else: tmp = math.cosh(x_m) return tmp
x_m = abs(x) function code(x_m, y) tmp = 0.0 if (cosh(x_m) <= 1.000000001) tmp = Float64(sin(y) / y); else tmp = cosh(x_m); end return tmp end
x_m = abs(x); function tmp_2 = code(x_m, y) tmp = 0.0; if (cosh(x_m) <= 1.000000001) tmp = sin(y) / y; else tmp = cosh(x_m); end tmp_2 = tmp; end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_, y_] := If[LessEqual[N[Cosh[x$95$m], $MachinePrecision], 1.000000001], N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision], N[Cosh[x$95$m], $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;\cosh x\_m \leq 1.000000001:\\
\;\;\;\;\frac{\sin y}{y}\\
\mathbf{else}:\\
\;\;\;\;\cosh x\_m\\
\end{array}
\end{array}
if (cosh.f64 x) < 1.0000000010000001Initial program 99.8%
Taylor expanded in x around 0 99.3%
if 1.0000000010000001 < (cosh.f64 x) Initial program 100.0%
Taylor expanded in y around 0 76.6%
Final simplification89.1%
x_m = (fabs.f64 x) (FPCore (x_m y) :precision binary64 (* (cosh x_m) (/ (sin y) y)))
x_m = fabs(x);
double code(double x_m, double y) {
return cosh(x_m) * (sin(y) / y);
}
x_m = abs(x)
real(8) function code(x_m, y)
real(8), intent (in) :: x_m
real(8), intent (in) :: y
code = cosh(x_m) * (sin(y) / y)
end function
x_m = Math.abs(x);
public static double code(double x_m, double y) {
return Math.cosh(x_m) * (Math.sin(y) / y);
}
x_m = math.fabs(x) def code(x_m, y): return math.cosh(x_m) * (math.sin(y) / y)
x_m = abs(x) function code(x_m, y) return Float64(cosh(x_m) * Float64(sin(y) / y)) end
x_m = abs(x); function tmp = code(x_m, y) tmp = cosh(x_m) * (sin(y) / y); end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_, y_] := N[(N[Cosh[x$95$m], $MachinePrecision] * N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
\cosh x\_m \cdot \frac{\sin y}{y}
\end{array}
Initial program 99.9%
Final simplification99.9%
x_m = (fabs.f64 x) (FPCore (x_m y) :precision binary64 (/ (sin y) (/ y (cosh x_m))))
x_m = fabs(x);
double code(double x_m, double y) {
return sin(y) / (y / cosh(x_m));
}
x_m = abs(x)
real(8) function code(x_m, y)
real(8), intent (in) :: x_m
real(8), intent (in) :: y
code = sin(y) / (y / cosh(x_m))
end function
x_m = Math.abs(x);
public static double code(double x_m, double y) {
return Math.sin(y) / (y / Math.cosh(x_m));
}
x_m = math.fabs(x) def code(x_m, y): return math.sin(y) / (y / math.cosh(x_m))
x_m = abs(x) function code(x_m, y) return Float64(sin(y) / Float64(y / cosh(x_m))) end
x_m = abs(x); function tmp = code(x_m, y) tmp = sin(y) / (y / cosh(x_m)); end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_, y_] := N[(N[Sin[y], $MachinePrecision] / N[(y / N[Cosh[x$95$m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
\frac{\sin y}{\frac{y}{\cosh x\_m}}
\end{array}
Initial program 99.9%
*-commutative99.9%
associate-*l/99.9%
associate-/l*99.8%
Simplified99.8%
add-sqr-sqrt48.6%
pow248.6%
Applied egg-rr48.6%
unpow248.6%
add-sqr-sqrt99.8%
clear-num99.8%
un-div-inv99.9%
Applied egg-rr99.9%
Final simplification99.9%
x_m = (fabs.f64 x) (FPCore (x_m y) :precision binary64 (cosh x_m))
x_m = fabs(x);
double code(double x_m, double y) {
return cosh(x_m);
}
x_m = abs(x)
real(8) function code(x_m, y)
real(8), intent (in) :: x_m
real(8), intent (in) :: y
code = cosh(x_m)
end function
x_m = Math.abs(x);
public static double code(double x_m, double y) {
return Math.cosh(x_m);
}
x_m = math.fabs(x) def code(x_m, y): return math.cosh(x_m)
x_m = abs(x) function code(x_m, y) return cosh(x_m) end
x_m = abs(x); function tmp = code(x_m, y) tmp = cosh(x_m); end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_, y_] := N[Cosh[x$95$m], $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
\cosh x\_m
\end{array}
Initial program 99.9%
Taylor expanded in y around 0 62.1%
Final simplification62.1%
x_m = (fabs.f64 x) (FPCore (x_m y) :precision binary64 1.0)
x_m = fabs(x);
double code(double x_m, double y) {
return 1.0;
}
x_m = abs(x)
real(8) function code(x_m, y)
real(8), intent (in) :: x_m
real(8), intent (in) :: y
code = 1.0d0
end function
x_m = Math.abs(x);
public static double code(double x_m, double y) {
return 1.0;
}
x_m = math.fabs(x) def code(x_m, y): return 1.0
x_m = abs(x) function code(x_m, y) return 1.0 end
x_m = abs(x); function tmp = code(x_m, y) tmp = 1.0; end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_, y_] := 1.0
\begin{array}{l}
x_m = \left|x\right|
\\
1
\end{array}
Initial program 99.9%
*-commutative99.9%
associate-*l/99.9%
associate-/l*99.8%
Simplified99.8%
add-sqr-sqrt48.6%
pow248.6%
Applied egg-rr48.6%
Taylor expanded in x around 0 25.6%
Taylor expanded in y around 0 29.4%
Final simplification29.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 2024078
(FPCore (x y)
:name "Linear.Quaternion:$csinh from linear-1.19.1.3"
:precision binary64
:alt
(/ (* (cosh x) (sin y)) y)
(* (cosh x) (/ (sin y) y)))