
(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 6 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 (let* ((t_0 (/ (sinh y) y))) (if (<= t_0 1.0) (sin x) (* x t_0))))
double code(double x, double y) {
double t_0 = sinh(y) / y;
double tmp;
if (t_0 <= 1.0) {
tmp = sin(x);
} else {
tmp = x * t_0;
}
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 = sinh(y) / y
if (t_0 <= 1.0d0) then
tmp = sin(x)
else
tmp = x * t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = Math.sinh(y) / y;
double tmp;
if (t_0 <= 1.0) {
tmp = Math.sin(x);
} else {
tmp = x * t_0;
}
return tmp;
}
def code(x, y): t_0 = math.sinh(y) / y tmp = 0 if t_0 <= 1.0: tmp = math.sin(x) else: tmp = x * t_0 return tmp
function code(x, y) t_0 = Float64(sinh(y) / y) tmp = 0.0 if (t_0 <= 1.0) tmp = sin(x); else tmp = Float64(x * t_0); end return tmp end
function tmp_2 = code(x, y) t_0 = sinh(y) / y; tmp = 0.0; if (t_0 <= 1.0) tmp = sin(x); else tmp = x * t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]}, If[LessEqual[t$95$0, 1.0], N[Sin[x], $MachinePrecision], N[(x * t$95$0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sinh y}{y}\\
\mathbf{if}\;t\_0 \leq 1:\\
\;\;\;\;\sin x\\
\mathbf{else}:\\
\;\;\;\;x \cdot t\_0\\
\end{array}
\end{array}
if (/.f64 (sinh.f64 y) y) < 1Initial program 100.0%
Taylor expanded in y around 0 100.0%
if 1 < (/.f64 (sinh.f64 y) y) Initial program 100.0%
Taylor expanded in x around 0 71.4%
(FPCore (x y) :precision binary64 (if (<= y 540000000000.0) (sin x) (* x (+ 1.0 (* (* x x) -0.16666666666666666)))))
double code(double x, double y) {
double tmp;
if (y <= 540000000000.0) {
tmp = sin(x);
} else {
tmp = x * (1.0 + ((x * x) * -0.16666666666666666));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 540000000000.0d0) then
tmp = sin(x)
else
tmp = x * (1.0d0 + ((x * x) * (-0.16666666666666666d0)))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 540000000000.0) {
tmp = Math.sin(x);
} else {
tmp = x * (1.0 + ((x * x) * -0.16666666666666666));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 540000000000.0: tmp = math.sin(x) else: tmp = x * (1.0 + ((x * x) * -0.16666666666666666)) return tmp
function code(x, y) tmp = 0.0 if (y <= 540000000000.0) tmp = sin(x); else tmp = Float64(x * Float64(1.0 + Float64(Float64(x * x) * -0.16666666666666666))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 540000000000.0) tmp = sin(x); else tmp = x * (1.0 + ((x * x) * -0.16666666666666666)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 540000000000.0], N[Sin[x], $MachinePrecision], N[(x * N[(1.0 + N[(N[(x * x), $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 540000000000:\\
\;\;\;\;\sin x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 + \left(x \cdot x\right) \cdot -0.16666666666666666\right)\\
\end{array}
\end{array}
if y < 5.4e11Initial program 100.0%
Taylor expanded in y around 0 60.1%
if 5.4e11 < y Initial program 100.0%
Taylor expanded in y around 0 2.8%
Taylor expanded in x around 0 23.5%
*-commutative23.5%
Simplified23.5%
unpow223.5%
Applied egg-rr23.5%
(FPCore (x y) :precision binary64 (if (<= x 9.5e+66) x (* (/ 1.0 y) (* x y))))
double code(double x, double y) {
double tmp;
if (x <= 9.5e+66) {
tmp = x;
} else {
tmp = (1.0 / y) * (x * 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.5d+66) then
tmp = x
else
tmp = (1.0d0 / y) * (x * y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= 9.5e+66) {
tmp = x;
} else {
tmp = (1.0 / y) * (x * y);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 9.5e+66: tmp = x else: tmp = (1.0 / y) * (x * y) return tmp
function code(x, y) tmp = 0.0 if (x <= 9.5e+66) tmp = x; else tmp = Float64(Float64(1.0 / y) * Float64(x * y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 9.5e+66) tmp = x; else tmp = (1.0 / y) * (x * y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 9.5e+66], x, N[(N[(1.0 / y), $MachinePrecision] * N[(x * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 9.5 \cdot 10^{+66}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{y} \cdot \left(x \cdot y\right)\\
\end{array}
\end{array}
if x < 9.50000000000000051e66Initial program 100.0%
Taylor expanded in x around 0 72.2%
Taylor expanded in y around 0 31.2%
if 9.50000000000000051e66 < x Initial program 100.0%
associate-*r/99.9%
clear-num99.8%
Applied egg-rr99.8%
Taylor expanded in x around 0 24.4%
*-commutative24.4%
associate-/r*23.5%
associate-/r/23.5%
rec-exp23.5%
sinh-def23.8%
associate-/r*23.9%
Simplified23.9%
Taylor expanded in y around 0 14.0%
associate-/r/14.0%
Applied egg-rr14.0%
(FPCore (x y) :precision binary64 (* x (+ 1.0 (* (* x x) -0.16666666666666666))))
double code(double x, double y) {
return x * (1.0 + ((x * x) * -0.16666666666666666));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x * (1.0d0 + ((x * x) * (-0.16666666666666666d0)))
end function
public static double code(double x, double y) {
return x * (1.0 + ((x * x) * -0.16666666666666666));
}
def code(x, y): return x * (1.0 + ((x * x) * -0.16666666666666666))
function code(x, y) return Float64(x * Float64(1.0 + Float64(Float64(x * x) * -0.16666666666666666))) end
function tmp = code(x, y) tmp = x * (1.0 + ((x * x) * -0.16666666666666666)); end
code[x_, y_] := N[(x * N[(1.0 + N[(N[(x * x), $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(1 + \left(x \cdot x\right) \cdot -0.16666666666666666\right)
\end{array}
Initial program 100.0%
Taylor expanded in y around 0 46.9%
Taylor expanded in x around 0 35.7%
*-commutative35.7%
Simplified35.7%
unpow235.7%
Applied egg-rr35.7%
(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 63.2%
Taylor expanded in y around 0 25.8%
herbie shell --seed 2024172
(FPCore (x y)
:name "Linear.Quaternion:$ccos from linear-1.19.1.3"
:precision binary64
(* (sin x) (/ (sinh y) y)))