
(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 8 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 (or (<= y 0.102) (not (<= y 1.4e+154))) (* (sin x) (+ 1.0 (* 0.16666666666666666 (* y y)))) (* x (/ (sinh y) y))))
double code(double x, double y) {
double tmp;
if ((y <= 0.102) || !(y <= 1.4e+154)) {
tmp = sin(x) * (1.0 + (0.16666666666666666 * (y * y)));
} 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 <= 0.102d0) .or. (.not. (y <= 1.4d+154))) then
tmp = sin(x) * (1.0d0 + (0.16666666666666666d0 * (y * y)))
else
tmp = x * (sinh(y) / y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= 0.102) || !(y <= 1.4e+154)) {
tmp = Math.sin(x) * (1.0 + (0.16666666666666666 * (y * y)));
} else {
tmp = x * (Math.sinh(y) / y);
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= 0.102) or not (y <= 1.4e+154): tmp = math.sin(x) * (1.0 + (0.16666666666666666 * (y * y))) else: tmp = x * (math.sinh(y) / y) return tmp
function code(x, y) tmp = 0.0 if ((y <= 0.102) || !(y <= 1.4e+154)) tmp = Float64(sin(x) * Float64(1.0 + Float64(0.16666666666666666 * Float64(y * y)))); else tmp = Float64(x * Float64(sinh(y) / y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= 0.102) || ~((y <= 1.4e+154))) tmp = sin(x) * (1.0 + (0.16666666666666666 * (y * y))); else tmp = x * (sinh(y) / y); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, 0.102], N[Not[LessEqual[y, 1.4e+154]], $MachinePrecision]], N[(N[Sin[x], $MachinePrecision] * N[(1.0 + N[(0.16666666666666666 * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 0.102 \lor \neg \left(y \leq 1.4 \cdot 10^{+154}\right):\\
\;\;\;\;\sin x \cdot \left(1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{\sinh y}{y}\\
\end{array}
\end{array}
if y < 0.101999999999999993 or 1.4e154 < y Initial program 100.0%
Taylor expanded in y around 0 85.4%
unpow285.4%
Applied egg-rr85.4%
if 0.101999999999999993 < y < 1.4e154Initial program 100.0%
Taylor expanded in x around 0 78.8%
Final simplification84.5%
(FPCore (x y) :precision binary64 (if (<= y 0.0132) (sin x) (* x (/ (sinh y) y))))
double code(double x, double y) {
double tmp;
if (y <= 0.0132) {
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 <= 0.0132d0) 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 <= 0.0132) {
tmp = Math.sin(x);
} else {
tmp = x * (Math.sinh(y) / y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 0.0132: tmp = math.sin(x) else: tmp = x * (math.sinh(y) / y) return tmp
function code(x, y) tmp = 0.0 if (y <= 0.0132) 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 <= 0.0132) tmp = sin(x); else tmp = x * (sinh(y) / y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 0.0132], N[Sin[x], $MachinePrecision], N[(x * N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 0.0132:\\
\;\;\;\;\sin x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{\sinh y}{y}\\
\end{array}
\end{array}
if y < 0.0132Initial program 100.0%
Taylor expanded in y around 0 67.0%
if 0.0132 < y Initial program 100.0%
Taylor expanded in x around 0 77.0%
(FPCore (x y)
:precision binary64
(if (<= y 1.02e+15)
(sin x)
(if (<= y 1.25e+56)
(* x (+ 1.0 (* (* x x) -0.16666666666666666)))
(* x (+ 1.0 (* 0.16666666666666666 (* y y)))))))
double code(double x, double y) {
double tmp;
if (y <= 1.02e+15) {
tmp = sin(x);
} else if (y <= 1.25e+56) {
tmp = x * (1.0 + ((x * x) * -0.16666666666666666));
} else {
tmp = x * (1.0 + (0.16666666666666666 * (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 <= 1.02d+15) then
tmp = sin(x)
else if (y <= 1.25d+56) then
tmp = x * (1.0d0 + ((x * x) * (-0.16666666666666666d0)))
else
tmp = x * (1.0d0 + (0.16666666666666666d0 * (y * y)))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 1.02e+15) {
tmp = Math.sin(x);
} else if (y <= 1.25e+56) {
tmp = x * (1.0 + ((x * x) * -0.16666666666666666));
} else {
tmp = x * (1.0 + (0.16666666666666666 * (y * y)));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 1.02e+15: tmp = math.sin(x) elif y <= 1.25e+56: tmp = x * (1.0 + ((x * x) * -0.16666666666666666)) else: tmp = x * (1.0 + (0.16666666666666666 * (y * y))) return tmp
function code(x, y) tmp = 0.0 if (y <= 1.02e+15) tmp = sin(x); elseif (y <= 1.25e+56) tmp = Float64(x * Float64(1.0 + Float64(Float64(x * x) * -0.16666666666666666))); else tmp = Float64(x * Float64(1.0 + Float64(0.16666666666666666 * Float64(y * y)))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 1.02e+15) tmp = sin(x); elseif (y <= 1.25e+56) tmp = x * (1.0 + ((x * x) * -0.16666666666666666)); else tmp = x * (1.0 + (0.16666666666666666 * (y * y))); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 1.02e+15], N[Sin[x], $MachinePrecision], If[LessEqual[y, 1.25e+56], N[(x * N[(1.0 + N[(N[(x * x), $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 + N[(0.16666666666666666 * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.02 \cdot 10^{+15}:\\
\;\;\;\;\sin x\\
\mathbf{elif}\;y \leq 1.25 \cdot 10^{+56}:\\
\;\;\;\;x \cdot \left(1 + \left(x \cdot x\right) \cdot -0.16666666666666666\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\right)\\
\end{array}
\end{array}
if y < 1.02e15Initial program 100.0%
Taylor expanded in y around 0 66.0%
if 1.02e15 < y < 1.25000000000000006e56Initial program 100.0%
Taylor expanded in y around 0 2.8%
Taylor expanded in x around 0 34.2%
*-commutative34.2%
Simplified34.2%
unpow234.2%
Applied egg-rr34.2%
if 1.25000000000000006e56 < y Initial program 100.0%
Taylor expanded in y around 0 56.2%
unpow256.2%
Applied egg-rr56.2%
Taylor expanded in x around 0 51.3%
(FPCore (x y) :precision binary64 (if (<= y 4.3e+54) (* x (+ 1.0 (* (* x x) -0.16666666666666666))) (* x (+ 1.0 (* 0.16666666666666666 (* y y))))))
double code(double x, double y) {
double tmp;
if (y <= 4.3e+54) {
tmp = x * (1.0 + ((x * x) * -0.16666666666666666));
} else {
tmp = x * (1.0 + (0.16666666666666666 * (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 <= 4.3d+54) then
tmp = x * (1.0d0 + ((x * x) * (-0.16666666666666666d0)))
else
tmp = x * (1.0d0 + (0.16666666666666666d0 * (y * y)))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 4.3e+54) {
tmp = x * (1.0 + ((x * x) * -0.16666666666666666));
} else {
tmp = x * (1.0 + (0.16666666666666666 * (y * y)));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 4.3e+54: tmp = x * (1.0 + ((x * x) * -0.16666666666666666)) else: tmp = x * (1.0 + (0.16666666666666666 * (y * y))) return tmp
function code(x, y) tmp = 0.0 if (y <= 4.3e+54) tmp = Float64(x * Float64(1.0 + Float64(Float64(x * x) * -0.16666666666666666))); else tmp = Float64(x * Float64(1.0 + Float64(0.16666666666666666 * Float64(y * y)))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 4.3e+54) tmp = x * (1.0 + ((x * x) * -0.16666666666666666)); else tmp = x * (1.0 + (0.16666666666666666 * (y * y))); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 4.3e+54], N[(x * N[(1.0 + N[(N[(x * x), $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 + N[(0.16666666666666666 * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.3 \cdot 10^{+54}:\\
\;\;\;\;x \cdot \left(1 + \left(x \cdot x\right) \cdot -0.16666666666666666\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\right)\\
\end{array}
\end{array}
if y < 4.29999999999999976e54Initial program 100.0%
Taylor expanded in y around 0 64.2%
Taylor expanded in x around 0 33.3%
*-commutative33.3%
Simplified33.3%
unpow233.3%
Applied egg-rr33.3%
if 4.29999999999999976e54 < y Initial program 100.0%
Taylor expanded in y around 0 56.2%
unpow256.2%
Applied egg-rr56.2%
Taylor expanded in x around 0 51.3%
(FPCore (x y) :precision binary64 (if (<= x 2e+78) x (/ (* x y) y)))
double code(double x, double y) {
double tmp;
if (x <= 2e+78) {
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 <= 2d+78) 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 <= 2e+78) {
tmp = x;
} else {
tmp = (x * y) / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 2e+78: tmp = x else: tmp = (x * y) / y return tmp
function code(x, y) tmp = 0.0 if (x <= 2e+78) tmp = x; else tmp = Float64(Float64(x * y) / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 2e+78) tmp = x; else tmp = (x * y) / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 2e+78], x, N[(N[(x * y), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2 \cdot 10^{+78}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{y}\\
\end{array}
\end{array}
if x < 2.00000000000000002e78Initial program 100.0%
Taylor expanded in x around 0 64.3%
Taylor expanded in y around 0 25.3%
if 2.00000000000000002e78 < x Initial program 100.0%
add-log-exp99.6%
*-un-lft-identity99.6%
log-prod99.6%
metadata-eval99.6%
add-log-exp100.0%
Applied egg-rr100.0%
+-lft-identity100.0%
associate-*r/99.9%
Simplified99.9%
Taylor expanded in y around 0 58.7%
Taylor expanded in x around 0 17.0%
*-commutative17.0%
Simplified17.0%
Final simplification23.6%
(FPCore (x y) :precision binary64 (* x (+ 1.0 (* 0.16666666666666666 (* y y)))))
double code(double x, double y) {
return x * (1.0 + (0.16666666666666666 * (y * y)));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x * (1.0d0 + (0.16666666666666666d0 * (y * y)))
end function
public static double code(double x, double y) {
return x * (1.0 + (0.16666666666666666 * (y * y)));
}
def code(x, y): return x * (1.0 + (0.16666666666666666 * (y * y)))
function code(x, y) return Float64(x * Float64(1.0 + Float64(0.16666666666666666 * Float64(y * y)))) end
function tmp = code(x, y) tmp = x * (1.0 + (0.16666666666666666 * (y * y))); end
code[x_, y_] := N[(x * N[(1.0 + N[(0.16666666666666666 * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\right)
\end{array}
Initial program 100.0%
Taylor expanded in y around 0 75.0%
unpow275.0%
Applied egg-rr75.0%
Taylor expanded in x around 0 41.2%
(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 56.2%
Taylor expanded in y around 0 20.7%
herbie shell --seed 2024181
(FPCore (x y)
:name "Linear.Quaternion:$ccos from linear-1.19.1.3"
:precision binary64
(* (sin x) (/ (sinh y) y)))