
(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.00000001) (sin x) (/ (* x (sinh y)) y)))
double code(double x, double y) {
double tmp;
if ((sinh(y) / y) <= 1.00000001) {
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.00000001d0) 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.00000001) {
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.00000001: 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.00000001) 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.00000001) 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.00000001], 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.00000001:\\
\;\;\;\;\sin x\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \sinh y}{y}\\
\end{array}
\end{array}
if (/.f64 (sinh.f64 y) y) < 1.0000000099999999Initial program 100.0%
Taylor expanded in y around 0 99.8%
if 1.0000000099999999 < (/.f64 (sinh.f64 y) y) Initial program 100.0%
Taylor expanded in x around 0 75.7%
add-log-exp74.4%
*-un-lft-identity74.4%
log-prod74.4%
metadata-eval74.4%
add-log-exp75.7%
Applied egg-rr75.7%
+-lft-identity75.7%
associate-*r/75.7%
Simplified75.7%
(FPCore (x y) :precision binary64 (let* ((t_0 (/ (sinh y) y))) (if (<= t_0 1.002) (sin x) (* x t_0))))
double code(double x, double y) {
double t_0 = sinh(y) / y;
double tmp;
if (t_0 <= 1.002) {
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.002d0) 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.002) {
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.002: 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.002) 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.002) 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.002], 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.002:\\
\;\;\;\;\sin x\\
\mathbf{else}:\\
\;\;\;\;x \cdot t\_0\\
\end{array}
\end{array}
if (/.f64 (sinh.f64 y) y) < 1.002Initial program 100.0%
Taylor expanded in y around 0 99.0%
if 1.002 < (/.f64 (sinh.f64 y) y) Initial program 100.0%
Taylor expanded in x around 0 76.1%
(FPCore (x y) :precision binary64 (if (<= y 680.0) (sin x) (if (<= y 3.7e+127) (* -0.16666666666666666 (pow x 3.0)) (/ (* x y) y))))
double code(double x, double y) {
double tmp;
if (y <= 680.0) {
tmp = sin(x);
} else if (y <= 3.7e+127) {
tmp = -0.16666666666666666 * pow(x, 3.0);
} 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 <= 680.0d0) then
tmp = sin(x)
else if (y <= 3.7d+127) then
tmp = (-0.16666666666666666d0) * (x ** 3.0d0)
else
tmp = (x * y) / y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 680.0) {
tmp = Math.sin(x);
} else if (y <= 3.7e+127) {
tmp = -0.16666666666666666 * Math.pow(x, 3.0);
} else {
tmp = (x * y) / y;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 680.0: tmp = math.sin(x) elif y <= 3.7e+127: tmp = -0.16666666666666666 * math.pow(x, 3.0) else: tmp = (x * y) / y return tmp
function code(x, y) tmp = 0.0 if (y <= 680.0) tmp = sin(x); elseif (y <= 3.7e+127) tmp = Float64(-0.16666666666666666 * (x ^ 3.0)); else tmp = Float64(Float64(x * y) / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 680.0) tmp = sin(x); elseif (y <= 3.7e+127) tmp = -0.16666666666666666 * (x ^ 3.0); else tmp = (x * y) / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 680.0], N[Sin[x], $MachinePrecision], If[LessEqual[y, 3.7e+127], N[(-0.16666666666666666 * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision], N[(N[(x * y), $MachinePrecision] / y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 680:\\
\;\;\;\;\sin x\\
\mathbf{elif}\;y \leq 3.7 \cdot 10^{+127}:\\
\;\;\;\;-0.16666666666666666 \cdot {x}^{3}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{y}\\
\end{array}
\end{array}
if y < 680Initial program 100.0%
Taylor expanded in y around 0 63.2%
if 680 < y < 3.6999999999999998e127Initial program 100.0%
Taylor expanded in y around 0 2.6%
Taylor expanded in x around 0 28.3%
distribute-rgt-in28.3%
*-lft-identity28.3%
associate-*l*28.3%
pow-plus28.3%
metadata-eval28.3%
Simplified28.3%
Taylor expanded in x around inf 27.9%
if 3.6999999999999998e127 < y Initial program 100.0%
associate-*r/100.0%
Applied egg-rr100.0%
Taylor expanded in y around 0 2.6%
Taylor expanded in x around 0 10.3%
Final simplification52.4%
(FPCore (x y) :precision binary64 (if (<= y 3.25e+30) (sin x) (/ (* x y) y)))
double code(double x, double y) {
double tmp;
if (y <= 3.25e+30) {
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 <= 3.25d+30) 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 <= 3.25e+30) {
tmp = Math.sin(x);
} else {
tmp = (x * y) / y;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 3.25e+30: tmp = math.sin(x) else: tmp = (x * y) / y return tmp
function code(x, y) tmp = 0.0 if (y <= 3.25e+30) 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 <= 3.25e+30) tmp = sin(x); else tmp = (x * y) / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 3.25e+30], N[Sin[x], $MachinePrecision], N[(N[(x * y), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.25 \cdot 10^{+30}:\\
\;\;\;\;\sin x\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{y}\\
\end{array}
\end{array}
if y < 3.25e30Initial program 100.0%
Taylor expanded in y around 0 60.0%
if 3.25e30 < y Initial program 100.0%
associate-*r/100.0%
Applied egg-rr100.0%
Taylor expanded in y around 0 2.6%
Taylor expanded in x around 0 7.8%
Final simplification49.8%
(FPCore (x y) :precision binary64 (if (<= y 2500000.0) x (/ (* x y) y)))
double code(double x, double y) {
double tmp;
if (y <= 2500000.0) {
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 <= 2500000.0d0) 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 <= 2500000.0) {
tmp = x;
} else {
tmp = (x * y) / y;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 2500000.0: tmp = x else: tmp = (x * y) / y return tmp
function code(x, y) tmp = 0.0 if (y <= 2500000.0) tmp = x; else tmp = Float64(Float64(x * y) / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 2500000.0) tmp = x; else tmp = (x * y) / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 2500000.0], x, N[(N[(x * y), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2500000:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{y}\\
\end{array}
\end{array}
if y < 2.5e6Initial program 100.0%
Taylor expanded in x around 0 64.0%
Taylor expanded in y around 0 36.0%
if 2.5e6 < y Initial program 100.0%
associate-*r/100.0%
Applied egg-rr100.0%
Taylor expanded in y around 0 2.6%
Taylor expanded in x around 0 6.8%
Final simplification29.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 66.6%
Taylor expanded in y around 0 28.0%
herbie shell --seed 2024101
(FPCore (x y)
:name "Linear.Quaternion:$ccos from linear-1.19.1.3"
:precision binary64
(* (sin x) (/ (sinh y) y)))