
(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 7 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}
(FPCore (x y)
:precision binary64
(if (<= y 3.2e+36)
(sin x)
(if (or (<= y 2.55e+168) (not (<= y 5.4e+225)))
(log (exp x))
(+ x (* -0.16666666666666666 (pow x 3.0))))))
double code(double x, double y) {
double tmp;
if (y <= 3.2e+36) {
tmp = sin(x);
} else if ((y <= 2.55e+168) || !(y <= 5.4e+225)) {
tmp = log(exp(x));
} else {
tmp = x + (-0.16666666666666666 * pow(x, 3.0));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 3.2d+36) then
tmp = sin(x)
else if ((y <= 2.55d+168) .or. (.not. (y <= 5.4d+225))) then
tmp = log(exp(x))
else
tmp = x + ((-0.16666666666666666d0) * (x ** 3.0d0))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 3.2e+36) {
tmp = Math.sin(x);
} else if ((y <= 2.55e+168) || !(y <= 5.4e+225)) {
tmp = Math.log(Math.exp(x));
} else {
tmp = x + (-0.16666666666666666 * Math.pow(x, 3.0));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 3.2e+36: tmp = math.sin(x) elif (y <= 2.55e+168) or not (y <= 5.4e+225): tmp = math.log(math.exp(x)) else: tmp = x + (-0.16666666666666666 * math.pow(x, 3.0)) return tmp
function code(x, y) tmp = 0.0 if (y <= 3.2e+36) tmp = sin(x); elseif ((y <= 2.55e+168) || !(y <= 5.4e+225)) tmp = log(exp(x)); else tmp = Float64(x + Float64(-0.16666666666666666 * (x ^ 3.0))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 3.2e+36) tmp = sin(x); elseif ((y <= 2.55e+168) || ~((y <= 5.4e+225))) tmp = log(exp(x)); else tmp = x + (-0.16666666666666666 * (x ^ 3.0)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 3.2e+36], N[Sin[x], $MachinePrecision], If[Or[LessEqual[y, 2.55e+168], N[Not[LessEqual[y, 5.4e+225]], $MachinePrecision]], N[Log[N[Exp[x], $MachinePrecision]], $MachinePrecision], N[(x + N[(-0.16666666666666666 * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.2 \cdot 10^{+36}:\\
\;\;\;\;\sin x\\
\mathbf{elif}\;y \leq 2.55 \cdot 10^{+168} \lor \neg \left(y \leq 5.4 \cdot 10^{+225}\right):\\
\;\;\;\;\log \left(e^{x}\right)\\
\mathbf{else}:\\
\;\;\;\;x + -0.16666666666666666 \cdot {x}^{3}\\
\end{array}
\end{array}
(FPCore (x y)
:precision binary64
(if (<= y 440.0)
(sin x)
(if (<= y 7.4e+225)
(+ x (* -0.16666666666666666 (pow x 3.0)))
(/ (* x y) y))))
double code(double x, double y) {
double tmp;
if (y <= 440.0) {
tmp = sin(x);
} else if (y <= 7.4e+225) {
tmp = x + (-0.16666666666666666 * pow(x, 3.0));
} else {
tmp = (x * 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 <= 440.0d0) then
tmp = sin(x)
else if (y <= 7.4d+225) then
tmp = x + ((-0.16666666666666666d0) * (x ** 3.0d0))
else
tmp = (x * y) / y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 440.0) {
tmp = Math.sin(x);
} else if (y <= 7.4e+225) {
tmp = x + (-0.16666666666666666 * Math.pow(x, 3.0));
} else {
tmp = (x * y) / y;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 440.0: tmp = math.sin(x) elif y <= 7.4e+225: tmp = x + (-0.16666666666666666 * math.pow(x, 3.0)) else: tmp = (x * y) / y return tmp
function code(x, y) tmp = 0.0 if (y <= 440.0) tmp = sin(x); elseif (y <= 7.4e+225) tmp = Float64(x + Float64(-0.16666666666666666 * (x ^ 3.0))); else tmp = Float64(Float64(x * y) / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 440.0) tmp = sin(x); elseif (y <= 7.4e+225) tmp = x + (-0.16666666666666666 * (x ^ 3.0)); else tmp = (x * y) / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 440.0], N[Sin[x], $MachinePrecision], If[LessEqual[y, 7.4e+225], N[(x + N[(-0.16666666666666666 * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * y), $MachinePrecision] / y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 440:\\
\;\;\;\;\sin x\\
\mathbf{elif}\;y \leq 7.4 \cdot 10^{+225}:\\
\;\;\;\;x + -0.16666666666666666 \cdot {x}^{3}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{y}\\
\end{array}
\end{array}
(FPCore (x y) :precision binary64 (if (<= y 510000.0) (sin x) (if (<= y 2.25e+222) (* -0.16666666666666666 (pow x 3.0)) (/ (* x y) y))))
double code(double x, double y) {
double tmp;
if (y <= 510000.0) {
tmp = sin(x);
} else if (y <= 2.25e+222) {
tmp = -0.16666666666666666 * pow(x, 3.0);
} else {
tmp = (x * 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 <= 510000.0d0) then
tmp = sin(x)
else if (y <= 2.25d+222) then
tmp = (-0.16666666666666666d0) * (x ** 3.0d0)
else
tmp = (x * y) / y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 510000.0) {
tmp = Math.sin(x);
} else if (y <= 2.25e+222) {
tmp = -0.16666666666666666 * Math.pow(x, 3.0);
} else {
tmp = (x * y) / y;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 510000.0: tmp = math.sin(x) elif y <= 2.25e+222: tmp = -0.16666666666666666 * math.pow(x, 3.0) else: tmp = (x * y) / y return tmp
function code(x, y) tmp = 0.0 if (y <= 510000.0) tmp = sin(x); elseif (y <= 2.25e+222) tmp = Float64(-0.16666666666666666 * (x ^ 3.0)); else tmp = Float64(Float64(x * y) / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 510000.0) tmp = sin(x); elseif (y <= 2.25e+222) tmp = -0.16666666666666666 * (x ^ 3.0); else tmp = (x * y) / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 510000.0], N[Sin[x], $MachinePrecision], If[LessEqual[y, 2.25e+222], N[(-0.16666666666666666 * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision], N[(N[(x * y), $MachinePrecision] / y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 510000:\\
\;\;\;\;\sin x\\
\mathbf{elif}\;y \leq 2.25 \cdot 10^{+222}:\\
\;\;\;\;-0.16666666666666666 \cdot {x}^{3}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{y}\\
\end{array}
\end{array}
(FPCore (x y) :precision binary64 (if (<= y 8e+27) (sin x) (/ (* x y) y)))
double code(double x, double y) {
double tmp;
if (y <= 8e+27) {
tmp = sin(x);
} else {
tmp = (x * 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 <= 8d+27) then
tmp = sin(x)
else
tmp = (x * y) / y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 8e+27) {
tmp = Math.sin(x);
} else {
tmp = (x * y) / y;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 8e+27: tmp = math.sin(x) else: tmp = (x * y) / y return tmp
function code(x, y) tmp = 0.0 if (y <= 8e+27) tmp = sin(x); else tmp = Float64(Float64(x * y) / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 8e+27) tmp = sin(x); else tmp = (x * y) / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 8e+27], N[Sin[x], $MachinePrecision], N[(N[(x * y), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 8 \cdot 10^{+27}:\\
\;\;\;\;\sin x\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{y}\\
\end{array}
\end{array}
(FPCore (x y) :precision binary64 (if (<= x 9.6e+61) x (/ (* x y) y)))
double code(double x, double y) {
double tmp;
if (x <= 9.6e+61) {
tmp = x;
} else {
tmp = (x * y) / y;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= 9.6d+61) then
tmp = x
else
tmp = (x * y) / y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= 9.6e+61) {
tmp = x;
} else {
tmp = (x * y) / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 9.6e+61: tmp = x else: tmp = (x * y) / y return tmp
function code(x, y) tmp = 0.0 if (x <= 9.6e+61) tmp = x; else tmp = Float64(Float64(x * y) / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 9.6e+61) tmp = x; else tmp = (x * y) / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 9.6e+61], x, N[(N[(x * y), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 9.6 \cdot 10^{+61}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{y}\\
\end{array}
\end{array}
(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}
herbie shell --seed 2023347
(FPCore (x y)
:name "Linear.Quaternion:$ccos from linear-1.19.1.3"
:precision binary64
(* (sin x) (/ (sinh y) y)))