
(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 4600000000000.0)
(sin x)
(if (<= y 4.2e+108)
(+ x (* -0.16666666666666666 (pow x 3.0)))
(* 0.16666666666666666 (* x (pow y 2.0))))))
double code(double x, double y) {
double tmp;
if (y <= 4600000000000.0) {
tmp = sin(x);
} else if (y <= 4.2e+108) {
tmp = x + (-0.16666666666666666 * pow(x, 3.0));
} 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 <= 4600000000000.0d0) then
tmp = sin(x)
else if (y <= 4.2d+108) then
tmp = x + ((-0.16666666666666666d0) * (x ** 3.0d0))
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 <= 4600000000000.0) {
tmp = Math.sin(x);
} else if (y <= 4.2e+108) {
tmp = x + (-0.16666666666666666 * Math.pow(x, 3.0));
} else {
tmp = 0.16666666666666666 * (x * Math.pow(y, 2.0));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 4600000000000.0: tmp = math.sin(x) elif y <= 4.2e+108: tmp = x + (-0.16666666666666666 * math.pow(x, 3.0)) else: tmp = 0.16666666666666666 * (x * math.pow(y, 2.0)) return tmp
function code(x, y) tmp = 0.0 if (y <= 4600000000000.0) tmp = sin(x); elseif (y <= 4.2e+108) tmp = Float64(x + Float64(-0.16666666666666666 * (x ^ 3.0))); 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 <= 4600000000000.0) tmp = sin(x); elseif (y <= 4.2e+108) tmp = x + (-0.16666666666666666 * (x ^ 3.0)); else tmp = 0.16666666666666666 * (x * (y ^ 2.0)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 4600000000000.0], N[Sin[x], $MachinePrecision], If[LessEqual[y, 4.2e+108], N[(x + N[(-0.16666666666666666 * N[Power[x, 3.0], $MachinePrecision]), $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 4600000000000:\\
\;\;\;\;\sin x\\
\mathbf{elif}\;y \leq 4.2 \cdot 10^{+108}:\\
\;\;\;\;x + -0.16666666666666666 \cdot {x}^{3}\\
\mathbf{else}:\\
\;\;\;\;0.16666666666666666 \cdot \left(x \cdot {y}^{2}\right)\\
\end{array}
\end{array}
if y < 4.6e12Initial program 100.0%
Taylor expanded in y around 0 62.8%
if 4.6e12 < y < 4.20000000000000019e108Initial program 100.0%
clear-num100.0%
un-div-inv100.0%
Applied egg-rr100.0%
associate-/r/95.5%
associate-*l/100.0%
div-inv100.0%
Applied egg-rr100.0%
Taylor expanded in y around 0 2.7%
Taylor expanded in x around 0 28.9%
distribute-rgt-in28.9%
*-lft-identity28.9%
associate-*l*28.9%
unpow228.9%
unpow328.9%
Simplified28.9%
if 4.20000000000000019e108 < y Initial program 100.0%
Taylor expanded in y around 0 80.8%
associate-*r*80.8%
Simplified80.8%
Taylor expanded in x around 0 67.5%
Taylor expanded in y around inf 67.5%
(FPCore (x y) :precision binary64 (if (<= y 1.3e+42) (sin x) (* 0.16666666666666666 (* x (pow y 2.0)))))
double code(double x, double y) {
double tmp;
if (y <= 1.3e+42) {
tmp = sin(x);
} 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 <= 1.3d+42) then
tmp = sin(x)
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 <= 1.3e+42) {
tmp = Math.sin(x);
} else {
tmp = 0.16666666666666666 * (x * Math.pow(y, 2.0));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 1.3e+42: tmp = math.sin(x) else: tmp = 0.16666666666666666 * (x * math.pow(y, 2.0)) return tmp
function code(x, y) tmp = 0.0 if (y <= 1.3e+42) tmp = sin(x); 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 <= 1.3e+42) tmp = sin(x); else tmp = 0.16666666666666666 * (x * (y ^ 2.0)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 1.3e+42], N[Sin[x], $MachinePrecision], N[(0.16666666666666666 * N[(x * N[Power[y, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.3 \cdot 10^{+42}:\\
\;\;\;\;\sin x\\
\mathbf{else}:\\
\;\;\;\;0.16666666666666666 \cdot \left(x \cdot {y}^{2}\right)\\
\end{array}
\end{array}
if y < 1.29999999999999995e42Initial program 100.0%
Taylor expanded in y around 0 61.0%
if 1.29999999999999995e42 < y Initial program 100.0%
Taylor expanded in y around 0 58.5%
associate-*r*58.5%
Simplified58.5%
Taylor expanded in x around 0 50.4%
Taylor expanded in y around inf 50.4%
(FPCore (x y) :precision binary64 (if (<= y 6.2e+89) (sin x) (* (* x y) (/ 1.0 y))))
double code(double x, double y) {
double tmp;
if (y <= 6.2e+89) {
tmp = sin(x);
} else {
tmp = (x * y) * (1.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 <= 6.2d+89) then
tmp = sin(x)
else
tmp = (x * y) * (1.0d0 / y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 6.2e+89) {
tmp = Math.sin(x);
} else {
tmp = (x * y) * (1.0 / y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 6.2e+89: tmp = math.sin(x) else: tmp = (x * y) * (1.0 / y) return tmp
function code(x, y) tmp = 0.0 if (y <= 6.2e+89) tmp = sin(x); else tmp = Float64(Float64(x * y) * Float64(1.0 / y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 6.2e+89) tmp = sin(x); else tmp = (x * y) * (1.0 / y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 6.2e+89], N[Sin[x], $MachinePrecision], N[(N[(x * y), $MachinePrecision] * N[(1.0 / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 6.2 \cdot 10^{+89}:\\
\;\;\;\;\sin x\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot y\right) \cdot \frac{1}{y}\\
\end{array}
\end{array}
if y < 6.2e89Initial program 100.0%
Taylor expanded in y around 0 58.0%
if 6.2e89 < y Initial program 100.0%
clear-num100.0%
un-div-inv100.0%
Applied egg-rr100.0%
associate-/r/61.4%
associate-*l/100.0%
div-inv100.0%
Applied egg-rr100.0%
Taylor expanded in y around 0 2.6%
Taylor expanded in x around 0 10.8%
(FPCore (x y) :precision binary64 (if (<= x 4.2e+60) x (* (* x y) (/ 1.0 y))))
double code(double x, double y) {
double tmp;
if (x <= 4.2e+60) {
tmp = x;
} else {
tmp = (x * y) * (1.0 / y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= 4.2d+60) then
tmp = x
else
tmp = (x * y) * (1.0d0 / y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= 4.2e+60) {
tmp = x;
} else {
tmp = (x * y) * (1.0 / y);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 4.2e+60: tmp = x else: tmp = (x * y) * (1.0 / y) return tmp
function code(x, y) tmp = 0.0 if (x <= 4.2e+60) tmp = x; else tmp = Float64(Float64(x * y) * Float64(1.0 / y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 4.2e+60) tmp = x; else tmp = (x * y) * (1.0 / y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 4.2e+60], x, N[(N[(x * y), $MachinePrecision] * N[(1.0 / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 4.2 \cdot 10^{+60}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot y\right) \cdot \frac{1}{y}\\
\end{array}
\end{array}
if x < 4.2000000000000002e60Initial program 100.0%
Taylor expanded in y around 0 75.4%
associate-*r*75.4%
Simplified75.4%
Taylor expanded in x around 0 50.2%
Taylor expanded in y around 0 26.7%
if 4.2000000000000002e60 < x Initial program 99.9%
clear-num99.9%
un-div-inv100.0%
Applied egg-rr100.0%
associate-/r/99.9%
associate-*l/99.9%
div-inv99.7%
Applied egg-rr99.7%
Taylor expanded in y around 0 57.9%
Taylor expanded in x around 0 14.6%
(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 75.1%
associate-*r*75.1%
Simplified75.1%
Taylor expanded in x around 0 42.9%
Taylor expanded in y around 0 21.6%
herbie shell --seed 2024107
(FPCore (x y)
:name "Linear.Quaternion:$ccos from linear-1.19.1.3"
:precision binary64
(* (sin x) (/ (sinh y) y)))