
(FPCore (x y) :precision binary64 (* (cos x) (/ (sinh y) y)))
double code(double x, double y) {
return cos(x) * (sinh(y) / y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = cos(x) * (sinh(y) / y)
end function
public static double code(double x, double y) {
return Math.cos(x) * (Math.sinh(y) / y);
}
def code(x, y): return math.cos(x) * (math.sinh(y) / y)
function code(x, y) return Float64(cos(x) * Float64(sinh(y) / y)) end
function tmp = code(x, y) tmp = cos(x) * (sinh(y) / y); end
code[x_, y_] := N[(N[Cos[x], $MachinePrecision] * N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos 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 (* (cos x) (/ (sinh y) y)))
double code(double x, double y) {
return cos(x) * (sinh(y) / y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = cos(x) * (sinh(y) / y)
end function
public static double code(double x, double y) {
return Math.cos(x) * (Math.sinh(y) / y);
}
def code(x, y): return math.cos(x) * (math.sinh(y) / y)
function code(x, y) return Float64(cos(x) * Float64(sinh(y) / y)) end
function tmp = code(x, y) tmp = cos(x) * (sinh(y) / y); end
code[x_, y_] := N[(N[Cos[x], $MachinePrecision] * N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos x \cdot \frac{\sinh y}{y}
\end{array}
(FPCore (x y) :precision binary64 (/ (cos x) (/ y (sinh y))))
double code(double x, double y) {
return cos(x) / (y / sinh(y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = cos(x) / (y / sinh(y))
end function
public static double code(double x, double y) {
return Math.cos(x) / (y / Math.sinh(y));
}
def code(x, y): return math.cos(x) / (y / math.sinh(y))
function code(x, y) return Float64(cos(x) / Float64(y / sinh(y))) end
function tmp = code(x, y) tmp = cos(x) / (y / sinh(y)); end
code[x_, y_] := N[(N[Cos[x], $MachinePrecision] / N[(y / N[Sinh[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\cos 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 (<= y 1.18e+24) (cos x) (cbrt (* (pow y 6.0) 0.004629629629629629))))
double code(double x, double y) {
double tmp;
if (y <= 1.18e+24) {
tmp = cos(x);
} else {
tmp = cbrt((pow(y, 6.0) * 0.004629629629629629));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (y <= 1.18e+24) {
tmp = Math.cos(x);
} else {
tmp = Math.cbrt((Math.pow(y, 6.0) * 0.004629629629629629));
}
return tmp;
}
function code(x, y) tmp = 0.0 if (y <= 1.18e+24) tmp = cos(x); else tmp = cbrt(Float64((y ^ 6.0) * 0.004629629629629629)); end return tmp end
code[x_, y_] := If[LessEqual[y, 1.18e+24], N[Cos[x], $MachinePrecision], N[Power[N[(N[Power[y, 6.0], $MachinePrecision] * 0.004629629629629629), $MachinePrecision], 1/3], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.18 \cdot 10^{+24}:\\
\;\;\;\;\cos x\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{{y}^{6} \cdot 0.004629629629629629}\\
\end{array}
\end{array}
if y < 1.17999999999999997e24Initial program 100.0%
Taylor expanded in y around 0 63.6%
if 1.17999999999999997e24 < y Initial program 100.0%
Taylor expanded in y around 0 74.9%
distribute-rgt-in74.9%
*-lft-identity74.9%
associate-*l*74.9%
unpow274.9%
unpow374.9%
Simplified74.9%
Taylor expanded in x around 0 58.7%
Taylor expanded in y around inf 44.2%
add-cbrt-cube68.7%
pow1/368.7%
pow368.7%
*-commutative68.7%
unpow-prod-down68.7%
pow-pow68.7%
metadata-eval68.7%
metadata-eval68.7%
Applied egg-rr68.7%
unpow1/368.7%
Simplified68.7%
Final simplification64.7%
(FPCore (x y) :precision binary64 (* (cos x) (/ (sinh y) y)))
double code(double x, double y) {
return cos(x) * (sinh(y) / y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = cos(x) * (sinh(y) / y)
end function
public static double code(double x, double y) {
return Math.cos(x) * (Math.sinh(y) / y);
}
def code(x, y): return math.cos(x) * (math.sinh(y) / y)
function code(x, y) return Float64(cos(x) * Float64(sinh(y) / y)) end
function tmp = code(x, y) tmp = cos(x) * (sinh(y) / y); end
code[x_, y_] := N[(N[Cos[x], $MachinePrecision] * N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos x \cdot \frac{\sinh y}{y}
\end{array}
Initial program 100.0%
Final simplification100.0%
(FPCore (x y) :precision binary64 (if (<= y 5.5e+23) (cos x) (/ (+ y (* 0.16666666666666666 (pow y 3.0))) y)))
double code(double x, double y) {
double tmp;
if (y <= 5.5e+23) {
tmp = cos(x);
} else {
tmp = (y + (0.16666666666666666 * pow(y, 3.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 <= 5.5d+23) then
tmp = cos(x)
else
tmp = (y + (0.16666666666666666d0 * (y ** 3.0d0))) / y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 5.5e+23) {
tmp = Math.cos(x);
} else {
tmp = (y + (0.16666666666666666 * Math.pow(y, 3.0))) / y;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 5.5e+23: tmp = math.cos(x) else: tmp = (y + (0.16666666666666666 * math.pow(y, 3.0))) / y return tmp
function code(x, y) tmp = 0.0 if (y <= 5.5e+23) tmp = cos(x); else tmp = Float64(Float64(y + Float64(0.16666666666666666 * (y ^ 3.0))) / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 5.5e+23) tmp = cos(x); else tmp = (y + (0.16666666666666666 * (y ^ 3.0))) / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 5.5e+23], N[Cos[x], $MachinePrecision], N[(N[(y + N[(0.16666666666666666 * N[Power[y, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5.5 \cdot 10^{+23}:\\
\;\;\;\;\cos x\\
\mathbf{else}:\\
\;\;\;\;\frac{y + 0.16666666666666666 \cdot {y}^{3}}{y}\\
\end{array}
\end{array}
if y < 5.50000000000000004e23Initial program 100.0%
Taylor expanded in y around 0 63.6%
if 5.50000000000000004e23 < y Initial program 100.0%
Taylor expanded in y around 0 74.9%
distribute-rgt-in74.9%
*-lft-identity74.9%
associate-*l*74.9%
unpow274.9%
unpow374.9%
Simplified74.9%
Taylor expanded in x around 0 58.7%
Final simplification62.5%
(FPCore (x y) :precision binary64 (if (<= y 1.35e+24) (cos x) (* 0.16666666666666666 (pow y 2.0))))
double code(double x, double y) {
double tmp;
if (y <= 1.35e+24) {
tmp = cos(x);
} else {
tmp = 0.16666666666666666 * pow(y, 2.0);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 1.35d+24) then
tmp = cos(x)
else
tmp = 0.16666666666666666d0 * (y ** 2.0d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 1.35e+24) {
tmp = Math.cos(x);
} else {
tmp = 0.16666666666666666 * Math.pow(y, 2.0);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 1.35e+24: tmp = math.cos(x) else: tmp = 0.16666666666666666 * math.pow(y, 2.0) return tmp
function code(x, y) tmp = 0.0 if (y <= 1.35e+24) tmp = cos(x); else tmp = Float64(0.16666666666666666 * (y ^ 2.0)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 1.35e+24) tmp = cos(x); else tmp = 0.16666666666666666 * (y ^ 2.0); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 1.35e+24], N[Cos[x], $MachinePrecision], N[(0.16666666666666666 * N[Power[y, 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.35 \cdot 10^{+24}:\\
\;\;\;\;\cos x\\
\mathbf{else}:\\
\;\;\;\;0.16666666666666666 \cdot {y}^{2}\\
\end{array}
\end{array}
if y < 1.35e24Initial program 100.0%
Taylor expanded in y around 0 63.6%
if 1.35e24 < y Initial program 100.0%
Taylor expanded in y around 0 74.9%
distribute-rgt-in74.9%
*-lft-identity74.9%
associate-*l*74.9%
unpow274.9%
unpow374.9%
Simplified74.9%
Taylor expanded in x around 0 58.7%
Taylor expanded in y around inf 44.2%
Final simplification59.3%
(FPCore (x y) :precision binary64 (cos x))
double code(double x, double y) {
return cos(x);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = cos(x)
end function
public static double code(double x, double y) {
return Math.cos(x);
}
def code(x, y): return math.cos(x)
function code(x, y) return cos(x) end
function tmp = code(x, y) tmp = cos(x); end
code[x_, y_] := N[Cos[x], $MachinePrecision]
\begin{array}{l}
\\
\cos x
\end{array}
Initial program 100.0%
Taylor expanded in y around 0 50.1%
Final simplification50.1%
(FPCore (x y) :precision binary64 1.0)
double code(double x, double y) {
return 1.0;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0
end function
public static double code(double x, double y) {
return 1.0;
}
def code(x, y): return 1.0
function code(x, y) return 1.0 end
function tmp = code(x, y) tmp = 1.0; end
code[x_, y_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 100.0%
Taylor expanded in y around 0 82.4%
distribute-rgt-in82.4%
*-lft-identity82.4%
associate-*l*82.4%
unpow282.4%
unpow382.4%
Simplified82.4%
Taylor expanded in x around 0 51.8%
Taylor expanded in y around 0 27.5%
Final simplification27.5%
herbie shell --seed 2024059
(FPCore (x y)
:name "Linear.Quaternion:$csin from linear-1.19.1.3"
:precision binary64
(* (cos x) (/ (sinh y) y)))