
(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 8 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) (/ y (sinh y))))
double code(double x, double y) {
return sin(x) / (y / sinh(y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sin(x) / (y / sinh(y))
end function
public static double code(double x, double y) {
return Math.sin(x) / (y / Math.sinh(y));
}
def code(x, y): return math.sin(x) / (y / math.sinh(y))
function code(x, y) return Float64(sin(x) / Float64(y / sinh(y))) end
function tmp = code(x, y) tmp = sin(x) / (y / sinh(y)); end
code[x_, y_] := N[(N[Sin[x], $MachinePrecision] / N[(y / N[Sinh[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin x}{\frac{y}{\sinh y}}
\end{array}
Initial program 100.0%
associate-*r/89.7%
associate-/l*100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x y) :precision binary64 (let* ((t_0 (/ (sinh y) y))) (if (<= t_0 2.0) (sin x) (* x t_0))))
double code(double x, double y) {
double t_0 = sinh(y) / y;
double tmp;
if (t_0 <= 2.0) {
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 <= 2.0d0) 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 <= 2.0) {
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 <= 2.0: 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 <= 2.0) 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 <= 2.0) 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, 2.0], 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 2:\\
\;\;\;\;\sin x\\
\mathbf{else}:\\
\;\;\;\;x \cdot t_0\\
\end{array}
\end{array}
if (/.f64 (sinh.f64 y) y) < 2Initial program 100.0%
associate-*r/79.2%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in y around 0 98.7%
if 2 < (/.f64 (sinh.f64 y) y) Initial program 100.0%
*-commutative100.0%
associate-/r/76.7%
Simplified76.7%
Taylor expanded in x around 0 56.6%
associate-/r/79.8%
Applied egg-rr79.8%
Final simplification89.2%
(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 2.1e+53) (sin x) (/ (* x y) y)))
double code(double x, double y) {
double tmp;
if (y <= 2.1e+53) {
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 <= 2.1d+53) 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 <= 2.1e+53) {
tmp = Math.sin(x);
} else {
tmp = (x * y) / y;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 2.1e+53: tmp = math.sin(x) else: tmp = (x * y) / y return tmp
function code(x, y) tmp = 0.0 if (y <= 2.1e+53) 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 <= 2.1e+53) tmp = sin(x); else tmp = (x * y) / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 2.1e+53], N[Sin[x], $MachinePrecision], N[(N[(x * y), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.1 \cdot 10^{+53}:\\
\;\;\;\;\sin x\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{y}\\
\end{array}
\end{array}
if y < 2.1000000000000002e53Initial program 100.0%
associate-*r/86.7%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in y around 0 64.3%
if 2.1000000000000002e53 < y Initial program 100.0%
*-commutative100.0%
associate-/r/75.9%
Simplified75.9%
Taylor expanded in y around 0 2.6%
Taylor expanded in x around 0 2.6%
*-un-lft-identity2.6%
div-inv2.6%
times-frac27.1%
Applied egg-rr27.1%
frac-times2.6%
*-un-lft-identity2.6%
div-inv2.6%
associate-/l*27.1%
Applied egg-rr27.1%
Final simplification55.9%
(FPCore (x y) :precision binary64 (if (<= y 55.0) (/ y (+ (* 0.16666666666666666 (* x y)) (/ y x))) (/ (* x y) y)))
double code(double x, double y) {
double tmp;
if (y <= 55.0) {
tmp = y / ((0.16666666666666666 * (x * y)) + (y / 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 <= 55.0d0) then
tmp = y / ((0.16666666666666666d0 * (x * y)) + (y / x))
else
tmp = (x * y) / y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 55.0) {
tmp = y / ((0.16666666666666666 * (x * y)) + (y / x));
} else {
tmp = (x * y) / y;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 55.0: tmp = y / ((0.16666666666666666 * (x * y)) + (y / x)) else: tmp = (x * y) / y return tmp
function code(x, y) tmp = 0.0 if (y <= 55.0) tmp = Float64(y / Float64(Float64(0.16666666666666666 * Float64(x * y)) + Float64(y / x))); else tmp = Float64(Float64(x * y) / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 55.0) tmp = y / ((0.16666666666666666 * (x * y)) + (y / x)); else tmp = (x * y) / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 55.0], N[(y / N[(N[(0.16666666666666666 * N[(x * y), $MachinePrecision]), $MachinePrecision] + N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * y), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 55:\\
\;\;\;\;\frac{y}{0.16666666666666666 \cdot \left(x \cdot y\right) + \frac{y}{x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{y}\\
\end{array}
\end{array}
if y < 55Initial program 100.0%
*-commutative100.0%
associate-/r/91.2%
Simplified91.2%
Taylor expanded in y around 0 67.7%
Taylor expanded in x around 0 33.4%
if 55 < y Initial program 100.0%
*-commutative100.0%
associate-/r/79.7%
Simplified79.7%
Taylor expanded in y around 0 2.6%
Taylor expanded in x around 0 2.7%
*-un-lft-identity2.7%
div-inv2.7%
times-frac23.3%
Applied egg-rr23.3%
frac-times2.7%
*-un-lft-identity2.7%
div-inv2.7%
associate-/l*23.3%
Applied egg-rr23.3%
Final simplification30.6%
(FPCore (x y) :precision binary64 (if (<= y 59.0) (/ 1.0 (+ (* x 0.16666666666666666) (/ 1.0 x))) (/ (* x y) y)))
double code(double x, double y) {
double tmp;
if (y <= 59.0) {
tmp = 1.0 / ((x * 0.16666666666666666) + (1.0 / 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 <= 59.0d0) then
tmp = 1.0d0 / ((x * 0.16666666666666666d0) + (1.0d0 / x))
else
tmp = (x * y) / y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 59.0) {
tmp = 1.0 / ((x * 0.16666666666666666) + (1.0 / x));
} else {
tmp = (x * y) / y;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 59.0: tmp = 1.0 / ((x * 0.16666666666666666) + (1.0 / x)) else: tmp = (x * y) / y return tmp
function code(x, y) tmp = 0.0 if (y <= 59.0) tmp = Float64(1.0 / Float64(Float64(x * 0.16666666666666666) + Float64(1.0 / x))); else tmp = Float64(Float64(x * y) / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 59.0) tmp = 1.0 / ((x * 0.16666666666666666) + (1.0 / x)); else tmp = (x * y) / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 59.0], N[(1.0 / N[(N[(x * 0.16666666666666666), $MachinePrecision] + N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * y), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 59:\\
\;\;\;\;\frac{1}{x \cdot 0.16666666666666666 + \frac{1}{x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{y}\\
\end{array}
\end{array}
if y < 59Initial program 100.0%
*-commutative100.0%
associate-/r/91.2%
Simplified91.2%
Taylor expanded in y around 0 67.7%
Taylor expanded in x around 0 33.4%
Taylor expanded in y around 0 33.4%
if 59 < y Initial program 100.0%
*-commutative100.0%
associate-/r/79.7%
Simplified79.7%
Taylor expanded in y around 0 2.6%
Taylor expanded in x around 0 2.7%
*-un-lft-identity2.7%
div-inv2.7%
times-frac23.3%
Applied egg-rr23.3%
frac-times2.7%
*-un-lft-identity2.7%
div-inv2.7%
associate-/l*23.3%
Applied egg-rr23.3%
Final simplification30.6%
(FPCore (x y) :precision binary64 (if (<= y 1e+41) x (/ (* x y) y)))
double code(double x, double y) {
double tmp;
if (y <= 1e+41) {
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 <= 1d+41) 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 <= 1e+41) {
tmp = x;
} else {
tmp = (x * y) / y;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 1e+41: tmp = x else: tmp = (x * y) / y return tmp
function code(x, y) tmp = 0.0 if (y <= 1e+41) tmp = x; else tmp = Float64(Float64(x * y) / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 1e+41) tmp = x; else tmp = (x * y) / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 1e+41], x, N[(N[(x * y), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 10^{+41}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{y}\\
\end{array}
\end{array}
if y < 1.00000000000000001e41Initial program 100.0%
*-commutative100.0%
associate-/r/91.6%
Simplified91.6%
Taylor expanded in y around 0 64.7%
Taylor expanded in x around 0 32.1%
if 1.00000000000000001e41 < y Initial program 100.0%
*-commutative100.0%
associate-/r/76.7%
Simplified76.7%
Taylor expanded in y around 0 2.6%
Taylor expanded in x around 0 2.6%
*-un-lft-identity2.6%
div-inv2.6%
times-frac26.3%
Applied egg-rr26.3%
frac-times2.6%
*-un-lft-identity2.6%
div-inv2.6%
associate-/l*26.3%
Applied egg-rr26.3%
Final simplification30.7%
(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/88.1%
Simplified88.1%
Taylor expanded in y around 0 50.1%
Taylor expanded in x around 0 25.2%
Final simplification25.2%
herbie shell --seed 2023336
(FPCore (x y)
:name "Linear.Quaternion:$ccos from linear-1.19.1.3"
:precision binary64
(* (sin x) (/ (sinh y) y)))