
(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 (<= (/ (sinh y) y) 1.02) (sin x) (/ (* x (sinh y)) y)))
double code(double x, double y) {
double tmp;
if ((sinh(y) / y) <= 1.02) {
tmp = sin(x);
} else {
tmp = (x * sinh(y)) / y;
}
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.02d0) then
tmp = sin(x)
else
tmp = (x * sinh(y)) / y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((Math.sinh(y) / y) <= 1.02) {
tmp = Math.sin(x);
} else {
tmp = (x * Math.sinh(y)) / y;
}
return tmp;
}
def code(x, y): tmp = 0 if (math.sinh(y) / y) <= 1.02: tmp = math.sin(x) else: tmp = (x * math.sinh(y)) / y return tmp
function code(x, y) tmp = 0.0 if (Float64(sinh(y) / y) <= 1.02) tmp = sin(x); else tmp = Float64(Float64(x * sinh(y)) / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((sinh(y) / y) <= 1.02) tmp = sin(x); else tmp = (x * sinh(y)) / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision], 1.02], N[Sin[x], $MachinePrecision], N[(N[(x * N[Sinh[y], $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{\sinh y}{y} \leq 1.02:\\
\;\;\;\;\sin x\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \sinh y}{y}\\
\end{array}
\end{array}
if (/.f64 (sinh.f64 y) y) < 1.02Initial program 100.0%
Taylor expanded in y around 0 99.3%
if 1.02 < (/.f64 (sinh.f64 y) y) Initial program 100.0%
Taylor expanded in x around 0 84.2%
associate-*r/84.2%
Applied egg-rr84.2%
(FPCore (x y) :precision binary64 (let* ((t_0 (/ (sinh y) y))) (if (<= t_0 1.02) (sin x) (* x t_0))))
double code(double x, double y) {
double t_0 = sinh(y) / y;
double tmp;
if (t_0 <= 1.02) {
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.02d0) 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.02) {
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.02: 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.02) 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.02) 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.02], 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.02:\\
\;\;\;\;\sin x\\
\mathbf{else}:\\
\;\;\;\;x \cdot t\_0\\
\end{array}
\end{array}
if (/.f64 (sinh.f64 y) y) < 1.02Initial program 100.0%
Taylor expanded in y around 0 99.3%
if 1.02 < (/.f64 (sinh.f64 y) y) Initial program 100.0%
Taylor expanded in x around 0 84.2%
(FPCore (x y) :precision binary64 (if (<= y 1.6e+44) (sin x) (* (/ 1.0 y) (* x y))))
double code(double x, double y) {
double tmp;
if (y <= 1.6e+44) {
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 <= 1.6d+44) 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 <= 1.6e+44) {
tmp = Math.sin(x);
} else {
tmp = (1.0 / y) * (x * y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 1.6e+44: tmp = math.sin(x) else: tmp = (1.0 / y) * (x * y) return tmp
function code(x, y) tmp = 0.0 if (y <= 1.6e+44) 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 <= 1.6e+44) tmp = sin(x); else tmp = (1.0 / y) * (x * y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 1.6e+44], 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 1.6 \cdot 10^{+44}:\\
\;\;\;\;\sin x\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{y} \cdot \left(x \cdot y\right)\\
\end{array}
\end{array}
if y < 1.60000000000000002e44Initial program 100.0%
Taylor expanded in y around 0 65.4%
if 1.60000000000000002e44 < y Initial program 100.0%
Taylor expanded in x around 0 89.1%
associate-*r/89.1%
Applied egg-rr89.1%
Taylor expanded in y around 0 23.4%
clear-num23.4%
associate-/r/23.4%
*-commutative23.4%
Applied egg-rr23.4%
Final simplification57.8%
(FPCore (x y) :precision binary64 (if (<= y 8.4e+43) (* x (+ 1.0 (* (* x x) -0.16666666666666666))) (* (/ 1.0 y) (* x y))))
double code(double x, double y) {
double tmp;
if (y <= 8.4e+43) {
tmp = x * (1.0 + ((x * x) * -0.16666666666666666));
} 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 <= 8.4d+43) then
tmp = x * (1.0d0 + ((x * x) * (-0.16666666666666666d0)))
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 <= 8.4e+43) {
tmp = x * (1.0 + ((x * x) * -0.16666666666666666));
} else {
tmp = (1.0 / y) * (x * y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 8.4e+43: tmp = x * (1.0 + ((x * x) * -0.16666666666666666)) else: tmp = (1.0 / y) * (x * y) return tmp
function code(x, y) tmp = 0.0 if (y <= 8.4e+43) tmp = Float64(x * Float64(1.0 + Float64(Float64(x * x) * -0.16666666666666666))); 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 <= 8.4e+43) tmp = x * (1.0 + ((x * x) * -0.16666666666666666)); else tmp = (1.0 / y) * (x * y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 8.4e+43], N[(x * N[(1.0 + N[(N[(x * x), $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / y), $MachinePrecision] * N[(x * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 8.4 \cdot 10^{+43}:\\
\;\;\;\;x \cdot \left(1 + \left(x \cdot x\right) \cdot -0.16666666666666666\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{y} \cdot \left(x \cdot y\right)\\
\end{array}
\end{array}
if y < 8.40000000000000007e43Initial program 100.0%
Taylor expanded in y around 0 65.4%
Taylor expanded in x around 0 40.6%
*-commutative40.6%
Simplified40.6%
unpow240.6%
Applied egg-rr40.6%
if 8.40000000000000007e43 < y Initial program 100.0%
Taylor expanded in x around 0 89.1%
associate-*r/89.1%
Applied egg-rr89.1%
Taylor expanded in y around 0 23.4%
clear-num23.4%
associate-/r/23.4%
*-commutative23.4%
Applied egg-rr23.4%
Final simplification37.5%
(FPCore (x y) :precision binary64 (if (<= y 2e+32) x (/ (* x y) y)))
double code(double x, double y) {
double tmp;
if (y <= 2e+32) {
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 <= 2d+32) 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 <= 2e+32) {
tmp = x;
} else {
tmp = (x * y) / y;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 2e+32: tmp = x else: tmp = (x * y) / y return tmp
function code(x, y) tmp = 0.0 if (y <= 2e+32) tmp = x; else tmp = Float64(Float64(x * y) / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 2e+32) tmp = x; else tmp = (x * y) / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 2e+32], x, N[(N[(x * y), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2 \cdot 10^{+32}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{y}\\
\end{array}
\end{array}
if y < 2.00000000000000011e32Initial program 100.0%
Taylor expanded in x around 0 65.1%
Taylor expanded in y around 0 38.3%
if 2.00000000000000011e32 < y Initial program 100.0%
Taylor expanded in x around 0 84.6%
associate-*r/84.6%
Applied egg-rr84.6%
Taylor expanded in y around 0 20.9%
(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%
Taylor expanded in x around 0 69.1%
Taylor expanded in y around 0 31.2%
herbie shell --seed 2024145
(FPCore (x y)
:name "Linear.Quaternion:$ccos from linear-1.19.1.3"
:precision binary64
(* (sin x) (/ (sinh y) y)))