
(FPCore (x y) :precision binary64 (/ (* (sin x) (sinh y)) x))
double code(double x, double y) {
return (sin(x) * sinh(y)) / x;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (sin(x) * sinh(y)) / x
end function
public static double code(double x, double y) {
return (Math.sin(x) * Math.sinh(y)) / x;
}
def code(x, y): return (math.sin(x) * math.sinh(y)) / x
function code(x, y) return Float64(Float64(sin(x) * sinh(y)) / x) end
function tmp = code(x, y) tmp = (sin(x) * sinh(y)) / x; end
code[x_, y_] := N[(N[(N[Sin[x], $MachinePrecision] * N[Sinh[y], $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin x \cdot \sinh y}{x}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (/ (* (sin x) (sinh y)) x))
double code(double x, double y) {
return (sin(x) * sinh(y)) / x;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (sin(x) * sinh(y)) / x
end function
public static double code(double x, double y) {
return (Math.sin(x) * Math.sinh(y)) / x;
}
def code(x, y): return (math.sin(x) * math.sinh(y)) / x
function code(x, y) return Float64(Float64(sin(x) * sinh(y)) / x) end
function tmp = code(x, y) tmp = (sin(x) * sinh(y)) / x; end
code[x_, y_] := N[(N[(N[Sin[x], $MachinePrecision] * N[Sinh[y], $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin x \cdot \sinh y}{x}
\end{array}
(FPCore (x y) :precision binary64 (* (sinh y) (/ (sin x) x)))
double code(double x, double y) {
return sinh(y) * (sin(x) / x);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sinh(y) * (sin(x) / x)
end function
public static double code(double x, double y) {
return Math.sinh(y) * (Math.sin(x) / x);
}
def code(x, y): return math.sinh(y) * (math.sin(x) / x)
function code(x, y) return Float64(sinh(y) * Float64(sin(x) / x)) end
function tmp = code(x, y) tmp = sinh(y) * (sin(x) / x); end
code[x_, y_] := N[(N[Sinh[y], $MachinePrecision] * N[(N[Sin[x], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sinh y \cdot \frac{\sin x}{x}
\end{array}
Initial program 92.0%
*-commutative92.0%
associate-/l*99.6%
Applied egg-rr99.6%
Final simplification99.6%
(FPCore (x y) :precision binary64 (if (<= (sinh y) 5e-7) (* y (/ (sin x) x)) (sinh y)))
double code(double x, double y) {
double tmp;
if (sinh(y) <= 5e-7) {
tmp = y * (sin(x) / x);
} else {
tmp = sinh(y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (sinh(y) <= 5d-7) then
tmp = y * (sin(x) / x)
else
tmp = sinh(y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (Math.sinh(y) <= 5e-7) {
tmp = y * (Math.sin(x) / x);
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= 5e-7: tmp = y * (math.sin(x) / x) else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= 5e-7) tmp = Float64(y * Float64(sin(x) / x)); else tmp = sinh(y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (sinh(y) <= 5e-7) tmp = y * (sin(x) / x); else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], 5e-7], N[(y * N[(N[Sin[x], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], N[Sinh[y], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sinh y \leq 5 \cdot 10^{-7}:\\
\;\;\;\;y \cdot \frac{\sin x}{x}\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if (sinh.f64 y) < 4.99999999999999977e-7Initial program 89.5%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around 0 51.9%
associate-/l*62.3%
Simplified62.3%
if 4.99999999999999977e-7 < (sinh.f64 y) Initial program 98.6%
*-commutative98.6%
associate-/l*98.6%
Applied egg-rr98.6%
Taylor expanded in x around 0 71.4%
Final simplification64.8%
(FPCore (x y) :precision binary64 (if (<= (sinh y) 5e-77) (/ (/ y x) (/ 1.0 x)) (sinh y)))
double code(double x, double y) {
double tmp;
if (sinh(y) <= 5e-77) {
tmp = (y / x) / (1.0 / x);
} else {
tmp = sinh(y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (sinh(y) <= 5d-77) then
tmp = (y / x) / (1.0d0 / x)
else
tmp = sinh(y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (Math.sinh(y) <= 5e-77) {
tmp = (y / x) / (1.0 / x);
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= 5e-77: tmp = (y / x) / (1.0 / x) else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= 5e-77) tmp = Float64(Float64(y / x) / Float64(1.0 / x)); else tmp = sinh(y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (sinh(y) <= 5e-77) tmp = (y / x) / (1.0 / x); else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], 5e-77], N[(N[(y / x), $MachinePrecision] / N[(1.0 / x), $MachinePrecision]), $MachinePrecision], N[Sinh[y], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sinh y \leq 5 \cdot 10^{-77}:\\
\;\;\;\;\frac{\frac{y}{x}}{\frac{1}{x}}\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if (sinh.f64 y) < 4.99999999999999963e-77Initial program 88.8%
Taylor expanded in y around 0 48.4%
associate-/l*70.2%
*-commutative70.2%
Applied egg-rr70.2%
associate-/r/59.5%
div-inv59.4%
associate-/r*70.1%
Applied egg-rr70.1%
Taylor expanded in x around 0 55.9%
if 4.99999999999999963e-77 < (sinh.f64 y) Initial program 98.6%
*-commutative98.6%
associate-/l*98.8%
Applied egg-rr98.8%
Taylor expanded in x around 0 67.8%
Final simplification59.7%
(FPCore (x y) :precision binary64 (* (sin x) (/ (sinh y) x)))
double code(double x, double y) {
return sin(x) * (sinh(y) / x);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sin(x) * (sinh(y) / x)
end function
public static double code(double x, double y) {
return Math.sin(x) * (Math.sinh(y) / x);
}
def code(x, y): return math.sin(x) * (math.sinh(y) / x)
function code(x, y) return Float64(sin(x) * Float64(sinh(y) / x)) end
function tmp = code(x, y) tmp = sin(x) * (sinh(y) / x); end
code[x_, y_] := N[(N[Sin[x], $MachinePrecision] * N[(N[Sinh[y], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin x \cdot \frac{\sinh y}{x}
\end{array}
Initial program 92.0%
associate-/l*99.5%
Simplified99.5%
Final simplification99.5%
(FPCore (x y) :precision binary64 (if (<= x 3.5e+92) y (/ 1.0 (/ x (* y x)))))
double code(double x, double y) {
double tmp;
if (x <= 3.5e+92) {
tmp = y;
} else {
tmp = 1.0 / (x / (y * x));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= 3.5d+92) then
tmp = y
else
tmp = 1.0d0 / (x / (y * x))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= 3.5e+92) {
tmp = y;
} else {
tmp = 1.0 / (x / (y * x));
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 3.5e+92: tmp = y else: tmp = 1.0 / (x / (y * x)) return tmp
function code(x, y) tmp = 0.0 if (x <= 3.5e+92) tmp = y; else tmp = Float64(1.0 / Float64(x / Float64(y * x))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 3.5e+92) tmp = y; else tmp = 1.0 / (x / (y * x)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 3.5e+92], y, N[(1.0 / N[(x / N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.5 \cdot 10^{+92}:\\
\;\;\;\;y\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{x}{y \cdot x}}\\
\end{array}
\end{array}
if x < 3.49999999999999986e92Initial program 89.7%
associate-/l*99.4%
Simplified99.4%
Taylor expanded in y around 0 35.2%
associate-/l*44.9%
Simplified44.9%
Taylor expanded in x around 0 28.0%
if 3.49999999999999986e92 < x Initial program 99.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 53.8%
associate-/l*53.8%
Simplified53.8%
associate-*r/53.8%
*-commutative53.8%
clear-num52.4%
associate-/r*52.3%
Applied egg-rr52.3%
Taylor expanded in x around inf 52.4%
Taylor expanded in x around 0 17.3%
*-commutative17.3%
Simplified17.3%
Final simplification25.6%
(FPCore (x y) :precision binary64 (if (<= x 1.85e+96) y (/ (* y x) x)))
double code(double x, double y) {
double tmp;
if (x <= 1.85e+96) {
tmp = y;
} else {
tmp = (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 <= 1.85d+96) then
tmp = y
else
tmp = (y * x) / x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= 1.85e+96) {
tmp = y;
} else {
tmp = (y * x) / x;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 1.85e+96: tmp = y else: tmp = (y * x) / x return tmp
function code(x, y) tmp = 0.0 if (x <= 1.85e+96) tmp = y; else tmp = Float64(Float64(y * x) / x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 1.85e+96) tmp = y; else tmp = (y * x) / x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 1.85e+96], y, N[(N[(y * x), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.85 \cdot 10^{+96}:\\
\;\;\;\;y\\
\mathbf{else}:\\
\;\;\;\;\frac{y \cdot x}{x}\\
\end{array}
\end{array}
if x < 1.84999999999999996e96Initial program 89.8%
associate-/l*99.4%
Simplified99.4%
Taylor expanded in y around 0 35.5%
associate-/l*45.2%
Simplified45.2%
Taylor expanded in x around 0 27.8%
if 1.84999999999999996e96 < x Initial program 99.9%
Taylor expanded in y around 0 53.0%
Taylor expanded in x around 0 17.5%
Final simplification25.6%
(FPCore (x y) :precision binary64 (/ (/ y x) (/ 1.0 x)))
double code(double x, double y) {
return (y / x) / (1.0 / x);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (y / x) / (1.0d0 / x)
end function
public static double code(double x, double y) {
return (y / x) / (1.0 / x);
}
def code(x, y): return (y / x) / (1.0 / x)
function code(x, y) return Float64(Float64(y / x) / Float64(1.0 / x)) end
function tmp = code(x, y) tmp = (y / x) / (1.0 / x); end
code[x_, y_] := N[(N[(y / x), $MachinePrecision] / N[(1.0 / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{y}{x}}{\frac{1}{x}}
\end{array}
Initial program 92.0%
Taylor expanded in y around 0 39.3%
associate-/l*60.2%
*-commutative60.2%
Applied egg-rr60.2%
associate-/r/46.9%
div-inv46.8%
associate-/r*60.2%
Applied egg-rr60.2%
Taylor expanded in x around 0 47.9%
Final simplification47.9%
(FPCore (x y) :precision binary64 y)
double code(double x, double y) {
return y;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = y
end function
public static double code(double x, double y) {
return y;
}
def code(x, y): return y
function code(x, y) return y end
function tmp = code(x, y) tmp = y; end
code[x_, y_] := y
\begin{array}{l}
\\
y
\end{array}
Initial program 92.0%
associate-/l*99.5%
Simplified99.5%
Taylor expanded in y around 0 39.3%
associate-/l*46.9%
Simplified46.9%
Taylor expanded in x around 0 22.6%
Final simplification22.6%
(FPCore (x y) :precision binary64 (* (sin x) (/ (sinh y) x)))
double code(double x, double y) {
return sin(x) * (sinh(y) / x);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sin(x) * (sinh(y) / x)
end function
public static double code(double x, double y) {
return Math.sin(x) * (Math.sinh(y) / x);
}
def code(x, y): return math.sin(x) * (math.sinh(y) / x)
function code(x, y) return Float64(sin(x) * Float64(sinh(y) / x)) end
function tmp = code(x, y) tmp = sin(x) * (sinh(y) / x); end
code[x_, y_] := N[(N[Sin[x], $MachinePrecision] * N[(N[Sinh[y], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin x \cdot \frac{\sinh y}{x}
\end{array}
herbie shell --seed 2024079
(FPCore (x y)
:name "Linear.Quaternion:$ccosh from linear-1.19.1.3"
:precision binary64
:alt
(* (sin x) (/ (sinh y) x))
(/ (* (sin x) (sinh y)) x))