
(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 (* (/ (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.0%
associate-*l/100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x y) :precision binary64 (if (or (<= (sinh y) -10000000.0) (not (<= (sinh y) 2e-6))) (sinh y) (/ (sin x) (+ (* -0.16666666666666666 (* x y)) (/ x y)))))
double code(double x, double y) {
double tmp;
if ((sinh(y) <= -10000000.0) || !(sinh(y) <= 2e-6)) {
tmp = sinh(y);
} else {
tmp = sin(x) / ((-0.16666666666666666 * (x * y)) + (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) <= (-10000000.0d0)) .or. (.not. (sinh(y) <= 2d-6))) then
tmp = sinh(y)
else
tmp = sin(x) / (((-0.16666666666666666d0) * (x * y)) + (x / y))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((Math.sinh(y) <= -10000000.0) || !(Math.sinh(y) <= 2e-6)) {
tmp = Math.sinh(y);
} else {
tmp = Math.sin(x) / ((-0.16666666666666666 * (x * y)) + (x / y));
}
return tmp;
}
def code(x, y): tmp = 0 if (math.sinh(y) <= -10000000.0) or not (math.sinh(y) <= 2e-6): tmp = math.sinh(y) else: tmp = math.sin(x) / ((-0.16666666666666666 * (x * y)) + (x / y)) return tmp
function code(x, y) tmp = 0.0 if ((sinh(y) <= -10000000.0) || !(sinh(y) <= 2e-6)) tmp = sinh(y); else tmp = Float64(sin(x) / Float64(Float64(-0.16666666666666666 * Float64(x * y)) + Float64(x / y))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((sinh(y) <= -10000000.0) || ~((sinh(y) <= 2e-6))) tmp = sinh(y); else tmp = sin(x) / ((-0.16666666666666666 * (x * y)) + (x / y)); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[N[Sinh[y], $MachinePrecision], -10000000.0], N[Not[LessEqual[N[Sinh[y], $MachinePrecision], 2e-6]], $MachinePrecision]], N[Sinh[y], $MachinePrecision], N[(N[Sin[x], $MachinePrecision] / N[(N[(-0.16666666666666666 * N[(x * y), $MachinePrecision]), $MachinePrecision] + N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sinh y \leq -10000000 \lor \neg \left(\sinh y \leq 2 \cdot 10^{-6}\right):\\
\;\;\;\;\sinh y\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin x}{-0.16666666666666666 \cdot \left(x \cdot y\right) + \frac{x}{y}}\\
\end{array}
\end{array}
if (sinh.f64 y) < -1e7 or 1.99999999999999991e-6 < (sinh.f64 y) Initial program 100.0%
associate-*l/100.0%
Simplified100.0%
Taylor expanded in x around 0 77.5%
if -1e7 < (sinh.f64 y) < 1.99999999999999991e-6Initial program 73.8%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around 0 99.7%
Final simplification88.5%
(FPCore (x y) :precision binary64 (if (or (<= (sinh y) -10000000.0) (not (<= (sinh y) 2e-6))) (sinh y) (* (sin x) (/ y x))))
double code(double x, double y) {
double tmp;
if ((sinh(y) <= -10000000.0) || !(sinh(y) <= 2e-6)) {
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) <= (-10000000.0d0)) .or. (.not. (sinh(y) <= 2d-6))) 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) <= -10000000.0) || !(Math.sinh(y) <= 2e-6)) {
tmp = Math.sinh(y);
} else {
tmp = Math.sin(x) * (y / x);
}
return tmp;
}
def code(x, y): tmp = 0 if (math.sinh(y) <= -10000000.0) or not (math.sinh(y) <= 2e-6): tmp = math.sinh(y) else: tmp = math.sin(x) * (y / x) return tmp
function code(x, y) tmp = 0.0 if ((sinh(y) <= -10000000.0) || !(sinh(y) <= 2e-6)) 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) <= -10000000.0) || ~((sinh(y) <= 2e-6))) tmp = sinh(y); else tmp = sin(x) * (y / x); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[N[Sinh[y], $MachinePrecision], -10000000.0], N[Not[LessEqual[N[Sinh[y], $MachinePrecision], 2e-6]], $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 -10000000 \lor \neg \left(\sinh y \leq 2 \cdot 10^{-6}\right):\\
\;\;\;\;\sinh y\\
\mathbf{else}:\\
\;\;\;\;\sin x \cdot \frac{y}{x}\\
\end{array}
\end{array}
if (sinh.f64 y) < -1e7 or 1.99999999999999991e-6 < (sinh.f64 y) Initial program 100.0%
associate-*l/100.0%
Simplified100.0%
Taylor expanded in x around 0 77.5%
if -1e7 < (sinh.f64 y) < 1.99999999999999991e-6Initial program 73.8%
associate-*l/99.9%
Simplified99.9%
Taylor expanded in y around 0 72.9%
associate-/l*98.9%
associate-/r/98.9%
Simplified98.9%
Final simplification88.1%
(FPCore (x y) :precision binary64 (if (or (<= (sinh y) -10000000.0) (not (<= (sinh y) 2e-6))) (sinh y) (* (/ (sin x) x) y)))
double code(double x, double y) {
double tmp;
if ((sinh(y) <= -10000000.0) || !(sinh(y) <= 2e-6)) {
tmp = sinh(y);
} else {
tmp = (sin(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) <= (-10000000.0d0)) .or. (.not. (sinh(y) <= 2d-6))) then
tmp = sinh(y)
else
tmp = (sin(x) / x) * y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((Math.sinh(y) <= -10000000.0) || !(Math.sinh(y) <= 2e-6)) {
tmp = Math.sinh(y);
} else {
tmp = (Math.sin(x) / x) * y;
}
return tmp;
}
def code(x, y): tmp = 0 if (math.sinh(y) <= -10000000.0) or not (math.sinh(y) <= 2e-6): tmp = math.sinh(y) else: tmp = (math.sin(x) / x) * y return tmp
function code(x, y) tmp = 0.0 if ((sinh(y) <= -10000000.0) || !(sinh(y) <= 2e-6)) tmp = sinh(y); else tmp = Float64(Float64(sin(x) / x) * y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((sinh(y) <= -10000000.0) || ~((sinh(y) <= 2e-6))) tmp = sinh(y); else tmp = (sin(x) / x) * y; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[N[Sinh[y], $MachinePrecision], -10000000.0], N[Not[LessEqual[N[Sinh[y], $MachinePrecision], 2e-6]], $MachinePrecision]], N[Sinh[y], $MachinePrecision], N[(N[(N[Sin[x], $MachinePrecision] / x), $MachinePrecision] * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sinh y \leq -10000000 \lor \neg \left(\sinh y \leq 2 \cdot 10^{-6}\right):\\
\;\;\;\;\sinh y\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin x}{x} \cdot y\\
\end{array}
\end{array}
if (sinh.f64 y) < -1e7 or 1.99999999999999991e-6 < (sinh.f64 y) Initial program 100.0%
associate-*l/100.0%
Simplified100.0%
Taylor expanded in x around 0 77.5%
if -1e7 < (sinh.f64 y) < 1.99999999999999991e-6Initial program 73.8%
associate-*l/99.9%
Simplified99.9%
Taylor expanded in y around 0 72.9%
associate-/l*98.9%
Simplified98.9%
associate-/l*72.9%
*-commutative72.9%
associate-*l/99.0%
Applied egg-rr99.0%
Final simplification88.2%
(FPCore (x y) :precision binary64 (if (or (<= (sinh y) -5e-6) (not (<= (sinh y) 5e-16))) (sinh y) (/ y (* x (+ (* x 0.16666666666666666) (/ 1.0 x))))))
double code(double x, double y) {
double tmp;
if ((sinh(y) <= -5e-6) || !(sinh(y) <= 5e-16)) {
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-6)) .or. (.not. (sinh(y) <= 5d-16))) 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-6) || !(Math.sinh(y) <= 5e-16)) {
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-6) or not (math.sinh(y) <= 5e-16): 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-6) || !(sinh(y) <= 5e-16)) 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) <= -5e-6) || ~((sinh(y) <= 5e-16))) 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-6], N[Not[LessEqual[N[Sinh[y], $MachinePrecision], 5e-16]], $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 -5 \cdot 10^{-6} \lor \neg \left(\sinh y \leq 5 \cdot 10^{-16}\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) < -5.00000000000000041e-6 or 5.0000000000000004e-16 < (sinh.f64 y) Initial program 100.0%
associate-*l/100.0%
Simplified100.0%
Taylor expanded in x around 0 77.1%
if -5.00000000000000041e-6 < (sinh.f64 y) < 5.0000000000000004e-16Initial program 72.6%
associate-*l/99.9%
Simplified99.9%
Taylor expanded in y around 0 72.6%
associate-/l*99.9%
Simplified99.9%
clear-num99.8%
associate-/r/99.7%
Applied egg-rr99.7%
Taylor expanded in x around 0 75.2%
Final simplification76.2%
(FPCore (x y) :precision binary64 (if (or (<= y -12200.0) (not (<= y 7.5e+103))) (/ (* x y) x) (/ y (* x (+ (* x 0.16666666666666666) (/ 1.0 x))))))
double code(double x, double y) {
double tmp;
if ((y <= -12200.0) || !(y <= 7.5e+103)) {
tmp = (x * y) / x;
} 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 ((y <= (-12200.0d0)) .or. (.not. (y <= 7.5d+103))) then
tmp = (x * y) / x
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 ((y <= -12200.0) || !(y <= 7.5e+103)) {
tmp = (x * y) / x;
} else {
tmp = y / (x * ((x * 0.16666666666666666) + (1.0 / x)));
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -12200.0) or not (y <= 7.5e+103): tmp = (x * y) / x else: tmp = y / (x * ((x * 0.16666666666666666) + (1.0 / x))) return tmp
function code(x, y) tmp = 0.0 if ((y <= -12200.0) || !(y <= 7.5e+103)) tmp = Float64(Float64(x * y) / x); 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 ((y <= -12200.0) || ~((y <= 7.5e+103))) tmp = (x * y) / x; else tmp = y / (x * ((x * 0.16666666666666666) + (1.0 / x))); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -12200.0], N[Not[LessEqual[y, 7.5e+103]], $MachinePrecision]], N[(N[(x * y), $MachinePrecision] / x), $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}\;y \leq -12200 \lor \neg \left(y \leq 7.5 \cdot 10^{+103}\right):\\
\;\;\;\;\frac{x \cdot y}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{x \cdot \left(x \cdot 0.16666666666666666 + \frac{1}{x}\right)}\\
\end{array}
\end{array}
if y < -12200 or 7.49999999999999922e103 < y Initial program 100.0%
associate-*l/100.0%
Simplified100.0%
Taylor expanded in y around 0 4.8%
associate-/l*4.8%
associate-/r/31.6%
Simplified31.6%
*-commutative31.6%
associate-*r/4.8%
Applied egg-rr4.8%
Taylor expanded in x around 0 20.2%
*-commutative20.2%
Simplified20.2%
if -12200 < y < 7.49999999999999922e103Initial program 77.6%
associate-*l/99.9%
Simplified99.9%
Taylor expanded in y around 0 63.3%
associate-/l*85.6%
Simplified85.6%
clear-num85.6%
associate-/r/85.4%
Applied egg-rr85.4%
Taylor expanded in x around 0 64.5%
Final simplification45.8%
(FPCore (x y) :precision binary64 (if (<= x 5e-25) y (/ (* x y) x)))
double code(double x, double y) {
double tmp;
if (x <= 5e-25) {
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 <= 5d-25) 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 <= 5e-25) {
tmp = y;
} else {
tmp = (x * y) / x;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 5e-25: tmp = y else: tmp = (x * y) / x return tmp
function code(x, y) tmp = 0.0 if (x <= 5e-25) tmp = y; else tmp = Float64(Float64(x * y) / x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 5e-25) tmp = y; else tmp = (x * y) / x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 5e-25], y, N[(N[(x * y), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 5 \cdot 10^{-25}:\\
\;\;\;\;y\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{x}\\
\end{array}
\end{array}
if x < 4.99999999999999962e-25Initial program 82.6%
associate-*l/100.0%
Simplified100.0%
Taylor expanded in y around 0 33.2%
associate-/l*50.6%
associate-/r/65.7%
Simplified65.7%
Taylor expanded in x around 0 37.7%
if 4.99999999999999962e-25 < x Initial program 99.9%
associate-*l/99.9%
Simplified99.9%
Taylor expanded in y around 0 54.2%
associate-/l*54.1%
associate-/r/54.3%
Simplified54.3%
*-commutative54.3%
associate-*r/54.2%
Applied egg-rr54.2%
Taylor expanded in x around 0 22.8%
*-commutative22.8%
Simplified22.8%
Final simplification33.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 87.0%
associate-*l/100.0%
Simplified100.0%
Taylor expanded in y around 0 38.6%
associate-/l*51.5%
associate-/r/62.8%
Simplified62.8%
Taylor expanded in x around 0 29.8%
Final simplification29.8%
(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 2023311
(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))