
(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) (/ x (sin x))))
double code(double x, double y) {
return sinh(y) / (x / sin(x));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sinh(y) / (x / sin(x))
end function
public static double code(double x, double y) {
return Math.sinh(y) / (x / Math.sin(x));
}
def code(x, y): return math.sinh(y) / (x / math.sin(x))
function code(x, y) return Float64(sinh(y) / Float64(x / sin(x))) end
function tmp = code(x, y) tmp = sinh(y) / (x / sin(x)); end
code[x_, y_] := N[(N[Sinh[y], $MachinePrecision] / N[(x / N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sinh y}{\frac{x}{\sin x}}
\end{array}
Initial program 87.7%
*-commutative87.7%
associate-/l*99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y) :precision binary64 (if (or (<= (sinh y) (- INFINITY)) (not (<= (sinh y) 2e+289))) (sinh y) (* y (/ (sin x) x))))
double code(double x, double y) {
double tmp;
if ((sinh(y) <= -((double) INFINITY)) || !(sinh(y) <= 2e+289)) {
tmp = sinh(y);
} else {
tmp = y * (sin(x) / x);
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if ((Math.sinh(y) <= -Double.POSITIVE_INFINITY) || !(Math.sinh(y) <= 2e+289)) {
tmp = Math.sinh(y);
} else {
tmp = y * (Math.sin(x) / x);
}
return tmp;
}
def code(x, y): tmp = 0 if (math.sinh(y) <= -math.inf) or not (math.sinh(y) <= 2e+289): tmp = math.sinh(y) else: tmp = y * (math.sin(x) / x) return tmp
function code(x, y) tmp = 0.0 if ((sinh(y) <= Float64(-Inf)) || !(sinh(y) <= 2e+289)) tmp = sinh(y); else tmp = Float64(y * Float64(sin(x) / x)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((sinh(y) <= -Inf) || ~((sinh(y) <= 2e+289))) tmp = sinh(y); else tmp = y * (sin(x) / x); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[N[Sinh[y], $MachinePrecision], (-Infinity)], N[Not[LessEqual[N[Sinh[y], $MachinePrecision], 2e+289]], $MachinePrecision]], N[Sinh[y], $MachinePrecision], N[(y * N[(N[Sin[x], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sinh y \leq -\infty \lor \neg \left(\sinh y \leq 2 \cdot 10^{+289}\right):\\
\;\;\;\;\sinh y\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{\sin x}{x}\\
\end{array}
\end{array}
if (sinh.f64 y) < -inf.0 or 2.0000000000000001e289 < (sinh.f64 y) Initial program 100.0%
associate-*l/100.0%
Simplified100.0%
Taylor expanded in x around 0 76.7%
if -inf.0 < (sinh.f64 y) < 2.0000000000000001e289Initial program 74.5%
associate-*l/99.9%
Simplified99.9%
Taylor expanded in y around 0 73.0%
associate-/l*98.4%
Simplified98.4%
associate-/l*73.0%
*-commutative73.0%
associate-*l/98.4%
Applied egg-rr98.4%
Final simplification87.1%
(FPCore (x y) :precision binary64 (if (or (<= (sinh y) (- INFINITY)) (not (<= (sinh y) 2e+289))) (sinh y) (/ y (/ x (sin x)))))
double code(double x, double y) {
double tmp;
if ((sinh(y) <= -((double) INFINITY)) || !(sinh(y) <= 2e+289)) {
tmp = sinh(y);
} else {
tmp = y / (x / sin(x));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if ((Math.sinh(y) <= -Double.POSITIVE_INFINITY) || !(Math.sinh(y) <= 2e+289)) {
tmp = Math.sinh(y);
} else {
tmp = y / (x / Math.sin(x));
}
return tmp;
}
def code(x, y): tmp = 0 if (math.sinh(y) <= -math.inf) or not (math.sinh(y) <= 2e+289): tmp = math.sinh(y) else: tmp = y / (x / math.sin(x)) return tmp
function code(x, y) tmp = 0.0 if ((sinh(y) <= Float64(-Inf)) || !(sinh(y) <= 2e+289)) tmp = sinh(y); else tmp = Float64(y / Float64(x / sin(x))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((sinh(y) <= -Inf) || ~((sinh(y) <= 2e+289))) tmp = sinh(y); else tmp = y / (x / sin(x)); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[N[Sinh[y], $MachinePrecision], (-Infinity)], N[Not[LessEqual[N[Sinh[y], $MachinePrecision], 2e+289]], $MachinePrecision]], N[Sinh[y], $MachinePrecision], N[(y / N[(x / N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sinh y \leq -\infty \lor \neg \left(\sinh y \leq 2 \cdot 10^{+289}\right):\\
\;\;\;\;\sinh y\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{\frac{x}{\sin x}}\\
\end{array}
\end{array}
if (sinh.f64 y) < -inf.0 or 2.0000000000000001e289 < (sinh.f64 y) Initial program 100.0%
associate-*l/100.0%
Simplified100.0%
Taylor expanded in x around 0 76.7%
if -inf.0 < (sinh.f64 y) < 2.0000000000000001e289Initial program 74.5%
associate-*l/99.9%
Simplified99.9%
Taylor expanded in y around 0 73.0%
associate-/l*98.4%
Simplified98.4%
Final simplification87.1%
(FPCore (x y) :precision binary64 (if (or (<= (sinh y) -6e-67) (not (<= (sinh y) 2e+289))) (sinh y) (/ y (* x (+ (* x 0.16666666666666666) (/ 1.0 x))))))
double code(double x, double y) {
double tmp;
if ((sinh(y) <= -6e-67) || !(sinh(y) <= 2e+289)) {
tmp = sinh(y);
} else {
tmp = y / (x * ((x * 0.16666666666666666) + (1.0 / x)));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((sinh(y) <= (-6d-67)) .or. (.not. (sinh(y) <= 2d+289))) then
tmp = sinh(y)
else
tmp = y / (x * ((x * 0.16666666666666666d0) + (1.0d0 / x)))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((Math.sinh(y) <= -6e-67) || !(Math.sinh(y) <= 2e+289)) {
tmp = Math.sinh(y);
} else {
tmp = y / (x * ((x * 0.16666666666666666) + (1.0 / x)));
}
return tmp;
}
def code(x, y): tmp = 0 if (math.sinh(y) <= -6e-67) or not (math.sinh(y) <= 2e+289): tmp = math.sinh(y) else: tmp = y / (x * ((x * 0.16666666666666666) + (1.0 / x))) return tmp
function code(x, y) tmp = 0.0 if ((sinh(y) <= -6e-67) || !(sinh(y) <= 2e+289)) tmp = sinh(y); else tmp = Float64(y / Float64(x * Float64(Float64(x * 0.16666666666666666) + Float64(1.0 / x)))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((sinh(y) <= -6e-67) || ~((sinh(y) <= 2e+289))) tmp = sinh(y); else tmp = y / (x * ((x * 0.16666666666666666) + (1.0 / x))); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[N[Sinh[y], $MachinePrecision], -6e-67], N[Not[LessEqual[N[Sinh[y], $MachinePrecision], 2e+289]], $MachinePrecision]], N[Sinh[y], $MachinePrecision], N[(y / N[(x * N[(N[(x * 0.16666666666666666), $MachinePrecision] + N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sinh y \leq -6 \cdot 10^{-67} \lor \neg \left(\sinh y \leq 2 \cdot 10^{+289}\right):\\
\;\;\;\;\sinh y\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{x \cdot \left(x \cdot 0.16666666666666666 + \frac{1}{x}\right)}\\
\end{array}
\end{array}
if (sinh.f64 y) < -6.00000000000000065e-67 or 2.0000000000000001e289 < (sinh.f64 y) Initial program 100.0%
associate-*l/100.0%
Simplified100.0%
Taylor expanded in x around 0 75.9%
if -6.00000000000000065e-67 < (sinh.f64 y) < 2.0000000000000001e289Initial program 73.0%
associate-*l/99.9%
Simplified99.9%
Taylor expanded in y around 0 72.2%
associate-/l*99.1%
Simplified99.1%
clear-num99.0%
associate-/r/98.9%
Applied egg-rr98.9%
Taylor expanded in x around 0 80.4%
Final simplification77.9%
(FPCore (x y) :precision binary64 (* (/ (sin x) x) (sinh y)))
double code(double x, double y) {
return (sin(x) / x) * sinh(y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (sin(x) / x) * sinh(y)
end function
public static double code(double x, double y) {
return (Math.sin(x) / x) * Math.sinh(y);
}
def code(x, y): return (math.sin(x) / x) * math.sinh(y)
function code(x, y) return Float64(Float64(sin(x) / x) * sinh(y)) end
function tmp = code(x, y) tmp = (sin(x) / x) * sinh(y); end
code[x_, y_] := N[(N[(N[Sin[x], $MachinePrecision] / x), $MachinePrecision] * N[Sinh[y], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin x}{x} \cdot \sinh y
\end{array}
Initial program 87.7%
associate-*l/99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y) :precision binary64 (/ (/ y x) (+ (* x 0.16666666666666666) (/ 1.0 x))))
double code(double x, double y) {
return (y / x) / ((x * 0.16666666666666666) + (1.0 / x));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (y / x) / ((x * 0.16666666666666666d0) + (1.0d0 / x))
end function
public static double code(double x, double y) {
return (y / x) / ((x * 0.16666666666666666) + (1.0 / x));
}
def code(x, y): return (y / x) / ((x * 0.16666666666666666) + (1.0 / x))
function code(x, y) return Float64(Float64(y / x) / Float64(Float64(x * 0.16666666666666666) + Float64(1.0 / x))) end
function tmp = code(x, y) tmp = (y / x) / ((x * 0.16666666666666666) + (1.0 / x)); end
code[x_, y_] := N[(N[(y / x), $MachinePrecision] / N[(N[(x * 0.16666666666666666), $MachinePrecision] + N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{y}{x}}{x \cdot 0.16666666666666666 + \frac{1}{x}}
\end{array}
Initial program 87.7%
associate-*l/99.9%
Simplified99.9%
Taylor expanded in y around 0 37.5%
associate-/l*49.7%
Simplified49.7%
associate-/l*37.5%
*-commutative37.5%
associate-*l/49.7%
Applied egg-rr49.7%
*-commutative49.7%
clear-num49.7%
*-un-lft-identity49.7%
associate-*l/49.6%
div-inv49.6%
*-commutative49.6%
associate-/r*65.6%
Applied egg-rr65.6%
Taylor expanded in x around 0 56.1%
Final simplification56.1%
(FPCore (x y) :precision binary64 (* x (/ y x)))
double code(double x, double y) {
return x * (y / x);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x * (y / x)
end function
public static double code(double x, double y) {
return x * (y / x);
}
def code(x, y): return x * (y / x)
function code(x, y) return Float64(x * Float64(y / x)) end
function tmp = code(x, y) tmp = x * (y / x); end
code[x_, y_] := N[(x * N[(y / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \frac{y}{x}
\end{array}
Initial program 87.7%
associate-*l/99.9%
Simplified99.9%
Taylor expanded in y around 0 37.5%
Taylor expanded in x around 0 20.3%
*-commutative20.3%
Simplified20.3%
associate-/l*28.1%
associate-/r/55.1%
Applied egg-rr55.1%
Final simplification55.1%
(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 87.7%
associate-*l/99.9%
Simplified99.9%
Taylor expanded in y around 0 37.5%
associate-/l*49.7%
Simplified49.7%
Taylor expanded in x around 0 28.1%
Final simplification28.1%
(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 2023336
(FPCore (x y)
:name "Linear.Quaternion:$ccosh from linear-1.19.1.3"
:precision binary64
:herbie-target
(* (sin x) (/ (sinh y) x))
(/ (* (sin x) (sinh y)) x))