
(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 1.7e-10) (sin x) (* x (+ 1.0 (* 0.16666666666666666 (pow y 2.0))))))
double code(double x, double y) {
double tmp;
if (y <= 1.7e-10) {
tmp = sin(x);
} else {
tmp = x * (1.0 + (0.16666666666666666 * 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.7d-10) then
tmp = sin(x)
else
tmp = x * (1.0d0 + (0.16666666666666666d0 * (y ** 2.0d0)))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 1.7e-10) {
tmp = Math.sin(x);
} else {
tmp = x * (1.0 + (0.16666666666666666 * Math.pow(y, 2.0)));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 1.7e-10: tmp = math.sin(x) else: tmp = x * (1.0 + (0.16666666666666666 * math.pow(y, 2.0))) return tmp
function code(x, y) tmp = 0.0 if (y <= 1.7e-10) tmp = sin(x); else tmp = Float64(x * Float64(1.0 + Float64(0.16666666666666666 * (y ^ 2.0)))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 1.7e-10) tmp = sin(x); else tmp = x * (1.0 + (0.16666666666666666 * (y ^ 2.0))); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 1.7e-10], N[Sin[x], $MachinePrecision], N[(x * N[(1.0 + N[(0.16666666666666666 * N[Power[y, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.7 \cdot 10^{-10}:\\
\;\;\;\;\sin x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 + 0.16666666666666666 \cdot {y}^{2}\right)\\
\end{array}
\end{array}
if y < 1.70000000000000007e-10Initial program 100.0%
Taylor expanded in y around 0 73.4%
if 1.70000000000000007e-10 < y Initial program 100.0%
Taylor expanded in y around 0 48.7%
associate-*r*48.7%
Simplified48.7%
Taylor expanded in x around 0 49.8%
Final simplification67.9%
(FPCore (x y) :precision binary64 (if (<= y 1.7e-10) (sin x) (+ x (* 0.16666666666666666 (* x (pow y 2.0))))))
double code(double x, double y) {
double tmp;
if (y <= 1.7e-10) {
tmp = sin(x);
} else {
tmp = x + (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.7d-10) then
tmp = sin(x)
else
tmp = x + (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.7e-10) {
tmp = Math.sin(x);
} else {
tmp = x + (0.16666666666666666 * (x * Math.pow(y, 2.0)));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 1.7e-10: tmp = math.sin(x) else: tmp = x + (0.16666666666666666 * (x * math.pow(y, 2.0))) return tmp
function code(x, y) tmp = 0.0 if (y <= 1.7e-10) tmp = sin(x); else tmp = Float64(x + Float64(0.16666666666666666 * Float64(x * (y ^ 2.0)))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 1.7e-10) tmp = sin(x); else tmp = x + (0.16666666666666666 * (x * (y ^ 2.0))); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 1.7e-10], N[Sin[x], $MachinePrecision], N[(x + N[(0.16666666666666666 * N[(x * N[Power[y, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.7 \cdot 10^{-10}:\\
\;\;\;\;\sin x\\
\mathbf{else}:\\
\;\;\;\;x + 0.16666666666666666 \cdot \left(x \cdot {y}^{2}\right)\\
\end{array}
\end{array}
if y < 1.70000000000000007e-10Initial program 100.0%
Taylor expanded in y around 0 73.4%
if 1.70000000000000007e-10 < y Initial program 100.0%
Taylor expanded in y around 0 48.7%
associate-*r*48.7%
Simplified48.7%
Taylor expanded in x around 0 49.8%
Taylor expanded in y around 0 49.8%
Final simplification67.9%
(FPCore (x y) :precision binary64 (if (<= y 700000.0) (sin x) (* 0.16666666666666666 (* x (pow y 2.0)))))
double code(double x, double y) {
double tmp;
if (y <= 700000.0) {
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 <= 700000.0d0) 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 <= 700000.0) {
tmp = Math.sin(x);
} else {
tmp = 0.16666666666666666 * (x * Math.pow(y, 2.0));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 700000.0: 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 <= 700000.0) 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 <= 700000.0) tmp = sin(x); else tmp = 0.16666666666666666 * (x * (y ^ 2.0)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 700000.0], 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 700000:\\
\;\;\;\;\sin x\\
\mathbf{else}:\\
\;\;\;\;0.16666666666666666 \cdot \left(x \cdot {y}^{2}\right)\\
\end{array}
\end{array}
if y < 7e5Initial program 100.0%
Taylor expanded in y around 0 72.5%
if 7e5 < y Initial program 100.0%
Taylor expanded in y around 0 49.3%
associate-*r*49.3%
Simplified49.3%
Taylor expanded in x around 0 50.4%
Taylor expanded in y around inf 50.4%
Final simplification67.7%
(FPCore (x y) :precision binary64 (if (<= y 235000.0) (sin x) (/ (* x y) y)))
double code(double x, double y) {
double tmp;
if (y <= 235000.0) {
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 <= 235000.0d0) 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 <= 235000.0) {
tmp = Math.sin(x);
} else {
tmp = (x * y) / y;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 235000.0: tmp = math.sin(x) else: tmp = (x * y) / y return tmp
function code(x, y) tmp = 0.0 if (y <= 235000.0) 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 <= 235000.0) tmp = sin(x); else tmp = (x * y) / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 235000.0], N[Sin[x], $MachinePrecision], N[(N[(x * y), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 235000:\\
\;\;\;\;\sin x\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{y}\\
\end{array}
\end{array}
if y < 235000Initial program 100.0%
Taylor expanded in y around 0 72.5%
if 235000 < 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%
Simplified100.0%
Taylor expanded in y around 0 2.7%
Taylor expanded in x around 0 18.4%
Final simplification60.9%
(FPCore (x y) :precision binary64 (if (<= y 4e+86) x (/ (* x y) y)))
double code(double x, double y) {
double tmp;
if (y <= 4e+86) {
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 (y <= 4d+86) 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 (y <= 4e+86) {
tmp = x;
} else {
tmp = (x * y) / y;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 4e+86: tmp = x else: tmp = (x * y) / y return tmp
function code(x, y) tmp = 0.0 if (y <= 4e+86) tmp = x; else tmp = Float64(Float64(x * y) / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 4e+86) tmp = x; else tmp = (x * y) / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 4e+86], x, N[(N[(x * y), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4 \cdot 10^{+86}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{y}\\
\end{array}
\end{array}
if y < 4.0000000000000001e86Initial program 100.0%
Taylor expanded in y around 0 78.7%
associate-*r*78.7%
Simplified78.7%
Taylor expanded in x around 0 47.7%
Taylor expanded in y around 0 35.9%
if 4.0000000000000001e86 < 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%
Simplified100.0%
Taylor expanded in y around 0 2.8%
Taylor expanded in x around 0 27.3%
Final simplification34.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 y around 0 78.2%
associate-*r*78.2%
Simplified78.2%
Taylor expanded in x around 0 51.4%
Taylor expanded in y around 0 31.5%
Final simplification31.5%
herbie shell --seed 2024066
(FPCore (x y)
:name "Linear.Quaternion:$ccos from linear-1.19.1.3"
:precision binary64
(* (sin x) (/ (sinh y) y)))