
(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 5 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.00000000002) (sin x) (* x t_0))))
double code(double x, double y) {
double t_0 = sinh(y) / y;
double tmp;
if (t_0 <= 1.00000000002) {
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.00000000002d0) 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.00000000002) {
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.00000000002: 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.00000000002) 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.00000000002) 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.00000000002], 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.00000000002:\\
\;\;\;\;\sin x\\
\mathbf{else}:\\
\;\;\;\;x \cdot t_0\\
\end{array}
\end{array}
if (/.f64 (sinh.f64 y) y) < 1.00000000002Initial program 100.0%
Taylor expanded in y around 0 99.9%
if 1.00000000002 < (/.f64 (sinh.f64 y) y) Initial program 100.0%
*-commutative100.0%
associate-/r/74.6%
Simplified74.6%
Taylor expanded in x around 0 54.7%
associate-/r/80.1%
Applied egg-rr80.1%
Final simplification90.2%
(FPCore (x y) :precision binary64 (if (<= y 1.2e-5) (sin x) (+ x (* 0.16666666666666666 (* x (* y y))))))
double code(double x, double y) {
double tmp;
if (y <= 1.2e-5) {
tmp = sin(x);
} else {
tmp = x + (0.16666666666666666 * (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.2d-5) then
tmp = sin(x)
else
tmp = x + (0.16666666666666666d0 * (x * (y * y)))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 1.2e-5) {
tmp = Math.sin(x);
} else {
tmp = x + (0.16666666666666666 * (x * (y * y)));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 1.2e-5: tmp = math.sin(x) else: tmp = x + (0.16666666666666666 * (x * (y * y))) return tmp
function code(x, y) tmp = 0.0 if (y <= 1.2e-5) tmp = sin(x); else tmp = Float64(x + Float64(0.16666666666666666 * Float64(x * Float64(y * y)))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 1.2e-5) tmp = sin(x); else tmp = x + (0.16666666666666666 * (x * (y * y))); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 1.2e-5], N[Sin[x], $MachinePrecision], N[(x + N[(0.16666666666666666 * N[(x * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.2 \cdot 10^{-5}:\\
\;\;\;\;\sin x\\
\mathbf{else}:\\
\;\;\;\;x + 0.16666666666666666 \cdot \left(x \cdot \left(y \cdot y\right)\right)\\
\end{array}
\end{array}
if y < 1.2e-5Initial program 100.0%
Taylor expanded in y around 0 70.1%
if 1.2e-5 < y Initial program 100.0%
*-commutative100.0%
associate-/r/76.1%
Simplified76.1%
Taylor expanded in x around 0 53.7%
Taylor expanded in y around 0 53.5%
unpow253.5%
Simplified53.5%
Final simplification65.7%
(FPCore (x y) :precision binary64 (+ x (* 0.16666666666666666 (* x (* y y)))))
double code(double x, double y) {
return x + (0.16666666666666666 * (x * (y * y)));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x + (0.16666666666666666d0 * (x * (y * y)))
end function
public static double code(double x, double y) {
return x + (0.16666666666666666 * (x * (y * y)));
}
def code(x, y): return x + (0.16666666666666666 * (x * (y * y)))
function code(x, y) return Float64(x + Float64(0.16666666666666666 * Float64(x * Float64(y * y)))) end
function tmp = code(x, y) tmp = x + (0.16666666666666666 * (x * (y * y))); end
code[x_, y_] := N[(x + N[(0.16666666666666666 * N[(x * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + 0.16666666666666666 \cdot \left(x \cdot \left(y \cdot y\right)\right)
\end{array}
Initial program 100.0%
*-commutative100.0%
associate-/r/87.4%
Simplified87.4%
Taylor expanded in x around 0 53.5%
Taylor expanded in y around 0 52.4%
unpow252.4%
Simplified52.4%
Final simplification52.4%
(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-/r/87.4%
Simplified87.4%
Taylor expanded in y around 0 52.3%
Taylor expanded in x around 0 28.4%
Final simplification28.4%
herbie shell --seed 2023271
(FPCore (x y)
:name "Linear.Quaternion:$ccos from linear-1.19.1.3"
:precision binary64
(* (sin x) (/ (sinh y) y)))