
(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 9 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 89.9%
*-commutative89.9%
associate-/l*99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y) :precision binary64 (if (or (<= (sinh y) -0.002) (not (<= (sinh y) 5e-8))) (sinh y) (* (sin x) (/ y x))))
double code(double x, double y) {
double tmp;
if ((sinh(y) <= -0.002) || !(sinh(y) <= 5e-8)) {
tmp = sinh(y);
} else {
tmp = sin(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 ((sinh(y) <= (-0.002d0)) .or. (.not. (sinh(y) <= 5d-8))) then
tmp = sinh(y)
else
tmp = sin(x) * (y / x)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((Math.sinh(y) <= -0.002) || !(Math.sinh(y) <= 5e-8)) {
tmp = Math.sinh(y);
} else {
tmp = Math.sin(x) * (y / x);
}
return tmp;
}
def code(x, y): tmp = 0 if (math.sinh(y) <= -0.002) or not (math.sinh(y) <= 5e-8): tmp = math.sinh(y) else: tmp = math.sin(x) * (y / x) return tmp
function code(x, y) tmp = 0.0 if ((sinh(y) <= -0.002) || !(sinh(y) <= 5e-8)) tmp = sinh(y); else tmp = Float64(sin(x) * Float64(y / x)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((sinh(y) <= -0.002) || ~((sinh(y) <= 5e-8))) tmp = sinh(y); else tmp = sin(x) * (y / x); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[N[Sinh[y], $MachinePrecision], -0.002], N[Not[LessEqual[N[Sinh[y], $MachinePrecision], 5e-8]], $MachinePrecision]], N[Sinh[y], $MachinePrecision], N[(N[Sin[x], $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sinh y \leq -0.002 \lor \neg \left(\sinh y \leq 5 \cdot 10^{-8}\right):\\
\;\;\;\;\sinh y\\
\mathbf{else}:\\
\;\;\;\;\sin x \cdot \frac{y}{x}\\
\end{array}
\end{array}
if (sinh.f64 y) < -2e-3 or 4.9999999999999998e-8 < (sinh.f64 y) Initial program 100.0%
associate-*l/100.0%
Simplified100.0%
Taylor expanded in x around 0 73.7%
if -2e-3 < (sinh.f64 y) < 4.9999999999999998e-8Initial program 78.9%
associate-*l/99.9%
Simplified99.9%
Taylor expanded in y around 0 78.3%
associate-/l*99.3%
associate-/r/99.2%
Simplified99.2%
Final simplification85.9%
(FPCore (x y) :precision binary64 (if (or (<= (sinh y) -0.002) (not (<= (sinh y) 5e-8))) (sinh y) (* y (/ (sin x) x))))
double code(double x, double y) {
double tmp;
if ((sinh(y) <= -0.002) || !(sinh(y) <= 5e-8)) {
tmp = sinh(y);
} else {
tmp = y * (sin(x) / 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) <= (-0.002d0)) .or. (.not. (sinh(y) <= 5d-8))) then
tmp = sinh(y)
else
tmp = y * (sin(x) / x)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((Math.sinh(y) <= -0.002) || !(Math.sinh(y) <= 5e-8)) {
tmp = Math.sinh(y);
} else {
tmp = y * (Math.sin(x) / x);
}
return tmp;
}
def code(x, y): tmp = 0 if (math.sinh(y) <= -0.002) or not (math.sinh(y) <= 5e-8): tmp = math.sinh(y) else: tmp = y * (math.sin(x) / x) return tmp
function code(x, y) tmp = 0.0 if ((sinh(y) <= -0.002) || !(sinh(y) <= 5e-8)) 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) <= -0.002) || ~((sinh(y) <= 5e-8))) tmp = sinh(y); else tmp = y * (sin(x) / x); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[N[Sinh[y], $MachinePrecision], -0.002], N[Not[LessEqual[N[Sinh[y], $MachinePrecision], 5e-8]], $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 -0.002 \lor \neg \left(\sinh y \leq 5 \cdot 10^{-8}\right):\\
\;\;\;\;\sinh y\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{\sin x}{x}\\
\end{array}
\end{array}
if (sinh.f64 y) < -2e-3 or 4.9999999999999998e-8 < (sinh.f64 y) Initial program 100.0%
associate-*l/100.0%
Simplified100.0%
Taylor expanded in x around 0 73.7%
if -2e-3 < (sinh.f64 y) < 4.9999999999999998e-8Initial program 78.9%
associate-*l/99.9%
Simplified99.9%
Taylor expanded in y around 0 78.3%
associate-/l*99.3%
Simplified99.3%
clear-num97.5%
associate-/r/99.2%
clear-num99.2%
Applied egg-rr99.2%
Final simplification86.0%
(FPCore (x y) :precision binary64 (if (or (<= (sinh y) -0.002) (not (<= (sinh y) 5e-8))) (sinh y) (/ y (/ x (sin x)))))
double code(double x, double y) {
double tmp;
if ((sinh(y) <= -0.002) || !(sinh(y) <= 5e-8)) {
tmp = sinh(y);
} else {
tmp = y / (x / sin(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) <= (-0.002d0)) .or. (.not. (sinh(y) <= 5d-8))) then
tmp = sinh(y)
else
tmp = y / (x / sin(x))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((Math.sinh(y) <= -0.002) || !(Math.sinh(y) <= 5e-8)) {
tmp = Math.sinh(y);
} else {
tmp = y / (x / Math.sin(x));
}
return tmp;
}
def code(x, y): tmp = 0 if (math.sinh(y) <= -0.002) or not (math.sinh(y) <= 5e-8): tmp = math.sinh(y) else: tmp = y / (x / math.sin(x)) return tmp
function code(x, y) tmp = 0.0 if ((sinh(y) <= -0.002) || !(sinh(y) <= 5e-8)) 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) <= -0.002) || ~((sinh(y) <= 5e-8))) tmp = sinh(y); else tmp = y / (x / sin(x)); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[N[Sinh[y], $MachinePrecision], -0.002], N[Not[LessEqual[N[Sinh[y], $MachinePrecision], 5e-8]], $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 -0.002 \lor \neg \left(\sinh y \leq 5 \cdot 10^{-8}\right):\\
\;\;\;\;\sinh y\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{\frac{x}{\sin x}}\\
\end{array}
\end{array}
if (sinh.f64 y) < -2e-3 or 4.9999999999999998e-8 < (sinh.f64 y) Initial program 100.0%
associate-*l/100.0%
Simplified100.0%
Taylor expanded in x around 0 73.7%
if -2e-3 < (sinh.f64 y) < 4.9999999999999998e-8Initial program 78.9%
associate-*l/99.9%
Simplified99.9%
Taylor expanded in y around 0 78.3%
associate-/l*99.3%
Simplified99.3%
Final simplification86.0%
(FPCore (x y) :precision binary64 (if (or (<= (sinh y) -2e-61) (not (<= (sinh y) 5e-90))) (sinh y) (/ x (/ x y))))
double code(double x, double y) {
double tmp;
if ((sinh(y) <= -2e-61) || !(sinh(y) <= 5e-90)) {
tmp = sinh(y);
} else {
tmp = x / (x / 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) <= (-2d-61)) .or. (.not. (sinh(y) <= 5d-90))) then
tmp = sinh(y)
else
tmp = x / (x / y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((Math.sinh(y) <= -2e-61) || !(Math.sinh(y) <= 5e-90)) {
tmp = Math.sinh(y);
} else {
tmp = x / (x / y);
}
return tmp;
}
def code(x, y): tmp = 0 if (math.sinh(y) <= -2e-61) or not (math.sinh(y) <= 5e-90): tmp = math.sinh(y) else: tmp = x / (x / y) return tmp
function code(x, y) tmp = 0.0 if ((sinh(y) <= -2e-61) || !(sinh(y) <= 5e-90)) tmp = sinh(y); else tmp = Float64(x / Float64(x / y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((sinh(y) <= -2e-61) || ~((sinh(y) <= 5e-90))) tmp = sinh(y); else tmp = x / (x / y); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[N[Sinh[y], $MachinePrecision], -2e-61], N[Not[LessEqual[N[Sinh[y], $MachinePrecision], 5e-90]], $MachinePrecision]], N[Sinh[y], $MachinePrecision], N[(x / N[(x / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sinh y \leq -2 \cdot 10^{-61} \lor \neg \left(\sinh y \leq 5 \cdot 10^{-90}\right):\\
\;\;\;\;\sinh y\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{x}{y}}\\
\end{array}
\end{array}
if (sinh.f64 y) < -2.0000000000000001e-61 or 5.00000000000000019e-90 < (sinh.f64 y) Initial program 98.2%
associate-*l/100.0%
Simplified100.0%
Taylor expanded in x around 0 71.0%
if -2.0000000000000001e-61 < (sinh.f64 y) < 5.00000000000000019e-90Initial program 75.3%
associate-/l*97.8%
Simplified97.8%
*-un-lft-identity97.8%
div-inv97.7%
times-frac75.3%
Applied egg-rr75.3%
Taylor expanded in y around 0 75.3%
*-commutative75.3%
Simplified75.3%
Taylor expanded in x around 0 22.2%
*-commutative22.2%
Simplified22.2%
associate-*l/22.2%
*-un-lft-identity22.2%
*-commutative22.2%
associate-/l*79.6%
Applied egg-rr79.6%
Final simplification74.1%
(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 89.9%
associate-*l/99.9%
Simplified99.9%
Final simplification99.9%
(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 89.9%
associate-*l/99.9%
Simplified99.9%
Taylor expanded in y around 0 39.9%
Taylor expanded in x around 0 22.3%
*-un-lft-identity22.3%
times-frac46.1%
/-rgt-identity46.1%
Applied egg-rr46.1%
Final simplification46.1%
(FPCore (x y) :precision binary64 (/ x (/ x y)))
double code(double x, double y) {
return x / (x / y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x / (x / y)
end function
public static double code(double x, double y) {
return x / (x / y);
}
def code(x, y): return x / (x / y)
function code(x, y) return Float64(x / Float64(x / y)) end
function tmp = code(x, y) tmp = x / (x / y); end
code[x_, y_] := N[(x / N[(x / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{\frac{x}{y}}
\end{array}
Initial program 89.9%
associate-/l*99.2%
Simplified99.2%
*-un-lft-identity99.2%
div-inv99.1%
times-frac89.8%
Applied egg-rr89.8%
Taylor expanded in y around 0 39.9%
*-commutative39.9%
Simplified39.9%
Taylor expanded in x around 0 22.2%
*-commutative22.2%
Simplified22.2%
associate-*l/22.3%
*-un-lft-identity22.3%
*-commutative22.3%
associate-/l*46.5%
Applied egg-rr46.5%
Final simplification46.5%
(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 89.9%
associate-*l/99.9%
Simplified99.9%
Taylor expanded in y around 0 39.9%
associate-/l*50.0%
Simplified50.0%
Taylor expanded in x around 0 26.1%
Final simplification26.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 2023308
(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))