
(FPCore (x y) :precision binary64 (* (cos x) (/ (sinh y) y)))
double code(double x, double y) {
return cos(x) * (sinh(y) / y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = cos(x) * (sinh(y) / y)
end function
public static double code(double x, double y) {
return Math.cos(x) * (Math.sinh(y) / y);
}
def code(x, y): return math.cos(x) * (math.sinh(y) / y)
function code(x, y) return Float64(cos(x) * Float64(sinh(y) / y)) end
function tmp = code(x, y) tmp = cos(x) * (sinh(y) / y); end
code[x_, y_] := N[(N[Cos[x], $MachinePrecision] * N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos x \cdot \frac{\sinh y}{y}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (* (cos x) (/ (sinh y) y)))
double code(double x, double y) {
return cos(x) * (sinh(y) / y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = cos(x) * (sinh(y) / y)
end function
public static double code(double x, double y) {
return Math.cos(x) * (Math.sinh(y) / y);
}
def code(x, y): return math.cos(x) * (math.sinh(y) / y)
function code(x, y) return Float64(cos(x) * Float64(sinh(y) / y)) end
function tmp = code(x, y) tmp = cos(x) * (sinh(y) / y); end
code[x_, y_] := N[(N[Cos[x], $MachinePrecision] * N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos x \cdot \frac{\sinh y}{y}
\end{array}
(FPCore (x y) :precision binary64 (* (cos x) (/ (sinh y) y)))
double code(double x, double y) {
return cos(x) * (sinh(y) / y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = cos(x) * (sinh(y) / y)
end function
public static double code(double x, double y) {
return Math.cos(x) * (Math.sinh(y) / y);
}
def code(x, y): return math.cos(x) * (math.sinh(y) / y)
function code(x, y) return Float64(cos(x) * Float64(sinh(y) / y)) end
function tmp = code(x, y) tmp = cos(x) * (sinh(y) / y); end
code[x_, y_] := N[(N[Cos[x], $MachinePrecision] * N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos x \cdot \frac{\sinh y}{y}
\end{array}
Initial program 100.0%
Final simplification100.0%
(FPCore (x y) :precision binary64 (if (<= y 2.1e-8) (cos x) (* (sinh y) (/ 1.0 y))))
double code(double x, double y) {
double tmp;
if (y <= 2.1e-8) {
tmp = cos(x);
} else {
tmp = sinh(y) * (1.0 / y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 2.1d-8) then
tmp = cos(x)
else
tmp = sinh(y) * (1.0d0 / y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 2.1e-8) {
tmp = Math.cos(x);
} else {
tmp = Math.sinh(y) * (1.0 / y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 2.1e-8: tmp = math.cos(x) else: tmp = math.sinh(y) * (1.0 / y) return tmp
function code(x, y) tmp = 0.0 if (y <= 2.1e-8) tmp = cos(x); else tmp = Float64(sinh(y) * Float64(1.0 / y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 2.1e-8) tmp = cos(x); else tmp = sinh(y) * (1.0 / y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 2.1e-8], N[Cos[x], $MachinePrecision], N[(N[Sinh[y], $MachinePrecision] * N[(1.0 / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.1 \cdot 10^{-8}:\\
\;\;\;\;\cos x\\
\mathbf{else}:\\
\;\;\;\;\sinh y \cdot \frac{1}{y}\\
\end{array}
\end{array}
if y < 2.09999999999999994e-8Initial program 100.0%
associate-*r/99.9%
associate-*l/99.8%
Simplified99.8%
Taylor expanded in y around 0 70.4%
if 2.09999999999999994e-8 < y Initial program 100.0%
associate-*r/100.0%
associate-*l/100.0%
Simplified100.0%
Taylor expanded in x around 0 76.5%
Final simplification71.9%
(FPCore (x y) :precision binary64 (if (<= y 55000.0) (cos x) (* -0.5 (pow x 2.0))))
double code(double x, double y) {
double tmp;
if (y <= 55000.0) {
tmp = cos(x);
} else {
tmp = -0.5 * pow(x, 2.0);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 55000.0d0) then
tmp = cos(x)
else
tmp = (-0.5d0) * (x ** 2.0d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 55000.0) {
tmp = Math.cos(x);
} else {
tmp = -0.5 * Math.pow(x, 2.0);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 55000.0: tmp = math.cos(x) else: tmp = -0.5 * math.pow(x, 2.0) return tmp
function code(x, y) tmp = 0.0 if (y <= 55000.0) tmp = cos(x); else tmp = Float64(-0.5 * (x ^ 2.0)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 55000.0) tmp = cos(x); else tmp = -0.5 * (x ^ 2.0); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 55000.0], N[Cos[x], $MachinePrecision], N[(-0.5 * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 55000:\\
\;\;\;\;\cos x\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot {x}^{2}\\
\end{array}
\end{array}
if y < 55000Initial program 100.0%
associate-*r/99.9%
associate-*l/99.8%
Simplified99.8%
Taylor expanded in y around 0 69.9%
if 55000 < y Initial program 100.0%
associate-*r/100.0%
associate-*l/100.0%
Simplified100.0%
Taylor expanded in x around inf 100.0%
associate-*r/100.0%
*-commutative100.0%
rec-exp100.0%
Simplified100.0%
Taylor expanded in y around 0 3.1%
Taylor expanded in x around 0 21.7%
Taylor expanded in x around inf 14.6%
Final simplification56.7%
(FPCore (x y) :precision binary64 (cos x))
double code(double x, double y) {
return cos(x);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = cos(x)
end function
public static double code(double x, double y) {
return Math.cos(x);
}
def code(x, y): return math.cos(x)
function code(x, y) return cos(x) end
function tmp = code(x, y) tmp = cos(x); end
code[x_, y_] := N[Cos[x], $MachinePrecision]
\begin{array}{l}
\\
\cos x
\end{array}
Initial program 100.0%
associate-*r/99.9%
associate-*l/99.9%
Simplified99.9%
Taylor expanded in y around 0 54.0%
Final simplification54.0%
(FPCore (x y) :precision binary64 (if (<= x 5.8e+21) 0.25 -1.0))
double code(double x, double y) {
double tmp;
if (x <= 5.8e+21) {
tmp = 0.25;
} else {
tmp = -1.0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= 5.8d+21) then
tmp = 0.25d0
else
tmp = -1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= 5.8e+21) {
tmp = 0.25;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 5.8e+21: tmp = 0.25 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= 5.8e+21) tmp = 0.25; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 5.8e+21) tmp = 0.25; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 5.8e+21], 0.25, -1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 5.8 \cdot 10^{+21}:\\
\;\;\;\;0.25\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < 5.8e21Initial program 100.0%
associate-*r/99.9%
associate-*l/99.9%
Simplified99.9%
Taylor expanded in x around 0 73.0%
Applied egg-rr8.4%
if 5.8e21 < x Initial program 100.0%
associate-*r/99.9%
associate-*l/99.9%
Simplified99.9%
Taylor expanded in x around 0 28.8%
Applied egg-rr6.6%
Final simplification8.0%
(FPCore (x y) :precision binary64 (if (<= x 5.8e+21) 0.3333333333333333 -1.0))
double code(double x, double y) {
double tmp;
if (x <= 5.8e+21) {
tmp = 0.3333333333333333;
} else {
tmp = -1.0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= 5.8d+21) then
tmp = 0.3333333333333333d0
else
tmp = -1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= 5.8e+21) {
tmp = 0.3333333333333333;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 5.8e+21: tmp = 0.3333333333333333 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= 5.8e+21) tmp = 0.3333333333333333; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 5.8e+21) tmp = 0.3333333333333333; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 5.8e+21], 0.3333333333333333, -1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 5.8 \cdot 10^{+21}:\\
\;\;\;\;0.3333333333333333\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < 5.8e21Initial program 100.0%
associate-*r/99.9%
associate-*l/99.9%
Simplified99.9%
Taylor expanded in x around 0 73.0%
Applied egg-rr8.6%
if 5.8e21 < x Initial program 100.0%
associate-*r/99.9%
associate-*l/99.9%
Simplified99.9%
Taylor expanded in x around 0 28.8%
Applied egg-rr6.6%
Final simplification8.1%
(FPCore (x y) :precision binary64 (if (<= x 3.1e+78) 0.5 -1.0))
double code(double x, double y) {
double tmp;
if (x <= 3.1e+78) {
tmp = 0.5;
} else {
tmp = -1.0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= 3.1d+78) then
tmp = 0.5d0
else
tmp = -1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= 3.1e+78) {
tmp = 0.5;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 3.1e+78: tmp = 0.5 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= 3.1e+78) tmp = 0.5; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 3.1e+78) tmp = 0.5; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 3.1e+78], 0.5, -1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.1 \cdot 10^{+78}:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < 3.1e78Initial program 100.0%
associate-*r/99.9%
associate-*l/99.9%
Simplified99.9%
Taylor expanded in x around 0 70.1%
Applied egg-rr9.2%
if 3.1e78 < x Initial program 100.0%
associate-*r/99.9%
associate-*l/99.8%
Simplified99.8%
Taylor expanded in x around 0 29.7%
Applied egg-rr7.2%
Final simplification8.8%
(FPCore (x y) :precision binary64 -3.0)
double code(double x, double y) {
return -3.0;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = -3.0d0
end function
public static double code(double x, double y) {
return -3.0;
}
def code(x, y): return -3.0
function code(x, y) return -3.0 end
function tmp = code(x, y) tmp = -3.0; end
code[x_, y_] := -3.0
\begin{array}{l}
\\
-3
\end{array}
Initial program 100.0%
associate-*r/99.9%
associate-*l/99.9%
Simplified99.9%
Taylor expanded in x around 0 61.8%
Applied egg-rr4.1%
Final simplification4.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 100.0%
associate-*r/99.9%
associate-*l/99.9%
Simplified99.9%
Taylor expanded in x around 0 61.8%
Applied egg-rr5.0%
Final simplification5.0%
(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 100.0%
associate-*r/99.9%
associate-*l/99.9%
Simplified99.9%
Taylor expanded in x around 0 61.8%
Taylor expanded in y around 0 28.6%
Final simplification28.6%
herbie shell --seed 2023302
(FPCore (x y)
:name "Linear.Quaternion:$csin from linear-1.19.1.3"
:precision binary64
(* (cos x) (/ (sinh y) y)))