
(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 91.8%
*-commutative91.8%
associate-/l*100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x y) :precision binary64 (if (or (<= (sinh y) -5e-8) (not (<= (sinh y) 5e-7))) (sinh y) (* (sin x) (/ y x))))
double code(double x, double y) {
double tmp;
if ((sinh(y) <= -5e-8) || !(sinh(y) <= 5e-7)) {
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) <= (-5d-8)) .or. (.not. (sinh(y) <= 5d-7))) 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) <= -5e-8) || !(Math.sinh(y) <= 5e-7)) {
tmp = Math.sinh(y);
} else {
tmp = Math.sin(x) * (y / x);
}
return tmp;
}
def code(x, y): tmp = 0 if (math.sinh(y) <= -5e-8) or not (math.sinh(y) <= 5e-7): tmp = math.sinh(y) else: tmp = math.sin(x) * (y / x) return tmp
function code(x, y) tmp = 0.0 if ((sinh(y) <= -5e-8) || !(sinh(y) <= 5e-7)) 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) <= -5e-8) || ~((sinh(y) <= 5e-7))) tmp = sinh(y); else tmp = sin(x) * (y / x); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[N[Sinh[y], $MachinePrecision], -5e-8], N[Not[LessEqual[N[Sinh[y], $MachinePrecision], 5e-7]], $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 -5 \cdot 10^{-8} \lor \neg \left(\sinh y \leq 5 \cdot 10^{-7}\right):\\
\;\;\;\;\sinh y\\
\mathbf{else}:\\
\;\;\;\;\sin x \cdot \frac{y}{x}\\
\end{array}
\end{array}
if (sinh.f64 y) < -4.9999999999999998e-8 or 4.99999999999999977e-7 < (sinh.f64 y) Initial program 100.0%
associate-*l/100.0%
Simplified100.0%
Taylor expanded in x around 0 75.2%
if -4.9999999999999998e-8 < (sinh.f64 y) < 4.99999999999999977e-7Initial program 81.1%
associate-*l/99.8%
Simplified99.8%
Taylor expanded in y around 0 81.0%
associate-/l*99.8%
associate-/r/99.7%
Simplified99.7%
Final simplification85.8%
(FPCore (x y) :precision binary64 (if (or (<= (sinh y) -5e-8) (not (<= (sinh y) 5e-7))) (sinh y) (* y (/ (sin x) x))))
double code(double x, double y) {
double tmp;
if ((sinh(y) <= -5e-8) || !(sinh(y) <= 5e-7)) {
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) <= (-5d-8)) .or. (.not. (sinh(y) <= 5d-7))) 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) <= -5e-8) || !(Math.sinh(y) <= 5e-7)) {
tmp = Math.sinh(y);
} else {
tmp = y * (Math.sin(x) / x);
}
return tmp;
}
def code(x, y): tmp = 0 if (math.sinh(y) <= -5e-8) or not (math.sinh(y) <= 5e-7): tmp = math.sinh(y) else: tmp = y * (math.sin(x) / x) return tmp
function code(x, y) tmp = 0.0 if ((sinh(y) <= -5e-8) || !(sinh(y) <= 5e-7)) 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) <= -5e-8) || ~((sinh(y) <= 5e-7))) tmp = sinh(y); else tmp = y * (sin(x) / x); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[N[Sinh[y], $MachinePrecision], -5e-8], N[Not[LessEqual[N[Sinh[y], $MachinePrecision], 5e-7]], $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 -5 \cdot 10^{-8} \lor \neg \left(\sinh y \leq 5 \cdot 10^{-7}\right):\\
\;\;\;\;\sinh y\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{\sin x}{x}\\
\end{array}
\end{array}
if (sinh.f64 y) < -4.9999999999999998e-8 or 4.99999999999999977e-7 < (sinh.f64 y) Initial program 100.0%
associate-*l/100.0%
Simplified100.0%
Taylor expanded in x around 0 75.2%
if -4.9999999999999998e-8 < (sinh.f64 y) < 4.99999999999999977e-7Initial program 81.1%
associate-*l/99.8%
Simplified99.8%
Taylor expanded in y around 0 81.0%
associate-/l*99.8%
Simplified99.8%
associate-/l*81.0%
*-commutative81.0%
associate-*l/99.7%
Applied egg-rr99.7%
Final simplification85.8%
(FPCore (x y) :precision binary64 (if (or (<= (sinh y) -5e-8) (not (<= (sinh y) 5e-7))) (sinh y) (/ y (/ x (sin x)))))
double code(double x, double y) {
double tmp;
if ((sinh(y) <= -5e-8) || !(sinh(y) <= 5e-7)) {
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) <= (-5d-8)) .or. (.not. (sinh(y) <= 5d-7))) 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) <= -5e-8) || !(Math.sinh(y) <= 5e-7)) {
tmp = Math.sinh(y);
} else {
tmp = y / (x / Math.sin(x));
}
return tmp;
}
def code(x, y): tmp = 0 if (math.sinh(y) <= -5e-8) or not (math.sinh(y) <= 5e-7): tmp = math.sinh(y) else: tmp = y / (x / math.sin(x)) return tmp
function code(x, y) tmp = 0.0 if ((sinh(y) <= -5e-8) || !(sinh(y) <= 5e-7)) 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) <= -5e-8) || ~((sinh(y) <= 5e-7))) tmp = sinh(y); else tmp = y / (x / sin(x)); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[N[Sinh[y], $MachinePrecision], -5e-8], N[Not[LessEqual[N[Sinh[y], $MachinePrecision], 5e-7]], $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 -5 \cdot 10^{-8} \lor \neg \left(\sinh y \leq 5 \cdot 10^{-7}\right):\\
\;\;\;\;\sinh y\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{\frac{x}{\sin x}}\\
\end{array}
\end{array}
if (sinh.f64 y) < -4.9999999999999998e-8 or 4.99999999999999977e-7 < (sinh.f64 y) Initial program 100.0%
associate-*l/100.0%
Simplified100.0%
Taylor expanded in x around 0 75.2%
if -4.9999999999999998e-8 < (sinh.f64 y) < 4.99999999999999977e-7Initial program 81.1%
associate-*l/99.8%
Simplified99.8%
Taylor expanded in y around 0 81.0%
associate-/l*99.8%
Simplified99.8%
Final simplification85.9%
(FPCore (x y) :precision binary64 (if (or (<= (sinh y) -5e-8) (not (<= (sinh y) 5e-7))) (sinh y) (/ (/ y x) (+ (* x 0.16666666666666666) (/ 1.0 x)))))
double code(double x, double y) {
double tmp;
if ((sinh(y) <= -5e-8) || !(sinh(y) <= 5e-7)) {
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) <= (-5d-8)) .or. (.not. (sinh(y) <= 5d-7))) 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) <= -5e-8) || !(Math.sinh(y) <= 5e-7)) {
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) <= -5e-8) or not (math.sinh(y) <= 5e-7): 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) <= -5e-8) || !(sinh(y) <= 5e-7)) tmp = sinh(y); else tmp = Float64(Float64(y / 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) <= -5e-8) || ~((sinh(y) <= 5e-7))) 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], -5e-8], N[Not[LessEqual[N[Sinh[y], $MachinePrecision], 5e-7]], $MachinePrecision]], N[Sinh[y], $MachinePrecision], N[(N[(y / x), $MachinePrecision] / N[(N[(x * 0.16666666666666666), $MachinePrecision] + N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sinh y \leq -5 \cdot 10^{-8} \lor \neg \left(\sinh y \leq 5 \cdot 10^{-7}\right):\\
\;\;\;\;\sinh y\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{y}{x}}{x \cdot 0.16666666666666666 + \frac{1}{x}}\\
\end{array}
\end{array}
if (sinh.f64 y) < -4.9999999999999998e-8 or 4.99999999999999977e-7 < (sinh.f64 y) Initial program 100.0%
associate-*l/100.0%
Simplified100.0%
Taylor expanded in x around 0 75.2%
if -4.9999999999999998e-8 < (sinh.f64 y) < 4.99999999999999977e-7Initial program 81.1%
associate-*l/99.8%
Simplified99.8%
Taylor expanded in y around 0 81.0%
associate-/l*99.8%
associate-/r/99.7%
Simplified99.7%
associate-/r/99.8%
div-inv99.6%
associate-/r*99.4%
Applied egg-rr99.4%
Taylor expanded in x around 0 72.0%
Final simplification73.8%
(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 91.8%
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 91.8%
associate-*l/99.9%
Simplified99.9%
Taylor expanded in y around 0 38.3%
associate-/l*46.5%
associate-/r/57.4%
Simplified57.4%
associate-/r/46.5%
div-inv46.4%
associate-/r*57.3%
Applied egg-rr57.3%
Taylor expanded in x around 0 44.9%
Final simplification44.9%
(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 91.8%
associate-*l/99.9%
Simplified99.9%
Taylor expanded in y around 0 38.3%
associate-/l*46.5%
associate-/r/57.4%
Simplified57.4%
associate-/r/46.5%
div-inv46.4%
associate-/r*57.3%
Applied egg-rr57.3%
Taylor expanded in x around 0 44.5%
Final simplification44.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 91.8%
associate-*l/99.9%
Simplified99.9%
Taylor expanded in y around 0 38.3%
associate-/l*46.5%
associate-/r/57.4%
Simplified57.4%
Taylor expanded in x around 0 25.6%
Final simplification25.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 2023320
(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))