
(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 9 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.9%
Final simplification99.9%
(FPCore (x y) :precision binary64 (if (<= (cosh x) 1.000005) (/ (sin y) y) (* (cosh x) (+ 1.0 (* -0.16666666666666666 (* y y))))))
double code(double x, double y) {
double tmp;
if (cosh(x) <= 1.000005) {
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.000005d0) 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.000005) {
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.000005: 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.000005) 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.000005) 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.000005], 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.000005:\\
\;\;\;\;\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.00000500000000003Initial program 99.9%
Taylor expanded in x around 0 99.3%
if 1.00000500000000003 < (cosh.f64 x) Initial program 100.0%
Taylor expanded in y around 0 71.1%
unpow271.1%
Simplified71.1%
Final simplification84.1%
(FPCore (x y) :precision binary64 (if (<= (cosh x) 1.000005) (/ (sin y) y) (cosh x)))
double code(double x, double y) {
double tmp;
if (cosh(x) <= 1.000005) {
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.000005d0) 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.000005) {
tmp = Math.sin(y) / y;
} else {
tmp = Math.cosh(x);
}
return tmp;
}
def code(x, y): tmp = 0 if math.cosh(x) <= 1.000005: tmp = math.sin(y) / y else: tmp = math.cosh(x) return tmp
function code(x, y) tmp = 0.0 if (cosh(x) <= 1.000005) 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.000005) tmp = sin(y) / y; else tmp = cosh(x); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Cosh[x], $MachinePrecision], 1.000005], N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision], N[Cosh[x], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cosh x \leq 1.000005:\\
\;\;\;\;\frac{\sin y}{y}\\
\mathbf{else}:\\
\;\;\;\;\cosh x\\
\end{array}
\end{array}
if (cosh.f64 x) < 1.00000500000000003Initial program 99.9%
Taylor expanded in x around 0 99.3%
if 1.00000500000000003 < (cosh.f64 x) Initial program 100.0%
Taylor expanded in y around 0 68.9%
Final simplification82.9%
(FPCore (x y) :precision binary64 (if (or (<= x 0.235) (not (<= x 2e+151))) (* (sin y) (+ (/ 1.0 y) (* 0.5 (/ (* x x) y)))) (* (cosh x) (+ 1.0 (* -0.16666666666666666 (* y y))))))
double code(double x, double y) {
double tmp;
if ((x <= 0.235) || !(x <= 2e+151)) {
tmp = sin(y) * ((1.0 / y) + (0.5 * ((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.235d0) .or. (.not. (x <= 2d+151))) then
tmp = sin(y) * ((1.0d0 / y) + (0.5d0 * ((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.235) || !(x <= 2e+151)) {
tmp = Math.sin(y) * ((1.0 / y) + (0.5 * ((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.235) or not (x <= 2e+151): tmp = math.sin(y) * ((1.0 / y) + (0.5 * ((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.235) || !(x <= 2e+151)) tmp = Float64(sin(y) * Float64(Float64(1.0 / y) + Float64(0.5 * Float64(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.235) || ~((x <= 2e+151))) tmp = sin(y) * ((1.0 / y) + (0.5 * ((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.235], N[Not[LessEqual[x, 2e+151]], $MachinePrecision]], N[(N[Sin[y], $MachinePrecision] * N[(N[(1.0 / y), $MachinePrecision] + N[(0.5 * N[(N[(x * x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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.235 \lor \neg \left(x \leq 2 \cdot 10^{+151}\right):\\
\;\;\;\;\sin y \cdot \left(\frac{1}{y} + 0.5 \cdot \frac{x \cdot x}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;\cosh x \cdot \left(1 + -0.16666666666666666 \cdot \left(y \cdot y\right)\right)\\
\end{array}
\end{array}
if x < 0.23499999999999999 or 2.00000000000000003e151 < x Initial program 99.9%
add-log-exp74.8%
*-un-lft-identity74.8%
log-prod74.8%
metadata-eval74.8%
add-log-exp99.9%
*-commutative99.9%
associate-*l/99.9%
Applied egg-rr99.9%
+-lft-identity99.9%
*-commutative99.9%
associate-*l/99.8%
*-commutative99.8%
Simplified99.8%
Taylor expanded in x around 0 84.1%
unpow284.1%
Simplified84.1%
if 0.23499999999999999 < x < 2.00000000000000003e151Initial program 100.0%
Taylor expanded in y around 0 73.7%
unpow273.7%
Simplified73.7%
Final simplification82.6%
(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.9%
Taylor expanded in y around 0 60.4%
Final simplification60.4%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* y (* y -0.16666666666666666))))
(if (<= y 3.9e+149)
(/ (+ (* t_0 t_0) -1.0) (+ t_0 -1.0))
(+ 1.0 (* -0.16666666666666666 (* y y))))))
double code(double x, double y) {
double t_0 = y * (y * -0.16666666666666666);
double tmp;
if (y <= 3.9e+149) {
tmp = ((t_0 * t_0) + -1.0) / (t_0 + -1.0);
} 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) :: t_0
real(8) :: tmp
t_0 = y * (y * (-0.16666666666666666d0))
if (y <= 3.9d+149) then
tmp = ((t_0 * t_0) + (-1.0d0)) / (t_0 + (-1.0d0))
else
tmp = 1.0d0 + ((-0.16666666666666666d0) * (y * y))
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = y * (y * -0.16666666666666666);
double tmp;
if (y <= 3.9e+149) {
tmp = ((t_0 * t_0) + -1.0) / (t_0 + -1.0);
} else {
tmp = 1.0 + (-0.16666666666666666 * (y * y));
}
return tmp;
}
def code(x, y): t_0 = y * (y * -0.16666666666666666) tmp = 0 if y <= 3.9e+149: tmp = ((t_0 * t_0) + -1.0) / (t_0 + -1.0) else: tmp = 1.0 + (-0.16666666666666666 * (y * y)) return tmp
function code(x, y) t_0 = Float64(y * Float64(y * -0.16666666666666666)) tmp = 0.0 if (y <= 3.9e+149) tmp = Float64(Float64(Float64(t_0 * t_0) + -1.0) / Float64(t_0 + -1.0)); else tmp = Float64(1.0 + Float64(-0.16666666666666666 * Float64(y * y))); end return tmp end
function tmp_2 = code(x, y) t_0 = y * (y * -0.16666666666666666); tmp = 0.0; if (y <= 3.9e+149) tmp = ((t_0 * t_0) + -1.0) / (t_0 + -1.0); else tmp = 1.0 + (-0.16666666666666666 * (y * y)); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(y * N[(y * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, 3.9e+149], N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] + -1.0), $MachinePrecision] / N[(t$95$0 + -1.0), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(-0.16666666666666666 * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \left(y \cdot -0.16666666666666666\right)\\
\mathbf{if}\;y \leq 3.9 \cdot 10^{+149}:\\
\;\;\;\;\frac{t_0 \cdot t_0 + -1}{t_0 + -1}\\
\mathbf{else}:\\
\;\;\;\;1 + -0.16666666666666666 \cdot \left(y \cdot y\right)\\
\end{array}
\end{array}
if y < 3.8999999999999999e149Initial program 99.9%
Taylor expanded in y around 0 63.5%
unpow263.5%
Simplified63.5%
Taylor expanded in x around 0 34.4%
+-commutative34.4%
unpow234.4%
*-commutative34.4%
associate-*r*34.4%
fma-udef34.4%
Simplified34.4%
fma-udef34.4%
flip-+29.7%
metadata-eval29.7%
Applied egg-rr29.7%
if 3.8999999999999999e149 < y Initial program 100.0%
Taylor expanded in x around 0 29.3%
Taylor expanded in y around 0 44.4%
unpow244.4%
Simplified44.4%
Final simplification31.1%
(FPCore (x y) :precision binary64 (if (<= y 22.0) 1.0 (* -0.16666666666666666 (* y y))))
double code(double x, double y) {
double tmp;
if (y <= 22.0) {
tmp = 1.0;
} else {
tmp = -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 <= 22.0d0) then
tmp = 1.0d0
else
tmp = (-0.16666666666666666d0) * (y * y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 22.0) {
tmp = 1.0;
} else {
tmp = -0.16666666666666666 * (y * y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 22.0: tmp = 1.0 else: tmp = -0.16666666666666666 * (y * y) return tmp
function code(x, y) tmp = 0.0 if (y <= 22.0) tmp = 1.0; else tmp = Float64(-0.16666666666666666 * Float64(y * y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 22.0) tmp = 1.0; else tmp = -0.16666666666666666 * (y * y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 22.0], 1.0, N[(-0.16666666666666666 * N[(y * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 22:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-0.16666666666666666 \cdot \left(y \cdot y\right)\\
\end{array}
\end{array}
if y < 22Initial program 99.9%
Taylor expanded in x around 0 49.1%
Taylor expanded in y around 0 31.7%
if 22 < y Initial program 99.9%
Taylor expanded in y around 0 33.5%
unpow233.5%
Simplified33.5%
Taylor expanded in x around 0 19.9%
+-commutative19.9%
unpow219.9%
*-commutative19.9%
associate-*r*19.9%
fma-udef19.9%
Simplified19.9%
Taylor expanded in y around inf 19.9%
unpow219.9%
Simplified19.9%
Final simplification28.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 47.5%
Taylor expanded in y around 0 35.4%
unpow261.6%
Simplified35.4%
Final simplification35.4%
(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 47.5%
Taylor expanded in y around 0 24.6%
Final simplification24.6%
(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 2023207
(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)))