
(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 8 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 600.0)
(sin x)
(if (<= y 1.05e+80)
(+ (* -0.16666666666666666 (/ (pow x 3.0) y)) (/ x y))
(* x (+ 1.0 (* 0.16666666666666666 (pow y 2.0)))))))
double code(double x, double y) {
double tmp;
if (y <= 600.0) {
tmp = sin(x);
} else if (y <= 1.05e+80) {
tmp = (-0.16666666666666666 * (pow(x, 3.0) / y)) + (x / y);
} 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 <= 600.0d0) then
tmp = sin(x)
else if (y <= 1.05d+80) then
tmp = ((-0.16666666666666666d0) * ((x ** 3.0d0) / y)) + (x / y)
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 <= 600.0) {
tmp = Math.sin(x);
} else if (y <= 1.05e+80) {
tmp = (-0.16666666666666666 * (Math.pow(x, 3.0) / y)) + (x / y);
} else {
tmp = x * (1.0 + (0.16666666666666666 * Math.pow(y, 2.0)));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 600.0: tmp = math.sin(x) elif y <= 1.05e+80: tmp = (-0.16666666666666666 * (math.pow(x, 3.0) / y)) + (x / y) else: tmp = x * (1.0 + (0.16666666666666666 * math.pow(y, 2.0))) return tmp
function code(x, y) tmp = 0.0 if (y <= 600.0) tmp = sin(x); elseif (y <= 1.05e+80) tmp = Float64(Float64(-0.16666666666666666 * Float64((x ^ 3.0) / y)) + Float64(x / y)); 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 <= 600.0) tmp = sin(x); elseif (y <= 1.05e+80) tmp = (-0.16666666666666666 * ((x ^ 3.0) / y)) + (x / y); else tmp = x * (1.0 + (0.16666666666666666 * (y ^ 2.0))); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 600.0], N[Sin[x], $MachinePrecision], If[LessEqual[y, 1.05e+80], N[(N[(-0.16666666666666666 * N[(N[Power[x, 3.0], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] + N[(x / y), $MachinePrecision]), $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 600:\\
\;\;\;\;\sin x\\
\mathbf{elif}\;y \leq 1.05 \cdot 10^{+80}:\\
\;\;\;\;-0.16666666666666666 \cdot \frac{{x}^{3}}{y} + \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 + 0.16666666666666666 \cdot {y}^{2}\right)\\
\end{array}
\end{array}
if y < 600Initial program 100.0%
Taylor expanded in y around 0 64.4%
if 600 < y < 1.05000000000000001e80Initial program 100.0%
Taylor expanded in y around inf 100.0%
rec-exp100.0%
Simplified100.0%
Applied egg-rr2.5%
Taylor expanded in x around 0 33.2%
distribute-rgt-in33.2%
associate-*l*33.2%
associate-*l/33.2%
unpow233.2%
unpow333.2%
associate-*l/33.2%
*-lft-identity33.2%
Simplified33.2%
if 1.05000000000000001e80 < y Initial program 100.0%
Taylor expanded in y around 0 70.3%
Taylor expanded in x around 0 55.2%
*-commutative55.2%
*-commutative55.2%
associate-*l*55.2%
Simplified55.2%
Taylor expanded in x around 0 55.2%
Final simplification60.8%
(FPCore (x y)
:precision binary64
(if (<= y 210000000000.0)
(sin x)
(if (<= y 7.8e+80)
(* -0.16666666666666666 (/ (pow x 3.0) y))
(* x (+ 1.0 (* 0.16666666666666666 (pow y 2.0)))))))
double code(double x, double y) {
double tmp;
if (y <= 210000000000.0) {
tmp = sin(x);
} else if (y <= 7.8e+80) {
tmp = -0.16666666666666666 * (pow(x, 3.0) / y);
} 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 <= 210000000000.0d0) then
tmp = sin(x)
else if (y <= 7.8d+80) then
tmp = (-0.16666666666666666d0) * ((x ** 3.0d0) / y)
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 <= 210000000000.0) {
tmp = Math.sin(x);
} else if (y <= 7.8e+80) {
tmp = -0.16666666666666666 * (Math.pow(x, 3.0) / y);
} else {
tmp = x * (1.0 + (0.16666666666666666 * Math.pow(y, 2.0)));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 210000000000.0: tmp = math.sin(x) elif y <= 7.8e+80: tmp = -0.16666666666666666 * (math.pow(x, 3.0) / y) else: tmp = x * (1.0 + (0.16666666666666666 * math.pow(y, 2.0))) return tmp
function code(x, y) tmp = 0.0 if (y <= 210000000000.0) tmp = sin(x); elseif (y <= 7.8e+80) tmp = Float64(-0.16666666666666666 * Float64((x ^ 3.0) / y)); 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 <= 210000000000.0) tmp = sin(x); elseif (y <= 7.8e+80) tmp = -0.16666666666666666 * ((x ^ 3.0) / y); else tmp = x * (1.0 + (0.16666666666666666 * (y ^ 2.0))); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 210000000000.0], N[Sin[x], $MachinePrecision], If[LessEqual[y, 7.8e+80], N[(-0.16666666666666666 * N[(N[Power[x, 3.0], $MachinePrecision] / y), $MachinePrecision]), $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 210000000000:\\
\;\;\;\;\sin x\\
\mathbf{elif}\;y \leq 7.8 \cdot 10^{+80}:\\
\;\;\;\;-0.16666666666666666 \cdot \frac{{x}^{3}}{y}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 + 0.16666666666666666 \cdot {y}^{2}\right)\\
\end{array}
\end{array}
if y < 2.1e11Initial program 100.0%
Taylor expanded in y around 0 64.1%
if 2.1e11 < y < 7.79999999999999998e80Initial program 100.0%
Taylor expanded in y around inf 100.0%
rec-exp100.0%
Simplified100.0%
Applied egg-rr2.5%
Taylor expanded in x around 0 35.1%
distribute-rgt-in35.1%
associate-*l*35.1%
associate-*l/35.1%
unpow235.1%
unpow335.1%
associate-*l/35.1%
*-lft-identity35.1%
Simplified35.1%
Taylor expanded in x around inf 35.0%
if 7.79999999999999998e80 < y Initial program 100.0%
Taylor expanded in y around 0 70.3%
Taylor expanded in x around 0 55.2%
*-commutative55.2%
*-commutative55.2%
associate-*l*55.2%
Simplified55.2%
Taylor expanded in x around 0 55.2%
Final simplification60.7%
(FPCore (x y)
:precision binary64
(if (<= y 520.0)
(sin x)
(if (<= y 3e+84)
(/ (+ x (* -0.16666666666666666 (pow x 3.0))) y)
(* x (+ 1.0 (* 0.16666666666666666 (pow y 2.0)))))))
double code(double x, double y) {
double tmp;
if (y <= 520.0) {
tmp = sin(x);
} else if (y <= 3e+84) {
tmp = (x + (-0.16666666666666666 * pow(x, 3.0))) / y;
} 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 <= 520.0d0) then
tmp = sin(x)
else if (y <= 3d+84) then
tmp = (x + ((-0.16666666666666666d0) * (x ** 3.0d0))) / y
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 <= 520.0) {
tmp = Math.sin(x);
} else if (y <= 3e+84) {
tmp = (x + (-0.16666666666666666 * Math.pow(x, 3.0))) / y;
} else {
tmp = x * (1.0 + (0.16666666666666666 * Math.pow(y, 2.0)));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 520.0: tmp = math.sin(x) elif y <= 3e+84: tmp = (x + (-0.16666666666666666 * math.pow(x, 3.0))) / y else: tmp = x * (1.0 + (0.16666666666666666 * math.pow(y, 2.0))) return tmp
function code(x, y) tmp = 0.0 if (y <= 520.0) tmp = sin(x); elseif (y <= 3e+84) tmp = Float64(Float64(x + Float64(-0.16666666666666666 * (x ^ 3.0))) / y); 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 <= 520.0) tmp = sin(x); elseif (y <= 3e+84) tmp = (x + (-0.16666666666666666 * (x ^ 3.0))) / y; else tmp = x * (1.0 + (0.16666666666666666 * (y ^ 2.0))); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 520.0], N[Sin[x], $MachinePrecision], If[LessEqual[y, 3e+84], N[(N[(x + N[(-0.16666666666666666 * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y), $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 520:\\
\;\;\;\;\sin x\\
\mathbf{elif}\;y \leq 3 \cdot 10^{+84}:\\
\;\;\;\;\frac{x + -0.16666666666666666 \cdot {x}^{3}}{y}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 + 0.16666666666666666 \cdot {y}^{2}\right)\\
\end{array}
\end{array}
if y < 520Initial program 100.0%
Taylor expanded in y around 0 64.4%
if 520 < y < 2.99999999999999996e84Initial program 100.0%
Taylor expanded in y around inf 100.0%
rec-exp100.0%
Simplified100.0%
Applied egg-rr2.5%
Taylor expanded in x around 0 33.2%
distribute-rgt-in33.2%
associate-*l*33.2%
associate-*l/33.2%
unpow233.2%
unpow333.2%
associate-*l/33.2%
*-lft-identity33.2%
Simplified33.2%
Taylor expanded in y around 0 33.2%
if 2.99999999999999996e84 < y Initial program 100.0%
Taylor expanded in y around 0 70.3%
Taylor expanded in x around 0 55.2%
*-commutative55.2%
*-commutative55.2%
associate-*l*55.2%
Simplified55.2%
Taylor expanded in x around 0 55.2%
Final simplification60.8%
(FPCore (x y)
:precision binary64
(if (<= y 210000000000.0)
(sin x)
(if (<= y 1.32e+83)
(* -0.16666666666666666 (/ (pow x 3.0) y))
(* 0.16666666666666666 (* x (pow y 2.0))))))
double code(double x, double y) {
double tmp;
if (y <= 210000000000.0) {
tmp = sin(x);
} else if (y <= 1.32e+83) {
tmp = -0.16666666666666666 * (pow(x, 3.0) / y);
} 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 <= 210000000000.0d0) then
tmp = sin(x)
else if (y <= 1.32d+83) then
tmp = (-0.16666666666666666d0) * ((x ** 3.0d0) / y)
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 <= 210000000000.0) {
tmp = Math.sin(x);
} else if (y <= 1.32e+83) {
tmp = -0.16666666666666666 * (Math.pow(x, 3.0) / y);
} else {
tmp = 0.16666666666666666 * (x * Math.pow(y, 2.0));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 210000000000.0: tmp = math.sin(x) elif y <= 1.32e+83: tmp = -0.16666666666666666 * (math.pow(x, 3.0) / y) else: tmp = 0.16666666666666666 * (x * math.pow(y, 2.0)) return tmp
function code(x, y) tmp = 0.0 if (y <= 210000000000.0) tmp = sin(x); elseif (y <= 1.32e+83) tmp = Float64(-0.16666666666666666 * Float64((x ^ 3.0) / y)); 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 <= 210000000000.0) tmp = sin(x); elseif (y <= 1.32e+83) tmp = -0.16666666666666666 * ((x ^ 3.0) / y); else tmp = 0.16666666666666666 * (x * (y ^ 2.0)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 210000000000.0], N[Sin[x], $MachinePrecision], If[LessEqual[y, 1.32e+83], N[(-0.16666666666666666 * N[(N[Power[x, 3.0], $MachinePrecision] / y), $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 210000000000:\\
\;\;\;\;\sin x\\
\mathbf{elif}\;y \leq 1.32 \cdot 10^{+83}:\\
\;\;\;\;-0.16666666666666666 \cdot \frac{{x}^{3}}{y}\\
\mathbf{else}:\\
\;\;\;\;0.16666666666666666 \cdot \left(x \cdot {y}^{2}\right)\\
\end{array}
\end{array}
if y < 2.1e11Initial program 100.0%
Taylor expanded in y around 0 64.1%
if 2.1e11 < y < 1.3199999999999999e83Initial program 100.0%
Taylor expanded in y around inf 100.0%
rec-exp100.0%
Simplified100.0%
Applied egg-rr2.5%
Taylor expanded in x around 0 35.1%
distribute-rgt-in35.1%
associate-*l*35.1%
associate-*l/35.1%
unpow235.1%
unpow335.1%
associate-*l/35.1%
*-lft-identity35.1%
Simplified35.1%
Taylor expanded in x around inf 35.0%
if 1.3199999999999999e83 < y Initial program 100.0%
Taylor expanded in y around 0 70.3%
Taylor expanded in x around 0 55.2%
*-commutative55.2%
*-commutative55.2%
associate-*l*55.2%
Simplified55.2%
+-commutative55.2%
*-commutative55.2%
unpow255.2%
associate-*r*32.0%
fma-define32.0%
Applied egg-rr32.0%
Taylor expanded in x around inf 55.2%
Final simplification60.7%
(FPCore (x y) :precision binary64 (if (<= y 210000000000.0) (sin x) (* -0.16666666666666666 (/ (pow x 3.0) y))))
double code(double x, double y) {
double tmp;
if (y <= 210000000000.0) {
tmp = sin(x);
} else {
tmp = -0.16666666666666666 * (pow(x, 3.0) / y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 210000000000.0d0) then
tmp = sin(x)
else
tmp = (-0.16666666666666666d0) * ((x ** 3.0d0) / y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 210000000000.0) {
tmp = Math.sin(x);
} else {
tmp = -0.16666666666666666 * (Math.pow(x, 3.0) / y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 210000000000.0: tmp = math.sin(x) else: tmp = -0.16666666666666666 * (math.pow(x, 3.0) / y) return tmp
function code(x, y) tmp = 0.0 if (y <= 210000000000.0) tmp = sin(x); else tmp = Float64(-0.16666666666666666 * Float64((x ^ 3.0) / y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 210000000000.0) tmp = sin(x); else tmp = -0.16666666666666666 * ((x ^ 3.0) / y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 210000000000.0], N[Sin[x], $MachinePrecision], N[(-0.16666666666666666 * N[(N[Power[x, 3.0], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 210000000000:\\
\;\;\;\;\sin x\\
\mathbf{else}:\\
\;\;\;\;-0.16666666666666666 \cdot \frac{{x}^{3}}{y}\\
\end{array}
\end{array}
if y < 2.1e11Initial program 100.0%
Taylor expanded in y around 0 64.1%
if 2.1e11 < y Initial program 100.0%
Taylor expanded in y around inf 100.0%
rec-exp100.0%
Simplified100.0%
Applied egg-rr2.0%
Taylor expanded in x around 0 12.8%
distribute-rgt-in12.8%
associate-*l*12.8%
associate-*l/12.8%
unpow212.8%
unpow312.8%
associate-*l/12.8%
*-lft-identity12.8%
Simplified12.8%
Taylor expanded in x around inf 12.7%
Final simplification51.5%
(FPCore (x y) :precision binary64 (sin x))
double code(double x, double y) {
return sin(x);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sin(x)
end function
public static double code(double x, double y) {
return Math.sin(x);
}
def code(x, y): return math.sin(x)
function code(x, y) return sin(x) end
function tmp = code(x, y) tmp = sin(x); end
code[x_, y_] := N[Sin[x], $MachinePrecision]
\begin{array}{l}
\\
\sin x
\end{array}
Initial program 100.0%
Taylor expanded in y around 0 49.0%
Final simplification49.0%
(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 72.3%
Taylor expanded in x around 0 60.6%
*-commutative60.6%
*-commutative60.6%
associate-*l*60.6%
Simplified60.6%
Taylor expanded in x around 0 44.2%
Taylor expanded in y around 0 25.0%
Final simplification25.0%
herbie shell --seed 2024096
(FPCore (x y)
:name "Linear.Quaternion:$ccos from linear-1.19.1.3"
:precision binary64
(* (sin x) (/ (sinh y) y)))