
(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 (let* ((t_0 (/ (sinh y) y))) (if (<= t_0 1.01) (sin x) (* x t_0))))
double code(double x, double y) {
double t_0 = sinh(y) / y;
double tmp;
if (t_0 <= 1.01) {
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.01d0) 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.01) {
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.01: 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.01) 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.01) 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.01], 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.01:\\
\;\;\;\;\sin x\\
\mathbf{else}:\\
\;\;\;\;x \cdot t_0\\
\end{array}
\end{array}
if (/.f64 (sinh.f64 y) y) < 1.01000000000000001Initial program 100.0%
Taylor expanded in y around 0 99.8%
if 1.01000000000000001 < (/.f64 (sinh.f64 y) y) Initial program 100.0%
Taylor expanded in x around 0 65.9%
Final simplification82.7%
(FPCore (x y) :precision binary64 (if (<= y 9e+57) (sin x) (* (/ 1.0 y) (/ y (/ 1.0 x)))))
double code(double x, double y) {
double tmp;
if (y <= 9e+57) {
tmp = sin(x);
} else {
tmp = (1.0 / y) * (y / (1.0 / x));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 9d+57) then
tmp = sin(x)
else
tmp = (1.0d0 / y) * (y / (1.0d0 / x))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 9e+57) {
tmp = Math.sin(x);
} else {
tmp = (1.0 / y) * (y / (1.0 / x));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 9e+57: tmp = math.sin(x) else: tmp = (1.0 / y) * (y / (1.0 / x)) return tmp
function code(x, y) tmp = 0.0 if (y <= 9e+57) tmp = sin(x); else tmp = Float64(Float64(1.0 / y) * Float64(y / Float64(1.0 / x))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 9e+57) tmp = sin(x); else tmp = (1.0 / y) * (y / (1.0 / x)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 9e+57], N[Sin[x], $MachinePrecision], N[(N[(1.0 / y), $MachinePrecision] * N[(y / N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 9 \cdot 10^{+57}:\\
\;\;\;\;\sin x\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{y} \cdot \frac{y}{\frac{1}{x}}\\
\end{array}
\end{array}
if y < 8.99999999999999991e57Initial program 100.0%
Taylor expanded in y around 0 64.2%
if 8.99999999999999991e57 < y Initial program 100.0%
add-log-exp100.0%
*-un-lft-identity100.0%
log-prod100.0%
metadata-eval100.0%
add-log-exp100.0%
clear-num100.0%
un-div-inv100.0%
Applied egg-rr100.0%
+-lft-identity100.0%
associate-/l*100.0%
*-commutative100.0%
associate-/l*69.1%
Simplified69.1%
Taylor expanded in y around 0 2.5%
Taylor expanded in x around 0 2.5%
*-un-lft-identity2.5%
div-inv2.5%
times-frac16.2%
Applied egg-rr16.2%
Final simplification53.9%
(FPCore (x y) :precision binary64 (if (<= y 0.34) (/ y (+ (* 0.16666666666666666 (* x y)) (/ y x))) (* (/ 1.0 y) (/ y (/ 1.0 x)))))
double code(double x, double y) {
double tmp;
if (y <= 0.34) {
tmp = y / ((0.16666666666666666 * (x * y)) + (y / x));
} else {
tmp = (1.0 / y) * (y / (1.0 / x));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 0.34d0) then
tmp = y / ((0.16666666666666666d0 * (x * y)) + (y / x))
else
tmp = (1.0d0 / y) * (y / (1.0d0 / x))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 0.34) {
tmp = y / ((0.16666666666666666 * (x * y)) + (y / x));
} else {
tmp = (1.0 / y) * (y / (1.0 / x));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 0.34: tmp = y / ((0.16666666666666666 * (x * y)) + (y / x)) else: tmp = (1.0 / y) * (y / (1.0 / x)) return tmp
function code(x, y) tmp = 0.0 if (y <= 0.34) tmp = Float64(y / Float64(Float64(0.16666666666666666 * Float64(x * y)) + Float64(y / x))); else tmp = Float64(Float64(1.0 / y) * Float64(y / Float64(1.0 / x))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 0.34) tmp = y / ((0.16666666666666666 * (x * y)) + (y / x)); else tmp = (1.0 / y) * (y / (1.0 / x)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 0.34], N[(y / N[(N[(0.16666666666666666 * N[(x * y), $MachinePrecision]), $MachinePrecision] + N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / y), $MachinePrecision] * N[(y / N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 0.34:\\
\;\;\;\;\frac{y}{0.16666666666666666 \cdot \left(x \cdot y\right) + \frac{y}{x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{y} \cdot \frac{y}{\frac{1}{x}}\\
\end{array}
\end{array}
if y < 0.340000000000000024Initial program 100.0%
add-log-exp64.5%
*-un-lft-identity64.5%
log-prod64.5%
metadata-eval64.5%
add-log-exp100.0%
clear-num100.0%
un-div-inv100.0%
Applied egg-rr100.0%
+-lft-identity100.0%
associate-/l*79.5%
*-commutative79.5%
associate-/l*90.5%
Simplified90.5%
Taylor expanded in y around 0 66.5%
Taylor expanded in x around 0 38.8%
if 0.340000000000000024 < y Initial program 100.0%
add-log-exp100.0%
*-un-lft-identity100.0%
log-prod100.0%
metadata-eval100.0%
add-log-exp100.0%
clear-num100.0%
un-div-inv100.0%
Applied egg-rr100.0%
+-lft-identity100.0%
associate-/l*100.0%
*-commutative100.0%
associate-/l*73.0%
Simplified73.0%
Taylor expanded in y around 0 2.6%
Taylor expanded in x around 0 2.4%
*-un-lft-identity2.4%
div-inv2.4%
times-frac14.4%
Applied egg-rr14.4%
Final simplification32.8%
(FPCore (x y) :precision binary64 (if (<= y 9e-8) x (* (/ 1.0 y) (/ y (/ 1.0 x)))))
double code(double x, double y) {
double tmp;
if (y <= 9e-8) {
tmp = x;
} else {
tmp = (1.0 / y) * (y / (1.0 / x));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 9d-8) then
tmp = x
else
tmp = (1.0d0 / y) * (y / (1.0d0 / x))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 9e-8) {
tmp = x;
} else {
tmp = (1.0 / y) * (y / (1.0 / x));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 9e-8: tmp = x else: tmp = (1.0 / y) * (y / (1.0 / x)) return tmp
function code(x, y) tmp = 0.0 if (y <= 9e-8) tmp = x; else tmp = Float64(Float64(1.0 / y) * Float64(y / Float64(1.0 / x))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 9e-8) tmp = x; else tmp = (1.0 / y) * (y / (1.0 / x)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 9e-8], x, N[(N[(1.0 / y), $MachinePrecision] * N[(y / N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 9 \cdot 10^{-8}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{y} \cdot \frac{y}{\frac{1}{x}}\\
\end{array}
\end{array}
if y < 8.99999999999999986e-8Initial program 100.0%
Taylor expanded in x around 0 58.5%
Taylor expanded in y around 0 38.7%
if 8.99999999999999986e-8 < y Initial program 100.0%
add-log-exp100.0%
*-un-lft-identity100.0%
log-prod100.0%
metadata-eval100.0%
add-log-exp100.0%
clear-num100.0%
un-div-inv100.0%
Applied egg-rr100.0%
+-lft-identity100.0%
associate-/l*100.0%
*-commutative100.0%
associate-/l*73.0%
Simplified73.0%
Taylor expanded in y around 0 2.6%
Taylor expanded in x around 0 2.4%
*-un-lft-identity2.4%
div-inv2.4%
times-frac14.4%
Applied egg-rr14.4%
Final simplification32.7%
(FPCore (x y) :precision binary64 (if (<= y 0.34) (/ 1.0 (+ (/ 1.0 x) (* x 0.16666666666666666))) (* (/ 1.0 y) (/ y (/ 1.0 x)))))
double code(double x, double y) {
double tmp;
if (y <= 0.34) {
tmp = 1.0 / ((1.0 / x) + (x * 0.16666666666666666));
} else {
tmp = (1.0 / y) * (y / (1.0 / x));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 0.34d0) then
tmp = 1.0d0 / ((1.0d0 / x) + (x * 0.16666666666666666d0))
else
tmp = (1.0d0 / y) * (y / (1.0d0 / x))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 0.34) {
tmp = 1.0 / ((1.0 / x) + (x * 0.16666666666666666));
} else {
tmp = (1.0 / y) * (y / (1.0 / x));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 0.34: tmp = 1.0 / ((1.0 / x) + (x * 0.16666666666666666)) else: tmp = (1.0 / y) * (y / (1.0 / x)) return tmp
function code(x, y) tmp = 0.0 if (y <= 0.34) tmp = Float64(1.0 / Float64(Float64(1.0 / x) + Float64(x * 0.16666666666666666))); else tmp = Float64(Float64(1.0 / y) * Float64(y / Float64(1.0 / x))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 0.34) tmp = 1.0 / ((1.0 / x) + (x * 0.16666666666666666)); else tmp = (1.0 / y) * (y / (1.0 / x)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 0.34], N[(1.0 / N[(N[(1.0 / x), $MachinePrecision] + N[(x * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / y), $MachinePrecision] * N[(y / N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 0.34:\\
\;\;\;\;\frac{1}{\frac{1}{x} + x \cdot 0.16666666666666666}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{y} \cdot \frac{y}{\frac{1}{x}}\\
\end{array}
\end{array}
if y < 0.340000000000000024Initial program 100.0%
add-log-exp64.5%
*-un-lft-identity64.5%
log-prod64.5%
metadata-eval64.5%
add-log-exp100.0%
clear-num100.0%
un-div-inv100.0%
Applied egg-rr100.0%
+-lft-identity100.0%
associate-/l*79.5%
*-commutative79.5%
associate-/l*90.5%
Simplified90.5%
Taylor expanded in y around 0 66.5%
Taylor expanded in x around 0 38.8%
Taylor expanded in y around 0 38.8%
if 0.340000000000000024 < y Initial program 100.0%
add-log-exp100.0%
*-un-lft-identity100.0%
log-prod100.0%
metadata-eval100.0%
add-log-exp100.0%
clear-num100.0%
un-div-inv100.0%
Applied egg-rr100.0%
+-lft-identity100.0%
associate-/l*100.0%
*-commutative100.0%
associate-/l*73.0%
Simplified73.0%
Taylor expanded in y around 0 2.6%
Taylor expanded in x around 0 2.4%
*-un-lft-identity2.4%
div-inv2.4%
times-frac14.4%
Applied egg-rr14.4%
Final simplification32.8%
(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 61.7%
Taylor expanded in y around 0 29.8%
Final simplification29.8%
herbie shell --seed 2024019
(FPCore (x y)
:name "Linear.Quaternion:$ccos from linear-1.19.1.3"
:precision binary64
(* (sin x) (/ (sinh y) y)))