
(FPCore (x y) :precision binary64 (* (sin x) (/ (sinh y) y)))
double code(double x, double y) {
return sin(x) * (sinh(y) / y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sin(x) * (sinh(y) / y)
end function
public static double code(double x, double y) {
return Math.sin(x) * (Math.sinh(y) / y);
}
def code(x, y): return math.sin(x) * (math.sinh(y) / y)
function code(x, y) return Float64(sin(x) * Float64(sinh(y) / y)) end
function tmp = code(x, y) tmp = sin(x) * (sinh(y) / y); end
code[x_, y_] := N[(N[Sin[x], $MachinePrecision] * N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin x \cdot \frac{\sinh y}{y}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 4 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (* (sin x) (/ (sinh y) y)))
double code(double x, double y) {
return sin(x) * (sinh(y) / y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sin(x) * (sinh(y) / y)
end function
public static double code(double x, double y) {
return Math.sin(x) * (Math.sinh(y) / y);
}
def code(x, y): return math.sin(x) * (math.sinh(y) / y)
function code(x, y) return Float64(sin(x) * Float64(sinh(y) / y)) end
function tmp = code(x, y) tmp = sin(x) * (sinh(y) / y); end
code[x_, y_] := N[(N[Sin[x], $MachinePrecision] * N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin x \cdot \frac{\sinh y}{y}
\end{array}
(FPCore (x y) :precision binary64 (* (sin x) (/ (sinh y) y)))
double code(double x, double y) {
return sin(x) * (sinh(y) / y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sin(x) * (sinh(y) / y)
end function
public static double code(double x, double y) {
return Math.sin(x) * (Math.sinh(y) / y);
}
def code(x, y): return math.sin(x) * (math.sinh(y) / y)
function code(x, y) return Float64(sin(x) * Float64(sinh(y) / y)) end
function tmp = code(x, y) tmp = sin(x) * (sinh(y) / y); end
code[x_, y_] := N[(N[Sin[x], $MachinePrecision] * N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin x \cdot \frac{\sinh y}{y}
\end{array}
Initial program 100.0%
(FPCore (x y) :precision binary64 (if (<= y 78000.0) (sin x) (* x (/ (sinh y) y))))
double code(double x, double y) {
double tmp;
if (y <= 78000.0) {
tmp = sin(x);
} else {
tmp = x * (sinh(y) / y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 78000.0d0) then
tmp = sin(x)
else
tmp = x * (sinh(y) / y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 78000.0) {
tmp = Math.sin(x);
} else {
tmp = x * (Math.sinh(y) / y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 78000.0: tmp = math.sin(x) else: tmp = x * (math.sinh(y) / y) return tmp
function code(x, y) tmp = 0.0 if (y <= 78000.0) tmp = sin(x); else tmp = Float64(x * Float64(sinh(y) / y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 78000.0) tmp = sin(x); else tmp = x * (sinh(y) / y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 78000.0], N[Sin[x], $MachinePrecision], N[(x * N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 78000:\\
\;\;\;\;\sin x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{\sinh y}{y}\\
\end{array}
\end{array}
if y < 78000Initial program 100.0%
Taylor expanded in y around 0 64.1%
if 78000 < y Initial program 100.0%
Taylor expanded in x around 0 69.8%
*-commutative69.8%
associate-/l*69.8%
associate-*r*69.8%
*-commutative69.8%
associate-*r/69.8%
*-commutative69.8%
metadata-eval69.8%
associate-/l*69.8%
*-rgt-identity69.8%
rec-exp69.8%
sinh-def69.8%
Simplified69.8%
(FPCore (x y) :precision binary64 (sin x))
double code(double x, double y) {
return sin(x);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sin(x)
end function
public static double code(double x, double y) {
return Math.sin(x);
}
def code(x, y): return math.sin(x)
function code(x, y) return sin(x) end
function tmp = code(x, y) tmp = sin(x); end
code[x_, y_] := N[Sin[x], $MachinePrecision]
\begin{array}{l}
\\
\sin x
\end{array}
Initial program 100.0%
Taylor expanded in y around 0 49.0%
(FPCore (x y) :precision binary64 x)
double code(double x, double y) {
return x;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x
end function
public static double code(double x, double y) {
return x;
}
def code(x, y): return x
function code(x, y) return x end
function tmp = code(x, y) tmp = x; end
code[x_, y_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 100.0%
Taylor expanded in x around 0 39.3%
*-commutative39.3%
associate-/l*39.3%
associate-*r*39.3%
*-commutative39.3%
associate-*r/39.3%
*-commutative39.3%
metadata-eval39.3%
associate-/l*39.3%
*-rgt-identity39.3%
rec-exp39.3%
sinh-def60.7%
Simplified60.7%
Taylor expanded in y around 0 25.0%
herbie shell --seed 2024096
(FPCore (x y)
:name "Linear.Quaternion:$ccos from linear-1.19.1.3"
:precision binary64
(* (sin x) (/ (sinh y) y)))