
(FPCore (x y) :precision binary64 (* (cosh x) (/ (sin y) y)))
double code(double x, double y) {
return cosh(x) * (sin(y) / y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = cosh(x) * (sin(y) / y)
end function
public static double code(double x, double y) {
return Math.cosh(x) * (Math.sin(y) / y);
}
def code(x, y): return math.cosh(x) * (math.sin(y) / y)
function code(x, y) return Float64(cosh(x) * Float64(sin(y) / y)) end
function tmp = code(x, y) tmp = cosh(x) * (sin(y) / y); end
code[x_, y_] := N[(N[Cosh[x], $MachinePrecision] * N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cosh x \cdot \frac{\sin y}{y}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (* (cosh x) (/ (sin y) y)))
double code(double x, double y) {
return cosh(x) * (sin(y) / y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = cosh(x) * (sin(y) / y)
end function
public static double code(double x, double y) {
return Math.cosh(x) * (Math.sin(y) / y);
}
def code(x, y): return math.cosh(x) * (math.sin(y) / y)
function code(x, y) return Float64(cosh(x) * Float64(sin(y) / y)) end
function tmp = code(x, y) tmp = cosh(x) * (sin(y) / y); end
code[x_, y_] := N[(N[Cosh[x], $MachinePrecision] * N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cosh x \cdot \frac{\sin y}{y}
\end{array}
(FPCore (x y) :precision binary64 (* (cosh x) (/ (sin y) y)))
double code(double x, double y) {
return cosh(x) * (sin(y) / y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = cosh(x) * (sin(y) / y)
end function
public static double code(double x, double y) {
return Math.cosh(x) * (Math.sin(y) / y);
}
def code(x, y): return math.cosh(x) * (math.sin(y) / y)
function code(x, y) return Float64(cosh(x) * Float64(sin(y) / y)) end
function tmp = code(x, y) tmp = cosh(x) * (sin(y) / y); end
code[x_, y_] := N[(N[Cosh[x], $MachinePrecision] * N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cosh x \cdot \frac{\sin y}{y}
\end{array}
Initial program 99.5%
(FPCore (x y) :precision binary64 (if (<= (cosh x) 1.0001) (/ (sin y) y) (cosh x)))
double code(double x, double y) {
double tmp;
if (cosh(x) <= 1.0001) {
tmp = sin(y) / y;
} else {
tmp = cosh(x);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (cosh(x) <= 1.0001d0) then
tmp = sin(y) / y
else
tmp = cosh(x)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (Math.cosh(x) <= 1.0001) {
tmp = Math.sin(y) / y;
} else {
tmp = Math.cosh(x);
}
return tmp;
}
def code(x, y): tmp = 0 if math.cosh(x) <= 1.0001: tmp = math.sin(y) / y else: tmp = math.cosh(x) return tmp
function code(x, y) tmp = 0.0 if (cosh(x) <= 1.0001) tmp = Float64(sin(y) / y); else tmp = cosh(x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (cosh(x) <= 1.0001) tmp = sin(y) / y; else tmp = cosh(x); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Cosh[x], $MachinePrecision], 1.0001], N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision], N[Cosh[x], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cosh x \leq 1.0001:\\
\;\;\;\;\frac{\sin y}{y}\\
\mathbf{else}:\\
\;\;\;\;\cosh x\\
\end{array}
\end{array}
if (cosh.f64 x) < 1.00009999999999999Initial program 99.8%
Taylor expanded in x around 0 98.9%
if 1.00009999999999999 < (cosh.f64 x) Initial program 99.3%
associate-*r/99.3%
associate-*l/99.3%
*-commutative99.3%
clear-num99.3%
un-div-inv99.3%
Applied egg-rr99.3%
Taylor expanded in y around 0 74.9%
div-inv74.9%
clear-num74.9%
Applied egg-rr74.9%
associate-*r/74.9%
*-commutative74.9%
associate-/l*74.9%
*-inverses74.9%
*-rgt-identity74.9%
Simplified74.9%
(FPCore (x y) :precision binary64 (cosh x))
double code(double x, double y) {
return cosh(x);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = cosh(x)
end function
public static double code(double x, double y) {
return Math.cosh(x);
}
def code(x, y): return math.cosh(x)
function code(x, y) return cosh(x) end
function tmp = code(x, y) tmp = cosh(x); end
code[x_, y_] := N[Cosh[x], $MachinePrecision]
\begin{array}{l}
\\
\cosh x
\end{array}
Initial program 99.5%
associate-*r/99.5%
associate-*l/99.5%
*-commutative99.5%
clear-num99.5%
un-div-inv99.5%
Applied egg-rr99.5%
Taylor expanded in y around 0 60.1%
div-inv60.1%
clear-num60.1%
Applied egg-rr60.1%
associate-*r/60.1%
*-commutative60.1%
associate-/l*60.1%
*-inverses60.1%
*-rgt-identity60.1%
Simplified60.1%
(FPCore (x y) :precision binary64 (/ 1.0 (/ y (* y (+ 1.0 (* (* y y) -0.16666666666666666))))))
double code(double x, double y) {
return 1.0 / (y / (y * (1.0 + ((y * y) * -0.16666666666666666))));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0 / (y / (y * (1.0d0 + ((y * y) * (-0.16666666666666666d0)))))
end function
public static double code(double x, double y) {
return 1.0 / (y / (y * (1.0 + ((y * y) * -0.16666666666666666))));
}
def code(x, y): return 1.0 / (y / (y * (1.0 + ((y * y) * -0.16666666666666666))))
function code(x, y) return Float64(1.0 / Float64(y / Float64(y * Float64(1.0 + Float64(Float64(y * y) * -0.16666666666666666))))) end
function tmp = code(x, y) tmp = 1.0 / (y / (y * (1.0 + ((y * y) * -0.16666666666666666)))); end
code[x_, y_] := N[(1.0 / N[(y / N[(y * N[(1.0 + N[(N[(y * y), $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\frac{y}{y \cdot \left(1 + \left(y \cdot y\right) \cdot -0.16666666666666666\right)}}
\end{array}
Initial program 99.5%
*-commutative99.5%
associate-*l/99.5%
associate-/l*99.5%
Simplified99.5%
Taylor expanded in x around 0 45.3%
un-div-inv45.4%
clear-num45.3%
Applied egg-rr45.3%
Taylor expanded in y around 0 26.8%
*-commutative26.8%
Simplified26.8%
unpow226.8%
Applied egg-rr26.8%
(FPCore (x y) :precision binary64 (* (* y (+ 1.0 (* (* y y) -0.16666666666666666))) (/ 1.0 y)))
double code(double x, double y) {
return (y * (1.0 + ((y * y) * -0.16666666666666666))) * (1.0 / y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (y * (1.0d0 + ((y * y) * (-0.16666666666666666d0)))) * (1.0d0 / y)
end function
public static double code(double x, double y) {
return (y * (1.0 + ((y * y) * -0.16666666666666666))) * (1.0 / y);
}
def code(x, y): return (y * (1.0 + ((y * y) * -0.16666666666666666))) * (1.0 / y)
function code(x, y) return Float64(Float64(y * Float64(1.0 + Float64(Float64(y * y) * -0.16666666666666666))) * Float64(1.0 / y)) end
function tmp = code(x, y) tmp = (y * (1.0 + ((y * y) * -0.16666666666666666))) * (1.0 / y); end
code[x_, y_] := N[(N[(y * N[(1.0 + N[(N[(y * y), $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(y \cdot \left(1 + \left(y \cdot y\right) \cdot -0.16666666666666666\right)\right) \cdot \frac{1}{y}
\end{array}
Initial program 99.5%
*-commutative99.5%
associate-*l/99.5%
associate-/l*99.5%
Simplified99.5%
Taylor expanded in x around 0 45.3%
Taylor expanded in y around 0 26.8%
*-commutative26.8%
Simplified26.8%
unpow226.8%
Applied egg-rr26.8%
(FPCore (x y) :precision binary64 (if (<= y 4.8e+160) 1.0 (* (* y y) -0.16666666666666666)))
double code(double x, double y) {
double tmp;
if (y <= 4.8e+160) {
tmp = 1.0;
} else {
tmp = (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 <= 4.8d+160) then
tmp = 1.0d0
else
tmp = (y * y) * (-0.16666666666666666d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 4.8e+160) {
tmp = 1.0;
} else {
tmp = (y * y) * -0.16666666666666666;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 4.8e+160: tmp = 1.0 else: tmp = (y * y) * -0.16666666666666666 return tmp
function code(x, y) tmp = 0.0 if (y <= 4.8e+160) tmp = 1.0; else tmp = Float64(Float64(y * y) * -0.16666666666666666); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 4.8e+160) tmp = 1.0; else tmp = (y * y) * -0.16666666666666666; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 4.8e+160], 1.0, N[(N[(y * y), $MachinePrecision] * -0.16666666666666666), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.8 \cdot 10^{+160}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\left(y \cdot y\right) \cdot -0.16666666666666666\\
\end{array}
\end{array}
if y < 4.8000000000000003e160Initial program 99.5%
*-commutative99.5%
associate-*l/99.5%
associate-/l*99.4%
Simplified99.4%
Taylor expanded in x around 0 46.0%
Taylor expanded in y around 0 22.4%
if 4.8000000000000003e160 < y Initial program 99.9%
Taylor expanded in x around 0 40.4%
Taylor expanded in y around 0 21.9%
distribute-rgt-in21.9%
*-lft-identity21.9%
associate-*l*21.9%
unpow221.9%
unpow321.9%
Simplified21.9%
Taylor expanded in y around inf 21.9%
unpow221.9%
Applied egg-rr21.9%
Final simplification22.3%
(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 99.5%
*-commutative99.5%
associate-*l/99.5%
associate-/l*99.5%
Simplified99.5%
Taylor expanded in x around 0 45.3%
Taylor expanded in y around 0 19.8%
(FPCore (x y) :precision binary64 (/ (* (cosh x) (sin y)) y))
double code(double x, double y) {
return (cosh(x) * sin(y)) / y;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (cosh(x) * sin(y)) / y
end function
public static double code(double x, double y) {
return (Math.cosh(x) * Math.sin(y)) / y;
}
def code(x, y): return (math.cosh(x) * math.sin(y)) / y
function code(x, y) return Float64(Float64(cosh(x) * sin(y)) / y) end
function tmp = code(x, y) tmp = (cosh(x) * sin(y)) / y; end
code[x_, y_] := N[(N[(N[Cosh[x], $MachinePrecision] * N[Sin[y], $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]
\begin{array}{l}
\\
\frac{\cosh x \cdot \sin y}{y}
\end{array}
herbie shell --seed 2024185
(FPCore (x y)
:name "Linear.Quaternion:$csinh from linear-1.19.1.3"
:precision binary64
:alt
(! :herbie-platform default (/ (* (cosh x) (sin y)) y))
(* (cosh x) (/ (sin y) y)))