
(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 9 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%
clear-num100.0%
un-div-inv100.0%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (x y) :precision binary64 (if (<= (/ (sinh y) y) 1.0) (sin x) (/ 1.0 (/ (/ y (sinh y)) x))))
double code(double x, double y) {
double tmp;
if ((sinh(y) / y) <= 1.0) {
tmp = sin(x);
} else {
tmp = 1.0 / ((y / sinh(y)) / x);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((sinh(y) / y) <= 1.0d0) then
tmp = sin(x)
else
tmp = 1.0d0 / ((y / sinh(y)) / x)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((Math.sinh(y) / y) <= 1.0) {
tmp = Math.sin(x);
} else {
tmp = 1.0 / ((y / Math.sinh(y)) / x);
}
return tmp;
}
def code(x, y): tmp = 0 if (math.sinh(y) / y) <= 1.0: tmp = math.sin(x) else: tmp = 1.0 / ((y / math.sinh(y)) / x) return tmp
function code(x, y) tmp = 0.0 if (Float64(sinh(y) / y) <= 1.0) tmp = sin(x); else tmp = Float64(1.0 / Float64(Float64(y / sinh(y)) / x)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((sinh(y) / y) <= 1.0) tmp = sin(x); else tmp = 1.0 / ((y / sinh(y)) / x); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision], 1.0], N[Sin[x], $MachinePrecision], N[(1.0 / N[(N[(y / N[Sinh[y], $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{\sinh y}{y} \leq 1:\\
\;\;\;\;\sin x\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{\frac{y}{\sinh y}}{x}}\\
\end{array}
\end{array}
if (/.f64 (sinh.f64 y) y) < 1Initial program 100.0%
Taylor expanded in y around 0 100.0%
if 1 < (/.f64 (sinh.f64 y) y) Initial program 100.0%
associate-*r/100.0%
clear-num100.0%
*-commutative100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 76.7%
associate-*r/76.0%
*-commutative76.0%
associate-/r*76.0%
associate-*r/76.7%
*-commutative76.7%
associate-/r/76.7%
rec-exp76.8%
sinh-def76.8%
Simplified76.8%
Final simplification87.5%
(FPCore (x y) :precision binary64 (let* ((t_0 (/ (sinh y) y))) (if (<= t_0 1.0) (sin x) (* x t_0))))
double code(double x, double y) {
double t_0 = sinh(y) / y;
double tmp;
if (t_0 <= 1.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 <= 1.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 <= 1.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 <= 1.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 <= 1.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 <= 1.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, 1.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 1:\\
\;\;\;\;\sin x\\
\mathbf{else}:\\
\;\;\;\;x \cdot t\_0\\
\end{array}
\end{array}
if (/.f64 (sinh.f64 y) y) < 1Initial program 100.0%
Taylor expanded in y around 0 100.0%
if 1 < (/.f64 (sinh.f64 y) y) Initial program 100.0%
associate-*r/100.0%
clear-num100.0%
*-commutative100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 76.7%
associate-*r/76.0%
*-commutative76.0%
associate-/r*76.0%
associate-*r/76.7%
*-commutative76.7%
associate-/r/76.7%
rec-exp76.8%
sinh-def76.8%
Simplified76.8%
associate-/r/76.8%
clear-num76.8%
Applied egg-rr76.8%
Final simplification87.5%
(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 0.00031) (sin x) (* (sinh y) (/ x y))))
double code(double x, double y) {
double tmp;
if (y <= 0.00031) {
tmp = sin(x);
} else {
tmp = sinh(y) * (x / y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 0.00031d0) then
tmp = sin(x)
else
tmp = sinh(y) * (x / y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 0.00031) {
tmp = Math.sin(x);
} else {
tmp = Math.sinh(y) * (x / y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 0.00031: tmp = math.sin(x) else: tmp = math.sinh(y) * (x / y) return tmp
function code(x, y) tmp = 0.0 if (y <= 0.00031) tmp = sin(x); else tmp = Float64(sinh(y) * Float64(x / y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 0.00031) tmp = sin(x); else tmp = sinh(y) * (x / y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 0.00031], N[Sin[x], $MachinePrecision], N[(N[Sinh[y], $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 0.00031:\\
\;\;\;\;\sin x\\
\mathbf{else}:\\
\;\;\;\;\sinh y \cdot \frac{x}{y}\\
\end{array}
\end{array}
if y < 3.1e-4Initial program 100.0%
Taylor expanded in y around 0 66.2%
if 3.1e-4 < y Initial program 99.9%
associate-*r/99.9%
clear-num100.0%
*-commutative100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 77.2%
associate-*r/77.2%
*-commutative77.2%
associate-/r*77.2%
associate-*r/77.2%
*-commutative77.2%
associate-/r/77.2%
rec-exp77.2%
sinh-def77.3%
Simplified77.3%
clear-num77.3%
associate-/r/54.7%
Applied egg-rr54.7%
Final simplification62.8%
(FPCore (x y) :precision binary64 (if (<= y 21.0) (sin x) (* (/ 1.0 y) (* x y))))
double code(double x, double y) {
double tmp;
if (y <= 21.0) {
tmp = sin(x);
} else {
tmp = (1.0 / y) * (x * y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 21.0d0) then
tmp = sin(x)
else
tmp = (1.0d0 / y) * (x * y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 21.0) {
tmp = Math.sin(x);
} else {
tmp = (1.0 / y) * (x * y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 21.0: tmp = math.sin(x) else: tmp = (1.0 / y) * (x * y) return tmp
function code(x, y) tmp = 0.0 if (y <= 21.0) tmp = sin(x); else tmp = Float64(Float64(1.0 / y) * Float64(x * y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 21.0) tmp = sin(x); else tmp = (1.0 / y) * (x * y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 21.0], N[Sin[x], $MachinePrecision], N[(N[(1.0 / y), $MachinePrecision] * N[(x * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 21:\\
\;\;\;\;\sin x\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{y} \cdot \left(x \cdot y\right)\\
\end{array}
\end{array}
if y < 21Initial program 100.0%
Taylor expanded in y around 0 66.0%
if 21 < y Initial program 100.0%
associate-*r/100.0%
clear-num100.0%
*-commutative100.0%
Applied egg-rr100.0%
Taylor expanded in y around 0 2.8%
Taylor expanded in x around 0 7.6%
associate-/r/7.6%
*-commutative7.6%
Applied egg-rr7.6%
Final simplification49.3%
(FPCore (x y) :precision binary64 (if (<= y 3.8) (/ 1.0 (+ (* x 0.16666666666666666) (/ 1.0 x))) (* (/ 1.0 y) (* x y))))
double code(double x, double y) {
double tmp;
if (y <= 3.8) {
tmp = 1.0 / ((x * 0.16666666666666666) + (1.0 / x));
} else {
tmp = (1.0 / y) * (x * y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 3.8d0) then
tmp = 1.0d0 / ((x * 0.16666666666666666d0) + (1.0d0 / x))
else
tmp = (1.0d0 / y) * (x * y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 3.8) {
tmp = 1.0 / ((x * 0.16666666666666666) + (1.0 / x));
} else {
tmp = (1.0 / y) * (x * y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 3.8: tmp = 1.0 / ((x * 0.16666666666666666) + (1.0 / x)) else: tmp = (1.0 / y) * (x * y) return tmp
function code(x, y) tmp = 0.0 if (y <= 3.8) tmp = Float64(1.0 / Float64(Float64(x * 0.16666666666666666) + Float64(1.0 / x))); else tmp = Float64(Float64(1.0 / y) * Float64(x * y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 3.8) tmp = 1.0 / ((x * 0.16666666666666666) + (1.0 / x)); else tmp = (1.0 / y) * (x * y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 3.8], N[(1.0 / N[(N[(x * 0.16666666666666666), $MachinePrecision] + N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / y), $MachinePrecision] * N[(x * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.8:\\
\;\;\;\;\frac{1}{x \cdot 0.16666666666666666 + \frac{1}{x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{y} \cdot \left(x \cdot y\right)\\
\end{array}
\end{array}
if y < 3.7999999999999998Initial program 100.0%
associate-*r/83.6%
clear-num83.5%
*-commutative83.5%
Applied egg-rr83.5%
Taylor expanded in y around 0 65.8%
Taylor expanded in x around 0 34.3%
if 3.7999999999999998 < y Initial program 100.0%
associate-*r/100.0%
clear-num100.0%
*-commutative100.0%
Applied egg-rr100.0%
Taylor expanded in y around 0 2.8%
Taylor expanded in x around 0 7.6%
associate-/r/7.6%
*-commutative7.6%
Applied egg-rr7.6%
Final simplification26.7%
(FPCore (x y) :precision binary64 (if (<= x 1e+53) x (* (/ 1.0 y) (* x y))))
double code(double x, double y) {
double tmp;
if (x <= 1e+53) {
tmp = x;
} else {
tmp = (1.0 / y) * (x * 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+53) then
tmp = x
else
tmp = (1.0d0 / y) * (x * y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= 1e+53) {
tmp = x;
} else {
tmp = (1.0 / y) * (x * y);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 1e+53: tmp = x else: tmp = (1.0 / y) * (x * y) return tmp
function code(x, y) tmp = 0.0 if (x <= 1e+53) tmp = x; else tmp = Float64(Float64(1.0 / y) * Float64(x * y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 1e+53) tmp = x; else tmp = (1.0 / y) * (x * y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 1e+53], x, N[(N[(1.0 / y), $MachinePrecision] * N[(x * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 10^{+53}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{y} \cdot \left(x \cdot y\right)\\
\end{array}
\end{array}
if x < 9.9999999999999999e52Initial program 100.0%
associate-*r/85.6%
clear-num85.5%
*-commutative85.5%
Applied egg-rr85.5%
Taylor expanded in y around 0 49.2%
Taylor expanded in x around 0 30.3%
if 9.9999999999999999e52 < x Initial program 100.0%
associate-*r/99.9%
clear-num99.8%
*-commutative99.8%
Applied egg-rr99.8%
Taylor expanded in y around 0 42.1%
Taylor expanded in x around 0 24.7%
associate-/r/24.7%
*-commutative24.7%
Applied egg-rr24.7%
Final simplification29.3%
(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%
associate-*r/88.3%
clear-num88.2%
*-commutative88.2%
Applied egg-rr88.2%
Taylor expanded in y around 0 47.8%
Taylor expanded in x around 0 25.2%
Final simplification25.2%
herbie shell --seed 2024040
(FPCore (x y)
:name "Linear.Quaternion:$ccos from linear-1.19.1.3"
:precision binary64
(* (sin x) (/ (sinh y) y)))