
(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 (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%
Taylor expanded in y around 0 98.4%
if 2 < (/.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 72.8%
associate-*r/72.8%
*-commutative72.8%
associate-/r*72.8%
associate-*r/72.8%
*-commutative72.8%
associate-/r/72.8%
rec-exp72.8%
sinh-def72.8%
Simplified72.8%
associate-/r/72.8%
clear-num72.8%
Applied egg-rr72.8%
Final simplification85.9%
(FPCore (x y) :precision binary64 (if (<= y 105000.0) (sin x) (* -0.16666666666666666 (pow x 3.0))))
double code(double x, double y) {
double tmp;
if (y <= 105000.0) {
tmp = sin(x);
} else {
tmp = -0.16666666666666666 * pow(x, 3.0);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 105000.0d0) then
tmp = sin(x)
else
tmp = (-0.16666666666666666d0) * (x ** 3.0d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 105000.0) {
tmp = Math.sin(x);
} else {
tmp = -0.16666666666666666 * Math.pow(x, 3.0);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 105000.0: tmp = math.sin(x) else: tmp = -0.16666666666666666 * math.pow(x, 3.0) return tmp
function code(x, y) tmp = 0.0 if (y <= 105000.0) tmp = sin(x); else tmp = Float64(-0.16666666666666666 * (x ^ 3.0)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 105000.0) tmp = sin(x); else tmp = -0.16666666666666666 * (x ^ 3.0); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 105000.0], N[Sin[x], $MachinePrecision], N[(-0.16666666666666666 * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 105000:\\
\;\;\;\;\sin x\\
\mathbf{else}:\\
\;\;\;\;-0.16666666666666666 \cdot {x}^{3}\\
\end{array}
\end{array}
if y < 105000Initial program 100.0%
Taylor expanded in y around 0 64.2%
if 105000 < 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.7%
Taylor expanded in x around 0 20.4%
distribute-rgt-in20.4%
*-lft-identity20.4%
associate-*l*20.4%
unpow220.4%
unpow320.4%
Simplified20.4%
Taylor expanded in x around inf 20.1%
(FPCore (x y) :precision binary64 (if (<= y 2.1e+145) (sin x) (/ 1.0 (* y (/ (/ 1.0 y) x)))))
double code(double x, double y) {
double tmp;
if (y <= 2.1e+145) {
tmp = sin(x);
} else {
tmp = 1.0 / (y * ((1.0 / y) / x));
}
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+145) then
tmp = sin(x)
else
tmp = 1.0d0 / (y * ((1.0d0 / y) / x))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 2.1e+145) {
tmp = Math.sin(x);
} else {
tmp = 1.0 / (y * ((1.0 / y) / x));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 2.1e+145: tmp = math.sin(x) else: tmp = 1.0 / (y * ((1.0 / y) / x)) return tmp
function code(x, y) tmp = 0.0 if (y <= 2.1e+145) tmp = sin(x); else tmp = Float64(1.0 / Float64(y * Float64(Float64(1.0 / y) / x))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 2.1e+145) tmp = sin(x); else tmp = 1.0 / (y * ((1.0 / y) / x)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 2.1e+145], N[Sin[x], $MachinePrecision], N[(1.0 / N[(y * N[(N[(1.0 / y), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.1 \cdot 10^{+145}:\\
\;\;\;\;\sin x\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{y \cdot \frac{\frac{1}{y}}{x}}\\
\end{array}
\end{array}
if y < 2.09999999999999989e145Initial program 100.0%
Taylor expanded in y around 0 56.7%
if 2.09999999999999989e145 < 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%
*-commutative2.8%
Simplified2.8%
Taylor expanded in x around 0 30.4%
clear-num30.4%
associate-/r/30.4%
*-commutative30.4%
associate-/r*30.4%
Applied egg-rr30.4%
Final simplification54.3%
(FPCore (x y) :precision binary64 (if (<= y 3.1e+93) x (/ 1.0 (* y (/ (/ 1.0 y) x)))))
double code(double x, double y) {
double tmp;
if (y <= 3.1e+93) {
tmp = x;
} else {
tmp = 1.0 / (y * ((1.0 / y) / x));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 3.1d+93) then
tmp = x
else
tmp = 1.0d0 / (y * ((1.0d0 / y) / x))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 3.1e+93) {
tmp = x;
} else {
tmp = 1.0 / (y * ((1.0 / y) / x));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 3.1e+93: tmp = x else: tmp = 1.0 / (y * ((1.0 / y) / x)) return tmp
function code(x, y) tmp = 0.0 if (y <= 3.1e+93) tmp = x; else tmp = Float64(1.0 / Float64(y * Float64(Float64(1.0 / y) / x))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 3.1e+93) tmp = x; else tmp = 1.0 / (y * ((1.0 / y) / x)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 3.1e+93], x, N[(1.0 / N[(y * N[(N[(1.0 / y), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.1 \cdot 10^{+93}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{y \cdot \frac{\frac{1}{y}}{x}}\\
\end{array}
\end{array}
if y < 3.10000000000000019e93Initial program 100.0%
associate-*r/85.7%
clear-num85.6%
*-commutative85.6%
Applied egg-rr85.6%
Taylor expanded in y around 0 57.8%
Taylor expanded in x around 0 29.2%
if 3.10000000000000019e93 < 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.7%
*-commutative2.7%
Simplified2.7%
Taylor expanded in x around 0 25.5%
clear-num25.5%
associate-/r/25.5%
*-commutative25.5%
associate-/r*25.5%
Applied egg-rr25.5%
Final simplification28.7%
(FPCore (x y) :precision binary64 (if (<= x 20000000000000.0) x (* (/ 1.0 y) (* x y))))
double code(double x, double y) {
double tmp;
if (x <= 20000000000000.0) {
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 <= 20000000000000.0d0) 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 <= 20000000000000.0) {
tmp = x;
} else {
tmp = (1.0 / y) * (x * y);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 20000000000000.0: tmp = x else: tmp = (1.0 / y) * (x * y) return tmp
function code(x, y) tmp = 0.0 if (x <= 20000000000000.0) 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 <= 20000000000000.0) tmp = x; else tmp = (1.0 / y) * (x * y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 20000000000000.0], x, N[(N[(1.0 / y), $MachinePrecision] * N[(x * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 20000000000000:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{y} \cdot \left(x \cdot y\right)\\
\end{array}
\end{array}
if x < 2e13Initial program 100.0%
associate-*r/83.6%
clear-num83.5%
*-commutative83.5%
Applied egg-rr83.5%
Taylor expanded in y around 0 53.1%
Taylor expanded in x around 0 33.3%
if 2e13 < x Initial program 100.0%
associate-*r/99.9%
clear-num99.8%
*-commutative99.8%
Applied egg-rr99.8%
Taylor expanded in y around 0 46.2%
*-commutative46.2%
Simplified46.2%
Taylor expanded in x around 0 8.8%
associate-/r/8.8%
*-commutative8.8%
Applied egg-rr8.8%
Final simplification27.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%
associate-*r/87.4%
clear-num87.3%
*-commutative87.3%
Applied egg-rr87.3%
Taylor expanded in y around 0 51.5%
Taylor expanded in x around 0 26.2%
herbie shell --seed 2024086
(FPCore (x y)
:name "Linear.Quaternion:$ccos from linear-1.19.1.3"
:precision binary64
(* (sin x) (/ (sinh y) y)))