
(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}
Initial program 100.0%
Final simplification100.0%
(FPCore (x y) :precision binary64 (if (<= y 7.3e-7) (sin x) (/ 1.0 (/ (/ y (sinh y)) x))))
double code(double x, double y) {
double tmp;
if (y <= 7.3e-7) {
tmp = sin(x);
} else {
tmp = 1.0 / ((y / sinh(y)) / x);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 7.3d-7) then
tmp = sin(x)
else
tmp = 1.0d0 / ((y / sinh(y)) / x)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 7.3e-7) {
tmp = Math.sin(x);
} else {
tmp = 1.0 / ((y / Math.sinh(y)) / x);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 7.3e-7: tmp = math.sin(x) else: tmp = 1.0 / ((y / math.sinh(y)) / x) return tmp
function code(x, y) tmp = 0.0 if (y <= 7.3e-7) tmp = sin(x); else tmp = Float64(1.0 / Float64(Float64(y / sinh(y)) / x)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 7.3e-7) tmp = sin(x); else tmp = 1.0 / ((y / sinh(y)) / x); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 7.3e-7], N[Sin[x], $MachinePrecision], N[(1.0 / N[(N[(y / N[Sinh[y], $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 7.3 \cdot 10^{-7}:\\
\;\;\;\;\sin x\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{\frac{y}{\sinh y}}{x}}\\
\end{array}
\end{array}
if y < 7.3e-7Initial program 100.0%
Taylor expanded in y around 0 76.7%
if 7.3e-7 < y Initial program 99.9%
associate-*r/100.0%
clear-num100.0%
*-commutative100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 66.5%
associate-*r/66.5%
*-commutative66.5%
associate-/r*66.5%
associate-*r/66.5%
*-commutative66.5%
associate-/r/66.5%
rec-exp66.5%
sinh-def67.2%
Simplified67.2%
Final simplification74.2%
(FPCore (x y) :precision binary64 (if (<= y 7.3e-7) (sin x) (* (sinh y) (/ x y))))
double code(double x, double y) {
double tmp;
if (y <= 7.3e-7) {
tmp = sin(x);
} else {
tmp = sinh(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 (y <= 7.3d-7) then
tmp = sin(x)
else
tmp = sinh(y) * (x / y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 7.3e-7) {
tmp = Math.sin(x);
} else {
tmp = Math.sinh(y) * (x / y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 7.3e-7: tmp = math.sin(x) else: tmp = math.sinh(y) * (x / y) return tmp
function code(x, y) tmp = 0.0 if (y <= 7.3e-7) tmp = sin(x); else tmp = Float64(sinh(y) * Float64(x / y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 7.3e-7) tmp = sin(x); else tmp = sinh(y) * (x / y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 7.3e-7], N[Sin[x], $MachinePrecision], N[(N[Sinh[y], $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 7.3 \cdot 10^{-7}:\\
\;\;\;\;\sin x\\
\mathbf{else}:\\
\;\;\;\;\sinh y \cdot \frac{x}{y}\\
\end{array}
\end{array}
if y < 7.3e-7Initial program 100.0%
Taylor expanded in y around 0 76.7%
if 7.3e-7 < y Initial program 99.9%
add-log-exp97.2%
*-un-lft-identity97.2%
log-prod97.2%
metadata-eval97.2%
add-log-exp99.9%
Applied egg-rr99.9%
+-lft-identity99.9%
associate-*r/100.0%
*-commutative100.0%
associate-/l*82.1%
Simplified82.1%
Taylor expanded in x around 0 49.3%
Final simplification69.5%
(FPCore (x y) :precision binary64 (if (<= y 7.3e-7) (sin x) (/ (* x (sinh y)) y)))
double code(double x, double y) {
double tmp;
if (y <= 7.3e-7) {
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 <= 7.3d-7) 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 <= 7.3e-7) {
tmp = Math.sin(x);
} else {
tmp = (x * Math.sinh(y)) / y;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 7.3e-7: tmp = math.sin(x) else: tmp = (x * math.sinh(y)) / y return tmp
function code(x, y) tmp = 0.0 if (y <= 7.3e-7) tmp = sin(x); else tmp = Float64(Float64(x * sinh(y)) / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 7.3e-7) tmp = sin(x); else tmp = (x * sinh(y)) / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 7.3e-7], N[Sin[x], $MachinePrecision], N[(N[(x * N[Sinh[y], $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 7.3 \cdot 10^{-7}:\\
\;\;\;\;\sin x\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \sinh y}{y}\\
\end{array}
\end{array}
if y < 7.3e-7Initial program 100.0%
Taylor expanded in y around 0 76.7%
if 7.3e-7 < y Initial program 99.9%
add-log-exp97.2%
*-un-lft-identity97.2%
log-prod97.2%
metadata-eval97.2%
add-log-exp99.9%
Applied egg-rr99.9%
+-lft-identity99.9%
associate-*r/100.0%
*-commutative100.0%
associate-/l*82.1%
Simplified82.1%
Taylor expanded in x around 0 49.3%
*-commutative49.3%
associate-*l/67.2%
Applied egg-rr67.2%
Final simplification74.2%
(FPCore (x y) :precision binary64 (if (<= y 4.8e+71) (sin x) (/ (* x y) y)))
double code(double x, double y) {
double tmp;
if (y <= 4.8e+71) {
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 <= 4.8d+71) 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 <= 4.8e+71) {
tmp = Math.sin(x);
} else {
tmp = (x * y) / y;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 4.8e+71: tmp = math.sin(x) else: tmp = (x * y) / y return tmp
function code(x, y) tmp = 0.0 if (y <= 4.8e+71) 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 <= 4.8e+71) tmp = sin(x); else tmp = (x * y) / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 4.8e+71], N[Sin[x], $MachinePrecision], N[(N[(x * y), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.8 \cdot 10^{+71}:\\
\;\;\;\;\sin x\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{y}\\
\end{array}
\end{array}
if y < 4.79999999999999961e71Initial program 100.0%
Taylor expanded in y around 0 69.8%
if 4.79999999999999961e71 < y Initial program 100.0%
add-log-exp100.0%
*-un-lft-identity100.0%
log-prod100.0%
metadata-eval100.0%
add-log-exp100.0%
Applied egg-rr100.0%
+-lft-identity100.0%
associate-*r/100.0%
*-commutative100.0%
associate-/l*73.3%
Simplified73.3%
Taylor expanded in y around 0 2.6%
associate-*r/2.7%
*-commutative2.7%
Applied egg-rr2.7%
Taylor expanded in x around 0 18.9%
Final simplification60.9%
(FPCore (x y) :precision binary64 (if (<= x 5e+34) x (/ (* x y) y)))
double code(double x, double y) {
double tmp;
if (x <= 5e+34) {
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 <= 5d+34) 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 <= 5e+34) {
tmp = x;
} else {
tmp = (x * y) / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 5e+34: tmp = x else: tmp = (x * y) / y return tmp
function code(x, y) tmp = 0.0 if (x <= 5e+34) tmp = x; else tmp = Float64(Float64(x * y) / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 5e+34) tmp = x; else tmp = (x * y) / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 5e+34], x, N[(N[(x * y), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 5 \cdot 10^{+34}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{y}\\
\end{array}
\end{array}
if x < 4.9999999999999998e34Initial program 100.0%
add-log-exp68.3%
*-un-lft-identity68.3%
log-prod68.3%
metadata-eval68.3%
add-log-exp100.0%
Applied egg-rr100.0%
+-lft-identity100.0%
associate-*r/84.5%
*-commutative84.5%
associate-/l*86.7%
Simplified86.7%
Taylor expanded in y around 0 59.6%
Taylor expanded in x around 0 35.6%
if 4.9999999999999998e34 < x Initial program 100.0%
add-log-exp99.5%
*-un-lft-identity99.5%
log-prod99.5%
metadata-eval99.5%
add-log-exp100.0%
Applied egg-rr100.0%
+-lft-identity100.0%
associate-*r/99.9%
*-commutative99.9%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in y around 0 52.4%
associate-*r/52.2%
*-commutative52.2%
Applied egg-rr52.2%
Taylor expanded in x around 0 14.0%
Final simplification30.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%
add-log-exp75.5%
*-un-lft-identity75.5%
log-prod75.5%
metadata-eval75.5%
add-log-exp100.0%
Applied egg-rr100.0%
+-lft-identity100.0%
associate-*r/88.0%
*-commutative88.0%
associate-/l*89.7%
Simplified89.7%
Taylor expanded in y around 0 57.9%
Taylor expanded in x around 0 28.1%
Final simplification28.1%
herbie shell --seed 2024071
(FPCore (x y)
:name "Linear.Quaternion:$ccos from linear-1.19.1.3"
:precision binary64
(* (sin x) (/ (sinh y) y)))