
(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 (* (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 89.6%
associate-/l*99.8%
Simplified99.8%
(FPCore (x y) :precision binary64 (if (<= (sinh y) 1e+19) (* y (/ (sin x) x)) (* x (/ (sinh y) x))))
double code(double x, double y) {
double tmp;
if (sinh(y) <= 1e+19) {
tmp = y * (sin(x) / x);
} else {
tmp = x * (sinh(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) <= 1d+19) then
tmp = y * (sin(x) / x)
else
tmp = x * (sinh(y) / x)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (Math.sinh(y) <= 1e+19) {
tmp = y * (Math.sin(x) / x);
} else {
tmp = x * (Math.sinh(y) / x);
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= 1e+19: tmp = y * (math.sin(x) / x) else: tmp = x * (math.sinh(y) / x) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= 1e+19) tmp = Float64(y * Float64(sin(x) / x)); else tmp = Float64(x * Float64(sinh(y) / x)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (sinh(y) <= 1e+19) tmp = y * (sin(x) / x); else tmp = x * (sinh(y) / x); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], 1e+19], N[(y * N[(N[Sin[x], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], N[(x * N[(N[Sinh[y], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sinh y \leq 10^{+19}:\\
\;\;\;\;y \cdot \frac{\sin x}{x}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{\sinh y}{x}\\
\end{array}
\end{array}
if (sinh.f64 y) < 1e19Initial program 85.8%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around 0 57.9%
associate-/l*72.0%
Simplified72.0%
if 1e19 < (sinh.f64 y) Initial program 100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around 0 78.3%
(FPCore (x y) :precision binary64 (if (<= (sinh y) 5e-54) (/ x (/ x y)) (sinh y)))
double code(double x, double y) {
double tmp;
if (sinh(y) <= 5e-54) {
tmp = x / (x / y);
} 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) <= 5d-54) then
tmp = x / (x / y)
else
tmp = sinh(y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (Math.sinh(y) <= 5e-54) {
tmp = x / (x / y);
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= 5e-54: tmp = x / (x / y) else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= 5e-54) tmp = Float64(x / Float64(x / y)); else tmp = sinh(y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (sinh(y) <= 5e-54) tmp = x / (x / y); else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], 5e-54], N[(x / N[(x / y), $MachinePrecision]), $MachinePrecision], N[Sinh[y], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sinh y \leq 5 \cdot 10^{-54}:\\
\;\;\;\;\frac{x}{\frac{x}{y}}\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if (sinh.f64 y) < 5.00000000000000015e-54Initial program 85.1%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around 0 79.3%
Taylor expanded in x around 0 58.0%
clear-num59.7%
un-div-inv58.2%
Applied egg-rr58.2%
if 5.00000000000000015e-54 < (sinh.f64 y) Initial program 99.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around 0 73.1%
clear-num73.1%
un-div-inv73.1%
Applied egg-rr73.1%
associate-/r/73.1%
*-inverses73.1%
*-lft-identity73.1%
Simplified73.1%
(FPCore (x y) :precision binary64 (* x (/ (sinh y) x)))
double code(double x, double y) {
return x * (sinh(y) / x);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x * (sinh(y) / x)
end function
public static double code(double x, double y) {
return x * (Math.sinh(y) / x);
}
def code(x, y): return x * (math.sinh(y) / x)
function code(x, y) return Float64(x * Float64(sinh(y) / x)) end
function tmp = code(x, y) tmp = x * (sinh(y) / x); end
code[x_, y_] := N[(x * N[(N[Sinh[y], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \frac{\sinh y}{x}
\end{array}
Initial program 89.6%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around 0 70.0%
(FPCore (x y)
:precision binary64
(if (<= x 1.76e+115)
(* x (/ 1.0 (/ x y)))
(if (<= x 8.6e+193)
(+ y (* -0.16666666666666666 (* y (* x x))))
(* x (/ y x)))))
double code(double x, double y) {
double tmp;
if (x <= 1.76e+115) {
tmp = x * (1.0 / (x / y));
} else if (x <= 8.6e+193) {
tmp = y + (-0.16666666666666666 * (y * (x * x)));
} 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 <= 1.76d+115) then
tmp = x * (1.0d0 / (x / y))
else if (x <= 8.6d+193) then
tmp = y + ((-0.16666666666666666d0) * (y * (x * x)))
else
tmp = x * (y / x)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= 1.76e+115) {
tmp = x * (1.0 / (x / y));
} else if (x <= 8.6e+193) {
tmp = y + (-0.16666666666666666 * (y * (x * x)));
} else {
tmp = x * (y / x);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 1.76e+115: tmp = x * (1.0 / (x / y)) elif x <= 8.6e+193: tmp = y + (-0.16666666666666666 * (y * (x * x))) else: tmp = x * (y / x) return tmp
function code(x, y) tmp = 0.0 if (x <= 1.76e+115) tmp = Float64(x * Float64(1.0 / Float64(x / y))); elseif (x <= 8.6e+193) tmp = Float64(y + Float64(-0.16666666666666666 * Float64(y * Float64(x * x)))); else tmp = Float64(x * Float64(y / x)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 1.76e+115) tmp = x * (1.0 / (x / y)); elseif (x <= 8.6e+193) tmp = y + (-0.16666666666666666 * (y * (x * x))); else tmp = x * (y / x); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 1.76e+115], N[(x * N[(1.0 / N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 8.6e+193], N[(y + N[(-0.16666666666666666 * N[(y * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(y / x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.76 \cdot 10^{+115}:\\
\;\;\;\;x \cdot \frac{1}{\frac{x}{y}}\\
\mathbf{elif}\;x \leq 8.6 \cdot 10^{+193}:\\
\;\;\;\;y + -0.16666666666666666 \cdot \left(y \cdot \left(x \cdot x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{y}{x}\\
\end{array}
\end{array}
if x < 1.76e115Initial program 88.0%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 69.2%
clear-num68.4%
associate-/r/69.1%
Applied egg-rr69.1%
associate-*l/69.2%
*-un-lft-identity69.2%
clear-num68.4%
Applied egg-rr68.4%
Taylor expanded in x around 0 54.2%
if 1.76e115 < x < 8.6000000000000005e193Initial program 99.8%
associate-/l*99.6%
Simplified99.6%
Taylor expanded in y around 0 53.0%
associate-/l*53.1%
Simplified53.1%
Taylor expanded in x around 0 37.8%
unpow237.8%
Applied egg-rr37.8%
if 8.6000000000000005e193 < x Initial program 99.9%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in y around 0 27.3%
Taylor expanded in x around 0 27.4%
Final simplification51.3%
(FPCore (x y) :precision binary64 (if (or (<= x 9.2e+113) (not (<= x 8.6e+193))) (* x (/ y x)) (* -0.16666666666666666 (* y (* x x)))))
double code(double x, double y) {
double tmp;
if ((x <= 9.2e+113) || !(x <= 8.6e+193)) {
tmp = x * (y / x);
} else {
tmp = -0.16666666666666666 * (y * (x * x));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((x <= 9.2d+113) .or. (.not. (x <= 8.6d+193))) then
tmp = x * (y / x)
else
tmp = (-0.16666666666666666d0) * (y * (x * x))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= 9.2e+113) || !(x <= 8.6e+193)) {
tmp = x * (y / x);
} else {
tmp = -0.16666666666666666 * (y * (x * x));
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= 9.2e+113) or not (x <= 8.6e+193): tmp = x * (y / x) else: tmp = -0.16666666666666666 * (y * (x * x)) return tmp
function code(x, y) tmp = 0.0 if ((x <= 9.2e+113) || !(x <= 8.6e+193)) tmp = Float64(x * Float64(y / x)); else tmp = Float64(-0.16666666666666666 * Float64(y * Float64(x * x))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= 9.2e+113) || ~((x <= 8.6e+193))) tmp = x * (y / x); else tmp = -0.16666666666666666 * (y * (x * x)); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, 9.2e+113], N[Not[LessEqual[x, 8.6e+193]], $MachinePrecision]], N[(x * N[(y / x), $MachinePrecision]), $MachinePrecision], N[(-0.16666666666666666 * N[(y * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 9.2 \cdot 10^{+113} \lor \neg \left(x \leq 8.6 \cdot 10^{+193}\right):\\
\;\;\;\;x \cdot \frac{y}{x}\\
\mathbf{else}:\\
\;\;\;\;-0.16666666666666666 \cdot \left(y \cdot \left(x \cdot x\right)\right)\\
\end{array}
\end{array}
if x < 9.19999999999999987e113 or 8.6000000000000005e193 < x Initial program 88.8%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 66.4%
Taylor expanded in x around 0 51.2%
if 9.19999999999999987e113 < x < 8.6000000000000005e193Initial program 99.8%
associate-/l*99.6%
Simplified99.6%
Taylor expanded in y around 0 53.0%
associate-/l*53.1%
Simplified53.1%
Taylor expanded in x around 0 37.8%
Taylor expanded in x around inf 37.8%
unpow237.8%
Applied egg-rr37.8%
Final simplification50.2%
(FPCore (x y) :precision binary64 (if (<= x 9.2e+113) (* x (/ 1.0 (/ x y))) (if (<= x 4.4e+193) (* -0.16666666666666666 (* y (* x x))) (* x (/ y x)))))
double code(double x, double y) {
double tmp;
if (x <= 9.2e+113) {
tmp = x * (1.0 / (x / y));
} else if (x <= 4.4e+193) {
tmp = -0.16666666666666666 * (y * (x * x));
} 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 <= 9.2d+113) then
tmp = x * (1.0d0 / (x / y))
else if (x <= 4.4d+193) then
tmp = (-0.16666666666666666d0) * (y * (x * x))
else
tmp = x * (y / x)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= 9.2e+113) {
tmp = x * (1.0 / (x / y));
} else if (x <= 4.4e+193) {
tmp = -0.16666666666666666 * (y * (x * x));
} else {
tmp = x * (y / x);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 9.2e+113: tmp = x * (1.0 / (x / y)) elif x <= 4.4e+193: tmp = -0.16666666666666666 * (y * (x * x)) else: tmp = x * (y / x) return tmp
function code(x, y) tmp = 0.0 if (x <= 9.2e+113) tmp = Float64(x * Float64(1.0 / Float64(x / y))); elseif (x <= 4.4e+193) tmp = Float64(-0.16666666666666666 * Float64(y * Float64(x * x))); else tmp = Float64(x * Float64(y / x)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 9.2e+113) tmp = x * (1.0 / (x / y)); elseif (x <= 4.4e+193) tmp = -0.16666666666666666 * (y * (x * x)); else tmp = x * (y / x); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 9.2e+113], N[(x * N[(1.0 / N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 4.4e+193], N[(-0.16666666666666666 * N[(y * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(y / x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 9.2 \cdot 10^{+113}:\\
\;\;\;\;x \cdot \frac{1}{\frac{x}{y}}\\
\mathbf{elif}\;x \leq 4.4 \cdot 10^{+193}:\\
\;\;\;\;-0.16666666666666666 \cdot \left(y \cdot \left(x \cdot x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{y}{x}\\
\end{array}
\end{array}
if x < 9.19999999999999987e113Initial program 88.0%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 69.2%
clear-num68.4%
associate-/r/69.1%
Applied egg-rr69.1%
associate-*l/69.2%
*-un-lft-identity69.2%
clear-num68.4%
Applied egg-rr68.4%
Taylor expanded in x around 0 54.2%
if 9.19999999999999987e113 < x < 4.39999999999999972e193Initial program 99.8%
associate-/l*99.6%
Simplified99.6%
Taylor expanded in y around 0 53.0%
associate-/l*53.1%
Simplified53.1%
Taylor expanded in x around 0 37.8%
Taylor expanded in x around inf 37.8%
unpow237.8%
Applied egg-rr37.8%
if 4.39999999999999972e193 < x Initial program 99.9%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in y around 0 27.3%
Taylor expanded in x around 0 27.4%
Final simplification51.3%
(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.6%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around 0 65.4%
Taylor expanded in x around 0 48.4%
(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.6%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around 0 70.0%
Taylor expanded in y around 0 27.7%
(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 2024143
(FPCore (x y)
:name "Linear.Quaternion:$ccosh from linear-1.19.1.3"
:precision binary64
:alt
(! :herbie-platform default (* (sin x) (/ (sinh y) x)))
(/ (* (sin x) (sinh y)) x))