
(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 8 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 (/ (* (sin y) (cosh x)) y))
double code(double x, double y) {
return (sin(y) * cosh(x)) / y;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (sin(y) * cosh(x)) / y
end function
public static double code(double x, double y) {
return (Math.sin(y) * Math.cosh(x)) / y;
}
def code(x, y): return (math.sin(y) * math.cosh(x)) / y
function code(x, y) return Float64(Float64(sin(y) * cosh(x)) / y) end
function tmp = code(x, y) tmp = (sin(y) * cosh(x)) / y; end
code[x_, y_] := N[(N[(N[Sin[y], $MachinePrecision] * N[Cosh[x], $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin y \cdot \cosh x}{y}
\end{array}
Initial program 99.9%
*-commutative99.9%
associate-*l/99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x y) :precision binary64 (if (<= (cosh x) 1.05) (/ (sin y) y) (* (cosh x) (+ 1.0 (* -0.16666666666666666 (* y y))))))
double code(double x, double y) {
double tmp;
if (cosh(x) <= 1.05) {
tmp = sin(y) / y;
} else {
tmp = cosh(x) * (1.0 + (-0.16666666666666666 * (y * y)));
}
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.05d0) then
tmp = sin(y) / y
else
tmp = cosh(x) * (1.0d0 + ((-0.16666666666666666d0) * (y * y)))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (Math.cosh(x) <= 1.05) {
tmp = Math.sin(y) / y;
} else {
tmp = Math.cosh(x) * (1.0 + (-0.16666666666666666 * (y * y)));
}
return tmp;
}
def code(x, y): tmp = 0 if math.cosh(x) <= 1.05: tmp = math.sin(y) / y else: tmp = math.cosh(x) * (1.0 + (-0.16666666666666666 * (y * y))) return tmp
function code(x, y) tmp = 0.0 if (cosh(x) <= 1.05) tmp = Float64(sin(y) / y); else tmp = Float64(cosh(x) * Float64(1.0 + Float64(-0.16666666666666666 * Float64(y * y)))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (cosh(x) <= 1.05) tmp = sin(y) / y; else tmp = cosh(x) * (1.0 + (-0.16666666666666666 * (y * y))); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Cosh[x], $MachinePrecision], 1.05], N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision], N[(N[Cosh[x], $MachinePrecision] * N[(1.0 + N[(-0.16666666666666666 * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cosh x \leq 1.05:\\
\;\;\;\;\frac{\sin y}{y}\\
\mathbf{else}:\\
\;\;\;\;\cosh x \cdot \left(1 + -0.16666666666666666 \cdot \left(y \cdot y\right)\right)\\
\end{array}
\end{array}
if (cosh.f64 x) < 1.05000000000000004Initial program 99.8%
Taylor expanded in x around 0 98.9%
if 1.05000000000000004 < (cosh.f64 x) Initial program 100.0%
Taylor expanded in y around 0 75.8%
unpow216.6%
Simplified75.8%
Final simplification87.4%
(FPCore (x y) :precision binary64 (if (<= (cosh x) 1.05) (/ (sin y) y) (cosh x)))
double code(double x, double y) {
double tmp;
if (cosh(x) <= 1.05) {
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.05d0) 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.05) {
tmp = Math.sin(y) / y;
} else {
tmp = Math.cosh(x);
}
return tmp;
}
def code(x, y): tmp = 0 if math.cosh(x) <= 1.05: tmp = math.sin(y) / y else: tmp = math.cosh(x) return tmp
function code(x, y) tmp = 0.0 if (cosh(x) <= 1.05) 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.05) tmp = sin(y) / y; else tmp = cosh(x); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Cosh[x], $MachinePrecision], 1.05], N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision], N[Cosh[x], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cosh x \leq 1.05:\\
\;\;\;\;\frac{\sin y}{y}\\
\mathbf{else}:\\
\;\;\;\;\cosh x\\
\end{array}
\end{array}
if (cosh.f64 x) < 1.05000000000000004Initial program 99.8%
Taylor expanded in x around 0 98.9%
if 1.05000000000000004 < (cosh.f64 x) Initial program 100.0%
Taylor expanded in y around 0 70.8%
Final simplification84.9%
(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.9%
Final simplification99.9%
(FPCore (x y) :precision binary64 (if (or (<= x 0.02) (not (<= x 1.35e+154))) (/ (* (* (sin y) 0.5) (+ 2.0 (* x x))) y) (* (cosh x) (+ 1.0 (* -0.16666666666666666 (* y y))))))
double code(double x, double y) {
double tmp;
if ((x <= 0.02) || !(x <= 1.35e+154)) {
tmp = ((sin(y) * 0.5) * (2.0 + (x * x))) / y;
} else {
tmp = cosh(x) * (1.0 + (-0.16666666666666666 * (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 <= 0.02d0) .or. (.not. (x <= 1.35d+154))) then
tmp = ((sin(y) * 0.5d0) * (2.0d0 + (x * x))) / y
else
tmp = cosh(x) * (1.0d0 + ((-0.16666666666666666d0) * (y * y)))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= 0.02) || !(x <= 1.35e+154)) {
tmp = ((Math.sin(y) * 0.5) * (2.0 + (x * x))) / y;
} else {
tmp = Math.cosh(x) * (1.0 + (-0.16666666666666666 * (y * y)));
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= 0.02) or not (x <= 1.35e+154): tmp = ((math.sin(y) * 0.5) * (2.0 + (x * x))) / y else: tmp = math.cosh(x) * (1.0 + (-0.16666666666666666 * (y * y))) return tmp
function code(x, y) tmp = 0.0 if ((x <= 0.02) || !(x <= 1.35e+154)) tmp = Float64(Float64(Float64(sin(y) * 0.5) * Float64(2.0 + Float64(x * x))) / y); else tmp = Float64(cosh(x) * Float64(1.0 + Float64(-0.16666666666666666 * Float64(y * y)))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= 0.02) || ~((x <= 1.35e+154))) tmp = ((sin(y) * 0.5) * (2.0 + (x * x))) / y; else tmp = cosh(x) * (1.0 + (-0.16666666666666666 * (y * y))); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, 0.02], N[Not[LessEqual[x, 1.35e+154]], $MachinePrecision]], N[(N[(N[(N[Sin[y], $MachinePrecision] * 0.5), $MachinePrecision] * N[(2.0 + N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision], N[(N[Cosh[x], $MachinePrecision] * N[(1.0 + N[(-0.16666666666666666 * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.02 \lor \neg \left(x \leq 1.35 \cdot 10^{+154}\right):\\
\;\;\;\;\frac{\left(\sin y \cdot 0.5\right) \cdot \left(2 + x \cdot x\right)}{y}\\
\mathbf{else}:\\
\;\;\;\;\cosh x \cdot \left(1 + -0.16666666666666666 \cdot \left(y \cdot y\right)\right)\\
\end{array}
\end{array}
if x < 0.0200000000000000004 or 1.35000000000000003e154 < x Initial program 99.9%
*-commutative99.9%
associate-*l/99.9%
Applied egg-rr99.9%
add-log-exp55.0%
Applied egg-rr55.0%
Taylor expanded in x around 0 85.2%
+-commutative85.2%
*-lft-identity85.2%
metadata-eval85.2%
associate-*r*85.2%
*-commutative85.2%
associate-*r*85.2%
distribute-lft-out85.2%
*-commutative85.2%
unpow285.2%
Simplified85.2%
if 0.0200000000000000004 < x < 1.35000000000000003e154Initial program 100.0%
Taylor expanded in y around 0 77.8%
unpow224.5%
Simplified77.8%
Final simplification84.2%
(FPCore (x y) :precision binary64 (if (<= y 3.7e+247) (cosh x) (+ 1.0 (* -0.16666666666666666 (* y y)))))
double code(double x, double y) {
double tmp;
if (y <= 3.7e+247) {
tmp = cosh(x);
} else {
tmp = 1.0 + (-0.16666666666666666 * (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.7d+247) then
tmp = cosh(x)
else
tmp = 1.0d0 + ((-0.16666666666666666d0) * (y * y))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 3.7e+247) {
tmp = Math.cosh(x);
} else {
tmp = 1.0 + (-0.16666666666666666 * (y * y));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 3.7e+247: tmp = math.cosh(x) else: tmp = 1.0 + (-0.16666666666666666 * (y * y)) return tmp
function code(x, y) tmp = 0.0 if (y <= 3.7e+247) tmp = cosh(x); else tmp = Float64(1.0 + Float64(-0.16666666666666666 * Float64(y * y))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 3.7e+247) tmp = cosh(x); else tmp = 1.0 + (-0.16666666666666666 * (y * y)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 3.7e+247], N[Cosh[x], $MachinePrecision], N[(1.0 + N[(-0.16666666666666666 * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.7 \cdot 10^{+247}:\\
\;\;\;\;\cosh x\\
\mathbf{else}:\\
\;\;\;\;1 + -0.16666666666666666 \cdot \left(y \cdot y\right)\\
\end{array}
\end{array}
if y < 3.6999999999999998e247Initial program 99.9%
Taylor expanded in y around 0 60.0%
if 3.6999999999999998e247 < y Initial program 100.0%
Taylor expanded in x around 0 38.6%
Taylor expanded in y around 0 25.6%
unpow225.6%
Simplified25.6%
Final simplification58.9%
(FPCore (x y) :precision binary64 (+ 1.0 (* -0.16666666666666666 (* y y))))
double code(double x, double y) {
return 1.0 + (-0.16666666666666666 * (y * y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0 + ((-0.16666666666666666d0) * (y * y))
end function
public static double code(double x, double y) {
return 1.0 + (-0.16666666666666666 * (y * y));
}
def code(x, y): return 1.0 + (-0.16666666666666666 * (y * y))
function code(x, y) return Float64(1.0 + Float64(-0.16666666666666666 * Float64(y * y))) end
function tmp = code(x, y) tmp = 1.0 + (-0.16666666666666666 * (y * y)); end
code[x_, y_] := N[(1.0 + N[(-0.16666666666666666 * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + -0.16666666666666666 \cdot \left(y \cdot y\right)
\end{array}
Initial program 99.9%
Taylor expanded in x around 0 50.9%
Taylor expanded in y around 0 32.1%
unpow232.1%
Simplified32.1%
Final simplification32.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 99.9%
Taylor expanded in x around 0 50.9%
Taylor expanded in y around 0 25.2%
Final simplification25.2%
(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 2023252
(FPCore (x y)
:name "Linear.Quaternion:$csinh from linear-1.19.1.3"
:precision binary64
:herbie-target
(/ (* (cosh x) (sin y)) y)
(* (cosh x) (/ (sin y) y)))