
(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(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}
Initial program 99.9%
associate-*r/99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y) :precision binary64 (if (<= (cosh x) 1.0000005) (/ (sin y) y) (* (* (cosh x) 4.0) 0.25)))
double code(double x, double y) {
double tmp;
if (cosh(x) <= 1.0000005) {
tmp = sin(y) / y;
} else {
tmp = (cosh(x) * 4.0) * 0.25;
}
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.0000005d0) then
tmp = sin(y) / y
else
tmp = (cosh(x) * 4.0d0) * 0.25d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (Math.cosh(x) <= 1.0000005) {
tmp = Math.sin(y) / y;
} else {
tmp = (Math.cosh(x) * 4.0) * 0.25;
}
return tmp;
}
def code(x, y): tmp = 0 if math.cosh(x) <= 1.0000005: tmp = math.sin(y) / y else: tmp = (math.cosh(x) * 4.0) * 0.25 return tmp
function code(x, y) tmp = 0.0 if (cosh(x) <= 1.0000005) tmp = Float64(sin(y) / y); else tmp = Float64(Float64(cosh(x) * 4.0) * 0.25); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (cosh(x) <= 1.0000005) tmp = sin(y) / y; else tmp = (cosh(x) * 4.0) * 0.25; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Cosh[x], $MachinePrecision], 1.0000005], N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision], N[(N[(N[Cosh[x], $MachinePrecision] * 4.0), $MachinePrecision] * 0.25), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cosh x \leq 1.0000005:\\
\;\;\;\;\frac{\sin y}{y}\\
\mathbf{else}:\\
\;\;\;\;\left(\cosh x \cdot 4\right) \cdot 0.25\\
\end{array}
\end{array}
if (cosh.f64 x) < 1.0000005000000001Initial program 99.8%
associate-*r/99.8%
Simplified99.8%
Taylor expanded in x around 0 99.1%
if 1.0000005000000001 < (cosh.f64 x) Initial program 100.0%
associate-*r/100.0%
Simplified100.0%
associate-/l*100.0%
cosh-def100.0%
associate-/l/100.0%
cosh-undef100.0%
cosh-def100.0%
div-inv100.0%
associate-*r*100.0%
times-frac100.0%
cosh-undef100.0%
associate-*r*100.0%
metadata-eval100.0%
metadata-eval100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Taylor expanded in y around 0 73.4%
Final simplification85.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(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 (<= x 800.0)
(/ (sin y) y)
(if (<= x 2.4e+181)
(+ 1.0 (* (* y y) -0.16666666666666666))
(+ -2.0 (/ (* -2.0 (* x x)) y)))))
double code(double x, double y) {
double tmp;
if (x <= 800.0) {
tmp = sin(y) / y;
} else if (x <= 2.4e+181) {
tmp = 1.0 + ((y * y) * -0.16666666666666666);
} else {
tmp = -2.0 + ((-2.0 * (x * x)) / y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= 800.0d0) then
tmp = sin(y) / y
else if (x <= 2.4d+181) then
tmp = 1.0d0 + ((y * y) * (-0.16666666666666666d0))
else
tmp = (-2.0d0) + (((-2.0d0) * (x * x)) / y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= 800.0) {
tmp = Math.sin(y) / y;
} else if (x <= 2.4e+181) {
tmp = 1.0 + ((y * y) * -0.16666666666666666);
} else {
tmp = -2.0 + ((-2.0 * (x * x)) / y);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 800.0: tmp = math.sin(y) / y elif x <= 2.4e+181: tmp = 1.0 + ((y * y) * -0.16666666666666666) else: tmp = -2.0 + ((-2.0 * (x * x)) / y) return tmp
function code(x, y) tmp = 0.0 if (x <= 800.0) tmp = Float64(sin(y) / y); elseif (x <= 2.4e+181) tmp = Float64(1.0 + Float64(Float64(y * y) * -0.16666666666666666)); else tmp = Float64(-2.0 + Float64(Float64(-2.0 * Float64(x * x)) / y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 800.0) tmp = sin(y) / y; elseif (x <= 2.4e+181) tmp = 1.0 + ((y * y) * -0.16666666666666666); else tmp = -2.0 + ((-2.0 * (x * x)) / y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 800.0], N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision], If[LessEqual[x, 2.4e+181], N[(1.0 + N[(N[(y * y), $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision], N[(-2.0 + N[(N[(-2.0 * N[(x * x), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 800:\\
\;\;\;\;\frac{\sin y}{y}\\
\mathbf{elif}\;x \leq 2.4 \cdot 10^{+181}:\\
\;\;\;\;1 + \left(y \cdot y\right) \cdot -0.16666666666666666\\
\mathbf{else}:\\
\;\;\;\;-2 + \frac{-2 \cdot \left(x \cdot x\right)}{y}\\
\end{array}
\end{array}
if x < 800Initial program 99.9%
associate-*r/99.9%
Simplified99.9%
Taylor expanded in x around 0 63.7%
if 800 < x < 2.40000000000000002e181Initial program 100.0%
associate-*r/100.0%
Simplified100.0%
Taylor expanded in x around 0 2.5%
Taylor expanded in y around 0 27.3%
*-commutative27.3%
unpow227.3%
Simplified27.3%
if 2.40000000000000002e181 < x Initial program 100.0%
associate-*r/100.0%
Simplified100.0%
clear-num100.0%
inv-pow100.0%
associate-/l/100.0%
Applied egg-rr100.0%
unpow-1100.0%
associate-/r*100.0%
associate-/l/100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 100.0%
Simplified40.7%
Final simplification55.1%
(FPCore (x y) :precision binary64 (if (<= x 2.2e+181) (+ 1.0 (* (* y y) -0.16666666666666666)) (+ -2.0 (/ (* -2.0 (* x x)) y))))
double code(double x, double y) {
double tmp;
if (x <= 2.2e+181) {
tmp = 1.0 + ((y * y) * -0.16666666666666666);
} else {
tmp = -2.0 + ((-2.0 * (x * x)) / y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= 2.2d+181) then
tmp = 1.0d0 + ((y * y) * (-0.16666666666666666d0))
else
tmp = (-2.0d0) + (((-2.0d0) * (x * x)) / y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= 2.2e+181) {
tmp = 1.0 + ((y * y) * -0.16666666666666666);
} else {
tmp = -2.0 + ((-2.0 * (x * x)) / y);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 2.2e+181: tmp = 1.0 + ((y * y) * -0.16666666666666666) else: tmp = -2.0 + ((-2.0 * (x * x)) / y) return tmp
function code(x, y) tmp = 0.0 if (x <= 2.2e+181) tmp = Float64(1.0 + Float64(Float64(y * y) * -0.16666666666666666)); else tmp = Float64(-2.0 + Float64(Float64(-2.0 * Float64(x * x)) / y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 2.2e+181) tmp = 1.0 + ((y * y) * -0.16666666666666666); else tmp = -2.0 + ((-2.0 * (x * x)) / y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 2.2e+181], N[(1.0 + N[(N[(y * y), $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision], N[(-2.0 + N[(N[(-2.0 * N[(x * x), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.2 \cdot 10^{+181}:\\
\;\;\;\;1 + \left(y \cdot y\right) \cdot -0.16666666666666666\\
\mathbf{else}:\\
\;\;\;\;-2 + \frac{-2 \cdot \left(x \cdot x\right)}{y}\\
\end{array}
\end{array}
if x < 2.2000000000000001e181Initial program 99.9%
associate-*r/99.9%
Simplified99.9%
Taylor expanded in x around 0 52.2%
Taylor expanded in y around 0 37.1%
*-commutative37.1%
unpow237.1%
Simplified37.1%
if 2.2000000000000001e181 < x Initial program 100.0%
associate-*r/100.0%
Simplified100.0%
clear-num100.0%
inv-pow100.0%
associate-/l/100.0%
Applied egg-rr100.0%
unpow-1100.0%
associate-/r*100.0%
associate-/l/100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 100.0%
Simplified40.7%
Final simplification37.5%
(FPCore (x y) :precision binary64 (+ 1.0 (* (* y y) -0.16666666666666666)))
double code(double x, double y) {
return 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) * (-0.16666666666666666d0))
end function
public static double code(double x, double y) {
return 1.0 + ((y * y) * -0.16666666666666666);
}
def code(x, y): return 1.0 + ((y * y) * -0.16666666666666666)
function code(x, y) return Float64(1.0 + Float64(Float64(y * y) * -0.16666666666666666)) end
function tmp = code(x, y) tmp = 1.0 + ((y * y) * -0.16666666666666666); end
code[x_, y_] := N[(1.0 + N[(N[(y * y), $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \left(y \cdot y\right) \cdot -0.16666666666666666
\end{array}
Initial program 99.9%
associate-*r/99.9%
Simplified99.9%
Taylor expanded in x around 0 47.0%
Taylor expanded in y around 0 36.1%
*-commutative36.1%
unpow236.1%
Simplified36.1%
Final simplification36.1%
(FPCore (x y) :precision binary64 -2.0)
double code(double x, double y) {
return -2.0;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = -2.0d0
end function
public static double code(double x, double y) {
return -2.0;
}
def code(x, y): return -2.0
function code(x, y) return -2.0 end
function tmp = code(x, y) tmp = -2.0; end
code[x_, y_] := -2.0
\begin{array}{l}
\\
-2
\end{array}
Initial program 99.9%
associate-*r/99.9%
Simplified99.9%
clear-num99.9%
inv-pow99.9%
associate-/l/99.9%
Applied egg-rr99.9%
unpow-199.9%
associate-/r*99.9%
associate-/l/99.9%
Applied egg-rr99.9%
Taylor expanded in x around 0 47.0%
Simplified1.9%
Final simplification1.9%
(FPCore (x y) :precision binary64 0.8333333333333334)
double code(double x, double y) {
return 0.8333333333333334;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 0.8333333333333334d0
end function
public static double code(double x, double y) {
return 0.8333333333333334;
}
def code(x, y): return 0.8333333333333334
function code(x, y) return 0.8333333333333334 end
function tmp = code(x, y) tmp = 0.8333333333333334; end
code[x_, y_] := 0.8333333333333334
\begin{array}{l}
\\
0.8333333333333334
\end{array}
Initial program 99.9%
associate-*r/99.9%
Simplified99.9%
Taylor expanded in x around 0 47.0%
clear-num46.9%
inv-pow46.9%
Applied egg-rr46.9%
Taylor expanded in y around 0 36.1%
Simplified7.6%
Final simplification7.6%
(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%
associate-*r/99.9%
Simplified99.9%
Taylor expanded in x around 0 47.0%
clear-num46.9%
inv-pow46.9%
Applied egg-rr46.9%
Taylor expanded in y around 0 27.1%
Final simplification27.1%
(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 2023297
(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)))