
(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
(if (<= y 600.0)
(sin x)
(if (<= y 1.05e+80)
(/ (+ x (* -0.16666666666666666 (pow x 3.0))) y)
(* 0.16666666666666666 (* x (pow y 2.0))))))
double code(double x, double y) {
double tmp;
if (y <= 600.0) {
tmp = sin(x);
} else if (y <= 1.05e+80) {
tmp = (x + (-0.16666666666666666 * pow(x, 3.0))) / y;
} else {
tmp = 0.16666666666666666 * (x * pow(y, 2.0));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 600.0d0) then
tmp = sin(x)
else if (y <= 1.05d+80) then
tmp = (x + ((-0.16666666666666666d0) * (x ** 3.0d0))) / y
else
tmp = 0.16666666666666666d0 * (x * (y ** 2.0d0))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 600.0) {
tmp = Math.sin(x);
} else if (y <= 1.05e+80) {
tmp = (x + (-0.16666666666666666 * Math.pow(x, 3.0))) / y;
} else {
tmp = 0.16666666666666666 * (x * Math.pow(y, 2.0));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 600.0: tmp = math.sin(x) elif y <= 1.05e+80: tmp = (x + (-0.16666666666666666 * math.pow(x, 3.0))) / y else: tmp = 0.16666666666666666 * (x * math.pow(y, 2.0)) return tmp
function code(x, y) tmp = 0.0 if (y <= 600.0) tmp = sin(x); elseif (y <= 1.05e+80) tmp = Float64(Float64(x + Float64(-0.16666666666666666 * (x ^ 3.0))) / y); else tmp = Float64(0.16666666666666666 * Float64(x * (y ^ 2.0))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 600.0) tmp = sin(x); elseif (y <= 1.05e+80) tmp = (x + (-0.16666666666666666 * (x ^ 3.0))) / y; else tmp = 0.16666666666666666 * (x * (y ^ 2.0)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 600.0], N[Sin[x], $MachinePrecision], If[LessEqual[y, 1.05e+80], N[(N[(x + N[(-0.16666666666666666 * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision], N[(0.16666666666666666 * N[(x * N[Power[y, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 600:\\
\;\;\;\;\sin x\\
\mathbf{elif}\;y \leq 1.05 \cdot 10^{+80}:\\
\;\;\;\;\frac{x + -0.16666666666666666 \cdot {x}^{3}}{y}\\
\mathbf{else}:\\
\;\;\;\;0.16666666666666666 \cdot \left(x \cdot {y}^{2}\right)\\
\end{array}
\end{array}
if y < 600Initial program 100.0%
Taylor expanded in y around 0 64.4%
if 600 < y < 1.05000000000000001e80Initial program 100.0%
Taylor expanded in y around inf 100.0%
rec-exp100.0%
Simplified100.0%
Applied egg-rr2.5%
Taylor expanded in x around 0 33.2%
distribute-rgt-in33.2%
associate-*l*33.2%
associate-*l/33.2%
unpow233.2%
unpow333.2%
associate-*l/33.2%
*-lft-identity33.2%
Simplified33.2%
Taylor expanded in y around 0 33.2%
if 1.05000000000000001e80 < y Initial program 100.0%
Taylor expanded in y around 0 70.3%
Taylor expanded in x around 0 55.2%
*-commutative55.2%
*-commutative55.2%
associate-*l*55.2%
Simplified55.2%
+-commutative55.2%
*-commutative55.2%
unpow255.2%
associate-*r*32.0%
fma-define32.0%
Applied egg-rr32.0%
Taylor expanded in x around inf 55.2%
(FPCore (x y)
:precision binary64
(if (<= y 400000000000.0)
(sin x)
(if (<= y 1.6e+82)
(* -0.16666666666666666 (/ (pow x 3.0) y))
(* 0.16666666666666666 (* x (pow y 2.0))))))
double code(double x, double y) {
double tmp;
if (y <= 400000000000.0) {
tmp = sin(x);
} else if (y <= 1.6e+82) {
tmp = -0.16666666666666666 * (pow(x, 3.0) / y);
} else {
tmp = 0.16666666666666666 * (x * pow(y, 2.0));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 400000000000.0d0) then
tmp = sin(x)
else if (y <= 1.6d+82) then
tmp = (-0.16666666666666666d0) * ((x ** 3.0d0) / y)
else
tmp = 0.16666666666666666d0 * (x * (y ** 2.0d0))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 400000000000.0) {
tmp = Math.sin(x);
} else if (y <= 1.6e+82) {
tmp = -0.16666666666666666 * (Math.pow(x, 3.0) / y);
} else {
tmp = 0.16666666666666666 * (x * Math.pow(y, 2.0));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 400000000000.0: tmp = math.sin(x) elif y <= 1.6e+82: tmp = -0.16666666666666666 * (math.pow(x, 3.0) / y) else: tmp = 0.16666666666666666 * (x * math.pow(y, 2.0)) return tmp
function code(x, y) tmp = 0.0 if (y <= 400000000000.0) tmp = sin(x); elseif (y <= 1.6e+82) tmp = Float64(-0.16666666666666666 * Float64((x ^ 3.0) / y)); else tmp = Float64(0.16666666666666666 * Float64(x * (y ^ 2.0))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 400000000000.0) tmp = sin(x); elseif (y <= 1.6e+82) tmp = -0.16666666666666666 * ((x ^ 3.0) / y); else tmp = 0.16666666666666666 * (x * (y ^ 2.0)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 400000000000.0], N[Sin[x], $MachinePrecision], If[LessEqual[y, 1.6e+82], N[(-0.16666666666666666 * N[(N[Power[x, 3.0], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(0.16666666666666666 * N[(x * N[Power[y, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 400000000000:\\
\;\;\;\;\sin x\\
\mathbf{elif}\;y \leq 1.6 \cdot 10^{+82}:\\
\;\;\;\;-0.16666666666666666 \cdot \frac{{x}^{3}}{y}\\
\mathbf{else}:\\
\;\;\;\;0.16666666666666666 \cdot \left(x \cdot {y}^{2}\right)\\
\end{array}
\end{array}
if y < 4e11Initial program 100.0%
Taylor expanded in y around 0 64.1%
if 4e11 < y < 1.59999999999999987e82Initial program 100.0%
Taylor expanded in y around inf 100.0%
rec-exp100.0%
Simplified100.0%
Applied egg-rr2.5%
Taylor expanded in x around 0 35.1%
distribute-rgt-in35.1%
associate-*l*35.1%
associate-*l/35.1%
unpow235.1%
unpow335.1%
associate-*l/35.1%
*-lft-identity35.1%
Simplified35.1%
Taylor expanded in x around inf 35.0%
if 1.59999999999999987e82 < y Initial program 100.0%
Taylor expanded in y around 0 70.3%
Taylor expanded in x around 0 55.2%
*-commutative55.2%
*-commutative55.2%
associate-*l*55.2%
Simplified55.2%
+-commutative55.2%
*-commutative55.2%
unpow255.2%
associate-*r*32.0%
fma-define32.0%
Applied egg-rr32.0%
Taylor expanded in x around inf 55.2%
(FPCore (x y) :precision binary64 (if (<= y 210000000000.0) (sin x) (* -0.16666666666666666 (/ (pow x 3.0) y))))
double code(double x, double y) {
double tmp;
if (y <= 210000000000.0) {
tmp = sin(x);
} else {
tmp = -0.16666666666666666 * (pow(x, 3.0) / y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 210000000000.0d0) then
tmp = sin(x)
else
tmp = (-0.16666666666666666d0) * ((x ** 3.0d0) / y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 210000000000.0) {
tmp = Math.sin(x);
} else {
tmp = -0.16666666666666666 * (Math.pow(x, 3.0) / y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 210000000000.0: tmp = math.sin(x) else: tmp = -0.16666666666666666 * (math.pow(x, 3.0) / y) return tmp
function code(x, y) tmp = 0.0 if (y <= 210000000000.0) tmp = sin(x); else tmp = Float64(-0.16666666666666666 * Float64((x ^ 3.0) / y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 210000000000.0) tmp = sin(x); else tmp = -0.16666666666666666 * ((x ^ 3.0) / y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 210000000000.0], N[Sin[x], $MachinePrecision], N[(-0.16666666666666666 * N[(N[Power[x, 3.0], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 210000000000:\\
\;\;\;\;\sin x\\
\mathbf{else}:\\
\;\;\;\;-0.16666666666666666 \cdot \frac{{x}^{3}}{y}\\
\end{array}
\end{array}
if y < 2.1e11Initial program 100.0%
Taylor expanded in y around 0 64.1%
if 2.1e11 < y Initial program 100.0%
Taylor expanded in y around inf 100.0%
rec-exp100.0%
Simplified100.0%
Applied egg-rr2.0%
Taylor expanded in x around 0 12.8%
distribute-rgt-in12.8%
associate-*l*12.8%
associate-*l/12.8%
unpow212.8%
unpow312.8%
associate-*l/12.8%
*-lft-identity12.8%
Simplified12.8%
Taylor expanded in x around inf 12.7%
(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 y around 0 72.3%
Taylor expanded in x around 0 60.6%
*-commutative60.6%
*-commutative60.6%
associate-*l*60.6%
Simplified60.6%
Taylor expanded in x around 0 44.2%
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)))