
(FPCore (x y) :precision binary64 (* (sin x) (/ (sinh y) y)))
double code(double x, double y) {
return sin(x) * (sinh(y) / y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sin(x) * (sinh(y) / y)
end function
public static double code(double x, double y) {
return Math.sin(x) * (Math.sinh(y) / y);
}
def code(x, y): return math.sin(x) * (math.sinh(y) / y)
function code(x, y) return Float64(sin(x) * Float64(sinh(y) / y)) end
function tmp = code(x, y) tmp = sin(x) * (sinh(y) / y); end
code[x_, y_] := N[(N[Sin[x], $MachinePrecision] * N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin x \cdot \frac{\sinh y}{y}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (* (sin x) (/ (sinh y) y)))
double code(double x, double y) {
return sin(x) * (sinh(y) / y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sin(x) * (sinh(y) / y)
end function
public static double code(double x, double y) {
return Math.sin(x) * (Math.sinh(y) / y);
}
def code(x, y): return math.sin(x) * (math.sinh(y) / y)
function code(x, y) return Float64(sin(x) * Float64(sinh(y) / y)) end
function tmp = code(x, y) tmp = sin(x) * (sinh(y) / y); end
code[x_, y_] := N[(N[Sin[x], $MachinePrecision] * N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin x \cdot \frac{\sinh y}{y}
\end{array}
(FPCore (x y) :precision binary64 (/ (sin x) (/ y (sinh y))))
double code(double x, double y) {
return sin(x) / (y / sinh(y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sin(x) / (y / sinh(y))
end function
public static double code(double x, double y) {
return Math.sin(x) / (y / Math.sinh(y));
}
def code(x, y): return math.sin(x) / (y / math.sinh(y))
function code(x, y) return Float64(sin(x) / Float64(y / sinh(y))) end
function tmp = code(x, y) tmp = sin(x) / (y / sinh(y)); end
code[x_, y_] := N[(N[Sin[x], $MachinePrecision] / N[(y / N[Sinh[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin x}{\frac{y}{\sinh y}}
\end{array}
Initial program 100.0%
associate-*r/87.9%
associate-/l*100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x y) :precision binary64 (* (sin x) (/ (sinh y) y)))
double code(double x, double y) {
return sin(x) * (sinh(y) / y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sin(x) * (sinh(y) / y)
end function
public static double code(double x, double y) {
return Math.sin(x) * (Math.sinh(y) / y);
}
def code(x, y): return math.sin(x) * (math.sinh(y) / y)
function code(x, y) return Float64(sin(x) * Float64(sinh(y) / y)) end
function tmp = code(x, y) tmp = sin(x) * (sinh(y) / y); end
code[x_, y_] := N[(N[Sin[x], $MachinePrecision] * N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin x \cdot \frac{\sinh y}{y}
\end{array}
Initial program 100.0%
Final simplification100.0%
(FPCore (x y) :precision binary64 (if (<= y 2.45e-5) (sin x) (/ x (/ y (sinh y)))))
double code(double x, double y) {
double tmp;
if (y <= 2.45e-5) {
tmp = sin(x);
} else {
tmp = x / (y / sinh(y));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 2.45d-5) then
tmp = sin(x)
else
tmp = x / (y / sinh(y))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 2.45e-5) {
tmp = Math.sin(x);
} else {
tmp = x / (y / Math.sinh(y));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 2.45e-5: tmp = math.sin(x) else: tmp = x / (y / math.sinh(y)) return tmp
function code(x, y) tmp = 0.0 if (y <= 2.45e-5) tmp = sin(x); else tmp = Float64(x / Float64(y / sinh(y))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 2.45e-5) tmp = sin(x); else tmp = x / (y / sinh(y)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 2.45e-5], N[Sin[x], $MachinePrecision], N[(x / N[(y / N[Sinh[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.45 \cdot 10^{-5}:\\
\;\;\;\;\sin x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{y}{\sinh y}}\\
\end{array}
\end{array}
if y < 2.45e-5Initial program 100.0%
*-commutative100.0%
associate-/r/92.0%
Simplified92.0%
Taylor expanded in y around 0 69.2%
if 2.45e-5 < y Initial program 100.0%
associate-*r/100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around 0 72.5%
Final simplification69.8%
(FPCore (x y) :precision binary64 (if (<= y 22000000000000.0) (sin x) (* -0.16666666666666666 (pow x 3.0))))
double code(double x, double y) {
double tmp;
if (y <= 22000000000000.0) {
tmp = sin(x);
} else {
tmp = -0.16666666666666666 * pow(x, 3.0);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 22000000000000.0d0) then
tmp = sin(x)
else
tmp = (-0.16666666666666666d0) * (x ** 3.0d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 22000000000000.0) {
tmp = Math.sin(x);
} else {
tmp = -0.16666666666666666 * Math.pow(x, 3.0);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 22000000000000.0: tmp = math.sin(x) else: tmp = -0.16666666666666666 * math.pow(x, 3.0) return tmp
function code(x, y) tmp = 0.0 if (y <= 22000000000000.0) tmp = sin(x); else tmp = Float64(-0.16666666666666666 * (x ^ 3.0)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 22000000000000.0) tmp = sin(x); else tmp = -0.16666666666666666 * (x ^ 3.0); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 22000000000000.0], N[Sin[x], $MachinePrecision], N[(-0.16666666666666666 * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 22000000000000:\\
\;\;\;\;\sin x\\
\mathbf{else}:\\
\;\;\;\;-0.16666666666666666 \cdot {x}^{3}\\
\end{array}
\end{array}
if y < 2.2e13Initial program 100.0%
*-commutative100.0%
associate-/r/92.2%
Simplified92.2%
Taylor expanded in y around 0 67.6%
if 2.2e13 < y Initial program 100.0%
*-commutative100.0%
associate-/r/80.0%
Simplified80.0%
Taylor expanded in y around 0 2.7%
clear-num2.7%
associate-/r/2.7%
clear-num2.7%
Applied egg-rr2.7%
Taylor expanded in x around 0 28.2%
Taylor expanded in x around inf 27.6%
Final simplification60.6%
(FPCore (x y) :precision binary64 (if (<= y 4.9e+129) (sin x) (/ (* x y) y)))
double code(double x, double y) {
double tmp;
if (y <= 4.9e+129) {
tmp = sin(x);
} else {
tmp = (x * y) / y;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 4.9d+129) then
tmp = sin(x)
else
tmp = (x * y) / y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 4.9e+129) {
tmp = Math.sin(x);
} else {
tmp = (x * y) / y;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 4.9e+129: tmp = math.sin(x) else: tmp = (x * y) / y return tmp
function code(x, y) tmp = 0.0 if (y <= 4.9e+129) tmp = sin(x); else tmp = Float64(Float64(x * y) / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 4.9e+129) tmp = sin(x); else tmp = (x * y) / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 4.9e+129], N[Sin[x], $MachinePrecision], N[(N[(x * y), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.9 \cdot 10^{+129}:\\
\;\;\;\;\sin x\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{y}\\
\end{array}
\end{array}
if y < 4.9e129Initial program 100.0%
*-commutative100.0%
associate-/r/91.4%
Simplified91.4%
Taylor expanded in y around 0 63.8%
if 4.9e129 < y Initial program 100.0%
*-commutative100.0%
associate-/r/81.3%
Simplified81.3%
Taylor expanded in y around 0 2.7%
clear-num2.7%
associate-/r/2.7%
clear-num2.7%
Applied egg-rr2.7%
associate-*l/2.8%
Applied egg-rr2.8%
Taylor expanded in x around 0 7.9%
Final simplification56.8%
(FPCore (x y) :precision binary64 (if (<= y 92000.0) (/ y (+ (* (* x y) 0.16666666666666666) (/ y x))) (* (/ 1.0 y) (/ y (/ 1.0 x)))))
double code(double x, double y) {
double tmp;
if (y <= 92000.0) {
tmp = y / (((x * y) * 0.16666666666666666) + (y / x));
} else {
tmp = (1.0 / y) * (y / (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 <= 92000.0d0) then
tmp = y / (((x * y) * 0.16666666666666666d0) + (y / x))
else
tmp = (1.0d0 / y) * (y / (1.0d0 / x))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 92000.0) {
tmp = y / (((x * y) * 0.16666666666666666) + (y / x));
} else {
tmp = (1.0 / y) * (y / (1.0 / x));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 92000.0: tmp = y / (((x * y) * 0.16666666666666666) + (y / x)) else: tmp = (1.0 / y) * (y / (1.0 / x)) return tmp
function code(x, y) tmp = 0.0 if (y <= 92000.0) tmp = Float64(y / Float64(Float64(Float64(x * y) * 0.16666666666666666) + Float64(y / x))); else tmp = Float64(Float64(1.0 / y) * Float64(y / Float64(1.0 / x))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 92000.0) tmp = y / (((x * y) * 0.16666666666666666) + (y / x)); else tmp = (1.0 / y) * (y / (1.0 / x)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 92000.0], N[(y / N[(N[(N[(x * y), $MachinePrecision] * 0.16666666666666666), $MachinePrecision] + N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / y), $MachinePrecision] * N[(y / N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 92000:\\
\;\;\;\;\frac{y}{\left(x \cdot y\right) \cdot 0.16666666666666666 + \frac{y}{x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{y} \cdot \frac{y}{\frac{1}{x}}\\
\end{array}
\end{array}
if y < 92000Initial program 100.0%
*-commutative100.0%
associate-/r/92.1%
Simplified92.1%
Taylor expanded in y around 0 69.0%
Taylor expanded in x around 0 38.3%
if 92000 < y Initial program 100.0%
*-commutative100.0%
associate-/r/82.0%
Simplified82.0%
Taylor expanded in y around 0 2.7%
Taylor expanded in x around 0 2.2%
*-un-lft-identity2.2%
div-inv2.2%
times-frac6.0%
Applied egg-rr6.0%
Final simplification32.0%
(FPCore (x y) :precision binary64 (if (<= y 9000.0) (/ 1.0 (+ (/ 1.0 x) (* x 0.16666666666666666))) (* (/ 1.0 y) (/ y (/ 1.0 x)))))
double code(double x, double y) {
double tmp;
if (y <= 9000.0) {
tmp = 1.0 / ((1.0 / x) + (x * 0.16666666666666666));
} else {
tmp = (1.0 / y) * (y / (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 <= 9000.0d0) then
tmp = 1.0d0 / ((1.0d0 / x) + (x * 0.16666666666666666d0))
else
tmp = (1.0d0 / y) * (y / (1.0d0 / x))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 9000.0) {
tmp = 1.0 / ((1.0 / x) + (x * 0.16666666666666666));
} else {
tmp = (1.0 / y) * (y / (1.0 / x));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 9000.0: tmp = 1.0 / ((1.0 / x) + (x * 0.16666666666666666)) else: tmp = (1.0 / y) * (y / (1.0 / x)) return tmp
function code(x, y) tmp = 0.0 if (y <= 9000.0) tmp = Float64(1.0 / Float64(Float64(1.0 / x) + Float64(x * 0.16666666666666666))); else tmp = Float64(Float64(1.0 / y) * Float64(y / Float64(1.0 / x))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 9000.0) tmp = 1.0 / ((1.0 / x) + (x * 0.16666666666666666)); else tmp = (1.0 / y) * (y / (1.0 / x)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 9000.0], N[(1.0 / N[(N[(1.0 / x), $MachinePrecision] + N[(x * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / y), $MachinePrecision] * N[(y / N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 9000:\\
\;\;\;\;\frac{1}{\frac{1}{x} + x \cdot 0.16666666666666666}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{y} \cdot \frac{y}{\frac{1}{x}}\\
\end{array}
\end{array}
if y < 9e3Initial program 100.0%
*-commutative100.0%
associate-/r/92.1%
Simplified92.1%
Taylor expanded in y around 0 69.0%
Taylor expanded in x around 0 38.3%
Taylor expanded in y around 0 38.3%
if 9e3 < y Initial program 100.0%
*-commutative100.0%
associate-/r/82.0%
Simplified82.0%
Taylor expanded in y around 0 2.7%
Taylor expanded in x around 0 2.2%
*-un-lft-identity2.2%
div-inv2.2%
times-frac6.0%
Applied egg-rr6.0%
Final simplification32.0%
(FPCore (x y) :precision binary64 (if (<= y 1.08e+129) x (/ (* x y) y)))
double code(double x, double y) {
double tmp;
if (y <= 1.08e+129) {
tmp = x;
} else {
tmp = (x * y) / y;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 1.08d+129) then
tmp = x
else
tmp = (x * y) / y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 1.08e+129) {
tmp = x;
} else {
tmp = (x * y) / y;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 1.08e+129: tmp = x else: tmp = (x * y) / y return tmp
function code(x, y) tmp = 0.0 if (y <= 1.08e+129) tmp = x; else tmp = Float64(Float64(x * y) / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 1.08e+129) tmp = x; else tmp = (x * y) / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 1.08e+129], x, N[(N[(x * y), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.08 \cdot 10^{+129}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{y}\\
\end{array}
\end{array}
if y < 1.08e129Initial program 100.0%
*-commutative100.0%
associate-/r/91.4%
Simplified91.4%
Taylor expanded in y around 0 63.6%
Taylor expanded in x around 0 35.3%
if 1.08e129 < y Initial program 100.0%
*-commutative100.0%
associate-/r/81.3%
Simplified81.3%
Taylor expanded in y around 0 2.7%
clear-num2.7%
associate-/r/2.7%
clear-num2.7%
Applied egg-rr2.7%
associate-*l/2.8%
Applied egg-rr2.8%
Taylor expanded in x around 0 7.9%
Final simplification31.9%
(FPCore (x y) :precision binary64 x)
double code(double x, double y) {
return x;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x
end function
public static double code(double x, double y) {
return x;
}
def code(x, y): return x
function code(x, y) return x end
function tmp = code(x, y) tmp = x; end
code[x_, y_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 100.0%
*-commutative100.0%
associate-/r/90.1%
Simplified90.1%
Taylor expanded in y around 0 56.0%
Taylor expanded in x around 0 31.2%
Final simplification31.2%
herbie shell --seed 2023308
(FPCore (x y)
:name "Linear.Quaternion:$ccos from linear-1.19.1.3"
:precision binary64
(* (sin x) (/ (sinh y) y)))