
(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 6 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 (* (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 88.1%
associate-/l*99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (x y) :precision binary64 (if (<= (sinh y) 20.0) (* y (/ (sin x) x)) (sinh y)))
double code(double x, double y) {
double tmp;
if (sinh(y) <= 20.0) {
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) <= 20.0d0) 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) <= 20.0) {
tmp = y * (Math.sin(x) / x);
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= 20.0: tmp = y * (math.sin(x) / x) else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= 20.0) 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) <= 20.0) tmp = y * (sin(x) / x); else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], 20.0], 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 20:\\
\;\;\;\;y \cdot \frac{\sin x}{x}\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if (sinh.f64 y) < 20Initial program 84.6%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around 0 58.1%
associate-/l*73.4%
Simplified73.4%
if 20 < (sinh.f64 y) Initial program 100.0%
associate-/l*100.0%
Simplified100.0%
associate-*r/100.0%
clear-num100.0%
*-commutative100.0%
associate-/r*100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 67.2%
metadata-eval67.2%
associate-*l/67.2%
associate-/r/67.2%
rec-exp67.2%
sinh-def67.2%
Simplified67.2%
remove-double-div67.2%
sinh-def67.2%
div-sub67.2%
Applied egg-rr67.2%
div-sub67.2%
sinh-def67.2%
Simplified67.2%
Final simplification72.0%
(FPCore (x y) :precision binary64 (if (<= (sinh y) 20.0) (/ y (/ x (sin x))) (sinh y)))
double code(double x, double y) {
double tmp;
if (sinh(y) <= 20.0) {
tmp = y / (x / sin(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) <= 20.0d0) then
tmp = y / (x / sin(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) <= 20.0) {
tmp = y / (x / Math.sin(x));
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= 20.0: tmp = y / (x / math.sin(x)) else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= 20.0) tmp = Float64(y / Float64(x / sin(x))); else tmp = sinh(y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (sinh(y) <= 20.0) tmp = y / (x / sin(x)); else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], 20.0], N[(y / N[(x / N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sinh[y], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sinh y \leq 20:\\
\;\;\;\;\frac{y}{\frac{x}{\sin x}}\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if (sinh.f64 y) < 20Initial program 84.6%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around 0 58.1%
associate-/l*73.4%
Simplified73.4%
clear-num73.4%
un-div-inv73.4%
Applied egg-rr73.4%
if 20 < (sinh.f64 y) Initial program 100.0%
associate-/l*100.0%
Simplified100.0%
associate-*r/100.0%
clear-num100.0%
*-commutative100.0%
associate-/r*100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 67.2%
metadata-eval67.2%
associate-*l/67.2%
associate-/r/67.2%
rec-exp67.2%
sinh-def67.2%
Simplified67.2%
remove-double-div67.2%
sinh-def67.2%
div-sub67.2%
Applied egg-rr67.2%
div-sub67.2%
sinh-def67.2%
Simplified67.2%
Final simplification72.0%
(FPCore (x y) :precision binary64 (sinh y))
double code(double x, double y) {
return sinh(y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sinh(y)
end function
public static double code(double x, double y) {
return Math.sinh(y);
}
def code(x, y): return math.sinh(y)
function code(x, y) return sinh(y) end
function tmp = code(x, y) tmp = sinh(y); end
code[x_, y_] := N[Sinh[y], $MachinePrecision]
\begin{array}{l}
\\
\sinh y
\end{array}
Initial program 88.1%
associate-/l*99.8%
Simplified99.8%
associate-*r/88.1%
clear-num87.4%
*-commutative87.4%
associate-/r*99.2%
Applied egg-rr99.2%
Taylor expanded in x around 0 52.3%
metadata-eval52.3%
associate-*l/52.3%
associate-/r/52.3%
rec-exp52.3%
sinh-def60.7%
Simplified60.7%
remove-double-div60.8%
sinh-def52.3%
div-sub52.3%
Applied egg-rr52.3%
div-sub52.3%
sinh-def60.8%
Simplified60.8%
Final simplification60.8%
(FPCore (x y) :precision binary64 (if (<= x 2.15e+30) y (/ (* x y) x)))
double code(double x, double y) {
double tmp;
if (x <= 2.15e+30) {
tmp = y;
} else {
tmp = (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 <= 2.15d+30) then
tmp = y
else
tmp = (x * y) / x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= 2.15e+30) {
tmp = y;
} else {
tmp = (x * y) / x;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 2.15e+30: tmp = y else: tmp = (x * y) / x return tmp
function code(x, y) tmp = 0.0 if (x <= 2.15e+30) tmp = y; else tmp = Float64(Float64(x * y) / x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 2.15e+30) tmp = y; else tmp = (x * y) / x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 2.15e+30], y, N[(N[(x * y), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.15 \cdot 10^{+30}:\\
\;\;\;\;y\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{x}\\
\end{array}
\end{array}
if x < 2.15e30Initial program 85.3%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around 0 41.2%
associate-/l*55.9%
Simplified55.9%
Taylor expanded in x around 0 36.8%
if 2.15e30 < x Initial program 99.8%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 65.9%
Taylor expanded in x around 0 11.9%
*-commutative11.9%
Simplified11.9%
Final simplification31.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 88.1%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around 0 46.0%
associate-/l*57.8%
Simplified57.8%
Taylor expanded in x around 0 30.5%
Final simplification30.5%
(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 2024130
(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))