
(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 7 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) (/ (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 1.36e+19)
(sin x)
(if (or (<= y 3.4e+189) (not (<= y 2.4e+290)))
(/ (* x y) y)
(* -0.16666666666666666 (pow x 3.0)))))
double code(double x, double y) {
double tmp;
if (y <= 1.36e+19) {
tmp = sin(x);
} else if ((y <= 3.4e+189) || !(y <= 2.4e+290)) {
tmp = (x * y) / y;
} 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 <= 1.36d+19) then
tmp = sin(x)
else if ((y <= 3.4d+189) .or. (.not. (y <= 2.4d+290))) then
tmp = (x * y) / y
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 <= 1.36e+19) {
tmp = Math.sin(x);
} else if ((y <= 3.4e+189) || !(y <= 2.4e+290)) {
tmp = (x * y) / y;
} else {
tmp = -0.16666666666666666 * Math.pow(x, 3.0);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 1.36e+19: tmp = math.sin(x) elif (y <= 3.4e+189) or not (y <= 2.4e+290): tmp = (x * y) / y else: tmp = -0.16666666666666666 * math.pow(x, 3.0) return tmp
function code(x, y) tmp = 0.0 if (y <= 1.36e+19) tmp = sin(x); elseif ((y <= 3.4e+189) || !(y <= 2.4e+290)) tmp = Float64(Float64(x * y) / y); else tmp = Float64(-0.16666666666666666 * (x ^ 3.0)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 1.36e+19) tmp = sin(x); elseif ((y <= 3.4e+189) || ~((y <= 2.4e+290))) tmp = (x * y) / y; else tmp = -0.16666666666666666 * (x ^ 3.0); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 1.36e+19], N[Sin[x], $MachinePrecision], If[Or[LessEqual[y, 3.4e+189], N[Not[LessEqual[y, 2.4e+290]], $MachinePrecision]], N[(N[(x * y), $MachinePrecision] / y), $MachinePrecision], N[(-0.16666666666666666 * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.36 \cdot 10^{+19}:\\
\;\;\;\;\sin x\\
\mathbf{elif}\;y \leq 3.4 \cdot 10^{+189} \lor \neg \left(y \leq 2.4 \cdot 10^{+290}\right):\\
\;\;\;\;\frac{x \cdot y}{y}\\
\mathbf{else}:\\
\;\;\;\;-0.16666666666666666 \cdot {x}^{3}\\
\end{array}
\end{array}
if y < 1.36e19Initial program 100.0%
Taylor expanded in y around 0 64.9%
if 1.36e19 < y < 3.39999999999999983e189 or 2.4000000000000001e290 < y Initial program 100.0%
*-commutative100.0%
associate-*l/100.0%
Applied egg-rr100.0%
Taylor expanded in y around 0 2.6%
Taylor expanded in x around 0 25.8%
if 3.39999999999999983e189 < y < 2.4000000000000001e290Initial program 100.0%
*-commutative100.0%
associate-*l/100.0%
Applied egg-rr100.0%
Taylor expanded in y around 0 2.7%
Taylor expanded in x around 0 20.0%
distribute-rgt-in20.0%
*-lft-identity20.0%
associate-*l*20.0%
unpow220.0%
unpow320.0%
Simplified20.0%
Taylor expanded in x around inf 19.7%
Final simplification55.8%
(FPCore (x y) :precision binary64 (if (<= y 2.65e+19) (sin x) (* x (+ 1.0 (* 0.16666666666666666 (pow y 2.0))))))
double code(double x, double y) {
double tmp;
if (y <= 2.65e+19) {
tmp = sin(x);
} else {
tmp = x * (1.0 + (0.16666666666666666 * pow(y, 2.0)));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 2.65d+19) then
tmp = sin(x)
else
tmp = x * (1.0d0 + (0.16666666666666666d0 * (y ** 2.0d0)))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 2.65e+19) {
tmp = Math.sin(x);
} else {
tmp = x * (1.0 + (0.16666666666666666 * Math.pow(y, 2.0)));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 2.65e+19: tmp = math.sin(x) else: tmp = x * (1.0 + (0.16666666666666666 * math.pow(y, 2.0))) return tmp
function code(x, y) tmp = 0.0 if (y <= 2.65e+19) tmp = sin(x); else tmp = Float64(x * Float64(1.0 + Float64(0.16666666666666666 * (y ^ 2.0)))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 2.65e+19) tmp = sin(x); else tmp = x * (1.0 + (0.16666666666666666 * (y ^ 2.0))); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 2.65e+19], N[Sin[x], $MachinePrecision], N[(x * N[(1.0 + N[(0.16666666666666666 * N[Power[y, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.65 \cdot 10^{+19}:\\
\;\;\;\;\sin x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 + 0.16666666666666666 \cdot {y}^{2}\right)\\
\end{array}
\end{array}
if y < 2.65e19Initial program 100.0%
Taylor expanded in y around 0 64.9%
if 2.65e19 < y Initial program 100.0%
Taylor expanded in y around 0 61.4%
associate-*r*61.4%
Simplified61.4%
Taylor expanded in x around 0 58.7%
Final simplification63.5%
(FPCore (x y) :precision binary64 (if (<= y 4.2e+15) (sin x) (* 0.16666666666666666 (* x (pow y 2.0)))))
double code(double x, double y) {
double tmp;
if (y <= 4.2e+15) {
tmp = sin(x);
} else {
tmp = 0.16666666666666666 * (x * pow(y, 2.0));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 4.2d+15) then
tmp = sin(x)
else
tmp = 0.16666666666666666d0 * (x * (y ** 2.0d0))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 4.2e+15) {
tmp = Math.sin(x);
} else {
tmp = 0.16666666666666666 * (x * Math.pow(y, 2.0));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 4.2e+15: tmp = math.sin(x) else: tmp = 0.16666666666666666 * (x * math.pow(y, 2.0)) return tmp
function code(x, y) tmp = 0.0 if (y <= 4.2e+15) tmp = sin(x); else tmp = Float64(0.16666666666666666 * Float64(x * (y ^ 2.0))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 4.2e+15) tmp = sin(x); else tmp = 0.16666666666666666 * (x * (y ^ 2.0)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 4.2e+15], N[Sin[x], $MachinePrecision], N[(0.16666666666666666 * N[(x * N[Power[y, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.2 \cdot 10^{+15}:\\
\;\;\;\;\sin x\\
\mathbf{else}:\\
\;\;\;\;0.16666666666666666 \cdot \left(x \cdot {y}^{2}\right)\\
\end{array}
\end{array}
if y < 4.2e15Initial program 100.0%
Taylor expanded in y around 0 64.9%
if 4.2e15 < y Initial program 100.0%
Taylor expanded in y around 0 61.4%
associate-*r*61.4%
Simplified61.4%
Taylor expanded in x around 0 58.7%
Taylor expanded in y around inf 58.7%
Final simplification63.5%
(FPCore (x y) :precision binary64 (if (<= y 2.95e+17) (sin x) (/ (* x y) y)))
double code(double x, double y) {
double tmp;
if (y <= 2.95e+17) {
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 <= 2.95d+17) 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 <= 2.95e+17) {
tmp = Math.sin(x);
} else {
tmp = (x * y) / y;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 2.95e+17: tmp = math.sin(x) else: tmp = (x * y) / y return tmp
function code(x, y) tmp = 0.0 if (y <= 2.95e+17) 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 <= 2.95e+17) tmp = sin(x); else tmp = (x * y) / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 2.95e+17], N[Sin[x], $MachinePrecision], N[(N[(x * y), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.95 \cdot 10^{+17}:\\
\;\;\;\;\sin x\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{y}\\
\end{array}
\end{array}
if y < 2.95e17Initial program 100.0%
Taylor expanded in y around 0 64.9%
if 2.95e17 < y Initial program 100.0%
*-commutative100.0%
associate-*l/100.0%
Applied egg-rr100.0%
Taylor expanded in y around 0 2.7%
Taylor expanded in x around 0 24.3%
Final simplification55.8%
(FPCore (x y) :precision binary64 (if (<= y 2e+36) x (/ (* x y) y)))
double code(double x, double y) {
double tmp;
if (y <= 2e+36) {
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 <= 2d+36) 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 <= 2e+36) {
tmp = x;
} else {
tmp = (x * y) / y;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 2e+36: tmp = x else: tmp = (x * y) / y return tmp
function code(x, y) tmp = 0.0 if (y <= 2e+36) tmp = x; else tmp = Float64(Float64(x * y) / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 2e+36) tmp = x; else tmp = (x * y) / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 2e+36], x, N[(N[(x * y), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2 \cdot 10^{+36}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{y}\\
\end{array}
\end{array}
if y < 2.00000000000000008e36Initial program 100.0%
Taylor expanded in y around 0 80.6%
associate-*r*80.6%
Simplified80.6%
Taylor expanded in x around 0 46.0%
Taylor expanded in y around 0 32.4%
if 2.00000000000000008e36 < y Initial program 100.0%
*-commutative100.0%
associate-*l/100.0%
Applied egg-rr100.0%
Taylor expanded in y around 0 2.7%
Taylor expanded in x around 0 24.6%
Final simplification30.7%
(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%
Taylor expanded in y around 0 76.6%
associate-*r*76.6%
Simplified76.6%
Taylor expanded in x around 0 49.0%
Taylor expanded in y around 0 26.0%
Final simplification26.0%
herbie shell --seed 2024079
(FPCore (x y)
:name "Linear.Quaternion:$ccos from linear-1.19.1.3"
:precision binary64
(* (sin x) (/ (sinh y) y)))