
(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 4 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) (/ 1.0 (/ y (sinh y)))))
double code(double x, double y) {
return cos(x) * (1.0 / (y / sinh(y)));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = cos(x) * (1.0d0 / (y / sinh(y)))
end function
public static double code(double x, double y) {
return Math.cos(x) * (1.0 / (y / Math.sinh(y)));
}
def code(x, y): return math.cos(x) * (1.0 / (y / math.sinh(y)))
function code(x, y) return Float64(cos(x) * Float64(1.0 / Float64(y / sinh(y)))) end
function tmp = code(x, y) tmp = cos(x) * (1.0 / (y / sinh(y))); end
code[x_, y_] := N[(N[Cos[x], $MachinePrecision] * N[(1.0 / N[(y / N[Sinh[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos x \cdot \frac{1}{\frac{y}{\sinh y}}
\end{array}
Initial program 100.0%
clear-num100.0%
associate-/r/99.8%
Applied egg-rr99.8%
associate-/r/100.0%
Applied egg-rr100.0%
Final simplification100.0%
(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 (* (cos x) (+ 1.0 (* 0.16666666666666666 (* y y)))))
double code(double x, double y) {
return cos(x) * (1.0 + (0.16666666666666666 * (y * y)));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = cos(x) * (1.0d0 + (0.16666666666666666d0 * (y * y)))
end function
public static double code(double x, double y) {
return Math.cos(x) * (1.0 + (0.16666666666666666 * (y * y)));
}
def code(x, y): return math.cos(x) * (1.0 + (0.16666666666666666 * (y * y)))
function code(x, y) return Float64(cos(x) * Float64(1.0 + Float64(0.16666666666666666 * Float64(y * y)))) end
function tmp = code(x, y) tmp = cos(x) * (1.0 + (0.16666666666666666 * (y * y))); end
code[x_, y_] := N[(N[Cos[x], $MachinePrecision] * N[(1.0 + N[(0.16666666666666666 * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos x \cdot \left(1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\right)
\end{array}
Initial program 100.0%
Taylor expanded in y around 0 96.2%
unpow296.2%
Simplified96.2%
Final simplification96.2%
(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 95.9%
Final simplification95.9%
herbie shell --seed 2023278
(FPCore (x y)
:name "Linear.Quaternion:$csin from linear-1.19.1.3"
:precision binary64
(* (cos x) (/ (sinh y) y)))