
(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 10 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%
add-log-exp77.0%
*-un-lft-identity77.0%
log-prod77.0%
metadata-eval77.0%
add-log-exp100.0%
Applied egg-rr100.0%
+-lft-identity100.0%
associate-*r/87.1%
associate-*l/88.5%
associate-/r/100.0%
Simplified100.0%
(FPCore (x y) :precision binary64 (if (<= (/ (sinh y) y) 1.0) (sin x) (/ (* x (sinh y)) y)))
double code(double x, double y) {
double tmp;
if ((sinh(y) / y) <= 1.0) {
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.0d0) 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.0) {
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.0: 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.0) 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.0) 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.0], 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:\\
\;\;\;\;\sin x\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \sinh y}{y}\\
\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%
Taylor expanded in x around 0 75.8%
add-log-exp73.0%
*-un-lft-identity73.0%
log-prod73.0%
metadata-eval73.0%
add-log-exp75.8%
Applied egg-rr75.8%
+-lft-identity75.8%
associate-*r/75.8%
Simplified75.8%
(FPCore (x y) :precision binary64 (if (<= (/ (sinh y) y) 1.0) (sin x) (/ x (/ y (sinh y)))))
double code(double x, double y) {
double tmp;
if ((sinh(y) / y) <= 1.0) {
tmp = sin(x);
} else {
tmp = x / (y / sinh(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.0d0) then
tmp = sin(x)
else
tmp = x / (y / sinh(y))
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 = x / (y / Math.sinh(y));
}
return tmp;
}
def code(x, y): tmp = 0 if (math.sinh(y) / y) <= 1.0: tmp = math.sin(x) else: tmp = x / (y / math.sinh(y)) return tmp
function code(x, y) tmp = 0.0 if (Float64(sinh(y) / y) <= 1.0) tmp = sin(x); else tmp = Float64(x / Float64(y / sinh(y))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((sinh(y) / y) <= 1.0) tmp = sin(x); else tmp = x / (y / sinh(y)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision], 1.0], N[Sin[x], $MachinePrecision], N[(x / N[(y / N[Sinh[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{\sinh y}{y} \leq 1:\\
\;\;\;\;\sin x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{y}{\sinh y}}\\
\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%
Taylor expanded in x around 0 75.8%
clear-num75.8%
un-div-inv75.8%
Applied egg-rr75.8%
(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%
Taylor expanded in x around 0 75.8%
(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 (<= y 580.0) (sin x) (* x (+ 1.0 (* (/ (* x (* x y)) y) -0.16666666666666666)))))
double code(double x, double y) {
double tmp;
if (y <= 580.0) {
tmp = sin(x);
} else {
tmp = x * (1.0 + (((x * (x * y)) / y) * -0.16666666666666666));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 580.0d0) then
tmp = sin(x)
else
tmp = x * (1.0d0 + (((x * (x * y)) / y) * (-0.16666666666666666d0)))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 580.0) {
tmp = Math.sin(x);
} else {
tmp = x * (1.0 + (((x * (x * y)) / y) * -0.16666666666666666));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 580.0: tmp = math.sin(x) else: tmp = x * (1.0 + (((x * (x * y)) / y) * -0.16666666666666666)) return tmp
function code(x, y) tmp = 0.0 if (y <= 580.0) tmp = sin(x); else tmp = Float64(x * Float64(1.0 + Float64(Float64(Float64(x * Float64(x * y)) / y) * -0.16666666666666666))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 580.0) tmp = sin(x); else tmp = x * (1.0 + (((x * (x * y)) / y) * -0.16666666666666666)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 580.0], N[Sin[x], $MachinePrecision], N[(x * N[(1.0 + N[(N[(N[(x * N[(x * y), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 580:\\
\;\;\;\;\sin x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 + \frac{x \cdot \left(x \cdot y\right)}{y} \cdot -0.16666666666666666\right)\\
\end{array}
\end{array}
if y < 580Initial program 100.0%
Taylor expanded in y around 0 69.8%
if 580 < y Initial program 100.0%
Taylor expanded in y around 0 2.8%
Taylor expanded in x around 0 21.7%
*-commutative21.7%
Simplified21.7%
unpow221.7%
*-un-lft-identity21.7%
associate-*r*21.7%
*-inverses21.7%
div-inv21.7%
associate-*l*21.7%
div-inv21.7%
associate-*l/22.9%
*-commutative22.9%
Applied egg-rr22.9%
Final simplification56.3%
(FPCore (x y) :precision binary64 (if (<= y 4.5e+181) (* x (+ 1.0 (* -0.16666666666666666 (* x x)))) (* (* x y) (/ 1.0 y))))
double code(double x, double y) {
double tmp;
if (y <= 4.5e+181) {
tmp = x * (1.0 + (-0.16666666666666666 * (x * x)));
} else {
tmp = (x * y) * (1.0 / y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 4.5d+181) then
tmp = x * (1.0d0 + ((-0.16666666666666666d0) * (x * x)))
else
tmp = (x * y) * (1.0d0 / y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 4.5e+181) {
tmp = x * (1.0 + (-0.16666666666666666 * (x * x)));
} else {
tmp = (x * y) * (1.0 / y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 4.5e+181: tmp = x * (1.0 + (-0.16666666666666666 * (x * x))) else: tmp = (x * y) * (1.0 / y) return tmp
function code(x, y) tmp = 0.0 if (y <= 4.5e+181) tmp = Float64(x * Float64(1.0 + Float64(-0.16666666666666666 * Float64(x * x)))); else tmp = Float64(Float64(x * y) * Float64(1.0 / y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 4.5e+181) tmp = x * (1.0 + (-0.16666666666666666 * (x * x))); else tmp = (x * y) * (1.0 / y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 4.5e+181], N[(x * N[(1.0 + N[(-0.16666666666666666 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * y), $MachinePrecision] * N[(1.0 / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.5 \cdot 10^{+181}:\\
\;\;\;\;x \cdot \left(1 + -0.16666666666666666 \cdot \left(x \cdot x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot y\right) \cdot \frac{1}{y}\\
\end{array}
\end{array}
if y < 4.5e181Initial program 100.0%
Taylor expanded in y around 0 55.2%
Taylor expanded in x around 0 34.8%
*-commutative34.8%
Simplified34.8%
unpow234.8%
Applied egg-rr34.8%
if 4.5e181 < y Initial program 100.0%
Taylor expanded in x around 0 82.6%
add-log-exp82.6%
*-un-lft-identity82.6%
log-prod82.6%
metadata-eval82.6%
add-log-exp82.6%
Applied egg-rr82.6%
+-lft-identity82.6%
associate-*r/82.6%
Simplified82.6%
Taylor expanded in y around 0 31.8%
clear-num31.8%
associate-/r/31.8%
*-commutative31.8%
Applied egg-rr31.8%
Final simplification34.5%
(FPCore (x y) :precision binary64 (* x (+ 1.0 (* (/ (* x (* x y)) y) -0.16666666666666666))))
double code(double x, double y) {
return x * (1.0 + (((x * (x * y)) / y) * -0.16666666666666666));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x * (1.0d0 + (((x * (x * y)) / y) * (-0.16666666666666666d0)))
end function
public static double code(double x, double y) {
return x * (1.0 + (((x * (x * y)) / y) * -0.16666666666666666));
}
def code(x, y): return x * (1.0 + (((x * (x * y)) / y) * -0.16666666666666666))
function code(x, y) return Float64(x * Float64(1.0 + Float64(Float64(Float64(x * Float64(x * y)) / y) * -0.16666666666666666))) end
function tmp = code(x, y) tmp = x * (1.0 + (((x * (x * y)) / y) * -0.16666666666666666)); end
code[x_, y_] := N[(x * N[(1.0 + N[(N[(N[(x * N[(x * y), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(1 + \frac{x \cdot \left(x \cdot y\right)}{y} \cdot -0.16666666666666666\right)
\end{array}
Initial program 100.0%
Taylor expanded in y around 0 50.5%
Taylor expanded in x around 0 33.0%
*-commutative33.0%
Simplified33.0%
unpow233.0%
*-un-lft-identity33.0%
associate-*r*33.0%
*-inverses33.0%
div-inv33.0%
associate-*l*33.7%
div-inv33.7%
associate-*l/34.4%
*-commutative34.4%
Applied egg-rr34.4%
Final simplification34.4%
(FPCore (x y) :precision binary64 (if (<= x 5.6e+113) x (/ (* x y) y)))
double code(double x, double y) {
double tmp;
if (x <= 5.6e+113) {
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 (x <= 5.6d+113) 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 (x <= 5.6e+113) {
tmp = x;
} else {
tmp = (x * y) / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 5.6e+113: tmp = x else: tmp = (x * y) / y return tmp
function code(x, y) tmp = 0.0 if (x <= 5.6e+113) tmp = x; else tmp = Float64(Float64(x * y) / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 5.6e+113) tmp = x; else tmp = (x * y) / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 5.6e+113], x, N[(N[(x * y), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 5.6 \cdot 10^{+113}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{y}\\
\end{array}
\end{array}
if x < 5.59999999999999995e113Initial program 100.0%
Taylor expanded in x around 0 69.1%
Taylor expanded in y around 0 30.0%
if 5.59999999999999995e113 < x Initial program 100.0%
Taylor expanded in x around 0 29.8%
add-log-exp29.5%
*-un-lft-identity29.5%
log-prod29.5%
metadata-eval29.5%
add-log-exp29.8%
Applied egg-rr29.8%
+-lft-identity29.8%
associate-*r/29.8%
Simplified29.8%
Taylor expanded in y around 0 14.1%
(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 62.6%
Taylor expanded in y around 0 25.5%
herbie shell --seed 2024154
(FPCore (x y)
:name "Linear.Quaternion:$ccos from linear-1.19.1.3"
:precision binary64
(* (sin x) (/ (sinh y) y)))