
(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 7 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 65000000000000.0) (* (cos x) (/ y y)) (/ (+ 16.0 (* -8.0 (pow x 2.0))) y)))
double code(double x, double y) {
double tmp;
if (y <= 65000000000000.0) {
tmp = cos(x) * (y / y);
} else {
tmp = (16.0 + (-8.0 * pow(x, 2.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 <= 65000000000000.0d0) then
tmp = cos(x) * (y / y)
else
tmp = (16.0d0 + ((-8.0d0) * (x ** 2.0d0))) / y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 65000000000000.0) {
tmp = Math.cos(x) * (y / y);
} else {
tmp = (16.0 + (-8.0 * Math.pow(x, 2.0))) / y;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 65000000000000.0: tmp = math.cos(x) * (y / y) else: tmp = (16.0 + (-8.0 * math.pow(x, 2.0))) / y return tmp
function code(x, y) tmp = 0.0 if (y <= 65000000000000.0) tmp = Float64(cos(x) * Float64(y / y)); else tmp = Float64(Float64(16.0 + Float64(-8.0 * (x ^ 2.0))) / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 65000000000000.0) tmp = cos(x) * (y / y); else tmp = (16.0 + (-8.0 * (x ^ 2.0))) / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 65000000000000.0], N[(N[Cos[x], $MachinePrecision] * N[(y / y), $MachinePrecision]), $MachinePrecision], N[(N[(16.0 + N[(-8.0 * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 65000000000000:\\
\;\;\;\;\cos x \cdot \frac{y}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{16 + -8 \cdot {x}^{2}}{y}\\
\end{array}
\end{array}
if y < 6.5e13Initial program 100.0%
Taylor expanded in y around 0 65.2%
if 6.5e13 < y Initial program 100.0%
Applied egg-rr2.2%
Taylor expanded in x around 0 12.5%
associate-*r/12.5%
*-rgt-identity12.5%
associate-*r/12.5%
distribute-rgt-out12.5%
associate-*l/12.5%
*-lft-identity12.5%
+-commutative12.5%
Simplified12.5%
Final simplification53.6%
(FPCore (x y) :precision binary64 (if (<= y 7.5e+14) (* (cos x) (/ y y)) (* -8.0 (/ (pow x 2.0) y))))
double code(double x, double y) {
double tmp;
if (y <= 7.5e+14) {
tmp = cos(x) * (y / y);
} else {
tmp = -8.0 * (pow(x, 2.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 <= 7.5d+14) then
tmp = cos(x) * (y / y)
else
tmp = (-8.0d0) * ((x ** 2.0d0) / y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 7.5e+14) {
tmp = Math.cos(x) * (y / y);
} else {
tmp = -8.0 * (Math.pow(x, 2.0) / y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 7.5e+14: tmp = math.cos(x) * (y / y) else: tmp = -8.0 * (math.pow(x, 2.0) / y) return tmp
function code(x, y) tmp = 0.0 if (y <= 7.5e+14) tmp = Float64(cos(x) * Float64(y / y)); else tmp = Float64(-8.0 * Float64((x ^ 2.0) / y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 7.5e+14) tmp = cos(x) * (y / y); else tmp = -8.0 * ((x ^ 2.0) / y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 7.5e+14], N[(N[Cos[x], $MachinePrecision] * N[(y / y), $MachinePrecision]), $MachinePrecision], N[(-8.0 * N[(N[Power[x, 2.0], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 7.5 \cdot 10^{+14}:\\
\;\;\;\;\cos x \cdot \frac{y}{y}\\
\mathbf{else}:\\
\;\;\;\;-8 \cdot \frac{{x}^{2}}{y}\\
\end{array}
\end{array}
if y < 7.5e14Initial program 100.0%
Taylor expanded in y around 0 65.2%
if 7.5e14 < y Initial program 100.0%
Applied egg-rr2.2%
Taylor expanded in x around 0 12.5%
associate-*r/12.5%
*-rgt-identity12.5%
associate-*r/12.5%
distribute-rgt-out12.5%
associate-*l/12.5%
*-lft-identity12.5%
+-commutative12.5%
Simplified12.5%
Taylor expanded in x around inf 12.0%
Final simplification53.5%
(FPCore (x y) :precision binary64 (if (<= (cos x) -5e-310) -2.0 1.5))
double code(double x, double y) {
double tmp;
if (cos(x) <= -5e-310) {
tmp = -2.0;
} else {
tmp = 1.5;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (cos(x) <= (-5d-310)) then
tmp = -2.0d0
else
tmp = 1.5d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (Math.cos(x) <= -5e-310) {
tmp = -2.0;
} else {
tmp = 1.5;
}
return tmp;
}
def code(x, y): tmp = 0 if math.cos(x) <= -5e-310: tmp = -2.0 else: tmp = 1.5 return tmp
function code(x, y) tmp = 0.0 if (cos(x) <= -5e-310) tmp = -2.0; else tmp = 1.5; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (cos(x) <= -5e-310) tmp = -2.0; else tmp = 1.5; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Cos[x], $MachinePrecision], -5e-310], -2.0, 1.5]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos x \leq -5 \cdot 10^{-310}:\\
\;\;\;\;-2\\
\mathbf{else}:\\
\;\;\;\;1.5\\
\end{array}
\end{array}
if (cos.f64 x) < -4.999999999999985e-310Initial program 100.0%
Applied egg-rr3.0%
Applied egg-rr11.1%
if -4.999999999999985e-310 < (cos.f64 x) Initial program 100.0%
Applied egg-rr2.4%
Applied egg-rr11.3%
Final simplification11.3%
(FPCore (x y) :precision binary64 (* (cos x) (/ y y)))
double code(double x, double y) {
return cos(x) * (y / y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = cos(x) * (y / y)
end function
public static double code(double x, double y) {
return Math.cos(x) * (y / y);
}
def code(x, y): return math.cos(x) * (y / y)
function code(x, y) return Float64(cos(x) * Float64(y / y)) end
function tmp = code(x, y) tmp = cos(x) * (y / y); end
code[x_, y_] := N[(N[Cos[x], $MachinePrecision] * N[(y / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos x \cdot \frac{y}{y}
\end{array}
Initial program 100.0%
Taylor expanded in y around 0 51.6%
Final simplification51.6%
(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 100.0%
Applied egg-rr2.5%
Applied egg-rr3.5%
Final simplification3.5%
(FPCore (x y) :precision binary64 0.5)
double code(double x, double y) {
return 0.5;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 0.5d0
end function
public static double code(double x, double y) {
return 0.5;
}
def code(x, y): return 0.5
function code(x, y) return 0.5 end
function tmp = code(x, y) tmp = 0.5; end
code[x_, y_] := 0.5
\begin{array}{l}
\\
0.5
\end{array}
Initial program 100.0%
Applied egg-rr2.5%
Applied egg-rr8.5%
Final simplification8.5%
herbie shell --seed 2024053
(FPCore (x y)
:name "Linear.Quaternion:$csin from linear-1.19.1.3"
:precision binary64
(* (cos x) (/ (sinh y) y)))