
(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 (* (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 6.8e-7) (/ (sin y) y) (if (<= x 8.5e+151) (cosh x) (* (sin y) (/ (+ 1.0 (* 0.5 (* x x))) y)))))
double code(double x, double y) {
double tmp;
if (x <= 6.8e-7) {
tmp = sin(y) / y;
} else if (x <= 8.5e+151) {
tmp = cosh(x);
} else {
tmp = sin(y) * ((1.0 + (0.5 * (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 <= 6.8d-7) then
tmp = sin(y) / y
else if (x <= 8.5d+151) then
tmp = cosh(x)
else
tmp = sin(y) * ((1.0d0 + (0.5d0 * (x * x))) / y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= 6.8e-7) {
tmp = Math.sin(y) / y;
} else if (x <= 8.5e+151) {
tmp = Math.cosh(x);
} else {
tmp = Math.sin(y) * ((1.0 + (0.5 * (x * x))) / y);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 6.8e-7: tmp = math.sin(y) / y elif x <= 8.5e+151: tmp = math.cosh(x) else: tmp = math.sin(y) * ((1.0 + (0.5 * (x * x))) / y) return tmp
function code(x, y) tmp = 0.0 if (x <= 6.8e-7) tmp = Float64(sin(y) / y); elseif (x <= 8.5e+151) tmp = cosh(x); else tmp = Float64(sin(y) * Float64(Float64(1.0 + Float64(0.5 * Float64(x * x))) / y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 6.8e-7) tmp = sin(y) / y; elseif (x <= 8.5e+151) tmp = cosh(x); else tmp = sin(y) * ((1.0 + (0.5 * (x * x))) / y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 6.8e-7], N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision], If[LessEqual[x, 8.5e+151], N[Cosh[x], $MachinePrecision], N[(N[Sin[y], $MachinePrecision] * N[(N[(1.0 + N[(0.5 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 6.8 \cdot 10^{-7}:\\
\;\;\;\;\frac{\sin y}{y}\\
\mathbf{elif}\;x \leq 8.5 \cdot 10^{+151}:\\
\;\;\;\;\cosh x\\
\mathbf{else}:\\
\;\;\;\;\sin y \cdot \frac{1 + 0.5 \cdot \left(x \cdot x\right)}{y}\\
\end{array}
\end{array}
if x < 6.79999999999999948e-7Initial program 99.9%
*-commutative99.9%
associate-/r/99.9%
Simplified99.9%
Taylor expanded in x around 0 66.6%
if 6.79999999999999948e-7 < x < 8.50000000000000051e151Initial program 100.0%
*-commutative100.0%
associate-/r/100.0%
Simplified100.0%
clear-num100.0%
inv-pow100.0%
Applied egg-rr100.0%
unpow-1100.0%
div-inv100.0%
associate-/r*100.0%
clear-num100.0%
Applied egg-rr100.0%
Taylor expanded in y around 0 68.8%
associate-/l/68.8%
cosh-def68.8%
lft-mult-inverse68.8%
associate-/l/68.8%
metadata-eval68.8%
cosh-def68.8%
expm1-log1p-u68.8%
expm1-udef68.8%
Applied egg-rr68.8%
expm1-def68.8%
expm1-log1p68.8%
Simplified68.8%
if 8.50000000000000051e151 < x Initial program 100.0%
*-commutative100.0%
associate-/r/100.0%
Simplified100.0%
clear-num100.0%
associate-/r/100.0%
clear-num100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 100.0%
unpow2100.0%
Simplified100.0%
Taylor expanded in y around 0 100.0%
unpow2100.0%
Simplified100.0%
Final simplification70.9%
(FPCore (x y) :precision binary64 (if (<= x 6.8e-7) (/ (sin y) y) (if (<= x 8.5e+151) (cosh x) (* 0.5 (/ (sin y) (/ y (* x x)))))))
double code(double x, double y) {
double tmp;
if (x <= 6.8e-7) {
tmp = sin(y) / y;
} else if (x <= 8.5e+151) {
tmp = cosh(x);
} else {
tmp = 0.5 * (sin(y) / (y / (x * x)));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= 6.8d-7) then
tmp = sin(y) / y
else if (x <= 8.5d+151) then
tmp = cosh(x)
else
tmp = 0.5d0 * (sin(y) / (y / (x * x)))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= 6.8e-7) {
tmp = Math.sin(y) / y;
} else if (x <= 8.5e+151) {
tmp = Math.cosh(x);
} else {
tmp = 0.5 * (Math.sin(y) / (y / (x * x)));
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 6.8e-7: tmp = math.sin(y) / y elif x <= 8.5e+151: tmp = math.cosh(x) else: tmp = 0.5 * (math.sin(y) / (y / (x * x))) return tmp
function code(x, y) tmp = 0.0 if (x <= 6.8e-7) tmp = Float64(sin(y) / y); elseif (x <= 8.5e+151) tmp = cosh(x); else tmp = Float64(0.5 * Float64(sin(y) / Float64(y / Float64(x * x)))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 6.8e-7) tmp = sin(y) / y; elseif (x <= 8.5e+151) tmp = cosh(x); else tmp = 0.5 * (sin(y) / (y / (x * x))); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 6.8e-7], N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision], If[LessEqual[x, 8.5e+151], N[Cosh[x], $MachinePrecision], N[(0.5 * N[(N[Sin[y], $MachinePrecision] / N[(y / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 6.8 \cdot 10^{-7}:\\
\;\;\;\;\frac{\sin y}{y}\\
\mathbf{elif}\;x \leq 8.5 \cdot 10^{+151}:\\
\;\;\;\;\cosh x\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{\sin y}{\frac{y}{x \cdot x}}\\
\end{array}
\end{array}
if x < 6.79999999999999948e-7Initial program 99.9%
*-commutative99.9%
associate-/r/99.9%
Simplified99.9%
Taylor expanded in x around 0 66.6%
if 6.79999999999999948e-7 < x < 8.50000000000000051e151Initial program 100.0%
*-commutative100.0%
associate-/r/100.0%
Simplified100.0%
clear-num100.0%
inv-pow100.0%
Applied egg-rr100.0%
unpow-1100.0%
div-inv100.0%
associate-/r*100.0%
clear-num100.0%
Applied egg-rr100.0%
Taylor expanded in y around 0 68.8%
associate-/l/68.8%
cosh-def68.8%
lft-mult-inverse68.8%
associate-/l/68.8%
metadata-eval68.8%
cosh-def68.8%
expm1-log1p-u68.8%
expm1-udef68.8%
Applied egg-rr68.8%
expm1-def68.8%
expm1-log1p68.8%
Simplified68.8%
if 8.50000000000000051e151 < x Initial program 100.0%
*-commutative100.0%
associate-/r/100.0%
Simplified100.0%
clear-num100.0%
associate-/r/100.0%
clear-num100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 100.0%
unpow2100.0%
Simplified100.0%
Taylor expanded in x around inf 100.0%
unpow2100.0%
associate-/l*100.0%
Simplified100.0%
Final simplification70.9%
(FPCore (x y) :precision binary64 (if (<= x 6.8e-7) (/ (sin y) y) (cosh x)))
double code(double x, double y) {
double tmp;
if (x <= 6.8e-7) {
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 (x <= 6.8d-7) 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 (x <= 6.8e-7) {
tmp = Math.sin(y) / y;
} else {
tmp = Math.cosh(x);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 6.8e-7: tmp = math.sin(y) / y else: tmp = math.cosh(x) return tmp
function code(x, y) tmp = 0.0 if (x <= 6.8e-7) tmp = Float64(sin(y) / y); else tmp = cosh(x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 6.8e-7) tmp = sin(y) / y; else tmp = cosh(x); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 6.8e-7], N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision], N[Cosh[x], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 6.8 \cdot 10^{-7}:\\
\;\;\;\;\frac{\sin y}{y}\\
\mathbf{else}:\\
\;\;\;\;\cosh x\\
\end{array}
\end{array}
if x < 6.79999999999999948e-7Initial program 99.9%
*-commutative99.9%
associate-/r/99.9%
Simplified99.9%
Taylor expanded in x around 0 66.6%
if 6.79999999999999948e-7 < x Initial program 100.0%
*-commutative100.0%
associate-/r/100.0%
Simplified100.0%
clear-num100.0%
inv-pow100.0%
Applied egg-rr100.0%
unpow-1100.0%
div-inv97.9%
associate-/r*97.9%
clear-num97.9%
Applied egg-rr97.9%
Taylor expanded in y around 0 72.9%
associate-/l/72.9%
cosh-def72.9%
lft-mult-inverse75.0%
associate-/l/75.0%
metadata-eval75.0%
cosh-def75.0%
expm1-log1p-u75.0%
expm1-udef75.0%
Applied egg-rr75.0%
expm1-def75.0%
expm1-log1p75.0%
Simplified75.0%
Final simplification68.2%
(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%
*-commutative99.9%
associate-/r/99.9%
Simplified99.9%
clear-num99.9%
inv-pow99.9%
Applied egg-rr99.9%
unpow-199.9%
div-inv99.4%
associate-/r*99.5%
clear-num99.5%
Applied egg-rr99.5%
Taylor expanded in y around 0 66.0%
associate-/l/65.9%
cosh-def65.9%
lft-mult-inverse66.4%
associate-/l/66.4%
metadata-eval66.4%
cosh-def66.4%
expm1-log1p-u66.4%
expm1-udef66.4%
Applied egg-rr66.4%
expm1-def66.4%
expm1-log1p66.4%
Simplified66.4%
Final simplification66.4%
(FPCore (x y) :precision binary64 (/ (+ (/ 1.0 y) (* 0.5 (/ (* x x) y))) (/ 1.0 y)))
double code(double x, double y) {
return ((1.0 / y) + (0.5 * ((x * x) / y))) / (1.0 / y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((1.0d0 / y) + (0.5d0 * ((x * x) / y))) / (1.0d0 / y)
end function
public static double code(double x, double y) {
return ((1.0 / y) + (0.5 * ((x * x) / y))) / (1.0 / y);
}
def code(x, y): return ((1.0 / y) + (0.5 * ((x * x) / y))) / (1.0 / y)
function code(x, y) return Float64(Float64(Float64(1.0 / y) + Float64(0.5 * Float64(Float64(x * x) / y))) / Float64(1.0 / y)) end
function tmp = code(x, y) tmp = ((1.0 / y) + (0.5 * ((x * x) / y))) / (1.0 / y); end
code[x_, y_] := N[(N[(N[(1.0 / y), $MachinePrecision] + N[(0.5 * N[(N[(x * x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(1.0 / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{y} + 0.5 \cdot \frac{x \cdot x}{y}}{\frac{1}{y}}
\end{array}
Initial program 99.9%
*-commutative99.9%
associate-/r/99.9%
Simplified99.9%
clear-num99.9%
inv-pow99.9%
Applied egg-rr99.9%
unpow-199.9%
div-inv99.4%
associate-/r*99.5%
clear-num99.5%
Applied egg-rr99.5%
Taylor expanded in y around 0 66.0%
Taylor expanded in x around 0 57.9%
unpow287.9%
Simplified57.9%
Final simplification57.9%
(FPCore (x y) :precision binary64 (+ 1.0 (* 0.5 (* x x))))
double code(double x, double y) {
return 1.0 + (0.5 * (x * x));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0 + (0.5d0 * (x * x))
end function
public static double code(double x, double y) {
return 1.0 + (0.5 * (x * x));
}
def code(x, y): return 1.0 + (0.5 * (x * x))
function code(x, y) return Float64(1.0 + Float64(0.5 * Float64(x * x))) end
function tmp = code(x, y) tmp = 1.0 + (0.5 * (x * x)); end
code[x_, y_] := N[(1.0 + N[(0.5 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + 0.5 \cdot \left(x \cdot x\right)
\end{array}
Initial program 99.9%
*-commutative99.9%
associate-/r/99.9%
Simplified99.9%
clear-num99.9%
associate-/r/99.8%
clear-num99.8%
Applied egg-rr99.8%
Taylor expanded in x around 0 87.9%
unpow287.9%
Simplified87.9%
Taylor expanded in y around 0 53.9%
unpow253.9%
Simplified53.9%
Final simplification53.9%
(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%
*-commutative99.9%
associate-/r/99.9%
Simplified99.9%
Taylor expanded in x around 0 54.6%
Taylor expanded in y around 0 32.0%
Final simplification32.0%
(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 2023268
(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)))