
(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%
(FPCore (x y) :precision binary64 (if (<= y 115000.0) (sin x) (* x (/ (sinh y) y))))
double code(double x, double y) {
double tmp;
if (y <= 115000.0) {
tmp = sin(x);
} else {
tmp = x * (sinh(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 <= 115000.0d0) then
tmp = sin(x)
else
tmp = x * (sinh(y) / y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 115000.0) {
tmp = Math.sin(x);
} else {
tmp = x * (Math.sinh(y) / y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 115000.0: tmp = math.sin(x) else: tmp = x * (math.sinh(y) / y) return tmp
function code(x, y) tmp = 0.0 if (y <= 115000.0) tmp = sin(x); else tmp = Float64(x * Float64(sinh(y) / y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 115000.0) tmp = sin(x); else tmp = x * (sinh(y) / y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 115000.0], N[Sin[x], $MachinePrecision], N[(x * N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 115000:\\
\;\;\;\;\sin x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{\sinh y}{y}\\
\end{array}
\end{array}
if y < 115000Initial program 100.0%
Taylor expanded in y around 0 65.0%
if 115000 < y Initial program 100.0%
Taylor expanded in x around 0 75.0%
(FPCore (x y) :precision binary64 (if (<= y 680.0) (sin x) (* x (+ 1.0 (* (/ (* x (* x y)) y) -0.16666666666666666)))))
double code(double x, double y) {
double tmp;
if (y <= 680.0) {
tmp = sin(x);
} else {
tmp = x * (1.0 + (((x * (x * y)) / y) * -0.16666666666666666));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 680.0d0) then
tmp = sin(x)
else
tmp = x * (1.0d0 + (((x * (x * y)) / y) * (-0.16666666666666666d0)))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 680.0) {
tmp = Math.sin(x);
} else {
tmp = x * (1.0 + (((x * (x * y)) / y) * -0.16666666666666666));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 680.0: tmp = math.sin(x) else: tmp = x * (1.0 + (((x * (x * y)) / y) * -0.16666666666666666)) return tmp
function code(x, y) tmp = 0.0 if (y <= 680.0) tmp = sin(x); else tmp = Float64(x * Float64(1.0 + Float64(Float64(Float64(x * Float64(x * y)) / y) * -0.16666666666666666))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 680.0) tmp = sin(x); else tmp = x * (1.0 + (((x * (x * y)) / y) * -0.16666666666666666)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 680.0], N[Sin[x], $MachinePrecision], N[(x * N[(1.0 + N[(N[(N[(x * N[(x * y), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 680:\\
\;\;\;\;\sin x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 + \frac{x \cdot \left(x \cdot y\right)}{y} \cdot -0.16666666666666666\right)\\
\end{array}
\end{array}
if y < 680Initial program 100.0%
Taylor expanded in y around 0 65.3%
if 680 < y Initial program 100.0%
Taylor expanded in y around 0 2.7%
Taylor expanded in x around 0 21.5%
*-commutative21.5%
Simplified21.5%
unpow221.5%
Applied egg-rr21.5%
*-un-lft-identity21.5%
associate-*r*21.5%
*-inverses21.5%
associate-/l*22.9%
associate-*l/24.4%
*-commutative24.4%
Applied egg-rr24.4%
Final simplification54.9%
(FPCore (x y) :precision binary64 (if (<= y 2.9e+182) (* x (+ 1.0 (* -0.16666666666666666 (* x x)))) (/ (* x y) y)))
double code(double x, double y) {
double tmp;
if (y <= 2.9e+182) {
tmp = x * (1.0 + (-0.16666666666666666 * (x * 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.9d+182) then
tmp = x * (1.0d0 + ((-0.16666666666666666d0) * (x * 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.9e+182) {
tmp = x * (1.0 + (-0.16666666666666666 * (x * x)));
} else {
tmp = (x * y) / y;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 2.9e+182: tmp = x * (1.0 + (-0.16666666666666666 * (x * x))) else: tmp = (x * y) / y return tmp
function code(x, y) tmp = 0.0 if (y <= 2.9e+182) tmp = Float64(x * Float64(1.0 + Float64(-0.16666666666666666 * Float64(x * x)))); else tmp = Float64(Float64(x * y) / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 2.9e+182) tmp = x * (1.0 + (-0.16666666666666666 * (x * x))); else tmp = (x * y) / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 2.9e+182], N[(x * N[(1.0 + N[(-0.16666666666666666 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * y), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.9 \cdot 10^{+182}:\\
\;\;\;\;x \cdot \left(1 + -0.16666666666666666 \cdot \left(x \cdot x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{y}\\
\end{array}
\end{array}
if y < 2.8999999999999998e182Initial program 100.0%
Taylor expanded in y around 0 54.7%
Taylor expanded in x around 0 40.7%
*-commutative40.7%
Simplified40.7%
unpow240.7%
Applied egg-rr40.7%
if 2.8999999999999998e182 < y Initial program 100.0%
add-log-exp100.0%
*-un-lft-identity100.0%
log-prod100.0%
metadata-eval100.0%
add-log-exp100.0%
Applied egg-rr100.0%
+-lft-identity100.0%
associate-*r/100.0%
Simplified100.0%
Taylor expanded in y around 0 2.5%
Taylor expanded in x around 0 16.9%
Final simplification38.3%
(FPCore (x y) :precision binary64 (* x (+ 1.0 (* (/ (* x (* x y)) y) -0.16666666666666666))))
double code(double x, double y) {
return x * (1.0 + (((x * (x * y)) / y) * -0.16666666666666666));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x * (1.0d0 + (((x * (x * y)) / y) * (-0.16666666666666666d0)))
end function
public static double code(double x, double y) {
return x * (1.0 + (((x * (x * y)) / y) * -0.16666666666666666));
}
def code(x, y): return x * (1.0 + (((x * (x * y)) / y) * -0.16666666666666666))
function code(x, y) return Float64(x * Float64(1.0 + Float64(Float64(Float64(x * Float64(x * y)) / y) * -0.16666666666666666))) end
function tmp = code(x, y) tmp = x * (1.0 + (((x * (x * y)) / y) * -0.16666666666666666)); end
code[x_, y_] := N[(x * N[(1.0 + N[(N[(N[(x * N[(x * y), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(1 + \frac{x \cdot \left(x \cdot y\right)}{y} \cdot -0.16666666666666666\right)
\end{array}
Initial program 100.0%
Taylor expanded in y around 0 49.4%
Taylor expanded in x around 0 37.6%
*-commutative37.6%
Simplified37.6%
unpow237.6%
Applied egg-rr37.6%
*-un-lft-identity37.6%
associate-*r*37.6%
*-inverses37.6%
associate-/l*37.9%
associate-*l/39.0%
*-commutative39.0%
Applied egg-rr39.0%
Final simplification39.0%
(FPCore (x y) :precision binary64 (if (<= x 1.25e+82) x (* (* x y) (/ 1.0 y))))
double code(double x, double y) {
double tmp;
if (x <= 1.25e+82) {
tmp = x;
} else {
tmp = (x * y) * (1.0 / y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= 1.25d+82) then
tmp = x
else
tmp = (x * y) * (1.0d0 / y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= 1.25e+82) {
tmp = x;
} else {
tmp = (x * y) * (1.0 / y);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 1.25e+82: tmp = x else: tmp = (x * y) * (1.0 / y) return tmp
function code(x, y) tmp = 0.0 if (x <= 1.25e+82) tmp = x; else tmp = Float64(Float64(x * y) * Float64(1.0 / y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 1.25e+82) tmp = x; else tmp = (x * y) * (1.0 / y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 1.25e+82], x, N[(N[(x * y), $MachinePrecision] * N[(1.0 / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.25 \cdot 10^{+82}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot y\right) \cdot \frac{1}{y}\\
\end{array}
\end{array}
if x < 1.25000000000000004e82Initial program 100.0%
Taylor expanded in x around 0 76.3%
Taylor expanded in y around 0 35.8%
if 1.25000000000000004e82 < x Initial program 100.0%
add-log-exp99.7%
*-un-lft-identity99.7%
log-prod99.7%
metadata-eval99.7%
add-log-exp100.0%
Applied egg-rr100.0%
+-lft-identity100.0%
associate-*r/100.0%
Simplified100.0%
Taylor expanded in y around 0 43.6%
Taylor expanded in x around 0 22.6%
clear-num22.6%
associate-/r/22.6%
*-commutative22.6%
Applied egg-rr22.6%
Final simplification33.6%
(FPCore (x y) :precision binary64 (if (<= x 1e+79) x (/ (* x y) y)))
double code(double x, double y) {
double tmp;
if (x <= 1e+79) {
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 <= 1d+79) 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 <= 1e+79) {
tmp = x;
} else {
tmp = (x * y) / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 1e+79: tmp = x else: tmp = (x * y) / y return tmp
function code(x, y) tmp = 0.0 if (x <= 1e+79) tmp = x; else tmp = Float64(Float64(x * y) / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 1e+79) tmp = x; else tmp = (x * y) / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 1e+79], x, N[(N[(x * y), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 10^{+79}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{y}\\
\end{array}
\end{array}
if x < 9.99999999999999967e78Initial program 100.0%
Taylor expanded in x around 0 76.3%
Taylor expanded in y around 0 35.8%
if 9.99999999999999967e78 < x Initial program 100.0%
add-log-exp99.7%
*-un-lft-identity99.7%
log-prod99.7%
metadata-eval99.7%
add-log-exp100.0%
Applied egg-rr100.0%
+-lft-identity100.0%
associate-*r/100.0%
Simplified100.0%
Taylor expanded in y around 0 43.6%
Taylor expanded in x around 0 22.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 x around 0 68.4%
Taylor expanded in y around 0 30.3%
herbie shell --seed 2024170
(FPCore (x y)
:name "Linear.Quaternion:$ccos from linear-1.19.1.3"
:precision binary64
(* (sin x) (/ (sinh y) y)))