
(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%
(FPCore (x y) :precision binary64 (if (<= y 580.0) (sin x) (/ (* x (+ y (* -0.16666666666666666 (* y (pow x 2.0))))) y)))
double code(double x, double y) {
double tmp;
if (y <= 580.0) {
tmp = sin(x);
} else {
tmp = (x * (y + (-0.16666666666666666 * (y * pow(x, 2.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 <= 580.0d0) then
tmp = sin(x)
else
tmp = (x * (y + ((-0.16666666666666666d0) * (y * (x ** 2.0d0))))) / y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 580.0) {
tmp = Math.sin(x);
} else {
tmp = (x * (y + (-0.16666666666666666 * (y * Math.pow(x, 2.0))))) / y;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 580.0: tmp = math.sin(x) else: tmp = (x * (y + (-0.16666666666666666 * (y * math.pow(x, 2.0))))) / y return tmp
function code(x, y) tmp = 0.0 if (y <= 580.0) tmp = sin(x); else tmp = Float64(Float64(x * Float64(y + Float64(-0.16666666666666666 * Float64(y * (x ^ 2.0))))) / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 580.0) tmp = sin(x); else tmp = (x * (y + (-0.16666666666666666 * (y * (x ^ 2.0))))) / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 580.0], N[Sin[x], $MachinePrecision], N[(N[(x * N[(y + N[(-0.16666666666666666 * N[(y * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 580:\\
\;\;\;\;\sin x\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \left(y + -0.16666666666666666 \cdot \left(y \cdot {x}^{2}\right)\right)}{y}\\
\end{array}
\end{array}
if y < 580Initial program 100.0%
Taylor expanded in y around 0 68.6%
if 580 < y Initial program 100.0%
*-commutative100.0%
associate-*l/100.0%
Applied egg-rr100.0%
Taylor expanded in y around 0 2.6%
*-commutative2.6%
Simplified2.6%
Taylor expanded in x around 0 21.1%
Final simplification57.3%
(FPCore (x y) :precision binary64 (if (<= y 580.0) (sin x) (* x (+ 1.0 (* -0.16666666666666666 (pow x 2.0))))))
double code(double x, double y) {
double tmp;
if (y <= 580.0) {
tmp = sin(x);
} else {
tmp = x * (1.0 + (-0.16666666666666666 * pow(x, 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 <= 580.0d0) then
tmp = sin(x)
else
tmp = x * (1.0d0 + ((-0.16666666666666666d0) * (x ** 2.0d0)))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 580.0) {
tmp = Math.sin(x);
} else {
tmp = x * (1.0 + (-0.16666666666666666 * Math.pow(x, 2.0)));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 580.0: tmp = math.sin(x) else: tmp = x * (1.0 + (-0.16666666666666666 * math.pow(x, 2.0))) return tmp
function code(x, y) tmp = 0.0 if (y <= 580.0) tmp = sin(x); else tmp = Float64(x * Float64(1.0 + Float64(-0.16666666666666666 * (x ^ 2.0)))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 580.0) tmp = sin(x); else tmp = x * (1.0 + (-0.16666666666666666 * (x ^ 2.0))); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 580.0], N[Sin[x], $MachinePrecision], N[(x * N[(1.0 + N[(-0.16666666666666666 * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 580:\\
\;\;\;\;\sin x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 + -0.16666666666666666 \cdot {x}^{2}\right)\\
\end{array}
\end{array}
if y < 580Initial program 100.0%
Taylor expanded in y around 0 68.6%
if 580 < y Initial program 100.0%
*-commutative100.0%
associate-*l/100.0%
Applied egg-rr100.0%
Taylor expanded in y around 0 2.6%
*-commutative2.6%
Simplified2.6%
Taylor expanded in x around 0 18.2%
(FPCore (x y) :precision binary64 (if (<= y 1.52e+63) (sin x) (/ (* x y) y)))
double code(double x, double y) {
double tmp;
if (y <= 1.52e+63) {
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 <= 1.52d+63) 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 <= 1.52e+63) {
tmp = Math.sin(x);
} else {
tmp = (x * y) / y;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 1.52e+63: tmp = math.sin(x) else: tmp = (x * y) / y return tmp
function code(x, y) tmp = 0.0 if (y <= 1.52e+63) 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 <= 1.52e+63) tmp = sin(x); else tmp = (x * y) / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 1.52e+63], N[Sin[x], $MachinePrecision], N[(N[(x * y), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.52 \cdot 10^{+63}:\\
\;\;\;\;\sin x\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{y}\\
\end{array}
\end{array}
if y < 1.51999999999999993e63Initial program 100.0%
Taylor expanded in y around 0 63.9%
if 1.51999999999999993e63 < y Initial program 100.0%
*-commutative100.0%
associate-*l/100.0%
Applied egg-rr100.0%
Taylor expanded in y around 0 2.6%
*-commutative2.6%
Simplified2.6%
Taylor expanded in x around 0 14.8%
(FPCore (x y) :precision binary64 (if (<= x 1e+102) x (/ (+ (+ 1.0 (* x y)) -1.0) y)))
double code(double x, double y) {
double tmp;
if (x <= 1e+102) {
tmp = x;
} else {
tmp = ((1.0 + (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 <= 1d+102) then
tmp = x
else
tmp = ((1.0d0 + (x * y)) + (-1.0d0)) / y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= 1e+102) {
tmp = x;
} else {
tmp = ((1.0 + (x * y)) + -1.0) / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 1e+102: tmp = x else: tmp = ((1.0 + (x * y)) + -1.0) / y return tmp
function code(x, y) tmp = 0.0 if (x <= 1e+102) tmp = x; else tmp = Float64(Float64(Float64(1.0 + Float64(x * y)) + -1.0) / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 1e+102) tmp = x; else tmp = ((1.0 + (x * y)) + -1.0) / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 1e+102], x, N[(N[(N[(1.0 + N[(x * y), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 10^{+102}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 + x \cdot y\right) + -1}{y}\\
\end{array}
\end{array}
if x < 9.99999999999999977e101Initial program 100.0%
*-commutative100.0%
associate-*l/83.6%
Applied egg-rr83.6%
Taylor expanded in y around 0 35.5%
*-commutative35.5%
Simplified35.5%
Taylor expanded in x around 0 34.2%
if 9.99999999999999977e101 < x Initial program 100.0%
*-commutative100.0%
associate-*l/99.9%
Applied egg-rr99.9%
Taylor expanded in y around 0 56.5%
*-commutative56.5%
Simplified56.5%
expm1-log1p-u55.9%
expm1-undefine4.9%
log1p-undefine4.9%
rem-exp-log5.6%
Applied egg-rr5.6%
Taylor expanded in x around 0 12.8%
Final simplification29.6%
(FPCore (x y) :precision binary64 (if (<= x 8.5e+101) x (/ (* x y) y)))
double code(double x, double y) {
double tmp;
if (x <= 8.5e+101) {
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 <= 8.5d+101) 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 <= 8.5e+101) {
tmp = x;
} else {
tmp = (x * y) / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 8.5e+101: tmp = x else: tmp = (x * y) / y return tmp
function code(x, y) tmp = 0.0 if (x <= 8.5e+101) tmp = x; else tmp = Float64(Float64(x * y) / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 8.5e+101) tmp = x; else tmp = (x * y) / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 8.5e+101], x, N[(N[(x * y), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 8.5 \cdot 10^{+101}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{y}\\
\end{array}
\end{array}
if x < 8.5000000000000001e101Initial program 100.0%
*-commutative100.0%
associate-*l/83.5%
Applied egg-rr83.5%
Taylor expanded in y around 0 35.1%
*-commutative35.1%
Simplified35.1%
Taylor expanded in x around 0 34.4%
if 8.5000000000000001e101 < x Initial program 100.0%
*-commutative100.0%
associate-*l/99.8%
Applied egg-rr99.8%
Taylor expanded in y around 0 57.3%
*-commutative57.3%
Simplified57.3%
Taylor expanded in x around 0 12.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%
*-commutative100.0%
associate-*l/87.1%
Applied egg-rr87.1%
Taylor expanded in y around 0 40.0%
*-commutative40.0%
Simplified40.0%
Taylor expanded in x around 0 27.4%
herbie shell --seed 2024084
(FPCore (x y)
:name "Linear.Quaternion:$ccos from linear-1.19.1.3"
:precision binary64
(* (sin x) (/ (sinh y) y)))