
(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 3.8e+36)
(sin x)
(if (or (<= y 9.5e+108) (and (not (<= y 7.62e+196)) (<= y 1.4e+208)))
(+ x (* -0.16666666666666666 (pow x 3.0)))
(* 0.16666666666666666 (* x (pow y 2.0))))))
double code(double x, double y) {
double tmp;
if (y <= 3.8e+36) {
tmp = sin(x);
} else if ((y <= 9.5e+108) || (!(y <= 7.62e+196) && (y <= 1.4e+208))) {
tmp = x + (-0.16666666666666666 * pow(x, 3.0));
} 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 <= 3.8d+36) then
tmp = sin(x)
else if ((y <= 9.5d+108) .or. (.not. (y <= 7.62d+196)) .and. (y <= 1.4d+208)) then
tmp = x + ((-0.16666666666666666d0) * (x ** 3.0d0))
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 <= 3.8e+36) {
tmp = Math.sin(x);
} else if ((y <= 9.5e+108) || (!(y <= 7.62e+196) && (y <= 1.4e+208))) {
tmp = x + (-0.16666666666666666 * Math.pow(x, 3.0));
} else {
tmp = 0.16666666666666666 * (x * Math.pow(y, 2.0));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 3.8e+36: tmp = math.sin(x) elif (y <= 9.5e+108) or (not (y <= 7.62e+196) and (y <= 1.4e+208)): tmp = x + (-0.16666666666666666 * math.pow(x, 3.0)) else: tmp = 0.16666666666666666 * (x * math.pow(y, 2.0)) return tmp
function code(x, y) tmp = 0.0 if (y <= 3.8e+36) tmp = sin(x); elseif ((y <= 9.5e+108) || (!(y <= 7.62e+196) && (y <= 1.4e+208))) tmp = Float64(x + Float64(-0.16666666666666666 * (x ^ 3.0))); 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 <= 3.8e+36) tmp = sin(x); elseif ((y <= 9.5e+108) || (~((y <= 7.62e+196)) && (y <= 1.4e+208))) tmp = x + (-0.16666666666666666 * (x ^ 3.0)); else tmp = 0.16666666666666666 * (x * (y ^ 2.0)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 3.8e+36], N[Sin[x], $MachinePrecision], If[Or[LessEqual[y, 9.5e+108], And[N[Not[LessEqual[y, 7.62e+196]], $MachinePrecision], LessEqual[y, 1.4e+208]]], N[(x + N[(-0.16666666666666666 * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.16666666666666666 * N[(x * N[Power[y, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.8 \cdot 10^{+36}:\\
\;\;\;\;\sin x\\
\mathbf{elif}\;y \leq 9.5 \cdot 10^{+108} \lor \neg \left(y \leq 7.62 \cdot 10^{+196}\right) \land y \leq 1.4 \cdot 10^{+208}:\\
\;\;\;\;x + -0.16666666666666666 \cdot {x}^{3}\\
\mathbf{else}:\\
\;\;\;\;0.16666666666666666 \cdot \left(x \cdot {y}^{2}\right)\\
\end{array}
\end{array}
if y < 3.80000000000000025e36Initial program 100.0%
Taylor expanded in y around 0 64.3%
if 3.80000000000000025e36 < y < 9.50000000000000097e108 or 7.6199999999999996e196 < y < 1.40000000000000011e208Initial 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 29.8%
distribute-rgt-in29.8%
*-lft-identity29.8%
associate-*l*29.8%
unpow229.8%
unpow329.8%
Simplified29.8%
if 9.50000000000000097e108 < y < 7.6199999999999996e196 or 1.40000000000000011e208 < y Initial program 100.0%
Taylor expanded in y around 0 77.5%
Taylor expanded in x around 0 56.1%
Taylor expanded in y around inf 56.1%
Final simplification60.3%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ x (* -0.16666666666666666 (pow x 3.0)))))
(if (<= y 3.8e+36)
(sin x)
(if (<= y 8.6e+108)
t_0
(if (<= y 7.62e+196)
(* x (+ 1.0 (* 0.16666666666666666 (pow y 2.0))))
(if (<= y 1.4e+208)
t_0
(* 0.16666666666666666 (* x (pow y 2.0)))))))))
double code(double x, double y) {
double t_0 = x + (-0.16666666666666666 * pow(x, 3.0));
double tmp;
if (y <= 3.8e+36) {
tmp = sin(x);
} else if (y <= 8.6e+108) {
tmp = t_0;
} else if (y <= 7.62e+196) {
tmp = x * (1.0 + (0.16666666666666666 * pow(y, 2.0)));
} else if (y <= 1.4e+208) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = x + ((-0.16666666666666666d0) * (x ** 3.0d0))
if (y <= 3.8d+36) then
tmp = sin(x)
else if (y <= 8.6d+108) then
tmp = t_0
else if (y <= 7.62d+196) then
tmp = x * (1.0d0 + (0.16666666666666666d0 * (y ** 2.0d0)))
else if (y <= 1.4d+208) then
tmp = t_0
else
tmp = 0.16666666666666666d0 * (x * (y ** 2.0d0))
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = x + (-0.16666666666666666 * Math.pow(x, 3.0));
double tmp;
if (y <= 3.8e+36) {
tmp = Math.sin(x);
} else if (y <= 8.6e+108) {
tmp = t_0;
} else if (y <= 7.62e+196) {
tmp = x * (1.0 + (0.16666666666666666 * Math.pow(y, 2.0)));
} else if (y <= 1.4e+208) {
tmp = t_0;
} else {
tmp = 0.16666666666666666 * (x * Math.pow(y, 2.0));
}
return tmp;
}
def code(x, y): t_0 = x + (-0.16666666666666666 * math.pow(x, 3.0)) tmp = 0 if y <= 3.8e+36: tmp = math.sin(x) elif y <= 8.6e+108: tmp = t_0 elif y <= 7.62e+196: tmp = x * (1.0 + (0.16666666666666666 * math.pow(y, 2.0))) elif y <= 1.4e+208: tmp = t_0 else: tmp = 0.16666666666666666 * (x * math.pow(y, 2.0)) return tmp
function code(x, y) t_0 = Float64(x + Float64(-0.16666666666666666 * (x ^ 3.0))) tmp = 0.0 if (y <= 3.8e+36) tmp = sin(x); elseif (y <= 8.6e+108) tmp = t_0; elseif (y <= 7.62e+196) tmp = Float64(x * Float64(1.0 + Float64(0.16666666666666666 * (y ^ 2.0)))); elseif (y <= 1.4e+208) tmp = t_0; else tmp = Float64(0.16666666666666666 * Float64(x * (y ^ 2.0))); end return tmp end
function tmp_2 = code(x, y) t_0 = x + (-0.16666666666666666 * (x ^ 3.0)); tmp = 0.0; if (y <= 3.8e+36) tmp = sin(x); elseif (y <= 8.6e+108) tmp = t_0; elseif (y <= 7.62e+196) tmp = x * (1.0 + (0.16666666666666666 * (y ^ 2.0))); elseif (y <= 1.4e+208) tmp = t_0; else tmp = 0.16666666666666666 * (x * (y ^ 2.0)); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x + N[(-0.16666666666666666 * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, 3.8e+36], N[Sin[x], $MachinePrecision], If[LessEqual[y, 8.6e+108], t$95$0, If[LessEqual[y, 7.62e+196], N[(x * N[(1.0 + N[(0.16666666666666666 * N[Power[y, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.4e+208], t$95$0, N[(0.16666666666666666 * N[(x * N[Power[y, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x + -0.16666666666666666 \cdot {x}^{3}\\
\mathbf{if}\;y \leq 3.8 \cdot 10^{+36}:\\
\;\;\;\;\sin x\\
\mathbf{elif}\;y \leq 8.6 \cdot 10^{+108}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 7.62 \cdot 10^{+196}:\\
\;\;\;\;x \cdot \left(1 + 0.16666666666666666 \cdot {y}^{2}\right)\\
\mathbf{elif}\;y \leq 1.4 \cdot 10^{+208}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;0.16666666666666666 \cdot \left(x \cdot {y}^{2}\right)\\
\end{array}
\end{array}
if y < 3.80000000000000025e36Initial program 100.0%
Taylor expanded in y around 0 64.3%
if 3.80000000000000025e36 < y < 8.59999999999999993e108 or 7.6199999999999996e196 < y < 1.40000000000000011e208Initial 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 29.8%
distribute-rgt-in29.8%
*-lft-identity29.8%
associate-*l*29.8%
unpow229.8%
unpow329.8%
Simplified29.8%
if 8.59999999999999993e108 < y < 7.6199999999999996e196Initial program 100.0%
Taylor expanded in y around 0 55.1%
Taylor expanded in x around 0 49.0%
if 1.40000000000000011e208 < y Initial program 100.0%
Taylor expanded in y around 0 100.0%
Taylor expanded in x around 0 63.2%
Taylor expanded in y around inf 63.2%
Final simplification60.3%
(FPCore (x y) :precision binary64 (if (<= y 425.0) (sin x) (* 0.16666666666666666 (* x (pow y 2.0)))))
double code(double x, double y) {
double tmp;
if (y <= 425.0) {
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 <= 425.0d0) 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 <= 425.0) {
tmp = Math.sin(x);
} else {
tmp = 0.16666666666666666 * (x * Math.pow(y, 2.0));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 425.0: 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 <= 425.0) 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 <= 425.0) tmp = sin(x); else tmp = 0.16666666666666666 * (x * (y ^ 2.0)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 425.0], 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 425:\\
\;\;\;\;\sin x\\
\mathbf{else}:\\
\;\;\;\;0.16666666666666666 \cdot \left(x \cdot {y}^{2}\right)\\
\end{array}
\end{array}
if y < 425Initial program 100.0%
Taylor expanded in y around 0 65.3%
if 425 < y Initial program 100.0%
Taylor expanded in y around 0 53.6%
Taylor expanded in x around 0 38.5%
Taylor expanded in y around inf 38.5%
Final simplification58.8%
(FPCore (x y) :precision binary64 (if (<= y 7.5e+46) (sin x) (/ (* x y) y)))
double code(double x, double y) {
double tmp;
if (y <= 7.5e+46) {
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 <= 7.5d+46) 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 <= 7.5e+46) {
tmp = Math.sin(x);
} else {
tmp = (x * y) / y;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 7.5e+46: tmp = math.sin(x) else: tmp = (x * y) / y return tmp
function code(x, y) tmp = 0.0 if (y <= 7.5e+46) 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 <= 7.5e+46) tmp = sin(x); else tmp = (x * y) / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 7.5e+46], N[Sin[x], $MachinePrecision], N[(N[(x * y), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 7.5 \cdot 10^{+46}:\\
\;\;\;\;\sin x\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{y}\\
\end{array}
\end{array}
if y < 7.5000000000000003e46Initial program 100.0%
Taylor expanded in y around 0 63.7%
if 7.5000000000000003e46 < 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 12.1%
Final simplification52.2%
(FPCore (x y) :precision binary64 (if (<= x 5e+45) x (/ (* x y) y)))
double code(double x, double y) {
double tmp;
if (x <= 5e+45) {
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 (x <= 5d+45) 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 (x <= 5e+45) {
tmp = x;
} else {
tmp = (x * y) / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 5e+45: tmp = x else: tmp = (x * y) / y return tmp
function code(x, y) tmp = 0.0 if (x <= 5e+45) tmp = x; else tmp = Float64(Float64(x * y) / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 5e+45) tmp = x; else tmp = (x * y) / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 5e+45], x, N[(N[(x * y), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 5 \cdot 10^{+45}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{y}\\
\end{array}
\end{array}
if x < 5e45Initial program 100.0%
Taylor expanded in y around 0 78.4%
Taylor expanded in x around 0 51.9%
Taylor expanded in y around 0 32.3%
if 5e45 < x Initial program 100.0%
*-commutative100.0%
associate-*l/99.9%
Applied egg-rr99.9%
Taylor expanded in y around 0 46.2%
Taylor expanded in x around 0 19.8%
Final simplification29.6%
(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 77.1%
Taylor expanded in x around 0 45.8%
Taylor expanded in y around 0 26.0%
Final simplification26.0%
herbie shell --seed 2024095
(FPCore (x y)
:name "Linear.Quaternion:$ccos from linear-1.19.1.3"
:precision binary64
(* (sin x) (/ (sinh y) y)))